@theholocron/astromech 5.0.0-alpha.260 → 5.0.0-alpha.261
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/index.d.mts +6 -0
- package/dist/index.mjs +126 -13
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,12 @@ export declare function codecovComponentBlock(packages: WorkspacePackage$1[]): s
|
|
|
23
23
|
* already declare it.
|
|
24
24
|
*/
|
|
25
25
|
export declare function ensureIfNotFound(yaml: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* The `uploads` input of the `verification.unitTests` workflow: a JSON list of `{ flag, files }`, one per package
|
|
28
|
+
* that has a flag. `files` is where the package writes its lcov report (`<location>/coverage/lcov.info`), unless
|
|
29
|
+
* `lcovPaths` names another for that slug (a package whose test runner writes it elsewhere).
|
|
30
|
+
*/
|
|
31
|
+
export declare function codecovUploads(packages: WorkspacePackage$1[], lcovPaths?: Record<string, string>): string;
|
|
26
32
|
export declare function mergeCodecovComponents(existing: string, packages: WorkspacePackage$1[]): string;
|
|
27
33
|
/**
|
|
28
34
|
* Every package the repo's `pnpm-workspace.yaml` declares (the default roots
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { stringifyJson } from "@theholocron/json-utils";
|
|
|
8
8
|
import { spawnSync } from "node:child_process";
|
|
9
9
|
import { findExecutableSync } from "@theholocron/fs-utils";
|
|
10
10
|
// src/templates/codecov/codecov.yml
|
|
11
|
-
var codecov_default = "codecov:\n require_ci_to_pass: true\n\ncoverage:\n precision: 2\n round: down\n status:\n project:\n default:\n target: auto\n threshold: 2%\n # Infra-only PRs (dep bumps, config, lockfile) touch no coverable code,\n # so codecov produces no report to compare. Pass instead of blocking\n # forever on a required check that will never post.\n if_not_found: success\n patch:\n default:\n target: 80%\n if_not_found: success\n\ncomment:\n layout: \"reach,diff,flags
|
|
11
|
+
var codecov_default = "codecov:\n require_ci_to_pass: true\n\ncoverage:\n precision: 2\n round: down\n status:\n project:\n default:\n target: auto\n threshold: 2%\n # Infra-only PRs (dep bumps, config, lockfile) touch no coverable code,\n # so codecov produces no report to compare. Pass instead of blocking\n # forever on a required check that will never post.\n if_not_found: success\n patch:\n default:\n target: 80%\n if_not_found: success\n\ncomment:\n layout: \"reach,diff,flags\"\n behavior: default\n require_changes: true\n\ncomponent_management:\n default_rules:\n statuses:\n - type: patch\n target: 80%\n if_not_found: success\n informational: true\n individual_components:\n";
|
|
12
12
|
// src/workspace/workspace-globs.ts
|
|
13
13
|
/**
|
|
14
14
|
* The `packages:` list of a `pnpm-workspace.yaml`. A line-based read of the
|
|
@@ -208,10 +208,128 @@ function ensureIfNotFound(yaml) {
|
|
|
208
208
|
}
|
|
209
209
|
return out.join("\n");
|
|
210
210
|
}
|
|
211
|
+
/** Folders that never get a flag: `docs` coverage must not count toward the aggregate statuses. */
|
|
212
|
+
const FLAGLESS_FOLDERS = /* @__PURE__ */ new Set(["docs"]);
|
|
213
|
+
/**
|
|
214
|
+
* One Codecov flag per workspace package (its slug, the same name as its
|
|
215
|
+
* component), in package order, without `docs`. A flag per package, not per
|
|
216
|
+
* group folder: Codecov carries a flag forward whole or not at all, so a run that
|
|
217
|
+
* tests one package of a group would otherwise drop the group's other packages.
|
|
218
|
+
*/
|
|
219
|
+
function codecovFlagNames(packages) {
|
|
220
|
+
return packages.filter((pkg) => !FLAGLESS_FOLDERS.has(location(pkg).split("/")[0])).map((pkg) => pkg.slug);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The `uploads` input of the `verification.unitTests` workflow: a JSON list of `{ flag, files }`, one per package
|
|
224
|
+
* that has a flag. `files` is where the package writes its lcov report (`<location>/coverage/lcov.info`), unless
|
|
225
|
+
* `lcovPaths` names another for that slug (a package whose test runner writes it elsewhere).
|
|
226
|
+
*/
|
|
227
|
+
function codecovUploads(packages, lcovPaths = {}) {
|
|
228
|
+
const flags = new Set(codecovFlagNames(packages));
|
|
229
|
+
const entries = packages.filter((pkg) => flags.has(pkg.slug)).map((pkg) => ({
|
|
230
|
+
flag: pkg.slug,
|
|
231
|
+
files: lcovPaths[pkg.slug] ?? `${location(pkg)}/coverage/lcov.info`
|
|
232
|
+
}));
|
|
233
|
+
return JSON.stringify(entries);
|
|
234
|
+
}
|
|
235
|
+
/** `[start, end)` of a top-level key's section; trailing blank lines are not part of it. `null` when absent. */
|
|
236
|
+
function section(lines, key) {
|
|
237
|
+
const start = lines.indexOf(`${key}:`);
|
|
238
|
+
if (start === -1) return null;
|
|
239
|
+
let end = lines.findIndex((line, i) => i > start && /^[A-Za-z_]/.test(line));
|
|
240
|
+
if (end === -1) end = lines.length;
|
|
241
|
+
while (lines[end - 1].trim() === "") end--;
|
|
242
|
+
return [start, end];
|
|
243
|
+
}
|
|
244
|
+
/** Insert the entries of `wanted` that no existing list item names, after the list's last line (`listEnd`). */
|
|
245
|
+
function appendMissingItems(lines, listStart, listEnd, wanted, itemName, render) {
|
|
246
|
+
const have = new Set(lines.slice(listStart + 1, listEnd).map((line) => itemName.exec(line)?.[1]));
|
|
247
|
+
lines.splice(listEnd, 0, ...wanted.filter((name) => !have.has(name)).map(render));
|
|
248
|
+
}
|
|
249
|
+
const FLAG_ENTRY = /^ {4}- name:\s*(\S+)/;
|
|
250
|
+
const flagEntry = (name) => ` - name: ${name}`;
|
|
251
|
+
/**
|
|
252
|
+
* Ensure a top-level `flag_management:` section carries `default_rules.carryforward`
|
|
253
|
+
* and one `individual_flags` entry per flag. A missing section is inserted before
|
|
254
|
+
* `component_management:`; an existing one only gains the entries it lacks, so hand
|
|
255
|
+
* edits (extra flags, per-flag `paths`/`statuses`, a different `carryforward`) survive.
|
|
256
|
+
*/
|
|
257
|
+
function ensureFlagManagement(yaml, flags) {
|
|
258
|
+
const lines = yaml.split("\n");
|
|
259
|
+
const listHead = flags.length === 0 ? " individual_flags: []" : " individual_flags:";
|
|
260
|
+
const range = section(lines, "flag_management");
|
|
261
|
+
if (!range) {
|
|
262
|
+
const block = [
|
|
263
|
+
"flag_management:",
|
|
264
|
+
" default_rules:",
|
|
265
|
+
" carryforward: true",
|
|
266
|
+
listHead,
|
|
267
|
+
...flags.map(flagEntry)
|
|
268
|
+
];
|
|
269
|
+
const at = lines.indexOf("component_management:");
|
|
270
|
+
if (at === -1) lines.push("", ...block);
|
|
271
|
+
else lines.splice(at, 0, ...block, "");
|
|
272
|
+
return lines.join("\n");
|
|
273
|
+
}
|
|
274
|
+
const [start, end] = range;
|
|
275
|
+
const list = lines.findIndex((line, i) => i > start && i < end && /^ {2}individual_flags:/.test(line));
|
|
276
|
+
if (list === -1) lines.splice(end, 0, listHead, ...flags.map(flagEntry));
|
|
277
|
+
else if (/\[\s*\]\s*$/.test(lines[list])) {
|
|
278
|
+
if (flags.length > 0) lines.splice(list, 1, listHead, ...flags.map(flagEntry));
|
|
279
|
+
} else appendMissingItems(lines, list, end, flags, FLAG_ENTRY, flagEntry);
|
|
280
|
+
return lines.join("\n");
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Scope `coverage.status.project.default` and `coverage.status.patch.default` to
|
|
284
|
+
* the flags, so the required `codecov/project` and `codecov/patch` contexts keep
|
|
285
|
+
* their names while only counting the grouped (non-`docs`) coverage. A block that
|
|
286
|
+
* already lists flags only gains the missing ones; an inline `flags: [...]` is left alone.
|
|
287
|
+
*/
|
|
288
|
+
function scopeAggregateStatuses(yaml, flags) {
|
|
289
|
+
if (flags.length === 0) return yaml;
|
|
290
|
+
const lines = yaml.split("\n");
|
|
291
|
+
for (const kind of ["project", "patch"]) {
|
|
292
|
+
const at = lines.indexOf(` ${kind}:`);
|
|
293
|
+
if (at === -1 || lines[at + 1] !== " default:") continue;
|
|
294
|
+
let end = at + 2;
|
|
295
|
+
while (end < lines.length && /^ {8}/.test(lines[end])) end++;
|
|
296
|
+
const flagsAt = lines.findIndex((line, i) => i >= at + 2 && i < end && /^ {8}flags:/.test(line));
|
|
297
|
+
if (flagsAt === -1) lines.splice(at + 2, 0, " flags:", ...flags.map((name) => ` - ${name}`));
|
|
298
|
+
else if (!/^ {8}flags:\s*\S/.test(lines[flagsAt])) {
|
|
299
|
+
let listEnd = flagsAt + 1;
|
|
300
|
+
while (listEnd < end && /^ {10}- /.test(lines[listEnd])) listEnd++;
|
|
301
|
+
appendMissingItems(lines, flagsAt, listEnd, flags, /^ {10}- (\S+)/, (name) => ` - ${name}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return lines.join("\n");
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Make the per-component statuses (`component_management.default_rules.statuses`)
|
|
308
|
+
* informational, so the ~70 `codecov/patch/<component>` contexts post but never block.
|
|
309
|
+
*/
|
|
310
|
+
function ensureInformationalComponentStatuses(yaml) {
|
|
311
|
+
const lines = yaml.split("\n");
|
|
312
|
+
const range = section(lines, "component_management");
|
|
313
|
+
if (!range) return yaml;
|
|
314
|
+
const stop = lines.indexOf(INDIVIDUAL_COMPONENTS_MARKER);
|
|
315
|
+
const limit = stop === -1 ? range[1] : stop;
|
|
316
|
+
const starts = lines.flatMap((line, i) => i > range[0] && i < limit && /^ {6}- type:/.test(line) ? [i] : []);
|
|
317
|
+
for (const first of starts.reverse()) {
|
|
318
|
+
let last = first + 1;
|
|
319
|
+
while (last < limit && /^ {8}\S/.test(lines[last])) last++;
|
|
320
|
+
if (!lines.slice(first, last).some((line) => /^ {8}informational:/.test(line))) lines.splice(last, 0, " informational: true");
|
|
321
|
+
}
|
|
322
|
+
return lines.join("\n");
|
|
323
|
+
}
|
|
324
|
+
/** Everything `codecov.yml` needs on top of the components list: if_not_found, flags, scoped aggregates, informational components. */
|
|
325
|
+
function applyStatusRules(yaml, flags) {
|
|
326
|
+
return ensureInformationalComponentStatuses(scopeAggregateStatuses(ensureFlagManagement(ensureIfNotFound(yaml), flags), flags));
|
|
327
|
+
}
|
|
211
328
|
function mergeCodecovComponents(existing, packages) {
|
|
329
|
+
const flags = codecovFlagNames(packages);
|
|
212
330
|
const idx = existing.indexOf(INDIVIDUAL_COMPONENTS_MARKER);
|
|
213
|
-
if (idx === -1) return
|
|
214
|
-
return
|
|
331
|
+
if (idx === -1) return applyStatusRules(existing, flags);
|
|
332
|
+
return applyStatusRules(existing.slice(0, idx + 24), flags) + codecovComponentBlock(packages);
|
|
215
333
|
}
|
|
216
334
|
/**
|
|
217
335
|
* Every package the repo's `pnpm-workspace.yaml` declares (the default roots
|
|
@@ -249,7 +367,8 @@ function readWorkspacePackages(repoRoot) {
|
|
|
249
367
|
}
|
|
250
368
|
/** A brand-new `codecov.yml` — the scaffold header + the base template + this repo's component list. */
|
|
251
369
|
function createCodecovConfig(packages) {
|
|
252
|
-
|
|
370
|
+
const base = applyStatusRules(codecov_default.trimEnd(), codecovFlagNames(packages));
|
|
371
|
+
return `${scaffoldHeader()}${base}${codecovComponentBlock(packages)}`;
|
|
253
372
|
}
|
|
254
373
|
/**
|
|
255
374
|
* The full pipeline `holocron repo setup` needs: read this repo's public
|
|
@@ -398,13 +517,13 @@ var verification_visualRegression_default = "name: Visual Regression\n\non: # ya
|
|
|
398
517
|
/**
|
|
399
518
|
* A value as a YAML scalar for a `with:` entry. Bare `[` and `{` would parse as
|
|
400
519
|
* sequence and mapping nodes, so values that start with one (JSON) are single-quoted
|
|
401
|
-
* and stay strings.
|
|
520
|
+
* and stay strings; a `'` inside is doubled, which is how YAML escapes it in single quotes.
|
|
402
521
|
*/
|
|
403
522
|
function yamlScalar(value) {
|
|
404
523
|
if (value === true) return "true";
|
|
405
524
|
if (value === false) return "false";
|
|
406
525
|
const text = String(value);
|
|
407
|
-
return text.startsWith("[") || text.startsWith("{") ? `'${text}'` : text;
|
|
526
|
+
return text.startsWith("[") || text.startsWith("{") ? `'${text.replaceAll("'", "''")}'` : text;
|
|
408
527
|
}
|
|
409
528
|
// src/generators/github-action-thin-callers/grouped-publish/grouped-publish.ts
|
|
410
529
|
/** The reusable's inputs a group may set for itself; everything else is shared by all releases. */
|
|
@@ -773,12 +892,6 @@ function extractPreviewConfig(raw, ctx = {}) {
|
|
|
773
892
|
* all repos with a `deploy` workflow get previews without per-repo config.
|
|
774
893
|
*/
|
|
775
894
|
function generateCombinedDeployContent(deployWith, paths, preview) {
|
|
776
|
-
const yamlScalar = (v) => {
|
|
777
|
-
if (v === true) return "true";
|
|
778
|
-
if (v === false) return "false";
|
|
779
|
-
const s = String(v);
|
|
780
|
-
return s.startsWith("[") || s.startsWith("{") ? `'${s}'` : s;
|
|
781
|
-
};
|
|
782
895
|
const withLines = (entries) => Object.entries(entries).map(([k, v]) => ` ${k}: ${yamlScalar(v)}`).join("\n");
|
|
783
896
|
const pathsBlock = paths.length > 0 ? ` paths:\n${paths.map((p) => ` - ${p}\n`).join("")}` : "";
|
|
784
897
|
const previewWith = {
|
|
@@ -3171,4 +3284,4 @@ function createConfig$9() {
|
|
|
3171
3284
|
function createIgnoreConfig$1() {
|
|
3172
3285
|
return `${workflowHeader()}${_yamlignore_default}`;
|
|
3173
3286
|
}
|
|
3174
|
-
export { CI_ORDER, DEFAULT_WORKSPACE_ROOTS, KNOWN_TASKS, KNOWN_WORKFLOWS, REUSABLE_ACTIONS, REUSABLE_WORKFLOWS, TASKS, WORKFLOW_CHECK_CONTEXTS, WORKFLOW_TEMPLATES, WORKFLOW_TEMPLATE_PROPERTIES, codecovComponentBlock, codecovConfig, createIgnoreConfig as createAlexignore, createRcConfig as createAlexrc, createAstromech, createCodecovConfig, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createHeader, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createTsconfig, createIgnoreConfig$1 as createYamlignore, createConfig$9 as createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, deriveDeployPaths, discoverWorkspacePackages, ensureIfNotFound, extractPreviewConfig, generateCombinedDeployContent, generateThinCallerContent, matchNamespace, mergeCodecovComponents, normalizeWorkflowWith, readWorkspaceGlobs, readWorkspacePackages, requiredChecks, resolveWorkspaceGlobs, reusableTemplates, runCi, runGroup, runTask, workspacePackages };
|
|
3287
|
+
export { CI_ORDER, DEFAULT_WORKSPACE_ROOTS, KNOWN_TASKS, KNOWN_WORKFLOWS, REUSABLE_ACTIONS, REUSABLE_WORKFLOWS, TASKS, WORKFLOW_CHECK_CONTEXTS, WORKFLOW_TEMPLATES, WORKFLOW_TEMPLATE_PROPERTIES, codecovComponentBlock, codecovConfig, codecovUploads, createIgnoreConfig as createAlexignore, createRcConfig as createAlexrc, createAstromech, createCodecovConfig, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createHeader, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createTsconfig, createIgnoreConfig$1 as createYamlignore, createConfig$9 as createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, deriveDeployPaths, discoverWorkspacePackages, ensureIfNotFound, extractPreviewConfig, generateCombinedDeployContent, generateThinCallerContent, matchNamespace, mergeCodecovComponents, normalizeWorkflowWith, readWorkspaceGlobs, readWorkspacePackages, requiredChecks, resolveWorkspaceGlobs, reusableTemplates, runCi, runGroup, runTask, workspacePackages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/astromech",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.261",
|
|
4
4
|
"description": "The Holocron task runner — one task manifest drives `holocron run`, `holocron run ci`, the CI workflows, package.json scripts, linters, and required checks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@commitlint/lint": "^21.2.3",
|
|
51
51
|
"@commitlint/load": "^21.2.3",
|
|
52
52
|
"@commitlint/types": "^21.2.3",
|
|
53
|
-
"@theholocron/datapad": "5.0.0-alpha.
|
|
53
|
+
"@theholocron/datapad": "5.0.0-alpha.261",
|
|
54
54
|
"@theholocron/fs-utils": "^1.16.1-alpha.1",
|
|
55
55
|
"@theholocron/json-utils": "^1.16.1-alpha.1",
|
|
56
56
|
"@theholocron/pkg-utils": "^1.16.1-alpha.1"
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"tsdown": "^0.23.3",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
71
|
"vitest": "^5.0.5",
|
|
72
|
+
"@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.3",
|
|
72
73
|
"@theholocron/commitlint-config": "^8.9.0-alpha.3",
|
|
73
74
|
"@theholocron/semantic-release-config": "^8.9.0-alpha.3",
|
|
74
75
|
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
75
76
|
"@theholocron/tsdown-config": "^8.9.0-alpha.3",
|
|
76
|
-
"@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.3",
|
|
77
77
|
"@theholocron/vitest-config": "^8.9.0-alpha.3",
|
|
78
78
|
"@theholocron/tsconfig": "^8.9.0-alpha.3"
|
|
79
79
|
},
|