@alxwlw/stack 1.7.1 → 1.8.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/canon/catalogs.json +3 -3
- package/package.json +1 -1
- package/src/canon.ts +31 -2
- package/src/cli.ts +2 -1
- package/src/deps.ts +2 -0
- package/src/package-manager.ts +1 -1
package/canon/catalogs.json
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"dependency-cruiser": "18.6.0",
|
|
11
11
|
"vitest": "4.1.12",
|
|
12
12
|
"@playwright/test": "1.64.1",
|
|
13
|
-
"@alxwlw/stack": "1.
|
|
14
|
-
"@alxwlw/oxlint-config": "1.
|
|
15
|
-
"@alxwlw/tsconfig": "1.
|
|
13
|
+
"@alxwlw/stack": "1.8.0",
|
|
14
|
+
"@alxwlw/oxlint-config": "1.8.0",
|
|
15
|
+
"@alxwlw/tsconfig": "1.8.0"
|
|
16
16
|
},
|
|
17
17
|
"libs": {
|
|
18
18
|
"@nestjs/core": "12.2.0",
|
package/package.json
CHANGED
package/src/canon.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
|
|
5
|
-
import type
|
|
5
|
+
import { type Profile, type StackConfig, StackConfigError } from './config.ts';
|
|
6
6
|
|
|
7
7
|
export type SyncStrategy = 'verbatim' | 'create-if-absent';
|
|
8
8
|
|
|
@@ -49,7 +49,36 @@ export function loadCatalogs(dir: string = canonDir()): CanonCatalogs {
|
|
|
49
49
|
return JSON.parse(readFileSync(join(dir, 'catalogs.json'), 'utf8')) as CanonCatalogs;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// Устаревшие группы принимаются ради старых .stack.jsonc и ничего не включают.
|
|
53
|
+
export const DEPRECATED_GROUPS: readonly string[] = ['renovate'];
|
|
54
|
+
|
|
55
|
+
export interface CanonGroups {
|
|
56
|
+
files: string[];
|
|
57
|
+
catalogs: string[];
|
|
58
|
+
deprecated: readonly string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Единственный источник имён групп: файловые — поле group манифеста, каталожные — ключи catalogs.json.
|
|
62
|
+
export function canonGroups(dir: string = canonDir()): CanonGroups {
|
|
63
|
+
const files = [...new Set(loadManifest(dir).flatMap((f) => (f.group == null ? [] : [f.group])))];
|
|
64
|
+
const catalogs = Object.keys(loadCatalogs(dir)).filter((g) => g !== 'dev');
|
|
65
|
+
return { files, catalogs, deprecated: DEPRECATED_GROUPS };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function assertKnownGroups(groups: readonly string[], dir: string = canonDir()): void {
|
|
69
|
+
const g = canonGroups(dir);
|
|
70
|
+
const known = [...g.files, ...g.catalogs, ...g.deprecated].sort();
|
|
71
|
+
for (const name of groups) {
|
|
72
|
+
if (!known.includes(name)) {
|
|
73
|
+
throw new StackConfigError(
|
|
74
|
+
`unknown group "${name}" in "with", expected one of: ${known.join(', ')}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
52
80
|
export function loadCanon(cfg: StackConfig, dir: string = canonDir()): Canon {
|
|
81
|
+
assertKnownGroups(cfg.with, dir);
|
|
53
82
|
const files = filesFor(cfg, dir).map((f) => ({
|
|
54
83
|
dest: f.dest,
|
|
55
84
|
content: readFileSync(join(dir, f.src), 'utf8'),
|
|
@@ -57,7 +86,7 @@ export function loadCanon(cfg: StackConfig, dir: string = canonDir()): Canon {
|
|
|
57
86
|
satisfiedBy: f.satisfiedBy,
|
|
58
87
|
}));
|
|
59
88
|
const all = loadCatalogs(dir);
|
|
60
|
-
const groups = ['dev', ...cfg.with
|
|
89
|
+
const groups = ['dev', ...cfg.with];
|
|
61
90
|
const catalogs = Object.fromEntries(
|
|
62
91
|
groups.filter((g) => g in all).map((g) => [g, all[g] as Record<string, string>]),
|
|
63
92
|
);
|
package/src/cli.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
4
|
|
|
5
|
-
import { loadCanon } from './canon.ts';
|
|
5
|
+
import { assertKnownGroups, loadCanon } from './canon.ts';
|
|
6
6
|
import { checkRepo, syncRepo } from './check.ts';
|
|
7
7
|
import { type Profile, PROFILES, readStackConfig, StackConfigError } from './config.ts';
|
|
8
8
|
import { type Finding, isDrift } from './findings.ts';
|
|
@@ -54,6 +54,7 @@ try {
|
|
|
54
54
|
if (!PROFILES.includes(profile as Profile)) {
|
|
55
55
|
fail(`unknown --profile "${profile}", expected one of: ${PROFILES.join(', ')}`);
|
|
56
56
|
}
|
|
57
|
+
assertKnownGroups(values.with ?? []);
|
|
57
58
|
const path = initConfig(repoRoot, { profile: profile as Profile, with: values.with ?? [] });
|
|
58
59
|
console.log(`created ${path}`);
|
|
59
60
|
} else if (command === 'sync') {
|
package/src/deps.ts
CHANGED
|
@@ -50,6 +50,8 @@ export function checkEnginesNode(repoRoot: string, canon: Canon): Finding[] {
|
|
|
50
50
|
try {
|
|
51
51
|
pkg = JSON.parse(readFileSync(path, 'utf8')) as { engines?: { node?: string } };
|
|
52
52
|
} catch (err) {
|
|
53
|
+
// С pnpm-workspace.yaml checkInlineVersions сканирует и корневой package.json: её находка уже есть.
|
|
54
|
+
if (existsSync(join(repoRoot, 'pnpm-workspace.yaml'))) return [];
|
|
53
55
|
return [
|
|
54
56
|
{
|
|
55
57
|
code: 'unreadable-file',
|
package/src/package-manager.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function planPackageManager(repoRoot: string, canon: Canon): Drift[] {
|
|
|
17
17
|
try {
|
|
18
18
|
current = (JSON.parse(text) as { packageManager?: unknown }).packageManager;
|
|
19
19
|
} catch {
|
|
20
|
-
// Нечитаемый package.json — находка unreadable-file у checkEnginesNode, не здесь.
|
|
20
|
+
// Нечитаемый package.json — находка unreadable-file у checkInlineVersions (есть pnpm-workspace.yaml) или у checkEnginesNode (нет), не здесь.
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
23
23
|
if (typeof current !== 'string' || !current.startsWith('pnpm@')) return [];
|