@theholocron/astromech 5.0.0-alpha.148 → 5.0.0-alpha.150
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/config/index.d.mts +23 -11
- package/dist/config/index.mjs +14 -2
- package/dist/index.mjs +32 -50
- package/dist/{load-BqpxDjMJ.mjs → load-ToVjaKPr.mjs} +15 -23
- package/package.json +6 -6
package/dist/config/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as TaskEntry, r as TasksConfig, t as TaskConfigItem } from "../schema.type-BUiSrwS5.mjs";
|
|
2
|
+
import { Loaded } from "@theholocron/datapad";
|
|
2
3
|
//#region src/config/define.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Typed identity helper for `astromech.config.ts`:
|
|
@@ -13,6 +14,23 @@ import { n as TaskEntry, r as TasksConfig, t as TaskConfigItem } from "../schema
|
|
|
13
14
|
*/
|
|
14
15
|
declare const defineConfig: <C extends TasksConfig>(config: C) => C;
|
|
15
16
|
//#endregion
|
|
17
|
+
//#region src/config/load.type.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* The `tasks` value in each source. A dedicated `astromech.config.*`
|
|
20
|
+
* default-exports the full {@link TasksConfig} object; the `tasks` key of
|
|
21
|
+
* `holocron.config.*` is the bare item array (it mirrors the old
|
|
22
|
+
* `workflows` key). Either form is accepted from either source.
|
|
23
|
+
*/
|
|
24
|
+
type TasksInput = TasksConfig | TaskConfigItem[];
|
|
25
|
+
interface LoadTasksConfigOptions {
|
|
26
|
+
/**
|
|
27
|
+
* The `holocron.config.*` the caller has already loaded (`null`: it looked and
|
|
28
|
+
* there is none), so it isn't found and loaded a second time. Leave it unset
|
|
29
|
+
* to have `loadTasksConfig` find it itself.
|
|
30
|
+
*/
|
|
31
|
+
holocron?: Loaded<object> | null;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
16
34
|
//#region src/config/load.d.ts
|
|
17
35
|
/**
|
|
18
36
|
* Resolve the task manifest for a repo: the `tasks` key of
|
|
@@ -23,21 +41,15 @@ declare const defineConfig: <C extends TasksConfig>(config: C) => C;
|
|
|
23
41
|
* `walkUp: true` — `holocron run`/`ci` are usable from any subdirectory of
|
|
24
42
|
* a repo, not only its exact root (datapad walks up to the nearest `.git`
|
|
25
43
|
* boundary; see `@theholocron/datapad`'s own doc comment).
|
|
44
|
+
*
|
|
45
|
+
* A caller that has already loaded `holocron.config.*` passes it as
|
|
46
|
+
* `options.holocron` so it is not found and loaded again.
|
|
26
47
|
*/
|
|
27
|
-
declare function loadTasksConfig(cwd: string): Promise<TasksConfig>;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/config/load.type.d.ts
|
|
30
|
-
/**
|
|
31
|
-
* The `tasks` value in each source. A dedicated `astromech.config.*`
|
|
32
|
-
* default-exports the full {@link TasksConfig} object; the `tasks` key of
|
|
33
|
-
* `holocron.config.*` is the bare item array (it mirrors the old
|
|
34
|
-
* `workflows` key). Either form is accepted from either source.
|
|
35
|
-
*/
|
|
36
|
-
type TasksInput = TasksConfig | TaskConfigItem[];
|
|
48
|
+
declare function loadTasksConfig(cwd: string, options?: LoadTasksConfigOptions): Promise<TasksConfig>;
|
|
37
49
|
//#endregion
|
|
38
50
|
//#region src/config/merge-tasks-layers.d.ts
|
|
39
51
|
/**
|
|
40
|
-
* The
|
|
52
|
+
* The same layering as {@link loadTasksConfig}, for callers that load the two
|
|
41
53
|
* sources some other way (Sentinel reads them from the GitHub API, not
|
|
42
54
|
* from disk, holocron#916): `holocron.config.*`'s `tasks` value first,
|
|
43
55
|
* then a dedicated `astromech.config.*`'s default export merged on top.
|
package/dist/config/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { createDefineConfig } from "@theholocron/datapad";
|
|
1
|
+
import { n as coerceTasks, r as normalizeTaskEntry, t as loadTasksConfig } from "../load-ToVjaKPr.mjs";
|
|
2
|
+
import { createDefineConfig, mergeLayers } from "@theholocron/datapad";
|
|
3
3
|
//#region src/config/define.ts
|
|
4
4
|
/**
|
|
5
5
|
* Typed identity helper for `astromech.config.ts`:
|
|
@@ -14,4 +14,16 @@ import { createDefineConfig } from "@theholocron/datapad";
|
|
|
14
14
|
*/
|
|
15
15
|
const defineConfig = createDefineConfig();
|
|
16
16
|
//#endregion
|
|
17
|
+
//#region src/config/merge-tasks-layers.ts
|
|
18
|
+
/**
|
|
19
|
+
* The same layering as {@link loadTasksConfig}, for callers that load the two
|
|
20
|
+
* sources some other way (Sentinel reads them from the GitHub API, not
|
|
21
|
+
* from disk, holocron#916): `holocron.config.*`'s `tasks` value first,
|
|
22
|
+
* then a dedicated `astromech.config.*`'s default export merged on top.
|
|
23
|
+
* Either may be `undefined` (source absent); returns `{}` when both are.
|
|
24
|
+
*/
|
|
25
|
+
function mergeTasksLayers(parentTasks, dedicated) {
|
|
26
|
+
return mergeLayers([coerceTasks(parentTasks), coerceTasks(dedicated)]) ?? {};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
17
29
|
export { defineConfig, loadTasksConfig, mergeTasksLayers, normalizeTaskEntry };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as normalizeTaskEntry, t as loadTasksConfig } from "./load-
|
|
1
|
+
import { r as normalizeTaskEntry, t as loadTasksConfig } from "./load-ToVjaKPr.mjs";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { dependencyNames, detectPackageManager, listWorkspacePackagesSync, readPackageJsonSync } from "@theholocron/pkg-utils";
|
|
4
4
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
5
|
-
import {
|
|
5
|
+
import { join, relative } from "node:path";
|
|
6
6
|
import { spawnSync } from "node:child_process";
|
|
7
7
|
import { findExecutableSync } from "@theholocron/fs-utils";
|
|
8
8
|
//#region src/templates/codecov/codecov.yml
|
|
@@ -75,24 +75,6 @@ function mergeCodecovComponents(existing, packages) {
|
|
|
75
75
|
if (idx === -1) return ensureIfNotFound(existing);
|
|
76
76
|
return ensureIfNotFound(existing.slice(0, idx + 24)) + codecovComponentBlock(packages);
|
|
77
77
|
}
|
|
78
|
-
function readWorkspaceDir(repoRoot, dir) {
|
|
79
|
-
const dirPath = join(repoRoot, dir);
|
|
80
|
-
if (!existsSync(dirPath)) return [];
|
|
81
|
-
const packages = [];
|
|
82
|
-
for (const entry of readdirSync(dirPath, { withFileTypes: true })) {
|
|
83
|
-
if (!entry.isDirectory()) continue;
|
|
84
|
-
try {
|
|
85
|
-
const raw = readFileSync(join(dirPath, entry.name, "package.json"), "utf8");
|
|
86
|
-
const pkg = JSON.parse(raw);
|
|
87
|
-
if (typeof pkg.name === "string") packages.push({
|
|
88
|
-
slug: entry.name,
|
|
89
|
-
name: pkg.name,
|
|
90
|
-
dir
|
|
91
|
-
});
|
|
92
|
-
} catch {}
|
|
93
|
-
}
|
|
94
|
-
return packages;
|
|
95
|
-
}
|
|
96
78
|
/**
|
|
97
79
|
* Every public `packages/*`, `apps/*`, and `plugins/*` workspace, sorted by
|
|
98
80
|
* slug. `[]` when none of the three directories exist. Monorepo templates
|
|
@@ -102,11 +84,18 @@ function readWorkspaceDir(repoRoot, dir) {
|
|
|
102
84
|
* component so `codecov/patch/<slug>` actually posts for each.
|
|
103
85
|
*/
|
|
104
86
|
function readWorkspacePackages(repoRoot) {
|
|
105
|
-
return [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
].
|
|
87
|
+
return listWorkspacePackagesSync(repoRoot, { roots: [
|
|
88
|
+
"packages",
|
|
89
|
+
"apps",
|
|
90
|
+
"plugins"
|
|
91
|
+
] }).flatMap(({ name, relativeDir }) => {
|
|
92
|
+
const [dir, slug] = relativeDir.split("/");
|
|
93
|
+
return name ? [{
|
|
94
|
+
slug,
|
|
95
|
+
name,
|
|
96
|
+
dir
|
|
97
|
+
}] : [];
|
|
98
|
+
}).sort((a, b) => a.slug.localeCompare(b.slug));
|
|
110
99
|
}
|
|
111
100
|
/** A brand-new `codecov.yml` — the scaffold header + the base template + this repo's component list. */
|
|
112
101
|
function createCodecovConfig(packages) {
|
|
@@ -2194,35 +2183,28 @@ async function waitForPublished({ packages, run, sleep, now, cwd, timeoutMs = WA
|
|
|
2194
2183
|
}
|
|
2195
2184
|
//#endregion
|
|
2196
2185
|
//#region src/tasks/deploy-on-release/workspace-packages.ts
|
|
2197
|
-
function scanWorkspaceDir(dirPath, { readJson, listDirs }) {
|
|
2198
|
-
let folders;
|
|
2199
|
-
try {
|
|
2200
|
-
folders = listDirs(dirPath);
|
|
2201
|
-
} catch {
|
|
2202
|
-
return [];
|
|
2203
|
-
}
|
|
2204
|
-
return folders.flatMap((folder) => {
|
|
2205
|
-
try {
|
|
2206
|
-
const manifest = readJson(join(dirPath, folder, "package.json"));
|
|
2207
|
-
if (!manifest.name) return [];
|
|
2208
|
-
return [{
|
|
2209
|
-
name: manifest.name,
|
|
2210
|
-
dir: join(dirPath, folder),
|
|
2211
|
-
version: manifest.version,
|
|
2212
|
-
dependencies: manifest.dependencies ?? {}
|
|
2213
|
-
}];
|
|
2214
|
-
} catch {
|
|
2215
|
-
return [];
|
|
2216
|
-
}
|
|
2217
|
-
});
|
|
2218
|
-
}
|
|
2219
2186
|
/**
|
|
2220
2187
|
* Every package under `<repoRoot>/packages/*` and `<repoRoot>/plugins/*`
|
|
2221
2188
|
* with a readable, named `package.json` — `holocron`'s own layout splits
|
|
2222
2189
|
* vendor plugin packages into `plugins/*`, sibling to `packages/*`.
|
|
2223
2190
|
*/
|
|
2224
|
-
function workspacePackages(repoRoot,
|
|
2225
|
-
return
|
|
2191
|
+
function workspacePackages(repoRoot, { readJson, listDirs }) {
|
|
2192
|
+
return listWorkspacePackagesSync(repoRoot, {
|
|
2193
|
+
roots: ["packages", "plugins"],
|
|
2194
|
+
readFile: (path) => JSON.stringify(readJson(path)),
|
|
2195
|
+
listDirs: (path) => {
|
|
2196
|
+
try {
|
|
2197
|
+
return listDirs(path);
|
|
2198
|
+
} catch {
|
|
2199
|
+
throw Object.assign(/* @__PURE__ */ new Error(`ENOENT: ${path}`), { code: "ENOENT" });
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}).flatMap(({ name, dir, manifest }) => name ? [{
|
|
2203
|
+
name,
|
|
2204
|
+
dir,
|
|
2205
|
+
version: manifest.version,
|
|
2206
|
+
dependencies: manifest.dependencies ?? {}
|
|
2207
|
+
}] : []);
|
|
2226
2208
|
}
|
|
2227
2209
|
//#endregion
|
|
2228
2210
|
//#region src/tasks/deploy-on-release/deploy-on-release.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { loadLayered } from "@theholocron/datapad";
|
|
2
2
|
//#region src/config/schema.ts
|
|
3
3
|
/**
|
|
4
4
|
* The `tasks` config shape — the single manifest of what a repo runs.
|
|
@@ -24,18 +24,6 @@ function coerceTasks(value) {
|
|
|
24
24
|
return Array.isArray(value) ? { tasks: value } : value;
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region src/config/merge-tasks-layers.ts
|
|
28
|
-
/**
|
|
29
|
-
* The merge step of {@link loadTasksConfig}, for callers that load the two
|
|
30
|
-
* sources some other way (Sentinel reads them from the GitHub API, not
|
|
31
|
-
* from disk, holocron#916): `holocron.config.*`'s `tasks` value first,
|
|
32
|
-
* then a dedicated `astromech.config.*`'s default export merged on top.
|
|
33
|
-
* Either may be `undefined` (source absent); returns `{}` when both are.
|
|
34
|
-
*/
|
|
35
|
-
function mergeTasksLayers(parentTasks, dedicated) {
|
|
36
|
-
return [coerceTasks(parentTasks), coerceTasks(dedicated)].filter((layer) => layer !== void 0).reduce((acc, layer) => mergeConfig(acc, layer), {});
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
27
|
//#region src/config/load.ts
|
|
40
28
|
/**
|
|
41
29
|
* Resolve the task manifest for a repo: the `tasks` key of
|
|
@@ -46,18 +34,22 @@ function mergeTasksLayers(parentTasks, dedicated) {
|
|
|
46
34
|
* `walkUp: true` — `holocron run`/`ci` are usable from any subdirectory of
|
|
47
35
|
* a repo, not only its exact root (datapad walks up to the nearest `.git`
|
|
48
36
|
* boundary; see `@theholocron/datapad`'s own doc comment).
|
|
37
|
+
*
|
|
38
|
+
* A caller that has already loaded `holocron.config.*` passes it as
|
|
39
|
+
* `options.holocron` so it is not found and loaded again.
|
|
49
40
|
*/
|
|
50
|
-
async function loadTasksConfig(cwd) {
|
|
51
|
-
|
|
41
|
+
async function loadTasksConfig(cwd, options = {}) {
|
|
42
|
+
return (await loadLayered({
|
|
52
43
|
cwd,
|
|
53
44
|
name: "astromech",
|
|
54
|
-
walkUp: true
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
walkUp: true,
|
|
46
|
+
fallback: {
|
|
47
|
+
file: "holocron",
|
|
48
|
+
key: "tasks",
|
|
49
|
+
preloaded: options.holocron
|
|
50
|
+
},
|
|
51
|
+
coerce: (raw) => coerceTasks(raw)
|
|
52
|
+
}))?.config ?? {};
|
|
61
53
|
}
|
|
62
54
|
//#endregion
|
|
63
|
-
export {
|
|
55
|
+
export { coerceTasks as n, normalizeTaskEntry as r, loadTasksConfig as t };
|
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.150",
|
|
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",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@theholocron/fs-utils": "^1.
|
|
41
|
-
"@theholocron/json-utils": "^1.
|
|
42
|
-
"@theholocron/pkg-utils": "^1.
|
|
43
|
-
"@theholocron/datapad": "5.0.0-alpha.
|
|
40
|
+
"@theholocron/fs-utils": "^1.13.0",
|
|
41
|
+
"@theholocron/json-utils": "^1.13.0",
|
|
42
|
+
"@theholocron/pkg-utils": "^1.13.0",
|
|
43
|
+
"@theholocron/datapad": "5.0.0-alpha.150"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@theholocron/eslint-config": "^8.7.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"tsdown": "^0.22.14",
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
58
|
"vitest": "^4.1.11",
|
|
59
|
-
"@theholocron/rollup-plugin-transform-template": "5.0.0-alpha.
|
|
59
|
+
"@theholocron/rollup-plugin-transform-template": "5.0.0-alpha.150"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=22"
|