Skip to content

Commit 6bddc17

Browse files
committed
Add DRY_RUN constants
1 parent 088be39 commit 6bddc17

37 files changed

+142
-41
lines changed

src/commands/action/cmd-action.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import { logger } from '@socketsecurity/registry/lib/logger'
44

55
import { runAction } from './run-action'
6+
import constants from '../../constants'
67
import { meowOrExit } from '../../utils/meow-with-subcommands'
78
import { getFlagListOutput } from '../../utils/output-formatting'
89

910
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1011

12+
const { DRY_RUN_BAIL_TEXT } = constants
13+
1114
const config: CliCommandConfig = {
1215
commandName: 'action',
1316
description: 'Socket action command', // GitHub Action ?
@@ -61,7 +64,7 @@ async function run(
6164
const githubEventAfter = String(cli.flags['githubEventAfter'] || '')
6265

6366
if (cli.flags['dryRun']) {
64-
logger.log('[DryRun] Bailing now')
67+
logger.log(DRY_RUN_BAIL_TEXT)
6568
return
6669
}
6770

src/commands/analytics/cmd-analytics.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import colors from 'yoctocolors-cjs'
33
import { logger } from '@socketsecurity/registry/lib/logger'
44

55
import { displayAnalytics } from './display-analytics'
6+
import constants from '../../constants'
67
import { commonFlags, outputFlags } from '../../flags'
78
import { AuthError } from '../../utils/errors'
89
import { meowOrExit } from '../../utils/meow-with-subcommands'
@@ -11,6 +12,8 @@ import { getDefaultToken } from '../../utils/sdk'
1112

1213
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1314

15+
const { DRY_RUN_BAIL_TEXT } = constants
16+
1417
const config: CliCommandConfig = {
1518
commandName: 'analytics',
1619
description: `Look up analytics data`,
@@ -98,7 +101,7 @@ async function run(
98101
}
99102

100103
if (cli.flags['dryRun']) {
101-
logger.log('[DryRun] Bailing now')
104+
logger.log(DRY_RUN_BAIL_TEXT)
102105
return
103106
}
104107

src/commands/audit-log/cmd-audit-log.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import colors from 'yoctocolors-cjs'
33
import { logger } from '@socketsecurity/registry/lib/logger'
44

55
import { getAuditLog } from './get-audit-log'
6+
import constants from '../../constants'
67
import { commonFlags, outputFlags } from '../../flags'
78
import { AuthError } from '../../utils/errors'
89
import { meowOrExit } from '../../utils/meow-with-subcommands'
@@ -11,6 +12,8 @@ import { getDefaultToken } from '../../utils/sdk'
1112

1213
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1314

15+
const { DRY_RUN_BAIL_TEXT } = constants
16+
1417
const config: CliCommandConfig = {
1518
commandName: 'audit-log',
1619
description: 'Look up the audit log for an organization',
@@ -81,7 +84,7 @@ async function run(
8184
}
8285

8386
if (cli.flags['dryRun']) {
84-
logger.log('[DryRun] Bailing now')
87+
logger.log(DRY_RUN_BAIL_TEXT)
8588
return
8689
}
8790

src/commands/cdxgen/cmd-cdxgen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import { logger } from '@socketsecurity/registry/lib/logger'
77
import { pluralize } from '@socketsecurity/registry/lib/words'
88

99
import { runCycloneDX } from './run-cyclonedx'
10+
import constants from '../../constants'
1011
import { meowOrExit } from '../../utils/meow-with-subcommands'
1112
import { getFlagListOutput } from '../../utils/output-formatting'
1213

1314
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1415

16+
const { DRY_RUN_BAIL_TEXT } = constants
17+
1518
// TODO: convert yargs to meow. Or convert all the other things to yargs.
1619
const toLower = (arg: string) => arg.toLowerCase()
1720
const arrayToLower = (arg: string[]) => arg.map(toLower)
21+
1822
const yargsConfig = {
1923
configuration: {
2024
'camel-case-expansion': false,
@@ -172,7 +176,7 @@ async function run(
172176
}
173177

174178
if (cli.flags['dryRun']) {
175-
logger.log('[DryRun] Bailing now')
179+
logger.log(DRY_RUN_BAIL_TEXT)
176180
return
177181
}
178182

src/commands/dependencies/cmd-dependencies.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { logger } from '@socketsecurity/registry/lib/logger'
22

33
import { findDependencies } from './find-dependencies'
4+
import constants from '../../constants'
45
import { commonFlags, outputFlags } from '../../flags'
56
import { meowOrExit } from '../../utils/meow-with-subcommands'
67
import { getFlagListOutput } from '../../utils/output-formatting'
78

89
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
910

11+
const { DRY_RUN_BAIL_TEXT } = constants
12+
1013
const config: CliCommandConfig = {
1114
commandName: 'dependencies',
1215
description:
@@ -59,7 +62,7 @@ async function run(
5962
})
6063

6164
if (cli.flags['dryRun']) {
62-
logger.log('[DryRun] Bailing now')
65+
logger.log(DRY_RUN_BAIL_TEXT)
6366
return
6467
}
6568

src/commands/diff-scan/cmd-diff-scan-get.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import colors from 'yoctocolors-cjs'
33
import { logger } from '@socketsecurity/registry/lib/logger'
44

55
import { getDiffScan } from './get-diff-scan'
6+
import constants from '../../constants'
67
import { commonFlags, outputFlags } from '../../flags'
78
import { AuthError } from '../../utils/errors'
89
import { meowOrExit } from '../../utils/meow-with-subcommands'
@@ -11,6 +12,8 @@ import { getDefaultToken } from '../../utils/sdk'
1112

1213
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1314

15+
const { DRY_RUN_BAIL_TEXT } = constants
16+
1417
const config: CliCommandConfig = {
1518
commandName: 'get',
1619
description: 'Get a diff scan for an organization',
@@ -90,7 +93,7 @@ async function run(
9093
}
9194

9295
if (cli.flags['dryRun']) {
93-
logger.log('[DryRun] Bailing now')
96+
logger.log(DRY_RUN_BAIL_TEXT)
9497
return
9598
}
9699

src/commands/fix/cmd-fix.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { logger } from '@socketsecurity/registry/lib/logger'
22

33
import { runFix } from './run-fix'
4+
import constants from '../../constants'
45
import { commonFlags } from '../../flags'
56
import { meowOrExit } from '../../utils/meow-with-subcommands'
67
import { getFlagListOutput } from '../../utils/output-formatting'
78

89
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
910

11+
const { DRY_RUN_BAIL_TEXT } = constants
12+
1013
const config: CliCommandConfig = {
1114
commandName: 'fix',
1215
description: 'Fix "fixable" Socket alerts',
@@ -42,7 +45,7 @@ async function run(
4245
})
4346

4447
if (cli.flags['dryRun']) {
45-
logger.log('[DryRun] Bailing now')
48+
logger.log(DRY_RUN_BAIL_TEXT)
4649
return
4750
}
4851

src/commands/info/cmd-info.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import colors from 'yoctocolors-cjs'
33
import { logger } from '@socketsecurity/registry/lib/logger'
44

55
import { getPackageInfo } from './get-package-info'
6+
import constants from '../../constants'
67
import { commonFlags, outputFlags, validationFlags } from '../../flags'
78
import { meowOrExit } from '../../utils/meow-with-subcommands'
89
import { getFlagListOutput } from '../../utils/output-formatting'
910

1011
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1112

13+
const { DRY_RUN_BAIL_TEXT } = constants
14+
1215
const config: CliCommandConfig = {
1316
commandName: 'info',
1417
description: 'Look up info regarding a package',
@@ -69,7 +72,7 @@ async function run(
6972
versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1)
7073

7174
if (cli.flags['dryRun']) {
72-
logger.log('[DryRun] Bailing now')
75+
logger.log(DRY_RUN_BAIL_TEXT)
7376
return
7477
}
7578

src/commands/login/cmd-login.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import isInteractive from '@socketregistry/is-interactive/index.cjs'
22
import { logger } from '@socketsecurity/registry/lib/logger'
33

44
import { attemptLogin } from './attempt-login'
5+
import constants from '../../constants'
56
import { commonFlags } from '../../flags'
67
import { InputError } from '../../utils/errors'
78
import { meowOrExit } from '../../utils/meow-with-subcommands'
89
import { getFlagListOutput } from '../../utils/output-formatting'
910

1011
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
1112

13+
const { DRY_RUN_BAIL_TEXT } = constants
14+
1215
const config: CliCommandConfig = {
1316
commandName: 'login',
1417
description: 'Socket API login',
@@ -61,7 +64,7 @@ async function run(
6164
let apiProxy = cli.flags['apiProxy'] as string | undefined
6265

6366
if (cli.flags['dryRun']) {
64-
logger.log('[DryRun] Bailing now')
67+
logger.log(DRY_RUN_BAIL_TEXT)
6568
return
6669
}
6770

src/commands/logout/cmd-logout.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { logger } from '@socketsecurity/registry/lib/logger'
22

33
import { attemptLogout } from './attempt-logout'
4+
import constants from '../../constants'
45
import { commonFlags } from '../../flags'
56
import { meowOrExit } from '../../utils/meow-with-subcommands'
67

78
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
89

10+
const { DRY_RUN_BAIL_TEXT } = constants
11+
912
const config: CliCommandConfig = {
1013
commandName: 'logout',
1114
description: 'Socket API logout',
@@ -40,7 +43,7 @@ async function run(
4043
})
4144

4245
if (cli.flags['dryRun']) {
43-
logger.log('[DryRun] Bailing now')
46+
logger.log(DRY_RUN_BAIL_TEXT)
4447
return
4548
}
4649

0 commit comments

Comments
 (0)