Skip to content

Commit

Permalink
fix(app-builder): remove obsolete argument
Browse files Browse the repository at this point in the history
also update descriptions and names of commands
  • Loading branch information
EdieLemoine committed Feb 22, 2023
1 parent e6fe58b commit ccf90e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
25 changes: 10 additions & 15 deletions apps/app-builder/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ const OPTION_VERBOSITY = ['-v, --verbose', 'Verbosity', (dummy: string, prev: nu

const OPTION_DRY_RUN = ['--dry-run', 'Dry run'] as const;

const ARGUMENT_PROJECT = ['[project]', 'Project name', 'all'] as const;
const REQUIRES_CONFIG_FILE = 'Requires a config file.';

// eslint-disable-next-line max-lines-per-function
export const run = (env: LiftoffEnv, argv: string[]): void => {
const withContext = createWithContext(env, argv);
const withConfig = createWithConfig(env, argv);

program.name('PDK Builder').description('Builds a plugin.');
program.name('pdk-builder').description('Builds a plugin for MyParcel.');

program
.command('init')
.description('Create a new config file')
.description(`Generate a config file in the current directory. Necessary for all other commands.`)
.option(...OPTION_VERBOSITY)
.action(withContext(init));

program
.command('all')
.description('Run all commands in sequence')
.argument(...ARGUMENT_PROJECT)
.command('build')
.description(`Run clean, copy, rename and compress in sequence. ${REQUIRES_CONFIG_FILE}`)
.option(...OPTION_DRY_RUN)
.option(...OPTION_VERBOSITY)
.action(
Expand All @@ -41,32 +40,28 @@ export const run = (env: LiftoffEnv, argv: string[]): void => {

program
.command('clean')
.description('Clean dist files')
.argument(...ARGUMENT_PROJECT)
.description(`Clear output directory. ${REQUIRES_CONFIG_FILE}`)
.option(...OPTION_DRY_RUN)
.option(...OPTION_VERBOSITY)
.action(withConfig(clean));

program
.command('copy')
.description('Copy files')
.argument(...ARGUMENT_PROJECT)
.description(`Copy source files to output directory. ${REQUIRES_CONFIG_FILE}`)
.option(...OPTION_DRY_RUN)
.option(...OPTION_VERBOSITY)
.action(withConfig(copy));

program
.command('rename')
.description('Rename files')
.argument(...ARGUMENT_PROJECT)
.description(`Rename output files. ${REQUIRES_CONFIG_FILE}`)
.option(...OPTION_DRY_RUN)
.option(...OPTION_VERBOSITY)
.action(withConfig(rename));

program
.command('zip')
.description('Zip dist files')
.argument(...ARGUMENT_PROJECT)
.command('compress')
.description(`Compress output files into an archive. ${REQUIRES_CONFIG_FILE}`)
.option(...OPTION_DRY_RUN)
.option(...OPTION_VERBOSITY)
.action(withConfig(compress));
Expand Down
6 changes: 3 additions & 3 deletions apps/app-builder/src/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type WithContextParams = <A extends CommandArgs>(context: Omit<PdkBuilderContext

type WithConfigParams = <A extends CommandArgs>(context: PdkBuilderContext<A>) => Promise<void> | void;

type CommandCb<A = Record<string, unknown>> = (cmd: string, args: A) => void | Promise<void>;
type CommandCb<A = Record<string, unknown>> = (args: A) => void | Promise<void>;

type CreateHook<T, A = Record<string, unknown>> = (
env: Liftoff.LiftoffEnv,
Expand All @@ -16,13 +16,13 @@ type CreateHook<T, A = Record<string, unknown>> = (

export const createWithContext: CreateHook<WithContextParams, CommandArgs> = (env) => {
return (callback) => {
return async (_, args) => callback({env: env, args});
return async (args) => callback({env: env, args});
};
};

export const createWithConfig: CreateHook<WithConfigParams, CommandArgs> = (env) => {
return (callback) => {
return async (_, args) => {
return async (args) => {
const config = await resolveConfig(env);

return callback({config: mergeDefaultConfig(config), env: env, args});
Expand Down

0 comments on commit ccf90e3

Please sign in to comment.