@intentius/chant 0.124.100 → 0.124.102

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 (270) hide show
  1. package/dist/action-pins.d.ts +2 -0
  2. package/dist/action-pins.js +3 -0
  3. package/dist/ci-detect.d.ts +13 -0
  4. package/dist/ci-detect.js +12 -0
  5. package/dist/ci-evidence-claims.d.ts +12 -0
  6. package/dist/ci-evidence-claims.js +12 -0
  7. package/dist/ci-system.d.ts +66 -0
  8. package/dist/ci-system.js +61 -0
  9. package/dist/cli/handlers/build.js +27 -0
  10. package/dist/cli/handlers/release-doctor.d.ts +12 -0
  11. package/dist/cli/handlers/release-doctor.js +118 -0
  12. package/dist/cli/handlers/release-init.d.ts +10 -0
  13. package/dist/cli/handlers/release-init.js +374 -0
  14. package/dist/cli/handlers/release.d.ts +43 -2
  15. package/dist/cli/handlers/release.js +667 -39
  16. package/dist/cli/handlers/run-generate.js +11 -0
  17. package/dist/cli/main.d.ts +2 -0
  18. package/dist/cli/main.js +44 -101
  19. package/dist/cli/parse-args.js +48 -0
  20. package/dist/cli/registry.d.ts +16 -0
  21. package/dist/cli/release-commands/artifacts.d.ts +3 -0
  22. package/dist/cli/release-commands/artifacts.js +14 -0
  23. package/dist/cli/release-commands/candidates.d.ts +3 -0
  24. package/dist/cli/release-commands/candidates.js +16 -0
  25. package/dist/cli/release-commands/changed.d.ts +3 -0
  26. package/dist/cli/release-commands/changed.js +14 -0
  27. package/dist/cli/release-commands/compose.d.ts +3 -0
  28. package/dist/cli/release-commands/compose.js +16 -0
  29. package/dist/cli/release-commands/cut.d.ts +3 -0
  30. package/dist/cli/release-commands/cut.js +50 -0
  31. package/dist/cli/release-commands/doctor.d.ts +3 -0
  32. package/dist/cli/release-commands/doctor.js +14 -0
  33. package/dist/cli/release-commands/export.d.ts +3 -0
  34. package/dist/cli/release-commands/export.js +12 -0
  35. package/dist/cli/release-commands/images.d.ts +3 -0
  36. package/dist/cli/release-commands/images.js +13 -0
  37. package/dist/cli/release-commands/index.d.ts +8 -0
  38. package/dist/cli/release-commands/index.js +52 -0
  39. package/dist/cli/release-commands/init.d.ts +3 -0
  40. package/dist/cli/release-commands/init.js +19 -0
  41. package/dist/cli/release-commands/list.d.ts +3 -0
  42. package/dist/cli/release-commands/list.js +10 -0
  43. package/dist/cli/release-commands/next.d.ts +3 -0
  44. package/dist/cli/release-commands/next.js +13 -0
  45. package/dist/cli/release-commands/publish.d.ts +3 -0
  46. package/dist/cli/release-commands/publish.js +22 -0
  47. package/dist/cli/release-commands/stamp.d.ts +3 -0
  48. package/dist/cli/release-commands/stamp.js +15 -0
  49. package/dist/cli/release-commands/status.d.ts +3 -0
  50. package/dist/cli/release-commands/status.js +17 -0
  51. package/dist/cli/release-commands/tag.d.ts +3 -0
  52. package/dist/cli/release-commands/tag.js +12 -0
  53. package/dist/cli/release-commands/types.d.ts +20 -0
  54. package/dist/cli/release-commands/types.js +1 -0
  55. package/dist/cli/release-commands/verify.d.ts +3 -0
  56. package/dist/cli/release-commands/verify.js +15 -0
  57. package/dist/cli/release-commands/workflow.d.ts +3 -0
  58. package/dist/cli/release-commands/workflow.js +15 -0
  59. package/dist/cloud-lister/index.d.ts +4 -1
  60. package/dist/cloud-lister/index.js +2 -1
  61. package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
  62. package/dist/cloud-lister/kubernetes-components.js +642 -0
  63. package/dist/cloud-lister/kubernetes.d.ts +18 -0
  64. package/dist/cloud-lister/kubernetes.js +26 -1
  65. package/dist/cloud-lister/mask.d.ts +5 -1
  66. package/dist/cloud-lister/mask.js +14 -5
  67. package/dist/components/cli-support.d.ts +1 -1
  68. package/dist/components/cli-support.js +1 -1
  69. package/dist/config-environments.d.ts +8 -1
  70. package/dist/config-environments.js +2 -0
  71. package/dist/config-import.d.ts +1 -1
  72. package/dist/config-import.js +6 -2
  73. package/dist/config-sandbox.d.ts +1 -1
  74. package/dist/config-sandbox.js +3 -3
  75. package/dist/config.d.ts +369 -10
  76. package/dist/config.js +127 -7
  77. package/dist/deep-observation.js +9 -3
  78. package/dist/floor-table.data.js +21 -1
  79. package/dist/forge-remote.d.ts +13 -0
  80. package/dist/forge-remote.js +15 -0
  81. package/dist/lexicon.d.ts +45 -4
  82. package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
  83. package/dist/lifecycle/__fixtures__/package-files.js +72 -0
  84. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
  85. package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -3
  86. package/dist/lifecycle/publish-attachments.d.ts +2 -1
  87. package/dist/lifecycle/publish-attachments.js +19 -2
  88. package/dist/lifecycle/publish-cargo.d.ts +99 -0
  89. package/dist/lifecycle/publish-cargo.js +412 -0
  90. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  91. package/dist/lifecycle/publish-credentials.js +13 -0
  92. package/dist/lifecycle/publish-declaration.d.ts +322 -4
  93. package/dist/lifecycle/publish-declaration.js +340 -9
  94. package/dist/lifecycle/publish-forge.d.ts +45 -2
  95. package/dist/lifecycle/publish-forge.js +434 -34
  96. package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
  97. package/dist/lifecycle/publish-git-ssh.js +30 -4
  98. package/dist/lifecycle/publish-github.d.ts +40 -2
  99. package/dist/lifecycle/publish-github.js +100 -3
  100. package/dist/lifecycle/publish-helm.d.ts +83 -0
  101. package/dist/lifecycle/publish-helm.js +452 -0
  102. package/dist/lifecycle/publish-homebrew.d.ts +7 -9
  103. package/dist/lifecycle/publish-homebrew.js +34 -197
  104. package/dist/lifecycle/publish-index.d.ts +141 -0
  105. package/dist/lifecycle/publish-index.js +719 -0
  106. package/dist/lifecycle/publish-marketplace.js +77 -0
  107. package/dist/lifecycle/publish-maven.d.ts +79 -0
  108. package/dist/lifecycle/publish-maven.js +364 -0
  109. package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
  110. package/dist/lifecycle/publish-mcp-registry.js +305 -0
  111. package/dist/lifecycle/publish-npm.d.ts +27 -1
  112. package/dist/lifecycle/publish-npm.js +216 -3
  113. package/dist/lifecycle/publish-nuget.d.ts +93 -0
  114. package/dist/lifecycle/publish-nuget.js +377 -0
  115. package/dist/lifecycle/publish-oci.d.ts +91 -2
  116. package/dist/lifecycle/publish-oci.js +247 -8
  117. package/dist/lifecycle/publish-package-files.d.ts +16 -0
  118. package/dist/lifecycle/publish-package-files.js +39 -0
  119. package/dist/lifecycle/publish-pypi.d.ts +138 -0
  120. package/dist/lifecycle/publish-pypi.js +657 -0
  121. package/dist/lifecycle/publish-record.d.ts +6 -3
  122. package/dist/lifecycle/publish-record.js +6 -3
  123. package/dist/lifecycle/publish-rubygems.d.ts +84 -0
  124. package/dist/lifecycle/publish-rubygems.js +366 -0
  125. package/dist/lifecycle/publish-signing.d.ts +147 -0
  126. package/dist/lifecycle/publish-signing.js +257 -0
  127. package/dist/lifecycle/publish-targets.d.ts +37 -1
  128. package/dist/lifecycle/publish-targets.js +102 -0
  129. package/dist/lifecycle/publish-tauri.js +43 -0
  130. package/dist/lifecycle/publish-train-names.d.ts +57 -0
  131. package/dist/lifecycle/publish-train-names.js +123 -0
  132. package/dist/lifecycle/publish-verify.d.ts +121 -0
  133. package/dist/lifecycle/publish-verify.js +130 -0
  134. package/dist/lifecycle/query.js +8 -0
  135. package/dist/lifecycle/release-artifacts.d.ts +290 -0
  136. package/dist/lifecycle/release-artifacts.js +808 -0
  137. package/dist/lifecycle/release-changelog.d.ts +13 -1
  138. package/dist/lifecycle/release-changelog.js +35 -2
  139. package/dist/lifecycle/release-cut.d.ts +64 -4
  140. package/dist/lifecycle/release-cut.js +147 -34
  141. package/dist/lifecycle/release-doctor.d.ts +113 -0
  142. package/dist/lifecycle/release-doctor.js +1198 -0
  143. package/dist/lifecycle/release-green.d.ts +86 -0
  144. package/dist/lifecycle/release-green.js +286 -0
  145. package/dist/lifecycle/release-init-registries.d.ts +48 -0
  146. package/dist/lifecycle/release-init-registries.js +97 -0
  147. package/dist/lifecycle/release-init.d.ts +275 -0
  148. package/dist/lifecycle/release-init.js +984 -0
  149. package/dist/lifecycle/release-intents.d.ts +73 -0
  150. package/dist/lifecycle/release-intents.js +128 -0
  151. package/dist/lifecycle/release-next.d.ts +111 -0
  152. package/dist/lifecycle/release-next.js +251 -0
  153. package/dist/lifecycle/release-prerelease.d.ts +19 -0
  154. package/dist/lifecycle/release-prerelease.js +30 -0
  155. package/dist/lifecycle/release-publish.d.ts +256 -10
  156. package/dist/lifecycle/release-publish.js +247 -35
  157. package/dist/lifecycle/release-status-change.d.ts +226 -0
  158. package/dist/lifecycle/release-status-change.js +478 -0
  159. package/dist/lifecycle/release-status.d.ts +11 -0
  160. package/dist/lifecycle/release-status.js +1 -1
  161. package/dist/lifecycle/release-store.d.ts +73 -2
  162. package/dist/lifecycle/release-store.js +32 -1
  163. package/dist/lifecycle/release-tag.d.ts +142 -0
  164. package/dist/lifecycle/release-tag.js +322 -0
  165. package/dist/lifecycle/release-verify.d.ts +73 -1
  166. package/dist/lifecycle/release-verify.js +117 -2
  167. package/dist/lifecycle/release-version-formats.d.ts +73 -0
  168. package/dist/lifecycle/release-version-formats.js +570 -0
  169. package/dist/lifecycle/release-version.d.ts +58 -10
  170. package/dist/lifecycle/release-version.js +164 -36
  171. package/dist/lifecycle/release-workstation.d.ts +3 -2
  172. package/dist/lifecycle/release-workstation.js +3 -2
  173. package/dist/op/generate-pipeline.js +1 -1
  174. package/dist/op/local-executor.d.ts +1 -1
  175. package/dist/op/local-executor.js +2 -2
  176. package/dist/op/op-waves-evidence.js +9 -2
  177. package/dist/pr-forge-base.js +4 -2
  178. package/dist/pr-forge.d.ts +20 -2
  179. package/dist/pr-forge.js +46 -10
  180. package/dist/release-floors.d.ts +8 -1
  181. package/dist/release-floors.js +9 -2
  182. package/dist/sensitive-key.d.ts +12 -0
  183. package/dist/sensitive-key.js +52 -0
  184. package/dist/tool-pins.d.ts +40 -0
  185. package/dist/tool-pins.js +66 -0
  186. package/dist/ts-loader.d.ts +8 -0
  187. package/dist/ts-loader.js +19 -0
  188. package/dist/wave-runtime.mjs +345 -342
  189. package/dist/workspace/ci-forge.d.ts +17 -0
  190. package/dist/workspace/ci-forge.js +17 -0
  191. package/dist/workspace/ci-init.js +1 -1
  192. package/dist/workspace/composites.schema.json +1 -0
  193. package/dist/workspace/declaration.d.ts +8 -0
  194. package/dist/workspace/declaration.js +12 -0
  195. package/dist/workspace/declaration.schema.json +8 -0
  196. package/dist/workspace/environments.d.ts +2 -0
  197. package/dist/workspace/environments.js +1 -1
  198. package/dist/workspace/identity-gate-rule.d.ts +61 -5
  199. package/dist/workspace/identity-gate-rule.js +81 -12
  200. package/dist/workspace/lexicon-outputs.d.ts +1 -1
  201. package/dist/workspace/lexicon-outputs.js +1 -1
  202. package/dist/workspace/member-pipeline.d.ts +2 -1
  203. package/dist/workspace/member-pipeline.js +5 -2
  204. package/dist/workspace/reason-codes.d.ts +2 -0
  205. package/dist/workspace/reason-codes.js +3 -1
  206. package/dist/workspace/release-changed.d.ts +75 -4
  207. package/dist/workspace/release-changed.js +205 -34
  208. package/dist/workspace/release-changed.schema.json +20 -2
  209. package/dist/workspace/release-steps/artifacts.d.ts +7 -0
  210. package/dist/workspace/release-steps/artifacts.js +45 -0
  211. package/dist/workspace/release-steps/builds.d.ts +12 -0
  212. package/dist/workspace/release-steps/builds.js +38 -0
  213. package/dist/workspace/release-steps/doctor.d.ts +8 -0
  214. package/dist/workspace/release-steps/doctor.js +14 -0
  215. package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
  216. package/dist/workspace/release-steps/goreleaser.js +36 -0
  217. package/dist/workspace/release-steps/green.d.ts +3 -0
  218. package/dist/workspace/release-steps/green.js +6 -0
  219. package/dist/workspace/release-steps/images.d.ts +22 -0
  220. package/dist/workspace/release-steps/images.js +59 -0
  221. package/dist/workspace/release-steps/index.d.ts +9 -0
  222. package/dist/workspace/release-steps/index.js +50 -0
  223. package/dist/workspace/release-steps/nfpm.d.ts +13 -0
  224. package/dist/workspace/release-steps/nfpm.js +29 -0
  225. package/dist/workspace/release-steps/nuget.d.ts +14 -0
  226. package/dist/workspace/release-steps/nuget.js +16 -0
  227. package/dist/workspace/release-steps/pypi.d.ts +15 -0
  228. package/dist/workspace/release-steps/pypi.js +21 -0
  229. package/dist/workspace/release-steps/qemu.d.ts +21 -0
  230. package/dist/workspace/release-steps/qemu.js +35 -0
  231. package/dist/workspace/release-steps/signing.d.ts +18 -0
  232. package/dist/workspace/release-steps/signing.js +30 -0
  233. package/dist/workspace/release-steps/stamp.d.ts +3 -0
  234. package/dist/workspace/release-steps/stamp.js +4 -0
  235. package/dist/workspace/release-steps/targets.d.ts +31 -0
  236. package/dist/workspace/release-steps/targets.js +40 -0
  237. package/dist/workspace/release-steps/types.d.ts +104 -0
  238. package/dist/workspace/release-steps/types.js +2 -0
  239. package/dist/workspace/release-steps/verify.d.ts +3 -0
  240. package/dist/workspace/release-steps/verify.js +4 -0
  241. package/dist/workspace/release-toolchains.d.ts +59 -0
  242. package/dist/workspace/release-toolchains.js +133 -0
  243. package/dist/workspace/release-train-workflow.d.ts +36 -0
  244. package/dist/workspace/release-train-workflow.js +121 -0
  245. package/dist/workspace/release-train.d.ts +3 -1
  246. package/dist/workspace/release-train.js +20 -3
  247. package/dist/workspace/release-workflow.d.ts +183 -59
  248. package/dist/workspace/release-workflow.js +570 -201
  249. package/dist/workspace/releases.schema.json +70 -1
  250. package/dist/workspace/search-contract.d.ts +1 -1
  251. package/dist/workspace/security.js +9 -2
  252. package/dist/workspace/train-cut.d.ts +182 -0
  253. package/dist/workspace/train-cut.js +504 -0
  254. package/dist/workspace/train-prepare.d.ts +64 -0
  255. package/dist/workspace/train-prepare.js +313 -0
  256. package/dist/workspace/train-publish.d.ts +177 -0
  257. package/dist/workspace/train-publish.js +574 -0
  258. package/dist/workspace/train-range-labels.d.ts +33 -0
  259. package/dist/workspace/train-range-labels.js +109 -0
  260. package/dist/workspace/train-shell.d.ts +5 -0
  261. package/dist/workspace/train-shell.js +17 -0
  262. package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
  263. package/dist/workspace/trust/check-evidence-report.js +3 -7
  264. package/dist/workspace/trust/seal.d.ts +13 -3
  265. package/dist/workspace/trust/seal.js +14 -4
  266. package/dist/workspace/work-cli.d.ts +3 -2
  267. package/dist/workspace/work-cli.js +3 -2
  268. package/dist/workspace/workspace-ledger.d.ts +14 -1
  269. package/dist/workspace/workspace-ledger.js +33 -7
  270. package/package.json +1 -1
@@ -137,6 +137,11 @@ export class SshGitRepo {
137
137
  await this.must(`fetching ${branch}`, ["fetch", "-q", "--no-tags", `--depth=${depth}`, this.remote, `+refs/heads/${branch}:refs/remotes/tap/${branch}`]);
138
138
  return (await this.must(`reading ${branch}`, ["rev-parse", `refs/remotes/tap/${branch}`])).trim();
139
139
  }
140
+ /** The fetched commits of `branch` that touch `path`, newest first (#5163). Fetch the branch deep enough first. */
141
+ async history(branch, path) {
142
+ const out = await this.must(`reading the history of ${path}`, ["log", "--format=%H", `refs/remotes/tap/${branch}`, "--", path]);
143
+ return out.split("\n").map((l) => l.trim()).filter(Boolean);
144
+ }
140
145
  /** The bytes of `path` at a fetched commit, or null when it holds no such file. */
141
146
  async file(commit, path) {
142
147
  const spec = `${commit}:${path}`;
@@ -146,14 +151,35 @@ export class SshGitRepo {
146
151
  execFile(this.git, ["cat-file", "blob", spec], { cwd: this.dir, env: this.env, encoding: "buffer", maxBuffer: 64 * 1024 * 1024 }, (err, stdout) => (err ? reject(err) : resolvePromise(stdout)));
147
152
  });
148
153
  }
154
+ /** The commit a submodule at `path` points to at a fetched commit, or null when `path` is not a submodule there (#5158). */
155
+ async gitlink(commit, path) {
156
+ const r = await this.run(["ls-tree", commit, "--", path]);
157
+ const m = /^160000 commit ([0-9a-f]{40,64})\t/m.exec(r.stdout);
158
+ return r.code === 0 && m ? m[1] : null;
159
+ }
149
160
  /** A commit on `parent` that writes `bytes` to `path`, with `message`. Made here, not pushed. */
150
161
  async commitFile(parent, path, bytes, message) {
151
- const blobFile = join(this.root, "blob");
152
- writeFileSync(blobFile, bytes);
153
- const blob = (await this.must("writing the file", ["hash-object", "-w", blobFile])).trim();
162
+ return this.commitFiles(parent, [{ path, bytes }], message);
163
+ }
164
+ /** A commit on `parent` that writes each file, points each submodule path at its commit (#5158) and removes each `remove` path (#5163). Made here, not pushed. */
165
+ async commitFiles(parent, changes, message) {
154
166
  const index = { GIT_INDEX_FILE: join(this.root, "index") };
155
167
  await this.must("reading the tree", ["read-tree", parent], index);
156
- await this.must("staging the file", ["update-index", "--add", "--cacheinfo", `100644,${blob},${path}`], index);
168
+ for (const c of changes) {
169
+ if ("remove" in c) {
170
+ // #5163: a yank takes out a manifest the head release did not publish.
171
+ await this.must(`removing ${c.path}`, ["--work-tree", this.dir, "update-index", "--force-remove", "--", c.path], index);
172
+ continue;
173
+ }
174
+ if ("gitlink" in c) {
175
+ await this.must(`pointing ${c.path} at ${c.gitlink.slice(0, 12)}`, ["update-index", "--add", "--cacheinfo", `160000,${c.gitlink},${c.path}`], index);
176
+ continue;
177
+ }
178
+ const blobFile = join(this.root, "blob");
179
+ writeFileSync(blobFile, c.bytes);
180
+ const blob = (await this.must("writing the file", ["hash-object", "-w", blobFile])).trim();
181
+ await this.must("staging the file", ["update-index", "--add", "--cacheinfo", `100644,${blob},${c.path}`], index);
182
+ }
157
183
  const tree = (await this.must("writing the tree", ["write-tree"], index)).trim();
158
184
  rmSync(index.GIT_INDEX_FILE, { force: true });
159
185
  const who = (await this.run(["config", "user.email"])).stdout.trim() ? [] : ["-c", "user.name=chant", "-c", "user.email=chant@localhost"];
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The GitHub REST calls the targets that write to a repository other than the
3
- * release's use (#4676): the Homebrew tap's formula, and the Tauri updater's
4
- * rolling release. Requests go through the injectable `fetch`, with the token
3
+ * release's use (#4676): the Homebrew tap's formula, the Tauri updater's
4
+ * rolling release, and an index repository's manifests, fork and pull
5
+ * request (#5158). Requests go through the injectable `fetch`, with the token
5
6
  * as a bearer, and every failure is redacted before it is thrown.
6
7
  */
7
8
  import type { Credential } from "./publish-credentials.js";
@@ -37,12 +38,40 @@ export declare class GitHubRepo {
37
38
  bytes: Buffer;
38
39
  sha: string;
39
40
  } | null>;
41
+ /** The commits of `branch` that touch `path`, newest first, up to 100 (#5163). */
42
+ commitsTouching(path: string, branch: string): Promise<string[]>;
40
43
  /** Commit `bytes` as `path` on `branch`, replacing the blob `sha` when the file is there. Returns the commit. */
41
44
  putFile(path: string, branch: string, bytes: Uint8Array, message: string, sha: string | null): Promise<string>;
42
45
  /** Make `refs/heads/<branch>` at `sha`. */
43
46
  createBranch(branch: string, sha: string): Promise<void>;
44
47
  /** Move `refs/<ref>` to `sha`. Without `force`, a move that is not a fast-forward answers false. */
45
48
  moveRef(ref: string, sha: string, force: boolean): Promise<boolean>;
49
+ /** True when the token sees the repository. */
50
+ exists(): Promise<boolean>;
51
+ /** The commit a submodule at `path` points to at `ref`, or null when `path` is not a submodule there (#5158). */
52
+ submodule(path: string, ref: string): Promise<string | null>;
53
+ /**
54
+ * A commit on `parent` that writes each file, points each submodule
55
+ * path at its commit and removes each `remove` path (#5163), made with
56
+ * the git data API (#5158): one commit
57
+ * whatever the number of files. No branch moves.
58
+ */
59
+ commitTree(parent: string, changes: ReadonlyArray<{
60
+ path: string;
61
+ bytes: Uint8Array;
62
+ } | {
63
+ path: string;
64
+ gitlink: string;
65
+ } | {
66
+ path: string;
67
+ remove: true;
68
+ }>, message: string): Promise<string>;
69
+ /** Ask for the token's user's fork of this repository (#5158). GitHub answers with the fork it has, or makes one; it may take a moment to appear. Returns its `owner/name`. */
70
+ fork(): Promise<string>;
71
+ /** The pull request from `head` (`owner:branch`) in any state, newest first, or null (#5158). */
72
+ findPull(head: string): Promise<GitHubPull | null>;
73
+ /** Open a pull request from `head` (`owner:branch`) into `base`. */
74
+ openPull(title: string, body: string, head: string, base: string): Promise<GitHubPull>;
46
75
  /** The published release for `tag`, or null. A draft is not found here. */
47
76
  publishedRelease(tag: string): Promise<GitHubRelease | null>;
48
77
  /** The draft release for `tag` named `name`, or null. */
@@ -58,6 +87,13 @@ export declare class GitHubRepo {
58
87
  /** Delete `refs/<ref>`. One that is not there is already gone. */
59
88
  deleteRef(ref: string): Promise<void>;
60
89
  }
90
+ /** A pull request as the index target reads it (#5158). */
91
+ export interface GitHubPull {
92
+ number: number;
93
+ url: string;
94
+ state: "open" | "closed";
95
+ merged: boolean;
96
+ }
61
97
  /** A GitHub release as the targets read it. */
62
98
  export interface GitHubRelease {
63
99
  id: string;
@@ -65,4 +101,6 @@ export interface GitHubRelease {
65
101
  /** Asset names, with the digest GitHub reports. */
66
102
  assets: Map<string, string | null>;
67
103
  uploadUrl?: string;
104
+ /** The release's name, when GitHub gives one. */
105
+ name?: string;
68
106
  }
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The GitHub REST calls the targets that write to a repository other than the
3
- * release's use (#4676): the Homebrew tap's formula, and the Tauri updater's
4
- * rolling release. Requests go through the injectable `fetch`, with the token
3
+ * release's use (#4676): the Homebrew tap's formula, the Tauri updater's
4
+ * rolling release, and an index repository's manifests, fork and pull
5
+ * request (#5158). Requests go through the injectable `fetch`, with the token
5
6
  * as a bearer, and every failure is redacted before it is thrown.
6
7
  */
7
8
  import { PublishTargetError } from "./release-publish.js";
@@ -74,6 +75,13 @@ export class GitHubRepo {
74
75
  this.fail(`reading ${path} at ${ref}`, res);
75
76
  return { bytes: body.encoding === "base64" ? Buffer.from(body.content, "base64") : Buffer.from(body.content), sha: body.sha };
76
77
  }
78
+ /** The commits of `branch` that touch `path`, newest first, up to 100 (#5163). */
79
+ async commitsTouching(path, branch) {
80
+ const res = await this.call("GET", `/commits?path=${encodeURIComponent(path)}&sha=${encodeURIComponent(branch)}&per_page=100`);
81
+ if (res.status !== 200 || !Array.isArray(res.json))
82
+ this.fail(`listing the commits of ${branch} that touch ${path}`, res);
83
+ return res.json.map((c) => c.sha).filter((c) => typeof c === "string");
84
+ }
77
85
  /** Commit `bytes` as `path` on `branch`, replacing the blob `sha` when the file is there. Returns the commit. */
78
86
  async putFile(path, branch, bytes, message, sha) {
79
87
  const res = await this.call("PUT", `/contents/${path.split("/").map(encodeURIComponent).join("/")}`, JSON.stringify({ message, content: Buffer.from(bytes).toString("base64"), branch, ...(sha ? { sha } : {}) }));
@@ -97,6 +105,87 @@ export class GitHubRepo {
97
105
  return false;
98
106
  this.fail(`moving ${ref} to ${sha.slice(0, 12)}`, res);
99
107
  }
108
+ /** True when the token sees the repository. */
109
+ async exists() {
110
+ const res = await this.call("GET", "");
111
+ if (res.status === 404)
112
+ return false;
113
+ if (res.status !== 200)
114
+ this.fail("reading the repository", res);
115
+ return true;
116
+ }
117
+ /** The commit a submodule at `path` points to at `ref`, or null when `path` is not a submodule there (#5158). */
118
+ async submodule(path, ref) {
119
+ const res = await this.call("GET", `/contents/${path.split("/").map(encodeURIComponent).join("/")}?ref=${encodeURIComponent(ref)}`);
120
+ if (res.status === 404)
121
+ return null;
122
+ const body = res.json;
123
+ if (res.status !== 200)
124
+ this.fail(`reading ${path} at ${ref}`, res);
125
+ return body?.type === "submodule" && typeof body.sha === "string" ? body.sha : null;
126
+ }
127
+ /**
128
+ * A commit on `parent` that writes each file, points each submodule
129
+ * path at its commit and removes each `remove` path (#5163), made with
130
+ * the git data API (#5158): one commit
131
+ * whatever the number of files. No branch moves.
132
+ */
133
+ async commitTree(parent, changes, message) {
134
+ const base = await this.call("GET", `/git/commits/${parent}`);
135
+ const tree = base.json?.tree?.sha;
136
+ if (base.status !== 200 || typeof tree !== "string")
137
+ this.fail(`reading commit ${parent.slice(0, 12)}`, base);
138
+ const entries = [];
139
+ for (const c of changes) {
140
+ if ("remove" in c) {
141
+ // #5163: a null sha takes the path out of the tree.
142
+ entries.push({ path: c.path, mode: "100644", type: "blob", sha: null });
143
+ continue;
144
+ }
145
+ if ("gitlink" in c) {
146
+ entries.push({ path: c.path, mode: "160000", type: "commit", sha: c.gitlink });
147
+ continue;
148
+ }
149
+ const blob = await this.call("POST", "/git/blobs", JSON.stringify({ content: Buffer.from(c.bytes).toString("base64"), encoding: "base64" }));
150
+ const sha = blob.json?.sha;
151
+ if (blob.status !== 201 || typeof sha !== "string")
152
+ this.fail(`writing ${c.path}`, blob);
153
+ entries.push({ path: c.path, mode: "100644", type: "blob", sha });
154
+ }
155
+ const made = await this.call("POST", "/git/trees", JSON.stringify({ base_tree: tree, tree: entries }));
156
+ const madeSha = made.json?.sha;
157
+ if (made.status !== 201 || typeof madeSha !== "string")
158
+ this.fail("writing the tree", made);
159
+ const commit = await this.call("POST", "/git/commits", JSON.stringify({ message, tree: madeSha, parents: [parent] }));
160
+ const commitSha = commit.json?.sha;
161
+ if (commit.status !== 201 || typeof commitSha !== "string")
162
+ this.fail("committing", commit);
163
+ return commitSha;
164
+ }
165
+ /** Ask for the token's user's fork of this repository (#5158). GitHub answers with the fork it has, or makes one; it may take a moment to appear. Returns its `owner/name`. */
166
+ async fork() {
167
+ const res = await this.call("POST", "/forks", JSON.stringify({ default_branch_only: true }));
168
+ const name = res.json?.full_name;
169
+ if ((res.status !== 202 && res.status !== 200) || typeof name !== "string")
170
+ this.fail("forking", res);
171
+ return name;
172
+ }
173
+ /** The pull request from `head` (`owner:branch`) in any state, newest first, or null (#5158). */
174
+ async findPull(head) {
175
+ const res = await this.call("GET", `/pulls?state=all&per_page=100&head=${encodeURIComponent(head)}`);
176
+ if (res.status !== 200)
177
+ this.fail(`listing pull requests from ${head}`, res);
178
+ const list = Array.isArray(res.json) ? res.json : [];
179
+ const found = list.find((p) => p.head?.label === head) ?? null;
180
+ return found ? toPull(found) : null;
181
+ }
182
+ /** Open a pull request from `head` (`owner:branch`) into `base`. */
183
+ async openPull(title, body, head, base) {
184
+ const res = await this.call("POST", "/pulls", JSON.stringify({ title, body, head, base, maintainer_can_modify: true }));
185
+ if (res.status !== 201 || !res.json)
186
+ this.fail(`opening a pull request from ${head} into ${base}`, res);
187
+ return toPull(res.json);
188
+ }
100
189
  /** The published release for `tag`, or null. A draft is not found here. */
101
190
  async publishedRelease(tag) {
102
191
  const res = await this.call("GET", `/releases/tags/${encodeURIComponent(tag)}`);
@@ -145,9 +234,17 @@ export class GitHubRepo {
145
234
  this.fail(`deleting ${ref}`, res);
146
235
  }
147
236
  }
237
+ function toPull(body) {
238
+ return {
239
+ number: Number(body.number),
240
+ url: typeof body.html_url === "string" ? body.html_url : `#${String(body.number)}`,
241
+ state: body.state === "open" ? "open" : "closed",
242
+ merged: typeof body.merged_at === "string" && body.merged_at.length > 0,
243
+ };
244
+ }
148
245
  function toRelease(body) {
149
246
  const assets = new Map();
150
247
  for (const a of body.assets ?? [])
151
248
  assets.set(a.name, typeof a.digest === "string" ? a.digest : null);
152
- return { id: String(body.id), draft: body.draft === true, assets, ...(typeof body.upload_url === "string" ? { uploadUrl: body.upload_url } : {}) };
249
+ return { id: String(body.id), draft: body.draft === true, assets, ...(typeof body.upload_url === "string" ? { uploadUrl: body.upload_url } : {}), ...(typeof body.name === "string" ? { name: body.name } : {}) };
153
250
  }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The Helm target (#5233): chart archives pushed to an OCI registry, and
3
+ * listed in a classic chart repository's `index.yaml`.
4
+ *
5
+ * Each chart is a `.tgz` as `helm package` writes it, or as a `helm` entry of
6
+ * `release.artifacts` packs it (./release-artifacts.ts). Its name, version
7
+ * and the rest of its `Chart.yaml` are read from the archive, and a chart
8
+ * whose version is not the release's label from its first digit is refused
9
+ * (`publish-helm-version-mismatch`).
10
+ *
11
+ * `oci`: the chart goes to `<repository>/<chart name>` as `helm push` puts
12
+ * it: an image manifest whose config is the chart's metadata as JSON
13
+ * (`application/vnd.cncf.helm.config.v1+json`) and whose one layer is the
14
+ * archive (`application/vnd.cncf.helm.chart.content.v1.tar+gzip`). The
15
+ * registry is spoken to as the `oci` target speaks to it (./publish-oci.ts),
16
+ * with the same credentials. The stage pushes by digest; the reveal tags
17
+ * the digest with the chart's version (`+` written `_`, as helm does), which
18
+ * is what `helm install oci://<repository>/<name> --version <version>` reads.
19
+ *
20
+ * `index`: a chart repository served from a branch of a GitHub repository,
21
+ * such as `gh-pages`. The index's entry for each chart is its `Chart.yaml`
22
+ * with `urls`, `created` and `digest`, as `helm repo index` writes it. With
23
+ * `url`, each chart is downloaded from there, such as the forge release a
24
+ * `forge` target attaches it to; without it, the archive is committed
25
+ * beside the index and named by its file name. The stage commits to
26
+ * `chant-publish/helm-<version>` at the branch's head, and the reveal
27
+ * fast-forwards the branch, or commits onto it when it moved. The index is
28
+ * read and added to, never rewritten: a version it lists with the same
29
+ * digest is left, and one it lists with another is refused
30
+ * (`publish-helm-version-taken`), since a chart version is never replaced.
31
+ * With `index`, the target reveals after every other target, since the
32
+ * index points at files they make downloadable.
33
+ */
34
+ import type { HelmPublishDeclaration } from "./publish-declaration.js";
35
+ import { type PublishDeps, type PublishTarget } from "./release-publish.js";
36
+ /** The first chant that publishes a `helm` target (#5233). */
37
+ export declare const PUBLISH_HELM_FLOOR = "0.124.102";
38
+ /** The media type of a chart's config blob: its metadata as JSON. */
39
+ export declare const HELM_CONFIG_MEDIA_TYPE = "application/vnd.cncf.helm.config.v1+json";
40
+ /** The media type of a chart's archive layer. */
41
+ export declare const HELM_CHART_MEDIA_TYPE = "application/vnd.cncf.helm.chart.content.v1.tar+gzip";
42
+ /** The variable the index's token is read from when the declaration names none. */
43
+ export declare const HELM_INDEX_TOKEN_ENV = "GITHUB_TOKEN";
44
+ /** What a chart archive holds, as the target reads it. */
45
+ export interface ChartArchive {
46
+ /** The path the target names, relative to the member. */
47
+ path: string;
48
+ /** The archive's file name. */
49
+ file: string;
50
+ bytes: Uint8Array;
51
+ /** `sha256:<hex>` of the archive. */
52
+ digest: string;
53
+ name: string;
54
+ version: string;
55
+ /** The chart's `Chart.yaml`, as read. */
56
+ metadata: Record<string, unknown>;
57
+ }
58
+ /**
59
+ * The `Chart.yaml` of a chart archive: the one file `<dir>/Chart.yaml` at the
60
+ * top of its gzipped tar. Reads ustar names, with a GNU long name or a PAX
61
+ * `path` in place of a short one. Null when the archive has none.
62
+ */
63
+ export declare function chartYamlOf(gz: Uint8Array): string | null;
64
+ /** Read a chart archive's metadata, refused (`publish-helm-not-a-chart`) when it holds no readable `Chart.yaml` with a name and a version. */
65
+ export declare function readChartArchive(path: string, bytes: Uint8Array): ChartArchive;
66
+ /** The OCI tag of a chart version: helm writes `+` as `_`, which a tag can't hold. */
67
+ export declare function helmOciTag(version: string): string;
68
+ /** The config blob and the manifest `helm push` would make for a chart, with no time in them, so the same chart is the same digest. */
69
+ export declare function helmOciManifest(chart: ChartArchive): {
70
+ config: Uint8Array;
71
+ manifest: Uint8Array;
72
+ digest: string;
73
+ };
74
+ /**
75
+ * The index with each chart's entry added, or null when it lists every chart
76
+ * already with the same digest. A version it lists with another digest is
77
+ * refused.
78
+ */
79
+ export declare function addToHelmIndex(existing: string | null, charts: ReadonlyArray<{
80
+ chart: ChartArchive;
81
+ url: string;
82
+ }>, created: string, where: string): string | null;
83
+ export declare function helmTarget(decl: HelmPublishDeclaration, deps: PublishDeps): PublishTarget;