@theholocron/astromech 5.0.0-alpha.274 → 5.0.0-alpha.276

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 CHANGED
@@ -1,5 +1,4 @@
1
1
  import { r as TasksConfig } from "./schema.type-C-3fZESa.mjs";
2
- import { ListWorkspacePackagesOptions, WorkspacePackageEntry } from "@theholocron/pkg-utils";
3
2
  interface WorkspacePackage$1 {
4
3
  slug: string;
5
4
  name: string;
@@ -798,61 +797,4 @@ declare function createConfig$7(holocronScript?: string): string;
798
797
  declare function createConfig$8(): string;
799
798
  declare function createConfig$9(): string;
800
799
  declare function createIgnoreConfig$1(): string;
801
- /** The `packages:` entries of a `pnpm-workspace.yaml`, split by whether they include or exclude (`!pattern`) packages. */
802
- interface WorkspaceGlobs {
803
- include: string[];
804
- exclude: string[];
805
- }
806
- /**
807
- * The `packages:` list of a `pnpm-workspace.yaml`. A line-based read of the
808
- * plain block-list form, not a YAML parse -- the same approach (and for the
809
- * same reason) as `ensureRootWorkspaceMember()`: the file routinely carries a
810
- * `catalog:`/`catalogs:`/`overrides:` block after `packages:` that nothing
811
- * here should have to round-trip. Quotes and trailing comments are stripped;
812
- * a missing `packages:` key, or the inline `packages: [a, b]` form, reads as no
813
- * globs (callers fall back to the default roots).
814
- */
815
- export declare function readWorkspaceGlobs(workspaceYaml: string): WorkspaceGlobs;
816
- /** Where packages live when there is no `pnpm-workspace.yaml` (or it lists none): the layout before globs were read. */
817
- export declare const DEFAULT_WORKSPACE_ROOTS: readonly string[];
818
- interface DiscoverWorkspacePackagesOptions extends Pick<ListWorkspacePackagesOptions, "listDirs" | "readFile"> {
819
- /** Replaces the read of `pnpm-workspace.yaml`. Throw (`ENOENT`) when it is absent -- or leave it out to read the real file. */
820
- readText?: (path: string) => string;
821
- /**
822
- * Only the packages of one version group: a folder of the repo (`clients`,
823
- * `observability`). A package belongs when it is that folder or sits under it.
824
- */
825
- group?: string;
826
- /**
827
- * Leave out the packages of these version groups. A repo that releases some folders on
828
- * their own line releases everything else together, and that release must not sweep the
829
- * independent groups in.
830
- */
831
- excludeGroups?: readonly string[];
832
- }
833
- /**
834
- * Every package the repo's `pnpm-workspace.yaml` declares, as
835
- * `listWorkspacePackagesSync()` entries -- in glob order, packages within a
836
- * `<dir>/*` glob sorted by name. Two forms of glob are understood:
837
- *
838
- * - `<dir>/*`: each child of `<dir>` that has a `package.json` (`clients/*`).
839
- * - a literal directory: that directory is the package (`observability`,
840
- * `docs/theme`).
841
- *
842
- * `!pattern` entries drop matching packages. The repo root (`.`) is not a
843
- * workspace child and is skipped; callers that treat a root-only repo as a
844
- * single package read the root manifest themselves. Any other glob throws
845
- * rather than being silently skipped. Without a `pnpm-workspace.yaml`, or one
846
- * with no `packages:`, the default roots are scanned.
847
- *
848
- * Nothing is filtered by `name`, `version` or `private`; that is the caller's
849
- * call, as for `listWorkspacePackagesSync()`.
850
- */
851
- export declare function discoverWorkspacePackages(repoRoot: string, options?: DiscoverWorkspacePackagesOptions): WorkspacePackageEntry[];
852
- /**
853
- * The globs {@link discoverWorkspacePackages} scans: the repo's
854
- * `pnpm-workspace.yaml` `packages:` list, or the {@link DEFAULT_WORKSPACE_ROOTS}
855
- * as `<root>/*` when there is no such file or it lists none.
856
- */
857
- export declare function resolveWorkspaceGlobs(repoRoot: string, options?: Pick<DiscoverWorkspacePackagesOptions, "readText">): WorkspaceGlobs;
858
- export { type Astromech, type AstromechOptions, type CiJobReport, type CiOptions, type CiReport, type CreateHeaderOptions, type DependabotConfigOptions, type DeployOnReleaseOptions, type DeployOnReleaseReport, type DeployOnReleaseResult, type WorkspacePackage as DeployWorkspacePackage, type DiscoverWorkspacePackagesOptions, type ExecFn, type GroupJobReport, type GroupOptions, type GroupReport, type HeaderFunctions, type JobDef, type LocalRunner, type OrgContext, type PreviewConfig, type RunLogger, type RunOptions, type RunTaskInput, type RunTaskReport, type TaskDef, type TsconfigOptions, type WorkflowHeaderFormat, type WorkspaceGlobs, type WorkspacePackage$1 as WorkspacePackage, createIgnoreConfig as createAlexignore, createRcConfig as createAlexrc, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createIgnoreConfig$1 as createYamlignore, createConfig$9 as createYamllint };
800
+ export { type Astromech, type AstromechOptions, type CiJobReport, type CiOptions, type CiReport, type CreateHeaderOptions, type DependabotConfigOptions, type DeployOnReleaseOptions, type DeployOnReleaseReport, type DeployOnReleaseResult, type WorkspacePackage as DeployWorkspacePackage, type ExecFn, type GroupJobReport, type GroupOptions, type GroupReport, type HeaderFunctions, type JobDef, type LocalRunner, type OrgContext, type PreviewConfig, type RunLogger, type RunOptions, type RunTaskInput, type RunTaskReport, type TaskDef, type TsconfigOptions, type WorkflowHeaderFormat, type WorkspacePackage$1 as WorkspacePackage, createIgnoreConfig as createAlexignore, createRcConfig as createAlexrc, createConfig as createCommitMsg, createConfig$1 as createDependabot, createConfig$2 as createDevmoji, createConfig$3 as createEditorconfig, createConfig$4 as createEditorconfigChecker, createConfig$5 as createLabeler, createConfig$6 as createPreCommit, createConfig$7 as createPrePush, createConfig$8 as createPrepareCommitMsg, createIgnoreConfig$1 as createYamlignore, createConfig$9 as createYamllint };
package/dist/index.mjs CHANGED
@@ -2,139 +2,13 @@ import { t as normalizeTaskEntry } from "./schema-CalPyBNd.mjs";
2
2
  import { t as loadTasksConfig } from "./load-C1uY2yBv.mjs";
3
3
  import { n as alexrc_default, t as editorconfig_checker_default } from "./editorconfig-checker-HPpphHhI.mjs";
4
4
  import { existsSync, readFileSync, readdirSync } from "node:fs";
5
- import { isAbsolute, join, relative, resolve, sep } from "node:path";
6
- import { dependencyNames, detectPackageManager, listWorkspacePackagesSync, parsePackageJson, readPackageJsonSync } from "@theholocron/pkg-utils";
5
+ import { dependencyNames, detectPackageManager, discoverWorkspacePackages, readPackageJsonSync } from "@theholocron/pkg-utils";
7
6
  import { stringifyJson } from "@theholocron/json-utils";
8
7
  import { spawnSync } from "node:child_process";
8
+ import { join, relative } from "node:path";
9
9
  import { findExecutableSync } from "@theholocron/fs-utils";
10
10
  // src/templates/codecov/codecov.yml
11
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
- // src/workspace/workspace-globs.ts
13
- /**
14
- * The `packages:` list of a `pnpm-workspace.yaml`. A line-based read of the
15
- * plain block-list form, not a YAML parse -- the same approach (and for the
16
- * same reason) as `ensureRootWorkspaceMember()`: the file routinely carries a
17
- * `catalog:`/`catalogs:`/`overrides:` block after `packages:` that nothing
18
- * here should have to round-trip. Quotes and trailing comments are stripped;
19
- * a missing `packages:` key, or the inline `packages: [a, b]` form, reads as no
20
- * globs (callers fall back to the default roots).
21
- */
22
- function readWorkspaceGlobs(workspaceYaml) {
23
- const lines = workspaceYaml.split("\n");
24
- const start = lines.findIndex((line) => /^packages:\s*(#.*)?$/.test(line));
25
- const globs = {
26
- include: [],
27
- exclude: []
28
- };
29
- if (start === -1) return globs;
30
- for (const line of lines.slice(start + 1)) {
31
- if (line.trim() === "" || /^\s*#/.test(line)) continue;
32
- const item = /^\s*-\s*(.*)$/.exec(line);
33
- if (!item) break;
34
- const value = item[1].replace(/(^|\s)#.*$/, "").trim().replace(/^["']|["']$/g, "").trim();
35
- if (value === "") continue;
36
- if (value.startsWith("!")) globs.exclude.push(normalizeGlob(value.slice(1)));
37
- else globs.include.push(normalizeGlob(value));
38
- }
39
- return globs;
40
- }
41
- /** `./a/b/` -> `a/b`: the form {@link discoverWorkspacePackages} matches against `relativeDir`. */
42
- function normalizeGlob(glob) {
43
- return glob.replace(/^\.\//, "").replace(/\/+$/, "");
44
- }
45
- // src/workspace/discover-workspace-packages.ts
46
- /** Where packages live when there is no `pnpm-workspace.yaml` (or it lists none): the layout before globs were read. */
47
- const DEFAULT_WORKSPACE_ROOTS = [
48
- "packages",
49
- "apps",
50
- "plugins"
51
- ];
52
- /** Characters pnpm globs treat specially. A literal directory has none of them. */
53
- const GLOB_CHARS = /[*?[\]{}!]/;
54
- /**
55
- * Every package the repo's `pnpm-workspace.yaml` declares, as
56
- * `listWorkspacePackagesSync()` entries -- in glob order, packages within a
57
- * `<dir>/*` glob sorted by name. Two forms of glob are understood:
58
- *
59
- * - `<dir>/*`: each child of `<dir>` that has a `package.json` (`clients/*`).
60
- * - a literal directory: that directory is the package (`observability`,
61
- * `docs/theme`).
62
- *
63
- * `!pattern` entries drop matching packages. The repo root (`.`) is not a
64
- * workspace child and is skipped; callers that treat a root-only repo as a
65
- * single package read the root manifest themselves. Any other glob throws
66
- * rather than being silently skipped. Without a `pnpm-workspace.yaml`, or one
67
- * with no `packages:`, the default roots are scanned.
68
- *
69
- * Nothing is filtered by `name`, `version` or `private`; that is the caller's
70
- * call, as for `listWorkspacePackagesSync()`.
71
- */
72
- function discoverWorkspacePackages(repoRoot, options = {}) {
73
- const base = resolve(repoRoot);
74
- const readFile = options.readFile ?? ((path) => readFileSync(path, "utf8"));
75
- const { include, exclude } = resolveWorkspaceGlobs(base, options);
76
- const entries = /* @__PURE__ */ new Map();
77
- for (const glob of include) {
78
- if (glob === "." || glob === "") continue;
79
- for (const entry of expandGlob(base, glob, {
80
- readFile,
81
- listDirs: options.listDirs
82
- })) if (!exclude.some((pattern) => matches(entry.relativeDir, pattern))) entries.set(entry.relativeDir, entry);
83
- }
84
- const { group, excludeGroups = [] } = options;
85
- return [...entries.values()].filter(({ relativeDir }) => (group === void 0 || inGroup(relativeDir, group)) && !excludeGroups.some((excluded) => inGroup(relativeDir, excluded)));
86
- }
87
- /** `relativeDir` is the group's folder, or is under it. `clients` holds `clients/http`, not `clients-old/x`. */
88
- function inGroup(relativeDir, group) {
89
- const folder = group.replace(/^\.\//, "").replace(/\/+$/, "");
90
- return relativeDir === folder || relativeDir.startsWith(`${folder}/`);
91
- }
92
- /**
93
- * The globs {@link discoverWorkspacePackages} scans: the repo's
94
- * `pnpm-workspace.yaml` `packages:` list, or the {@link DEFAULT_WORKSPACE_ROOTS}
95
- * as `<root>/*` when there is no such file or it lists none.
96
- */
97
- function resolveWorkspaceGlobs(repoRoot, options = {}) {
98
- const readText = options.readText ?? ((path) => readFileSync(path, "utf8"));
99
- let workspaceYaml = "";
100
- try {
101
- workspaceYaml = readText(join(resolve(repoRoot), "pnpm-workspace.yaml"));
102
- } catch {}
103
- const { include, exclude } = readWorkspaceGlobs(workspaceYaml);
104
- return {
105
- include: include.length > 0 ? include : DEFAULT_WORKSPACE_ROOTS.map((root) => `${root}/*`),
106
- exclude
107
- };
108
- }
109
- function expandGlob(base, glob, options) {
110
- if (glob.endsWith("/*") && !GLOB_CHARS.test(glob.slice(0, -2))) return listWorkspacePackagesSync(base, {
111
- ...options,
112
- roots: [glob.slice(0, -2)]
113
- });
114
- if (GLOB_CHARS.test(glob)) throw new TypeError(`unsupported workspace pattern ${JSON.stringify(glob)}: only "<dir>/*" and literal directories are supported`);
115
- const rel = relative(base, resolve(base, glob));
116
- if (isAbsolute(glob) || rel === ".." || rel.startsWith(`..${sep}`)) throw new TypeError(`workspace directory must be inside the repo, got ${JSON.stringify(glob)}`);
117
- const dir = join(base, glob);
118
- try {
119
- const manifest = parsePackageJson(options.readFile(join(dir, "package.json")));
120
- return manifest ? [{
121
- name: manifest.name,
122
- dir,
123
- relativeDir: glob,
124
- manifest
125
- }] : [];
126
- } catch {
127
- return [];
128
- }
129
- }
130
- /** `relativeDir` against an exclusion: the same directory, or a child of `<dir>/*`. */
131
- function matches(relativeDir, pattern) {
132
- if (pattern.endsWith("/*")) {
133
- const parent = pattern.slice(0, -2);
134
- return relativeDir.startsWith(`${parent}/`) && !relativeDir.slice(parent.length + 1).includes("/");
135
- }
136
- return relativeDir === pattern;
137
- }
138
12
  // src/generators/codecov/codecov.ts
139
13
  /**
140
14
  * `codecov.yml` generation — a manifest-derived artifact (component `paths`
@@ -321,9 +195,37 @@ function ensureInformationalComponentStatuses(yaml) {
321
195
  }
322
196
  return lines.join("\n");
323
197
  }
324
- /** Everything `codecov.yml` needs on top of the components list: if_not_found, flags, scoped aggregates, informational components. */
198
+ /** Documentation Codecov would otherwise count as testable code, though nothing reports coverage for it. */
199
+ const IGNORED_DOCS = ["**/*.mdx"];
200
+ const ignoreEntry = (glob) => ` - "${glob}"`;
201
+ /**
202
+ * Ensure a top-level `ignore:` list names the documentation files in {@link IGNORED_DOCS}. Without it a docs-only
203
+ * PR that adds `.mdx` pages is judged to change testable files, posts no coverage and fails `codecov/patch` and
204
+ * `codecov/project` ("Empty Upload", #1442). A missing list is inserted before `coverage:`; an existing one only
205
+ * gains the entries it lacks, so hand-added globs survive.
206
+ */
207
+ function ensureIgnore(yaml) {
208
+ const lines = yaml.split("\n");
209
+ const range = section(lines, "ignore");
210
+ if (!range) {
211
+ const block = [
212
+ "ignore:",
213
+ ...IGNORED_DOCS.map(ignoreEntry),
214
+ ""
215
+ ];
216
+ const at = lines.indexOf("coverage:");
217
+ if (at === -1) {
218
+ while (lines.at(-1) === "") lines.pop();
219
+ lines.push("", ...block.slice(0, -1));
220
+ } else lines.splice(at, 0, ...block);
221
+ return lines.join("\n");
222
+ }
223
+ appendMissingItems(lines, range[0], range[1], IGNORED_DOCS, /^ {2}- ["']?([^"'\s]+)/, ignoreEntry);
224
+ return lines.join("\n");
225
+ }
226
+ /** Everything `codecov.yml` needs on top of the components list: if_not_found, ignored docs, flags, scoped aggregates, informational components. */
325
227
  function applyStatusRules(yaml, flags) {
326
- return ensureInformationalComponentStatuses(scopeAggregateStatuses(ensureFlagManagement(ensureIfNotFound(yaml), flags), flags));
228
+ return ensureInformationalComponentStatuses(scopeAggregateStatuses(ensureFlagManagement(ensureIgnore(ensureIfNotFound(yaml)), flags), flags));
327
229
  }
328
230
  function mergeCodecovComponents(existing, packages) {
329
231
  const flags = codecovFlagNames(packages);
@@ -3291,4 +3193,4 @@ function createConfig$9() {
3291
3193
  function createIgnoreConfig$1() {
3292
3194
  return `${workflowHeader()}${_yamlignore_default}`;
3293
3195
  }
3294
- 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 };
3196
+ export { CI_ORDER, 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, ensureIfNotFound, extractPreviewConfig, generateCombinedDeployContent, generateThinCallerContent, matchNamespace, mergeCodecovComponents, normalizeWorkflowWith, readWorkspacePackages, requiredChecks, reusableTemplates, runCi, runGroup, runTask, workspacePackages };
@@ -1,7 +1,7 @@
1
1
  import { t as normalizeTaskEntry } from "../schema-CalPyBNd.mjs";
2
2
  import { createRequire } from "node:module";
3
- import { join } from "node:path";
4
3
  import { execFileSync } from "node:child_process";
4
+ import { join } from "node:path";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { defineConfig } from "@theholocron/semantic-release-config";
7
7
  // src/release/commit-files/commit-files.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/astromech",
3
- "version": "5.0.0-alpha.274",
3
+ "version": "5.0.0-alpha.276",
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,10 +50,10 @@
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.276",
53
54
  "@theholocron/fs-utils": "^1.16.1-alpha.1",
54
55
  "@theholocron/json-utils": "^1.16.1-alpha.1",
55
- "@theholocron/pkg-utils": "^1.16.1-alpha.1",
56
- "@theholocron/datapad": "5.0.0-alpha.274"
56
+ "@theholocron/pkg-utils": "^1.16.1-alpha.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@commitlint/config-conventional": "^21.2.3",
@@ -69,11 +69,11 @@
69
69
  "tsdown": "^0.23.3",
70
70
  "typescript": "^5.9.3",
71
71
  "vitest": "^5.0.5",
72
- "@theholocron/commitlint-config": "^8.9.0-alpha.3",
73
72
  "@theholocron/eslint-config": "^8.9.0-alpha.3",
74
73
  "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.3",
75
74
  "@theholocron/semantic-release-config": "^8.9.0-alpha.3",
76
75
  "@theholocron/tsconfig": "^8.9.0-alpha.3",
76
+ "@theholocron/commitlint-config": "^8.9.0-alpha.3",
77
77
  "@theholocron/vitest-config": "^8.9.0-alpha.3",
78
78
  "@theholocron/tsdown-config": "^8.9.0-alpha.3"
79
79
  },