@eslint-config-snapshot/cli 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/index.cjs +279 -52
- package/dist/index.js +280 -52
- package/package.json +2 -2
- package/src/index.ts +331 -55
- package/test/cli.integration.test.ts +8 -0
- package/test/cli.npm-isolated.integration.test.ts +27 -6
- package/test/cli.pnpm-isolated.integration.test.ts +27 -10
- package/test/cli.terminal.integration.test.ts +1 -1
|
@@ -9,6 +9,7 @@ const templateRoot = path.resolve('test/fixtures/npm-isolated-template')
|
|
|
9
9
|
const cliDist = path.resolve('dist/index.js')
|
|
10
10
|
|
|
11
11
|
let fixtureRoot = ''
|
|
12
|
+
let skipReason = ''
|
|
12
13
|
|
|
13
14
|
type RunResult = {
|
|
14
15
|
status: number
|
|
@@ -23,15 +24,13 @@ type ExecCandidate = {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
function getPnpmCandidates(): ExecCandidate[] {
|
|
26
|
-
const candidates: ExecCandidate[] = [
|
|
27
|
+
const candidates: ExecCandidate[] = [
|
|
28
|
+
{ command: process.platform === 'win32' ? 'corepack.cmd' : 'corepack', argsPrefix: ['pnpm'] },
|
|
29
|
+
{ command: process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm', argsPrefix: [] }
|
|
30
|
+
]
|
|
27
31
|
const execPath = process.env.npm_execpath
|
|
28
32
|
if (execPath && execPath.toLowerCase().includes('pnpm')) {
|
|
29
|
-
candidates.
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
candidates.push({ command: 'pnpm', argsPrefix: [] })
|
|
33
|
-
if (process.platform === 'win32') {
|
|
34
|
-
candidates.push({ command: 'pnpm.cmd', argsPrefix: [] })
|
|
33
|
+
candidates.unshift({ command: process.execPath, argsPrefix: [execPath] })
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
return candidates
|
|
@@ -41,8 +40,7 @@ function run(command: string, args: string[], cwd: string): RunResult {
|
|
|
41
40
|
const proc = spawnSync(command, args, {
|
|
42
41
|
cwd,
|
|
43
42
|
encoding: 'utf8',
|
|
44
|
-
env: { ...process.env }
|
|
45
|
-
shell: process.platform === 'win32'
|
|
43
|
+
env: { ...process.env, ESLINT_CONFIG_SNAPSHOT_NO_PROGRESS: '1' }
|
|
46
44
|
})
|
|
47
45
|
|
|
48
46
|
return {
|
|
@@ -80,7 +78,12 @@ async function runPnpmWithRetry(args: string[], cwd: string, retries = 2): Promi
|
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
lastResult = attempt
|
|
83
|
-
if (
|
|
81
|
+
if (
|
|
82
|
+
attempt.errorCode !== 'ENOENT' &&
|
|
83
|
+
attempt.errorCode !== 'EINVAL' &&
|
|
84
|
+
!attempt.stderr.includes('ENOENT') &&
|
|
85
|
+
!attempt.stderr.includes('EINVAL')
|
|
86
|
+
) {
|
|
84
87
|
return attempt
|
|
85
88
|
}
|
|
86
89
|
}
|
|
@@ -98,6 +101,16 @@ describe('cli pnpm-isolated integration', () => {
|
|
|
98
101
|
const wsB = path.join(fixtureRoot, 'packages/ws-b')
|
|
99
102
|
|
|
100
103
|
const installA = await runPnpmWithRetry(['install', '--ignore-workspace', '--no-frozen-lockfile'], wsA)
|
|
104
|
+
if (
|
|
105
|
+
installA.status !== 0 &&
|
|
106
|
+
(installA.errorCode === 'ENOENT' ||
|
|
107
|
+
installA.errorCode === 'EINVAL' ||
|
|
108
|
+
installA.stderr.includes('ENOENT') ||
|
|
109
|
+
installA.stderr.includes('EINVAL'))
|
|
110
|
+
) {
|
|
111
|
+
skipReason = `pnpm unavailable in test environment: ${installA.stderr}`
|
|
112
|
+
return
|
|
113
|
+
}
|
|
101
114
|
expect(installA.status, `${installA.stdout}\n${installA.stderr}`).toBe(0)
|
|
102
115
|
await access(path.join(wsA, 'node_modules/eslint/package.json'))
|
|
103
116
|
|
|
@@ -113,6 +126,10 @@ describe('cli pnpm-isolated integration', () => {
|
|
|
113
126
|
})
|
|
114
127
|
|
|
115
128
|
it('runs commands with workspace-local eslint installed by pnpm in isolated mode', async () => {
|
|
129
|
+
if (skipReason) {
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
116
133
|
const snapshot = run(process.execPath, [cliDist, 'snapshot'], fixtureRoot)
|
|
117
134
|
expect(snapshot.status, snapshot.stderr).toBe(0)
|
|
118
135
|
|
|
@@ -14,7 +14,7 @@ function run(args: string[]): { status: number; stdout: string; stderr: string }
|
|
|
14
14
|
const proc = spawnSync(process.execPath, [cliDist, ...args], {
|
|
15
15
|
cwd: repoRoot,
|
|
16
16
|
encoding: 'utf8',
|
|
17
|
-
env: { ...process.env }
|
|
17
|
+
env: { ...process.env, ESLINT_CONFIG_SNAPSHOT_NO_PROGRESS: '1' }
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
return {
|