From a70bc02a3f8e91577aeedb00f754d799e65b34b7 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Wed, 5 Mar 2025 12:57:32 +0100 Subject: [PATCH] Enable banner by default over stderr --- src/constants.ts | 6 - src/utils/meow-with-subcommands.ts | 30 +- test/dry-run.test.ts | 466 +++++++++++++---------------- 3 files changed, 230 insertions(+), 272 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index ab68fea6f..248dc1298 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -48,7 +48,6 @@ type ENV = Remap< SOCKET_CLI_NO_API_TOKEN: boolean SOCKET_CLI_PUBLISHED_BUILD: boolean SOCKET_CLI_SENTRY_BUILD: boolean - SOCKET_CLI_SHOW_BANNER: boolean SOCKET_CLI_VERSION_HASH: string }> > @@ -109,7 +108,6 @@ type Constants = Remap< readonly SOCKET_CLI_SENTRY_NPM_BIN_NAME: 'socket-npm-with-sentry' readonly SOCKET_CLI_SENTRY_NPX_BIN_NAME: 'socket-npx-with-sentry' readonly SOCKET_CLI_SENTRY_PACKAGE_NAME: '@socketsecurity/cli-with-sentry' - readonly SOCKET_CLI_SHOW_BANNER: 'SOCKET_CLI_SHOW_BANNER' readonly SOCKET_CLI_VERSION_HASH: 'SOCKET_CLI_VERSION_HASH' readonly VLT: 'vlt' readonly WITH_SENTRY: 'with-sentry' @@ -179,7 +177,6 @@ const SOCKET_CLI_SENTRY_BUILD = 'SOCKET_CLI_SENTRY_BUILD' const SOCKET_CLI_SENTRY_NPM_BIN_NAME = `${SOCKET_CLI_NPM_BIN_NAME}-${WITH_SENTRY}` const SOCKET_CLI_SENTRY_NPX_BIN_NAME = `${SOCKET_CLI_NPX_BIN_NAME}-${WITH_SENTRY}` const SOCKET_CLI_SENTRY_PACKAGE_NAME = `${SOCKET_CLI_LEGACY_PACKAGE_NAME}-${WITH_SENTRY}` -const SOCKET_CLI_SHOW_BANNER = 'SOCKET_CLI_SHOW_BANNER' const SOCKET_CLI_VERSION_HASH = 'SOCKET_CLI_VERSION_HASH' const VLT = 'vlt' const YARN = 'yarn' @@ -218,8 +215,6 @@ const LAZY_ENV = () => { // Inlined flag set to determine if this is the Sentry build. // The '@rollup/plugin-replace' will replace "process.env[SOCKET_CLI_SENTRY_BUILD]". [SOCKET_CLI_SENTRY_BUILD]: process.env[SOCKET_CLI_SENTRY_BUILD], - // Flag set to toggle the informative ASCII art banner. - [SOCKET_CLI_SHOW_BANNER]: envAsBoolean(env[SOCKET_CLI_SHOW_BANNER]), // Inlined flag set to determine the version hash of the build. // The '@rollup/plugin-replace' will replace "process.env[SOCKET_CLI_VERSION_HASH]". [SOCKET_CLI_VERSION_HASH]: process.env[SOCKET_CLI_VERSION_HASH] @@ -331,7 +326,6 @@ const constants = createConstantsObject( SOCKET_CLI_SENTRY_NPM_BIN_NAME, SOCKET_CLI_SENTRY_NPX_BIN_NAME, SOCKET_CLI_SENTRY_PACKAGE_NAME, - SOCKET_CLI_SHOW_BANNER, SOCKET_CLI_VERSION_HASH, VLT, WITH_SENTRY, diff --git a/src/utils/meow-with-subcommands.ts b/src/utils/meow-with-subcommands.ts index a35e9060e..47473ee1e 100644 --- a/src/utils/meow-with-subcommands.ts +++ b/src/utils/meow-with-subcommands.ts @@ -12,7 +12,7 @@ import { MeowFlags, commonFlags } from '../flags' import type { Options } from 'meow' -const { DRY_RUN_LABEL, REDACTED, SOCKET_CLI_SHOW_BANNER } = constants +const { DRY_RUN_LABEL, REDACTED } = constants interface CliAlias { description: string @@ -93,11 +93,8 @@ export async function meowWithSubcommands( } // ...else we provide basic instructions and help. - // Temp disable until we clear the --json and --markdown usage - // Lazily access constants.ENV[SOCKET_CLI_SHOW_BANNER]. - if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) { - logger.log(getAsciiHeader(name)) - } + emitBanner(name) + const cli = meow( ` Usage @@ -167,11 +164,8 @@ export function meowOrExit({ }) { const command = `${parentName} ${config.commandName}` lastSeenCommand = command - // Temp disable until we clear the --json and --markdown usage. - // Lazily access constants.ENV[SOCKET_CLI_SHOW_BANNER]. - if (constants.ENV[SOCKET_CLI_SHOW_BANNER]) { - logger.log(getAsciiHeader(command)) - } + + emitBanner(command) // This exits if .printHelp() is called either by meow itself or by us. const cli = meow({ @@ -189,6 +183,18 @@ export function meowOrExit({ return cli } +export function emitBanner(name: string) { + // Print a banner at the top of each command. + // This helps with brand recognition and marketing. + // It also helps with debugging since it contains version and command details. + // Note: print over stderr to preserve stdout for flags like --json and + // --markdown. If we don't do this, you can't use --json in particular + // and pipe the result to other tools. By emiting the banner over stderr + // you can do something like `socket scan view xyz | jq | process`. + // The spinner also emits over stderr for example. + logger.error(getAsciiHeader(name)) +} + function getAsciiHeader(command: string) { // Note: In tests we return because otherwise snapshots will fail. // The '@rollup/plugin-replace' will replace "process.env['SOCKET_CLI_VERSION_HASH']". @@ -208,7 +214,7 @@ function getAsciiHeader(command: string) { ? REDACTED : process .cwd() - .replace(new RegExp(`^${escapeRegExp(constants.homePath)}`, 'i'), '~/') + .replace(new RegExp(`^${escapeRegExp(constants.homePath)}`, 'i'), '~') const body = ` _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion} diff --git a/test/dry-run.test.ts b/test/dry-run.test.ts index 0ab77c518..57878ee3c 100644 --- a/test/dry-run.test.ts +++ b/test/dry-run.test.ts @@ -98,151 +98,134 @@ function toAsciiSafeString(str: string): string { } describe('dry-run on all commands', async () => { - let was: unknown // Lazily access constants.rootBinPath. const entryPath = path.join(constants.rootBinPath, `${CLI}.js`) - beforeAll(() => { - // Temp: we have to disable the banner by default until we make it work - // properly with --json and --markdown, since otherwise the output - // would be invalid. - was = process.env['SOCKET_CLI_SHOW_BANNER'] - process.env['SOCKET_CLI_SHOW_BANNER'] = '1' - }) - - afterAll(() => { - if (was) { - process.env['SOCKET_CLI_SHOW_BANNER'] = was as any - } - }) - cmdit(['--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot( + `"[DryRun]: No-op, call a sub-command; ok"` + ) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket\`, cwd: - - [DryRun]: No-op, call a sub-command; ok" + |_____|___|___|_,_|___|_|.dev | Command: \`socket\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['analytics', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket analytics\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['audit-log', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket audit-log\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket audit-log\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m" `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['cdxgen', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot( + ` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket cdxgen\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot( - `"\\x1b[31m\\xd7\\x1b[39m Unknown argument: --dry-run"` + |_____|___|___|_,_|___|_|.dev | Command: \`socket cdxgen\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m Unknown argument: --dry-run" + ` ) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['dependencies', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket dependencies\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket dependencies\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['diff-scan', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot( + `"[DryRun]: No-op, call a sub-command; ok"` + ) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket diff-scan\`, cwd: - - [DryRun]: No-op, call a sub-command; ok" + |_____|___|___|_,_|___|_|.dev | Command: \`socket diff-scan\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['diff-scan', 'get', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket diff-scan get\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket diff-scan get\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Specify a before and after full scan ID \\x1b[31m(missing before and after!)\\x1b[39m @@ -253,41 +236,39 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['fix', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket fix\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket fix\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['info', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket info\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket info\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Expecting a package name \\x1b[31m(missing!)\\x1b[39m @@ -295,79 +276,68 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['login', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket login\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket login\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['logout', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket logout\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket logout\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['manifest', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot( + `"[DryRun]: No-op, call a sub-command; ok"` + ) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest\`, cwd: - - [DryRun]: No-op, call a sub-command; ok" + |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['manifest', 'auto', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` - " - _____ _ _ /--------------- - | __|___ ___| |_ ___| |_ | Socket.dev CLI ver - |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest auto\`, cwd: - - - Auto-detect build and attempt to generate manifest file + expect(stdout).toMatchInlineSnapshot(` + "Auto-detect build and attempt to generate manifest file $ socket manifest auto @@ -381,25 +351,31 @@ describe('dry-run on all commands', async () => { If that doesn't work, see \`socket manifest --help\` for config details for your target language." `) - expect(stderr).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` + " + _____ _ _ /--------------- + | __|___ ___| |_ ___| |_ | Socket.dev CLI ver + |__ | . | _| '_| -_| _| | Node: , API token set: + |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest auto\`, cwd: " + `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['manifest', 'gradle', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest gradle\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest gradle\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - The DIR arg is required \\x1b[31m(missing!)\\x1b[39m @@ -407,22 +383,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['manifest', 'kotlin', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest kotlin\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest kotlin\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - The DIR arg is required \\x1b[31m(missing!)\\x1b[39m @@ -430,22 +406,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['manifest', 'scala', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest scala\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest scala\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - The DIR or FILE arg is required \\x1b[31m(missing!)\\x1b[39m @@ -453,193 +429,177 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['npm', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket npm\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket npm\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['npx', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket npx\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket npx\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['oops', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket oops\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket oops\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['optimize', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket optimize\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket optimize\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['organization', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket organizations\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket organizations\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['raw-npm', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket raw-npm\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket raw-npm\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['raw-npx', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket raw-npx\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket raw-npx\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['report', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot( + `"[DryRun]: No-op, call a sub-command; ok"` + ) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket report\`, cwd: - - [DryRun]: No-op, call a sub-command; ok" + |_____|___|___|_,_|___|_|.dev | Command: \`socket report\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['report', 'create', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket report create\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket report create\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['report', 'view', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket report view\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket report view\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Need at least one report ID \\x1b[31m(missing!)\\x1b[39m @@ -647,41 +607,41 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['repos', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot( + `"[DryRun]: No-op, call a sub-command; ok"` + ) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket repos\`, cwd: - - [DryRun]: No-op, call a sub-command; ok" + |_____|___|___|_,_|___|_|.dev | Command: \`socket repos\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['repos', 'create', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket repos create\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket repos create\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -689,22 +649,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['repos', 'del', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket repos del\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket repos del\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -714,22 +674,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['repos', 'list', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket repos list\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket repos list\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -737,22 +697,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['repos', 'update', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket repos update\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket repos update\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -762,22 +722,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['repos', 'view', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket repos view\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket repos view\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -785,14 +745,14 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) // cmdit(['scan', '--dry-run'], 'should support', async cmd => { // const { code, stderr, stdout } = await invoke(entryPath, cmd) - // expect(`\n ${stdout}`).toMatchInlineSnapshot(` + // expect(stdout).toMatchInlineSnapshot(` // " // _____ _ _ /--------------- // | __|___ ___| |_ ___| |_ | Socket.dev CLI ver @@ -801,17 +761,17 @@ describe('dry-run on all commands', async () => { // [DryRun]: noop, call a sub-command; ok" // `) - // expect(stderr).toMatchInlineSnapshot(`""`) + // expect(`\n ${stderr}`).toMatchInlineSnapshot(`""`) // expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - // expect(stdout, 'header should include command (without params)').toContain( + // expect(stderr, 'header should include command (without params)').toContain( // cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') // ) // }) // cmdit(['scan', 'create', '--dry-run'], 'should support', async cmd => { // const { code, stderr, stdout } = await invoke(entryPath, cmd) - // expect(`\n ${stdout}`).toMatchInlineSnapshot(` + // expect(stdout).toMatchInlineSnapshot(` // " // _____ _ _ /--------------- // | __|___ ___| |_ ___| |_ | Socket.dev CLI ver @@ -820,7 +780,7 @@ describe('dry-run on all commands', async () => { // [DryRun] Bailing now" // `) - // expect(stderr).toMatchInlineSnapshot(` + // expect(`\n ${stderr}`).toMatchInlineSnapshot(` // "\\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: // - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -835,22 +795,22 @@ describe('dry-run on all commands', async () => { // `) // expect(code).toBe(2) - // expect(stdout, 'header should include command (without params)').toContain( + // expect(stderr, 'header should include command (without params)').toContain( // cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') // ) // }) cmdit(['scan', 'del', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket scan del\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket scan del\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -858,43 +818,43 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['scan', 'list', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket scan list\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket scan list\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the argument \\x1b[31m(missing!)\\x1b[39m" `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['scan', 'metadata', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket scan metadata\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket scan metadata\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -902,22 +862,22 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['scan', 'view', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket scan view\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: + |_____|___|___|_,_|___|_|.dev | Command: \`socket scan view\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required fields: - Org name as the first argument \\x1b[31m(missing!)\\x1b[39m @@ -925,47 +885,45 @@ describe('dry-run on all commands', async () => { `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['threat-feed', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket threat-feed\`, cwd: - - [DryRun]: Bailing now" + |_____|___|___|_,_|___|_|.dev | Command: \`socket threat-feed\`, cwd: " `) - expect(stderr).toMatchInlineSnapshot(`""`) expect(code, 'dry-run should exit with code 0 if input is ok').toBe(0) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) }) cmdit(['wrapper', '--dry-run'], 'should support', async cmd => { const { code, stderr, stdout } = await invoke(entryPath, cmd) - expect(`\n ${stdout}`).toMatchInlineSnapshot(` + expect(stdout).toMatchInlineSnapshot(`""`) + expect(`\n ${stderr}`).toMatchInlineSnapshot(` " _____ _ _ /--------------- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver |__ | . | _| '_| -_| _| | Node: , API token set: - |_____|___|___|_,_|___|_|.dev | Command: \`socket wrapper\`, cwd: " - `) - expect(stderr).toMatchInlineSnapshot(` - "\\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required flags: + |_____|___|___|_,_|___|_|.dev | Command: \`socket wrapper\`, cwd: + + \\x1b[31m\\xd7\\x1b[39m \\x1b[41m\\x1b[37mInput error\\x1b[39m\\x1b[49m: Please provide the required flags: - Must use --enabled or --disabled" `) expect(code).toBe(2) - expect(stdout, 'header should include command (without params)').toContain( + expect(stderr, 'header should include command (without params)').toContain( cmd.slice(0, cmd.indexOf('--dry-run')).join(' ') ) })