Skip to content

Commit 56fdeca

Browse files
committed
Seems I forgot to split the fix command
1 parent ad4cf00 commit 56fdeca

File tree

2 files changed

+53
-48
lines changed

2 files changed

+53
-48
lines changed

src/commands/fix/cmd-fix.ts

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import meowOrExit from 'meow'
22

3-
import { Spinner } from '@socketsecurity/registry/lib/spinner'
4-
5-
import constants from '../../constants'
6-
import { shadowNpmInstall } from '../../utils/npm'
3+
import { runFix } from './run-fix.ts'
74
import { getFlagListOutput } from '../../utils/output-formatting.ts'
85

96
import type { CliCommandConfig } from '../../utils/meow-with-subcommands.ts'
107

11-
const { SOCKET_CLI_IN_FIX_CMD, SOCKET_IPC_HANDSHAKE } = constants
12-
138
const config: CliCommandConfig = {
149
commandName: 'fix',
1510
description: 'Fix "fixable" Socket alerts',
@@ -42,46 +37,5 @@ async function run(
4237
flags: config.flags
4338
})
4439

45-
// const prev = new Set(alerts.map(a => a.key))
46-
// let ret: SafeNode | undefined
47-
// /* eslint-disable no-await-in-loop */
48-
// while (alerts.length > 0) {
49-
// await updateAdvisoryNodes(this, alerts)
50-
// ret = await this[kRiskyReify](...args)
51-
// await this.loadActual()
52-
// await this.buildIdealTree()
53-
// needInfoOn = getPackagesToQueryFromDiff(this.diff, {
54-
// includeUnchanged: true
55-
// })
56-
// alerts = (
57-
// await getPackagesAlerts(needInfoOn, {
58-
// includeExisting: true,
59-
// includeUnfixable: true
60-
// })
61-
// ).filter(({ key }) => {
62-
// const unseen = !prev.has(key)
63-
// if (unseen) {
64-
// prev.add(key)
65-
// }
66-
// return unseen
67-
// })
68-
// }
69-
// /* eslint-enable no-await-in-loop */
70-
// return ret!
71-
72-
const spinner = new Spinner().start()
73-
try {
74-
await shadowNpmInstall({
75-
ipc: {
76-
[SOCKET_IPC_HANDSHAKE]: {
77-
[SOCKET_CLI_IN_FIX_CMD]: true
78-
}
79-
}
80-
})
81-
} catch (e: any) {
82-
console.error(e)
83-
spinner.error()
84-
} finally {
85-
spinner.stop()
86-
}
40+
await runFix()
8741
}

src/commands/fix/run-fix.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Spinner } from '@socketsecurity/registry/lib/spinner'
2+
3+
import constants from '../../constants.ts'
4+
import { shadowNpmInstall } from '../../utils/npm.ts'
5+
6+
const { SOCKET_CLI_IN_FIX_CMD, SOCKET_IPC_HANDSHAKE } = constants
7+
8+
export async function runFix() {
9+
// const prev = new Set(alerts.map(a => a.key))
10+
// let ret: SafeNode | undefined
11+
// /* eslint-disable no-await-in-loop */
12+
// while (alerts.length > 0) {
13+
// await updateAdvisoryNodes(this, alerts)
14+
// ret = await this[kRiskyReify](...args)
15+
// await this.loadActual()
16+
// await this.buildIdealTree()
17+
// needInfoOn = getPackagesToQueryFromDiff(this.diff, {
18+
// includeUnchanged: true
19+
// })
20+
// alerts = (
21+
// await getPackagesAlerts(needInfoOn, {
22+
// includeExisting: true,
23+
// includeUnfixable: true
24+
// })
25+
// ).filter(({ key }) => {
26+
// const unseen = !prev.has(key)
27+
// if (unseen) {
28+
// prev.add(key)
29+
// }
30+
// return unseen
31+
// })
32+
// }
33+
// /* eslint-enable no-await-in-loop */
34+
// return ret!
35+
36+
const spinner = new Spinner().start()
37+
try {
38+
await shadowNpmInstall({
39+
ipc: {
40+
[SOCKET_IPC_HANDSHAKE]: {
41+
[SOCKET_CLI_IN_FIX_CMD]: true
42+
}
43+
}
44+
})
45+
} catch (e: any) {
46+
console.error(e)
47+
spinner.error()
48+
} finally {
49+
spinner.stop()
50+
}
51+
}

0 commit comments

Comments
 (0)