@intentius/chant 0.124.62 → 0.124.64

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 (262) hide show
  1. package/dist/cli/handlers/approve.d.ts +26 -0
  2. package/dist/cli/handlers/approve.d.ts.map +1 -1
  3. package/dist/cli/handlers/approve.js +167 -18
  4. package/dist/cli/handlers/plan.d.ts +10 -0
  5. package/dist/cli/handlers/plan.d.ts.map +1 -0
  6. package/dist/cli/handlers/plan.js +71 -0
  7. package/dist/cli/handlers/pr.d.ts.map +1 -1
  8. package/dist/cli/handlers/pr.js +2 -1
  9. package/dist/cli/handlers/release.d.ts +11 -7
  10. package/dist/cli/handlers/release.d.ts.map +1 -1
  11. package/dist/cli/handlers/release.js +93 -20
  12. package/dist/cli/main.d.ts.map +1 -1
  13. package/dist/cli/main.js +48 -7
  14. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  15. package/dist/cli/mcp/workspace-tools.js +2 -1
  16. package/dist/cli/parse-args.d.ts.map +1 -1
  17. package/dist/cli/parse-args.js +43 -0
  18. package/dist/cli/registry.d.ts +18 -2
  19. package/dist/cli/registry.d.ts.map +1 -1
  20. package/dist/config.d.ts +50 -0
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/config.js +1 -0
  23. package/dist/gate-decision.d.ts +1 -1
  24. package/dist/gate-decision.d.ts.map +1 -1
  25. package/dist/gate-decision.js +4 -2
  26. package/dist/gate-statement.schema.json +46 -0
  27. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
  28. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
  29. package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
  30. package/dist/lifecycle/gate-ledger.d.ts +28 -5
  31. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  32. package/dist/lifecycle/gate-ledger.js +6 -0
  33. package/dist/lifecycle/gate-seal.d.ts +59 -7
  34. package/dist/lifecycle/gate-seal.d.ts.map +1 -1
  35. package/dist/lifecycle/gate-seal.js +68 -15
  36. package/dist/lifecycle/gate-statement.d.ts +95 -0
  37. package/dist/lifecycle/gate-statement.d.ts.map +1 -0
  38. package/dist/lifecycle/gate-statement.js +110 -0
  39. package/dist/lifecycle/gate-webauthn.d.ts +79 -0
  40. package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
  41. package/dist/lifecycle/gate-webauthn.js +105 -0
  42. package/dist/lifecycle/git.d.ts +1 -1
  43. package/dist/lifecycle/git.d.ts.map +1 -1
  44. package/dist/lifecycle/git.js +24 -19
  45. package/dist/lifecycle/ledger-remote.d.ts +37 -0
  46. package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
  47. package/dist/lifecycle/ledger-remote.js +42 -0
  48. package/dist/lifecycle/plan-stale.d.ts +76 -0
  49. package/dist/lifecycle/plan-stale.d.ts.map +1 -0
  50. package/dist/lifecycle/plan-stale.js +120 -0
  51. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  52. package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
  53. package/dist/lifecycle/publish-credentials.js +2 -0
  54. package/dist/lifecycle/publish-declaration.d.ts +107 -0
  55. package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
  56. package/dist/lifecycle/publish-declaration.js +110 -1
  57. package/dist/lifecycle/publish-forge.d.ts +5 -1
  58. package/dist/lifecycle/publish-forge.d.ts.map +1 -1
  59. package/dist/lifecycle/publish-forge.js +13 -4
  60. package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
  61. package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
  62. package/dist/lifecycle/publish-git-ssh.js +180 -0
  63. package/dist/lifecycle/publish-github.d.ts +69 -0
  64. package/dist/lifecycle/publish-github.d.ts.map +1 -0
  65. package/dist/lifecycle/publish-github.js +153 -0
  66. package/dist/lifecycle/publish-homebrew.d.ts +77 -0
  67. package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
  68. package/dist/lifecycle/publish-homebrew.js +265 -0
  69. package/dist/lifecycle/publish-marketplace.d.ts +85 -0
  70. package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
  71. package/dist/lifecycle/publish-marketplace.js +398 -0
  72. package/dist/lifecycle/publish-targets.d.ts +6 -0
  73. package/dist/lifecycle/publish-targets.d.ts.map +1 -1
  74. package/dist/lifecycle/publish-targets.js +15 -0
  75. package/dist/lifecycle/publish-tauri.d.ts +61 -0
  76. package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
  77. package/dist/lifecycle/publish-tauri.js +181 -0
  78. package/dist/lifecycle/release-cut.d.ts +51 -5
  79. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  80. package/dist/lifecycle/release-cut.js +165 -16
  81. package/dist/lifecycle/release-publish.d.ts +18 -2
  82. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  83. package/dist/lifecycle/release-publish.js +5 -0
  84. package/dist/lifecycle/release-revocation.d.ts +4 -3
  85. package/dist/lifecycle/release-revocation.d.ts.map +1 -1
  86. package/dist/lifecycle/release-revocation.js +5 -4
  87. package/dist/lifecycle/release-store.d.ts +32 -0
  88. package/dist/lifecycle/release-store.d.ts.map +1 -1
  89. package/dist/lifecycle/release-store.js +11 -0
  90. package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
  91. package/dist/lifecycle/snapshot-store.js +17 -9
  92. package/dist/lifecycle/test-passkey.d.ts +25 -0
  93. package/dist/lifecycle/test-passkey.d.ts.map +1 -0
  94. package/dist/lifecycle/test-passkey.js +39 -0
  95. package/dist/notify.d.ts +23 -3
  96. package/dist/notify.d.ts.map +1 -1
  97. package/dist/notify.js +8 -2
  98. package/dist/notify.schema.json +12 -3
  99. package/dist/op/gate.d.ts +1 -1
  100. package/dist/op/gate.d.ts.map +1 -1
  101. package/dist/op/gate.js +2 -1
  102. package/dist/pr-forge.d.ts +20 -0
  103. package/dist/pr-forge.d.ts.map +1 -1
  104. package/dist/pr-forge.js +87 -8
  105. package/dist/release-floors.d.ts +1 -1
  106. package/dist/release-floors.js +1 -1
  107. package/dist/wave-runtime.mjs +333 -331
  108. package/dist/workspace/ci-builds.d.ts +21 -0
  109. package/dist/workspace/ci-builds.d.ts.map +1 -1
  110. package/dist/workspace/ci-builds.js +14 -0
  111. package/dist/workspace/ci-green.d.ts +45 -2
  112. package/dist/workspace/ci-green.d.ts.map +1 -1
  113. package/dist/workspace/ci-green.js +123 -5
  114. package/dist/workspace/ci-quarantine-report.d.ts +80 -0
  115. package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
  116. package/dist/workspace/ci-quarantine-report.js +204 -0
  117. package/dist/workspace/ci-quarantine.d.ts +73 -0
  118. package/dist/workspace/ci-quarantine.d.ts.map +1 -0
  119. package/dist/workspace/ci-quarantine.js +170 -0
  120. package/dist/workspace/ci-serve.d.ts.map +1 -1
  121. package/dist/workspace/ci-serve.js +7 -4
  122. package/dist/workspace/class-data.d.ts +3 -1
  123. package/dist/workspace/class-data.d.ts.map +1 -1
  124. package/dist/workspace/class-data.js +4 -1
  125. package/dist/workspace/declaration.d.ts +45 -2
  126. package/dist/workspace/declaration.d.ts.map +1 -1
  127. package/dist/workspace/declaration.js +45 -2
  128. package/dist/workspace/declaration.schema.json +51 -3
  129. package/dist/workspace/forge-work.d.ts +76 -0
  130. package/dist/workspace/forge-work.d.ts.map +1 -0
  131. package/dist/workspace/forge-work.js +160 -0
  132. package/dist/workspace/identity-gate-rule.d.ts +3 -2
  133. package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
  134. package/dist/workspace/identity-gate-rule.js +5 -7
  135. package/dist/workspace/identity.d.ts +3 -2
  136. package/dist/workspace/identity.d.ts.map +1 -1
  137. package/dist/workspace/identity.js +6 -3
  138. package/dist/workspace/intent-cli.d.ts +3 -2
  139. package/dist/workspace/intent-cli.d.ts.map +1 -1
  140. package/dist/workspace/intent-cli.js +26 -5
  141. package/dist/workspace/intent-record.d.ts +3 -0
  142. package/dist/workspace/intent-record.d.ts.map +1 -1
  143. package/dist/workspace/intent-record.schema.json +32 -0
  144. package/dist/workspace/intent.d.ts +9 -0
  145. package/dist/workspace/intent.d.ts.map +1 -1
  146. package/dist/workspace/intent.js +2 -0
  147. package/dist/workspace/intent.schema.json +32 -0
  148. package/dist/workspace/kind-readers.d.ts.map +1 -1
  149. package/dist/workspace/kind-readers.js +2 -1
  150. package/dist/workspace/kinds.d.ts +6 -1
  151. package/dist/workspace/kinds.d.ts.map +1 -1
  152. package/dist/workspace/kinds.js +8 -3
  153. package/dist/workspace/plan-stale.schema.json +286 -0
  154. package/dist/workspace/release-candidates.d.ts +42 -7
  155. package/dist/workspace/release-candidates.d.ts.map +1 -1
  156. package/dist/workspace/release-candidates.js +64 -23
  157. package/dist/workspace/release-candidates.schema.json +55 -2
  158. package/dist/workspace/releases.schema.json +47 -0
  159. package/dist/workspace/trust/policy.d.ts +10 -0
  160. package/dist/workspace/trust/policy.d.ts.map +1 -1
  161. package/dist/workspace/trust/policy.js +19 -1
  162. package/dist/workspace/trust/run-commits.d.ts.map +1 -1
  163. package/dist/workspace/trust/run-commits.js +2 -1
  164. package/dist/workspace/trust/seal.d.ts.map +1 -1
  165. package/dist/workspace/trust/seal.js +34 -3
  166. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  167. package/dist/workspace/trust/trust-files.js +6 -1
  168. package/package.json +2 -1
  169. package/src/cli/handlers/approve-external-signature.test.ts +328 -0
  170. package/src/cli/handlers/approve.ts +206 -18
  171. package/src/cli/handlers/plan.ts +74 -0
  172. package/src/cli/handlers/pr.ts +2 -1
  173. package/src/cli/handlers/release.ts +84 -20
  174. package/src/cli/main.ts +48 -7
  175. package/src/cli/mcp/workspace-tools.ts +2 -1
  176. package/src/cli/parse-args.ts +33 -0
  177. package/src/cli/registry.ts +18 -2
  178. package/src/config.ts +8 -0
  179. package/src/gate-decision-bundle.test.ts +4 -2
  180. package/src/gate-decision.ts +11 -2
  181. package/src/gate-statement.schema.json +46 -0
  182. package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
  183. package/src/lifecycle/gate-ledger.ts +34 -5
  184. package/src/lifecycle/gate-seal.ts +86 -15
  185. package/src/lifecycle/gate-statement.ts +144 -0
  186. package/src/lifecycle/gate-webauthn.test.ts +77 -0
  187. package/src/lifecycle/gate-webauthn.ts +133 -0
  188. package/src/lifecycle/git.ts +23 -19
  189. package/src/lifecycle/ledger-remote.test.ts +183 -0
  190. package/src/lifecycle/ledger-remote.ts +46 -0
  191. package/src/lifecycle/plan-stale.test.ts +149 -0
  192. package/src/lifecycle/plan-stale.ts +172 -0
  193. package/src/lifecycle/publish-credentials.ts +2 -0
  194. package/src/lifecycle/publish-declaration.ts +116 -1
  195. package/src/lifecycle/publish-forge.ts +14 -4
  196. package/src/lifecycle/publish-git-ssh.ts +202 -0
  197. package/src/lifecycle/publish-github.ts +174 -0
  198. package/src/lifecycle/publish-homebrew.test.ts +358 -0
  199. package/src/lifecycle/publish-homebrew.ts +283 -0
  200. package/src/lifecycle/publish-marketplace.test.ts +406 -0
  201. package/src/lifecycle/publish-marketplace.ts +421 -0
  202. package/src/lifecycle/publish-resume.test.ts +40 -0
  203. package/src/lifecycle/publish-target-context.test.ts +2 -2
  204. package/src/lifecycle/publish-targets.test.ts +23 -0
  205. package/src/lifecycle/publish-targets.ts +15 -0
  206. package/src/lifecycle/publish-tauri.test.ts +163 -0
  207. package/src/lifecycle/publish-tauri.ts +198 -0
  208. package/src/lifecycle/release-cut-lane.test.ts +177 -0
  209. package/src/lifecycle/release-cut-override.test.ts +213 -0
  210. package/src/lifecycle/release-cut.ts +198 -17
  211. package/src/lifecycle/release-publish.ts +23 -3
  212. package/src/lifecycle/release-revocation.ts +5 -4
  213. package/src/lifecycle/release-store.ts +44 -0
  214. package/src/lifecycle/snapshot-store.ts +16 -9
  215. package/src/lifecycle/test-passkey.ts +55 -0
  216. package/src/notify-bundle.test.ts +3 -1
  217. package/src/notify.schema.json +12 -3
  218. package/src/notify.ts +20 -3
  219. package/src/op/gate.ts +2 -1
  220. package/src/override-gate-bundle.test.ts +2 -0
  221. package/src/pr-forge-bundle.test.ts +2 -2
  222. package/src/pr-forge.test.ts +38 -0
  223. package/src/pr-forge.ts +93 -11
  224. package/src/pr-requires.test.ts +9 -0
  225. package/src/release-floors.ts +1 -1
  226. package/src/stage-hooks-bundle.test.ts +2 -0
  227. package/src/wave-runtime-bundle.test.ts +3 -2
  228. package/src/workspace/ci-builds.ts +27 -0
  229. package/src/workspace/ci-green-stale.test.ts +193 -0
  230. package/src/workspace/ci-green.ts +137 -6
  231. package/src/workspace/ci-quarantine-report.test.ts +145 -0
  232. package/src/workspace/ci-quarantine-report.ts +234 -0
  233. package/src/workspace/ci-quarantine.test.ts +160 -0
  234. package/src/workspace/ci-quarantine.ts +188 -0
  235. package/src/workspace/ci-serve.ts +7 -4
  236. package/src/workspace/class-data.ts +5 -1
  237. package/src/workspace/declaration.schema.json +51 -3
  238. package/src/workspace/declaration.test.ts +1 -0
  239. package/src/workspace/declaration.ts +88 -5
  240. package/src/workspace/forge-work.test.ts +143 -0
  241. package/src/workspace/forge-work.ts +195 -0
  242. package/src/workspace/identity-gate-rule.ts +6 -8
  243. package/src/workspace/identity.ts +6 -3
  244. package/src/workspace/intent-cli.ts +24 -5
  245. package/src/workspace/intent-record.schema.json +32 -0
  246. package/src/workspace/intent-record.ts +3 -0
  247. package/src/workspace/intent.schema.json +32 -0
  248. package/src/workspace/intent.ts +9 -0
  249. package/src/workspace/kind-readers.ts +2 -1
  250. package/src/workspace/kinds.test.ts +13 -0
  251. package/src/workspace/kinds.ts +12 -3
  252. package/src/workspace/plan-stale.schema.json +286 -0
  253. package/src/workspace/release-candidates.schema.json +55 -2
  254. package/src/workspace/release-candidates.test.ts +77 -4
  255. package/src/workspace/release-candidates.ts +80 -23
  256. package/src/workspace/releases.schema.json +47 -0
  257. package/src/workspace/trust/gate-seal.test.ts +44 -0
  258. package/src/workspace/trust/policy.ts +24 -1
  259. package/src/workspace/trust/run-commits.ts +2 -1
  260. package/src/workspace/trust/seal.ts +35 -3
  261. package/src/workspace/trust/trust-files.test.ts +5 -0
  262. package/src/workspace/trust/trust-files.ts +15 -1
@@ -10,6 +10,9 @@
10
10
  * { type: "npm", packages: ["packages/core", "packages/cli"] },
11
11
  * { type: "oci", image: "dist/api.oci.tar", repository: "ghcr.io/acme/api", tags: ["{label}"], usernameEnv: "GITHUB_ACTOR", passwordEnv: "GITHUB_TOKEN" },
12
12
  * { type: "forge", forge: "github", repo: "acme/api", assets: ["dist/api-linux-amd64.tar.gz"] },
13
+ * { type: "marketplace", marketplace: "openvsx", vsix: "dist/acme.vsix" },
14
+ * { type: "tauri-updater", repo: "acme/app", tag: "app-latest", platforms: { "darwin-aarch64": "dist/Acme_aarch64.app.tar.gz" } },
15
+ * { type: "homebrew", tap: "acme/homebrew-tap", formula: "Formula/api.rb", template: "packaging/api.rb", assets: ["dist/api-linux-amd64.tar.gz"], url: "https://github.com/acme/api/releases/download/{tag}/{name}" },
13
16
  * ],
14
17
  * },
15
18
  * };
@@ -61,6 +64,65 @@ export declare const ForgePublishSchema: z.ZodObject<{
61
64
  tag: z.ZodOptional<z.ZodString>;
62
65
  tokenEnv: z.ZodOptional<z.ZodString>;
63
66
  sbom: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
67
+ latest: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"legacy">]>>;
68
+ }, z.core.$strict>;
69
+ /**
70
+ * A Homebrew formula in a tap repository on GitHub (#4676), rendered from a
71
+ * template in the member with the release's version and each asset's URL and
72
+ * SHA-256 (./publish-homebrew.ts).
73
+ */
74
+ export declare const HomebrewPublishSchema: z.ZodObject<{
75
+ type: z.ZodLiteral<"homebrew">;
76
+ tap: z.ZodString;
77
+ formula: z.ZodString;
78
+ template: z.ZodString;
79
+ assets: z.ZodArray<z.ZodString>;
80
+ url: z.ZodString;
81
+ branch: z.ZodOptional<z.ZodString>;
82
+ api: z.ZodOptional<z.ZodString>;
83
+ tokenEnv: z.ZodOptional<z.ZodString>;
84
+ sshKeyEnv: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strict>;
86
+ /**
87
+ * A packaged `.vsix` on the VS Code Marketplace or Open VSX (#4676), uploaded
88
+ * at the reveal, since a marketplace has no draft (./publish-marketplace.ts).
89
+ */
90
+ export declare const MarketplacePublishSchema: z.ZodObject<{
91
+ type: z.ZodLiteral<"marketplace">;
92
+ marketplace: z.ZodEnum<{
93
+ openvsx: "openvsx";
94
+ vscode: "vscode";
95
+ }>;
96
+ vsix: z.ZodString;
97
+ registry: z.ZodOptional<z.ZodString>;
98
+ tokenEnv: z.ZodOptional<z.ZodString>;
99
+ auth: z.ZodOptional<z.ZodEnum<{
100
+ "azure-credential": "azure-credential";
101
+ token: "token";
102
+ "trusted-publishing": "trusted-publishing";
103
+ }>>;
104
+ onRefusal: z.ZodOptional<z.ZodEnum<{
105
+ fail: "fail";
106
+ warn: "warn";
107
+ }>>;
108
+ }, z.core.$strict>;
109
+ /**
110
+ * A Tauri v2 updater manifest and the rolling GitHub release that holds it
111
+ * with the app's bundles (#4676), replaced on each publish
112
+ * (./publish-tauri.ts).
113
+ */
114
+ export declare const TauriUpdaterPublishSchema: z.ZodObject<{
115
+ type: z.ZodLiteral<"tauri-updater">;
116
+ repo: z.ZodString;
117
+ tag: z.ZodString;
118
+ platforms: z.ZodRecord<z.ZodString, z.ZodString>;
119
+ assets: z.ZodOptional<z.ZodArray<z.ZodString>>;
120
+ notes: z.ZodOptional<z.ZodString>;
121
+ url: z.ZodOptional<z.ZodString>;
122
+ manifest: z.ZodOptional<z.ZodString>;
123
+ latest: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"legacy">]>>;
124
+ api: z.ZodOptional<z.ZodString>;
125
+ tokenEnv: z.ZodOptional<z.ZodString>;
64
126
  }, z.core.$strict>;
65
127
  export declare const PublishDeclarationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
66
128
  type: z.ZodLiteral<"npm">;
@@ -95,9 +157,54 @@ export declare const PublishDeclarationSchema: z.ZodDiscriminatedUnion<[z.ZodObj
95
157
  tag: z.ZodOptional<z.ZodString>;
96
158
  tokenEnv: z.ZodOptional<z.ZodString>;
97
159
  sbom: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
160
+ latest: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"legacy">]>>;
161
+ }, z.core.$strict>, z.ZodObject<{
162
+ type: z.ZodLiteral<"homebrew">;
163
+ tap: z.ZodString;
164
+ formula: z.ZodString;
165
+ template: z.ZodString;
166
+ assets: z.ZodArray<z.ZodString>;
167
+ url: z.ZodString;
168
+ branch: z.ZodOptional<z.ZodString>;
169
+ api: z.ZodOptional<z.ZodString>;
170
+ tokenEnv: z.ZodOptional<z.ZodString>;
171
+ sshKeyEnv: z.ZodOptional<z.ZodString>;
172
+ }, z.core.$strict>, z.ZodObject<{
173
+ type: z.ZodLiteral<"marketplace">;
174
+ marketplace: z.ZodEnum<{
175
+ openvsx: "openvsx";
176
+ vscode: "vscode";
177
+ }>;
178
+ vsix: z.ZodString;
179
+ registry: z.ZodOptional<z.ZodString>;
180
+ tokenEnv: z.ZodOptional<z.ZodString>;
181
+ auth: z.ZodOptional<z.ZodEnum<{
182
+ "azure-credential": "azure-credential";
183
+ token: "token";
184
+ "trusted-publishing": "trusted-publishing";
185
+ }>>;
186
+ onRefusal: z.ZodOptional<z.ZodEnum<{
187
+ fail: "fail";
188
+ warn: "warn";
189
+ }>>;
190
+ }, z.core.$strict>, z.ZodObject<{
191
+ type: z.ZodLiteral<"tauri-updater">;
192
+ repo: z.ZodString;
193
+ tag: z.ZodString;
194
+ platforms: z.ZodRecord<z.ZodString, z.ZodString>;
195
+ assets: z.ZodOptional<z.ZodArray<z.ZodString>>;
196
+ notes: z.ZodOptional<z.ZodString>;
197
+ url: z.ZodOptional<z.ZodString>;
198
+ manifest: z.ZodOptional<z.ZodString>;
199
+ latest: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"legacy">]>>;
200
+ api: z.ZodOptional<z.ZodString>;
201
+ tokenEnv: z.ZodOptional<z.ZodString>;
98
202
  }, z.core.$strict>], "type">;
99
203
  export type NpmPublishDeclaration = z.infer<typeof NpmPublishSchema>;
100
204
  export type OciPublishDeclaration = z.infer<typeof OciPublishSchema>;
101
205
  export type ForgePublishDeclaration = z.infer<typeof ForgePublishSchema>;
206
+ export type HomebrewPublishDeclaration = z.infer<typeof HomebrewPublishSchema>;
207
+ export type MarketplacePublishDeclaration = z.infer<typeof MarketplacePublishSchema>;
208
+ export type TauriUpdaterPublishDeclaration = z.infer<typeof TauriUpdaterPublishSchema>;
102
209
  export type PublishDeclaration = z.infer<typeof PublishDeclarationSchema>;
103
210
  //# sourceMappingURL=publish-declaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publish-declaration.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-declaration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;kBAqClB,CAAC;AAEZ,8FAA8F;AAC9F,eAAO,MAAM,gBAAgB;;;;;;;;kBAgBlB,CAAC;AAEZ,wFAAwF;AACxF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;kBAiBpB,CAAC;AAEZ,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAAyF,CAAC;AAE/H,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACrE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACrE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACzE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"publish-declaration.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-declaration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;kBAqClB,CAAC;AAEZ,8FAA8F;AAC9F,eAAO,MAAM,gBAAgB;;;;;;;;kBAgBlB,CAAC;AAEZ,wFAAwF;AACxF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;kBAwBpB,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;kBA0BvB,CAAC;AAEZ;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;kBA4B1B,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;kBA4B3B,CAAC;AAEZ,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAAqK,CAAC;AAE3M,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACrE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACrE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACzE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC/E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACrF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -10,6 +10,9 @@
10
10
  * { type: "npm", packages: ["packages/core", "packages/cli"] },
11
11
  * { type: "oci", image: "dist/api.oci.tar", repository: "ghcr.io/acme/api", tags: ["{label}"], usernameEnv: "GITHUB_ACTOR", passwordEnv: "GITHUB_TOKEN" },
12
12
  * { type: "forge", forge: "github", repo: "acme/api", assets: ["dist/api-linux-amd64.tar.gz"] },
13
+ * { type: "marketplace", marketplace: "openvsx", vsix: "dist/acme.vsix" },
14
+ * { type: "tauri-updater", repo: "acme/app", tag: "app-latest", platforms: { "darwin-aarch64": "dist/Acme_aarch64.app.tar.gz" } },
15
+ * { type: "homebrew", tap: "acme/homebrew-tap", formula: "Formula/api.rb", template: "packaging/api.rb", assets: ["dist/api-linux-amd64.tar.gz"], url: "https://github.com/acme/api/releases/download/{tag}/{name}" },
13
16
  * ],
14
17
  * },
15
18
  * };
@@ -100,6 +103,112 @@ export const ForgePublishSchema = z
100
103
  tokenEnv: envName.optional(),
101
104
  /** The SBOM attached to the release (#4049), relative to the member. Default: one written from the member's lockfile. `false` publishes without one. */
102
105
  sbom: sbomField.optional(),
106
+ /**
107
+ * GitHub only (#4676): whether the release becomes the repository's
108
+ * latest when the reveal publishes it, sent as GitHub's `make_latest`.
109
+ * `"legacy"` lets GitHub pick by creation date and semantic version.
110
+ * Unset, nothing is sent and GitHub makes it latest.
111
+ */
112
+ latest: z.union([z.boolean(), z.literal("legacy")]).optional(),
113
+ })
114
+ .strict();
115
+ /**
116
+ * A Homebrew formula in a tap repository on GitHub (#4676), rendered from a
117
+ * template in the member with the release's version and each asset's URL and
118
+ * SHA-256 (./publish-homebrew.ts).
119
+ */
120
+ export const HomebrewPublishSchema = z
121
+ .object({
122
+ type: z.literal("homebrew"),
123
+ /** The tap's repository, `owner/name`, such as `acme/homebrew-tap`. */
124
+ tap: z.string().regex(/^[^/\s]+\/[^/\s]+$/, "owner/name"),
125
+ /** The formula's path in the tap, such as `Formula/api.rb`. */
126
+ formula: z.string().min(1),
127
+ /** The formula with placeholders, relative to the member: `{{version}}`, `{{label}}`, `{{tag}}`, `{{url:<asset name>}}`, `{{sha256:<asset name>}}`. */
128
+ template: z.string().min(1),
129
+ /** The files the formula downloads, relative to the member. Each is named in the template by its file name. */
130
+ assets: z.array(z.string().min(1)).min(1),
131
+ /** Where each asset is downloaded from: `{tag}`, `{label}`, `{version}` and `{name}` (its file name) are filled in. */
132
+ url: z.string().min(1),
133
+ /** The tap's branch that brew installs from. Default: the repository's default branch. */
134
+ branch: z.string().min(1).optional(),
135
+ /** The GitHub API root. Default `$GITHUB_API_URL`, else `https://api.github.com`. */
136
+ api: z.string().url().optional(),
137
+ /** The variable holding a token that may push to the tap. Default `HOMEBREW_TAP_TOKEN`. */
138
+ tokenEnv: envName.optional(),
139
+ /**
140
+ * The variable holding an SSH private key that may push to the tap, such
141
+ * as a deploy key with write access (#4699). Set, the target pushes with
142
+ * git over SSH and reads no token; `tokenEnv` beside it is refused.
143
+ */
144
+ sshKeyEnv: envName.optional(),
145
+ })
146
+ .strict();
147
+ /**
148
+ * A packaged `.vsix` on the VS Code Marketplace or Open VSX (#4676), uploaded
149
+ * at the reveal, since a marketplace has no draft (./publish-marketplace.ts).
150
+ */
151
+ export const MarketplacePublishSchema = z
152
+ .object({
153
+ type: z.literal("marketplace"),
154
+ marketplace: z.enum(["vscode", "openvsx"]),
155
+ /** The `.vsix` that `vsce package` wrote, relative to the member. Its publisher, name and version are read from it. */
156
+ vsix: z.string().min(1),
157
+ /** Open VSX's root, default `https://open-vsx.org`; the VS Code Marketplace's gallery, default `https://marketplace.visualstudio.com`. */
158
+ registry: z.string().url().optional(),
159
+ /** The variable holding the token, under `auth: "token"`. Default `VSCE_PAT` for the VS Code Marketplace, `OVSX_PAT` for Open VSX. */
160
+ tokenEnv: envName.optional(),
161
+ /**
162
+ * How the target authenticates (#4698). `"token"` (the default) reads a
163
+ * token from `tokenEnv`. `"azure-credential"`, VS Code Marketplace only,
164
+ * runs `vsce` with `--azure-credential`, which signs in with the Microsoft
165
+ * Entra identity the job has, such as one `azure/login` set up from the
166
+ * run's OIDC token. `"trusted-publishing"`, Open VSX only, exchanges the
167
+ * run's OIDC ID token for a short-lived publishing token, as
168
+ * `ovsx publish --trusted-publishing` does.
169
+ */
170
+ auth: z.enum(["token", "azure-credential", "trusted-publishing"]).optional(),
171
+ /**
172
+ * What the reveal does when the marketplace refuses the upload (#4698).
173
+ * `"fail"` (the default) fails the publish. `"warn"` prints a warning
174
+ * and goes on to the next target, and the target is not recorded as
175
+ * published, so the same publish run again tries the upload again.
176
+ */
177
+ onRefusal: z.enum(["fail", "warn"]).optional(),
178
+ })
179
+ .strict();
180
+ /**
181
+ * A Tauri v2 updater manifest and the rolling GitHub release that holds it
182
+ * with the app's bundles (#4676), replaced on each publish
183
+ * (./publish-tauri.ts).
184
+ */
185
+ export const TauriUpdaterPublishSchema = z
186
+ .object({
187
+ type: z.literal("tauri-updater"),
188
+ /** The GitHub repository, `owner/name`. */
189
+ repo: z.string().regex(/^[^/\s]+\/[^/\s]+$/, "owner/name"),
190
+ /** The rolling release's tag, such as `app-latest`. */
191
+ tag: z.string().min(1),
192
+ /**
193
+ * Each updater platform, such as `darwin-aarch64`, `linux-x86_64` or
194
+ * `windows-x86_64-nsis`, and its updater bundle, relative to the member.
195
+ * Its signature is the `.sig` file beside it that the Tauri build wrote.
196
+ */
197
+ platforms: z.record(z.string().regex(/^(darwin|linux|windows)-[a-z0-9_]+(-[a-z0-9]+)?$/, "<os>-<arch> or <os>-<arch>-<installer>"), z.string().min(1)).refine((p) => Object.keys(p).length > 0, "at least one platform"),
198
+ /** More files the rolling release holds, such as installers for the site's download links, relative to the member. */
199
+ assets: z.array(z.string().min(1)).optional(),
200
+ /** A file whose text is the manifest's `notes`, relative to the member. */
201
+ notes: z.string().min(1).optional(),
202
+ /** Each platform's URL in the manifest: `{tag}` (the rolling tag), `{label}`, `{version}` and `{name}` are filled in. Default: the bundle's download URL on the rolling release on github.com. */
203
+ url: z.string().min(1).optional(),
204
+ /** The manifest's asset name. Default `latest.json`. */
205
+ manifest: z.string().regex(/^[^/\\]+$/, "a file name").optional(),
206
+ /** GitHub's `make_latest` for the rolling release. Default `false`. */
207
+ latest: z.union([z.boolean(), z.literal("legacy")]).optional(),
208
+ /** The GitHub API root. Default `$GITHUB_API_URL`, else `https://api.github.com`. */
209
+ api: z.string().url().optional(),
210
+ /** The variable holding the token. Default `GITHUB_TOKEN`. */
211
+ tokenEnv: envName.optional(),
103
212
  })
104
213
  .strict();
105
- export const PublishDeclarationSchema = z.discriminatedUnion("type", [NpmPublishSchema, OciPublishSchema, ForgePublishSchema]);
214
+ export const PublishDeclarationSchema = z.discriminatedUnion("type", [NpmPublishSchema, OciPublishSchema, ForgePublishSchema, HomebrewPublishSchema, MarketplacePublishSchema, TauriUpdaterPublishSchema]);
@@ -16,7 +16,9 @@
16
16
  * GitHub uploads each asset to the draft's `upload_url`, Forgejo with a
17
17
  * multipart `POST /repos/{repo}/releases/{id}/assets`. The reveal publishes
18
18
  * the draft, `PATCH /repos/{repo}/releases/{id}` with `draft: false`, and
19
- * the forge creates the tag then if it was not pushed.
19
+ * the forge creates the tag then if it was not pushed. On GitHub, a
20
+ * declared `latest` goes in the same request as `make_latest` (#4676), so
21
+ * the release becomes the repository's latest, or doesn't, as it appears.
20
22
  * - GitLab has no draft release, so its stage puts each asset in the
21
23
  * project's generic package registry (package `release`, version the
22
24
  * label) and makes no release. The reveal creates the release at the
@@ -43,6 +45,8 @@
43
45
  */
44
46
  import type { ForgePublishDeclaration } from "./publish-declaration.js";
45
47
  import { type PublishDeps, type PublishTarget } from "./release-publish.js";
48
+ /** The first chant that reads `latest` on a forge target and sends it as GitHub's `make_latest` (#4676). */
49
+ export declare const PUBLISH_FORGE_LATEST_FLOOR = "0.124.63";
46
50
  /** The variables a forge's token is read from, in order. */
47
51
  export declare function forgeTokenEnv(decl: Pick<ForgePublishDeclaration, "forge" | "tokenEnv">): string[];
48
52
  /** The API root a forge is reached at. */
@@ -1 +1 @@
1
- {"version":3,"file":"publish-forge.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-forge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAMH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAA2C,KAAK,WAAW,EAAuC,KAAK,aAAa,EAAqB,MAAM,mBAAmB,CAAC;AAE1K,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG,MAAM,EAAE,CAKjG;AAED,0CAA0C;AAC1C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAGpH;AAqID,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CA0H3F"}
1
+ {"version":3,"file":"publish-forge.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-forge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAA2C,KAAK,WAAW,EAAuC,KAAK,aAAa,EAAqB,MAAM,mBAAmB,CAAC;AAE1K,4GAA4G;AAC5G,eAAO,MAAM,0BAA0B,aAAa,CAAC;AAErD,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG,MAAM,EAAE,CAKjG;AAED,0CAA0C;AAC1C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAGpH;AAuID,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CA6H3F"}
@@ -16,7 +16,9 @@
16
16
  * GitHub uploads each asset to the draft's `upload_url`, Forgejo with a
17
17
  * multipart `POST /repos/{repo}/releases/{id}/assets`. The reveal publishes
18
18
  * the draft, `PATCH /repos/{repo}/releases/{id}` with `draft: false`, and
19
- * the forge creates the tag then if it was not pushed.
19
+ * the forge creates the tag then if it was not pushed. On GitHub, a
20
+ * declared `latest` goes in the same request as `make_latest` (#4676), so
21
+ * the release becomes the repository's latest, or doesn't, as it appears.
20
22
  * - GitLab has no draft release, so its stage puts each asset in the
21
23
  * project's generic package registry (package `release`, version the
22
24
  * label) and makes no release. The reveal creates the release at the
@@ -47,6 +49,8 @@ import { memberSbom, releaseProvenance } from "./publish-attachments.js";
47
49
  import { readCredential } from "./publish-credentials.js";
48
50
  import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
49
51
  import { PublishTargetError } from "./release-publish.js";
52
+ /** The first chant that reads `latest` on a forge target and sends it as GitHub's `make_latest` (#4676). */
53
+ export const PUBLISH_FORGE_LATEST_FLOOR = "0.124.63";
50
54
  /** The variables a forge's token is read from, in order. */
51
55
  export function forgeTokenEnv(decl) {
52
56
  if (decl.tokenEnv)
@@ -137,9 +141,11 @@ class ForgeClient {
137
141
  this.fail(`creating a draft release ${tag}`, create.status, create.text);
138
142
  return this.toRelease(create.json, tag);
139
143
  }
140
- /** GitHub and Forgejo: publish the draft `id`. */
144
+ /** GitHub and Forgejo: publish the draft `id`, with GitHub's `make_latest` when `latest` is declared. */
141
145
  async publishDraft(id, tag) {
142
- const res = await this.call("PATCH", `${this.repoPath}/releases/${id}`, JSON.stringify({ draft: false }));
146
+ const latest = this.decl.latest;
147
+ const body = latest === undefined ? { draft: false } : { draft: false, make_latest: String(latest) };
148
+ const res = await this.call("PATCH", `${this.repoPath}/releases/${id}`, JSON.stringify(body));
143
149
  if (res.status !== 200)
144
150
  this.fail(`publishing the draft release ${tag}`, res.status, res.text);
145
151
  }
@@ -187,6 +193,9 @@ export function forgeTarget(decl, deps) {
187
193
  if (!tag) {
188
194
  throw new PublishTargetError("publish-forge-no-tag", `a ${decl.forge} release is named by a tag, and release ${ctx.release.releaseDigest} has no label`, "Cut the release with a label, or set tag in the declaration.");
189
195
  }
196
+ if (decl.latest !== undefined && decl.forge !== "github") {
197
+ throw new PublishTargetError("publish-forge-latest-unsupported", `latest is GitHub's make_latest, and ${decl.forge} has no setting for which release is latest`, "Remove latest from the declaration.");
198
+ }
190
199
  const api = forgeApi(decl, ctx.env);
191
200
  if (!api)
192
201
  throw new PublishTargetError("publish-forge-no-api", "a Forgejo target needs its API root, and neither api nor GITHUB_API_URL is set", "Set api, such as https://forgejo.example/api/v1.");
@@ -289,7 +298,7 @@ export function forgeTarget(decl, deps) {
289
298
  const id = staged.state.releaseId;
290
299
  if (!id)
291
300
  throw new PublishTargetError("publish-forge-failed", `the staged ${decl.forge} release for ${tag} has no draft id to publish`);
292
- ctx.log(`publishing the draft ${decl.forge} release ${tag}`);
301
+ ctx.log(`publishing the draft ${decl.forge} release ${tag}${decl.latest === undefined ? "" : ` with make_latest ${String(decl.latest)}`}`);
293
302
  await client.publishDraft(id, tag);
294
303
  }
295
304
  return { target: this.name, destination: this.destination, items };
@@ -0,0 +1,82 @@
1
+ /**
2
+ * One repository reached with git over SSH and one private key (#4699), for
3
+ * a target that may not use a forge's API token, such as a Homebrew tap
4
+ * written with a deploy key.
5
+ *
6
+ * Each {@link SshGitRepo} works in a temporary bare repository of its own.
7
+ * It fetches only the branches it reads, at depth 1, makes commits with git's
8
+ * plumbing (no checkout), and pushes. The key is written to a file only the
9
+ * user can read, inside that directory, and the directory is removed by
10
+ * {@link SshGitRepo.close}.
11
+ *
12
+ * The host's keys are pinned: ssh runs with `StrictHostKeyChecking=yes` and a
13
+ * known-hosts file written from the `ssh_keys` that GitHub's `GET /meta`
14
+ * lists, read over HTTPS from the API root. ssh reads no config file
15
+ * (`-F /dev/null`) and offers only the key (`IdentitiesOnly=yes`).
16
+ */
17
+ import type { Credential } from "./publish-credentials.js";
18
+ import { type PublishContextBase, type PublishFetch } from "./release-publish.js";
19
+ /** The SSH host for a GitHub API root: `github.com` for `https://api.github.com`, else the API's own host (GitHub Enterprise Server). */
20
+ export declare function githubSshHost(api: string): string;
21
+ /** The SSH URL of `owner/name` on `host`. */
22
+ export declare function sshRemote(host: string, repo: string): string;
23
+ /** What a push did: `ok`, or `rejected` when the remote refused a non-fast-forward. Any other failure throws. */
24
+ export type PushResult = "ok" | "rejected";
25
+ export declare class SshGitRepo {
26
+ readonly repo: string;
27
+ readonly host: string;
28
+ private readonly ctx;
29
+ private readonly git;
30
+ /** The code a failure throws. */
31
+ private readonly code;
32
+ /** The temporary directory: the key, the known hosts, the repository. */
33
+ private readonly root;
34
+ private readonly env;
35
+ /** The bare repository, inside {@link root}. */
36
+ private readonly dir;
37
+ readonly remote: string;
38
+ private constructor();
39
+ /**
40
+ * A repository session: reads the host's keys from `GET {api}/meta`, writes
41
+ * them and the key to a temporary directory, and makes an empty bare
42
+ * repository there. Close it with {@link close}.
43
+ */
44
+ static open(opts: {
45
+ api: string;
46
+ repo: string;
47
+ key: Credential;
48
+ ctx: PublishContextBase;
49
+ fetch: PublishFetch;
50
+ code: string;
51
+ git?: string;
52
+ ssh?: string;
53
+ }): Promise<SshGitRepo>;
54
+ /** Remove the temporary directory, with the key in it. */
55
+ close(): void;
56
+ private run;
57
+ private must;
58
+ private fail;
59
+ /** The remote's default branch and the head of each of its branches. */
60
+ heads(): Promise<{
61
+ defaultBranch: string | null;
62
+ heads: Map<string, string>;
63
+ }>;
64
+ /**
65
+ * Fetch `branch` and return its head. `depth` 1 is enough to read it and
66
+ * commit on it; 2 also brings its head's parent, so git sees that pushing
67
+ * the head fast-forwards a branch at that parent.
68
+ */
69
+ fetch(branch: string, depth?: number): Promise<string>;
70
+ /** The bytes of `path` at a fetched commit, or null when it holds no such file. */
71
+ file(commit: string, path: string): Promise<Buffer | null>;
72
+ /** A commit on `parent` that writes `bytes` to `path`, with `message`. Made here, not pushed. */
73
+ commitFile(parent: string, path: string, bytes: Uint8Array, message: string): Promise<string>;
74
+ /**
75
+ * Push `commit` to `branch`. `force` moves it wherever it is; without it,
76
+ * a branch that does not fast-forward comes back `rejected`.
77
+ */
78
+ push(commit: string, branch: string, force: boolean): Promise<PushResult>;
79
+ /** Delete `branch` on the remote, if it is there. */
80
+ deleteBranch(branch: string): Promise<void>;
81
+ }
82
+ //# sourceMappingURL=publish-git-ssh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-git-ssh.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-git-ssh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAsB,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEnG,yIAAyI;AACzI,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED,6CAA6C;AAC7C,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAOD,iHAAiH;AACjH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,UAAU,CAAC;AAE3C,qBAAa,UAAU;IAMnB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,iCAAiC;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,yEAAyE;IACzE,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAbtB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,eAaN;IAED;;;;OAIG;IACH,OAAa,IAAI,CAAC,IAAI,EAAE;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,UAAU,CAAC;QAChB,GAAG,EAAE,kBAAkB,CAAC;QACxB,KAAK,EAAE,YAAY,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,UAAU,CAAC,CA8BtB;IAED,0DAA0D;IAC1D,KAAK,IAAI,IAAI,CAEZ;IAED,OAAO,CAAC,GAAG;YAYG,IAAI;IAMlB,OAAO,CAAC,IAAI;IAMZ,wEAAwE;IAClE,KAAK,IAAI,OAAO,CAAC;QAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAWnF;IAED;;;;OAIG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtD;IAED,mFAAmF;IAC7E,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAM/D;IAED,iGAAiG;IAC3F,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWlG;IAED;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAK9E;IAED,qDAAqD;IAC/C,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhD;CACF"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * One repository reached with git over SSH and one private key (#4699), for
3
+ * a target that may not use a forge's API token, such as a Homebrew tap
4
+ * written with a deploy key.
5
+ *
6
+ * Each {@link SshGitRepo} works in a temporary bare repository of its own.
7
+ * It fetches only the branches it reads, at depth 1, makes commits with git's
8
+ * plumbing (no checkout), and pushes. The key is written to a file only the
9
+ * user can read, inside that directory, and the directory is removed by
10
+ * {@link SshGitRepo.close}.
11
+ *
12
+ * The host's keys are pinned: ssh runs with `StrictHostKeyChecking=yes` and a
13
+ * known-hosts file written from the `ssh_keys` that GitHub's `GET /meta`
14
+ * lists, read over HTTPS from the API root. ssh reads no config file
15
+ * (`-F /dev/null`) and offers only the key (`IdentitiesOnly=yes`).
16
+ */
17
+ import { execFile } from "node:child_process";
18
+ import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
19
+ import { tmpdir } from "node:os";
20
+ import { join } from "node:path";
21
+ import { PublishTargetError } from "./release-publish.js";
22
+ /** The SSH host for a GitHub API root: `github.com` for `https://api.github.com`, else the API's own host (GitHub Enterprise Server). */
23
+ export function githubSshHost(api) {
24
+ const host = new URL(api).hostname;
25
+ return host === "api.github.com" ? "github.com" : host;
26
+ }
27
+ /** The SSH URL of `owner/name` on `host`. */
28
+ export function sshRemote(host, repo) {
29
+ return `git@${host}:${repo}.git`;
30
+ }
31
+ /** A shell word for GIT_SSH_COMMAND, which git runs through the shell. */
32
+ function shellWord(s) {
33
+ return /^[A-Za-z0-9_./:@=-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
34
+ }
35
+ export class SshGitRepo {
36
+ constructor(repo, host, ctx, git,
37
+ /** The code a failure throws. */
38
+ code,
39
+ /** The temporary directory: the key, the known hosts, the repository. */
40
+ root, env) {
41
+ this.repo = repo;
42
+ this.host = host;
43
+ this.ctx = ctx;
44
+ this.git = git;
45
+ this.code = code;
46
+ this.root = root;
47
+ this.env = env;
48
+ this.dir = join(root, "repo.git");
49
+ this.remote = sshRemote(host, repo);
50
+ }
51
+ /**
52
+ * A repository session: reads the host's keys from `GET {api}/meta`, writes
53
+ * them and the key to a temporary directory, and makes an empty bare
54
+ * repository there. Close it with {@link close}.
55
+ */
56
+ static async open(opts) {
57
+ const host = githubSshHost(opts.api);
58
+ const meta = await opts.fetch(`${opts.api}/meta`, { method: "GET", headers: { accept: "application/vnd.github+json", "user-agent": "chant" } });
59
+ const text = await meta.text().catch(() => "");
60
+ let keys;
61
+ try {
62
+ keys = meta.status === 200 ? JSON.parse(text).ssh_keys : undefined;
63
+ }
64
+ catch {
65
+ keys = undefined;
66
+ }
67
+ if (!Array.isArray(keys) || keys.length === 0 || !keys.every((k) => typeof k === "string" && /^[a-z0-9@.-]+ [A-Za-z0-9+/=]+$/.test(k))) {
68
+ throw new PublishTargetError(opts.code, `${opts.api}/meta gave no SSH host keys for ${host} (it answered ${meta.status}), so ${host} can't be checked`, "Set api to the GitHub API root of the host the repository is on.");
69
+ }
70
+ const dir = mkdtempSync(join(tmpdir(), "chant-git-ssh-"));
71
+ try {
72
+ const keyFile = join(dir, "key");
73
+ writeFileSync(keyFile, opts.key.value.endsWith("\n") ? opts.key.value : `${opts.key.value}\n`, { mode: 0o600 });
74
+ chmodSync(keyFile, 0o600);
75
+ const knownHosts = join(dir, "known_hosts");
76
+ writeFileSync(knownHosts, keys.map((k) => `${host} ${k}\n`).join(""));
77
+ const ssh = [opts.ssh ?? "ssh", "-F", "/dev/null", "-i", keyFile, "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=yes", "-o", `UserKnownHostsFile=${knownHosts}`, "-o", "BatchMode=yes"];
78
+ const env = { ...opts.ctx.env, GIT_SSH_COMMAND: ssh.map(shellWord).join(" "), GIT_TERMINAL_PROMPT: "0" };
79
+ for (const v of ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY", "GIT_SSH", "GIT_SSH_VARIANT"])
80
+ delete env[v];
81
+ const repo = new SshGitRepo(opts.repo, host, opts.ctx, opts.git ?? "git", opts.code, dir, env);
82
+ await repo.run(["init", "-q", "--bare", repo.dir], dir);
83
+ return repo;
84
+ }
85
+ catch (err) {
86
+ rmSync(dir, { recursive: true, force: true });
87
+ throw err;
88
+ }
89
+ }
90
+ /** Remove the temporary directory, with the key in it. */
91
+ close() {
92
+ rmSync(this.root, { recursive: true, force: true });
93
+ }
94
+ run(args, cwd = this.dir, extraEnv = {}) {
95
+ return new Promise((resolvePromise, reject) => {
96
+ execFile(this.git, args, { cwd, env: { ...this.env, ...extraEnv }, encoding: "utf-8", maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
97
+ if (err && typeof err.code === "string") {
98
+ reject(new PublishTargetError(this.code, `git could not be run: ${err.message}`, "Install git on the job's PATH."));
99
+ return;
100
+ }
101
+ resolvePromise({ code: err ? (err.code ?? 1) : 0, stdout, stderr });
102
+ });
103
+ });
104
+ }
105
+ async must(what, args, extraEnv = {}) {
106
+ const r = await this.run(args, this.dir, extraEnv);
107
+ if (r.code !== 0)
108
+ this.fail(what, r.stderr || r.stdout);
109
+ return r.stdout;
110
+ }
111
+ fail(what, output) {
112
+ // git's advice after an ssh failure says nothing ssh didn't, and would push ssh's own line out of the last three.
113
+ const lines = output.split("\n").map((l) => l.trim()).filter((l) => l && !/^(Please make sure you have the correct access rights|and the repository exists\.)$/.test(l));
114
+ throw new PublishTargetError(this.code, this.ctx.redactor.redact(`${what} on ${this.remote} failed${lines.length ? `: ${lines.slice(-3).join(" ")}` : ""}`));
115
+ }
116
+ /** The remote's default branch and the head of each of its branches. */
117
+ async heads() {
118
+ const out = await this.must("listing the branches", ["ls-remote", "--symref", this.remote]);
119
+ const heads = new Map();
120
+ let defaultBranch = null;
121
+ for (const line of out.split("\n")) {
122
+ const sym = /^ref: refs\/heads\/(\S+)\tHEAD$/.exec(line);
123
+ if (sym)
124
+ defaultBranch = sym[1];
125
+ const ref = /^([0-9a-f]{40,64})\trefs\/heads\/(\S+)$/.exec(line);
126
+ if (ref)
127
+ heads.set(ref[2], ref[1]);
128
+ }
129
+ return { defaultBranch, heads };
130
+ }
131
+ /**
132
+ * Fetch `branch` and return its head. `depth` 1 is enough to read it and
133
+ * commit on it; 2 also brings its head's parent, so git sees that pushing
134
+ * the head fast-forwards a branch at that parent.
135
+ */
136
+ async fetch(branch, depth = 1) {
137
+ await this.must(`fetching ${branch}`, ["fetch", "-q", "--no-tags", `--depth=${depth}`, this.remote, `+refs/heads/${branch}:refs/remotes/tap/${branch}`]);
138
+ return (await this.must(`reading ${branch}`, ["rev-parse", `refs/remotes/tap/${branch}`])).trim();
139
+ }
140
+ /** The bytes of `path` at a fetched commit, or null when it holds no such file. */
141
+ async file(commit, path) {
142
+ const spec = `${commit}:${path}`;
143
+ if ((await this.run(["cat-file", "-e", spec])).code !== 0)
144
+ return null;
145
+ return new Promise((resolvePromise, reject) => {
146
+ 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
+ });
148
+ }
149
+ /** A commit on `parent` that writes `bytes` to `path`, with `message`. Made here, not pushed. */
150
+ 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();
154
+ const index = { GIT_INDEX_FILE: join(this.root, "index") };
155
+ 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);
157
+ const tree = (await this.must("writing the tree", ["write-tree"], index)).trim();
158
+ rmSync(index.GIT_INDEX_FILE, { force: true });
159
+ const who = (await this.run(["config", "user.email"])).stdout.trim() ? [] : ["-c", "user.name=chant", "-c", "user.email=chant@localhost"];
160
+ return (await this.must("committing", [...who, "-c", "commit.gpgsign=false", "commit-tree", tree, "-p", parent, "-m", message])).trim();
161
+ }
162
+ /**
163
+ * Push `commit` to `branch`. `force` moves it wherever it is; without it,
164
+ * a branch that does not fast-forward comes back `rejected`.
165
+ */
166
+ async push(commit, branch, force) {
167
+ const r = await this.run(["push", "--porcelain", this.remote, `${force ? "+" : ""}${commit}:refs/heads/${branch}`]);
168
+ if (r.code === 0)
169
+ return "ok";
170
+ if (!force && /^!\t[^\t]*\t\[rejected\] \((non-fast-forward|fetch first)\)/m.test(r.stdout))
171
+ return "rejected";
172
+ this.fail(`pushing ${commit.slice(0, 12)} to ${branch}`, `${r.stdout}\n${r.stderr}`);
173
+ }
174
+ /** Delete `branch` on the remote, if it is there. */
175
+ async deleteBranch(branch) {
176
+ const r = await this.run(["push", "--porcelain", this.remote, `:refs/heads/${branch}`]);
177
+ if (r.code !== 0 && !/remote ref does not exist/.test(`${r.stdout}\n${r.stderr}`))
178
+ this.fail(`deleting ${branch}`, `${r.stdout}\n${r.stderr}`);
179
+ }
180
+ }