From c4d387f3b8a4d7d16b2034987453bd566df843da Mon Sep 17 00:00:00 2001 From: Tyler Dane Date: Mon, 30 Dec 2024 07:50:34 -0600 Subject: [PATCH] fix(cli): validate packages after they're provided --- packages/scripts/src/cli.ts | 3 +-- packages/scripts/src/commands/build.ts | 7 +++---- packages/scripts/src/common/cli.utils.ts | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/scripts/src/cli.ts b/packages/scripts/src/cli.ts index 48490293..c342ba88 100644 --- a/packages/scripts/src/cli.ts +++ b/packages/scripts/src/cli.ts @@ -64,12 +64,11 @@ class CompassCli { } public async run() { - const { user, force, packages } = this.options; + const { user, force } = this.options; const cmd = this.program.args[0]; switch (true) { case cmd === "build": { - validatePackages(packages); await runBuild(this.options); break; } diff --git a/packages/scripts/src/commands/build.ts b/packages/scripts/src/commands/build.ts index fb2fdf00..d3a3aaca 100644 --- a/packages/scripts/src/commands/build.ts +++ b/packages/scripts/src/commands/build.ts @@ -16,13 +16,12 @@ import { getClientId, getApiBaseUrl, getEnvironmentAnswer, + validatePackages, } from "@scripts/common/cli.utils"; export const runBuild = async (options: Options_Cli) => { - const pckgs = - options?.packages?.length === 0 - ? await getPckgsTo("build") - : (options.packages as string[]); + const pckgs = options.packages ? options.packages : await getPckgsTo("build"); + validatePackages(pckgs); if (pckgs.includes(PCKG.NODE)) { await buildNodePckgs(options); diff --git a/packages/scripts/src/common/cli.utils.ts b/packages/scripts/src/common/cli.utils.ts index bf9e8aca..297690db 100644 --- a/packages/scripts/src/common/cli.utils.ts +++ b/packages/scripts/src/common/cli.utils.ts @@ -176,7 +176,7 @@ export const validateOptions = (options: Options_Cli): Options_Cli => { export const validatePackages = (packages: string[] | undefined) => { if (!packages) { - log.error("Packages must be defined"); + log.error("Package must be defined"); process.exit(1); } const unsupportedPackages = packages.filter(