@theholocron/cli 3.37.2 → 3.38.1

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
@@ -4897,97 +4897,6 @@ const WORKFLOW_TEMPLATE_PROPERTIES = { bookkeeping: JSON.stringify({
4897
4897
  //#endregion
4898
4898
  //#region src/commands/sync-github.ts
4899
4899
  const DEFAULT_REPO = "theholocron/.github";
4900
- /**
4901
- * Extracts the `workflows` array from a `holocron.config.ts` source string.
4902
- * Handles both plain string entries and `{ name, with }` object entries.
4903
- * Falls back to an empty array if the array cannot be found or parsed.
4904
- */
4905
- function parseWorkflowsFromTs(source) {
4906
- const keyMatch = source.match(/\bworkflows\s*:\s*\[/);
4907
- if (!keyMatch) return [];
4908
- const start = keyMatch.index + keyMatch[0].length;
4909
- let depth = 1;
4910
- let i = start;
4911
- while (i < source.length && depth > 0) {
4912
- if (source[i] === "[") depth++;
4913
- else if (source[i] === "]") depth--;
4914
- i++;
4915
- }
4916
- const body = source.slice(start, i - 1);
4917
- const hasPresetSpread = /\.\.\.[a-zA-Z_$][a-zA-Z0-9_$]*/.test(body);
4918
- const explicit = [];
4919
- const objSpans = [];
4920
- let j = 0;
4921
- while (j < body.length) {
4922
- if (body[j] !== "{") {
4923
- j++;
4924
- continue;
4925
- }
4926
- const objStart = j;
4927
- let objDepth = 1;
4928
- j++;
4929
- while (j < body.length && objDepth > 0) {
4930
- if (body[j] === "{") objDepth++;
4931
- else if (body[j] === "}") objDepth--;
4932
- j++;
4933
- }
4934
- const objContent = body.slice(objStart, j);
4935
- objSpans.push([objStart, j]);
4936
- const nameMatch = objContent.match(/\bname\s*:\s*"([^"]+)"/);
4937
- if (!nameMatch) continue;
4938
- const name = nameMatch[1];
4939
- let withObj;
4940
- const withKeyMatch = objContent.match(/\bwith\s*:\s*\{/);
4941
- if (withKeyMatch) {
4942
- const withOpen = withKeyMatch.index + withKeyMatch[0].length - 1;
4943
- let withDepth = 1;
4944
- let k = withOpen + 1;
4945
- while (k < objContent.length && withDepth > 0) {
4946
- if (objContent[k] === "{") withDepth++;
4947
- else if (objContent[k] === "}") withDepth--;
4948
- k++;
4949
- }
4950
- const withStr = objContent.slice(withOpen, k);
4951
- try {
4952
- const jsonSafe = withStr.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/g, "$1\"$2\":").replace(/,(\s*[}\]])/g, "$1");
4953
- withObj = JSON.parse(jsonSafe);
4954
- } catch {}
4955
- }
4956
- explicit.push({
4957
- pos: objStart,
4958
- entry: {
4959
- name,
4960
- ...withObj && { with: withObj }
4961
- }
4962
- });
4963
- }
4964
- const strRe = /"([^"]+)"/g;
4965
- let m;
4966
- while ((m = strRe.exec(body)) !== null) if (!objSpans.some(([s, e]) => m.index >= s && m.index < e)) explicit.push({
4967
- pos: m.index,
4968
- entry: { name: m[1] }
4969
- });
4970
- explicit.sort((a, b) => a.pos - b.pos);
4971
- const explicitEntries = explicit.map(({ entry }) => entry);
4972
- if (!hasPresetSpread) return explicitEntries;
4973
- const merged = new Map([...KNOWN_WORKFLOWS].map((name) => [name, { name }]));
4974
- for (const entry of explicitEntries) merged.set(entry.name, entry);
4975
- return [...merged.values()];
4976
- }
4977
- /**
4978
- * Extract org name and docs domain from a `holocron.config.ts` source string.
4979
- * Used to resolve `preview: true` to `{ project: "<org>-preview", domain: "preview.<docsDomain>" }`.
4980
- */
4981
- function parseOrgContextFromTs(source) {
4982
- const orgMatch = source.match(/\borg\s*:\s*["']([^"']+)["']/);
4983
- const domainMatch = source.match(/\bdomain\s*:\s*["']([^"']+)["']/);
4984
- const nameMatch = source.split(/\bworkflows\s*:/)[0].match(/\bname\s*:\s*["']([^"']+)["']/);
4985
- return {
4986
- org: orgMatch?.[1],
4987
- domain: domainMatch?.[1],
4988
- repoName: nameMatch?.[1]
4989
- };
4990
- }
4991
4900
  function reusableHeader(source) {
4992
4901
  return [
4993
4902
  `# AUTO-GENERATED — do not edit in theholocron/.github directly.`,
@@ -4998,7 +4907,7 @@ function reusableHeader(source) {
4998
4907
  ``
4999
4908
  ].join("\n");
5000
4909
  }
5001
- function buildBatch(repo, allowedWorkflows, withOverrides, orgContext) {
4910
+ function buildBatch(repo) {
5002
4911
  const files = [];
5003
4912
  const isPrimaryGithubRepo = repo === DEFAULT_REPO;
5004
4913
  if (isPrimaryGithubRepo) for (const [name, content] of Object.entries(ACTIONS)) files.push({
@@ -5021,28 +4930,6 @@ function buildBatch(repo, allowedWorkflows, withOverrides, orgContext) {
5021
4930
  content: props
5022
4931
  });
5023
4932
  }
5024
- } else for (const name of Object.keys(REUSABLE_WORKFLOWS)) {
5025
- if (name === "deploy-preview") continue;
5026
- if (allowedWorkflows && !allowedWorkflows.has(name)) continue;
5027
- const rawWith = withOverrides?.get(name);
5028
- const normalizedWith = rawWith ? normalizeWorkflowWith(rawWith) : void 0;
5029
- const additionalPaths = name === "deploy" && rawWith ? deriveDeployPaths(rawWith) : void 0;
5030
- if (name === "deploy" && rawWith) {
5031
- const previewCfg = extractPreviewConfig(rawWith, orgContext);
5032
- if (previewCfg) {
5033
- files.push({
5034
- path: `.github/workflows/deploy.yml`,
5035
- content: workflowHeader() + generateCombinedDeployContent(normalizedWith, additionalPaths, previewCfg)
5036
- });
5037
- continue;
5038
- }
5039
- }
5040
- const content = generateThinCallerContent(name, normalizedWith, additionalPaths);
5041
- if (!content) continue;
5042
- files.push({
5043
- path: `.github/workflows/${name}.yml`,
5044
- content: workflowHeader() + content
5045
- });
5046
4933
  }
5047
4934
  return files;
5048
4935
  }
@@ -5115,30 +5002,7 @@ async function runSyncGithub(input) {
5115
5002
  message: msg
5116
5003
  };
5117
5004
  }
5118
- let allowedWorkflows;
5119
- let withOverrides;
5120
- let orgContext;
5121
- if (repo !== DEFAULT_REPO) try {
5122
- let entries = [];
5123
- try {
5124
- const data = await client.git.getContents(repo, "holocron.config.json");
5125
- entries = (JSON.parse(Buffer.from(data.content.replace(/\n/g, ""), "base64").toString("utf8"))?.workflows ?? []).map((w) => typeof w === "string" ? { name: w } : w);
5126
- } catch (err) {
5127
- if (!(err instanceof ProviderApiError) || err.status !== 404) throw err;
5128
- try {
5129
- const data = await client.git.getContents(repo, "holocron.config.ts");
5130
- const source = Buffer.from(data.content.replace(/\n/g, ""), "base64").toString("utf8");
5131
- entries = parseWorkflowsFromTs(source);
5132
- orgContext = parseOrgContextFromTs(source);
5133
- } catch {}
5134
- }
5135
- if (entries.length > 0) {
5136
- allowedWorkflows = new Set(entries.map((e) => e.name));
5137
- const overrideEntries = entries.filter((e) => e.with != null).map((e) => [e.name, e.with]);
5138
- if (overrideEntries.length > 0) withOverrides = new Map(overrideEntries);
5139
- }
5140
- } catch {}
5141
- const batch = buildBatch(repo, allowedWorkflows, withOverrides, orgContext);
5005
+ const batch = buildBatch(repo);
5142
5006
  let created = 0;
5143
5007
  let updated = 0;
5144
5008
  let unchanged = 0;