@theholocron/cli 3.24.1 → 3.24.2

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/cli.mjs CHANGED
@@ -2808,6 +2808,65 @@ function generateThinCallerContent(name, withOverrides, additionalPaths) {
2808
2808
  if (injected === result) console.warn(`[generateThinCallerContent] could not inject with: overrides into "${name}" template`);
2809
2809
  return injected;
2810
2810
  }
2811
+ /**
2812
+ * Expand structured with-values to flat GitHub Actions inputs before
2813
+ * generating the thin caller. Handles:
2814
+ * - deploy shorthand: docs/storybook → type + storybook-projects
2815
+ * - run-chromatic object → run-chromatic: true + chromatic-projects
2816
+ * - plain arrays → JSON-stringified for YAML scalar quoting
2817
+ *
2818
+ * Used by both `holocron setup` and `sync-workflow-templates`.
2819
+ */
2820
+ function normalizeWorkflowWith(raw) {
2821
+ const result = { ...raw };
2822
+ const hasDocs = raw["docs"] === true || raw["docs"] !== null && typeof raw["docs"] === "object";
2823
+ const storybookProjects = raw["storybook"];
2824
+ if (hasDocs) {
2825
+ result["type"] = "docs";
2826
+ delete result["docs"];
2827
+ }
2828
+ if (Array.isArray(storybookProjects)) {
2829
+ if (!hasDocs) result["type"] = "storybook";
2830
+ result["storybook-projects"] = JSON.stringify(storybookProjects.map(({ name, path = "." }) => ({
2831
+ name,
2832
+ workingDir: path
2833
+ })));
2834
+ delete result["storybook"];
2835
+ }
2836
+ const runChromatic = raw["run-chromatic"];
2837
+ if (runChromatic !== null && typeof runChromatic === "object" && "projects" in runChromatic) {
2838
+ result["run-chromatic"] = true;
2839
+ const projects = runChromatic.projects.map((p) => ({
2840
+ ...p,
2841
+ ...Array.isArray(p.untraced) ? { untraced: p.untraced.join("\n") } : {}
2842
+ }));
2843
+ result["chromatic-projects"] = JSON.stringify(projects);
2844
+ }
2845
+ for (const [k, v] of Object.entries(result)) if (Array.isArray(v)) result[k] = JSON.stringify(v);
2846
+ return result;
2847
+ }
2848
+ /**
2849
+ * Derive on.push.paths entries from the deploy with: shorthand.
2850
+ * Used by both `holocron setup` and `sync-workflow-templates`.
2851
+ */
2852
+ function deriveDeployPaths(raw) {
2853
+ const paths = [];
2854
+ const docs = raw["docs"];
2855
+ if (docs === true) paths.push("docs/**");
2856
+ else if (docs !== null && typeof docs === "object" && "path" in docs) {
2857
+ const p = docs.path;
2858
+ if (p && p !== ".") paths.push(`${p}/**`);
2859
+ }
2860
+ const storybookProjects = raw["storybook"];
2861
+ if (Array.isArray(storybookProjects)) for (const s of storybookProjects) {
2862
+ const p = s.path || ".";
2863
+ if (p === ".") {
2864
+ paths.push("src/**");
2865
+ paths.push(".storybook/**");
2866
+ } else paths.push(`${p}/**`);
2867
+ }
2868
+ return paths;
2869
+ }
2811
2870
  //#endregion
2812
2871
  //#region src/commands/setup.ts
2813
2872
  /**
@@ -3264,52 +3323,6 @@ async function runSetup(input) {
3264
3323
  print(formatStep(steps[steps.length - 1]));
3265
3324
  }
3266
3325
  }
3267
- function normalizeWorkflowWith(raw) {
3268
- const result = { ...raw };
3269
- const hasDocs = raw["docs"] === true || raw["docs"] !== null && typeof raw["docs"] === "object";
3270
- const storybookProjects = raw["storybook"];
3271
- if (hasDocs) {
3272
- result["type"] = "docs";
3273
- delete result["docs"];
3274
- }
3275
- if (Array.isArray(storybookProjects)) {
3276
- if (!hasDocs) result["type"] = "storybook";
3277
- result["storybook-projects"] = JSON.stringify(storybookProjects.map(({ name, path = "." }) => ({
3278
- name,
3279
- workingDir: path
3280
- })));
3281
- delete result["storybook"];
3282
- }
3283
- const runChromatic = raw["run-chromatic"];
3284
- if (runChromatic !== null && typeof runChromatic === "object" && "projects" in runChromatic) {
3285
- result["run-chromatic"] = true;
3286
- const projects = runChromatic.projects.map((p) => ({
3287
- ...p,
3288
- ...Array.isArray(p.untraced) ? { untraced: p.untraced.join("\n") } : {}
3289
- }));
3290
- result["chromatic-projects"] = JSON.stringify(projects);
3291
- }
3292
- for (const [k, v] of Object.entries(result)) if (Array.isArray(v)) result[k] = JSON.stringify(v);
3293
- return result;
3294
- }
3295
- function deriveDeployPaths(raw) {
3296
- const paths = [];
3297
- const docs = raw["docs"];
3298
- if (docs === true) paths.push("docs/**");
3299
- else if (docs !== null && typeof docs === "object" && "path" in docs) {
3300
- const p = docs.path;
3301
- if (p && p !== ".") paths.push(`${p}/**`);
3302
- }
3303
- const storybookProjects = raw["storybook"];
3304
- if (Array.isArray(storybookProjects)) for (const s of storybookProjects) {
3305
- const p = s.path || ".";
3306
- if (p === ".") {
3307
- paths.push("src/**");
3308
- paths.push(".storybook/**");
3309
- } else paths.push(`${p}/**`);
3310
- }
3311
- return paths;
3312
- }
3313
3326
  const workflows = config.workflows;
3314
3327
  if (loader.has("source") && workflows && workflows.length > 0) {
3315
3328
  const source = loader.get("source");
@@ -4333,7 +4346,8 @@ function parseWorkflowsFromTs(source) {
4333
4346
  objSpans.push([m.index, m.index + m[0].length]);
4334
4347
  let withObj;
4335
4348
  if (m[2]) try {
4336
- withObj = JSON.parse(m[2]);
4349
+ const jsonSafe = m[2].replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/g, "$1\"$2\":");
4350
+ withObj = JSON.parse(jsonSafe);
4337
4351
  } catch {}
4338
4352
  entries.push({
4339
4353
  pos: m.index,
@@ -4395,7 +4409,8 @@ function buildBatch(repo, allowedWorkflows, withOverrides) {
4395
4409
  }
4396
4410
  } else for (const name of Object.keys(REUSABLE_WORKFLOWS)) {
4397
4411
  if (allowedWorkflows && !allowedWorkflows.has(name)) continue;
4398
- const content = generateThinCallerContent(name, withOverrides?.get(name));
4412
+ const rawWith = withOverrides?.get(name);
4413
+ const content = generateThinCallerContent(name, rawWith ? normalizeWorkflowWith(rawWith) : void 0, name === "deploy" && rawWith ? deriveDeployPaths(rawWith) : void 0);
4399
4414
  if (!content) continue;
4400
4415
  files.push({
4401
4416
  path: `.github/workflows/${name}.yml`,