@alxwlw/stack 1.1.2 → 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.
@@ -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.1.2",
14
- "@alxwlw/oxlint-config": "1.1.2",
15
- "@alxwlw/tsconfig": "1.1.2"
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 }}
@@ -74,12 +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
- },
83
77
  {
84
78
  "src": "files/oxlintrc.template.json",
85
79
  "dest": ".oxlintrc.json",
@@ -153,6 +147,31 @@
153
147
  "src": "files/workflow-stack-sync.yml",
154
148
  "dest": ".github/workflows/stack-sync.yml",
155
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
+ ]
156
175
  }
157
176
  ]
158
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alxwlw/stack",
3
- "version": "1.1.2",
3
+ "version": "1.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,6 +21,7 @@
21
21
  "provenance": true
22
22
  },
23
23
  "dependencies": {
24
+ "json5": "^2.2.3",
24
25
  "jsonc-parser": "^3.3.1",
25
26
  "yaml": "^2.9.1"
26
27
  }
package/schema.json CHANGED
@@ -11,10 +11,10 @@
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
- "enum": ["moon-tasks", "libs", "knip", "depcruise"]
17
+ "enum": ["moon-tasks", "libs", "knip", "depcruise", "renovate"]
18
18
  }
19
19
  },
20
20
  "exceptions": {
package/src/canon.ts CHANGED
@@ -13,6 +13,8 @@ export interface CanonFile {
13
13
  strategy?: SyncStrategy;
14
14
  /** Группа, включаемая через `with` в .stack.jsonc. Без группы файл обязателен всем. */
15
15
  group?: string;
16
+ /** Для create-if-absent: другие пути, любой из которых тоже закрывает засев (у конфига несколько законных имён). */
17
+ satisfiedBy?: string[];
16
18
  }
17
19
 
18
20
  export type CanonCatalogs = Record<string, Record<string, string>>;
@@ -20,7 +22,7 @@ export type CanonCatalogs = Record<string, Record<string, string>>;
20
22
  // Канон одного прогона как значение: уже отфильтрован под профиль и группы, содержимое файлов
21
23
  // прочитано, пины node и pnpm вычислены. Правила и план принимают его и не знают, где лежит каталог.
22
24
  export interface Canon {
23
- files: { dest: string; content: string; strategy?: SyncStrategy }[];
25
+ files: { dest: string; content: string; strategy?: SyncStrategy; satisfiedBy?: string[] }[];
24
26
  catalogs: CanonCatalogs;
25
27
  nodePin: string;
26
28
  pnpmPin: string;
@@ -52,6 +54,7 @@ export function loadCanon(cfg: StackConfig, dir: string = canonDir()): Canon {
52
54
  dest: f.dest,
53
55
  content: readFileSync(join(dir, f.src), 'utf8'),
54
56
  strategy: f.strategy,
57
+ satisfiedBy: f.satisfiedBy,
55
58
  }));
56
59
  const all = loadCatalogs(dir);
57
60
  const groups = ['dev', ...cfg.with.filter((g) => g !== 'dev')];
@@ -69,5 +72,10 @@ export function loadCanon(cfg: StackConfig, dir: string = canonDir()): Canon {
69
72
  // Пин pnpm нужен правилу package-manager: поле packageManager — второй источник версии pnpm.
70
73
  const pnpm = /^pnpm\s*=\s*"([^"]+)"/m.exec(prototools.content);
71
74
  if (!pnpm?.[1]) throw new Error('canon .prototools has no pnpm pin');
72
- return { files, catalogs, nodePin: pin[1], pnpmPin: pnpm[1] };
75
+ return {
76
+ files,
77
+ catalogs,
78
+ nodePin: pin[1],
79
+ pnpmPin: pnpm[1],
80
+ };
73
81
  }
package/src/check.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import type { Canon } from './canon.ts';
2
2
  import { planCatalogs } from './catalogs.ts';
3
3
  import type { Exception } from './config.ts';
4
- import { checkDependabotIgnore, checkEnginesNode, checkInlineVersions } from './deps.ts';
4
+ import {
5
+ checkDependabot,
6
+ checkEnginesNode,
7
+ checkInlineVersions,
8
+ checkRenovatePreset,
9
+ } from './deps.ts';
5
10
  import { planFiles } from './files.ts';
6
11
  import { applyExceptions, covers, type Drift, type Finding } from './findings.ts';
7
12
  import { planPackageManager } from './package-manager.ts';
@@ -43,7 +48,8 @@ export function checkRepo(repoRoot: string, canon: Canon, exceptions: Exception[
43
48
  ...planRepo(repoRoot, canon),
44
49
  ...checkInlineVersions(repoRoot, canon),
45
50
  ...checkEnginesNode(repoRoot, canon),
46
- ...checkDependabotIgnore(repoRoot),
51
+ ...checkRenovatePreset(repoRoot),
52
+ ...checkDependabot(repoRoot),
47
53
  ],
48
54
  exceptions,
49
55
  );
package/src/deps.ts CHANGED
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
 
4
4
  import { Glob } from 'bun';
5
- import { parse as parseYaml } from 'yaml';
5
+ import JSON5 from 'json5';
6
6
 
7
7
  import type { Canon } from './canon.ts';
8
8
  import type { Finding } from './findings.ts';
@@ -70,45 +70,68 @@ export function checkEnginesNode(repoRoot: string, canon: Canon): Finding[] {
70
70
  ];
71
71
  }
72
72
 
73
- // Формы дальше — только то, что нужно прочитать; настоящий dependabot.yml несёт больше полей.
74
- interface DependabotYaml {
75
- updates?: unknown;
76
- }
77
-
78
- function ignoresAlxwlw(doc: unknown): boolean {
79
- const updates = (doc as DependabotYaml | null)?.updates;
80
- if (!Array.isArray(updates)) return false;
81
- return updates.some((u) => {
82
- const ignore = (u as { ignore?: unknown } | null)?.ignore;
83
- return (
84
- Array.isArray(ignore) &&
85
- ignore.some(
86
- (i) => (i as { 'dependency-name'?: unknown } | null)?.['dependency-name'] === '@alxwlw/*',
87
- )
88
- );
89
- });
90
- }
73
+ // Имена и порядок поиска — как у самого Renovate (renovate.json{,c,5} для каждого места; первый
74
+ // найденный файл и есть конфиг), без устаревшего package.json#renovate. JSON5.parse читает и JSONC.
75
+ export const RENOVATE_CONFIGS = [
76
+ 'renovate.json',
77
+ 'renovate.jsonc',
78
+ 'renovate.json5',
79
+ '.github/renovate.json',
80
+ '.github/renovate.jsonc',
81
+ '.github/renovate.json5',
82
+ '.gitlab/renovate.json',
83
+ '.gitlab/renovate.jsonc',
84
+ '.gitlab/renovate.json5',
85
+ '.renovaterc',
86
+ '.renovaterc.json',
87
+ '.renovaterc.jsonc',
88
+ '.renovaterc.json5',
89
+ ];
90
+ // Строка подключения пресета канона. Ровно с тегом мажора: без тега или с #main потребитель
91
+ // получал бы неопубликованный канон, а пресет — тот же источник, что и rollout (плавающий v1).
92
+ export const STACK_RENOVATE_PRESET = 'github>alxwlw/stack//renovate/canon.json5#v1';
91
93
 
92
- export function checkDependabotIgnore(repoRoot: string): Finding[] {
93
- if (!existsSync(join(repoRoot, 'pnpm-workspace.yaml'))) return [];
94
- const path = join(repoRoot, '.github/dependabot.yml');
95
- if (!existsSync(path)) return [];
96
- const finding: Finding = {
97
- code: 'dependabot-ignore',
98
- target: '.github/dependabot.yml',
99
- message: 'missing an ignore for "@alxwlw/*" — the bot will fight the canon rollout',
100
- };
94
+ // Пресет выключает Renovate для всего, что двигает stack sync (proto, каталоги канона dev и libs, @alxwlw/*,
95
+ // ссылки alxwlw/stack) — без него бот и rollout перетягивают одни версии. Профиль не важен.
96
+ export function checkRenovatePreset(repoRoot: string): Finding[] {
97
+ const found = RENOVATE_CONFIGS.find((p) => existsSync(join(repoRoot, p)));
98
+ if (!found) {
99
+ return [
100
+ {
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}"`,
104
+ },
105
+ ];
106
+ }
101
107
  let doc: unknown;
102
108
  try {
103
- doc = parseYaml(readFileSync(path, 'utf8'));
109
+ doc = JSON5.parse(readFileSync(join(repoRoot, found), 'utf8'));
104
110
  } catch {
105
111
  return [
106
- {
107
- code: 'unreadable-file',
108
- target: '.github/dependabot.yml',
109
- message: '.github/dependabot.yml does not parse as YAML',
110
- },
112
+ { code: 'unreadable-file', target: found, message: `${found} does not parse as JSON5` },
111
113
  ];
112
114
  }
113
- return ignoresAlxwlw(doc) ? [] : [finding];
115
+ const ext = (doc as { extends?: unknown } | null)?.extends;
116
+ return Array.isArray(ext) && ext.includes(STACK_RENOVATE_PRESET)
117
+ ? []
118
+ : [
119
+ {
120
+ code: 'renovate-preset',
121
+ target: found,
122
+ message: `"extends" must include "${STACK_RENOVATE_PRESET}" — without the canon preset the bot fights stack sync`,
123
+ },
124
+ ];
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
+ }));
114
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
@@ -8,7 +8,8 @@ export type FindingCode =
8
8
  | 'inline-version'
9
9
  | 'engines-node'
10
10
  | 'package-manager'
11
- | 'dependabot-ignore'
11
+ | 'renovate-preset'
12
+ | 'dependabot-config'
12
13
  | 'unreadable-file'
13
14
  | 'stale-exception';
14
15
 
@@ -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/*'