next-issue 17.2.5 → 17.2.6
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/dist/shared/setup.mjs +27 -12
- package/package.json +1 -1
package/dist/shared/setup.mjs
CHANGED
|
@@ -2,12 +2,14 @@ import { access } from 'node:fs/promises';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { message, parseJson } from './errors.mjs';
|
|
4
4
|
import { readTextIfPresent } from './files.mjs';
|
|
5
|
-
const
|
|
5
|
+
const JS_MARKERS = [
|
|
6
6
|
['pnpm-lock.yaml', 'pnpm install --frozen-lockfile'],
|
|
7
7
|
['package-lock.json', 'npm ci'],
|
|
8
8
|
['yarn.lock', 'yarn install --frozen-lockfile'],
|
|
9
9
|
['bun.lock', 'bun install --frozen-lockfile'],
|
|
10
10
|
['bun.lockb', 'bun install --frozen-lockfile'],
|
|
11
|
+
];
|
|
12
|
+
const OTHER_MARKERS = [
|
|
11
13
|
['Cargo.lock', 'cargo fetch --locked'],
|
|
12
14
|
['go.sum', 'go mod download'],
|
|
13
15
|
['uv.lock', 'uv sync --locked'],
|
|
@@ -17,21 +19,34 @@ const MARKERS = [
|
|
|
17
19
|
function exists(path) {
|
|
18
20
|
return access(path).then(() => true, () => false);
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
for (const
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
if (file === 'yarn.lock' && (await exists(join(root, '.yarnrc.yml')))) {
|
|
26
|
-
return 'yarn install --immutable';
|
|
22
|
+
async function firstMatch(root, markers) {
|
|
23
|
+
for (const marker of markers) {
|
|
24
|
+
if (await exists(join(root, marker[0]))) {
|
|
25
|
+
return marker;
|
|
27
26
|
}
|
|
28
|
-
return command;
|
|
29
|
-
}
|
|
30
|
-
if (await exists(join(root, 'package.json'))) {
|
|
31
|
-
return 'npm install --no-package-lock';
|
|
32
27
|
}
|
|
33
28
|
return undefined;
|
|
34
29
|
}
|
|
30
|
+
async function jsLockCommand(root) {
|
|
31
|
+
const match = await firstMatch(root, JS_MARKERS);
|
|
32
|
+
if (match === undefined) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const [file, command] = match;
|
|
36
|
+
if (file === 'yarn.lock' && (await exists(join(root, '.yarnrc.yml')))) {
|
|
37
|
+
return 'yarn install --immutable';
|
|
38
|
+
}
|
|
39
|
+
return command;
|
|
40
|
+
}
|
|
41
|
+
export async function detectSetupCommand(root) {
|
|
42
|
+
const jsCommand = await jsLockCommand(root);
|
|
43
|
+
const otherCommand = (await firstMatch(root, OTHER_MARKERS))?.[1];
|
|
44
|
+
const fallback = jsCommand === undefined && (await exists(join(root, 'package.json')))
|
|
45
|
+
? 'npm install --no-package-lock'
|
|
46
|
+
: undefined;
|
|
47
|
+
const commands = [jsCommand, otherCommand, fallback].filter((command) => command !== undefined);
|
|
48
|
+
return commands.length === 0 ? undefined : commands.join(' && ');
|
|
49
|
+
}
|
|
35
50
|
export const SCRIPTS = ['format', 'lint', 'typecheck', 'test'];
|
|
36
51
|
const RUNNERS = [
|
|
37
52
|
['pnpm-lock.yaml', 'pnpm run'],
|