@theholocron/cli 3.4.0 → 3.5.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
@@ -2484,6 +2484,9 @@ var codeql_default$1 = "name: CodeQL\n\non: # yamllint disable-line rule:truthy\
2484
2484
  //#region src/commands/workflows/dependencies.yml
2485
2485
  var dependencies_default$1 = "name: Dependencies\n\non: # yamllint disable-line rule:truthy\n pull_request:\n\npermissions:\n contents: write\n pull-requests: write\n\njobs:\n dependencies:\n uses: theholocron/.github/.github/workflows/dependencies.yml@main\n secrets: inherit\n";
2486
2486
  //#endregion
2487
+ //#region src/commands/workflows/deploy-docs.yml
2488
+ var deploy_docs_default$1 = "name: Deploy Docs\n\non: # yamllint disable-line rule:truthy\n push:\n branches: [main]\n paths:\n - docs/**\n workflow_dispatch:\n\nconcurrency:\n group: pages\n cancel-in-progress: false\n\npermissions:\n contents: read\n pages: write\n id-token: write\n\njobs:\n deploy-docs:\n name: Deploy Docs\n uses: theholocron/.github/.github/workflows/deploy-docs.yml@main\n secrets: inherit\n";
2489
+ //#endregion
2487
2490
  //#region src/commands/workflows/greetings.yml
2488
2491
  var greetings_default$1 = "name: Greetings\n\non: # yamllint disable-line rule:truthy\n pull_request:\n issues:\n\npermissions:\n issues: write\n pull-requests: write\n\njobs:\n greetings:\n uses: theholocron/.github/.github/workflows/greetings.yml@main\n secrets: inherit\n";
2489
2492
  //#endregion
@@ -2531,7 +2534,8 @@ const WORKFLOW_TEMPLATES = {
2531
2534
  dependencies: dependencies_default$1,
2532
2535
  bookkeeping: bookkeeping_default$1,
2533
2536
  audit: audit_default$1,
2534
- "sync-github": sync_github_default$1
2537
+ "sync-github": sync_github_default$1,
2538
+ "deploy-docs": deploy_docs_default$1
2535
2539
  };
2536
2540
  const KNOWN_WORKFLOWS = new Set(Object.keys(WORKFLOW_TEMPLATES));
2537
2541
  /**
@@ -2560,13 +2564,19 @@ const WORKFLOW_CHECK_CONTEXTS = {
2560
2564
  * If neither pattern matches the template, a warning is emitted and the
2561
2565
  * base template is returned unchanged.
2562
2566
  */
2563
- function generateThinCallerContent(name, withOverrides) {
2567
+ function generateThinCallerContent(name, withOverrides, additionalPaths) {
2564
2568
  const base = WORKFLOW_TEMPLATES[name];
2565
2569
  if (!base) return "";
2566
- if (!withOverrides || Object.keys(withOverrides).length === 0) return base;
2567
2570
  const fmt = (k, v) => ` ${k}: ${v === true ? "true" : v === false ? "false" : String(v)}`;
2571
+ let result = base;
2572
+ if (additionalPaths && additionalPaths.length > 0) {
2573
+ const pathsBlockRe = /( {4}paths:\n)((?:[ ]{6}- [^\n]+\n)+)/;
2574
+ const newEntries = additionalPaths.map((p) => ` - ${p}\n`).join("");
2575
+ result = result.replace(pathsBlockRe, (_, header, existing) => header + existing + newEntries);
2576
+ }
2577
+ if (!withOverrides || Object.keys(withOverrides).length === 0) return result;
2568
2578
  const withBlockRe = /( {4}with:\n)((?:[ ]{6}[^\n]+\n)*)/;
2569
- const existingMatch = base.match(withBlockRe);
2579
+ const existingMatch = result.match(withBlockRe);
2570
2580
  if (existingMatch) {
2571
2581
  const existingEntries = new Map(existingMatch[2].split("\n").filter(Boolean).map((line) => {
2572
2582
  const m = line.match(/^ {6}([^:]+):\s*(.*)/);
@@ -2574,12 +2584,12 @@ function generateThinCallerContent(name, withOverrides) {
2574
2584
  }).filter((e) => e !== null));
2575
2585
  for (const [k, v] of Object.entries(withOverrides)) existingEntries.set(k, v === true ? "true" : v === false ? "false" : String(v));
2576
2586
  const merged = [...existingEntries.entries()].map(([k, v]) => ` ${k}: ${v}`).join("\n");
2577
- return base.replace(withBlockRe, ` with:\n${merged}\n`);
2587
+ return result.replace(withBlockRe, ` with:\n${merged}\n`);
2578
2588
  }
2579
2589
  const withBlock = Object.entries(withOverrides).map(([k, v]) => fmt(k, v)).join("\n");
2580
- const result = base.replace(/ {4}secrets: inherit\n$/, ` with:\n${withBlock}\n secrets: inherit\n`);
2581
- if (result === base) console.warn(`[generateThinCallerContent] could not inject with: overrides into "${name}" template`);
2582
- return result;
2590
+ const injected = result.replace(/ {4}secrets: inherit\n$/, ` with:\n${withBlock}\n secrets: inherit\n`);
2591
+ if (injected === result) console.warn(`[generateThinCallerContent] could not inject with: overrides into "${name}" template`);
2592
+ return injected;
2583
2593
  }
2584
2594
  //#endregion
2585
2595
  //#region src/commands/setup.ts
@@ -3037,6 +3047,7 @@ async function runSetup(input) {
3037
3047
  for (const entry of workflows) {
3038
3048
  const name = typeof entry === "string" ? entry : entry.name;
3039
3049
  const withOverrides = typeof entry === "object" ? entry.with : void 0;
3050
+ const additionalPaths = typeof entry === "object" ? entry.paths : void 0;
3040
3051
  if (!KNOWN_WORKFLOWS.has(name)) {
3041
3052
  steps.push({
3042
3053
  capability: "source",
@@ -3048,7 +3059,7 @@ async function runSetup(input) {
3048
3059
  continue;
3049
3060
  }
3050
3061
  steps.push(await runStep("source", `write workflow ${name}`, dryRun, async () => {
3051
- await source.writeWorkflowFile(`${name}.yml`, workflowHeader() + generateThinCallerContent(name, withOverrides));
3062
+ await source.writeWorkflowFile(`${name}.yml`, workflowHeader() + generateThinCallerContent(name, withOverrides, additionalPaths));
3052
3063
  }));
3053
3064
  print(formatStep(steps[steps.length - 1]));
3054
3065
  }
@@ -3892,6 +3903,9 @@ var codeql_default = "name: CodeQL\n\non: # yamllint disable-line rule:truthy\n
3892
3903
  //#region src/templates/workflows/dependencies.yml
3893
3904
  var dependencies_default = "name: Dependencies\n\non: # yamllint disable-line rule:truthy\n workflow_call:\n secrets:\n merge-token:\n description: >\n Optional privileged token for auto-merge. Falls back to GITHUB_TOKEN.\n Required when branch protection enforces required reviews — GITHUB_TOKEN\n cannot approve its own PRs.\n required: false\n\njobs:\n dependabot:\n name: Update the dependencies\n permissions:\n contents: write\n pull-requests: write\n runs-on: ubuntu-latest\n timeout-minutes: 5\n concurrency:\n group: dependencies-${{ github.event.pull_request.number }}\n cancel-in-progress: true\n if: github.event.pull_request.user.login == 'dependabot[bot]'\n steps:\n - uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0\n name: Fetch Dependabot metadata\n id: metadata\n\n - run: gh pr merge --auto --squash \"$PR_URL\"\n # --squash is intentional: repo protection sets allow_merge_commit: false,\n # so --merge would fail on any repo using the standard preset.\n name: Enable auto-merge for Dependabot PRs\n if: steps.metadata.outputs.update-type == 'version-update:semver-patch'\n env:\n PR_URL: ${{ github.event.pull_request.html_url }}\n GH_TOKEN: ${{ secrets.merge-token || github.token }}\n";
3894
3905
  //#endregion
3906
+ //#region src/templates/workflows/deploy-docs.yml
3907
+ var deploy_docs_default = "name: Deploy Docs\n\non: # yamllint disable-line rule:truthy\n workflow_call:\n inputs:\n name:\n description: Repo name prefix used to derive package names (<name>-docs, <name>-site)\n required: true\n type: string\n use-turbo:\n description: Build content packages with pnpm turbo build (default true)\n required: false\n type: boolean\n default: true\n\njobs:\n build:\n name: Build\n runs-on: ubuntu-latest\n permissions:\n contents: read\n steps:\n - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0\n name: Checkout repository\n\n - uses: theholocron/.github/.github/actions/setup@main\n name: Setup\n\n - name: Build content packages\n if: ${{ inputs.use-turbo }}\n env:\n DOCS_NAME: ${{ inputs.name }}\n run: pnpm turbo build --filter=@theholocron/\"$DOCS_NAME\"-docs\n\n - name: Build content packages\n if: ${{ !inputs.use-turbo }}\n env:\n DOCS_NAME: ${{ inputs.name }}\n run: pnpm --filter @theholocron/\"$DOCS_NAME\"-docs build\n\n - name: Build docs site\n env:\n DOCS_NAME: ${{ inputs.name }}\n run: pnpm --filter @theholocron/\"$DOCS_NAME\"-site build\n\n - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1\n name: Upload pages artifact\n with:\n path: docs/dist\n\n deploy:\n name: Deploy\n needs: build\n runs-on: ubuntu-latest\n permissions:\n pages: write\n id-token: write\n environment:\n name: github-pages\n url: ${{ steps.deployment.outputs.page_url }}\n steps:\n - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5\n id: deployment\n name: Deploy to GitHub Pages\n";
3908
+ //#endregion
3895
3909
  //#region src/templates/workflows/greetings.yml
3896
3910
  var greetings_default = "name: Greetings\n\non: # yamllint disable-line rule:truthy\n workflow_call:\n\njobs:\n greeting:\n name: Greet first-time contributors\n permissions:\n issues: write\n pull-requests: write\n runs-on: ubuntu-latest\n timeout-minutes: 5\n # Group by the issue/PR number so duplicate events don't race each other.\n concurrency:\n group: greetings-${{ github.event.issue.number || github.event.pull_request.number }}\n cancel-in-progress: false\n steps:\n - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0\n name: Greet on first contribution\n with:\n script: |\n // Only greet on the initial open — ignore synchronize, reopened, etc.\n if (context.payload.action !== 'opened') return;\n\n const actor = context.actor;\n const { owner, repo } = context.repo;\n\n // Payload inspection is more reliable than context.eventName for detecting\n // whether this is an issue vs. PR event — works regardless of how GitHub\n // propagates event names through workflow_call chains.\n const isIssue = !!context.payload.issue && !context.payload.pull_request;\n // listForRepo returns both issues and PRs (GitHub treats PRs as issues),\n // sorted newest-first. Filter by type to track first-issue and first-PR\n // independently, and avoid search-index eventual-consistency lag.\n const { data: recent } = await github.rest.issues.listForRepo({\n owner, repo,\n creator: actor,\n state: 'all',\n per_page: 100\n });\n\n const sameType = recent.filter(item =>\n isIssue ? !item.pull_request : !!item.pull_request\n );\n\n if (sameType.length !== 1) return;\n const body = isIssue\n ? `Hey @${actor}!\\n\\nWe really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we are a limited number of volunteers, so it is possible that this will not be addressed as swiftly.\\n\\nYour patience is much appreciated and we will get back to you as quickly as possible.`\n : `Hey @${actor}!\\n\\nWe really appreciate you taking the time to help out with this PR. The collaborators on this project attempt to help as many people as possible, but we are a limited number of volunteers, so it is possible that this will not be addressed as swiftly.\\n\\nYour patience is much appreciated and we will get back to you as quickly as possible.`;\n\n await github.rest.issues.createComment({\n owner,\n repo,\n issue_number: context.issue.number,\n body\n });\n";
3897
3911
  //#endregion
@@ -3935,6 +3949,7 @@ const REUSABLE_WORKFLOWS = {
3935
3949
  bookkeeping: bookkeeping_default,
3936
3950
  codeql: codeql_default,
3937
3951
  dependencies: dependencies_default,
3952
+ "deploy-docs": deploy_docs_default,
3938
3953
  greetings: greetings_default,
3939
3954
  lint: lint_default,
3940
3955
  release: release_default,