@theholocron/astromech 5.0.0-alpha.255 → 5.0.0-alpha.256

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,4 @@
1
- import { n as TaskEntry, r as TasksConfig, t as TaskConfigItem } from "../schema.type-DThrbvO2.mjs";
1
+ import { n as TaskEntry, r as TasksConfig, t as TaskConfigItem } from "../schema.type-C-3fZESa.mjs";
2
2
  import { Loaded } from "@theholocron/datapad";
3
3
  /**
4
4
  * The `tasks` config shape — the single manifest of what a repo runs.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as TasksConfig } from "./schema.type-DThrbvO2.mjs";
1
+ import { r as TasksConfig } from "./schema.type-C-3fZESa.mjs";
2
2
  import { ListWorkspacePackagesOptions, WorkspacePackageEntry } from "@theholocron/pkg-utils";
3
3
  interface WorkspacePackage$1 {
4
4
  slug: string;
@@ -211,8 +211,13 @@ interface RunLogger {
211
211
  debug(obj: Record<string, unknown>, msg?: string): void;
212
212
  warn(obj: Record<string, unknown>, msg?: string): void;
213
213
  }
214
+ /**
215
+ * Runs `cmd` and reports its exit code. `opts.env` is added to the child's
216
+ * environment (on top of the parent's), e.g. `TURBO_SCM_BASE` for `--affected`.
217
+ */
214
218
  type ExecFn = (cmd: string, args: string[], opts: {
215
219
  cwd: string;
220
+ env?: Record<string, string>;
216
221
  }) => {
217
222
  exitCode: number;
218
223
  };
@@ -250,6 +255,12 @@ interface RunTaskInput extends RunDeps {
250
255
  required?: boolean;
251
256
  /** `turbo --filter=<pkg>` passthrough (monorepo). Ignored when the repo has no `turbo.json`. */
252
257
  filter?: string;
258
+ /** `turbo --affected`: only the packages changed since `base`, plus their dependents. Ignored without a `turbo.json`. */
259
+ affected?: boolean;
260
+ /** Git ref `affected` compares against; falls back to `TURBO_SCM_BASE`. */
261
+ base?: string;
262
+ /** Environment `affected` reads (`GITHUB_EVENT_NAME`, `GITHUB_REF_NAME`, `TURBO_SCM_BASE`). Defaults to empty. */
263
+ env?: Record<string, string | undefined>;
253
264
  /** The task entry's `jobs` switches: a sub-job set to `false` (by key or alias) is not run. */
254
265
  jobSwitches?: Record<string, boolean>;
255
266
  }
@@ -265,6 +276,12 @@ interface CiOptions {
265
276
  dryRun?: boolean;
266
277
  /** `turbo --filter=<pkg>` passthrough (monorepo). */
267
278
  filter?: string;
279
+ /** `turbo --affected`: only the packages changed since `base`. */
280
+ affected?: boolean;
281
+ /** Git ref `affected` compares against. */
282
+ base?: string;
283
+ /** Environment `affected` reads. */
284
+ env?: Record<string, string | undefined>;
268
285
  /** `"required"` (default) or `"all"` (every `ci: true` task). */
269
286
  scope?: "required" | "all";
270
287
  }
@@ -415,6 +432,12 @@ interface GroupOptions {
415
432
  dryRun?: boolean;
416
433
  /** `turbo --filter=<pkg>` passthrough (monorepo). */
417
434
  filter?: string;
435
+ /** `turbo --affected`: only the packages changed since `base`. */
436
+ affected?: boolean;
437
+ /** Git ref `affected` compares against. */
438
+ base?: string;
439
+ /** Environment `affected` reads. */
440
+ env?: Record<string, string | undefined>;
418
441
  }
419
442
  interface GroupJobReport {
420
443
  task: string;
@@ -460,6 +483,8 @@ interface AstromechOptions {
460
483
  readFile?: (path: string) => string;
461
484
  fileExists?: (path: string) => boolean;
462
485
  listDir?: (path: string) => string[];
486
+ /** Injectable environment for `--affected` (tests). Defaults to `process.env`. */
487
+ env?: Record<string, string | undefined>;
463
488
  /** Injectable binary lookup (tests). Default checks `node_modules/.bin` then `PATH`. */
464
489
  lookPath?: (cwd: string, bin: string) => string | null;
465
490
  }
@@ -478,6 +503,10 @@ interface RunOptions {
478
503
  required?: boolean;
479
504
  /** `turbo --filter=<pkg>` passthrough (monorepo). */
480
505
  filter?: string;
506
+ /** `turbo --affected`: only the packages changed since `base`. */
507
+ affected?: boolean;
508
+ /** Git ref `affected` compares against. */
509
+ base?: string;
481
510
  }
482
511
  interface Astromech {
483
512
  /**
package/dist/index.mjs CHANGED
@@ -263,13 +263,13 @@ function codecovConfig(repoRoot, existing) {
263
263
  // src/templates/reusable/actions/auto-commit.yml
264
264
  var auto_commit_default = "name: Auto Commit\ndescription: >\n Commit and push any file changes using stefanzweifel/git-auto-commit-action.\n If a branch name is provided and differs from the current branch, a new branch\n is created automatically.\n\ninputs:\n token:\n description: >\n GitHub token with push access to the target branch. Used to authenticate\n the git remote so the commit can be pushed.\n required: true\n branch:\n description: >\n Branch to commit to. Leave empty to commit to the current branch (useful\n in PR contexts). Provide an explicit name (e.g. chore/auto-sync-<sha>) to push\n to a separate branch.\n required: false\n default: \"\"\n commit-message:\n description: Commit message.\n required: true\n commit-options:\n description: >\n Additional options passed to git commit (e.g. --no-verify).\n required: false\n default: \"\"\n commit-user-name:\n description: Git user.name for the commit.\n required: false\n default: \"github-actions[bot]\"\n commit-user-email:\n description: Git user.email for the commit.\n required: false\n default: \"41898282+github-actions[bot]@users.noreply.github.com\"\n commit-author:\n description: >\n Git author string in \"Name <email>\" format.\n required: false\n default: \"github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>\"\n\noutputs:\n changes-detected:\n description: \"'true' if any files were committed, 'false' otherwise.\"\n value: ${{ steps.commit.outputs.changes_detected }}\n\nruns:\n using: composite\n steps:\n - name: Configure git remote with token\n shell: bash\n run: |\n REMOTE_URL=$(git remote get-url origin)\n AUTHED_URL=$(echo \"$REMOTE_URL\" | sed \"s|https://|https://x-access-token:${TOKEN}@|\")\n git remote set-url origin \"$AUTHED_URL\"\n env:\n TOKEN: ${{ inputs.token }}\n\n - name: Reset branch to current HEAD\n if: ${{ inputs.branch != '' }}\n shell: bash\n run: git checkout -B \"$BRANCH\"\n env:\n BRANCH: ${{ inputs.branch }}\n\n - name: Build signed commit message\n id: msg\n shell: bash\n run: |\n TRAILER=\"Signed-off-by: ${COMMIT_USER_NAME} <${COMMIT_USER_EMAIL}>\"\n if echo \"$COMMIT_MESSAGE\" | grep -qF \"$TRAILER\"; then\n FINAL=\"$COMMIT_MESSAGE\"\n else\n FINAL=\"${COMMIT_MESSAGE}\"$'\\n\\n'\"${TRAILER}\"\n fi\n {\n echo \"value<<EOF_TRAILER\"\n printf '%s' \"$FINAL\"\n echo \"\"\n echo \"EOF_TRAILER\"\n } >> \"$GITHUB_OUTPUT\"\n env:\n COMMIT_MESSAGE: ${{ inputs.commit-message }}\n COMMIT_USER_NAME: ${{ inputs.commit-user-name }}\n COMMIT_USER_EMAIL: ${{ inputs.commit-user-email }}\n\n - uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0\n id: commit\n with:\n branch: ${{ inputs.branch }}\n commit_message: ${{ steps.msg.outputs.value }}\n commit_options: ${{ inputs.commit-options }}\n commit_user_name: ${{ inputs.commit-user-name }}\n commit_user_email: ${{ inputs.commit-user-email }}\n commit_author: ${{ inputs.commit-author }}\n";
265
265
  // src/templates/reusable/actions/holocron.yml
266
- var holocron_default = "name: Holocron\ndescription: >\n Run the Holocron CLI — `holocron run <task> [job]` by default, or any other\n subcommand via `command:` (`repo sync`, `sync github`, …). Resolves\n `@theholocron/cli` from `node_modules` (published tarball) or builds it from\n source when it resolves to an unbuilt workspace checkout (the holocron repo\n itself). Requires dependencies to be installed already (run the setup action\n first).\n\ninputs:\n command:\n description: >\n Holocron subcommand. Default `run` — then `task` (and optional `job`)\n name the manifest task. Set to `repo sync` / `sync github` / … to run that\n subcommand directly; `args` becomes everything after it.\n required: false\n default: run\n task:\n description: >\n Manifest task to run when command is run — typecheck, test, build, audit.\n required: false\n default: \"\"\n job:\n description: Optional sub-job within the task (e.g. knip, performance for audit).\n required: false\n default: \"\"\n args:\n description: >\n For `command: run`, extra arguments forwarded to the tool after `--`.\n For any other command, the arguments passed straight to it.\n required: false\n default: \"\"\n\noutputs:\n log-file:\n description: >\n Path to a file holding the full captured stdout+stderr of this\n invocation — the same text the live Actions log shows, saved for a\n caller that wants to ship it elsewhere (e.g. Sentinel's dispatched\n checks shipping it to Axiom, holocron#769/#794).\n value: ${{ steps.run.outputs.log-file }}\n\nruns:\n using: composite\n\n steps:\n - name: Build the workspace when the CLI resolves to an unbuilt checkout\n shell: bash\n # The holocron repo carries @theholocron/cli as `workspace:*`; its bin\n # (dist/cli.mjs) does not exist on a fresh checkout. `pnpm build` is a\n # turbo run — cached and cheap once warm. A no-op everywhere else, where\n # the published tarball already ships dist/.\n #\n # pnpm creates every workspace package's node_modules/.bin/holocron shim\n # once, during the setup action's earlier `pnpm install` — before this\n # build has run, so every one of them is silently skipped (\"Failed to\n # create bin ... ENOENT\"), not just @theholocron/cli's own. That's a\n # one-time decision: a later build doesn't retroactively fix a shim that\n # was never created. Re-running `pnpm install` here (fast — the lockfile\n # hasn't changed, so it only re-links `.bin`) is what actually fixes it,\n # confirmed against a real cold install: `holocron` stays unresolvable\n # from inside any package until this second install runs.\n run: |\n if [ ! -f node_modules/@theholocron/cli/dist/cli.mjs ]; then\n echo \"→ @theholocron/cli dist/ missing — building the workspace from source\" >&2\n pnpm build\n echo \"→ re-linking node_modules/.bin — pnpm skipped it pre-build\" >&2\n pnpm install --frozen-lockfile\n fi\n\n - name: holocron ${{ inputs.command }} ${{ inputs.task }}\n id: run\n shell: bash\n env:\n HOLOCRON_COMMAND: ${{ inputs.command }}\n HOLOCRON_TASK: ${{ inputs.task }}\n HOLOCRON_JOB: ${{ inputs.job }}\n HOLOCRON_ARGS: ${{ inputs.args }}\n run: |\n if [ \"$HOLOCRON_COMMAND\" = \"run\" ]; then\n set -- run \"$HOLOCRON_TASK\"\n [ -n \"$HOLOCRON_JOB\" ] && set -- \"$@\" \"$HOLOCRON_JOB\"\n # shellcheck disable=SC2086\n [ -n \"$HOLOCRON_ARGS\" ] && set -- \"$@\" -- $HOLOCRON_ARGS\n else\n # `command` may be a multi-word path (`repo sync`, `deploy on-release`):\n # word-split it so each token is its own argument.\n # shellcheck disable=SC2086\n set -- $HOLOCRON_COMMAND $HOLOCRON_ARGS\n fi\n # Invoke the built entry directly. `pnpm exec holocron` relies on a\n # node_modules/.bin/holocron shim that pnpm does not create for a\n # workspace package whose dist/ was absent at install time (the holocron\n # repo itself). Resolving the package's main export gives dist/index.mjs;\n # the bin sits next to it as dist/cli.mjs. This is `require.resolve` from\n # node_modules — it works in the holocron monorepo AND in every consumer\n # repo (theholocron/holocron#655), unlike a hard-coded `cli/cli/…`.\n cli=\"$(dirname \"$(node -e 'process.stdout.write(require.resolve(\"@theholocron/cli\"))')\")/cli.mjs\"\n if [ ! -f \"$cli\" ]; then\n echo \"::error::@theholocron/cli entry not found at $cli — is the workspace built?\" >&2\n exit 1\n fi\n echo \"→ $cli $*\" >&2\n # `tee` keeps the live Actions log streaming exactly as before while\n # also capturing it to a file callers can ship elsewhere (log-file\n # output, above). PIPESTATUS[0] -- not $? -- is `node`'s own exit\n # code; $? after a pipe is tee's, which succeeds even when node fails.\n log_file=\"${RUNNER_TEMP}/holocron-output.log\"\n node \"$cli\" \"$@\" 2>&1 | tee \"$log_file\"\n exit_code=${PIPESTATUS[0]}\n echo \"log-file=$log_file\" >> \"$GITHUB_OUTPUT\"\n exit \"$exit_code\"\n";
266
+ var holocron_default = "name: Holocron\ndescription: >\n Run the Holocron CLI — `holocron run <task> [job]` by default, or any other\n subcommand via `command:` (`repo sync`, `sync github`, …). Resolves\n `@theholocron/cli` from `node_modules` (published tarball) or builds it from\n source when it resolves to an unbuilt workspace checkout (the holocron repo\n itself). Requires dependencies to be installed already (run the setup action\n first).\n\ninputs:\n command:\n description: >\n Holocron subcommand. Default `run` — then `task` (and optional `job`)\n name the manifest task. Set to `repo sync` / `sync github` / … to run that\n subcommand directly; `args` becomes everything after it.\n required: false\n default: run\n task:\n description: >\n Manifest task to run when command is run — typecheck, test, build, audit.\n required: false\n default: \"\"\n job:\n description: Optional sub-job within the task (e.g. knip, performance for audit).\n required: false\n default: \"\"\n affected:\n description: >\n For `command: run`, only run the packages changed since the PR base (or the\n merge-base with the default branch), plus their dependents: `--affected`.\n Needs a checkout with enough history to reach the base (`fetch-depth: 0`);\n without it holocron logs a warning and runs everything.\n required: false\n default: \"false\"\n args:\n description: >\n For `command: run`, extra arguments forwarded to the tool after `--`.\n For any other command, the arguments passed straight to it.\n required: false\n default: \"\"\n\noutputs:\n log-file:\n description: >\n Path to a file holding the full captured stdout+stderr of this\n invocation — the same text the live Actions log shows, saved for a\n caller that wants to ship it elsewhere (e.g. Sentinel's dispatched\n checks shipping it to Axiom, holocron#769/#794).\n value: ${{ steps.run.outputs.log-file }}\n\nruns:\n using: composite\n\n steps:\n - name: Build the workspace when the CLI resolves to an unbuilt checkout\n shell: bash\n # The holocron repo carries @theholocron/cli as `workspace:*`; its bin\n # (dist/cli.mjs) does not exist on a fresh checkout. `pnpm build` is a\n # turbo run — cached and cheap once warm. A no-op everywhere else, where\n # the published tarball already ships dist/.\n #\n # pnpm creates every workspace package's node_modules/.bin/holocron shim\n # once, during the setup action's earlier `pnpm install` — before this\n # build has run, so every one of them is silently skipped (\"Failed to\n # create bin ... ENOENT\"), not just @theholocron/cli's own. That's a\n # one-time decision: a later build doesn't retroactively fix a shim that\n # was never created. Re-running `pnpm install` here (fast — the lockfile\n # hasn't changed, so it only re-links `.bin`) is what actually fixes it,\n # confirmed against a real cold install: `holocron` stays unresolvable\n # from inside any package until this second install runs.\n run: |\n if [ ! -f node_modules/@theholocron/cli/dist/cli.mjs ]; then\n echo \"→ @theholocron/cli dist/ missing — building the workspace from source\" >&2\n pnpm build\n echo \"→ re-linking node_modules/.bin — pnpm skipped it pre-build\" >&2\n pnpm install --frozen-lockfile\n fi\n\n - name: holocron ${{ inputs.command }} ${{ inputs.task }}\n id: run\n shell: bash\n env:\n HOLOCRON_COMMAND: ${{ inputs.command }}\n HOLOCRON_TASK: ${{ inputs.task }}\n HOLOCRON_JOB: ${{ inputs.job }}\n HOLOCRON_ARGS: ${{ inputs.args }}\n HOLOCRON_AFFECTED: ${{ inputs.affected }}\n HOLOCRON_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}\n HOLOCRON_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}\n run: |\n if [ \"$HOLOCRON_COMMAND\" = \"run\" ]; then\n set -- run \"$HOLOCRON_TASK\"\n [ -n \"$HOLOCRON_JOB\" ] && set -- \"$@\" \"$HOLOCRON_JOB\"\n if [ \"$HOLOCRON_AFFECTED\" = \"true\" ]; then\n # A pull request compares against its base commit. Any other trigger\n # (a push to a PR branch) compares against where the branch left the\n # default branch. If neither resolves, no --base is passed and holocron\n # runs everything.\n base=\"$HOLOCRON_PR_BASE_SHA\"\n if [ -z \"$base\" ] && [ -n \"$HOLOCRON_DEFAULT_BRANCH\" ]; then\n git fetch --no-tags --quiet origin \"$HOLOCRON_DEFAULT_BRANCH\" || true\n base=\"$(git merge-base HEAD \"origin/$HOLOCRON_DEFAULT_BRANCH\" 2>/dev/null || true)\"\n fi\n set -- \"$@\" --affected\n [ -n \"$base\" ] && set -- \"$@\" --base \"$base\"\n fi\n # shellcheck disable=SC2086\n [ -n \"$HOLOCRON_ARGS\" ] && set -- \"$@\" -- $HOLOCRON_ARGS\n else\n # `command` may be a multi-word path (`repo sync`, `deploy on-release`):\n # word-split it so each token is its own argument.\n # shellcheck disable=SC2086\n set -- $HOLOCRON_COMMAND $HOLOCRON_ARGS\n fi\n # Invoke the built entry directly. `pnpm exec holocron` relies on a\n # node_modules/.bin/holocron shim that pnpm does not create for a\n # workspace package whose dist/ was absent at install time (the holocron\n # repo itself). Resolving the package's main export gives dist/index.mjs;\n # the bin sits next to it as dist/cli.mjs. This is `require.resolve` from\n # node_modules — it works in the holocron monorepo AND in every consumer\n # repo (theholocron/holocron#655), unlike a hard-coded `cli/cli/…`.\n cli=\"$(dirname \"$(node -e 'process.stdout.write(require.resolve(\"@theholocron/cli\"))')\")/cli.mjs\"\n if [ ! -f \"$cli\" ]; then\n echo \"::error::@theholocron/cli entry not found at $cli — is the workspace built?\" >&2\n exit 1\n fi\n echo \"→ $cli $*\" >&2\n # `tee` keeps the live Actions log streaming exactly as before while\n # also capturing it to a file callers can ship elsewhere (log-file\n # output, above). PIPESTATUS[0] -- not $? -- is `node`'s own exit\n # code; $? after a pipe is tee's, which succeeds even when node fails.\n log_file=\"${RUNNER_TEMP}/holocron-output.log\"\n node \"$cli\" \"$@\" 2>&1 | tee \"$log_file\"\n exit_code=${PIPESTATUS[0]}\n echo \"log-file=$log_file\" >> \"$GITHUB_OUTPUT\"\n exit \"$exit_code\"\n";
267
267
  // src/templates/reusable/actions/install.yml
268
268
  var install_default = "name: Install dependencies\ndescription: Install project dependencies with pnpm frozen lockfile.\n\nruns:\n using: composite\n\n steps:\n - name: Install dependencies\n if: ${{ hashFiles('pnpm-lock.yaml') != '' }}\n shell: bash\n run: pnpm install --frozen-lockfile\n";
269
269
  // src/templates/reusable/actions/notify.yml
270
270
  var notify_default = "name: Notify\ndescription: >\n Post a message to a chat channel through an incoming webhook. The request\n body is Discord-compatible (`content`, `username`, `allowed_mentions`), so\n the webhook must accept that shape. Does nothing (and never fails the\n calling job) when no webhook is provided, so repos that haven't set one up\n are unaffected. Set `strict` for a check whose only purpose is to prove the\n notification works: it then fails when the webhook is missing or rejects the post.\n\ninputs:\n webhook:\n description: >\n Incoming webhook URL for the target channel.\n A webhook posts to exactly one channel, so pass the secret for the\n channel this message belongs in (for example\n `secrets.HOLOCRON_NOTIFY_WEBHOOK_ALERTS`). Empty = skip.\n required: false\n default: \"\"\n message:\n description: Message text. Truncated to 2000 characters.\n required: true\n mention:\n description: >\n Optional role id (digits only) to ping. Only that one role can\n be mentioned; anything else in the message never pings.\n required: false\n default: \"\"\n username:\n description: Display name for the post.\n required: false\n default: \"Holocron\"\n strict:\n description: >\n \"true\" fails the step when no webhook is set or the post is rejected.\n Off by default: a notification problem must never fail the job it reports on.\n required: false\n default: \"false\"\n\nruns:\n using: composite\n steps:\n - name: Post the notification\n shell: bash\n run: |\n if [ -z \"$WEBHOOK\" ]; then\n if [ \"$STRICT\" = \"true\" ]; then\n echo \"::error::No notification webhook set.\"\n exit 1\n fi\n echo \"::notice::No notification webhook set — skipping notification.\"\n exit 0\n fi\n echo \"::add-mask::$WEBHOOK\"\n # allowed_mentions.parse = [] so message text can never ping @everyone\n # or a role; only the explicit `mention` role id is allowed through. The\n # body is built with jq so quotes/newlines in the message can't break the JSON.\n content=\"$MESSAGE\"\n roles='[]'\n # A mention that is not a role id is dropped, which is right for a real\n # notification but would let a check pass without ever pinging anyone.\n if [ \"$STRICT\" = \"true\" ] && [ -n \"$MENTION\" ] && ! [[ \"$MENTION\" =~ ^[0-9]+$ ]]; then\n echo \"::error::The mention is not a role id (digits only).\"\n exit 1\n fi\n if [[ \"$MENTION\" =~ ^[0-9]+$ ]]; then\n content=\"<@&$MENTION> $MESSAGE\"\n roles=$(jq -cn --arg r \"$MENTION\" '[$r]')\n fi\n body=$(jq -n --arg content \"${content:0:2000}\" --arg username \"$USERNAME\" --argjson roles \"$roles\" \\\n '{content: $content, username: $username, allowed_mentions: {parse: [], roles: $roles}}')\n status=$(curl -sS -o /dev/null -w '%{http_code}' --max-time 15 \\\n -H 'Content-Type: application/json' -d \"$body\" \"$WEBHOOK\" || true)\n case \"${status:-000}\" in\n 2??) echo \"Notification posted.\" ;;\n *)\n if [ \"$STRICT\" = \"true\" ]; then\n echo \"::error::Notification failed (HTTP ${status:-000}).\"\n exit 1\n fi\n echo \"::warning::Notification failed (HTTP ${status:-000}).\"\n ;;\n esac\n env:\n WEBHOOK: ${{ inputs.webhook }}\n MESSAGE: ${{ inputs.message }}\n MENTION: ${{ inputs.mention }}\n USERNAME: ${{ inputs.username }}\n STRICT: ${{ inputs.strict }}\n";
271
271
  // src/templates/reusable/actions/setup.yml
272
- var setup_default = "name: Setup\ndescription: Prepare the environment and install project dependencies.\n\ninputs:\n node-version:\n description: Node.js version\n required: false\n default: \"22.x\"\n\nruns:\n using: composite\n\n steps:\n - uses: theholocron/.github/.github/actions/setup-node@main\n with:\n node-version: ${{ inputs.node-version }}\n\n - uses: theholocron/.github/.github/actions/install@main\n\n # `@theholocron/cli`'s `dist/cli.mjs` doesn't exist yet at this point, so\n # pnpm's workspace bin-linking can't create `node_modules/.bin/holocron`\n # (silent `WARN ... ENOENT`, not a hard failure). Every package whose\n # scripts delegate via `holocron run <task> --` then fails at run time\n # with `holocron: not found` (#698). Same fix the `holocron` composite\n # action already applies for its own direct invocation (see its \"Build\n # the workspace when the CLI resolves to an unbuilt checkout\" step) —\n # mirrored here so it also covers *nested* `holocron run <task> --`\n # calls from inside package.json scripts, which that action's own guard\n # doesn't reach. `pnpm build` (not a scoped `--filter`) so the CLI's own\n # workspace dependencies (e.g. astromech) build\n # in topological order too — a scoped build skips them and fails.\n # No-op in every consumer repo, where the published tarball already\n # ships `dist/`.\n - name: Build the Holocron CLI\n shell: bash\n run: |\n if [ ! -f node_modules/@theholocron/cli/dist/cli.mjs ]; then\n echo \"→ @theholocron/cli dist/ missing — building the workspace from source\" >&2\n pnpm build\n echo \"→ re-linking node_modules/.bin — pnpm skipped it pre-build\" >&2\n pnpm install --frozen-lockfile\n fi\n\n - name: Cache Turbo artifacts\n if: ${{ hashFiles('turbo.json') != '' }}\n uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0\n with:\n path: .turbo\n key: turbo-${{ runner.os }}-${{ github.sha }}\n restore-keys: |\n turbo-${{ runner.os }}-\n\n # A Turbo token with no team turns the remote cache off without a word: every task just runs cold. `TURBO_TEAM` is\n # an organization variable that `holocron repo setup` writes from `repo.variables.org.TURBO_TEAM` in\n # holocron.config.ts. Quiet when there is no token, because then the cache is meant to be off.\n - name: Warn when the Turbo remote cache is off\n if: ${{ hashFiles('turbo.json') != '' }}\n shell: bash\n run: |\n if [ -n \"$TURBO_TOKEN\" ] && [ -z \"$TURBO_TEAM\" ]; then\n echo \"::warning title=Turbo remote cache is off::TURBO_TOKEN is set but TURBO_TEAM is not. Declare it under repo.variables.org in holocron.config.ts and run holocron repo setup.\"\n fi\n";
272
+ var setup_default = "name: Setup\ndescription: Prepare the environment and install project dependencies.\n\ninputs:\n node-version:\n description: Node.js version\n required: false\n default: \"22.x\"\n\nruns:\n using: composite\n\n steps:\n - uses: theholocron/.github/.github/actions/setup-node@main\n with:\n node-version: ${{ inputs.node-version }}\n\n - uses: theholocron/.github/.github/actions/install@main\n\n # Restored before the bootstrap build below so `pnpm build` replays from the cache instead of running cold.\n - name: Cache Turbo artifacts\n if: ${{ hashFiles('turbo.json') != '' }}\n uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0\n with:\n path: .turbo\n key: turbo-${{ runner.os }}-${{ github.sha }}\n restore-keys: |\n turbo-${{ runner.os }}-\n\n # `@theholocron/cli`'s `dist/cli.mjs` doesn't exist yet at this point, so\n # pnpm's workspace bin-linking can't create `node_modules/.bin/holocron`\n # (silent `WARN ... ENOENT`, not a hard failure). Every package whose\n # scripts delegate via `holocron run <task> --` then fails at run time\n # with `holocron: not found` (#698). Same fix the `holocron` composite\n # action already applies for its own direct invocation (see its \"Build\n # the workspace when the CLI resolves to an unbuilt checkout\" step) —\n # mirrored here so it also covers *nested* `holocron run <task> --`\n # calls from inside package.json scripts, which that action's own guard\n # doesn't reach. `pnpm build` (not a scoped `--filter`) so the CLI's own\n # workspace dependencies (e.g. astromech) build\n # in topological order too — a scoped build skips them and fails.\n # No-op in every consumer repo, where the published tarball already\n # ships `dist/`.\n - name: Build the Holocron CLI\n shell: bash\n run: |\n if [ ! -f node_modules/@theholocron/cli/dist/cli.mjs ]; then\n echo \"→ @theholocron/cli dist/ missing — building the workspace from source\" >&2\n pnpm build\n echo \"→ re-linking node_modules/.bin — pnpm skipped it pre-build\" >&2\n pnpm install --frozen-lockfile\n fi\n\n # A Turbo token with no team turns the remote cache off without a word: every task just runs cold. `TURBO_TEAM` is\n # an organization variable that `holocron repo setup` writes from `repo.variables.org.TURBO_TEAM` in\n # holocron.config.ts. Quiet when there is no token, because then the cache is meant to be off.\n - name: Warn when the Turbo remote cache is off\n if: ${{ hashFiles('turbo.json') != '' }}\n shell: bash\n run: |\n if [ -n \"$TURBO_TOKEN\" ] && [ -z \"$TURBO_TEAM\" ]; then\n echo \"::warning title=Turbo remote cache is off::TURBO_TOKEN is set but TURBO_TEAM is not. Declare it under repo.variables.org in holocron.config.ts and run holocron repo setup.\"\n fi\n";
273
273
  // src/templates/reusable/actions/setup-node.yml
274
274
  var setup_node_default = "name: Setup Node\ndescription: Install pnpm and Node.js with pnpm dependency caching.\n\ninputs:\n node-version:\n description: Node.js version\n required: false\n default: \"22.x\"\nruns:\n using: composite\n\n steps:\n - name: Setup pnpm\n if: ${{ hashFiles('pnpm-lock.yaml') != '' }}\n uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4\n\n - name: Setup Node.js\n uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0\n with:\n node-version: ${{ hashFiles('.node-version') != '' && '' || inputs.node-version }}\n node-version-file: ${{ hashFiles('.node-version') != '' && '.node-version' || '' }}\n cache: ${{ hashFiles('pnpm-lock.yaml') != '' && 'pnpm' || '' }}\n # Do NOT add registry-url here. setup-node writes .npmrc with\n # _authToken=${NODE_AUTH_TOKEN} and sets NPM_CONFIG_USERCONFIG to it.\n # pnpm reads that file, fails env-var substitution when the token is\n # empty, and loses auth entirely. Without registry-url, pnpm 10.15+\n # handles Trusted Publishing via its own native OIDC exchange.\n\n - name: Add node_modules/.bin to PATH\n shell: bash\n run: echo \"$GITHUB_WORKSPACE/node_modules/.bin\" >> $GITHUB_PATH\n";
275
275
  // src/templates/reusable/bookkeeping.yml
@@ -1349,12 +1349,15 @@ function turboConfig(config) {
1349
1349
  if (!turbo) continue;
1350
1350
  const extraEnv = validatedGlobList(entry.turbo?.passThroughEnv, entry.name, "passThroughEnv");
1351
1351
  const extraInputs = validatedGlobList(entry.turbo?.inputs, entry.name, "inputs");
1352
+ const extraDependsOn = validatedGlobList(entry.turbo?.dependsOn, entry.name, "dependsOn");
1352
1353
  const current = tasks[entry.name] ?? turbo;
1353
1354
  const passThroughEnv = extraEnv.length > 0 ? [...current.passThroughEnv ?? [], ...extraEnv] : current.passThroughEnv;
1354
1355
  const inputs = extraInputs.length > 0 ? [...current.inputs, ...extraInputs] : current.inputs;
1356
+ const dependsOn = [.../* @__PURE__ */ new Set([...current.dependsOn, ...extraDependsOn])];
1355
1357
  tasks[entry.name] = {
1356
1358
  ...turbo,
1357
1359
  inputs,
1360
+ dependsOn,
1358
1361
  ...passThroughEnv && passThroughEnv.length > 0 ? { passThroughEnv } : {}
1359
1362
  };
1360
1363
  }
@@ -1661,6 +1664,42 @@ function resolveLinters(opts) {
1661
1664
  def: LINTERS[name]
1662
1665
  }));
1663
1666
  }
1667
+ // src/tasks/run/resolve-affected/resolve-affected.ts
1668
+ /** Branches that releases are cut from: on a push to one, HEAD equals the base, so nothing would be "affected". */
1669
+ const RELEASE_BRANCHES = /* @__PURE__ */ new Set(["main", "alpha"]);
1670
+ /**
1671
+ * Decide whether `turbo run` gets `--affected`, and against which base.
1672
+ *
1673
+ * `--affected` is dropped (everything runs, the safe direction) on a push to a
1674
+ * release branch, and when the base ref is missing or not in this checkout —
1675
+ * raw turbo would error on that, a shallow CI clone must not.
1676
+ */
1677
+ function resolveAffected(input) {
1678
+ if (!input.affected) return { affected: false };
1679
+ const { env, exec, cwd } = input;
1680
+ const branch = env.GITHUB_REF_NAME;
1681
+ if (env.GITHUB_EVENT_NAME === "push" && branch !== void 0 && RELEASE_BRANCHES.has(branch)) return {
1682
+ affected: false,
1683
+ notice: `--affected ignored on a push to ${branch}: running everything`
1684
+ };
1685
+ const base = input.base ?? env.TURBO_SCM_BASE;
1686
+ if (!base) return {
1687
+ affected: false,
1688
+ notice: "--affected ignored: no base given (--base or TURBO_SCM_BASE); running everything"
1689
+ };
1690
+ if (exec("git", [
1691
+ "cat-file",
1692
+ "-e",
1693
+ `${base}^{commit}`
1694
+ ], { cwd }).exitCode !== 0) return {
1695
+ affected: false,
1696
+ notice: `--affected ignored: base "${base}" is not in this checkout (fetch more history); running everything`
1697
+ };
1698
+ return {
1699
+ affected: true,
1700
+ env: { TURBO_SCM_BASE: base }
1701
+ };
1702
+ }
1664
1703
  // src/tasks/run/resolve-bin/resolve-bin.ts
1665
1704
  /** `<cwd>/node_modules/.bin/<tool>` when it exists, else the bare `tool` name (left to `PATH`). */
1666
1705
  function resolveBin(cwd, tool, fileExists) {
@@ -1915,7 +1954,7 @@ function turboDefinesTask(cwd, task, readFile, fileExists) {
1915
1954
  function makeRunOne(input) {
1916
1955
  const { print, logger, exec, task, cwd } = input;
1917
1956
  const dryRun = input.dryRun ?? false;
1918
- return (cmd, args) => {
1957
+ return (cmd, args, env) => {
1919
1958
  const command = [cmd, ...args].join(" ");
1920
1959
  if (dryRun) {
1921
1960
  print(`would run: ${command}`);
@@ -1930,7 +1969,10 @@ function makeRunOne(input) {
1930
1969
  };
1931
1970
  }
1932
1971
  print(`→ ${command}`);
1933
- const { exitCode } = exec(cmd, args, { cwd });
1972
+ const { exitCode } = exec(cmd, args, env ? {
1973
+ cwd,
1974
+ env
1975
+ } : { cwd });
1934
1976
  const status = exitCode === 0 ? "ok" : "fail";
1935
1977
  logger[status === "fail" ? "warn" : "debug"]({
1936
1978
  task,
@@ -2010,14 +2052,25 @@ function runTask(input) {
2010
2052
  if (turboDefinesTask(cwd, task, readFile, fileExists)) {
2011
2053
  const filterArg = input.filter ? [`--filter=${input.filter}`] : [];
2012
2054
  const forwarded = [...def?.local && !def.local.command && def.local.tool ? def.flags?.[def.local.tool] ?? [] : [], ...passthrough];
2055
+ const plan = resolveAffected({
2056
+ affected: input.affected,
2057
+ base: input.base,
2058
+ env: input.env ?? {},
2059
+ exec: input.exec,
2060
+ cwd
2061
+ });
2062
+ if (plan.notice) print(`· ${plan.notice}`);
2063
+ const affectedArg = plan.affected ? ["--affected"] : [];
2013
2064
  const args = [
2014
2065
  "run",
2015
2066
  task,
2016
2067
  ...filterArg,
2068
+ ...affectedArg,
2017
2069
  ...forwarded.length ? ["--", ...forwarded] : []
2018
2070
  ];
2019
- return run(resolveBin(cwd, "turbo", fileExists), args);
2071
+ return run(resolveBin(cwd, "turbo", fileExists), args, plan.env);
2020
2072
  }
2073
+ if (input.affected) print("· --affected ignored: this repo has no turbo task for it");
2021
2074
  const script = readPackageJsonSync(cwd, { readFile })?.scripts?.[task];
2022
2075
  if (script && !/^holocron run\b/.test(script.trim())) return run(detectPackageManager(cwd, {
2023
2076
  readFile,
@@ -2292,7 +2345,10 @@ function runCi(input) {
2292
2345
  cwd: input.cwd,
2293
2346
  dryRun: input.dryRun ?? false,
2294
2347
  required: entry.required === true,
2295
- ...input.filter ? { filter: input.filter } : {}
2348
+ ...input.filter ? { filter: input.filter } : {},
2349
+ ...input.affected ? { affected: true } : {},
2350
+ ...input.base ? { base: input.base } : {},
2351
+ ...input.env ? { env: input.env } : {}
2296
2352
  });
2297
2353
  const status = r.status;
2298
2354
  jobs.push({
@@ -2396,7 +2452,11 @@ const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2396
2452
  const realExec = (cmd, args, opts) => {
2397
2453
  return { exitCode: spawnSync(cmd, args, {
2398
2454
  cwd: opts.cwd,
2399
- stdio: "inherit"
2455
+ stdio: "inherit",
2456
+ ...opts.env ? { env: {
2457
+ ...process.env,
2458
+ ...opts.env
2459
+ } } : {}
2400
2460
  }).status ?? -1 };
2401
2461
  };
2402
2462
  // src/utils/look-path/look-path.ts
@@ -2757,7 +2817,10 @@ function runGroup(input) {
2757
2817
  ...jobSwitches(input.config, name),
2758
2818
  cwd: input.cwd,
2759
2819
  dryRun: input.dryRun ?? false,
2760
- ...input.filter ? { filter: input.filter } : {}
2820
+ ...input.filter ? { filter: input.filter } : {},
2821
+ ...input.affected ? { affected: true } : {},
2822
+ ...input.base ? { base: input.base } : {},
2823
+ ...input.env ? { env: input.env } : {}
2761
2824
  });
2762
2825
  jobs.push({
2763
2826
  task: name,
@@ -2787,6 +2850,7 @@ function createAstromech(options) {
2787
2850
  listDir: options.listDir ?? ((path) => readdirSync(path)),
2788
2851
  lookPath: options.lookPath ?? realLookPath
2789
2852
  };
2853
+ const env = options.env ?? process.env;
2790
2854
  const items = () => (options.config?.tasks ?? []).map((i) => normalizeTaskEntry(i));
2791
2855
  /** The `jobs` switches of a task's entry in the manifest, as a `runTask` input; nothing when it has none. */
2792
2856
  const jobSwitchesFor = (task) => {
@@ -2820,7 +2884,12 @@ function createAstromech(options) {
2820
2884
  config: options.config,
2821
2885
  namespace: task,
2822
2886
  dryRun: opts.dryRun ?? false,
2823
- ...opts.filter ? { filter: opts.filter } : {}
2887
+ ...opts.filter ? { filter: opts.filter } : {},
2888
+ ...opts.affected ? {
2889
+ affected: true,
2890
+ env
2891
+ } : {},
2892
+ ...opts.base ? { base: opts.base } : {}
2824
2893
  });
2825
2894
  return runTask({
2826
2895
  ...deps,
@@ -2831,6 +2900,11 @@ function createAstromech(options) {
2831
2900
  dryRun: opts.dryRun ?? false,
2832
2901
  required: opts.required ?? false,
2833
2902
  ...opts.filter ? { filter: opts.filter } : {},
2903
+ ...opts.affected ? {
2904
+ affected: true,
2905
+ env
2906
+ } : {},
2907
+ ...opts.base ? { base: opts.base } : {},
2834
2908
  ...jobSwitchesFor(task)
2835
2909
  });
2836
2910
  },
@@ -2838,6 +2912,7 @@ function createAstromech(options) {
2838
2912
  ...deps,
2839
2913
  cwd: options.cwd,
2840
2914
  config: options.config ?? {},
2915
+ ...opts.affected ? { env } : {},
2841
2916
  ...opts
2842
2917
  }),
2843
2918
  thinCallers: () => {
@@ -1,4 +1,4 @@
1
- import { r as TasksConfig } from "../schema.type-DThrbvO2.mjs";
1
+ import { r as TasksConfig } from "../schema.type-C-3fZESa.mjs";
2
2
  import { defineConfig } from "@theholocron/semantic-release-config";
3
3
  /** Runs `git` with `args` in `cwd`, feeding it `input` on stdin, and returns stdout. */
4
4
  export type GitRun = (args: string[], input: string, cwd: string) => string;
@@ -46,6 +46,14 @@ interface TaskEntry {
46
46
  * stay tracked without needing to be repeated here.
47
47
  */
48
48
  inputs?: string[];
49
+ /**
50
+ * Extra tasks this one waits for, appended to the registry default's
51
+ * `dependsOn` — for a build the package does not list as a dependency
52
+ * but its task loads anyway (e.g. `staticAnalysis` loading the root
53
+ * ESLint config, which imports a package of the workspace). Turbo
54
+ * syntax: `"<package>#<task>"`, `"^<task>"`.
55
+ */
56
+ dependsOn?: string[];
49
57
  };
50
58
  }
51
59
  /** A task is either its bare name (all defaults) or an entry object. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/astromech",
3
- "version": "5.0.0-alpha.255",
3
+ "version": "5.0.0-alpha.256",
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",
@@ -50,18 +50,15 @@
50
50
  "@commitlint/lint": "^21.2.3",
51
51
  "@commitlint/load": "^21.2.3",
52
52
  "@commitlint/types": "^21.2.3",
53
- "@theholocron/json-utils": "^1.16.1-alpha.1",
53
+ "@theholocron/datapad": "5.0.0-alpha.256",
54
54
  "@theholocron/fs-utils": "^1.16.1-alpha.1",
55
- "@theholocron/datapad": "5.0.0-alpha.255",
56
- "@theholocron/pkg-utils": "^1.16.1-alpha.1"
55
+ "@theholocron/pkg-utils": "^1.16.1-alpha.1",
56
+ "@theholocron/json-utils": "^1.16.1-alpha.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@commitlint/config-conventional": "^21.2.3",
60
60
  "@semantic-release/commit-analyzer": "^13.0.1",
61
61
  "@semantic-release/release-notes-generator": "^14.1.1",
62
- "@theholocron/commitlint-config": "^8.8.0",
63
- "@theholocron/eslint-config": "^8.8.2",
64
- "@theholocron/semantic-release-config": "^8.8.2",
65
62
  "@types/node": "^26",
66
63
  "@vitest/coverage-v8": "^5.0.5",
67
64
  "@vitest/eslint-plugin": "^1.6.27",
@@ -71,9 +68,12 @@
71
68
  "tsdown": "^0.23.3",
72
69
  "typescript": "^5.9.3",
73
70
  "vitest": "^5.0.5",
71
+ "@theholocron/commitlint-config": "^8.9.0-alpha.3",
74
72
  "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.3",
75
- "@theholocron/tsdown-config": "^8.9.0-alpha.3",
73
+ "@theholocron/eslint-config": "^8.9.0-alpha.3",
74
+ "@theholocron/semantic-release-config": "^8.9.0-alpha.3",
76
75
  "@theholocron/tsconfig": "^8.9.0-alpha.3",
76
+ "@theholocron/tsdown-config": "^8.9.0-alpha.3",
77
77
  "@theholocron/vitest-config": "^8.9.0-alpha.3"
78
78
  },
79
79
  "peerDependencies": {