@intentius/chant 0.124.103 → 0.124.105
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/audit/secrets.d.ts +6 -0
- package/dist/audit/secrets.js +9 -2
- package/dist/capabilities/templates.d.ts +66 -3
- package/dist/capabilities/templates.js +220 -81
- package/dist/cli/commands/import-index.d.ts +15 -0
- package/dist/cli/commands/import-index.js +37 -3
- package/dist/cli/handlers/lifecycle.js +6 -0
- package/dist/cli/handlers/release-config.d.ts +15 -0
- package/dist/cli/handlers/release-config.js +58 -0
- package/dist/cli/handlers/release-doctor.js +8 -3
- package/dist/cli/handlers/release-init.js +7 -4
- package/dist/cli/handlers/release.js +36 -3
- package/dist/cli/handlers/search.d.ts +1 -1
- package/dist/cli/handlers/search.js +24 -2
- package/dist/cli/main.js +12 -2
- package/dist/cli/parse-args.js +9 -2
- package/dist/cli/registry.d.ts +2 -0
- package/dist/cli/release-commands/cut.js +3 -0
- package/dist/cli/release-commands/doctor.js +5 -2
- package/dist/cloud-lister/aws.d.ts +9 -0
- package/dist/cloud-lister/aws.js +20 -0
- package/dist/config-import.js +26 -4
- package/dist/config.d.ts +24 -0
- package/dist/config.js +6 -0
- package/dist/floor-table.data.js +8 -6
- package/dist/floor-table.js +3 -1
- package/dist/graph-refs.d.ts +22 -0
- package/dist/graph-refs.js +20 -11
- package/dist/lifecycle/cloud-index.d.ts +6 -0
- package/dist/lifecycle/cloud-index.js +32 -5
- package/dist/lifecycle/derive-edges.d.ts +1 -1
- package/dist/lifecycle/derive-edges.js +5 -3
- package/dist/lifecycle/identity-match.d.ts +18 -2
- package/dist/lifecycle/identity-match.js +10 -5
- package/dist/lifecycle/index-drift.d.ts +13 -0
- package/dist/lifecycle/index-drift.js +21 -3
- package/dist/lifecycle/index-import.d.ts +24 -2
- package/dist/lifecycle/index-import.js +61 -9
- package/dist/lifecycle/index-join.d.ts +1 -1
- package/dist/lifecycle/index-join.js +1 -1
- package/dist/lifecycle/publish-declaration.d.ts +6 -0
- package/dist/lifecycle/publish-declaration.js +18 -1
- package/dist/lifecycle/publish-forge.d.ts +2 -0
- package/dist/lifecycle/publish-forge.js +3 -1
- package/dist/lifecycle/publish-oci.d.ts +27 -0
- package/dist/lifecycle/publish-oci.js +63 -8
- package/dist/lifecycle/release-artifacts.js +3 -1
- package/dist/lifecycle/release-at.d.ts +5 -1
- package/dist/lifecycle/release-at.js +69 -4
- package/dist/lifecycle/release-changelog.d.ts +18 -5
- package/dist/lifecycle/release-changelog.js +22 -10
- package/dist/lifecycle/release-cut.d.ts +13 -1
- package/dist/lifecycle/release-cut.js +3 -0
- package/dist/lifecycle/release-doctor.d.ts +10 -0
- package/dist/lifecycle/release-doctor.js +84 -14
- package/dist/lifecycle/release-green.d.ts +5 -2
- package/dist/lifecycle/release-green.js +40 -8
- package/dist/lifecycle/release-images.d.ts +39 -3
- package/dist/lifecycle/release-images.js +84 -7
- package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
- package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
- package/dist/lifecycle/release-init.d.ts +38 -7
- package/dist/lifecycle/release-init.js +298 -52
- package/dist/lifecycle/release-next.d.ts +1 -1
- package/dist/lifecycle/release-next.js +9 -4
- package/dist/local-chant.d.ts +3 -0
- package/dist/local-chant.js +28 -2
- package/dist/release-floors.d.ts +10 -6
- package/dist/release-floors.js +10 -6
- package/dist/ts-loader.d.ts +12 -3
- package/dist/ts-loader.js +27 -11
- package/dist/wave-runtime.mjs +292 -291
- package/dist/workspace/capabilities-contract.d.ts +15 -5
- package/dist/workspace/capabilities-contract.js +7 -4
- package/dist/workspace/capabilities.schema.json +45 -1
- package/dist/workspace/catalog-edges.d.ts +22 -0
- package/dist/workspace/catalog-edges.js +23 -0
- package/dist/workspace/release-changed.d.ts +2 -0
- package/dist/workspace/release-changed.js +7 -2
- package/dist/workspace/release-steps/doctor.js +2 -1
- package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
- package/dist/workspace/release-steps/goreleaser.js +12 -6
- package/dist/workspace/release-toolchains.d.ts +6 -0
- package/dist/workspace/release-toolchains.js +8 -0
- package/dist/workspace/release-train-workflow.d.ts +18 -0
- package/dist/workspace/release-train-workflow.js +135 -7
- package/dist/workspace/release-train.js +1 -1
- package/dist/workspace/release-workflow.d.ts +26 -0
- package/dist/workspace/release-workflow.js +60 -12
- package/dist/workspace/train-artifacts.js +3 -4
- package/dist/workspace/train-cut.d.ts +22 -1
- package/dist/workspace/train-cut.js +80 -16
- package/package.json +2 -2
|
@@ -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
|
|
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
|
-
|
|
538
|
-
|
|
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
|
-
|
|
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
|
-
|
|
577
|
-
|
|
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;
|
|
@@ -692,9 +771,17 @@ export function planRelease(facts, opts) {
|
|
|
692
771
|
}
|
|
693
772
|
/** The environment a planned train is recorded for. */
|
|
694
773
|
export const TRAIN_ENV = "npm";
|
|
774
|
+
/** The directory a train member init makes for what no workspace package holds (#5271), from the project root. */
|
|
775
|
+
export const TRAIN_OWN_DIR = "release";
|
|
776
|
+
/** The rule by which init gives a train member what the project builds besides its packages (#5271), as the plan's reasons print it. */
|
|
777
|
+
export const TRAIN_OWNERSHIP_RULE = `an image, chart or Python or Rust package belongs to the train member whose directory holds its file; what no member's directory holds gets a member of its own at ${TRAIN_OWN_DIR}/<name>, one per directory, whose entries name the files with ../.. and whose release.sources names that directory, so release changed releases it when the files change`;
|
|
778
|
+
/** A workspace package a train releases: an npm package, or a VS Code extension (#5271). */
|
|
779
|
+
const trainPackage = (p) => p.name !== null && !p.private;
|
|
695
780
|
/**
|
|
696
781
|
* Whether the project's npm, pnpm or yarn workspaces can release as a train:
|
|
697
|
-
* one member per publishable package
|
|
782
|
+
* one member per publishable package or VS Code extension (#5154, #5271),
|
|
783
|
+
* with the images, charts and Python or Rust package beside them given to a
|
|
784
|
+
* member by {@link TRAIN_OWNERSHIP_RULE}. `why` says why a project with
|
|
698
785
|
* several packages gets one release instead, and is null for a project with
|
|
699
786
|
* fewer than two.
|
|
700
787
|
*/
|
|
@@ -702,28 +789,20 @@ export function trainFit(facts) {
|
|
|
702
789
|
const node = facts.node;
|
|
703
790
|
if (!node?.workspaces)
|
|
704
791
|
return { train: false, why: null };
|
|
705
|
-
const
|
|
706
|
-
const
|
|
707
|
-
const rootPublished = published(node.root);
|
|
792
|
+
const packages = node.workspaces.filter(trainPackage);
|
|
793
|
+
const rootPublished = trainPackage(node.root);
|
|
708
794
|
if (packages.length + (rootPublished ? 1 : 0) < 2)
|
|
709
795
|
return { train: false, why: null };
|
|
710
796
|
if (rootPublished)
|
|
711
797
|
return { train: false, why: `the root package ${node.root.name} is published too, and a train releases the packages below the root` };
|
|
712
|
-
const ext = [node.root, ...node.workspaces].find((p) => p.vscode && !p.private && p.name);
|
|
713
|
-
if (ext)
|
|
714
|
-
return { train: false, why: `${ext.name} is a VS Code extension, and release init makes a train's members of npm packages only` };
|
|
715
798
|
if (facts.goreleaser)
|
|
716
|
-
return { train: false, why: `${facts.goreleaser.file}
|
|
717
|
-
if (facts.dockerfiles.length > 0)
|
|
718
|
-
return { train: false, why: `${facts.dockerfiles[0]} builds an image, and release init makes a train's members of npm packages only, with none to build it` };
|
|
719
|
-
if ((facts.charts?.length ?? 0) > 0)
|
|
720
|
-
return { train: false, why: `${facts.charts[0].dir}/Chart.yaml is a chart packed at the cut, and release init makes a train's members of npm packages only, with none to pack it` };
|
|
799
|
+
return { train: false, why: `${facts.goreleaser.file} runs goreleaser at the repository root, and a train member runs it in its own directory, where its builds and dist would not be the root's` };
|
|
721
800
|
if (facts.nfpm)
|
|
722
|
-
return { train: false, why: `${facts.nfpm.file}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (
|
|
726
|
-
return { train: false, why:
|
|
801
|
+
return { train: false, why: `${facts.nfpm.file} packs files by paths from the repository root, and a train member runs nfpm in its own directory` };
|
|
802
|
+
const r = facts.registries;
|
|
803
|
+
const other = r?.maven ? "pom.xml" : r?.dotnet ? r.dotnet.projects[0].file : r?.ruby ? r.ruby.gemspec : null;
|
|
804
|
+
if (other)
|
|
805
|
+
return { train: false, why: `${other} builds at the repository root, and release init makes no train member for it` };
|
|
727
806
|
return { train: true };
|
|
728
807
|
}
|
|
729
808
|
/** A workspace member name (lowercase letters, digits and dashes, at most 40) for a package. */
|
|
@@ -736,10 +815,15 @@ function ownPrefixes(h, pkg, member) {
|
|
|
736
815
|
const names = new Set([pkg.name, pkg.name?.replace(/^@[^/]+\//, ""), member, pkg.dir, posix.basename(pkg.dir)].filter((n) => !!n));
|
|
737
816
|
return [h.prefix, ...h.others.map((o) => o.prefix)].filter((p) => p !== null && p !== "" && names.has(p.replace(/[/@_-]v?$/, "")));
|
|
738
817
|
}
|
|
818
|
+
/** `path` (from the project root) relative to `dir`, `.` for the directory itself. */
|
|
819
|
+
const relTo = (dir, path) => posix.relative(dir === "." ? "" : dir, path === "." ? "" : path) || ".";
|
|
739
820
|
/**
|
|
740
821
|
* Plan a train for a project {@link trainFit} accepts: a member per
|
|
741
|
-
* publishable workspace package, each stamping and
|
|
742
|
-
* package,
|
|
822
|
+
* publishable workspace package or VS Code extension, each stamping and
|
|
823
|
+
* publishing its own package, the images and charts each member's
|
|
824
|
+
* directory holds, a member at `release/<name>` for each other directory
|
|
825
|
+
* that holds an image, a chart, or a Python or Rust package (#5271), and the
|
|
826
|
+
* root's `release.train` with a dispatched workflow.
|
|
743
827
|
*/
|
|
744
828
|
export function planTrain(facts, opts) {
|
|
745
829
|
const node = facts.node;
|
|
@@ -747,86 +831,248 @@ export function planTrain(facts, opts) {
|
|
|
747
831
|
const notes = [];
|
|
748
832
|
const registry = [];
|
|
749
833
|
const forge = facts.workflowForge;
|
|
750
|
-
const
|
|
834
|
+
const named = node.workspaces.filter((p) => p.name);
|
|
835
|
+
const packages = dependencyOrder(named.filter(trainPackage));
|
|
836
|
+
const npmPackages = packages.filter((p) => !p.vscode);
|
|
837
|
+
const { file: workflowFile, adopted } = releaseWorkflowFile(facts, npmPackages.length > 0, notes);
|
|
751
838
|
const workflowName = posix.basename(workflowFile);
|
|
752
839
|
const env = TRAIN_ENV;
|
|
753
|
-
const
|
|
754
|
-
const packages = dependencyOrder(named.filter((p) => !p.private && !p.vscode));
|
|
840
|
+
const repo = facts.origin?.repo ?? "this repository";
|
|
755
841
|
const skipped = named.filter((p) => p.private);
|
|
756
842
|
const names = new Set(packages.map((p) => p.name));
|
|
757
843
|
const greenReasons = [];
|
|
758
844
|
const green = greenOf(facts, greenReasons, notes);
|
|
845
|
+
const workflow = { trigger: "dispatch" };
|
|
846
|
+
const addEnv = (k, v) => void (workflow.env = { ...(workflow.env ?? {}), [k]: v });
|
|
759
847
|
// Member names, unique.
|
|
760
848
|
const used = new Set();
|
|
761
|
-
const
|
|
762
|
-
const base = memberNameOf(p);
|
|
849
|
+
const unique = (base) => {
|
|
763
850
|
let name = base;
|
|
764
851
|
for (let i = 2; used.has(name); i++)
|
|
765
852
|
name = `${base.slice(0, 38)}-${i}`;
|
|
766
853
|
used.add(name);
|
|
767
854
|
return name;
|
|
768
|
-
}
|
|
769
|
-
// Tags: a
|
|
855
|
+
};
|
|
856
|
+
// Tags: a member's own history keeps its prefix; tags shared by every member are the root's legacy tags.
|
|
770
857
|
const h = facts.tags;
|
|
771
858
|
const claimed = new Set();
|
|
772
|
-
const
|
|
773
|
-
const
|
|
774
|
-
const own = ownPrefixes(h, p, name);
|
|
859
|
+
const tagged = (release, who, name) => {
|
|
860
|
+
const own = ownPrefixes(h, who, name);
|
|
775
861
|
for (const o of own)
|
|
776
862
|
claimed.add(o);
|
|
777
863
|
const template = own.find(templatePrefix);
|
|
778
|
-
|
|
864
|
+
release.tag = template ? `${template}{version}` : "{member}/v{version}";
|
|
779
865
|
const legacy = own.filter((o) => o !== template);
|
|
780
866
|
if (legacy.length > 0)
|
|
781
867
|
release.legacyTags = legacy;
|
|
782
868
|
release.green = green;
|
|
869
|
+
};
|
|
870
|
+
const members = packages.map((p) => {
|
|
871
|
+
const name = unique(memberNameOf(p));
|
|
872
|
+
const release = {};
|
|
873
|
+
tagged(release, p, name);
|
|
783
874
|
const internal = p.deps.some((d) => names.has(d) && d !== p.name);
|
|
784
875
|
release.version = internal ? { packages: ["."], ranges: "train" } : { packages: ["."] };
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
876
|
+
const publish = [];
|
|
877
|
+
const what = [];
|
|
878
|
+
if (p.vscode) {
|
|
879
|
+
const vsix = `dist/${p.name.replace(/^@[^/]+\//, "")}.vsix`;
|
|
880
|
+
publish.push({ type: "marketplace", marketplace: "vscode", vsix }, { type: "marketplace", marketplace: "openvsx", vsix, auth: "trusted-publishing" });
|
|
881
|
+
what.push(`${p.name} stamped with its label and published to the VS Code Marketplace and Open VSX from ${vsix}`);
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
const target = { type: "npm", packages: ["."] };
|
|
885
|
+
if (p.name.startsWith("@") && p.access === null)
|
|
886
|
+
target.access = "public";
|
|
887
|
+
publish.push(target);
|
|
888
|
+
what.push(`${p.name} stamped with its label and published to npm${target.access ? ' with access "public"' : ""}`);
|
|
889
|
+
}
|
|
890
|
+
release.publish = publish;
|
|
891
|
+
return { name, dir: p.dir, package: p.name, release, what, source: p.dir, npm: !p.vscode };
|
|
790
892
|
});
|
|
893
|
+
// #5271: what the members' directories don't hold gets a member at release/<name>, one per directory.
|
|
894
|
+
const ownerOf = (path) => {
|
|
895
|
+
let best = null;
|
|
896
|
+
for (const m of members)
|
|
897
|
+
if (m.package !== null && (path === m.dir || path.startsWith(`${m.dir}/`)) && (!best || m.dir.length > best.dir.length))
|
|
898
|
+
best = m;
|
|
899
|
+
return best;
|
|
900
|
+
};
|
|
901
|
+
const fallbackName = facts.origin?.repo.split("/").pop() ?? node.root.name?.replace(/^@[^/]+\//, "") ?? "app";
|
|
902
|
+
const ownMember = (source, base) => {
|
|
903
|
+
const found = members.find((m) => m.package === null && m.source === source);
|
|
904
|
+
if (found)
|
|
905
|
+
return found;
|
|
906
|
+
const name = unique(memberNameOf({ name: base, dir: source === "." ? fallbackName : source }));
|
|
907
|
+
const back = relTo(`${TRAIN_OWN_DIR}/${name}`, source);
|
|
908
|
+
const release = {};
|
|
909
|
+
tagged(release, { name: null, dir: `${TRAIN_OWN_DIR}/${name}` }, name);
|
|
910
|
+
release.sources = [back];
|
|
911
|
+
const m = { name, dir: `${TRAIN_OWN_DIR}/${name}`, package: null, release, what: [], source, npm: false };
|
|
912
|
+
members.push(m);
|
|
913
|
+
return m;
|
|
914
|
+
};
|
|
915
|
+
/** A path from the project root as the member names it: from its own directory, or back from release/<name>. */
|
|
916
|
+
const fromMember = (m, path) => relTo(m.dir, path);
|
|
917
|
+
const push = (m, key, v) => void (m.release[key] = [...(m.release[key] ?? []), v]);
|
|
918
|
+
const stampFile = (m, file) => {
|
|
919
|
+
const version = m.release.version ?? {};
|
|
920
|
+
m.release.version = { ...version, files: [...(version.files ?? []), fromMember(m, file)] };
|
|
921
|
+
};
|
|
922
|
+
// Python and Rust packages at the root, before the images, so the root's member is named for the package.
|
|
923
|
+
const py = facts.python;
|
|
924
|
+
const forgejo = forge === "forgejo";
|
|
925
|
+
if (py?.pyproject && py.name) {
|
|
926
|
+
const m = ownMember(".", py.name);
|
|
927
|
+
push(m, "artifacts", { name: "python", build: `python -m pip install build && python -m build --outdir dist ${fromMember(m, ".")}`, outputs: ["dist/*"] });
|
|
928
|
+
push(m, "publish", { type: "pypi", files: ["artifact:python"], auth: forgejo ? "token" : "trusted-publishing" });
|
|
929
|
+
if (py.version)
|
|
930
|
+
stampFile(m, "pyproject.toml");
|
|
931
|
+
else
|
|
932
|
+
notes.push(`pyproject.toml has no static version (it is dynamic, or unset), so member ${m.name} does not stamp it: the build takes the version from wherever the project sets it.`);
|
|
933
|
+
m.what.push(`${py.name} built with python -m build into its own dist and published to PyPI ${forgejo ? "with the token in PYPI_TOKEN" : "with trusted publishing"}${py.version ? ", its label stamped into the root's pyproject.toml" : ""}`);
|
|
934
|
+
if (forgejo) {
|
|
935
|
+
addEnv("PYPI_TOKEN", "${{ secrets.PYPI_TOKEN }}");
|
|
936
|
+
registry.push(`PyPI ${py.name}: create an API token for the project on pypi.org and store it as the secret PYPI_TOKEN; PyPI has no trusted publisher for this forge.`);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
registry.push(`PyPI ${py.name}: on pypi.org add a trusted publisher to the project's publishing settings (a pending publisher if the project does not exist yet) for ${forge === "gitlab" ? `GitLab CI/CD naming ${repo} and the top-level pipeline file .gitlab-ci.yml` : `GitHub Actions naming ${repo} and the workflow file ${workflowName}`}.${forge === "github" ? " A GitHub publisher can name an environment; leave it empty, since the workflow runs in none." : ""}`);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
else if (py)
|
|
943
|
+
notes.push(`${py.name ?? "The Python package"} is in no member and not published to PyPI: ${py.pyproject ? "pyproject.toml has no [project] name" : "there is no pyproject.toml for python -m build to read"}.`);
|
|
944
|
+
const rs = facts.rust;
|
|
945
|
+
if (rs && !rs.unpublishable && (rs.name || rs.workspace)) {
|
|
946
|
+
const m = ownMember(".", rs.name ?? fallbackName);
|
|
947
|
+
push(m, "publish", { type: "cargo", manifest: fromMember(m, "Cargo.toml") });
|
|
948
|
+
if (rs.version)
|
|
949
|
+
stampFile(m, "Cargo.toml");
|
|
950
|
+
else
|
|
951
|
+
notes.push(`Cargo.toml has no [package] or [workspace.package] version at the root, so member ${m.name} does not stamp it: add the member crates' Cargo.toml files to its release.version.files.`);
|
|
952
|
+
m.what.push(`${rs.name ?? "the workspace's crates"} published with cargo publish from the root's Cargo.toml${rs.version ? ", its label stamped into it" : ""}`);
|
|
953
|
+
registry.push(`crates.io ${rs.name ?? "each crate"}: ${forge === "github" ? `add a trusted publisher to ${rs.name ? "the crate" : "each crate"} on crates.io for GitHub Actions naming ${repo} and the workflow file ${workflowName}. A crate's first version can't be published that way: publish it by hand, or store a token that may publish new crates as the secret CARGO_REGISTRY_TOKEN and set CARGO_REGISTRY_TOKEN: "\${{ secrets.CARGO_REGISTRY_TOKEN }}" in the root's release.workflow.env.` : `create an API token that may publish ${rs.name ? "the crate" : "the crates"} and store it as the ${forge === "gitlab" ? "masked CI/CD variable" : "secret"} CARGO_REGISTRY_TOKEN${forge === "gitlab" ? "." : ", and set CARGO_REGISTRY_TOKEN: \"${{ secrets.CARGO_REGISTRY_TOKEN }}\" in the root's release.workflow.env."}`}`);
|
|
954
|
+
}
|
|
955
|
+
else if (rs)
|
|
956
|
+
notes.push(`${rs.name ?? "The crate"} is in no member and not published to crates.io: ${rs.unpublishable ? "Cargo.toml sets publish = false" : "Cargo.toml has no [package] name or [workspace]"}.`);
|
|
957
|
+
// Images: each in the member whose directory holds its Dockerfile, else in release/<name>.
|
|
958
|
+
const usedImages = new Set();
|
|
959
|
+
const imageCount = facts.dockerfiles.length;
|
|
960
|
+
for (const dockerfile of facts.dockerfiles) {
|
|
961
|
+
let image = imageName(dockerfile, fallbackName);
|
|
962
|
+
while (usedImages.has(image))
|
|
963
|
+
image = `${image}-${usedImages.size}`;
|
|
964
|
+
usedImages.add(image);
|
|
965
|
+
const dir = posix.dirname(dockerfile);
|
|
966
|
+
const m = ownerOf(dockerfile) ?? ownMember(dir, image);
|
|
967
|
+
const context = fromMember(m, dir);
|
|
968
|
+
// In a package npm publishes, the archive is written outside dist, which npm packs.
|
|
969
|
+
const archive = m.npm ? imageArchiveBesideGoreleaser(image) : `dist/images/${image}.tar`;
|
|
970
|
+
push(m, "images", { name: image, dockerfile: fromMember(m, dockerfile), ...(context === "." ? {} : { context }), ...(m.npm ? { archive } : {}) });
|
|
971
|
+
const repository = imageRepository(facts.origin, image, imageCount === 1);
|
|
972
|
+
if (repository) {
|
|
973
|
+
push(m, "publish", { type: "oci", image: archive, repository });
|
|
974
|
+
m.what.push(`the image ${image} built from ${dockerfile} and pushed to ${repository}`);
|
|
975
|
+
if (repository.startsWith("ghcr.io/"))
|
|
976
|
+
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.`);
|
|
977
|
+
else
|
|
978
|
+
registry.push(`${repository}: set OCI_USERNAME and OCI_PASSWORD for the release workflow, as ${forge === "gitlab" ? "masked CI/CD variables" : "secrets in the root's release.workflow.env"}, with push access to the registry.`);
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
m.what.push(`the image ${image} built from ${dockerfile}`);
|
|
982
|
+
notes.push(`${dockerfile} is built into member ${m.name}'s release.images as ${image}, and no oci target is declared: origin names no registry chant knows. Add { type: "oci", image: "${archive}", repository: "<registry>/<name>" } to its release.publish.`);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
// Helm charts: the same rule, a helm target per member that packs any.
|
|
986
|
+
const charts = facts.charts ?? [];
|
|
987
|
+
const chartRepository = imageRepository(facts.origin, "charts", false);
|
|
988
|
+
const placed = charts.map((c) => {
|
|
989
|
+
const chartName = (c.name ?? posix.basename(c.dir === "." ? fallbackName : c.dir)).toLowerCase().replace(/[^a-z0-9._-]+/g, "-");
|
|
990
|
+
return { c, chartName, m: ownerOf(c.dir) ?? ownMember(c.dir, chartName) };
|
|
991
|
+
});
|
|
992
|
+
for (const { c, chartName, m } of placed) {
|
|
993
|
+
const entries = m.release.artifacts ?? [];
|
|
994
|
+
let entry = placed.filter((x) => x.m === m).length === 1 ? "chart" : `chart-${chartName}`;
|
|
995
|
+
while (entries.some((e) => e.name === entry))
|
|
996
|
+
entry = `${entry}-${entries.length}`;
|
|
997
|
+
push(m, "artifacts", { name: entry, helm: m.npm ? { chart: fromMember(m, c.dir), dir: "build" } : { chart: fromMember(m, c.dir) } });
|
|
998
|
+
const target = (m.release.publish ?? []).find((t) => t.type === "helm");
|
|
999
|
+
if (target)
|
|
1000
|
+
target.charts.push(`artifact:${entry}`);
|
|
1001
|
+
else if (chartRepository)
|
|
1002
|
+
push(m, "publish", { type: "helm", charts: [`artifact:${entry}`], oci: { repository: chartRepository } });
|
|
1003
|
+
m.what.push(`the chart ${c.dir === "." ? "Chart.yaml" : `${c.dir}/Chart.yaml`} packed with its label${chartRepository ? ` and pushed to ${chartRepository}/${chartName}` : ""}`);
|
|
1004
|
+
}
|
|
1005
|
+
if (charts.length > 0) {
|
|
1006
|
+
if (chartRepository) {
|
|
1007
|
+
if (chartRepository.startsWith("ghcr.io/"))
|
|
1008
|
+
registry.push(`${chartRepository}: the workflow pushes the charts with the run's token. The first push makes each package private; make it public in the package's settings if it should be.`);
|
|
1009
|
+
else
|
|
1010
|
+
registry.push(`${chartRepository}: set OCI_USERNAME and OCI_PASSWORD for the release workflow, as ${forge === "gitlab" ? "masked CI/CD variables" : "secrets in the root's release.workflow.env"}, with push access to the registry.`);
|
|
1011
|
+
}
|
|
1012
|
+
else
|
|
1013
|
+
notes.push(`The charts are packed into their members' release.artifacts, and no helm target is declared: origin names no registry chant knows. Add { type: "helm", charts: ["artifact:<entry>"], oci: { repository: "<registry>/<path>" } } to each member's release.publish.`);
|
|
1014
|
+
}
|
|
1015
|
+
// The members' tags read the old ones: shared tags are the root's.
|
|
791
1016
|
const shared = [h.prefix, ...h.others.map((o) => o.prefix)].filter((p) => p !== null && p !== "" && !claimed.has(p));
|
|
792
1017
|
const release = { train: shared.length > 0 ? { env, first: "together" } : { env } };
|
|
793
|
-
reasons.push(`release.train: ${
|
|
1018
|
+
reasons.push(`release.train: ${members.length} members, each released at its own version; chant workspace train cut ${env} cuts every member that changed since its last release, and the train publishes them in dependency order${shared.length > 0 ? `. first "together": the packages have shared ${shared.map((p) => `${p}<version>`).join(" and ")} releases, so the first train gives every member one label past the highest version any has, and each later train labels each on its own` : ""}`);
|
|
1019
|
+
if (members.some((m) => m.package === null) || members.some((m) => m.release.images || m.release.artifacts))
|
|
1020
|
+
reasons.push(`members: ${TRAIN_OWNERSHIP_RULE}`);
|
|
794
1021
|
if (shared.length > 0) {
|
|
795
1022
|
release.legacyTags = shared;
|
|
796
|
-
reasons.push(`release.legacyTags ${JSON.stringify(shared)}: chant release changed reads the newest ${shared.map((p) => `${p}<version>`).join(" or ")} tag as every
|
|
1023
|
+
reasons.push(`release.legacyTags ${JSON.stringify(shared)}: chant release changed reads the newest ${shared.map((p) => `${p}<version>`).join(" or ")} tag as every member's last release until the train has cut one`);
|
|
797
1024
|
}
|
|
798
1025
|
release.green = green;
|
|
799
1026
|
reasons.push(...greenReasons);
|
|
800
|
-
const workflow = { trigger: "dispatch" };
|
|
801
1027
|
if (adopted)
|
|
802
1028
|
workflow.file = workflowFile;
|
|
1029
|
+
const extensions = packages.filter((p) => p.vscode);
|
|
1030
|
+
// A GitLab job gets the project's CI/CD variables as they are.
|
|
1031
|
+
if (extensions.length > 0 && forge !== "gitlab")
|
|
1032
|
+
addEnv("VSCE_PAT", "${{ secrets.VSCE_PAT }}");
|
|
803
1033
|
nodeWorkflow(node, opts, workflow, reasons);
|
|
804
|
-
release
|
|
1034
|
+
// Keys in the order the one release writes them.
|
|
1035
|
+
const { env: wfEnv, ...wfRest } = workflow;
|
|
1036
|
+
release.workflow = wfEnv ? { ...wfRest, env: wfEnv } : wfRest;
|
|
805
1037
|
reasons.push(`release.workflow: ${workflowFile}, started by hand with the levels, cuts the train from a green commit and publishes it`);
|
|
806
1038
|
if (adopted)
|
|
807
1039
|
reasons.push(`release.workflow.file ${workflowFile}: it runs npm publish today, so the npm trusted publishers that name it keep working; the train workflow replaces it rather than publishing from a second file`);
|
|
808
1040
|
for (const m of members) {
|
|
809
1041
|
const tag = m.release.tag;
|
|
810
|
-
const ranges = m.release.version
|
|
811
|
-
const
|
|
812
|
-
reasons.push(`${
|
|
1042
|
+
const ranges = m.release.version?.ranges;
|
|
1043
|
+
const where = m.package === null ? `${m.dir}/chant.config.ts, member ${m.name}, a member of its own for ${m.source === "." ? "the repository root" : m.source} (release.sources ${JSON.stringify(m.release.sources)})` : `${m.dir}/chant.config.ts, member ${m.name}`;
|
|
1044
|
+
reasons.push(`${where}: ${m.what.join("; ")}, tagged ${tag}${ranges ? `; ranges "train", so its range on a sibling names the version the train gives it` : ""}${m.release.legacyTags ? `; its ${m.release.legacyTags.map((p) => `${p}<version>`).join(" and ")} tags read as earlier releases` : ""}`);
|
|
813
1045
|
}
|
|
814
1046
|
if (skipped.length > 0)
|
|
815
1047
|
notes.push(`Not published, being private: ${skipped.map((p) => p.name).join(", ")}. The train's publish job builds ${skipped.length === 1 ? "it" : "them"} when a member needs ${skipped.length === 1 ? "it" : "them"}.`);
|
|
816
|
-
const packed =
|
|
1048
|
+
const packed = npmPackages.filter((p) => !p.packList);
|
|
817
1049
|
if (packed.length > 0)
|
|
818
1050
|
notes.push(`npm packs a package's chant.config.ts with it unless package.json files or an .npmignore leaves it out: ${packed.map((p) => p.name).join(", ")} ${packed.length === 1 ? "has" : "have"} neither.`);
|
|
819
|
-
const
|
|
1051
|
+
for (const ext of extensions) {
|
|
1052
|
+
const vsix = `${ext.dir}/dist/${ext.name.replace(/^@[^/]+\//, "")}.vsix`;
|
|
1053
|
+
notes.push(`The build must write ${vsix}, such as with vsce package -o dist/${posix.basename(vsix)} in ${ext.dir}, and the VS Code Marketplace target needs vsce on PATH.`);
|
|
1054
|
+
}
|
|
1055
|
+
const anyDist = members.some((m) => m.release.images || m.release.artifacts) || extensions.length > 0;
|
|
1056
|
+
if (!facts.distIgnored && anyDist)
|
|
1057
|
+
notes.push("dist/ is not in .gitignore: the publish refuses a tree with build outputs git does not ignore.");
|
|
1058
|
+
if (facts.buildIgnored !== true && members.some((m) => m.npm && (m.release.images || m.release.artifacts)))
|
|
1059
|
+
notes.push("build/ is not in .gitignore: a member that publishes to npm writes its images and charts to build/, outside the dist npm packs, and the publish refuses a tree with build outputs git does not ignore.");
|
|
820
1060
|
for (const m of members) {
|
|
1061
|
+
if (!m.npm)
|
|
1062
|
+
continue;
|
|
821
1063
|
registry.push(adopted
|
|
822
1064
|
? `npm ${m.package}: keep the trusted publisher on npmjs.com that names ${repo} and the workflow file ${workflowName}, or add one naming them if the package has none, and allow npm dist-tag on it, since the reveal moves latest. If ${m.package} is not on npm yet, publish its first version by hand from ${m.dir} (npm publish) so it has settings; the train labels the next past it.`
|
|
823
1065
|
: `npm ${m.package}: on npmjs.com, add a trusted publisher for ${forge === "gitlab" ? `GitLab CI/CD naming ${repo} and the top-level config .gitlab-ci.yml` : `${forge === "github" ? "GitHub Actions" : "this forge"} naming ${repo} and the workflow file ${workflowName}`}, and allow npm dist-tag, since the reveal moves latest. Every package names the same file. If ${m.package} is not on npm yet, publish its first version by hand from ${m.dir} (npm publish) so it has settings; the train labels the next past it.`);
|
|
824
1066
|
}
|
|
1067
|
+
for (const ext of extensions) {
|
|
1068
|
+
registry.push(`VS Code Marketplace ${ext.publisher ?? "<publisher>"}.${ext.name}: create a personal access token with Marketplace (Manage) scope and store it as the ${forge === "gitlab" ? "masked CI/CD variable" : "repository secret"} VSCE_PAT.`);
|
|
1069
|
+
registry.push(`Open VSX ${ext.publisher ?? "<publisher>"}.${ext.name}: create the namespace ${ext.publisher ?? "<publisher>"} once, and add ${repo} with the workflow file ${workflowName} under the extension's trusted publishers at https://open-vsx.org/user-settings/trusted-publishers.`);
|
|
1070
|
+
}
|
|
825
1071
|
// #5216: a GitLab job token cannot push the train's tags.
|
|
826
1072
|
if (forge === "gitlab")
|
|
827
1073
|
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.`);
|
|
828
1074
|
const workspaceName = memberNameOf({ name: facts.origin?.repo.split("/").pop() ?? node.root.name ?? null, dir: facts.path ?? "workspace" }) || "workspace";
|
|
829
|
-
return { release, members, workspaceName, reasons, notes, registry, workflowFile, env };
|
|
1075
|
+
return { release, members: members.map(({ name, dir, package: pkg, release: r }) => ({ name, dir, package: pkg, release: r })), workspaceName, reasons, notes, registry, workflowFile, env };
|
|
830
1076
|
}
|
|
831
1077
|
const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
832
1078
|
/** A value as TypeScript source, objects and arrays on one line when short. */
|
|
@@ -88,7 +88,7 @@ export declare function nextLabel(input: {
|
|
|
88
88
|
yanked?: readonly string[];
|
|
89
89
|
}): string;
|
|
90
90
|
/** The commits in `from..to` touching `path` (from the repository root), newest first, merges left out. */
|
|
91
|
-
export declare function commitsTouching(top: string, from: string, to: string, path: string): NextCommit[];
|
|
91
|
+
export declare function commitsTouching(top: string, from: string, to: string, path: string | readonly string[]): NextCommit[];
|
|
92
92
|
/** The highest level of `commits`, or null when there are none. */
|
|
93
93
|
export declare function commitsBump(commits: readonly NextCommit[]): ReleaseBumpLevel | null;
|
|
94
94
|
/**
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
*/
|
|
39
39
|
import { execFileSync } from "node:child_process";
|
|
40
40
|
import { realpathSync } from "node:fs";
|
|
41
|
-
import { relative } from "node:path";
|
|
41
|
+
import { relative, resolve } from "node:path";
|
|
42
42
|
import { classifyCommit } from "./release-changelog.js";
|
|
43
43
|
import { consumedIntents, maxBump, pendingIntents, readIntents } from "./release-intents.js";
|
|
44
44
|
/** The first chant with `chant release next` and `chant release cut auto`, the label from the conventional commits and the `.chant/release/*.md` intent files since the member's previous release; a cut records the intent files it consumed (`intents` on its cut line), `release changed` computes each member's bump from them (`bumpFrom`, `intents`, `intent-pending`), notes generated from commits lead with their summaries, and a dispatched release workflow takes the label `auto` (#5159); with no release in the ledger the previous one is the newest version tag `release.tag` or `release.legacyTags` matches (#5200), and on 0.x a breaking commit bumps minor unless `release.breakingOnZero` is `major` (#5191). */
|
|
@@ -117,7 +117,9 @@ function git(top, args) {
|
|
|
117
117
|
}
|
|
118
118
|
/** The commits in `from..to` touching `path` (from the repository root), newest first, merges left out. */
|
|
119
119
|
export function commitsTouching(top, from, to, path) {
|
|
120
|
-
const
|
|
120
|
+
const paths = typeof path === "string" ? [path] : path;
|
|
121
|
+
const specs = paths.includes("") ? ["."] : paths.map((p) => `:(top,literal)${p}`);
|
|
122
|
+
const out = git(top, ["log", "--no-merges", "--format=%H%x00%B%x1e", `${from}..${to}`, "--", ...specs]);
|
|
121
123
|
if (out === null)
|
|
122
124
|
throw new ReleaseNextError("revision-unknown", `git could not list the commits ${from.slice(0, 12)}..${to.slice(0, 12)}`, "Fetch the full history of the branch.");
|
|
123
125
|
return out
|
|
@@ -226,8 +228,11 @@ export async function nextRelease(req) {
|
|
|
226
228
|
stable = { label: hit.label, commit: hit.commit, source: "tag", tag: hit.tag };
|
|
227
229
|
}
|
|
228
230
|
const intents = await memberPendingIntents(req.cwd, top, at, names, cuts);
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
+
const fromTop = (abs) => relative(realpathSync(top), abs).split("\\").join("/");
|
|
232
|
+
const path = fromTop(realpathOr(memberSourcePath(req.cwd)));
|
|
233
|
+
// #5271: release.sources count beside the member's own directory.
|
|
234
|
+
const sources = settings.sources.map((s) => fromTop(resolve(realpathOr(req.cwd), s))).filter((s) => s !== ".." && !s.startsWith("../"));
|
|
235
|
+
const commits = stable ? shiftOnZero(commitsTouching(top, stable.commit, at, [path, ...sources]), stable.label, settings.breakingOnZero) : [];
|
|
231
236
|
if (here) {
|
|
232
237
|
return { label: here.label, at, bump: null, alreadyCut: true, from: stable ?? { label: here.label, commit: at, source: "ledger" }, commits, intents: [] };
|
|
233
238
|
}
|
package/dist/local-chant.d.ts
CHANGED
|
@@ -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
|
*/
|
package/dist/local-chant.js
CHANGED
|
@@ -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
|
-
|
|
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
|