@alxwlw/stack 1.2.0 → 1.3.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/canon/files/renovate.template.json5 +6 -0
- package/canon/files/workflow-renovate.yml +19 -0
- package/canon/manifest.json +25 -7
- package/package.json +1 -1
- package/schema.json +1 -1
- package/src/canon.ts +5 -10
- package/src/check.ts +4 -4
- package/src/deps.ts +26 -72
- package/src/files.ts +7 -0
- package/src/findings.ts +2 -2
- package/canon/files/dependabot.template.yml +0 -10
package/canon/catalogs.json
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"dependency-cruiser": "18.1.0",
|
|
11
11
|
"vitest": "4.1.10",
|
|
12
12
|
"@playwright/test": "1.62.0",
|
|
13
|
-
"@alxwlw/stack": "1.
|
|
14
|
-
"@alxwlw/oxlint-config": "1.
|
|
15
|
-
"@alxwlw/tsconfig": "1.
|
|
13
|
+
"@alxwlw/stack": "1.3.0",
|
|
14
|
+
"@alxwlw/oxlint-config": "1.3.0",
|
|
15
|
+
"@alxwlw/tsconfig": "1.3.0"
|
|
16
16
|
},
|
|
17
17
|
"libs": {
|
|
18
18
|
"@nestjs/core": "12.0.1",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Repo-local Renovate config — YOURS to edit (seeded once by `stack sync`, never overwritten).
|
|
2
|
+
// Keep the canon preset in `extends`: it turns Renovate off for what `stack sync` moves.
|
|
3
|
+
{
|
|
4
|
+
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
|
|
5
|
+
extends: ['config:recommended', 'github>alxwlw/stack//renovate/canon.json5#v1'],
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Canon file — sync-managed: edits happen in alxwlw/stack, not here.
|
|
2
|
+
# Needs the RENOVATE_TOKEN secret (contents, pull requests, issues, workflows: write).
|
|
3
|
+
name: renovate
|
|
4
|
+
on:
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: '0 6 * * 1'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
log-level:
|
|
10
|
+
type: choice
|
|
11
|
+
options: [info, debug]
|
|
12
|
+
default: info
|
|
13
|
+
jobs:
|
|
14
|
+
renovate:
|
|
15
|
+
uses: alxwlw/stack/.github/workflows/renovate.yml@v1
|
|
16
|
+
with:
|
|
17
|
+
log-level: ${{ inputs.log-level || 'info' }}
|
|
18
|
+
secrets:
|
|
19
|
+
token: ${{ secrets.RENOVATE_TOKEN }}
|
package/canon/manifest.json
CHANGED
|
@@ -74,13 +74,6 @@
|
|
|
74
74
|
"appliesTo": ["node", "contracts"],
|
|
75
75
|
"strategy": "create-if-absent"
|
|
76
76
|
},
|
|
77
|
-
{
|
|
78
|
-
"src": "files/dependabot.template.yml",
|
|
79
|
-
"dest": ".github/dependabot.yml",
|
|
80
|
-
"appliesTo": ["node", "contracts"],
|
|
81
|
-
"strategy": "create-if-absent",
|
|
82
|
-
"unlessWith": "renovate"
|
|
83
|
-
},
|
|
84
77
|
{
|
|
85
78
|
"src": "files/oxlintrc.template.json",
|
|
86
79
|
"dest": ".oxlintrc.json",
|
|
@@ -154,6 +147,31 @@
|
|
|
154
147
|
"src": "files/workflow-stack-sync.yml",
|
|
155
148
|
"dest": ".github/workflows/stack-sync.yml",
|
|
156
149
|
"appliesTo": ["node", "contracts", "infra"]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"src": "files/workflow-renovate.yml",
|
|
153
|
+
"dest": ".github/workflows/renovate.yml",
|
|
154
|
+
"appliesTo": ["node", "contracts", "infra"]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"src": "files/renovate.template.json5",
|
|
158
|
+
"dest": "renovate.json5",
|
|
159
|
+
"appliesTo": ["node", "contracts", "infra"],
|
|
160
|
+
"strategy": "create-if-absent",
|
|
161
|
+
"satisfiedBy": [
|
|
162
|
+
"renovate.json",
|
|
163
|
+
"renovate.jsonc",
|
|
164
|
+
".github/renovate.json",
|
|
165
|
+
".github/renovate.jsonc",
|
|
166
|
+
".github/renovate.json5",
|
|
167
|
+
".gitlab/renovate.json",
|
|
168
|
+
".gitlab/renovate.jsonc",
|
|
169
|
+
".gitlab/renovate.json5",
|
|
170
|
+
".renovaterc",
|
|
171
|
+
".renovaterc.json",
|
|
172
|
+
".renovaterc.jsonc",
|
|
173
|
+
".renovaterc.json5"
|
|
174
|
+
]
|
|
157
175
|
}
|
|
158
176
|
]
|
|
159
177
|
}
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"with": {
|
|
13
13
|
"type": "array",
|
|
14
|
-
"description": "Opt-in canon groups.",
|
|
14
|
+
"description": "Opt-in canon groups. \"renovate\" is deprecated and does nothing: Renovate is the canon's dependency bot for every profile.",
|
|
15
15
|
"items": {
|
|
16
16
|
"type": "string",
|
|
17
17
|
"enum": ["moon-tasks", "libs", "knip", "depcruise", "renovate"]
|
package/src/canon.ts
CHANGED
|
@@ -13,8 +13,8 @@ export interface CanonFile {
|
|
|
13
13
|
strategy?: SyncStrategy;
|
|
14
14
|
/** Группа, включаемая через `with` в .stack.jsonc. Без группы файл обязателен всем. */
|
|
15
15
|
group?: string;
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/** Для create-if-absent: другие пути, любой из которых тоже закрывает засев (у конфига несколько законных имён). */
|
|
17
|
+
satisfiedBy?: string[];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export type CanonCatalogs = Record<string, Record<string, string>>;
|
|
@@ -22,12 +22,10 @@ export type CanonCatalogs = Record<string, Record<string, string>>;
|
|
|
22
22
|
// Канон одного прогона как значение: уже отфильтрован под профиль и группы, содержимое файлов
|
|
23
23
|
// прочитано, пины node и pnpm вычислены. Правила и план принимают его и не знают, где лежит каталог.
|
|
24
24
|
export interface Canon {
|
|
25
|
-
files: { dest: string; content: string; strategy?: SyncStrategy }[];
|
|
25
|
+
files: { dest: string; content: string; strategy?: SyncStrategy; satisfiedBy?: string[] }[];
|
|
26
26
|
catalogs: CanonCatalogs;
|
|
27
27
|
nodePin: string;
|
|
28
28
|
pnpmPin: string;
|
|
29
|
-
/** Бот зависимостей репо. renovate добавляет правило renovate-ignore (конфиг Renovate должен отключать `@alxwlw/*`); dependabot-ignore по-прежнему проверяет .github/dependabot.yml, если файл есть. */
|
|
30
|
-
bot?: 'dependabot' | 'renovate';
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
export function canonDir(): string {
|
|
@@ -43,10 +41,7 @@ export function loadManifest(dir: string = canonDir()): CanonFile[] {
|
|
|
43
41
|
|
|
44
42
|
export function filesFor(cfg: StackConfig, dir: string = canonDir()): CanonFile[] {
|
|
45
43
|
return loadManifest(dir).filter(
|
|
46
|
-
(f) =>
|
|
47
|
-
f.appliesTo.includes(cfg.profile) &&
|
|
48
|
-
(f.group == null || cfg.with.includes(f.group)) &&
|
|
49
|
-
(f.unlessWith == null || !cfg.with.includes(f.unlessWith)),
|
|
44
|
+
(f) => f.appliesTo.includes(cfg.profile) && (f.group == null || cfg.with.includes(f.group)),
|
|
50
45
|
);
|
|
51
46
|
}
|
|
52
47
|
|
|
@@ -59,6 +54,7 @@ export function loadCanon(cfg: StackConfig, dir: string = canonDir()): Canon {
|
|
|
59
54
|
dest: f.dest,
|
|
60
55
|
content: readFileSync(join(dir, f.src), 'utf8'),
|
|
61
56
|
strategy: f.strategy,
|
|
57
|
+
satisfiedBy: f.satisfiedBy,
|
|
62
58
|
}));
|
|
63
59
|
const all = loadCatalogs(dir);
|
|
64
60
|
const groups = ['dev', ...cfg.with.filter((g) => g !== 'dev')];
|
|
@@ -81,6 +77,5 @@ export function loadCanon(cfg: StackConfig, dir: string = canonDir()): Canon {
|
|
|
81
77
|
catalogs,
|
|
82
78
|
nodePin: pin[1],
|
|
83
79
|
pnpmPin: pnpm[1],
|
|
84
|
-
bot: cfg.with.includes('renovate') ? 'renovate' : 'dependabot',
|
|
85
80
|
};
|
|
86
81
|
}
|
package/src/check.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { Canon } from './canon.ts';
|
|
|
2
2
|
import { planCatalogs } from './catalogs.ts';
|
|
3
3
|
import type { Exception } from './config.ts';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
checkDependabot,
|
|
6
6
|
checkEnginesNode,
|
|
7
7
|
checkInlineVersions,
|
|
8
|
-
|
|
8
|
+
checkRenovatePreset,
|
|
9
9
|
} from './deps.ts';
|
|
10
10
|
import { planFiles } from './files.ts';
|
|
11
11
|
import { applyExceptions, covers, type Drift, type Finding } from './findings.ts';
|
|
@@ -48,8 +48,8 @@ export function checkRepo(repoRoot: string, canon: Canon, exceptions: Exception[
|
|
|
48
48
|
...planRepo(repoRoot, canon),
|
|
49
49
|
...checkInlineVersions(repoRoot, canon),
|
|
50
50
|
...checkEnginesNode(repoRoot, canon),
|
|
51
|
-
...
|
|
52
|
-
...(
|
|
51
|
+
...checkRenovatePreset(repoRoot),
|
|
52
|
+
...checkDependabot(repoRoot),
|
|
53
53
|
],
|
|
54
54
|
exceptions,
|
|
55
55
|
);
|
package/src/deps.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { join } from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
import { Glob } from 'bun';
|
|
5
5
|
import JSON5 from 'json5';
|
|
6
|
-
import { parse as parseYaml } from 'yaml';
|
|
7
6
|
|
|
8
7
|
import type { Canon } from './canon.ts';
|
|
9
8
|
import type { Finding } from './findings.ts';
|
|
@@ -71,52 +70,9 @@ export function checkEnginesNode(repoRoot: string, canon: Canon): Finding[] {
|
|
|
71
70
|
];
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
// Формы дальше — только то, что нужно прочитать; настоящий dependabot.yml несёт больше полей.
|
|
75
|
-
interface DependabotYaml {
|
|
76
|
-
updates?: unknown;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function ignoresAlxwlw(doc: unknown): boolean {
|
|
80
|
-
const updates = (doc as DependabotYaml | null)?.updates;
|
|
81
|
-
if (!Array.isArray(updates)) return false;
|
|
82
|
-
return updates.some((u) => {
|
|
83
|
-
const ignore = (u as { ignore?: unknown } | null)?.ignore;
|
|
84
|
-
return (
|
|
85
|
-
Array.isArray(ignore) &&
|
|
86
|
-
ignore.some(
|
|
87
|
-
(i) => (i as { 'dependency-name'?: unknown } | null)?.['dependency-name'] === '@alxwlw/*',
|
|
88
|
-
)
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function checkDependabotIgnore(repoRoot: string): Finding[] {
|
|
94
|
-
if (!existsSync(join(repoRoot, 'pnpm-workspace.yaml'))) return [];
|
|
95
|
-
const path = join(repoRoot, '.github/dependabot.yml');
|
|
96
|
-
if (!existsSync(path)) return [];
|
|
97
|
-
const finding: Finding = {
|
|
98
|
-
code: 'dependabot-ignore',
|
|
99
|
-
target: '.github/dependabot.yml',
|
|
100
|
-
message: 'missing an ignore for "@alxwlw/*" — the bot will fight the canon rollout',
|
|
101
|
-
};
|
|
102
|
-
let doc: unknown;
|
|
103
|
-
try {
|
|
104
|
-
doc = parseYaml(readFileSync(path, 'utf8'));
|
|
105
|
-
} catch {
|
|
106
|
-
return [
|
|
107
|
-
{
|
|
108
|
-
code: 'unreadable-file',
|
|
109
|
-
target: '.github/dependabot.yml',
|
|
110
|
-
message: '.github/dependabot.yml does not parse as YAML',
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
}
|
|
114
|
-
return ignoresAlxwlw(doc) ? [] : [finding];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
73
|
// Имена и порядок поиска — как у самого Renovate (renovate.json{,c,5} для каждого места; первый
|
|
118
74
|
// найденный файл и есть конфиг), без устаревшего package.json#renovate. JSON5.parse читает и JSONC.
|
|
119
|
-
const RENOVATE_CONFIGS = [
|
|
75
|
+
export const RENOVATE_CONFIGS = [
|
|
120
76
|
'renovate.json',
|
|
121
77
|
'renovate.jsonc',
|
|
122
78
|
'renovate.json5',
|
|
@@ -131,34 +87,20 @@ const RENOVATE_CONFIGS = [
|
|
|
131
87
|
'.renovaterc.jsonc',
|
|
132
88
|
'.renovaterc.json5',
|
|
133
89
|
];
|
|
134
|
-
//
|
|
135
|
-
|
|
90
|
+
// Строка подключения пресета канона. Ровно с тегом мажора: без тега или с #main потребитель
|
|
91
|
+
// получал бы неопубликованный канон, а пресет — тот же источник, что и rollout (плавающий v1).
|
|
92
|
+
export const STACK_RENOVATE_PRESET = 'github>alxwlw/stack//renovate/canon.json5#v1';
|
|
136
93
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return rules.some((r) => {
|
|
141
|
-
const rule = r as { enabled?: unknown; matchPackageNames?: unknown } | null;
|
|
142
|
-
return (
|
|
143
|
-
rule?.enabled === false &&
|
|
144
|
-
Array.isArray(rule.matchPackageNames) &&
|
|
145
|
-
rule.matchPackageNames.some((n) => typeof n === 'string' && ALXWLW_GLOBS.has(n))
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Группа renovate: версии @alxwlw/* двигает stack sync, бот должен их не трогать — иначе его PR
|
|
151
|
-
// разводят каталог с каноном и check краснеет. Группировка (groupName) не мешает боту — нужен
|
|
152
|
-
// enabled: false.
|
|
153
|
-
export function checkRenovateIgnore(repoRoot: string): Finding[] {
|
|
154
|
-
if (!existsSync(join(repoRoot, 'pnpm-workspace.yaml'))) return [];
|
|
94
|
+
// Пресет выключает Renovate для всего, что двигает stack sync (proto, каталоги канона dev и libs, @alxwlw/*,
|
|
95
|
+
// ссылки alxwlw/stack) — без него бот и rollout перетягивают одни версии. Профиль не важен.
|
|
96
|
+
export function checkRenovatePreset(repoRoot: string): Finding[] {
|
|
155
97
|
const found = RENOVATE_CONFIGS.find((p) => existsSync(join(repoRoot, p)));
|
|
156
98
|
if (!found) {
|
|
157
99
|
return [
|
|
158
100
|
{
|
|
159
|
-
code: 'renovate-
|
|
160
|
-
target: 'renovate.
|
|
161
|
-
message: `no Renovate config found
|
|
101
|
+
code: 'renovate-preset',
|
|
102
|
+
target: 'renovate.json5',
|
|
103
|
+
message: `no Renovate config found — stack sync seeds renovate.json5; an own config must extend "${STACK_RENOVATE_PRESET}"`,
|
|
162
104
|
},
|
|
163
105
|
];
|
|
164
106
|
}
|
|
@@ -170,14 +112,26 @@ export function checkRenovateIgnore(repoRoot: string): Finding[] {
|
|
|
170
112
|
{ code: 'unreadable-file', target: found, message: `${found} does not parse as JSON5` },
|
|
171
113
|
];
|
|
172
114
|
}
|
|
173
|
-
|
|
115
|
+
const ext = (doc as { extends?: unknown } | null)?.extends;
|
|
116
|
+
return Array.isArray(ext) && ext.includes(STACK_RENOVATE_PRESET)
|
|
174
117
|
? []
|
|
175
118
|
: [
|
|
176
119
|
{
|
|
177
|
-
code: 'renovate-
|
|
120
|
+
code: 'renovate-preset',
|
|
178
121
|
target: found,
|
|
179
|
-
message:
|
|
180
|
-
'no packageRules entry with matchPackageNames "@alxwlw/**" and enabled: false — the bot will fight the canon rollout',
|
|
122
|
+
message: `"extends" must include "${STACK_RENOVATE_PRESET}" — without the canon preset the bot fights stack sync`,
|
|
181
123
|
},
|
|
182
124
|
];
|
|
183
125
|
}
|
|
126
|
+
|
|
127
|
+
const DEPENDABOT_CONFIGS = ['.github/dependabot.yml', '.github/dependabot.yaml'];
|
|
128
|
+
|
|
129
|
+
// Renovate — единственный бот канона: второй бот открывал бы те же PR, а dependabot не умеет
|
|
130
|
+
// выключить каталоги канона или .prototools.
|
|
131
|
+
export function checkDependabot(repoRoot: string): Finding[] {
|
|
132
|
+
return DEPENDABOT_CONFIGS.filter((p) => existsSync(join(repoRoot, p))).map((p) => ({
|
|
133
|
+
code: 'dependabot-config',
|
|
134
|
+
target: p,
|
|
135
|
+
message: `${p}: the canon's dependency bot is Renovate — move these rules into the Renovate config and delete the file`,
|
|
136
|
+
}));
|
|
137
|
+
}
|
package/src/files.ts
CHANGED
|
@@ -10,6 +10,13 @@ export function planFiles(repoRoot: string, canon: Canon): Drift[] {
|
|
|
10
10
|
const plan: Drift[] = [];
|
|
11
11
|
for (const f of canon.files) {
|
|
12
12
|
const target = join(repoRoot, f.dest);
|
|
13
|
+
// Засев с альтернативами: репо уже держит тот же конфиг под другим законным именем.
|
|
14
|
+
if (
|
|
15
|
+
f.strategy === 'create-if-absent' &&
|
|
16
|
+
f.satisfiedBy?.some((p) => existsSync(join(repoRoot, p)))
|
|
17
|
+
) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
13
20
|
const exists = existsSync(target);
|
|
14
21
|
// create-if-absent принадлежит репозиторию после первого засева: расхождением считается
|
|
15
22
|
// только отсутствие, содержимое не трогаем.
|
package/src/findings.ts
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Repo-local Dependabot config — YOURS to edit (seeded once by `stack sync`, never overwritten).
|
|
2
|
-
version: 2
|
|
3
|
-
updates:
|
|
4
|
-
- package-ecosystem: 'npm'
|
|
5
|
-
directory: '/'
|
|
6
|
-
schedule:
|
|
7
|
-
interval: 'weekly'
|
|
8
|
-
ignore:
|
|
9
|
-
# Canon packages arrive through `stack sync`, not through Dependabot.
|
|
10
|
-
- dependency-name: '@alxwlw/*'
|