diff --git a/src/commands/analytics/cmd-analytics.mts b/src/commands/analytics/cmd-analytics.mts index d9d08648..0542548b 100644 --- a/src/commands/analytics/cmd-analytics.mts +++ b/src/commands/analytics/cmd-analytics.mts @@ -12,7 +12,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'analytics', @@ -211,7 +211,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/audit-log/cmd-audit-log.mts b/src/commands/audit-log/cmd-audit-log.mts index c18ae71b..c0a90451 100644 --- a/src/commands/audit-log/cmd-audit-log.mts +++ b/src/commands/audit-log/cmd-audit-log.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'audit-log', @@ -144,7 +144,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/cdxgen/cmd-cdxgen.mts b/src/commands/cdxgen/cmd-cdxgen.mts index fc844377..a77ce235 100644 --- a/src/commands/cdxgen/cmd-cdxgen.mts +++ b/src/commands/cdxgen/cmd-cdxgen.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants // TODO: convert yargs to meow. Or convert all the other things to yargs. const toLower = (arg: string) => arg.toLowerCase() @@ -168,7 +168,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/ci/cmd-ci.mts b/src/commands/ci/cmd-ci.mts index f0a35827..231abb59 100644 --- a/src/commands/ci/cmd-ci.mts +++ b/src/commands/ci/cmd-ci.mts @@ -7,7 +7,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'ci', @@ -48,7 +48,7 @@ async function run( }) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/config/cmd-config-auto.mts b/src/commands/config/cmd-config-auto.mts index 3063c3ca..4517e49d 100644 --- a/src/commands/config/cmd-config-auto.mts +++ b/src/commands/config/cmd-config-auto.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { LocalConfig } from '../../utils/config.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'auto', @@ -90,7 +90,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/config/cmd-config-get.mts b/src/commands/config/cmd-config-get.mts index af50d972..f71b9180 100644 --- a/src/commands/config/cmd-config-get.mts +++ b/src/commands/config/cmd-config-get.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { LocalConfig } from '../../utils/config.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'get', @@ -85,7 +85,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/config/cmd-config-list.mts b/src/commands/config/cmd-config-list.mts index be77971d..6d5cb63f 100644 --- a/src/commands/config/cmd-config-list.mts +++ b/src/commands/config/cmd-config-list.mts @@ -11,7 +11,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'list', @@ -78,7 +78,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/config/cmd-config-set.mts b/src/commands/config/cmd-config-set.mts index cff835cb..143c82ba 100644 --- a/src/commands/config/cmd-config-set.mts +++ b/src/commands/config/cmd-config-set.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { LocalConfig } from '../../utils/config.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'set', @@ -98,7 +98,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/config/cmd-config-unset.mts b/src/commands/config/cmd-config-unset.mts index 2d76f3d9..4ae0ea36 100644 --- a/src/commands/config/cmd-config-unset.mts +++ b/src/commands/config/cmd-config-unset.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { LocalConfig } from '../../utils/config.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'unset', @@ -85,7 +85,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/dependencies/cmd-dependencies.mts b/src/commands/dependencies/cmd-dependencies.mts index b5aacd8a..7b194445 100644 --- a/src/commands/dependencies/cmd-dependencies.mts +++ b/src/commands/dependencies/cmd-dependencies.mts @@ -11,7 +11,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'dependencies', @@ -97,7 +97,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/diff-scan/cmd-diff-scan-get.mts b/src/commands/diff-scan/cmd-diff-scan-get.mts index e5e54a49..3bc81bbf 100644 --- a/src/commands/diff-scan/cmd-diff-scan-get.mts +++ b/src/commands/diff-scan/cmd-diff-scan-get.mts @@ -12,7 +12,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'get', @@ -152,7 +152,7 @@ async function run( ) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/fix/cmd-fix.mts b/src/commands/fix/cmd-fix.mts index 91734e79..4524066e 100644 --- a/src/commands/fix/cmd-fix.mts +++ b/src/commands/fix/cmd-fix.mts @@ -1,10 +1,8 @@ import terminalLink from 'terminal-link' import { joinOr } from '@socketsecurity/registry/lib/arrays' -import { logger } from '@socketsecurity/registry/lib/logger' import { runFix } from './run-fix.mts' -import constants from '../../constants.mts' import { commonFlags } from '../../flags.mts' import { getOutputKind } from '../../utils/get-output-kind.mts' import { checkCommandInput } from '../../utils/handle-bad-input.mts' @@ -15,8 +13,6 @@ import { RangeStyles } from '../../utils/semver.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' import type { RangeStyle } from '../../utils/semver.mts' -const { DRY_RUN_BAIL_TEXT } = constants - const config: CliCommandConfig = { commandName: 'fix', description: 'Update dependencies with "fixable" Socket alerts', @@ -113,11 +109,6 @@ async function run( return } - if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) - return - } - await runFix({ autoMerge: Boolean(cli.flags['autoMerge']), autopilot: Boolean(cli.flags['autopilot']), diff --git a/src/commands/fix/cmd-fix.test.mts b/src/commands/fix/cmd-fix.test.mts index f6be8e90..15e11c87 100644 --- a/src/commands/fix/cmd-fix.test.mts +++ b/src/commands/fix/cmd-fix.test.mts @@ -62,13 +62,18 @@ describe('socket fix', async () => { 'should require args with just dry-run', async cmd => { const { code, stderr, stdout } = await invokeNpm(entryPath, cmd) - expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(stdout).toMatchInlineSnapshot(` + "\\x1b[34mi\\x1b[39m Fixing packages for npm + [DryRun]: Not saving" + `) expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | * | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket fix\`, cwd: " + |_____|___|___|_,_|___|_|.dev | Command: \`socket fix\`, cwd: + + \\x1b[33m\\u203c\\x1b[39m socket fix: Package package-lock.json found at /Users/jdalton/projects/socket-cli/package-lock.json" `) expect(code, 'dry-run should exit with code 0 if input ok').toBe(0) diff --git a/src/commands/fix/npm-fix.mts b/src/commands/fix/npm-fix.mts index 7532947d..3d93884f 100644 --- a/src/commands/fix/npm-fix.mts +++ b/src/commands/fix/npm-fix.mts @@ -53,7 +53,7 @@ import type { SafeNode } from '../../shadow/npm/arborist/lib/node.mts' import type { EnvDetails } from '../../utils/package-environment.mts' import type { PackageJson } from '@socketsecurity/registry/lib/packages' -const { NPM } = constants +const { DRY_RUN_NOT_SAVING, NPM } = constants type InstallOptions = { cwd?: string | undefined @@ -74,8 +74,12 @@ async function install( export async function npmFix( pkgEnvDetails: EnvDetails, - { autoMerge, cwd, purls, rangeStyle, test, testScript }: NormalizedFixOptions + { autoMerge, cwd, dryRun, purls, rangeStyle, test, testScript }: NormalizedFixOptions ) { + if (dryRun) { + logger.log(DRY_RUN_NOT_SAVING) + return + } // Lazily access constants.spinner. const { spinner } = constants diff --git a/src/commands/fix/pnpm-fix.mts b/src/commands/fix/pnpm-fix.mts index af3f9eb9..0dc22599 100644 --- a/src/commands/fix/pnpm-fix.mts +++ b/src/commands/fix/pnpm-fix.mts @@ -57,7 +57,7 @@ import type { LockfileObject } from '@pnpm/lockfile.fs' import type { PackageJson } from '@socketsecurity/registry/lib/packages' import type { Spinner } from '@socketsecurity/registry/lib/spinner' -const { NPM, OVERRIDES, PNPM } = constants +const { DRY_RUN_NOT_SAVING, NPM, OVERRIDES, PNPM } = constants async function getActualTree(cwd: string = process.cwd()): Promise { const arb = new SafeArborist({ @@ -93,8 +93,12 @@ async function readLockfile(pkgPath: string): Promise { export async function pnpmFix( pkgEnvDetails: EnvDetails, - { autoMerge, cwd, purls, rangeStyle, test, testScript }: NormalizedFixOptions + { autoMerge, cwd, dryRun, purls, rangeStyle, test, testScript }: NormalizedFixOptions ) { + if (dryRun) { + logger.log(DRY_RUN_NOT_SAVING) + return + } // Lazily access constants.spinner. const { spinner } = constants diff --git a/src/commands/info/cmd-info.mts b/src/commands/info/cmd-info.mts index af8cf7a0..eb4fd882 100644 --- a/src/commands/info/cmd-info.mts +++ b/src/commands/info/cmd-info.mts @@ -11,7 +11,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'info', @@ -98,7 +98,7 @@ async function run( versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/login/cmd-login.mts b/src/commands/login/cmd-login.mts index 3796be80..ecb48b7f 100644 --- a/src/commands/login/cmd-login.mts +++ b/src/commands/login/cmd-login.mts @@ -10,7 +10,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'login', @@ -67,7 +67,7 @@ async function run( const apiProxy = cli.flags['apiProxy'] as string | undefined if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/logout/cmd-logout.mts b/src/commands/logout/cmd-logout.mts index 3528f951..09e34aff 100644 --- a/src/commands/logout/cmd-logout.mts +++ b/src/commands/logout/cmd-logout.mts @@ -7,7 +7,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'logout', @@ -43,7 +43,7 @@ async function run( }) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/manifest/cmd-manifest-auto.mts b/src/commands/manifest/cmd-manifest-auto.mts index 4731c88e..75b1c2ef 100644 --- a/src/commands/manifest/cmd-manifest-auto.mts +++ b/src/commands/manifest/cmd-manifest-auto.mts @@ -15,7 +15,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'auto', @@ -91,7 +91,7 @@ async function run( } subArgs.push(dir) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } await cmdManifestScala.run(subArgs, importMeta, { parentName }) @@ -105,7 +105,7 @@ async function run( subArgs.push(cwd) } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } await cmdManifestGradle.run(subArgs, importMeta, { parentName }) @@ -123,7 +123,7 @@ async function run( // This command takes the TARGET as first arg. subArgs.push(hasEnvyml ? envyml : hasEnvyaml ? envyaml : '') if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } await cmdManifestConda.run(subArgs, importMeta, { parentName }) @@ -131,7 +131,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/manifest/cmd-manifest-conda.mts b/src/commands/manifest/cmd-manifest-conda.mts index 3b2a2dd8..77ff87d8 100644 --- a/src/commands/manifest/cmd-manifest-conda.mts +++ b/src/commands/manifest/cmd-manifest-conda.mts @@ -10,7 +10,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'conda', @@ -127,7 +127,7 @@ async function run( ) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/manifest/cmd-manifest-gradle.mts b/src/commands/manifest/cmd-manifest-gradle.mts index c49801b9..78b814de 100644 --- a/src/commands/manifest/cmd-manifest-gradle.mts +++ b/src/commands/manifest/cmd-manifest-gradle.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'gradle', @@ -153,7 +153,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/manifest/cmd-manifest-kotlin.mts b/src/commands/manifest/cmd-manifest-kotlin.mts index 51cc778d..d30a34ce 100644 --- a/src/commands/manifest/cmd-manifest-kotlin.mts +++ b/src/commands/manifest/cmd-manifest-kotlin.mts @@ -12,7 +12,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants // TODO: we may want to dedupe some pieces for all gradle languages. I think it // makes sense to have separate commands for them and I think it makes @@ -158,7 +158,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/manifest/cmd-manifest-scala.mts b/src/commands/manifest/cmd-manifest-scala.mts index 0e98a6a2..be91b57b 100644 --- a/src/commands/manifest/cmd-manifest-scala.mts +++ b/src/commands/manifest/cmd-manifest-scala.mts @@ -10,7 +10,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'scala', @@ -173,7 +173,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/npm/cmd-npm.mts b/src/commands/npm/cmd-npm.mts index 11401c8d..2faef437 100644 --- a/src/commands/npm/cmd-npm.mts +++ b/src/commands/npm/cmd-npm.mts @@ -7,7 +7,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT, NPM } = constants +const { DRY_RUN_BAILING_NOW, NPM } = constants const config: CliCommandConfig = { commandName: 'npm', @@ -42,7 +42,7 @@ async function run( }) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/npx/cmd-npx.mts b/src/commands/npx/cmd-npx.mts index 6ec3aa76..170e873a 100644 --- a/src/commands/npx/cmd-npx.mts +++ b/src/commands/npx/cmd-npx.mts @@ -7,7 +7,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT, NPX } = constants +const { DRY_RUN_BAILING_NOW, NPX } = constants const config: CliCommandConfig = { commandName: 'npx', @@ -42,7 +42,7 @@ async function run( }) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/oops/cmd-oops.mts b/src/commands/oops/cmd-oops.mts index c98aef1d..05dd007b 100644 --- a/src/commands/oops/cmd-oops.mts +++ b/src/commands/oops/cmd-oops.mts @@ -6,7 +6,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'oops', @@ -44,7 +44,7 @@ async function run( // TODO: impl json/md if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/optimize/cmd-optimize.mts b/src/commands/optimize/cmd-optimize.mts index e7077287..f1d6f60f 100644 --- a/src/commands/optimize/cmd-optimize.mts +++ b/src/commands/optimize/cmd-optimize.mts @@ -8,7 +8,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'optimize', @@ -63,7 +63,7 @@ async function run( const cwd = process.cwd() if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/organization/cmd-organization-list.mts b/src/commands/organization/cmd-organization-list.mts index 24adde71..5a288287 100644 --- a/src/commands/organization/cmd-organization-list.mts +++ b/src/commands/organization/cmd-organization-list.mts @@ -11,7 +11,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'list', @@ -81,7 +81,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/organization/cmd-organization-policy-license.mts b/src/commands/organization/cmd-organization-policy-license.mts index 50a6ce62..1d425724 100644 --- a/src/commands/organization/cmd-organization-policy-license.mts +++ b/src/commands/organization/cmd-organization-policy-license.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants // TODO: secret toplevel alias `socket license policy`? const config: CliCommandConfig = { @@ -117,7 +117,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/organization/cmd-organization-policy-security.mts b/src/commands/organization/cmd-organization-policy-security.mts index ba287c17..ecb35b3a 100644 --- a/src/commands/organization/cmd-organization-policy-security.mts +++ b/src/commands/organization/cmd-organization-policy-security.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants // TODO: secret toplevel alias `socket security policy`? const config: CliCommandConfig = { @@ -115,7 +115,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/organization/cmd-organization-quota.mts b/src/commands/organization/cmd-organization-quota.mts index 36da0bf8..a9ac3d06 100644 --- a/src/commands/organization/cmd-organization-quota.mts +++ b/src/commands/organization/cmd-organization-quota.mts @@ -11,7 +11,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'quota', @@ -77,7 +77,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/package/cmd-package-score.mts b/src/commands/package/cmd-package-score.mts index e59886a9..a0ed2b46 100644 --- a/src/commands/package/cmd-package-score.mts +++ b/src/commands/package/cmd-package-score.mts @@ -12,7 +12,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'score', @@ -118,7 +118,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/package/cmd-package-shallow.mts b/src/commands/package/cmd-package-shallow.mts index 9c068474..6e92c0c3 100644 --- a/src/commands/package/cmd-package-shallow.mts +++ b/src/commands/package/cmd-package-shallow.mts @@ -11,7 +11,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'shallow', @@ -116,7 +116,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/raw-npm/cmd-raw-npm.mts b/src/commands/raw-npm/cmd-raw-npm.mts index 641141dc..be255e6e 100644 --- a/src/commands/raw-npm/cmd-raw-npm.mts +++ b/src/commands/raw-npm/cmd-raw-npm.mts @@ -6,7 +6,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT, NPM } = constants +const { DRY_RUN_BAILING_NOW, NPM } = constants const config: CliCommandConfig = { commandName: 'raw-npm', @@ -42,7 +42,7 @@ async function run( }) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/raw-npx/cmd-raw-npx.mts b/src/commands/raw-npx/cmd-raw-npx.mts index dd89ddb8..8271a2a4 100644 --- a/src/commands/raw-npx/cmd-raw-npx.mts +++ b/src/commands/raw-npx/cmd-raw-npx.mts @@ -6,7 +6,7 @@ import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT, NPX } = constants +const { DRY_RUN_BAILING_NOW, NPX } = constants const config: CliCommandConfig = { commandName: 'raw-npx', @@ -42,7 +42,7 @@ async function run( }) if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/repos/cmd-repos-create.mts b/src/commands/repos/cmd-repos-create.mts index 1e39dc97..9121ff27 100644 --- a/src/commands/repos/cmd-repos-create.mts +++ b/src/commands/repos/cmd-repos-create.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'create', @@ -158,7 +158,7 @@ async function run( } if (dryRun) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/repos/cmd-repos-del.mts b/src/commands/repos/cmd-repos-del.mts index ad7c36e8..d2e863ca 100644 --- a/src/commands/repos/cmd-repos-del.mts +++ b/src/commands/repos/cmd-repos-del.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'del', @@ -115,7 +115,7 @@ async function run( } if (dryRun) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/repos/cmd-repos-list.mts b/src/commands/repos/cmd-repos-list.mts index f90dbe62..b14c0b31 100644 --- a/src/commands/repos/cmd-repos-list.mts +++ b/src/commands/repos/cmd-repos-list.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'list', @@ -138,7 +138,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/repos/cmd-repos-update.mts b/src/commands/repos/cmd-repos-update.mts index 5f4298b5..d25cf59a 100644 --- a/src/commands/repos/cmd-repos-update.mts +++ b/src/commands/repos/cmd-repos-update.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'update', @@ -152,7 +152,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/repos/cmd-repos-view.mts b/src/commands/repos/cmd-repos-view.mts index 491bb794..5e3541fd 100644 --- a/src/commands/repos/cmd-repos-view.mts +++ b/src/commands/repos/cmd-repos-view.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'view', @@ -142,7 +142,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-create.mts b/src/commands/scan/cmd-scan-create.mts index f8febeba..e78f6ee3 100644 --- a/src/commands/scan/cmd-scan-create.mts +++ b/src/commands/scan/cmd-scan-create.mts @@ -15,7 +15,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'create', @@ -323,7 +323,7 @@ async function run( // Note exiting earlier to skirt a hidden auth requirement if (dryRun) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-del.mts b/src/commands/scan/cmd-scan-del.mts index cfa4a515..8bb6b62f 100644 --- a/src/commands/scan/cmd-scan-del.mts +++ b/src/commands/scan/cmd-scan-del.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'del', @@ -116,7 +116,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-diff.mts b/src/commands/scan/cmd-scan-diff.mts index 94587f42..9263080e 100644 --- a/src/commands/scan/cmd-scan-diff.mts +++ b/src/commands/scan/cmd-scan-diff.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const SOCKET_SBOM_URL_PREFIX = 'https://socket.dev/dashboard/org/SocketDev/sbom/' @@ -166,7 +166,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-list.mts b/src/commands/scan/cmd-scan-list.mts index 10b2ec4c..a2e14d41 100644 --- a/src/commands/scan/cmd-scan-list.mts +++ b/src/commands/scan/cmd-scan-list.mts @@ -16,7 +16,7 @@ import type { CliSubcommand } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'list', @@ -171,7 +171,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-metadata.mts b/src/commands/scan/cmd-scan-metadata.mts index c527cd68..ebdc1b57 100644 --- a/src/commands/scan/cmd-scan-metadata.mts +++ b/src/commands/scan/cmd-scan-metadata.mts @@ -16,7 +16,7 @@ import type { CliSubcommand } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'metadata', @@ -126,7 +126,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-report.mts b/src/commands/scan/cmd-scan-report.mts index 52148eba..4c66f14b 100644 --- a/src/commands/scan/cmd-scan-report.mts +++ b/src/commands/scan/cmd-scan-report.mts @@ -16,7 +16,7 @@ import type { CliSubcommand } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'report', @@ -167,7 +167,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/scan/cmd-scan-view.mts b/src/commands/scan/cmd-scan-view.mts index 533ada4d..863a66ea 100644 --- a/src/commands/scan/cmd-scan-view.mts +++ b/src/commands/scan/cmd-scan-view.mts @@ -17,7 +17,7 @@ import type { CliSubcommand } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'view', @@ -152,7 +152,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/threat-feed/cmd-threat-feed.mts b/src/commands/threat-feed/cmd-threat-feed.mts index 4b30014c..f5f7beba 100644 --- a/src/commands/threat-feed/cmd-threat-feed.mts +++ b/src/commands/threat-feed/cmd-threat-feed.mts @@ -13,7 +13,7 @@ import { getDefaultToken } from '../../utils/sdk.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'threat-feed', @@ -168,7 +168,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/commands/wrapper/cmd-wrapper.mts b/src/commands/wrapper/cmd-wrapper.mts index ef563754..1f441afe 100644 --- a/src/commands/wrapper/cmd-wrapper.mts +++ b/src/commands/wrapper/cmd-wrapper.mts @@ -15,7 +15,7 @@ import { getFlagListOutput } from '../../utils/output-formatting.mts' import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts' -const { DRY_RUN_BAIL_TEXT } = constants +const { DRY_RUN_BAILING_NOW } = constants const config: CliCommandConfig = { commandName: 'wrapper', @@ -95,7 +95,7 @@ async function run( } if (cli.flags['dryRun']) { - logger.log(DRY_RUN_BAIL_TEXT) + logger.log(DRY_RUN_BAILING_NOW) return } diff --git a/src/constants.mts b/src/constants.mts index 8bb6616a..2eeb5195 100644 --- a/src/constants.mts +++ b/src/constants.mts @@ -96,7 +96,8 @@ type Constants = Remap< readonly CVE_ALERT_PROPS_FIRST_PATCHED_VERSION_IDENTIFIER: 'firstPatchedVersionIdentifier' readonly ENV: ENV readonly DRY_RUN_LABEL: '[DryRun]' - readonly DRY_RUN_BAIL_TEXT: '[DryRun] Bailing now' + readonly DRY_RUN_BAILING_NOW: '[DryRun] Bailing now' + readonly DRY_RUN_NOT_SAVING: '[DryRun] Not saving' readonly IPC: IPC readonly LOCALAPPDATA: 'LOCALAPPDATA' readonly LOCK_EXT: '.lock' @@ -167,14 +168,14 @@ const CLI = 'cli' const CVE_ALERT_PROPS_FIRST_PATCHED_VERSION_IDENTIFIER = 'firstPatchedVersionIdentifier' const DRY_RUN_LABEL = '[DryRun]' -const DRY_RUN_BAIL_TEXT = `${DRY_RUN_LABEL}: Bailing now` +const DRY_RUN_BAILING_NOW = `${DRY_RUN_LABEL}: Bailing now` +const DRY_RUN_NOT_SAVING = `${DRY_RUN_LABEL}: Not saving` const LOCALAPPDATA = 'LOCALAPPDATA' const LOCK_EXT = '.lock' const NPM_BUGGY_OVERRIDES_PATCHED_VERSION = '11.2.0' const NPM_REGISTRY_URL = 'https://registry.npmjs.org' const PNPM = 'pnpm' const REDACTED = '' -const REQUIRE = 'require' const SHADOW_NPM_BIN = 'shadow-bin' const SHADOW_NPM_INJECT = 'shadow-npm-inject' const SHADOW_NPM_PATHS = 'shadow-npm-paths' @@ -431,7 +432,8 @@ const constants: Constants = createConstantsObject( CLI, CVE_ALERT_PROPS_FIRST_PATCHED_VERSION_IDENTIFIER, DRY_RUN_LABEL, - DRY_RUN_BAIL_TEXT, + DRY_RUN_BAILING_NOW, + DRY_RUN_NOT_SAVING, ENV: undefined, LOCALAPPDATA, LOCK_EXT, @@ -439,7 +441,6 @@ const constants: Constants = createConstantsObject( NPM_REGISTRY_URL, PNPM, REDACTED, - REQUIRE, SHADOW_NPM_BIN, SHADOW_NPM_INJECT, SHADOW_NPM_PATHS,