Skip to content

Commit

Permalink
new: Move to individual CLI commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Oct 13, 2020
1 parent dee9bd1 commit 6bd2792
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/Command.tsx → src/commands/Distribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import React from 'react';
import os from 'os';
import { Arg, Command, Config, GlobalOptions } from '@boost/cli';
import Main from './components/Main';
import Packemon from './Packemon';
import { PackemonOptions } from './types';
import Distribute from '../components/Distribute';
import Packemon from '../Packemon';
import { PackemonOptions } from '../types';

export type Options = GlobalOptions & PackemonOptions;

export type Params = [string];

@Config('packemon', 'Build standardized packages for distribution.')
export default class PackemonCommand extends Command<Options, Params> {
@Config('distribute', 'Build and prepare standardized packages for distribution.')
export default class DistributeCommand extends Command<Options, Params> {
@Arg.Flag('Add `main`, `browser`, and `exports` fields to `package.json`')
addExports: boolean = false;

Expand Down Expand Up @@ -41,6 +41,6 @@ export default class PackemonCommand extends Command<Options, Params> {
timeout: this.timeout,
});

return <Main packemon={packemon} />;
return <Distribute packemon={packemon} />;
}
}
3 changes: 2 additions & 1 deletion src/components/BundleBuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default function BundleBuilds({ artifact }: BundleBuildsProps) {
return (
<Box key={build} marginLeft={1}>
<Style bold type={STATE_COLORS[artifact.state] || 'default'}>
{figures.squareSmallFilled} {build.toLowerCase()}
{artifact.state === 'failed' ? figures.cross : figures.squareSmallFilled}{' '}
{build.toLowerCase()}
</Style>

{stats && <Style type="muted">{` (${size(stats.size)})`}</Style>}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Main.tsx → src/components/Distribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const HEADER_LABELS = {
pack: 'Packing for distribution',
};

export interface MainProps {
export interface DistributeProps {
packemon: Packemon;
}

export default function Main({ packemon }: MainProps) {
export default function Distribute({ packemon }: DistributeProps) {
const [, forceUpdate] = useReducer((count) => count + 1, 0);
const [error, setError] = useState<Error>();
const [staticPackages, setStaticPackages] = useState<Package[]>([]);
Expand Down
10 changes: 2 additions & 8 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Program } from '@boost/cli';
import Command from './Command';
import DistributeCommand from './commands/Distribute';

export async function run() {
const program = new Program({
Expand All @@ -10,13 +10,7 @@ export async function run() {
version: require('../package.json').version,
});

program
.categories({
browser: 'Browser',
global: 'Global',
node: 'Node',
})
.default(new Command());
program.register(new DistributeCommand());

await program.runAndExit(process.argv);
}

0 comments on commit 6bd2792

Please sign in to comment.