diff --git a/src/cli/commands/lift.ts b/src/cli/commands/lift.ts index bb7b2c0..aaaf6a9 100644 --- a/src/cli/commands/lift.ts +++ b/src/cli/commands/lift.ts @@ -15,7 +15,7 @@ export async function lift(params: CLI.Extension.Params): Promise { Options: --purge Purge all non-${params.options.bin} scripts --defaults Lift default tasks and subtasks by their own - --mode Lift mode of operation (default, confirm, dry, audit) + --mode Lift mode of operation (confirm, fix, dry, audit) -h, --help Show help `; @@ -44,9 +44,9 @@ export async function lift(params: CLI.Extension.Params): Promise { } if ( - !['default', 'confirm', 'dry', 'audit'].includes(cmd['--mode'] || 'default') + !['confirm', 'fix', 'dry', 'audit'].includes(cmd['--mode'] || 'confirm') ) { - return raises(Error(`Lift mode must be default, confirm, dry, or audit`)); + return raises(Error(`Lift mode must be confirm, fix, dry, or audit`)); } const tasks = await fetch({ @@ -61,7 +61,8 @@ export async function lift(params: CLI.Extension.Params): Promise { purge: cmd['--purge'], defaults: cmd['--defaults'], mode: cmd['--mode'] as any, - bin: params.options.bin + bin: params.options.bin, + multitask: params.options.multitask }) ); } diff --git a/src/tasks/reflection/lift.ts b/src/tasks/reflection/lift.ts index bfbd295..995b21b 100644 --- a/src/tasks/reflection/lift.ts +++ b/src/tasks/reflection/lift.ts @@ -21,12 +21,12 @@ export interface LiftOptions { purge?: boolean; /** * Lift mode of operation: - * * `'default'`: produces an immediate write. * * `'confirm'`: prints the changes and waits for confirmation before a write. + * * `'fix'`: produces an immediate write. * * `'dry'`: prints the expected changes. * * `'audit'`: prints the expected changes and fails if there are pending changes. */ - mode?: 'default' | 'confirm' | 'dry' | 'audit'; + mode?: 'confirm' | 'fix' | 'dry' | 'audit'; /** * Lift default tasks and subtasks by their own */ @@ -35,6 +35,10 @@ export interface LiftOptions { * Name of kpo's executable */ bin?: string; + /** + * Whether kpo's executable allows running multiple tasks. + */ + multitask?: boolean; } /** @@ -53,9 +57,10 @@ export function lift( const opts = shallow( { purge: false, - mode: 'default', + mode: 'confirm', defaults: false, - bin: constants.cli.bin + bin: constants.cli.bin, + multitask: constants.cli.multitask }, options || undefined ); @@ -83,7 +88,7 @@ export function lift( return keys.reduce( (acc: Members, name) => ({ ...acc, - [name]: `${opts.bin} ${name} --` + [name]: opts.bin + ' ' + name + (opts.multitask ? ' --' : '') }), {} ); @@ -92,29 +97,27 @@ export function lift( pkg.scripts = opts.purge ? taskScripts : { ...pkg.scripts, ...taskScripts }; - const isDefault = !['confirm', 'dry', 'audit'].includes(opts.mode); const areChangesPending = await evaluateChanges( pkgScripts, taskScripts, ctx, - { post: isDefault, purge: opts.purge } + { post: opts.mode === 'fix', purge: opts.purge } ); if (!areChangesPending || (await isCancelled(ctx))) return; - if (isDefault) { - return write(pkgPath, pkg, { exists: 'overwrite' }); - } + if (opts.mode === 'dry') return; if (opts.mode === 'audit') { throw Error(`There are pending scripts changes`); } - if (opts.mode === 'confirm') { - return confirm( - { default: true, message: 'Continue?' }, - write(pkgPath, pkg, { exists: 'overwrite' }), - null - ); + if (opts.mode === 'fix') { + return write(pkgPath, pkg, { exists: 'overwrite' }); } + return confirm( + { default: true, message: 'Continue?' }, + write(pkgPath, pkg, { exists: 'overwrite' }), + null + ); }); }