@theholocron/astromech 5.0.0-alpha.148 → 5.0.0-alpha.149

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.
@@ -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 merge step of {@link loadTasksConfig}, for callers that load the two
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.
@@ -1,5 +1,5 @@
1
- import { n as mergeTasksLayers, r as normalizeTaskEntry, t as loadTasksConfig } from "../load-BqpxDjMJ.mjs";
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,4 +1,4 @@
1
- import { r as normalizeTaskEntry, t as loadTasksConfig } from "./load-BqpxDjMJ.mjs";
1
+ import { r as normalizeTaskEntry, t as loadTasksConfig } from "./load-ToVjaKPr.mjs";
2
2
  import { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import { join, relative } from "node:path";
4
4
  import { stringifyJson } from "@theholocron/json-utils";
@@ -1,4 +1,4 @@
1
- import { loadConfigFile, mergeConfig } from "@theholocron/datapad";
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
- const dedicated = await loadConfigFile({
41
+ async function loadTasksConfig(cwd, options = {}) {
42
+ return (await loadLayered({
52
43
  cwd,
53
44
  name: "astromech",
54
- walkUp: true
55
- });
56
- return mergeTasksLayers((await loadConfigFile({
57
- cwd,
58
- name: "holocron",
59
- walkUp: true
60
- }))?.config.tasks, dedicated?.config);
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 { mergeTasksLayers as n, normalizeTaskEntry as r, loadTasksConfig as t };
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.148",
3
+ "version": "5.0.0-alpha.149",
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",
@@ -40,7 +40,7 @@
40
40
  "@theholocron/fs-utils": "^1.12.0",
41
41
  "@theholocron/json-utils": "^1.12.0",
42
42
  "@theholocron/pkg-utils": "^1.12.0",
43
- "@theholocron/datapad": "5.0.0-alpha.148"
43
+ "@theholocron/datapad": "5.0.0-alpha.149"
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.148"
59
+ "@theholocron/rollup-plugin-transform-template": "5.0.0-alpha.149"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=22"