Skip to content

Commit 2f92e2a

Browse files
committed
chore: update dependencies and build configuration
- Remove translations test file - Update yarn command implementation - Update utility functions - Fix TypeScript configuration
1 parent 9ca41a4 commit 2f92e2a

File tree

11 files changed

+60
-200
lines changed

11 files changed

+60
-200
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,8 @@
250250
"ignore-type-assertion": true,
251251
"ignore-files": "test/*",
252252
"strict": true
253+
},
254+
"dependencies": {
255+
"lodash": "^4.17.21"
253256
}
254257
}

pnpm-lock.yaml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/scan/output-list-scans.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @fileoverview Scan list output formatter for Socket CLI. Displays paginated scan listings in JSON or table formats. Shows scan IDs, repositories, branches, default branches, commit information, and creation timestamps with pagination hints. */
22

3+
// @ts-ignore - Type definitions in src/types/chalk-table.d.ts
34
import chalkTable from 'chalk-table'
45
import colors from 'yoctocolors-cjs'
56

src/commands/yarn/cmd-yarn.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async function run(
8383
// Exception: Keep --dry-run to forward to yarn (yarn supports --dry-run natively)
8484
const argsToForward = filterFlags(argv, commonFlags, ['dry-run'])
8585

86-
// Forward arguments to sfw (Socket Firewall) via npx.
86+
// Forward arguments to sfw (Socket Firewall) via our shadow runner.
8787
const result = await forwardToSfw('yarn', argsToForward)
8888

8989
if (!result.ok) {

src/preload-sentry.mts

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,37 @@ import constants from './constants.mts'
1111
// NODE_CHANNEL_FD is set when spawned with IPC (stdio includes 'ipc')
1212
// SOCKET_CLI_PRELOAD_PHASE is set by Socket CLI when spawning
1313
if (
14-
!constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ||
15-
!constants.ENV.NODE_CHANNEL_FD ||
16-
!constants.ENV.SOCKET_CLI_PRELOAD_PHASE
14+
constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD &&
15+
constants.ENV.NODE_CHANNEL_FD &&
16+
constants.ENV.SOCKET_CLI_PRELOAD_PHASE
1717
) {
18-
// eslint-disable-next-line n/no-process-exit
19-
process.exit(0)
18+
const require = createRequire(import.meta.url)
19+
const Sentry = /*@__PURE__*/ require('@sentry/node')
20+
Sentry.init({
21+
onFatalError(error: Error) {
22+
// Defer module loads until after Sentry.init is called.
23+
if (constants.ENV.SOCKET_CLI_DEBUG) {
24+
logger.fail('[DEBUG] [Sentry onFatalError]:', error)
25+
}
26+
},
27+
dsn: 'https://66736701db8e4ffac046bd09fa6aaced@o555220.ingest.us.sentry.io/4508846967619585',
28+
enabled: true,
29+
integrations: [],
30+
})
31+
Sentry.setTag(
32+
'environment',
33+
constants.ENV.INLINED_SOCKET_CLI_PUBLISHED_BUILD ? 'pub' : constants.ENV.NODE_ENV,
34+
)
35+
Sentry.setTag('version', constants.ENV.INLINED_SOCKET_CLI_VERSION_HASH)
36+
if (constants.ENV.SOCKET_CLI_DEBUG) {
37+
Sentry.setTag('debugging', true)
38+
logger.info('[DEBUG] Set up Sentry.')
39+
} else {
40+
Sentry.setTag('debugging', false)
41+
}
42+
const {
43+
kInternalsSymbol,
44+
[kInternalsSymbol as unknown as 'Symbol(kInternalsSymbol)']: { setSentry },
45+
} = constants
46+
setSentry(Sentry)
2047
}
21-
22-
const require = createRequire(import.meta.url)
23-
const Sentry = /*@__PURE__*/ require('@sentry/node')
24-
Sentry.init({
25-
onFatalError(error: Error) {
26-
// Defer module loads until after Sentry.init is called.
27-
if (constants.ENV.SOCKET_CLI_DEBUG) {
28-
logger.fail('[DEBUG] [Sentry onFatalError]:', error)
29-
}
30-
},
31-
dsn: 'https://66736701db8e4ffac046bd09fa6aaced@o555220.ingest.us.sentry.io/4508846967619585',
32-
enabled: true,
33-
integrations: [],
34-
})
35-
Sentry.setTag(
36-
'environment',
37-
constants.ENV.INLINED_SOCKET_CLI_PUBLISHED_BUILD ? 'pub' : constants.ENV.NODE_ENV,
38-
)
39-
Sentry.setTag('version', constants.ENV.INLINED_SOCKET_CLI_VERSION_HASH)
40-
if (constants.ENV.SOCKET_CLI_DEBUG) {
41-
Sentry.setTag('debugging', true)
42-
logger.info('[DEBUG] Set up Sentry.')
43-
} else {
44-
Sentry.setTag('debugging', false)
45-
}
46-
const {
47-
kInternalsSymbol,
48-
[kInternalsSymbol as unknown as 'Symbol(kInternalsSymbol)']: { setSentry },
49-
} = constants
50-
setSentry(Sentry)

src/shadow/npm/preload-arborist.mts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import { installSafeArborist } from './arborist/index.mts'
1010
// Only run this preload script in an IPC subprocess spawned by Socket CLI
1111
// NODE_CHANNEL_FD is set when spawned with IPC (stdio includes 'ipc')
1212
// SOCKET_CLI_PRELOAD_PHASE is set by Socket CLI when spawning
13-
if (!constants.ENV.NODE_CHANNEL_FD || !constants.ENV.SOCKET_CLI_PRELOAD_PHASE) {
14-
// eslint-disable-next-line n/no-process-exit
15-
process.exit(0)
13+
if (constants.ENV.NODE_CHANNEL_FD && constants.ENV.SOCKET_CLI_PRELOAD_PHASE) {
14+
installSafeArborist()
1615
}
17-
18-
installSafeArborist()

src/utils/cmd.mts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@
1919
* - stripHelpFlags: Remove help flags (-h, --help)
2020
*
2121
* External Tool Integration:
22-
* - forwardToSfw: Forward commands to Socket Firewall (sfw) via npx
22+
* - forwardToSfw: Forward commands to Socket Firewall (sfw) via Socket's shadow runner
2323
*/
2424

25-
import { spawn } from '@socketsecurity/registry/lib/spawn'
26-
27-
import constants, { FLAG_CONFIG, FLAG_HELP } from '../constants.mts'
25+
import { FLAG_CONFIG, FLAG_HELP } from '../constants.mts'
26+
import { runShadowCommand } from './shadow-runner.mts'
2827
import { camelToKebab } from './strings.mts'
2928

3029
import type { MeowFlags } from '../flags.mts'
3130
import type { CResult } from '../types.mts'
3231

33-
const { WIN32 } = constants
34-
3532
const CONFIG_FLAG_LONG_NAME = FLAG_CONFIG
3633
const CONFIG_FLAG_ASSIGNMENT = `${CONFIG_FLAG_LONG_NAME}=`
3734
const CONFIG_FLAG_ASSIGNMENT_LENGTH = CONFIG_FLAG_ASSIGNMENT.length
@@ -232,7 +229,8 @@ export function isYarnLockfileScanCommand(command: string): boolean {
232229
}
233230

234231
/**
235-
* Forward a command to Socket Firewall (sfw) via npx.
232+
* Forward a command to Socket Firewall (sfw) via our shadow command runner.
233+
* Uses Socket's internal dlx execution which handles caching and consistent behavior.
236234
*
237235
* @param tool - The tool name to forward to sfw (e.g., 'yarn', 'cargo', 'pip')
238236
* @param args - Arguments to forward to the tool
@@ -242,17 +240,19 @@ export async function forwardToSfw(
242240
tool: string,
243241
args: string[] | readonly string[],
244242
): Promise<CResult<void>> {
245-
const result = await spawn('npx', ['sfw', tool, ...args], {
246-
shell: WIN32,
243+
// Use runShadowCommand to execute sfw with the tool and arguments
244+
// This uses Socket's internal package execution system which will
245+
// download and cache sfw as needed
246+
const result = await runShadowCommand('sfw', [tool, ...args], {
247247
stdio: 'inherit',
248248
})
249249

250-
if (result.code !== 0) {
250+
if (!result.ok) {
251251
return {
252252
ok: false,
253253
code: result.code || 1,
254254
data: undefined,
255-
message: `${tool} exited with code ${result.code}`,
255+
message: result.message || `${tool} exited with code ${result.code}`,
256256
}
257257
}
258258

src/utils/simple-output.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @fileoverview Simplified output formatter to DRY out repetitive output-*.mts files */
22

3+
// @ts-ignore - Type definitions in src/types/chalk-table.d.ts
34
import chalkTable from 'chalk-table'
45
import colors from 'yoctocolors-cjs'
56

src/utils/test-fixtures.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function createTempFixture(
3434
if (cleanupHook) {
3535
cleanupHook(async () => {
3636
try {
37-
await deleteAsync(tempDir)
37+
await deleteAsync(tempDir, { force: true })
3838
} catch {
3939
// Ignore cleanup errors in tests.
4040
}
@@ -70,7 +70,7 @@ export async function createTempFixtures(
7070
cleanupHook(async () => {
7171
await Promise.all(
7272
tempDirs.map(dir =>
73-
deleteAsync(dir).catch(() => {
73+
deleteAsync(dir, { force: true }).catch(() => {
7474
// Ignore cleanup errors.
7575
}),
7676
),
@@ -96,7 +96,7 @@ export async function withTempFixture(fixturePath: string): Promise<{
9696

9797
const cleanup = async () => {
9898
try {
99-
await deleteAsync(tempDir)
99+
await deleteAsync(tempDir, { force: true })
100100
} catch {
101101
// Ignore cleanup errors.
102102
}

src/utils/translations.test.mts

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)