|
1 | | -import { debugDir } from '@socketsecurity/registry/lib/debug' |
2 | | -import { logger } from '@socketsecurity/registry/lib/logger' |
3 | | - |
4 | 1 | import { coanaFix } from './coana-fix.mts' |
5 | | -import { npmFix } from './npm-fix.mts' |
6 | 2 | import { outputFixResult } from './output-fix-result.mts' |
7 | | -import { pnpmFix } from './pnpm-fix.mts' |
8 | | -import { CMD_NAME } from './shared.mts' |
9 | | -import { detectAndValidatePackageEnvironment } from '../../utils/package-environment.mts' |
10 | 3 |
|
11 | | -import type { FixConfig } from './agent-fix.mts' |
| 4 | +import type { FixConfig } from './types.mts' |
12 | 5 | import type { OutputKind } from '../../types.mts' |
13 | 6 | import type { Remap } from '@socketsecurity/registry/lib/objects' |
14 | 7 |
|
@@ -37,73 +30,8 @@ export async function handleFix({ |
37 | 30 | testScript, |
38 | 31 | unknownFlags, |
39 | 32 | }: HandleFixConfig) { |
40 | | - if (ghsas.length) { |
41 | | - await outputFixResult( |
42 | | - await coanaFix({ |
43 | | - autoMerge, |
44 | | - cwd, |
45 | | - ghsas, |
46 | | - limit, |
47 | | - minSatisfying, |
48 | | - orgSlug, |
49 | | - prCheck, |
50 | | - purls, |
51 | | - rangeStyle, |
52 | | - spinner, |
53 | | - test, |
54 | | - testScript, |
55 | | - unknownFlags, |
56 | | - }), |
57 | | - outputKind, |
58 | | - ) |
59 | | - return |
60 | | - } |
61 | | - |
62 | | - const pkgEnvCResult = await detectAndValidatePackageEnvironment(cwd, { |
63 | | - cmdName: CMD_NAME, |
64 | | - logger, |
65 | | - }) |
66 | | - if (!pkgEnvCResult.ok) { |
67 | | - await outputFixResult(pkgEnvCResult, outputKind) |
68 | | - return |
69 | | - } |
70 | | - |
71 | | - const { data: pkgEnvDetails } = pkgEnvCResult |
72 | | - if (!pkgEnvDetails) { |
73 | | - await outputFixResult( |
74 | | - { |
75 | | - ok: false, |
76 | | - message: 'No package found.', |
77 | | - cause: `No valid package environment found for project path: ${cwd}`, |
78 | | - }, |
79 | | - outputKind, |
80 | | - ) |
81 | | - return |
82 | | - } |
83 | | - |
84 | | - debugDir('inspect', { pkgEnvDetails }) |
85 | | - |
86 | | - const { agent, agentVersion } = pkgEnvDetails |
87 | | - const isNpm = agent === 'npm' |
88 | | - const isPnpm = agent === 'pnpm' |
89 | | - |
90 | | - if (!isNpm && !isPnpm) { |
91 | | - await outputFixResult( |
92 | | - { |
93 | | - ok: false, |
94 | | - message: 'Not supported.', |
95 | | - cause: `${agent} v${agentVersion} is not supported by this command.`, |
96 | | - }, |
97 | | - outputKind, |
98 | | - ) |
99 | | - return |
100 | | - } |
101 | | - |
102 | | - logger.info(`Fixing packages for ${agent} v${agentVersion}.\n`) |
103 | | - |
104 | | - const fixer = isNpm ? npmFix : pnpmFix |
105 | 33 | await outputFixResult( |
106 | | - await fixer(pkgEnvDetails, { |
| 34 | + await coanaFix({ |
107 | 35 | autoMerge, |
108 | 36 | cwd, |
109 | 37 | ghsas, |
|
0 commit comments