Skip to content

Commit 0035c7e

Browse files
committed
Remove lazily access comments
1 parent 4b08ad5 commit 0035c7e

File tree

121 files changed

+48
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+48
-384
lines changed

.config/rollup.base.config.mjs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ const builtinAliases = builtinModules.reduce((o, n) => {
5454
let _rootPkgJson
5555
function getRootPkgJsonSync() {
5656
if (_rootPkgJson === undefined) {
57-
// Lazily access constants.rootPath.
5857
_rootPkgJson = readPackageJsonSync(constants.rootPath, { normalize: true })
5958
}
6059
return _rootPkgJson
@@ -77,7 +76,6 @@ function getSocketCliVersionHash() {
7776
// Mostly for development: confirms the build refreshed. For prod builds
7877
// the git hash should suffice to identify the build.
7978
_socketVersionHash = `${version}:${gitHash}:${randUuidSegment}${
80-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_PUBLISHED_BUILD].
8179
constants.ENV[INLINED_SOCKET_CLI_PUBLISHED_BUILD] ? ':pub' : ':dev'
8280
}`
8381
}
@@ -102,7 +100,6 @@ function getVarNameForRequireId(filename, id, lookbehindContent) {
102100
}
103101

104102
export default function baseConfig(extendConfig = {}) {
105-
// Lazily access constants path properties.
106103
const { configPath, rootPath } = constants
107104

108105
const nmPath = path.join(rootPath, NODE_MODULES)
@@ -215,10 +212,7 @@ export default function baseConfig(extendConfig = {}) {
215212
[
216213
INLINED_SOCKET_CLI_LEGACY_BUILD,
217214
() =>
218-
JSON.stringify(
219-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD].
220-
!!constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD],
221-
),
215+
JSON.stringify(!!constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD]),
222216
],
223217
[
224218
INLINED_SOCKET_CLI_NAME,
@@ -228,17 +222,13 @@ export default function baseConfig(extendConfig = {}) {
228222
INLINED_SOCKET_CLI_PUBLISHED_BUILD,
229223
() =>
230224
JSON.stringify(
231-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_PUBLISHED_BUILD].
232225
!!constants.ENV[INLINED_SOCKET_CLI_PUBLISHED_BUILD],
233226
),
234227
],
235228
[
236229
INLINED_SOCKET_CLI_SENTRY_BUILD,
237230
() =>
238-
JSON.stringify(
239-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD].
240-
!!constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD],
241-
),
231+
JSON.stringify(!!constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]),
242232
],
243233
[
244234
INLINED_SOCKET_CLI_SYNP_VERSION,
@@ -252,12 +242,7 @@ export default function baseConfig(extendConfig = {}) {
252242
INLINED_SOCKET_CLI_VERSION_HASH,
253243
() => JSON.stringify(getSocketCliVersionHash()),
254244
],
255-
[
256-
VITEST,
257-
() =>
258-
// Lazily access constants.ENV[VITEST].
259-
!!constants.ENV[VITEST],
260-
],
245+
[VITEST, () => !!constants.ENV[VITEST]],
261246
].reduce((obj, { 0: name, 1: value }) => {
262247
obj[`process.env.${name}`] = value
263248
obj[`process.env['${name}']`] = value

.config/rollup.dist.config.mjs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,12 @@ const UTILS = 'utils'
7070
const VENDOR = 'vendor'
7171

7272
async function copyInitGradle() {
73-
// Lazily access constants path properties.
7473
const filepath = path.join(constants.srcPath, 'commands/manifest/init.gradle')
7574
const destPath = path.join(constants.distPath, 'init.gradle')
7675
await fs.copyFile(filepath, destPath)
7776
}
7877

7978
async function copyBashCompletion() {
80-
// Lazily access constants path properties.
8179
const filepath = path.join(
8280
constants.srcPath,
8381
'commands/install/socket-completion.bash',
@@ -87,7 +85,6 @@ async function copyBashCompletion() {
8785
}
8886

8987
async function copyExternalPackages() {
90-
// Lazily access constants path properties.
9188
const { blessedContribPath, blessedPath, socketRegistryPath } = constants
9289
const nmPath = path.join(constants.rootPath, NODE_MODULES)
9390
const blessedContribNmPath = path.join(nmPath, BLESSED_CONTRIB)
@@ -160,7 +157,6 @@ async function copyExternalPackages() {
160157

161158
async function copyPackage(pkgName, options) {
162159
const { strict = true } = { __proto__: null, ...options }
163-
// Lazily access constants path properties.
164160
const nmPath = path.join(constants.rootPath, NODE_MODULES)
165161
const pkgDestPath = path.join(constants.externalPath, pkgName)
166162
const pkgNmPath = path.join(nmPath, pkgName)
@@ -200,7 +196,6 @@ async function getSentryManifest() {
200196
}
201197

202198
async function updatePackageJson() {
203-
// Lazily access constants.rootPath.
204199
const editablePkgJson = await readPackageJson(constants.rootPath, {
205200
editable: true,
206201
normalize: true,
@@ -213,7 +208,6 @@ async function updatePackageJson() {
213208
bin,
214209
dependencies: hasKeys(dependencies) ? dependencies : undefined,
215210
})
216-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD].
217211
if (constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD]) {
218212
editablePkgJson.update({
219213
name: SOCKET_CLI_LEGACY_PACKAGE_NAME,
@@ -222,9 +216,7 @@ async function updatePackageJson() {
222216
...bin,
223217
},
224218
})
225-
}
226-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD].
227-
else if (constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]) {
219+
} else if (constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]) {
228220
editablePkgJson.update({
229221
name: SOCKET_CLI_SENTRY_PACKAGE_NAME,
230222
description: SOCKET_DESCRIPTION_WITH_SENTRY,
@@ -244,7 +236,6 @@ async function updatePackageJson() {
244236
}
245237

246238
async function updatePackageLockFile() {
247-
// Lazily access constants.rootPackageLockPath.
248239
const { rootPackageLockPath } = constants
249240
if (!existsSync(rootPackageLockPath)) {
250241
return
@@ -262,17 +253,14 @@ async function updatePackageLockFile() {
262253
} else {
263254
delete rootPkg.dependencies
264255
}
265-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD].
266256
if (constants.ENV[INLINED_SOCKET_CLI_LEGACY_BUILD]) {
267257
lockJson.name = SOCKET_CLI_LEGACY_PACKAGE_NAME
268258
rootPkg.name = SOCKET_CLI_LEGACY_PACKAGE_NAME
269259
rootPkg.bin = toSortedObject({
270260
[SOCKET_CLI_BIN_NAME_ALIAS]: bin[SOCKET_CLI_BIN_NAME],
271261
...bin,
272262
})
273-
}
274-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD].
275-
else if (constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]) {
263+
} else if (constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]) {
276264
lockJson.name = SOCKET_CLI_SENTRY_PACKAGE_NAME
277265
rootPkg.name = SOCKET_CLI_SENTRY_PACKAGE_NAME
278266
rootPkg.bin = {
@@ -356,7 +344,6 @@ function resetDependencies(deps) {
356344
}
357345

358346
export default async () => {
359-
// Lazily access constants path properties.
360347
const { configPath, distPath, rootPath, srcPath } = constants
361348
const nmPath = normalizePath(path.join(rootPath, NODE_MODULES))
362349
const constantsSrcPath = normalizePath(path.join(srcPath, 'constants.mts'))
@@ -381,7 +368,6 @@ export default async () => {
381368
[CONSTANTS]: `${srcPath}/constants.mts`,
382369
[SHADOW_NPM_BIN]: `${srcPath}/shadow/npm/bin.mts`,
383370
[SHADOW_NPM_INJECT]: `${srcPath}/shadow/npm/inject.mts`,
384-
// Lazily access constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD].
385371
...(constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]
386372
? {
387373
[INSTRUMENT_WITH_SENTRY]: `${srcPath}/${INSTRUMENT_WITH_SENTRY}.mts`,

bin/cli.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,20 @@ const { spawn } = require(
1515
process.exitCode = 1
1616

1717
spawn(
18-
// Lazily access constants.execPath.
1918
constants.execPath,
2019
[
21-
// Lazily access constants.nodeNoWarningsFlags.
2220
...constants.nodeNoWarningsFlags,
23-
// Lazily access constants.nodeHardenFlags.
2421
...constants.nodeHardenFlags,
25-
// Lazily access constants.nodeMemoryFlags.
2622
...constants.nodeMemoryFlags,
27-
// Lazily access constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD.
2823
...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD
29-
? [
30-
'--require',
31-
// Lazily access constants.instrumentWithSentryPath.
32-
constants.instrumentWithSentryPath,
33-
]
24+
? ['--require', constants.instrumentWithSentryPath]
3425
: []),
35-
// Lazily access constants.distCliPath.
3626
constants.distCliPath,
3727
...process.argv.slice(2),
3828
],
3929
{
4030
env: {
4131
...process.env,
42-
// Lazily access constants.processEnv.
4332
...constants.processEnv,
4433
},
4534
stdio: 'inherit',

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ const sharedRulesForNode = {
142142
'test',
143143
'test.describe',
144144
],
145-
// Lazily access constants.maintainedNodeVersions.
146145
version: constants.maintainedNodeVersions.current,
147146
},
148147
],

scripts/constants.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,42 +64,28 @@ const LAZY_ENV = () => {
6464
}
6565

6666
const lazyBlessedContribPath = () =>
67-
// Lazily access constants.externalPath.
6867
path.join(constants.externalPath, 'blessed-contrib')
6968

70-
const lazyBlessedPath = () =>
71-
// Lazily access constants.externalPath.
72-
path.join(constants.externalPath, 'blessed')
69+
const lazyBlessedPath = () => path.join(constants.externalPath, 'blessed')
7370

74-
const lazyConfigPath = () =>
75-
// Lazily access constants.rootPath.
76-
path.join(constants.rootPath, '.config')
71+
const lazyConfigPath = () => path.join(constants.rootPath, '.config')
7772

78-
const lazyDistPath = () =>
79-
// Lazily access constants.rootPath.
80-
path.join(constants.rootPath, 'dist')
73+
const lazyDistPath = () => path.join(constants.rootPath, 'dist')
8174

82-
const lazyExternalPath = () =>
83-
// Lazily access constants.rootPath.
84-
path.join(constants.rootPath, 'external')
75+
const lazyExternalPath = () => path.join(constants.rootPath, 'external')
8576

8677
const lazyRootPackageJsonPath = () =>
87-
// Lazily access constants.rootPath.
8878
path.join(constants.rootPath, 'package.json')
8979

9080
const lazyRootPackageLockPath = () =>
91-
// Lazily access constants.rootPath.
9281
path.join(constants.rootPath, 'package-lock.json')
9382

9483
const lazyRootPath = () => path.resolve(__dirname, '..')
9584

9685
const lazySocketRegistryPath = () =>
97-
// Lazily access constants.externalPath.
9886
path.join(constants.externalPath, '@socketsecurity/registry')
9987

100-
const lazySrcPath = () =>
101-
// Lazily access constants.rootPath.
102-
path.join(constants.rootPath, 'src')
88+
const lazySrcPath = () => path.join(constants.rootPath, 'src')
10389

10490
const constants = createConstantsObject(
10591
{

src/cli.mts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@ void (async () => {
2424
const registryUrl = lookupRegistryUrl()
2525
await updateNotifier({
2626
authInfo: lookupRegistryAuthToken(registryUrl, { recursive: true }),
27-
// Lazily access constants.SOCKET_CLI_BIN_NAME.
2827
name: constants.SOCKET_CLI_BIN_NAME,
2928
registryUrl,
3029
ttl: 86_400_000 /* 24 hours in milliseconds */,
31-
// Lazily access constants.ENV.INLINED_SOCKET_CLI_VERSION.
3230
version: constants.ENV.INLINED_SOCKET_CLI_VERSION,
3331
})
3432

3533
try {
3634
await meowWithSubcommands(rootCommands, {
3735
aliases: rootAliases,
3836
argv: process.argv.slice(2),
39-
// Lazily access constants.SOCKET_CLI_BIN_NAME.
4037
name: constants.SOCKET_CLI_BIN_NAME,
4138
importMeta: { url: `${pathToFileURL(__filename)}` } as ImportMeta,
4239
})

src/commands/analytics/cmd-analytics.test.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import constants from '../../../src/constants.mts'
55
import { cmdit, invokeNpm } from '../../../test/utils.mts'
66

77
describe('socket analytics', async () => {
8-
// Lazily access constants.binCliPath.
98
const { binCliPath } = constants
109

1110
cmdit(

src/commands/analytics/output-analytics.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ ${mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
203203

204204
function displayAnalyticsScreen(data: FormattedData): void {
205205
const ScreenWidget = /*@__PURE__*/ require('blessed/lib/widgets/screen.js')
206-
// Lazily access constants.blessedOptions.
207206
const screen: Widgets.Screen = new ScreenWidget({
208207
...constants.blessedOptions,
209208
})

src/commands/audit-log/cmd-audit-log.test.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import constants from '../../../src/constants.mts'
44
import { cmdit, invokeNpm } from '../../../test/utils.mts'
55

66
describe('socket audit-log', async () => {
7-
// Lazily access constants.binCliPath.
87
const { binCliPath } = constants
98

109
cmdit(

src/commands/audit-log/output-audit-log.mts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export async function outputAsJson(
110110
ok: true,
111111
data: {
112112
desc: 'Audit logs for given query',
113-
// Lazily access constants.ENV.VITEST.
114113
generated: constants.ENV.VITEST ? REDACTED : new Date().toISOString(),
115114
logType,
116115
nextPage: auditLogs.data.nextPage,
@@ -212,7 +211,6 @@ async function outputWithBlessed(
212211

213212
// Note: this temporarily takes over the terminal (just like `man` does).
214213
const ScreenWidget = /*@__PURE__*/ require('blessed/lib/widgets/screen.js')
215-
// Lazily access constants.blessedOptions.
216214
const screen: Widgets.Screen = new ScreenWidget({
217215
...constants.blessedOptions,
218216
})

0 commit comments

Comments
 (0)