@icebreakers/monorepo 5.5.10 → 5.7.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/README.md +2 -0
- package/dist/baseline-DPfotf4y.mjs +146 -0
- package/dist/bundle-B9vRch4R.mjs +49 -0
- package/dist/catalog-CDEyc1uA.mjs +299 -0
- package/dist/cli.mjs +1487 -156
- package/dist/commands-TS8ABFdP.mjs +13820 -0
- package/dist/config-C38c_Q8L.mjs +66 -0
- package/dist/{create-flow-C811m80z.mjs → create-flow-CCr2hfSY.mjs} +103 -40
- package/dist/deps-CUdI2DaB.mjs +47 -0
- package/dist/execute-PX1hT0qv.mjs +68 -0
- package/dist/execute-Vi4qHe-D.mjs +663 -0
- package/dist/format-DZ7L34rf.mjs +28 -0
- package/dist/index-CoCTFWZJ.d.mts +2150 -0
- package/dist/index.d.mts +1741 -111
- package/dist/index.mjs +60 -6
- package/dist/inputs-_xIVONmB.mjs +50 -0
- package/dist/npm-B25nrSyz.mjs +82 -0
- package/dist/plan-B5aE_WNF.mjs +75 -0
- package/dist/run-Lu7y1bNf.mjs +165 -0
- package/dist/save-CdCf630Z.mjs +79 -0
- package/dist/scan-4nboHNXP.mjs +293 -0
- package/dist/template-drift-BBhnrHY1.mjs +2740 -0
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +2 -1
- package/dist/transaction-DAhY8EpG.mjs +168 -0
- package/dist/tsconfig-CGntrzBM.mjs +1483 -0
- package/dist/{tooling-BfXlmCi-.mjs → vitest-DkGh4Ygo.mjs} +108 -167
- package/dist/workspace-tasks-CnB8kkS0.mjs +4435 -0
- package/package.json +25 -7
- package/resources/api-report/runner.cjs +76 -0
- package/resources/devcontainer/setup.mjs +36 -0
- package/resources/knip/reporter.mjs +46 -0
- package/resources/maintenance/migration-lanes.mjs +141 -0
- package/resources/maintenance/migration-lock.mjs +119 -0
- package/resources/maintenance/migrations.mjs +215 -0
- package/resources/maintenance/presets.mjs +130 -0
- package/resources/maintenance/validate.mjs +233 -0
- package/resources/maintenance/workflow.yml +151 -0
- package/resources/skills/repoctl/SKILL.md +4 -2
- package/resources/skills/repoctl/references/commands.md +224 -13
- package/resources/skills/repoctl/references/config.md +70 -6
- package/resources/skills/repoctl/references/dependencies.md +37 -0
- package/resources/skills/repoctl/references/knip.md +34 -0
- package/resources/skills/repoctl/references/templates.md +26 -2
- package/dist/commands-CIzCAxyY.mjs +0 -5672
- package/dist/config-p842Knhq.mjs +0 -114
- package/dist/index-DDQKKYet.d.mts +0 -1025
- package/dist/types-m8JLwKzl.mjs +0 -499
- package/dist/workspace-MCKewElu.mjs +0 -123
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { St as localize, at as record, it as readInput, rt as hash } from "./workspace-tasks-CnB8kkS0.mjs";
|
|
2
|
+
import { A as mergeConfigValues, H as validateSchema, M as assertMonorepoConfig, f as loadMonorepoConfigDetails, j as ConfigValidationError, u as getRepoctlConfigCandidates, z as commandSchemas } from "./tsconfig-CGntrzBM.mjs";
|
|
3
|
+
import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
|
|
4
|
+
import { findWorkspacePackages } from "@pnpm/workspace.find-packages";
|
|
5
|
+
import path from "pathe";
|
|
6
|
+
import { access, realpath } from "node:fs/promises";
|
|
7
|
+
import { Range, minVersion, satisfies, subset, validRange } from "semver";
|
|
8
|
+
import YAML from "yaml";
|
|
9
|
+
//#region src/commands/mirror/sources.ts
|
|
10
|
+
const chinaMirrorsEnvs = {
|
|
11
|
+
COREPACK_NPM_REGISTRY: "https://registry.npmmirror.com",
|
|
12
|
+
EDGEDRIVER_CDNURL: "https://npmmirror.com/mirrors/edgedriver",
|
|
13
|
+
NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
14
|
+
NVM_NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
15
|
+
PHANTOMJS_CDNURL: "https://cdn.npmmirror.com/binaries/phantomjs",
|
|
16
|
+
CHROMEDRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/chromedriver",
|
|
17
|
+
OPERADRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/operadriver",
|
|
18
|
+
CYPRESS_DOWNLOAD_PATH_TEMPLATE: "https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip",
|
|
19
|
+
ELECTRON_MIRROR: "https://cdn.npmmirror.com/binaries/electron/",
|
|
20
|
+
ELECTRON_BUILDER_BINARIES_MIRROR: "https://cdn.npmmirror.com/binaries/electron-builder-binaries/",
|
|
21
|
+
SASS_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-sass",
|
|
22
|
+
SWC_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-swc",
|
|
23
|
+
NWJS_URLBASE: "https://cdn.npmmirror.com/binaries/nwjs/v",
|
|
24
|
+
PUPPETEER_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
25
|
+
PUPPETEER_DOWNLOAD_BASE_URL: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
26
|
+
PLAYWRIGHT_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/playwright",
|
|
27
|
+
SENTRYCLI_CDNURL: "https://cdn.npmmirror.com/binaries/sentry-cli",
|
|
28
|
+
SAUCECTL_INSTALL_BINARY_MIRROR: "https://cdn.npmmirror.com/binaries/saucectl",
|
|
29
|
+
RE2_DOWNLOAD_MIRROR: "https://cdn.npmmirror.com/binaries/node-re2",
|
|
30
|
+
RE2_DOWNLOAD_SKIP_PATH: "true",
|
|
31
|
+
PRISMA_ENGINES_MIRROR: "https://cdn.npmmirror.com/binaries/prisma",
|
|
32
|
+
npm_config_better_sqlite3_binary_host: "https://cdn.npmmirror.com/binaries/better-sqlite3",
|
|
33
|
+
npm_config_keytar_binary_host: "https://cdn.npmmirror.com/binaries/keytar",
|
|
34
|
+
npm_config_sharp_binary_host: "https://cdn.npmmirror.com/binaries/sharp",
|
|
35
|
+
npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
|
|
36
|
+
npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/core/config/resolution.ts
|
|
40
|
+
const defaults = {
|
|
41
|
+
ai: {
|
|
42
|
+
baseDir: "agentic/prompts",
|
|
43
|
+
force: false,
|
|
44
|
+
format: "md"
|
|
45
|
+
},
|
|
46
|
+
clean: {
|
|
47
|
+
autoConfirm: false,
|
|
48
|
+
dryRun: false,
|
|
49
|
+
ignorePackages: [],
|
|
50
|
+
includePrivate: true
|
|
51
|
+
},
|
|
52
|
+
create: {
|
|
53
|
+
offline: false,
|
|
54
|
+
renameJson: false,
|
|
55
|
+
defaultTemplate: "tsdown"
|
|
56
|
+
},
|
|
57
|
+
deps: { groups: [] },
|
|
58
|
+
doctor: {},
|
|
59
|
+
env: {
|
|
60
|
+
tasks: ["build"],
|
|
61
|
+
frameworkInference: true
|
|
62
|
+
},
|
|
63
|
+
init: {
|
|
64
|
+
skipReadme: false,
|
|
65
|
+
skipPkgJson: false,
|
|
66
|
+
skipChangeset: false,
|
|
67
|
+
skipIssueTemplateConfig: false,
|
|
68
|
+
tooling: [],
|
|
69
|
+
force: false
|
|
70
|
+
},
|
|
71
|
+
mirror: { env: chinaMirrorsEnvs },
|
|
72
|
+
release: {
|
|
73
|
+
qualityScripts: [
|
|
74
|
+
"build",
|
|
75
|
+
"lint",
|
|
76
|
+
"test"
|
|
77
|
+
],
|
|
78
|
+
hooks: {
|
|
79
|
+
verify: [],
|
|
80
|
+
beforeVersion: [],
|
|
81
|
+
afterVersion: [],
|
|
82
|
+
beforePublish: [],
|
|
83
|
+
afterPublish: []
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
upgrade: {
|
|
87
|
+
interactive: false,
|
|
88
|
+
core: false,
|
|
89
|
+
outDir: "",
|
|
90
|
+
skipOverwrite: false,
|
|
91
|
+
yes: false,
|
|
92
|
+
overwrite: false,
|
|
93
|
+
noOverwrite: false,
|
|
94
|
+
overwriteRelease: false,
|
|
95
|
+
mergeTargets: true,
|
|
96
|
+
scripts: {},
|
|
97
|
+
skipChangesetMarkdown: true
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/** Shared by inspection and execution. Undefined never masks a project/default value. */
|
|
101
|
+
function resolveCommandValues(name, project = {}, overrides = {}, options = {}) {
|
|
102
|
+
const schema = Object.hasOwn(commandSchemas, name) ? commandSchemas[name] : void 0;
|
|
103
|
+
if (!schema) throw new ConfigValidationError([{
|
|
104
|
+
id: "config.invalid-value",
|
|
105
|
+
path: "command",
|
|
106
|
+
actualType: typeof name,
|
|
107
|
+
expected: Object.keys(commandSchemas).join(" | "),
|
|
108
|
+
suggestion: "Select a supported command context."
|
|
109
|
+
}]);
|
|
110
|
+
const diagnostics = [];
|
|
111
|
+
validateSchema(project, schema, `commands.${name}`, diagnostics);
|
|
112
|
+
validateSchema(overrides, schema, `commands.${name}`, diagnostics);
|
|
113
|
+
if (diagnostics.length) throw new ConfigValidationError(diagnostics);
|
|
114
|
+
const { values, sources } = mergeConfigValues([
|
|
115
|
+
{
|
|
116
|
+
source: { kind: "default" },
|
|
117
|
+
values: defaults[name]
|
|
118
|
+
},
|
|
119
|
+
...name === "init" && options.entry === "cli" ? [{
|
|
120
|
+
source: { kind: "default" },
|
|
121
|
+
values: { preset: "standard" }
|
|
122
|
+
}] : [],
|
|
123
|
+
...options.layers ? options.layers.map((layer) => ({
|
|
124
|
+
source: layer.source,
|
|
125
|
+
values: layer.config.commands?.[name] ?? {}
|
|
126
|
+
})) : [{
|
|
127
|
+
source: { kind: "project" },
|
|
128
|
+
values: project
|
|
129
|
+
}],
|
|
130
|
+
{
|
|
131
|
+
source: { kind: "cli" },
|
|
132
|
+
values: overrides
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
const origins = Object.fromEntries(Object.entries(sources).map(([field, source]) => [field, source.kind === "preset" ? "project" : source.kind]));
|
|
136
|
+
if (name === "create" && values["type"] === void 0) {
|
|
137
|
+
values["type"] = values["defaultTemplate"];
|
|
138
|
+
origins["type"] = origins["defaultTemplate"];
|
|
139
|
+
sources["type"] = sources["defaultTemplate"];
|
|
140
|
+
}
|
|
141
|
+
assertMonorepoConfig({ commands: { [name]: values } });
|
|
142
|
+
return {
|
|
143
|
+
command: name,
|
|
144
|
+
values,
|
|
145
|
+
origins,
|
|
146
|
+
sources
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Separate the config contract from command-only controls such as cwd, apply and signals. */
|
|
150
|
+
function selectCommandOverrides(name, input) {
|
|
151
|
+
const fields = commandSchemas[name].fields;
|
|
152
|
+
return Object.fromEntries(Object.entries(input).filter(([key, value]) => Object.hasOwn(fields, key) && value !== void 0));
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/commands/deps/policy.ts
|
|
156
|
+
const dependencySections = [
|
|
157
|
+
"dependencies",
|
|
158
|
+
"devDependencies",
|
|
159
|
+
"peerDependencies",
|
|
160
|
+
"optionalDependencies"
|
|
161
|
+
];
|
|
162
|
+
function validatePolicy(config) {
|
|
163
|
+
if (config.groups !== void 0 && !Array.isArray(config.groups)) throw new Error(localize("commands.deps.groups must be an array.", "commands.deps.groups 必须是数组。"));
|
|
164
|
+
const names = /* @__PURE__ */ new Set(["default"]);
|
|
165
|
+
for (const group of config.groups ?? []) {
|
|
166
|
+
if (!group || typeof group.name !== "string" || !group.name.trim() || names.has(group.name) || typeof group.reason !== "string" || !group.reason.trim() || !Array.isArray(group.workspaces) || !group.workspaces.length || group.workspaces.some((value) => typeof value !== "string" || !value) || !Array.isArray(group.dependencies) || !group.dependencies.length || group.dependencies.some((value) => typeof value !== "string" || !value) || group.sections !== void 0 && (!Array.isArray(group.sections) || !group.sections.length || group.sections.some((value) => !dependencySections.includes(value))) || group.ignore !== void 0 && typeof group.ignore !== "boolean") throw new Error(localize("Dependency groups require a unique name, a reason and explicit workspace/dependency selectors.", "依赖分组必须提供唯一名称、原因以及明确的工作区和依赖选择器。"));
|
|
167
|
+
names.add(group.name);
|
|
168
|
+
}
|
|
169
|
+
return config.groups ?? [];
|
|
170
|
+
}
|
|
171
|
+
function matchGroup(occurrence, groups) {
|
|
172
|
+
const matches = groups.filter((group) => group.workspaces.includes(occurrence.workspace) && group.dependencies.includes(occurrence.name) && (!group.sections || group.sections.includes(occurrence.section)));
|
|
173
|
+
if (matches.length > 1) throw new Error(localize(`Overlapping dependency groups for ${occurrence.path}: ${occurrence.section}.${occurrence.name}`, `依赖分组重叠:${occurrence.path} 的 ${occurrence.section}.${occurrence.name}`));
|
|
174
|
+
return matches[0];
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/commands/deps/specifiers.ts
|
|
178
|
+
function parseSpecifier(name, specifier, workspace = {}) {
|
|
179
|
+
const numeric = specifier.trim() ? validRange(specifier) : null;
|
|
180
|
+
if (numeric) return {
|
|
181
|
+
protocol: "semver",
|
|
182
|
+
source: name,
|
|
183
|
+
range: numeric
|
|
184
|
+
};
|
|
185
|
+
if (specifier.startsWith("npm:")) {
|
|
186
|
+
const alias = /^npm:((?:@[^/@]+\/)?[^/@]+)@(.+)$/.exec(specifier);
|
|
187
|
+
return {
|
|
188
|
+
protocol: "npm",
|
|
189
|
+
source: alias?.[1] ?? null,
|
|
190
|
+
range: alias?.[2] ? validRange(alias[2]) : null
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (specifier.startsWith("catalog:")) {
|
|
194
|
+
const catalog = specifier.slice(8) || "default";
|
|
195
|
+
const catalogs = record(workspace["catalogs"]);
|
|
196
|
+
const value = (workspace["catalog"] != null && catalogs?.["default"] != null ? void 0 : catalog === "default" ? record(workspace["catalog"] ?? catalogs?.["default"]) : record(catalogs?.[catalog]))?.[name];
|
|
197
|
+
const parsed = typeof value === "string" && !value.startsWith("catalog:") ? parseSpecifier(name, value) : void 0;
|
|
198
|
+
return {
|
|
199
|
+
protocol: "catalog",
|
|
200
|
+
source: parsed?.source ?? null,
|
|
201
|
+
range: parsed?.range ?? null
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
protocol: specifier.startsWith("workspace:") ? "workspace" : specifier.startsWith("file:") ? "file" : specifier.startsWith("link:") ? "link" : /^(?:git(?:\+[^:]+)?:|github:|gitlab:|bitbucket:|git@)/.test(specifier) ? "git" : /^https?:/.test(specifier) ? "url" : "unknown",
|
|
206
|
+
source: null,
|
|
207
|
+
range: null
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function equivalentRanges(ranges) {
|
|
211
|
+
return ranges.every((range) => subset(range, ranges[0]) && subset(ranges[0], range));
|
|
212
|
+
}
|
|
213
|
+
/** Intersect OR branches, rather than mistaking pairwise overlap for a common range. */
|
|
214
|
+
function rangesOverlap(ranges) {
|
|
215
|
+
let branches = ["*"];
|
|
216
|
+
for (const range of ranges) {
|
|
217
|
+
const alternatives = new Range(range).set.map((set) => set.map((comparator) => comparator.value).join(" ") || "*");
|
|
218
|
+
if (branches.length * alternatives.length > 256) return;
|
|
219
|
+
branches = branches.flatMap((left) => alternatives.map((right) => `${left} ${right}`)).filter((branch) => minVersion(branch) !== null);
|
|
220
|
+
}
|
|
221
|
+
return branches.some((branch) => {
|
|
222
|
+
const minimum = minVersion(branch);
|
|
223
|
+
if (!minimum) return false;
|
|
224
|
+
return [minimum.version, `${minimum.major}.${minimum.minor}.${minimum.patch}`].some((candidate) => ranges.every((range) => satisfies(candidate, range)));
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/commands/deps/scan.ts
|
|
229
|
+
async function scanDependencies(cwd, options = {}) {
|
|
230
|
+
const found = await findWorkspaceDir(cwd);
|
|
231
|
+
if (!found) throw new Error(localize("Dependency checks require a pnpm workspace.", "依赖检查需要 pnpm 工作区。"));
|
|
232
|
+
const workspaceDir = path.resolve(await realpath(found));
|
|
233
|
+
const contents = /* @__PURE__ */ new Map();
|
|
234
|
+
const workspaceContent = await readInput(workspaceDir, "pnpm-workspace.yaml");
|
|
235
|
+
contents.set("pnpm-workspace.yaml", workspaceContent);
|
|
236
|
+
const workspace = record(YAML.parse(workspaceContent)) ?? {};
|
|
237
|
+
const patterns = workspace["packages"];
|
|
238
|
+
if (patterns !== void 0 && (!Array.isArray(patterns) || patterns.some((value) => typeof value !== "string"))) throw new Error(localize("Invalid workspace package patterns.", "工作区包匹配规则无效。"));
|
|
239
|
+
const packages = await findWorkspacePackages(workspaceDir, patterns ? { patterns } : {});
|
|
240
|
+
for (const candidate of getRepoctlConfigCandidates(workspaceDir)) {
|
|
241
|
+
try {
|
|
242
|
+
await access(candidate);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (error.code === "ENOENT") continue;
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
const relative = path.relative(workspaceDir, candidate);
|
|
248
|
+
contents.set(relative, await readInput(workspaceDir, relative));
|
|
249
|
+
}
|
|
250
|
+
const loaded = options.policy === false ? void 0 : await loadMonorepoConfigDetails(workspaceDir, { refresh: true });
|
|
251
|
+
for (const file of loaded?.files ?? []) {
|
|
252
|
+
const relative = path.relative(workspaceDir, file);
|
|
253
|
+
if (!contents.has(relative)) contents.set(relative, await readInput(workspaceDir, relative));
|
|
254
|
+
}
|
|
255
|
+
const policy = loaded ? validatePolicy(resolveCommandValues("deps", loaded.config.commands?.deps ?? {}).values) : [];
|
|
256
|
+
const occurrences = [];
|
|
257
|
+
const manifests = [.../* @__PURE__ */ new Set(["package.json", ...packages.map((pkg) => path.relative(workspaceDir, path.join(pkg.rootDir, "package.json")))])].sort();
|
|
258
|
+
for (const relative of manifests) {
|
|
259
|
+
const content = await readInput(workspaceDir, relative);
|
|
260
|
+
contents.set(relative, content);
|
|
261
|
+
const manifest = record(JSON.parse(content));
|
|
262
|
+
if (!manifest) throw new Error(localize(`Invalid manifest: ${relative}`, `清单无效:${relative}`));
|
|
263
|
+
for (const section of dependencySections) {
|
|
264
|
+
const dependencies = record(manifest[section]);
|
|
265
|
+
if (manifest[section] !== void 0 && !dependencies) throw new Error(localize(`Invalid dependency map: ${relative} ${section}`, `依赖声明无效:${relative} ${section}`));
|
|
266
|
+
for (const [name, value] of Object.entries(dependencies ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
267
|
+
if (typeof value !== "string") throw new TypeError(localize(`Invalid dependency specifier: ${relative} ${section}.${name}`, `依赖版本声明无效:${relative} ${section}.${name}`));
|
|
268
|
+
occurrences.push({
|
|
269
|
+
name,
|
|
270
|
+
section,
|
|
271
|
+
path: relative,
|
|
272
|
+
workspace: path.dirname(relative),
|
|
273
|
+
packageName: typeof manifest["name"] === "string" ? manifest["name"] : null,
|
|
274
|
+
specifier: value,
|
|
275
|
+
...parseSpecifier(name, value, workspace)
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
workspaceDir,
|
|
282
|
+
workspace,
|
|
283
|
+
occurrences,
|
|
284
|
+
policy,
|
|
285
|
+
inputs: [...contents].sort(([a], [b]) => a.localeCompare(b)).map(([file, content]) => ({
|
|
286
|
+
path: file,
|
|
287
|
+
hash: hash(content)
|
|
288
|
+
})),
|
|
289
|
+
contents
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
export { dependencySections as a, selectCommandOverrides as c, rangesOverlap as i, chinaMirrorsEnvs as l, equivalentRanges as n, matchGroup as o, parseSpecifier as r, resolveCommandValues as s, scanDependencies as t };
|