@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.
Files changed (93) hide show
  1. package/dist/audit/secrets.d.ts +6 -0
  2. package/dist/audit/secrets.js +9 -2
  3. package/dist/capabilities/templates.d.ts +66 -3
  4. package/dist/capabilities/templates.js +220 -81
  5. package/dist/cli/commands/import-index.d.ts +15 -0
  6. package/dist/cli/commands/import-index.js +37 -3
  7. package/dist/cli/handlers/lifecycle.js +6 -0
  8. package/dist/cli/handlers/release-config.d.ts +15 -0
  9. package/dist/cli/handlers/release-config.js +58 -0
  10. package/dist/cli/handlers/release-doctor.js +8 -3
  11. package/dist/cli/handlers/release-init.js +7 -4
  12. package/dist/cli/handlers/release.js +36 -3
  13. package/dist/cli/handlers/search.d.ts +1 -1
  14. package/dist/cli/handlers/search.js +24 -2
  15. package/dist/cli/main.js +12 -2
  16. package/dist/cli/parse-args.js +9 -2
  17. package/dist/cli/registry.d.ts +2 -0
  18. package/dist/cli/release-commands/cut.js +3 -0
  19. package/dist/cli/release-commands/doctor.js +5 -2
  20. package/dist/cloud-lister/aws.d.ts +9 -0
  21. package/dist/cloud-lister/aws.js +20 -0
  22. package/dist/config-import.js +26 -4
  23. package/dist/config.d.ts +24 -0
  24. package/dist/config.js +6 -0
  25. package/dist/floor-table.data.js +8 -6
  26. package/dist/floor-table.js +3 -1
  27. package/dist/graph-refs.d.ts +22 -0
  28. package/dist/graph-refs.js +20 -11
  29. package/dist/lifecycle/cloud-index.d.ts +6 -0
  30. package/dist/lifecycle/cloud-index.js +32 -5
  31. package/dist/lifecycle/derive-edges.d.ts +1 -1
  32. package/dist/lifecycle/derive-edges.js +5 -3
  33. package/dist/lifecycle/identity-match.d.ts +18 -2
  34. package/dist/lifecycle/identity-match.js +10 -5
  35. package/dist/lifecycle/index-drift.d.ts +13 -0
  36. package/dist/lifecycle/index-drift.js +21 -3
  37. package/dist/lifecycle/index-import.d.ts +24 -2
  38. package/dist/lifecycle/index-import.js +61 -9
  39. package/dist/lifecycle/index-join.d.ts +1 -1
  40. package/dist/lifecycle/index-join.js +1 -1
  41. package/dist/lifecycle/publish-declaration.d.ts +6 -0
  42. package/dist/lifecycle/publish-declaration.js +18 -1
  43. package/dist/lifecycle/publish-forge.d.ts +2 -0
  44. package/dist/lifecycle/publish-forge.js +3 -1
  45. package/dist/lifecycle/publish-oci.d.ts +27 -0
  46. package/dist/lifecycle/publish-oci.js +63 -8
  47. package/dist/lifecycle/release-artifacts.js +3 -1
  48. package/dist/lifecycle/release-at.d.ts +5 -1
  49. package/dist/lifecycle/release-at.js +69 -4
  50. package/dist/lifecycle/release-changelog.d.ts +18 -5
  51. package/dist/lifecycle/release-changelog.js +22 -10
  52. package/dist/lifecycle/release-cut.d.ts +13 -1
  53. package/dist/lifecycle/release-cut.js +3 -0
  54. package/dist/lifecycle/release-doctor.d.ts +10 -0
  55. package/dist/lifecycle/release-doctor.js +84 -14
  56. package/dist/lifecycle/release-green.d.ts +5 -2
  57. package/dist/lifecycle/release-green.js +40 -8
  58. package/dist/lifecycle/release-images.d.ts +39 -3
  59. package/dist/lifecycle/release-images.js +84 -7
  60. package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
  61. package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
  62. package/dist/lifecycle/release-init.d.ts +38 -7
  63. package/dist/lifecycle/release-init.js +298 -52
  64. package/dist/lifecycle/release-next.d.ts +1 -1
  65. package/dist/lifecycle/release-next.js +9 -4
  66. package/dist/local-chant.d.ts +3 -0
  67. package/dist/local-chant.js +28 -2
  68. package/dist/release-floors.d.ts +10 -6
  69. package/dist/release-floors.js +10 -6
  70. package/dist/ts-loader.d.ts +12 -3
  71. package/dist/ts-loader.js +27 -11
  72. package/dist/wave-runtime.mjs +292 -291
  73. package/dist/workspace/capabilities-contract.d.ts +15 -5
  74. package/dist/workspace/capabilities-contract.js +7 -4
  75. package/dist/workspace/capabilities.schema.json +45 -1
  76. package/dist/workspace/catalog-edges.d.ts +22 -0
  77. package/dist/workspace/catalog-edges.js +23 -0
  78. package/dist/workspace/release-changed.d.ts +2 -0
  79. package/dist/workspace/release-changed.js +7 -2
  80. package/dist/workspace/release-steps/doctor.js +2 -1
  81. package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
  82. package/dist/workspace/release-steps/goreleaser.js +12 -6
  83. package/dist/workspace/release-toolchains.d.ts +6 -0
  84. package/dist/workspace/release-toolchains.js +8 -0
  85. package/dist/workspace/release-train-workflow.d.ts +18 -0
  86. package/dist/workspace/release-train-workflow.js +135 -7
  87. package/dist/workspace/release-train.js +1 -1
  88. package/dist/workspace/release-workflow.d.ts +26 -0
  89. package/dist/workspace/release-workflow.js +60 -12
  90. package/dist/workspace/train-artifacts.js +3 -4
  91. package/dist/workspace/train-cut.d.ts +22 -1
  92. package/dist/workspace/train-cut.js +80 -16
  93. package/package.json +2 -2
@@ -0,0 +1,160 @@
1
+ /**
2
+ * `chant release init` for a goreleaser config that builds container images
3
+ * (#5269): its `dockers` (with `docker_manifests`) or `dockers_v2` read as
4
+ * one `release.images` Dockerfile entry and an `oci` target with the same
5
+ * repository, tags, per-platform tags, build arguments and labels, so a
6
+ * project that adopts the plan keeps publishing its image. What does not
7
+ * translate is named, never dropped without a word.
8
+ *
9
+ * goreleaser's templates map to chant's placeholders: `{{ .Version }}` is
10
+ * `{version}`. Any other template is not carried.
11
+ */
12
+ import { parseYAML } from "../yaml.js";
13
+ import { imageArchiveBesideGoreleaser } from "./release-images.js";
14
+ const VERSION = /\{\{\s*\.Version\s*\}\}/g;
15
+ /** A goreleaser template as a chant value, or null when it holds a template chant has no placeholder for. */
16
+ function template(t) {
17
+ const v = t.replace(VERSION, "{version}");
18
+ return /\{\{/.test(v) ? null : v;
19
+ }
20
+ /** `repo:tag` split at the tag's colon (a registry port's colon comes before the last slash). */
21
+ function splitRef(ref) {
22
+ const at = ref.lastIndexOf(":");
23
+ if (at <= ref.lastIndexOf("/"))
24
+ return null;
25
+ return { repository: ref.slice(0, at), tag: ref.slice(at + 1) };
26
+ }
27
+ const strings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === "string") : typeof v === "string" ? [v] : []);
28
+ /** `--build-arg=K=V`, `--label=K=V` and `--platform=...` flags into args and labels; the rest is not carried. */
29
+ function readFlags(flags, into) {
30
+ for (const f of flags) {
31
+ const m = /^--(build-arg|label)[= ]([^=\s]+)=(.*)$/.exec(f.trim());
32
+ if (m) {
33
+ const value = template(m[3]);
34
+ if (value === null)
35
+ into.unread.push(`the ${m[1]} ${m[2]}=${m[3]}, whose template chant has no placeholder for`);
36
+ else
37
+ (m[1] === "label" ? into.labels : into.args)[m[2]] = value;
38
+ }
39
+ else if (!/^--platform[= ]/.test(f.trim()))
40
+ into.unread.push(`the build flag ${f}`);
41
+ }
42
+ }
43
+ /** The image a goreleaser config builds, or null when it builds none with `dockers` or `dockers_v2`. */
44
+ export function goreleaserImage(text) {
45
+ let doc;
46
+ try {
47
+ doc = parseYAML(text);
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ if (!doc || typeof doc !== "object")
53
+ return null;
54
+ const unread = [];
55
+ const args = {};
56
+ const labels = {};
57
+ const flags = { args, labels, unread };
58
+ const platforms = [];
59
+ const tags = [];
60
+ const platformTags = new Set();
61
+ const repositories = new Set();
62
+ const dockerfiles = new Set();
63
+ const keys = [];
64
+ const addTag = (raw) => {
65
+ const t = template(raw);
66
+ if (t === null)
67
+ unread.push(`the tag ${raw}, whose template chant has no placeholder for`);
68
+ else if (!tags.includes(t))
69
+ tags.push(t);
70
+ };
71
+ const v2 = Array.isArray(doc.dockers_v2) ? doc.dockers_v2 : [];
72
+ const v1 = Array.isArray(doc.dockers) ? doc.dockers : [];
73
+ if (v2.length > 0) {
74
+ keys.push("dockers_v2");
75
+ for (const d of v2) {
76
+ for (const r of strings(d.images))
77
+ repositories.add(r);
78
+ dockerfiles.add(typeof d.dockerfile === "string" ? d.dockerfile : "Dockerfile");
79
+ for (const p of strings(d.platforms))
80
+ if (!platforms.includes(p))
81
+ platforms.push(p);
82
+ for (const t of strings(d.tags))
83
+ addTag(t);
84
+ for (const [k, v] of Object.entries(d.build_args ?? {})) {
85
+ const value = typeof v === "string" ? template(v) : null;
86
+ if (value === null)
87
+ unread.push(`the build argument ${k}, whose value chant can't carry`);
88
+ else
89
+ args[k] = value;
90
+ }
91
+ for (const [k, v] of Object.entries(d.labels ?? {})) {
92
+ const value = typeof v === "string" ? template(v) : null;
93
+ if (value === null)
94
+ unread.push(`the label ${k}, whose value chant can't carry`);
95
+ else
96
+ labels[k] = value;
97
+ }
98
+ readFlags(strings(d.flags), flags);
99
+ }
100
+ }
101
+ if (v1.length > 0) {
102
+ keys.push("dockers");
103
+ // The images each entry pushes: per platform, or the whole image when there are no manifests.
104
+ const manifests = Array.isArray(doc.docker_manifests) ? doc.docker_manifests : [];
105
+ if (manifests.length > 0)
106
+ keys.push("docker_manifests");
107
+ for (const d of v1) {
108
+ const goos = typeof d.goos === "string" ? d.goos : "linux";
109
+ const goarch = typeof d.goarch === "string" ? d.goarch : "amd64";
110
+ const variant = goarch === "arm" && d.goarm !== undefined ? `v${String(d.goarm)}` : "";
111
+ const platform = `${goos}/${goarch}${variant ? `/${variant}` : ""}`;
112
+ if (!platforms.includes(platform))
113
+ platforms.push(platform);
114
+ dockerfiles.add(typeof d.dockerfile === "string" ? d.dockerfile : "Dockerfile");
115
+ readFlags(strings(d.build_flag_templates), flags);
116
+ for (const ref of strings(d.image_templates)) {
117
+ const r = splitRef(ref);
118
+ if (!r) {
119
+ unread.push(`the image ${ref}, which names no tag`);
120
+ continue;
121
+ }
122
+ repositories.add(r.repository);
123
+ const t = template(r.tag);
124
+ const arch = `${goarch}${variant}`;
125
+ if (manifests.length === 0)
126
+ addTag(r.tag);
127
+ else if (t !== null && t.includes(arch))
128
+ platformTags.add(t.split(arch).join("{arch}"));
129
+ else
130
+ unread.push(`the per-platform tag ${r.tag}, which does not name its platform's architecture`);
131
+ }
132
+ }
133
+ for (const m of manifests) {
134
+ const name = typeof m.name_template === "string" ? splitRef(m.name_template) : null;
135
+ if (!name)
136
+ continue;
137
+ repositories.add(name.repository);
138
+ addTag(name.tag);
139
+ }
140
+ }
141
+ if (keys.length === 0)
142
+ return null;
143
+ if (Object.keys(doc).includes("kos"))
144
+ unread.push("the kos images, which chant does not build");
145
+ const [repository, ...others] = [...repositories];
146
+ if (!repository)
147
+ return null;
148
+ if (others.length > 0)
149
+ unread.push(`the images pushed to ${others.join(", ")}, as one oci target pushes to one repository`);
150
+ const [dockerfile, ...moreFiles] = [...dockerfiles];
151
+ if (moreFiles.length > 0)
152
+ unread.push(`the images built from ${moreFiles.join(", ")}, as one entry builds one Dockerfile`);
153
+ const name = (repository.split("/").pop() ?? "image").toLowerCase().replace(/[^a-z0-9._-]+/g, "-") || "image";
154
+ // A platform tag that names no version would move with every release; chant tags each release's own.
155
+ const ownTags = [...platformTags].filter((t) => t.includes("{version}") || t.includes("{label}"));
156
+ for (const t of platformTags)
157
+ if (!ownTags.includes(t))
158
+ unread.push(`the per-platform tag ${t}, which names no version`);
159
+ return { name, repository, dockerfile: dockerfile ?? "Dockerfile", platforms, args, labels, tags, platformTags: ownTags, archive: imageArchiveBesideGoreleaser(name), keys, unread };
160
+ }
@@ -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`. */
@@ -211,14 +233,14 @@ export declare function tagTemplateOf(facts: Pick<ProjectFacts, "tags" | "go" |
211
233
  };
212
234
  /** Plan the `release` block for a project. */
213
235
  export declare function planRelease(facts: ProjectFacts, opts: PlanOptions): ReleaseInitPlan;
214
- /** One member of a planned train: a publishable package, released at its own version from its own `chant.config.ts`. */
236
+ /** One member of a planned train: a publishable package, or what the train builds outside one, released at its own version from its own `chant.config.ts`. */
215
237
  export interface TrainMemberPlan {
216
238
  /** The member's name in `chant.workspace.json`. */
217
239
  name: string;
218
- /** The package's directory from the project root. */
240
+ /** The member's directory from the project root. */
219
241
  dir: string;
220
- /** The npm package name. */
221
- package: string;
242
+ /** The npm package name, or null for a member that is no workspace package (#5271). */
243
+ package: string | null;
222
244
  /** The member's `release` block. */
223
245
  release: Record<string, Json>;
224
246
  }
@@ -238,9 +260,15 @@ export interface ReleaseTrainPlan {
238
260
  }
239
261
  /** The environment a planned train is recorded for. */
240
262
  export declare const TRAIN_ENV = "npm";
263
+ /** The directory a train member init makes for what no workspace package holds (#5271), from the project root. */
264
+ export declare const TRAIN_OWN_DIR = "release";
265
+ /** The rule by which init gives a train member what the project builds besides its packages (#5271), as the plan's reasons print it. */
266
+ export declare 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 release/<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";
241
267
  /**
242
268
  * Whether the project's npm, pnpm or yarn workspaces can release as a train:
243
- * one member per publishable package (#5154). `why` says why a project with
269
+ * one member per publishable package or VS Code extension (#5154, #5271),
270
+ * with the images, charts and Python or Rust package beside them given to a
271
+ * member by {@link TRAIN_OWNERSHIP_RULE}. `why` says why a project with
244
272
  * several packages gets one release instead, and is null for a project with
245
273
  * fewer than two.
246
274
  */
@@ -254,8 +282,11 @@ export declare function trainFit(facts: ProjectFacts): {
254
282
  export declare function memberNameOf(pkg: Pick<InitPackage, "name" | "dir">): string;
255
283
  /**
256
284
  * Plan a train for a project {@link trainFit} accepts: a member per
257
- * publishable workspace package, each stamping and publishing its own
258
- * package, and the root's `release.train` with a dispatched workflow.
285
+ * publishable workspace package or VS Code extension, each stamping and
286
+ * publishing its own package, the images and charts each member's
287
+ * directory holds, a member at `release/<name>` for each other directory
288
+ * that holds an image, a chart, or a Python or Rust package (#5271), and the
289
+ * root's `release.train` with a dispatched workflow.
259
290
  */
260
291
  export declare function planTrain(facts: ProjectFacts, opts: PlanOptions): ReleaseTrainPlan;
261
292
  /** A value as TypeScript source, objects and arrays on one line when short. */