From ccf90e382fc889f0ee6d678a26c353a263e18d51 Mon Sep 17 00:00:00 2001 From: Edie Lemoine Date: Wed, 22 Feb 2023 17:58:37 +0100 Subject: [PATCH] fix(app-builder): remove obsolete argument also update descriptions and names of commands --- apps/app-builder/src/run.ts | 25 ++++++++++--------------- apps/app-builder/src/utils/hooks.ts | 6 +++--- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/apps/app-builder/src/run.ts b/apps/app-builder/src/run.ts index dbebee72b..760ad1b93 100644 --- a/apps/app-builder/src/run.ts +++ b/apps/app-builder/src/run.ts @@ -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( @@ -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)); diff --git a/apps/app-builder/src/utils/hooks.ts b/apps/app-builder/src/utils/hooks.ts index a9725e519..6889da560 100644 --- a/apps/app-builder/src/utils/hooks.ts +++ b/apps/app-builder/src/utils/hooks.ts @@ -7,7 +7,7 @@ type WithContextParams = (context: Omit(context: PdkBuilderContext) => Promise | void; -type CommandCb> = (cmd: string, args: A) => void | Promise; +type CommandCb> = (args: A) => void | Promise; type CreateHook> = ( env: Liftoff.LiftoffEnv, @@ -16,13 +16,13 @@ type CreateHook> = ( export const createWithContext: CreateHook = (env) => { return (callback) => { - return async (_, args) => callback({env: env, args}); + return async (args) => callback({env: env, args}); }; }; export const createWithConfig: CreateHook = (env) => { return (callback) => { - return async (_, args) => { + return async (args) => { const config = await resolveConfig(env); return callback({config: mergeDefaultConfig(config), env: env, args});