From 8f7fe79d0d5e3339ffb7a21567a8bd111fcab218 Mon Sep 17 00:00:00 2001 From: Svana Date: Tue, 15 Oct 2024 12:20:29 +0000 Subject: [PATCH 1/2] chore: Fix run-local-env services argument --- infra/src/cli/cli.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/infra/src/cli/cli.ts b/infra/src/cli/cli.ts index 78cf78f8d92a..c26a887c02fa 100644 --- a/infra/src/cli/cli.ts +++ b/infra/src/cli/cli.ts @@ -85,7 +85,7 @@ const cli = yargs(process.argv.slice(2)) }, ) .command( - 'run-local-env', + 'run-local-env [services...]', 'Render environment and run the local environment.\nThis is to be used when developing locally and loading of the environment variables for "dev" environment is needed.', (yargs) => { return yargs @@ -109,7 +109,14 @@ const cli = yargs(process.argv.slice(2)) type: 'boolean', default: false, }) - .demandCommand(1, 'You must pass at least one service to run!') + .check((argv) => { + const svc = argv.services + if (svc.length < 1) { + throw new Error('You must pass at least one service to run!') + } else { + return true + } + }) }, async (argv) => await runLocalServices(argv.services, argv.dependencies, { From 0d287b46be92fa06f2e683a59627dea162e1f09d Mon Sep 17 00:00:00 2001 From: Svana Date: Tue, 15 Oct 2024 16:48:47 +0000 Subject: [PATCH 2/2] Added comment for yargs services check validation --- infra/src/cli/cli.ts | 61 +++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/infra/src/cli/cli.ts b/infra/src/cli/cli.ts index c26a887c02fa..9be060943dbd 100644 --- a/infra/src/cli/cli.ts +++ b/infra/src/cli/cli.ts @@ -88,35 +88,38 @@ const cli = yargs(process.argv.slice(2)) 'run-local-env [services...]', 'Render environment and run the local environment.\nThis is to be used when developing locally and loading of the environment variables for "dev" environment is needed.', (yargs) => { - return yargs - .positional('services', { - type: 'string', - array: true, - demandOption: true, - }) - .option('dependencies', { array: true, type: 'string', default: [] }) - .option('json', { type: 'boolean', default: false }) - .option('dry', { type: 'boolean', default: false }) - .option('no-update-secrets', { - type: 'boolean', - default: false, - alias: ['nosecrets', 'no-secrets'], - }) - .option('print', { type: 'boolean', default: false }) - .option('proxies', { type: 'boolean', default: false }) - .option('never-fail', { - alias: 'nofail', - type: 'boolean', - default: false, - }) - .check((argv) => { - const svc = argv.services - if (svc.length < 1) { - throw new Error('You must pass at least one service to run!') - } else { - return true - } - }) + return ( + yargs + .positional('services', { + type: 'string', + array: true, + demandOption: true, + }) + .option('dependencies', { array: true, type: 'string', default: [] }) + .option('json', { type: 'boolean', default: false }) + .option('dry', { type: 'boolean', default: false }) + .option('no-update-secrets', { + type: 'boolean', + default: false, + alias: ['nosecrets', 'no-secrets'], + }) + .option('print', { type: 'boolean', default: false }) + .option('proxies', { type: 'boolean', default: false }) + .option('never-fail', { + alias: 'nofail', + type: 'boolean', + default: false, + }) + // Custom check for 'services' since yargs lack built-in validation + .check((argv) => { + const svc = argv.services + if (svc.length < 1) { + throw new Error('You must pass at least one service to run!') + } else { + return true + } + }) + ) }, async (argv) => await runLocalServices(argv.services, argv.dependencies, {