@intentius/chant 0.124.103 → 0.124.104

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.
Files changed (67) hide show
  1. package/dist/audit/secrets.d.ts +6 -0
  2. package/dist/audit/secrets.js +9 -2
  3. package/dist/cli/commands/import-index.d.ts +15 -0
  4. package/dist/cli/commands/import-index.js +37 -3
  5. package/dist/cli/handlers/lifecycle.js +6 -0
  6. package/dist/cli/handlers/release-config.d.ts +15 -0
  7. package/dist/cli/handlers/release-config.js +58 -0
  8. package/dist/cli/handlers/release.js +36 -3
  9. package/dist/cli/main.js +12 -2
  10. package/dist/cli/parse-args.js +7 -0
  11. package/dist/cli/registry.d.ts +2 -0
  12. package/dist/cli/release-commands/cut.js +3 -0
  13. package/dist/config-import.js +26 -4
  14. package/dist/config.d.ts +14 -0
  15. package/dist/config.js +4 -0
  16. package/dist/floor-table.data.js +7 -6
  17. package/dist/floor-table.js +3 -1
  18. package/dist/graph-refs.d.ts +9 -0
  19. package/dist/graph-refs.js +9 -7
  20. package/dist/lifecycle/cloud-index.d.ts +6 -0
  21. package/dist/lifecycle/cloud-index.js +32 -5
  22. package/dist/lifecycle/identity-match.d.ts +18 -2
  23. package/dist/lifecycle/identity-match.js +10 -5
  24. package/dist/lifecycle/index-drift.d.ts +13 -0
  25. package/dist/lifecycle/index-drift.js +21 -3
  26. package/dist/lifecycle/index-import.d.ts +15 -0
  27. package/dist/lifecycle/index-import.js +25 -2
  28. package/dist/lifecycle/index-join.d.ts +1 -1
  29. package/dist/lifecycle/index-join.js +1 -1
  30. package/dist/lifecycle/publish-declaration.d.ts +6 -0
  31. package/dist/lifecycle/publish-declaration.js +18 -1
  32. package/dist/lifecycle/publish-forge.d.ts +2 -0
  33. package/dist/lifecycle/publish-forge.js +3 -1
  34. package/dist/lifecycle/publish-oci.d.ts +27 -0
  35. package/dist/lifecycle/publish-oci.js +63 -8
  36. package/dist/lifecycle/release-changelog.d.ts +18 -5
  37. package/dist/lifecycle/release-changelog.js +22 -10
  38. package/dist/lifecycle/release-cut.d.ts +13 -1
  39. package/dist/lifecycle/release-cut.js +3 -0
  40. package/dist/lifecycle/release-images.d.ts +32 -2
  41. package/dist/lifecycle/release-images.js +70 -2
  42. package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
  43. package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
  44. package/dist/lifecycle/release-init.d.ts +22 -0
  45. package/dist/lifecycle/release-init.js +86 -7
  46. package/dist/local-chant.d.ts +3 -0
  47. package/dist/local-chant.js +28 -2
  48. package/dist/release-floors.d.ts +10 -6
  49. package/dist/release-floors.js +10 -6
  50. package/dist/ts-loader.d.ts +12 -3
  51. package/dist/ts-loader.js +27 -11
  52. package/dist/wave-runtime.mjs +291 -290
  53. package/dist/workspace/catalog-edges.d.ts +22 -0
  54. package/dist/workspace/catalog-edges.js +23 -0
  55. package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
  56. package/dist/workspace/release-steps/goreleaser.js +12 -6
  57. package/dist/workspace/release-toolchains.d.ts +6 -0
  58. package/dist/workspace/release-toolchains.js +8 -0
  59. package/dist/workspace/release-train-workflow.d.ts +18 -0
  60. package/dist/workspace/release-train-workflow.js +135 -7
  61. package/dist/workspace/release-train.js +1 -1
  62. package/dist/workspace/release-workflow.d.ts +26 -0
  63. package/dist/workspace/release-workflow.js +60 -12
  64. package/dist/workspace/train-artifacts.js +3 -4
  65. package/dist/workspace/train-cut.d.ts +22 -1
  66. package/dist/workspace/train-cut.js +78 -14
  67. package/package.json +2 -2
@@ -17,6 +17,7 @@
17
17
  * the forge. Everything it can't set up from the repository, such as an npm
18
18
  * trusted publisher, is a step printed for a person ({@link ReleaseInitPlan.registry}).
19
19
  */
20
+ import { type GoreleaserImage } from "./release-init-goreleaser-images.js";
20
21
  import { type RegistryProjectFacts } from "./release-init-registries.js";
21
22
  export type ReleaseInitCode = "release-init-release-exists" | "release-init-config-unreadable" | "release-init-workflow-exists" | "release-init-not-a-project" | "release-init-member-exists" | "release-init-tsx-missing";
22
23
  /** A refusal of `chant release init`, with its code. */
@@ -103,6 +104,14 @@ export interface ProjectFacts {
103
104
  snapshot: boolean;
104
105
  /** The config builds images (`dockers:` or `kos:`). */
105
106
  images: boolean;
107
+ /** Its `changelog.filters` (#5270): the types left out, or the patterns no commit type names. */
108
+ changelog?: {
109
+ exclude: string[];
110
+ } | {
111
+ unread: string[];
112
+ } | null;
113
+ /** The image its `dockers` or `dockers_v2` build (#5269), as release.images and an oci target declare it. */
114
+ image?: GoreleaserImage | null;
106
115
  } | null;
107
116
  /** Helm charts (#5233): each directory holding a `Chart.yaml`, from the project root, and the chart's name. A chart inside another's directory is its subchart and is not listed. */
108
117
  charts?: Array<{
@@ -120,6 +129,8 @@ export interface ProjectFacts {
120
129
  chantCi: boolean;
121
130
  /** `.gitignore` ignores `dist/`. */
122
131
  distIgnored: boolean;
132
+ /** `.gitignore` ignores `build/`, where an image beside goreleaser's dist is written (#5269). */
133
+ buildIgnored?: boolean;
123
134
  /** A `pom.xml`, `*.csproj` files or a `*.gemspec` at the root (#5232). */
124
135
  registries?: RegistryProjectFacts;
125
136
  }
@@ -153,6 +164,17 @@ export declare function goreleaserFacts(text: string): {
153
164
  snapshot: boolean;
154
165
  images: boolean;
155
166
  };
167
+ /**
168
+ * A goreleaser config's `changelog` (#5270), as generated notes: the commit
169
+ * types its `filters.exclude` leaves out, when each pattern names one type
170
+ * (`^docs:`, `^chore(\(.*\))?:`), or the patterns that name none. `null` when the
171
+ * config generates no changelog of its own filtering.
172
+ */
173
+ export declare function goreleaserChangelog(text: string): {
174
+ exclude: string[];
175
+ } | {
176
+ unread: string[];
177
+ } | null;
156
178
  /** The lines a goreleaser config needs so its snapshot build carries the release's label. */
157
179
  export declare const GORELEASER_SNAPSHOT = "snapshot:\n version_template: \"{{ .Env.CHANT_RELEASE_LABEL }}\"\n";
158
180
  /** A `Cargo.toml`'s name, workspace, stampable version and `publish = false`. */
@@ -22,6 +22,9 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
22
22
  import { basename, join, posix, relative, sep } from "node:path";
23
23
  import { GENERATED_MARKER } from "../discovery/files.js";
24
24
  import { forgeOfRemote } from "../forge-remote.js";
25
+ import { parseYAML } from "../yaml.js";
26
+ import { goreleaserImage } from "./release-init-goreleaser-images.js";
27
+ import { imageArchiveBesideGoreleaser } from "./release-images.js";
25
28
  import { detectRegistryProjects, planRegistryTargets } from "./release-init-registries.js";
26
29
  /** A refusal of `chant release init`, with its code. */
27
30
  export class ReleaseInitError extends Error {
@@ -236,6 +239,40 @@ export function goreleaserFacts(text) {
236
239
  images: /^(dockers|dockers_v2|kos)\s*:/m.test(text),
237
240
  };
238
241
  }
242
+ /**
243
+ * A goreleaser config's `changelog` (#5270), as generated notes: the commit
244
+ * types its `filters.exclude` leaves out, when each pattern names one type
245
+ * (`^docs:`, `^chore(\(.*\))?:`), or the patterns that name none. `null` when the
246
+ * config generates no changelog of its own filtering.
247
+ */
248
+ export function goreleaserChangelog(text) {
249
+ let doc;
250
+ try {
251
+ doc = parseYAML(text);
252
+ }
253
+ catch {
254
+ return null;
255
+ }
256
+ const changelog = doc?.changelog;
257
+ if (!changelog || typeof changelog !== "object" || changelog.disable === true)
258
+ return null;
259
+ const patterns = Array.isArray(changelog.filters?.exclude) ? changelog.filters.exclude.filter((p) => typeof p === "string") : [];
260
+ const include = Array.isArray(changelog.filters?.include) ? changelog.filters.include.filter((p) => typeof p === "string") : [];
261
+ if (patterns.length === 0 && include.length === 0)
262
+ return null;
263
+ const types = [];
264
+ const unread = [...include];
265
+ for (const p of patterns) {
266
+ const m = /^\^(\w+)(?:\(\\\(\.\*\\\)\)\?)?:$/.exec(p.trim());
267
+ if (m) {
268
+ if (!types.includes(m[1]))
269
+ types.push(m[1]);
270
+ }
271
+ else
272
+ unread.push(p);
273
+ }
274
+ return unread.length > 0 ? { unread } : { exclude: types };
275
+ }
239
276
  /** The lines a goreleaser config needs so its snapshot build carries the release's label. */
240
277
  export const GORELEASER_SNAPSHOT = 'snapshot:\n version_template: "{{ .Env.CHANT_RELEASE_LABEL }}"\n';
241
278
  /** Read the project at `root` (the directory `chant release init` runs in). */
@@ -318,7 +355,13 @@ export function detectProject(root) {
318
355
  const pyproject = readText(join(root, "pyproject.toml"));
319
356
  const python = pyproject === null ? (existsSync(join(root, "setup.py")) ? { name: null, pyproject: false, version: false } : null) : pyprojectFacts(pyproject);
320
357
  const grFile = GORELEASER_FILES.find((f) => existsSync(join(root, f)));
321
- const goreleaser = grFile ? { file: grFile, ...goreleaserFacts(readText(join(root, grFile)) ?? "") } : null;
358
+ const grText = grFile ? (readText(join(root, grFile)) ?? "") : "";
359
+ const grImage = grFile ? goreleaserImage(grText) : null;
360
+ // #5269: chant builds the Dockerfile from the repository, not from goreleaser's context with the binary it built.
361
+ if (grImage && (readText(join(root, grImage.dockerfile)) ?? "").match(/^\s*FROM\s/gim)?.length === 1) {
362
+ grImage.unread.push(`a binary goreleaser builds: chant builds ${grImage.dockerfile} from the repository, and its one stage copies what goreleaser would have put in its context; give it a build stage of its own`);
363
+ }
364
+ const goreleaser = grFile ? { file: grFile, ...goreleaserFacts(grText), ...(grImage ? { image: grImage } : {}), changelog: goreleaserChangelog(grText) } : null;
322
365
  const nfpmFile = NFPM_FILES.find((f) => existsSync(join(root, f)));
323
366
  const nfpmVersion = nfpmFile ? /^version:[ \t]*["']?[^\n]*\$\{?CHANT_RELEASE_(VERSION|LABEL)/m.test(readText(join(root, nfpmFile)) ?? "") : false;
324
367
  const tagList = (git(top, ["tag", "--list"]) ?? "").split("\n").map((t) => t.trim()).filter(Boolean);
@@ -342,6 +385,7 @@ export function detectProject(root) {
342
385
  tags: readTagHistory(tagList),
343
386
  chantCi: ciGreen || tagList.some((t) => t.startsWith("ci/green/") || /^ci\/green-[^/]+\//.test(t)),
344
387
  distIgnored: /^\/?dist\/?\s*$/m.test(gitignore) || /^\/?dist\/\*\s*$/m.test(gitignore),
388
+ buildIgnored: /^\/?build\/?\s*$/m.test(gitignore) || /^\/?build\/\*\s*$/m.test(gitignore),
345
389
  registries: detectRegistryProjects(root),
346
390
  };
347
391
  }
@@ -534,11 +578,36 @@ export function planRelease(facts, opts) {
534
578
  // Images.
535
579
  const goreleaserImages = facts.goreleaser?.images ?? false;
536
580
  const dockerfiles = goreleaserImages ? [] : facts.dockerfiles;
537
- if (goreleaserImages && facts.dockerfiles.length > 0)
538
- notes.push(`${facts.goreleaser.file} builds the images, so no Dockerfile is declared in release.images.`);
581
+ const grImage = facts.goreleaser?.image ?? null;
582
+ if (goreleaserImages && !grImage)
583
+ notes.push(`${facts.goreleaser.file} builds its images with kos, which chant does not build, so no image is declared in release.images and the release publishes none: declare a Dockerfile entry in release.images and an oci target to keep publishing it.`);
584
+ else if (goreleaserImages && facts.dockerfiles.length > 0)
585
+ notes.push(`${facts.goreleaser.file} builds the images, so release.images declares its image alone and no other Dockerfile.`);
539
586
  const fallbackName = (facts.origin?.repo.split("/").pop() ?? facts.node?.root.name?.replace(/^@[^/]+\//, "") ?? facts.go?.module?.split("/").pop() ?? "app");
540
587
  const images = [];
541
588
  const usedNames = new Set();
589
+ // #5269: goreleaser's image, built by chant at the cut and pushed by an oci target with goreleaser's tags.
590
+ if (grImage) {
591
+ const g = grImage;
592
+ usedNames.add(g.name);
593
+ images.push({
594
+ name: g.name,
595
+ dockerfile: g.dockerfile,
596
+ ...(g.platforms.length > 0 ? { platforms: g.platforms } : {}),
597
+ archive: g.archive,
598
+ ...(Object.keys(g.args).length > 0 ? { args: g.args } : {}),
599
+ ...(Object.keys(g.labels).length > 0 ? { labels: g.labels } : {}),
600
+ });
601
+ publish.push({ type: "oci", image: g.archive, repository: g.repository, ...(g.tags.length > 0 ? { tags: g.tags } : {}), ...(g.platformTags.length > 0 ? { platformTags: g.platformTags } : {}) });
602
+ if (g.repository.startsWith("ghcr.io/"))
603
+ registry.push(`${g.repository}: the workflow pushes with the run's token, as goreleaser did.`);
604
+ else
605
+ registry.push(`${g.repository}: set OCI_USERNAME and OCI_PASSWORD for the release workflow, as ${forge === "gitlab" ? "masked CI/CD variables" : "secrets in release.workflow.env"}, with push access to the registry.`);
606
+ reasons.push(`release.images: ${g.dockerfile} built once at the cut as a reproducible OCI archive of ${g.platforms.join(", ") || "the default platforms"}, as ${facts.goreleaser.file}'s ${g.keys.join(" and ")} built it, pushed to ${g.repository} by the oci target`);
607
+ notes.push(`Remove ${g.keys.join(" and ")} from ${facts.goreleaser.file}: chant builds and pushes the image now, and the cut's goreleaser would build it again.`);
608
+ if (g.unread.length > 0)
609
+ notes.push(`Not carried from ${facts.goreleaser.file}'s images: ${g.unread.join("; ")}.`);
610
+ }
542
611
  for (const dockerfile of dockerfiles) {
543
612
  let name = imageName(dockerfile, fallbackName);
544
613
  while (usedNames.has(name))
@@ -548,7 +617,7 @@ export function planRelease(facts, opts) {
548
617
  images.push(dir === "." ? { name, dockerfile } : { name, dockerfile, context: dir });
549
618
  const repository = imageRepository(facts.origin, name, dockerfiles.length === 1);
550
619
  if (repository) {
551
- publish.push({ type: "oci", image: `dist/images/${name}.tar`, repository });
620
+ publish.push({ type: "oci", image: facts.goreleaser ? imageArchiveBesideGoreleaser(name) : `dist/images/${name}.tar`, repository });
552
621
  if (repository.startsWith("ghcr.io/"))
553
622
  registry.push(`${repository}: the workflow pushes with the run's token. The first push makes the package private; make it public in the package's settings if it should be.`);
554
623
  else
@@ -559,7 +628,8 @@ export function planRelease(facts, opts) {
559
628
  }
560
629
  if (images.length > 0) {
561
630
  release.images = images;
562
- reasons.push(`release.images: ${dockerfiles.join(", ")} built once at the cut as reproducible OCI archives${publish.some((p) => p.type === "oci") ? ", pushed by the oci target" : ""}`);
631
+ if (dockerfiles.length > 0)
632
+ reasons.push(`release.images: ${dockerfiles.join(", ")} built once at the cut as reproducible OCI archives${publish.some((p) => p.type === "oci") ? ", pushed by the oci target" : ""}`);
563
633
  }
564
634
  // goreleaser.
565
635
  let goreleaserPatch = null;
@@ -573,8 +643,15 @@ export function planRelease(facts, opts) {
573
643
  release.artifacts = [{ name: "goreleaser", goreleaser: {} }];
574
644
  reasons.push(`release.artifacts: ${gr.file} builds the binaries and archives once at the cut with goreleaser release --snapshot, and the release records each file`);
575
645
  if (facts.origin) {
576
- publish.push({ type: "forge", forge: facts.origin.kind, repo: facts.origin.repo, assets: ["artifact:goreleaser"], notes: { generate: "forge" } });
577
- reasons.push(`forge target: the goreleaser files as assets of the ${facts.origin.kind} release ${facts.origin.repo}, with generated notes`);
646
+ // #5270: a changelog that filters commit types keeps its filters as notes from commits.
647
+ const cl = gr.changelog;
648
+ const exclude = cl && "exclude" in cl ? cl.exclude : null;
649
+ publish.push({ type: "forge", forge: facts.origin.kind, repo: facts.origin.repo, assets: ["artifact:goreleaser"], notes: exclude ? { generate: "commits", exclude } : { generate: "forge" } });
650
+ reasons.push(exclude
651
+ ? `forge target: the goreleaser files as assets of the ${facts.origin.kind} release ${facts.origin.repo}, with notes from the commits since the previous release except ${exclude.join(", ")}, as ${gr.file}'s changelog filters left them out`
652
+ : `forge target: the goreleaser files as assets of the ${facts.origin.kind} release ${facts.origin.repo}, with generated notes`);
653
+ if (cl && "unread" in cl)
654
+ notes.push(`${gr.file}'s changelog filters ${cl.unread.map((p) => JSON.stringify(p)).join(", ")} name no commit type, so the forge release's notes are the forge's own: set notes to { generate: "commits", types: [...] } or { generate: "commits", exclude: [...] } to filter them.`);
578
655
  }
579
656
  else
580
657
  notes.push(`No forge release is declared for ${gr.file}'s files: origin names no GitHub, GitLab or Forgejo repository.`);
@@ -684,6 +761,8 @@ export function planRelease(facts, opts) {
684
761
  reasons.push(`release.workflow.file ${workflowFile}: it runs npm publish today, so the npm trusted publisher that names it keeps working; the release workflow replaces it rather than publishing from a second file`);
685
762
  if (!facts.distIgnored && (images.length > 0 || facts.goreleaser || charts.length > 0 || facts.nfpm || publish.some((p) => ["pypi", "nuget", "rubygems"].includes(p.type ?? "")) || publish.some((p) => p.type === "marketplace")))
686
763
  notes.push("dist/ is not in .gitignore: the publish refuses a tree with build outputs git does not ignore.");
764
+ if (facts.goreleaser && images.length > 0 && facts.buildIgnored !== true)
765
+ notes.push("build/ is not in .gitignore: the images are written to build/images/, outside goreleaser's dist, and the publish refuses a tree with build outputs git does not ignore.");
687
766
  if (forge === "gitlab")
688
767
  registry.push(`GitLab: include ${workflowFile} from .gitlab-ci.yml, and store a project access token with write_repository as the masked CI/CD variable CHANT_RELEASE_TOKEN; the cut and publish jobs push with it.`);
689
768
  const h = facts.tags.prefix;
@@ -50,6 +50,9 @@ export declare function packOrder(pkgs: Map<string, ChantPackage>, want: Iterabl
50
50
  * hand (0.124.34 while 0.124.87 was out), which failed a product's floor and
51
51
  * `minReader` checks that pass on a published chant. Every floor the checkout
52
52
  * declares is at or below `NEXT_RELEASE`, so the local build passes each one.
53
+ * A checkout's NEXT_RELEASE can name a release that already shipped, since a
54
+ * release train needs no commit to move it on (#5260), so the version is at
55
+ * least the patch after core's newest release tag in the checkout.
53
56
  * The build is marked local by the `chantLocal` field on each installed copy,
54
57
  * not in the version, because a prerelease of `NEXT_RELEASE` sorts below it.
55
58
  */
@@ -25,7 +25,7 @@
25
25
  * {@link resetLocalChant} goes back: `npm ci`, then a check that every
26
26
  * installed chant package is the version the lock pins, with no mark.
27
27
  */
28
- import { spawnSync } from "node:child_process";
28
+ import { execFileSync, spawnSync } from "node:child_process";
29
29
  import { createHash } from "node:crypto";
30
30
  import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
31
31
  import { tmpdir } from "node:os";
@@ -139,13 +139,39 @@ function compareCore(a, b) {
139
139
  * hand (0.124.34 while 0.124.87 was out), which failed a product's floor and
140
140
  * `minReader` checks that pass on a published chant. Every floor the checkout
141
141
  * declares is at or below `NEXT_RELEASE`, so the local build passes each one.
142
+ * A checkout's NEXT_RELEASE can name a release that already shipped, since a
143
+ * release train needs no commit to move it on (#5260), so the version is at
144
+ * least the patch after core's newest release tag in the checkout.
142
145
  * The build is marked local by the `chantLocal` field on each installed copy,
143
146
  * not in the version, because a prerelease of `NEXT_RELEASE` sorts below it.
144
147
  */
145
148
  export function localChantVersion(chantDir, coreVersion) {
146
149
  const f = join(chantDir, "packages/core/src/release-floors.ts");
147
150
  const next = existsSync(f) ? /export const NEXT_RELEASE = "(\d+\.\d+\.\d+)"/.exec(readFileSync(f, "utf8"))?.[1] : undefined;
148
- return next !== undefined && compareCore(next, coreVersion) > 0 ? next : coreVersion;
151
+ const released = newestCoreRelease(chantDir);
152
+ const afterRelease = released === undefined ? undefined : released.replace(/\d+$/, (p) => String(Number(p) + 1));
153
+ let out = coreVersion;
154
+ for (const v of [next, afterRelease])
155
+ if (v !== undefined && compareCore(v, out) > 0)
156
+ out = v;
157
+ return out;
158
+ }
159
+ /** The newest core release a chant checkout's tags name (`release/npm/core/<v>`, `release/npm/<v>`, `chant-v<v>`), or undefined. */
160
+ function newestCoreRelease(chantDir) {
161
+ let tags;
162
+ try {
163
+ tags = execFileSync("git", ["tag", "-l", "release/npm/core/*", "release/npm/[0-9]*", "chant-v*"], { cwd: chantDir, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
164
+ }
165
+ catch {
166
+ return undefined;
167
+ }
168
+ let out;
169
+ for (const t of tags.split("\n")) {
170
+ const v = /^(?:release\/npm\/core\/|release\/npm\/|chant-v)(\d+\.\d+\.\d+)$/.exec(t.trim())?.[1];
171
+ if (v !== undefined && (out === undefined || compareCore(v, out) > 0))
172
+ out = v;
173
+ }
174
+ return out;
149
175
  }
150
176
  /**
151
177
  * Set the version of one packed tarball's package.json, and every chant
@@ -13,11 +13,15 @@
13
13
  * cut a version when any floor names a version that is neither a published
14
14
  * release nor the one being cut.
15
15
  *
16
- * After the cut, a floor stays at the value it was released with. Once the
17
- * release is published, `just release-floors --freeze <version>` writes the
18
- * version into every floor that names this constant as a literal, and moves
19
- * this constant to the next patch (#4501). The check fails while a floor
20
- * still names this constant after its version shipped.
16
+ * After the cut, a floor stays at the value it was released with. The
17
+ * release tags say which release first carried a floor still on this
18
+ * constant, and core's prepack (`scripts/release-floors.ts --pack`) builds
19
+ * with each such floor written as that release, every other one and this
20
+ * constant as the version being packed, then puts the sources back (#5260).
21
+ * So a release train needs no commit between releases, and this constant can
22
+ * name a release that already shipped. `just release-floors --freeze
23
+ * <version>` writes those literals into the sources and moves this constant
24
+ * to the next patch (#4501), for a tree that reads plainly.
21
25
  *
22
26
  * A new floor is declared next to the code it gates, in that feature's own
23
27
  * file, as `export const <NAME>_FLOOR = NEXT_RELEASE;` with NEXT_RELEASE
@@ -26,7 +30,7 @@
26
30
  * files rather than to the end of this one. The floors below were declared
27
31
  * here before that and keep the subpath they shipped under.
28
32
  */
29
- export declare const NEXT_RELEASE = "0.124.103";
33
+ export declare const NEXT_RELEASE = "0.124.104";
30
34
  /** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
31
35
  export declare const LOCAL_CHANT_FLOOR = "0.124.86";
32
36
  /** The first chant with `chant workspace ref-gate` (pre-receive, pre-push, check, status, attach, install) and `refs` in `.chant/trust.json`, the checks a ref update needs evidence for (#4867). */
@@ -13,11 +13,15 @@
13
13
  * cut a version when any floor names a version that is neither a published
14
14
  * release nor the one being cut.
15
15
  *
16
- * After the cut, a floor stays at the value it was released with. Once the
17
- * release is published, `just release-floors --freeze <version>` writes the
18
- * version into every floor that names this constant as a literal, and moves
19
- * this constant to the next patch (#4501). The check fails while a floor
20
- * still names this constant after its version shipped.
16
+ * After the cut, a floor stays at the value it was released with. The
17
+ * release tags say which release first carried a floor still on this
18
+ * constant, and core's prepack (`scripts/release-floors.ts --pack`) builds
19
+ * with each such floor written as that release, every other one and this
20
+ * constant as the version being packed, then puts the sources back (#5260).
21
+ * So a release train needs no commit between releases, and this constant can
22
+ * name a release that already shipped. `just release-floors --freeze
23
+ * <version>` writes those literals into the sources and moves this constant
24
+ * to the next patch (#4501), for a tree that reads plainly.
21
25
  *
22
26
  * A new floor is declared next to the code it gates, in that feature's own
23
27
  * file, as `export const <NAME>_FLOOR = NEXT_RELEASE;` with NEXT_RELEASE
@@ -26,7 +30,7 @@
26
30
  * files rather than to the end of this one. The floors below were declared
27
31
  * here before that and keep the subpath they shipped under.
28
32
  */
29
- export const NEXT_RELEASE = "0.124.103";
33
+ export const NEXT_RELEASE = "0.124.104";
30
34
  /** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
31
35
  export const LOCAL_CHANT_FLOOR = "0.124.86";
32
36
  /** The first chant with `chant workspace ref-gate` (pre-receive, pre-push, check, status, attach, install) and `refs` in `.chant/trust.json`, the checks a ref update needs evidence for (#4867). */
@@ -50,15 +50,24 @@ export declare function chantPackageSourceTarget(specifier: string, parentPath:
50
50
  * registration covers this process, so a caller that registers its own
51
51
  * CommonJS hook from source knows not to add a second one.
52
52
  */
53
- export declare function ensureTypeScriptLoader(): boolean;
53
+ export declare function ensureTypeScriptLoader(projectDir?: string): boolean;
54
+ /**
55
+ * #5263 — where tsx resolves from: chant's own install first, then the
56
+ * project's (`projectDir`, then the working directory). chant run through
57
+ * `npx @intentius/chant@<v>` lives in npx's cache, where tsx is not
58
+ * installed, while the project has it in its `node_modules`. Returns the
59
+ * path or URL to resolve from, or undefined when neither has tsx.
60
+ */
61
+ export declare function tsxResolvedFrom(projectDir?: string): string | undefined;
54
62
  /**
55
63
  * Whether this process can load a TypeScript module such as
56
64
  * `chant.config.ts`: always from source, where a loader already runs chant
57
- * itself, and in the compiled CLI when tsx resolves from chant's install.
65
+ * itself, and in the compiled CLI when tsx resolves from chant's install or
66
+ * the project's (#5263).
58
67
  * Nothing is registered; `chant release init` asks before it writes a
59
68
  * config it would have to read back.
60
69
  */
61
- export declare function typeScriptLoaderAvailable(): boolean;
70
+ export declare function typeScriptLoaderAvailable(projectDir?: string): boolean;
62
71
  /**
63
72
  * #3981 — register tsx only when the module about to be imported is not
64
73
  * JavaScript. `pathOrUrl` is the resolved module, a path or a file URL. A
package/dist/ts-loader.js CHANGED
@@ -229,36 +229,52 @@ function installSourceResolution() {
229
229
  * registration covers this process, so a caller that registers its own
230
230
  * CommonJS hook from source knows not to add a second one.
231
231
  */
232
- export function ensureTypeScriptLoader() {
232
+ export function ensureTypeScriptLoader(projectDir) {
233
233
  const state = compiledState();
234
234
  if (!state)
235
235
  return false;
236
236
  if (state.tsx)
237
237
  return true;
238
- const load = (specifier) => requireOptionalPeer("tsx", specifier, "run TypeScript", import.meta.url);
238
+ const from = tsxResolvedFrom(projectDir) ?? import.meta.url;
239
+ const load = (specifier) => requireOptionalPeer("tsx", specifier, "run TypeScript", from);
239
240
  load("tsx/cjs/api").register();
240
241
  load("tsx/esm/api").register();
241
242
  state.tsx = true;
242
243
  return true;
243
244
  }
245
+ /**
246
+ * #5263 — where tsx resolves from: chant's own install first, then the
247
+ * project's (`projectDir`, then the working directory). chant run through
248
+ * `npx @intentius/chant@<v>` lives in npx's cache, where tsx is not
249
+ * installed, while the project has it in its `node_modules`. Returns the
250
+ * path or URL to resolve from, or undefined when neither has tsx.
251
+ */
252
+ export function tsxResolvedFrom(projectDir) {
253
+ const bases = [import.meta.url, ...[projectDir, process.cwd()].filter((d) => d !== undefined).map((d) => join(d, "package.json"))];
254
+ for (const base of bases) {
255
+ try {
256
+ nodeModule.createRequire(base).resolve("tsx/cjs/api");
257
+ return base;
258
+ }
259
+ catch {
260
+ // Not installed where this base resolves from.
261
+ }
262
+ }
263
+ return undefined;
264
+ }
244
265
  /**
245
266
  * Whether this process can load a TypeScript module such as
246
267
  * `chant.config.ts`: always from source, where a loader already runs chant
247
- * itself, and in the compiled CLI when tsx resolves from chant's install.
268
+ * itself, and in the compiled CLI when tsx resolves from chant's install or
269
+ * the project's (#5263).
248
270
  * Nothing is registered; `chant release init` asks before it writes a
249
271
  * config it would have to read back.
250
272
  */
251
- export function typeScriptLoaderAvailable() {
273
+ export function typeScriptLoaderAvailable(projectDir) {
252
274
  const state = compiledState();
253
275
  if (!state || state.tsx)
254
276
  return true;
255
- try {
256
- nodeModule.createRequire(import.meta.url).resolve("tsx/cjs/api");
257
- return true;
258
- }
259
- catch {
260
- return false;
261
- }
277
+ return tsxResolvedFrom(projectDir) !== undefined;
262
278
  }
263
279
  /**
264
280
  * #3981 — register tsx only when the module about to be imported is not