@theholocron/cli 3.20.0 → 3.22.0

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
@@ -3266,6 +3266,20 @@ async function runSetup(input) {
3266
3266
  }
3267
3267
  function normalizeWorkflowWith(raw) {
3268
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
+ }
3269
3283
  const runChromatic = raw["run-chromatic"];
3270
3284
  if (runChromatic !== null && typeof runChromatic === "object" && "projects" in runChromatic) {
3271
3285
  result["run-chromatic"] = true;
@@ -3275,8 +3289,23 @@ async function runSetup(input) {
3275
3289
  }));
3276
3290
  result["chromatic-projects"] = JSON.stringify(projects);
3277
3291
  }
3292
+ for (const [k, v] of Object.entries(result)) if (Array.isArray(v)) result[k] = JSON.stringify(v);
3278
3293
  return result;
3279
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)) {
3305
+ for (const s of storybookProjects) if (typeof s.path === "string" && s.path !== "." && s.path !== "") paths.push(`${s.path}/**`);
3306
+ }
3307
+ return paths;
3308
+ }
3280
3309
  const workflows = config.workflows;
3281
3310
  if (loader.has("source") && workflows && workflows.length > 0) {
3282
3311
  const source = loader.get("source");
@@ -3285,7 +3314,7 @@ async function runSetup(input) {
3285
3314
  const name = typeof entry === "string" ? entry : entry.name;
3286
3315
  const rawWith = typeof entry === "object" ? entry.with : void 0;
3287
3316
  const withOverrides = rawWith ? normalizeWorkflowWith(rawWith) : void 0;
3288
- const additionalPaths = typeof entry === "object" ? entry.paths : void 0;
3317
+ const additionalPaths = (typeof entry === "object" ? entry.paths : void 0) ?? (name === "deploy" && rawWith ? deriveDeployPaths(rawWith) : void 0);
3289
3318
  if (name === "test" && withOverrides) {
3290
3319
  const runUnit = withOverrides["run-unit"];
3291
3320
  const runStorybook = withOverrides["run-storybook"];
@@ -4212,7 +4241,7 @@ var codeql_default = "name: CodeQL\n\non: # yamllint disable-line rule:truthy\n
4212
4241
  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 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";
4213
4242
  //#endregion
4214
4243
  //#region src/templates/workflows/deploy.yml
4215
- var deploy_default = "name: Deploy\n\non: # yamllint disable-line rule:truthy\n workflow_call:\n inputs:\n type:\n description: \"Type of deployment: docs or storybook\"\n required: true\n type: string\n name:\n description: Repo name prefix used to filter the docs site package (<name>-site); omit to run pnpm -C docs build\n required: false\n type: string\n default: \"\"\n build-script:\n description: pnpm script that builds the Storybook static output (storybook type only)\n type: string\n required: false\n default: build:storybook\n output-dir:\n description: Directory where Storybook writes its static output (storybook type only)\n type: string\n required: false\n default: storybook-static\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 docs site\n if: ${{ inputs.type == 'docs' && inputs.name != '' }}\n env:\n SITE_NAME: ${{ inputs.name }}\n run: pnpm --filter @theholocron/\"$SITE_NAME\"-site build\n\n - name: Build docs site\n if: ${{ inputs.type == 'docs' && inputs.name == '' }}\n run: pnpm -C docs build\n\n - name: Build Storybook\n if: ${{ inputs.type == 'storybook' }}\n env:\n BUILD_SCRIPT: ${{ inputs.build-script }}\n run: pnpm run \"$BUILD_SCRIPT\"\n\n - name: Resolve artifact path\n id: artifact\n env:\n DEPLOY_TYPE: ${{ inputs.type }}\n STORYBOOK_OUTPUT_DIR: ${{ inputs.output-dir }}\n run: |\n if [ \"$DEPLOY_TYPE\" = \"docs\" ]; then\n echo \"path=docs/dist\" >> \"$GITHUB_OUTPUT\"\n else\n echo \"path=$STORYBOOK_OUTPUT_DIR\" >> \"$GITHUB_OUTPUT\"\n fi\n\n - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1\n name: Upload pages artifact\n with:\n path: ${{ steps.artifact.outputs.path }}\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";
4244
+ var deploy_default = "name: Deploy\n\non: # yamllint disable-line rule:truthy\n workflow_call:\n inputs:\n type:\n description: \"Type of deployment: docs or storybook\"\n required: true\n type: string\n name:\n description: Repo name prefix used to filter the docs site package (<name>-site); omit to run pnpm -C docs build\n required: false\n type: string\n default: \"\"\n storybook-projects:\n description: >\n JSON array of { \"name\", \"workingDir\", \"outputDir\"? } objects for monorepo multi-storybook\n deploys. Each is built via `pnpm -C <workingDir> build:storybook` and assembled under\n `sandbox/<name>/` alongside docs in a single deployment.\n type: string\n required: false\n default: \"[]\"\n build-script:\n description: pnpm script that builds the Storybook static output (single storybook, type:storybook only)\n type: string\n required: false\n default: build:storybook\n output-dir:\n description: Directory where Storybook writes its static output (single storybook, type:storybook only)\n type: string\n required: false\n default: storybook-static\n\njobs:\n deploy:\n name: Deploy\n runs-on: ubuntu-latest\n permissions:\n contents: read\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/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 docs site\n if: ${{ inputs.type == 'docs' && inputs.name != '' }}\n env:\n SITE_NAME: ${{ inputs.name }}\n run: pnpm --filter @theholocron/\"$SITE_NAME\"-site build\n\n - name: Build docs site\n if: ${{ inputs.type == 'docs' && inputs.name == '' }}\n run: pnpm -C docs build\n\n - name: Build Storybook projects\n if: ${{ inputs.storybook-projects != '[]' }}\n env:\n PROJECTS: ${{ inputs.storybook-projects }}\n run: |\n echo \"$PROJECTS\" | jq -c '.[]' | while IFS= read -r project; do\n workingDir=$(echo \"$project\" | jq -r '.workingDir')\n pnpm -C \"$workingDir\" build:storybook\n done\n\n - name: Build Storybook\n if: ${{ inputs.type == 'storybook' && inputs.storybook-projects == '[]' }}\n env:\n BUILD_SCRIPT: ${{ inputs.build-script }}\n run: pnpm run \"$BUILD_SCRIPT\"\n\n - name: Assemble site\n env:\n DEPLOY_TYPE: ${{ inputs.type }}\n PROJECTS: ${{ inputs.storybook-projects }}\n STORYBOOK_OUTPUT_DIR: ${{ inputs.output-dir }}\n run: |\n mkdir -p _site\n if [ \"$DEPLOY_TYPE\" = \"docs\" ]; then\n cp -r docs/dist/. _site/\n fi\n if [ \"$PROJECTS\" != \"[]\" ]; then\n echo \"$PROJECTS\" | jq -c '.[]' | while IFS= read -r project; do\n name=$(echo \"$project\" | jq -r '.name')\n workingDir=$(echo \"$project\" | jq -r '.workingDir')\n outputDir=$(echo \"$project\" | jq -r '.outputDir // \"storybook-static\"')\n mkdir -p \"_site/sandbox/${name}\"\n cp -r \"${workingDir}/${outputDir}/.\" \"_site/sandbox/${name}/\"\n done\n elif [ \"$DEPLOY_TYPE\" = \"storybook\" ]; then\n mkdir -p _site/sandbox\n cp -r \"${STORYBOOK_OUTPUT_DIR}/.\" _site/sandbox/\n fi\n\n - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1\n name: Upload pages artifact\n with:\n path: _site\n\n - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5\n id: deployment\n name: Deploy to GitHub Pages\n";
4216
4245
  //#endregion
4217
4246
  //#region src/templates/workflows/greetings.yml
4218
4247
  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 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";