obsidian-plugin-dev-kit 0.0.0-stage → 0.3.2

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 (329) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +223 -2
  3. package/bin/opdk.js +34 -0
  4. package/dist/build/args.d.ts +10 -0
  5. package/dist/build/args.js +45 -0
  6. package/dist/build/bundle-check.d.ts +17 -0
  7. package/dist/build/bundle-check.js +42 -0
  8. package/dist/build/bundle-file.d.ts +4 -0
  9. package/dist/build/bundle-file.js +29 -0
  10. package/dist/build/commands.d.ts +5 -0
  11. package/dist/build/commands.js +109 -0
  12. package/dist/build/config.d.ts +3 -0
  13. package/dist/build/config.js +103 -0
  14. package/dist/build/css-imports.d.ts +23 -0
  15. package/dist/build/css-imports.js +50 -0
  16. package/dist/build/css-step.d.ts +10 -0
  17. package/dist/build/css-step.js +27 -0
  18. package/dist/build/css.d.ts +24 -0
  19. package/dist/build/css.js +47 -0
  20. package/dist/build/options.d.ts +55 -0
  21. package/dist/build/options.js +70 -0
  22. package/dist/build/release.d.ts +5 -0
  23. package/dist/build/release.js +34 -0
  24. package/dist/build/report.d.ts +7 -0
  25. package/dist/build/report.js +16 -0
  26. package/dist/build/vault.d.ts +26 -0
  27. package/dist/build/vault.js +290 -0
  28. package/dist/build-info.json +1 -0
  29. package/dist/cli/argv.d.ts +14 -0
  30. package/dist/cli/argv.js +18 -0
  31. package/dist/cli/commands.d.ts +3 -0
  32. package/dist/cli/commands.js +7 -0
  33. package/dist/cli/main.d.ts +2 -0
  34. package/dist/cli/main.js +23 -0
  35. package/dist/cli/process-reporter.d.ts +5 -0
  36. package/dist/cli/process-reporter.js +15 -0
  37. package/dist/cli/registry.d.ts +4 -0
  38. package/dist/cli/registry.js +15 -0
  39. package/dist/cli/reporter.d.ts +53 -0
  40. package/dist/cli/reporter.js +100 -0
  41. package/dist/cli/run.d.ts +9 -0
  42. package/dist/cli/run.js +61 -0
  43. package/dist/cli/types.d.ts +27 -0
  44. package/dist/cli/types.js +1 -0
  45. package/dist/cli/version.d.ts +13 -0
  46. package/dist/cli/version.js +61 -0
  47. package/dist/config/define-config.d.ts +3 -0
  48. package/dist/config/define-config.js +4 -0
  49. package/dist/config/load-config.d.ts +6 -0
  50. package/dist/config/load-config.js +70 -0
  51. package/dist/config/manifest.d.ts +3 -0
  52. package/dist/config/manifest.js +72 -0
  53. package/dist/config/types.d.ts +146 -0
  54. package/dist/config/types.js +23 -0
  55. package/dist/demo/args.d.ts +4 -0
  56. package/dist/demo/args.js +13 -0
  57. package/dist/demo/checks.d.ts +56 -0
  58. package/dist/demo/checks.js +124 -0
  59. package/dist/demo/commands.d.ts +3 -0
  60. package/dist/demo/commands.js +65 -0
  61. package/dist/demo/config.d.ts +57 -0
  62. package/dist/demo/config.js +337 -0
  63. package/dist/demo/ffmpeg-run.d.ts +18 -0
  64. package/dist/demo/ffmpeg-run.js +59 -0
  65. package/dist/demo/ffmpeg.d.ts +63 -0
  66. package/dist/demo/ffmpeg.js +111 -0
  67. package/dist/demo/films.d.ts +46 -0
  68. package/dist/demo/films.js +134 -0
  69. package/dist/demo/phone-layout.d.ts +38 -0
  70. package/dist/demo/phone-layout.js +98 -0
  71. package/dist/demo/phone-render.d.ts +28 -0
  72. package/dist/demo/phone-render.js +124 -0
  73. package/dist/demo/published.d.ts +16 -0
  74. package/dist/demo/published.js +72 -0
  75. package/dist/demo/run.d.ts +31 -0
  76. package/dist/demo/run.js +397 -0
  77. package/dist/demo/stills.d.ts +21 -0
  78. package/dist/demo/stills.js +62 -0
  79. package/dist/e2e/artifacts.d.ts +27 -0
  80. package/dist/e2e/artifacts.js +90 -0
  81. package/dist/e2e/cleanup.d.ts +54 -0
  82. package/dist/e2e/cleanup.js +109 -0
  83. package/dist/e2e/config.d.ts +9 -0
  84. package/dist/e2e/config.js +42 -0
  85. package/dist/e2e/create-test.d.ts +37 -0
  86. package/dist/e2e/create-test.js +109 -0
  87. package/dist/e2e/demo/clip.d.ts +21 -0
  88. package/dist/e2e/demo/clip.js +44 -0
  89. package/dist/e2e/demo/create-demo.d.ts +42 -0
  90. package/dist/e2e/demo/create-demo.js +439 -0
  91. package/dist/e2e/demo/manifest.d.ts +76 -0
  92. package/dist/e2e/demo/manifest.js +168 -0
  93. package/dist/e2e/demo/names.d.ts +18 -0
  94. package/dist/e2e/demo/names.js +44 -0
  95. package/dist/e2e/demo/options.d.ts +22 -0
  96. package/dist/e2e/demo/options.js +59 -0
  97. package/dist/e2e/demo/ownership.d.ts +27 -0
  98. package/dist/e2e/demo/ownership.js +65 -0
  99. package/dist/e2e/demo/page-scripts.d.ts +82 -0
  100. package/dist/e2e/demo/page-scripts.js +250 -0
  101. package/dist/e2e/demo/png.d.ts +8 -0
  102. package/dist/e2e/demo/png.js +23 -0
  103. package/dist/e2e/demo/presets.d.ts +43 -0
  104. package/dist/e2e/demo/presets.js +20 -0
  105. package/dist/e2e/demo/privacy.d.ts +18 -0
  106. package/dist/e2e/demo/privacy.js +30 -0
  107. package/dist/e2e/demo/still-options.d.ts +22 -0
  108. package/dist/e2e/demo/still-options.js +68 -0
  109. package/dist/e2e/demo/types.d.ts +184 -0
  110. package/dist/e2e/demo/types.js +1 -0
  111. package/dist/e2e/electron-binary.d.ts +15 -0
  112. package/dist/e2e/electron-binary.js +30 -0
  113. package/dist/e2e/fixtures.d.ts +62 -0
  114. package/dist/e2e/fixtures.js +68 -0
  115. package/dist/e2e/gate.d.ts +4 -0
  116. package/dist/e2e/gate.js +8 -0
  117. package/dist/e2e/global-setup.d.ts +11 -0
  118. package/dist/e2e/global-setup.js +17 -0
  119. package/dist/e2e/helpers/commands.d.ts +14 -0
  120. package/dist/e2e/helpers/commands.js +56 -0
  121. package/dist/e2e/helpers/create-helpers.d.ts +24 -0
  122. package/dist/e2e/helpers/create-helpers.js +582 -0
  123. package/dist/e2e/helpers/device-metrics.d.ts +21 -0
  124. package/dist/e2e/helpers/device-metrics.js +25 -0
  125. package/dist/e2e/helpers/ime.d.ts +13 -0
  126. package/dist/e2e/helpers/ime.js +19 -0
  127. package/dist/e2e/helpers/layout-page-scripts.d.ts +103 -0
  128. package/dist/e2e/helpers/layout-page-scripts.js +224 -0
  129. package/dist/e2e/helpers/layout.d.ts +83 -0
  130. package/dist/e2e/helpers/layout.js +148 -0
  131. package/dist/e2e/helpers/mobile.d.ts +31 -0
  132. package/dist/e2e/helpers/mobile.js +26 -0
  133. package/dist/e2e/helpers/page-scripts.d.ts +194 -0
  134. package/dist/e2e/helpers/page-scripts.js +467 -0
  135. package/dist/e2e/helpers/settings.d.ts +8 -0
  136. package/dist/e2e/helpers/settings.js +16 -0
  137. package/dist/e2e/helpers/settle.d.ts +28 -0
  138. package/dist/e2e/helpers/settle.js +33 -0
  139. package/dist/e2e/helpers/types.d.ts +193 -0
  140. package/dist/e2e/helpers/types.js +1 -0
  141. package/dist/e2e/helpers/view-mode.d.ts +23 -0
  142. package/dist/e2e/helpers/view-mode.js +35 -0
  143. package/dist/e2e/index.d.ts +14 -0
  144. package/dist/e2e/index.js +4 -0
  145. package/dist/e2e/internals.d.ts +155 -0
  146. package/dist/e2e/internals.js +8 -0
  147. package/dist/e2e/obsidian-path.d.ts +17 -0
  148. package/dist/e2e/obsidian-path.js +31 -0
  149. package/dist/e2e/options.d.ts +123 -0
  150. package/dist/e2e/options.js +244 -0
  151. package/dist/e2e/page-scripts.d.ts +45 -0
  152. package/dist/e2e/page-scripts.js +53 -0
  153. package/dist/e2e/peers.d.ts +9 -0
  154. package/dist/e2e/peers.js +19 -0
  155. package/dist/e2e/plugins.d.ts +32 -0
  156. package/dist/e2e/plugins.js +119 -0
  157. package/dist/e2e/process-tree.d.ts +33 -0
  158. package/dist/e2e/process-tree.js +133 -0
  159. package/dist/e2e/readiness.d.ts +23 -0
  160. package/dist/e2e/readiness.js +63 -0
  161. package/dist/e2e/seed.d.ts +34 -0
  162. package/dist/e2e/seed.js +122 -0
  163. package/dist/e2e/session.d.ts +71 -0
  164. package/dist/e2e/session.js +266 -0
  165. package/dist/e2e/vault.d.ts +52 -0
  166. package/dist/e2e/vault.js +146 -0
  167. package/dist/e2e/version.d.ts +25 -0
  168. package/dist/e2e/version.js +40 -0
  169. package/dist/eslint/index.d.ts +2 -0
  170. package/dist/eslint/index.js +1 -0
  171. package/dist/eslint/obsidian-plugin.d.ts +49 -0
  172. package/dist/eslint/obsidian-plugin.js +115 -0
  173. package/dist/index.d.ts +3 -0
  174. package/dist/index.js +1 -0
  175. package/dist/kit/args.d.ts +7 -0
  176. package/dist/kit/args.js +21 -0
  177. package/dist/kit/commands.d.ts +3 -0
  178. package/dist/kit/commands.js +52 -0
  179. package/dist/kit/files.d.ts +3 -0
  180. package/dist/kit/files.js +24 -0
  181. package/dist/kit/pins.d.ts +89 -0
  182. package/dist/kit/pins.js +178 -0
  183. package/dist/kit/remote.d.ts +13 -0
  184. package/dist/kit/remote.js +33 -0
  185. package/dist/kit/runners.d.ts +11 -0
  186. package/dist/kit/runners.js +53 -0
  187. package/dist/kit/terminal-text.d.ts +6 -0
  188. package/dist/kit/terminal-text.js +20 -0
  189. package/dist/kit/upgrade.d.ts +26 -0
  190. package/dist/kit/upgrade.js +162 -0
  191. package/dist/peers/resolve.d.ts +8 -0
  192. package/dist/peers/resolve.js +28 -0
  193. package/dist/peers/versions.d.ts +30 -0
  194. package/dist/peers/versions.js +32 -0
  195. package/dist/release/api-check.d.ts +27 -0
  196. package/dist/release/api-check.js +119 -0
  197. package/dist/release/args.d.ts +40 -0
  198. package/dist/release/args.js +120 -0
  199. package/dist/release/assets.d.ts +21 -0
  200. package/dist/release/assets.js +35 -0
  201. package/dist/release/build-check.d.ts +43 -0
  202. package/dist/release/build-check.js +184 -0
  203. package/dist/release/build-script.d.ts +12 -0
  204. package/dist/release/build-script.js +30 -0
  205. package/dist/release/build-tagged.d.ts +26 -0
  206. package/dist/release/build-tagged.js +52 -0
  207. package/dist/release/bump.d.ts +24 -0
  208. package/dist/release/bump.js +58 -0
  209. package/dist/release/changelog.d.ts +25 -0
  210. package/dist/release/changelog.js +148 -0
  211. package/dist/release/check.d.ts +38 -0
  212. package/dist/release/check.js +150 -0
  213. package/dist/release/commands.d.ts +3 -0
  214. package/dist/release/commands.js +154 -0
  215. package/dist/release/committed-tree.d.ts +63 -0
  216. package/dist/release/committed-tree.js +118 -0
  217. package/dist/release/config.d.ts +3 -0
  218. package/dist/release/config.js +28 -0
  219. package/dist/release/gh-access.d.ts +14 -0
  220. package/dist/release/gh-access.js +45 -0
  221. package/dist/release/gh.d.ts +10 -0
  222. package/dist/release/gh.js +33 -0
  223. package/dist/release/git.d.ts +49 -0
  224. package/dist/release/git.js +111 -0
  225. package/dist/release/interrupt.d.ts +30 -0
  226. package/dist/release/interrupt.js +60 -0
  227. package/dist/release/json.d.ts +33 -0
  228. package/dist/release/json.js +81 -0
  229. package/dist/release/kit-check.d.ts +8 -0
  230. package/dist/release/kit-check.js +51 -0
  231. package/dist/release/manifest-rules.d.ts +23 -0
  232. package/dist/release/manifest-rules.js +255 -0
  233. package/dist/release/preflight.d.ts +10 -0
  234. package/dist/release/preflight.js +65 -0
  235. package/dist/release/problems.d.ts +24 -0
  236. package/dist/release/problems.js +11 -0
  237. package/dist/release/project-files.d.ts +14 -0
  238. package/dist/release/project-files.js +16 -0
  239. package/dist/release/publish-command.d.ts +21 -0
  240. package/dist/release/publish-command.js +83 -0
  241. package/dist/release/publish-git.d.ts +37 -0
  242. package/dist/release/publish-git.js +108 -0
  243. package/dist/release/publish-state.d.ts +29 -0
  244. package/dist/release/publish-state.js +70 -0
  245. package/dist/release/publish-verify.d.ts +41 -0
  246. package/dist/release/publish-verify.js +112 -0
  247. package/dist/release/publish-wait.d.ts +25 -0
  248. package/dist/release/publish-wait.js +56 -0
  249. package/dist/release/publish.d.ts +35 -0
  250. package/dist/release/publish.js +181 -0
  251. package/dist/release/release-assets.d.ts +39 -0
  252. package/dist/release/release-assets.js +68 -0
  253. package/dist/release/release.d.ts +37 -0
  254. package/dist/release/release.js +179 -0
  255. package/dist/release/remote.d.ts +12 -0
  256. package/dist/release/remote.js +15 -0
  257. package/dist/release/reproducible.d.ts +16 -0
  258. package/dist/release/reproducible.js +34 -0
  259. package/dist/release/run-tests.d.ts +5 -0
  260. package/dist/release/run-tests.js +17 -0
  261. package/dist/release/semver.d.ts +8 -0
  262. package/dist/release/semver.js +60 -0
  263. package/dist/release/version-rules.d.ts +28 -0
  264. package/dist/release/version-rules.js +63 -0
  265. package/dist/release/versions-json.d.ts +15 -0
  266. package/dist/release/versions-json.js +88 -0
  267. package/dist/release/workflow-run.d.ts +44 -0
  268. package/dist/release/workflow-run.js +71 -0
  269. package/dist/scanner/code-checks.d.ts +41 -0
  270. package/dist/scanner/code-checks.js +82 -0
  271. package/dist/scanner/commands.d.ts +3 -0
  272. package/dist/scanner/commands.js +43 -0
  273. package/dist/scanner/config.d.ts +7 -0
  274. package/dist/scanner/config.js +25 -0
  275. package/dist/scanner/css-check.d.ts +26 -0
  276. package/dist/scanner/css-check.js +63 -0
  277. package/dist/scanner/eslint-nesting.d.ts +16 -0
  278. package/dist/scanner/eslint-nesting.js +45 -0
  279. package/dist/scanner/findings.d.ts +23 -0
  280. package/dist/scanner/findings.js +21 -0
  281. package/dist/scanner/git-files.d.ts +16 -0
  282. package/dist/scanner/git-files.js +73 -0
  283. package/dist/scanner/lint.d.ts +47 -0
  284. package/dist/scanner/lint.js +163 -0
  285. package/dist/scanner/meta-checks.d.ts +8 -0
  286. package/dist/scanner/meta-checks.js +22 -0
  287. package/dist/scanner/outside-project.d.ts +19 -0
  288. package/dist/scanner/outside-project.js +20 -0
  289. package/dist/scanner/run.d.ts +19 -0
  290. package/dist/scanner/run.js +78 -0
  291. package/dist/scanner/scanner-config.d.ts +114 -0
  292. package/dist/scanner/scanner-config.js +207 -0
  293. package/dist/scanner/typescript-gate.d.ts +30 -0
  294. package/dist/scanner/typescript-gate.js +73 -0
  295. package/dist/vitest/build-config.d.ts +17 -0
  296. package/dist/vitest/build-config.js +106 -0
  297. package/dist/vitest/define-unit-config.d.ts +27 -0
  298. package/dist/vitest/define-unit-config.js +45 -0
  299. package/dist/vitest/dom/elements.d.ts +87 -0
  300. package/dist/vitest/dom/elements.js +291 -0
  301. package/dist/vitest/dom/index.d.ts +1 -0
  302. package/dist/vitest/dom/index.js +1 -0
  303. package/dist/vitest/dom/install.d.ts +8 -0
  304. package/dist/vitest/dom/install.js +261 -0
  305. package/dist/vitest/dom/setup.d.ts +1 -0
  306. package/dist/vitest/dom/setup.js +3 -0
  307. package/dist/vitest/index.d.ts +3 -0
  308. package/dist/vitest/index.js +2 -0
  309. package/dist/vitest/options.d.ts +92 -0
  310. package/dist/vitest/options.js +136 -0
  311. package/dist/vitest/peers.d.ts +10 -0
  312. package/dist/vitest/peers.js +51 -0
  313. package/dist/vitest/workspace-root.d.ts +7 -0
  314. package/dist/vitest/workspace-root.js +39 -0
  315. package/docs/build.md +232 -0
  316. package/docs/ci.md +182 -0
  317. package/docs/demo.md +364 -0
  318. package/docs/e2e.md +563 -0
  319. package/docs/release.md +374 -0
  320. package/docs/scanner.md +204 -0
  321. package/docs/unit.md +291 -0
  322. package/package.json +100 -4
  323. package/plugins/opdk/skills/audit/SKILL.md +81 -0
  324. package/plugins/opdk/skills/build/SKILL.md +79 -0
  325. package/plugins/opdk/skills/demo/SKILL.md +102 -0
  326. package/plugins/opdk/skills/e2e/SKILL.md +132 -0
  327. package/plugins/opdk/skills/release/SKILL.md +84 -0
  328. package/plugins/opdk/skills/scanner/SKILL.md +60 -0
  329. package/plugins/opdk/skills/unit/SKILL.md +90 -0
@@ -0,0 +1,29 @@
1
+ /** Where the push flow is; Ctrl+C and every failure report it, so the owner knows what is on origin. */
2
+ export type Stage = "preflight" | "gh" | "tag" | "release-lookup" | "workflow" | "verify" | "publish" | "latest" | "branch";
3
+ export interface StopReport {
4
+ /** Where it stopped, as a sentence fragment: "while waiting for the release workflow". */
5
+ readonly where: string;
6
+ /** What is on origin and what is not. */
7
+ readonly state: readonly string[];
8
+ /** The command that continues from here. */
9
+ readonly resume: string;
10
+ }
11
+ /**
12
+ * What is on origin when the flow stops at `stage`. The steps are idempotent, so `opdk release publish <version>`
13
+ * continues from any of them; a step that was in flight when Ctrl+C arrived says what to check first.
14
+ */
15
+ export declare function stopReport(stage: Stage, version: string, branch: string, options: {
16
+ readonly interrupted: boolean;
17
+ readonly releasePublic?: boolean;
18
+ }): StopReport;
19
+ /**
20
+ * A failure of one step, with what to do about it. The flow turns it into one `✗` line and the stop report.
21
+ * `resumable` is false when the hint itself says to release a new version: resuming would fail the same way, so no
22
+ * resume line is printed.
23
+ */
24
+ export declare class StepFailure extends Error {
25
+ readonly hint: string;
26
+ readonly details: readonly string[];
27
+ readonly resumable: boolean;
28
+ constructor(message: string, hint: string, details?: readonly string[], resumable?: boolean);
29
+ }
@@ -0,0 +1,70 @@
1
+ const LABEL = {
2
+ preflight: "checking the tag and the branch",
3
+ gh: "checking the GitHub CLI",
4
+ tag: "pushing the tag",
5
+ "release-lookup": "looking up the release",
6
+ workflow: "waiting for the release workflow",
7
+ verify: "verifying the draft release",
8
+ publish: "publishing the release",
9
+ latest: "confirming the latest release",
10
+ branch: "pushing the branch",
11
+ };
12
+ /**
13
+ * What is on origin when the flow stops at `stage`. The steps are idempotent, so `opdk release publish <version>`
14
+ * continues from any of them; a step that was in flight when Ctrl+C arrived says what to check first.
15
+ */
16
+ export function stopReport(stage, version, branch, options) {
17
+ const resume = `opdk release publish ${version}`;
18
+ const where = `${options.interrupted ? "interrupted " : "stopped "}while ${LABEL[stage]}`;
19
+ const inFlight = options.interrupted;
20
+ switch (stage) {
21
+ case "preflight":
22
+ case "gh":
23
+ return { where, state: ["Nothing new was pushed."], resume };
24
+ case "tag":
25
+ return {
26
+ where,
27
+ state: [inFlight ? `The push of the tag ${version} was in flight: check \`git ls-remote --tags origin ${version}\` to see whether it arrived.` : `The tag ${version} was not pushed.`, "The branch was not pushed."],
28
+ resume,
29
+ };
30
+ case "release-lookup":
31
+ case "workflow":
32
+ case "verify":
33
+ return { where, state: [`The tag ${version} is on origin.`, options.releasePublic === true ? `The release ${version} is public.` : "The release is not public (a draft at most).", `The branch ${branch} was not pushed.`], resume };
34
+ case "publish":
35
+ return {
36
+ where,
37
+ state: [
38
+ `The tag ${version} is on origin.`,
39
+ options.releasePublic === true ? `The release ${version} is public.` : inFlight ? `Publishing was in flight: check \`gh release view ${version}\` to see whether the release is public.` : "The release is not public.",
40
+ `The branch ${branch} was not pushed.`,
41
+ ],
42
+ resume,
43
+ };
44
+ case "latest":
45
+ return { where, state: [`The release ${version} is public.`, `The branch ${branch} was not pushed.`], resume };
46
+ case "branch":
47
+ return {
48
+ where,
49
+ state: [`The release ${version} is public.`, inFlight ? `The push of ${branch} was in flight: check \`git ls-remote origin ${branch}\`.` : `The branch ${branch} was not pushed.`],
50
+ resume,
51
+ };
52
+ }
53
+ }
54
+ /**
55
+ * A failure of one step, with what to do about it. The flow turns it into one `✗` line and the stop report.
56
+ * `resumable` is false when the hint itself says to release a new version: resuming would fail the same way, so no
57
+ * resume line is printed.
58
+ */
59
+ export class StepFailure extends Error {
60
+ hint;
61
+ details;
62
+ resumable;
63
+ constructor(message, hint, details = [], resumable = true) {
64
+ super(message);
65
+ this.hint = hint;
66
+ this.details = details;
67
+ this.resumable = resumable;
68
+ this.name = "StepFailure";
69
+ }
70
+ }
@@ -0,0 +1,41 @@
1
+ import type { Reporter } from "../cli/reporter.js";
2
+ import type { TaggedBuild } from "./build-tagged.js";
3
+ import type { RunGh } from "./gh.js";
4
+ import type { TagFacts } from "./publish-git.js";
5
+ import { type RepoSlug } from "./remote.js";
6
+ import { type ReleaseInfo } from "./release-assets.js";
7
+ /**
8
+ * The release of a tag, drafts included (`/releases/tags/<tag>` does not return a draft). Undefined when there is none.
9
+ * Every page of the list is read, and a tag with two releases (a re-run of a failed workflow may leave a second draft) stops
10
+ * the flow: verifying and publishing one of them would be a guess.
11
+ */
12
+ export declare function fetchRelease(gh: RunGh, slug: RepoSlug, version: string): Promise<ReleaseInfo | undefined>;
13
+ export interface VerifyInput {
14
+ readonly gh: RunGh;
15
+ readonly slug: RepoSlug;
16
+ readonly facts: TagFacts;
17
+ readonly release: ReleaseInfo;
18
+ readonly local: TaggedBuild;
19
+ /** The changelog notes of the tag, which the draft's body must equal. */
20
+ readonly notes: string;
21
+ readonly zip: boolean;
22
+ /** An empty folder for the downloaded assets. */
23
+ readonly dir: string;
24
+ readonly reporter: Reporter;
25
+ }
26
+ /**
27
+ * The signer of the attestations: the kit's reusable release workflow, not the plugin's caller workflow. The signing
28
+ * certificate of a job that runs a reusable workflow names that workflow, so `gh attestation verify --repo` alone
29
+ * refuses it ("verifying with issuer sigstore.dev", with no reason); the signer has to be named. The regex is anchored
30
+ * at both ends of the prefix (`https://github.com/` and the `@` before the ref), so `release.yml-copy` or another
31
+ * owner's `obsidian-plugin-dev-kit` does not match, and any ref of the kit (a tag or a full SHA) does.
32
+ */
33
+ export declare const KIT_SIGNER_REGEX: string;
34
+ /** Reads the notes of the tag; a failure is a stop that resuming would not fix (the tag's changelog is what it is). */
35
+ export declare function tagNotes(read: (version: string) => Promise<string>, version: string): Promise<string>;
36
+ /**
37
+ * Checks a release before it is made public: the right asset names, the bytes equal to a build of the tagged
38
+ * commit made here (and the manifest equal to the committed one), and an attestation for each attested file. Throws a
39
+ * `StepFailure` for the first kind of problem; the downloads are left in `dir` for the caller to remove.
40
+ */
41
+ export declare function verifyRelease(input: VerifyInput): Promise<void>;
@@ -0,0 +1,112 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { StepFailure } from "./publish-state.js";
4
+ import { slugText } from "./remote.js";
5
+ import { assetProblems, expectedAssets, releasesOfTag, zipAssetName } from "./release-assets.js";
6
+ import { KIT_WORKFLOW_PATH } from "./workflow-run.js";
7
+ import { describeDifference, firstDifference } from "./reproducible.js";
8
+ const PAGE_SIZE = 100;
9
+ const MAX_PAGES = 30;
10
+ /**
11
+ * The release of a tag, drafts included (`/releases/tags/<tag>` does not return a draft). Undefined when there is none.
12
+ * Every page of the list is read, and a tag with two releases (a re-run of a failed workflow may leave a second draft) stops
13
+ * the flow: verifying and publishing one of them would be a guess.
14
+ */
15
+ export async function fetchRelease(gh, slug, version) {
16
+ const repo = slugText(slug);
17
+ const found = [];
18
+ let finished = false;
19
+ for (let page = 1; page <= MAX_PAGES && !finished; page++) {
20
+ const result = releasesOfTag(await gh.text(["api", `repos/${repo}/releases?per_page=${String(PAGE_SIZE)}&page=${String(page)}`]), version);
21
+ found.push(...result.found);
22
+ finished = result.count < PAGE_SIZE;
23
+ }
24
+ if (!finished) {
25
+ throw new StepFailure(`${repo} has more than ${String(MAX_PAGES * PAGE_SIZE)} releases, and the release ${version} was not among the first ones.`, "Look for the release by hand on GitHub; opdk does not read further.");
26
+ }
27
+ if (found.length > 1) {
28
+ throw new StepFailure(`GitHub has ${String(found.length)} releases for the tag ${version}: ${found.map((release) => release.url).join(", ")}`, `Keep the one you trust and delete the other(s) on GitHub (a re-run of a failed workflow may leave a second draft), then run \`opdk release publish ${version}\`.`);
29
+ }
30
+ return found[0];
31
+ }
32
+ const escapeRegex = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33
+ /**
34
+ * The signer of the attestations: the kit's reusable release workflow, not the plugin's caller workflow. The signing
35
+ * certificate of a job that runs a reusable workflow names that workflow, so `gh attestation verify --repo` alone
36
+ * refuses it ("verifying with issuer sigstore.dev", with no reason); the signer has to be named. The regex is anchored
37
+ * at both ends of the prefix (`https://github.com/` and the `@` before the ref), so `release.yml-copy` or another
38
+ * owner's `obsidian-plugin-dev-kit` does not match, and any ref of the kit (a tag or a full SHA) does.
39
+ */
40
+ export const KIT_SIGNER_REGEX = `^https://github\\.com/${escapeRegex(KIT_WORKFLOW_PATH)}@`;
41
+ const FIX = (version, release) => release.draft
42
+ ? `Nothing was published. Do not edit the assets by hand: delete the draft on GitHub, fix the cause, and release a new patch version with \`opdk release patch\` (the tag ${version} stays and is never moved).`
43
+ : `The release ${version} is already public, so this flow changes nothing. Do not delete it: look at what differs, and if the assets are wrong, release a new patch version with \`opdk release patch\`.`;
44
+ /** Reads the notes of the tag; a failure is a stop that resuming would not fix (the tag's changelog is what it is). */
45
+ export async function tagNotes(read, version) {
46
+ try {
47
+ return await read(version);
48
+ }
49
+ catch (error) {
50
+ throw new StepFailure(`cannot read the release notes of the tag ${version}: ${error instanceof Error ? error.message : String(error)}`, "The workflow takes the release notes from the changelog at the tag, and so does this check. The tag is never moved: release a new patch version with `opdk release patch`.", [], false);
51
+ }
52
+ }
53
+ const NOTES_SHOWN = 300;
54
+ const trimNotes = (text) => text.replace(/\s+$/, "");
55
+ const shortNotes = (text) => {
56
+ const trimmed = trimNotes(text);
57
+ return trimmed.length > NOTES_SHOWN ? `${trimmed.slice(0, NOTES_SHOWN)}... (${String(trimmed.length)} characters)` : trimmed;
58
+ };
59
+ /**
60
+ * Checks a release before it is made public: the right asset names, the bytes equal to a build of the tagged
61
+ * commit made here (and the manifest equal to the committed one), and an attestation for each attested file. Throws a
62
+ * `StepFailure` for the first kind of problem; the downloads are left in `dir` for the caller to remove.
63
+ */
64
+ export async function verifyRelease(input) {
65
+ const { gh, slug, facts, release, local, reporter } = input;
66
+ const repo = slugText(slug);
67
+ const expected = expectedAssets({ hasCss: local.css !== undefined, zipName: input.zip ? zipAssetName(facts.pluginId, facts.version) : undefined });
68
+ const problems = assetProblems(release, expected);
69
+ if (problems.length > 0) {
70
+ throw new StepFailure(`the release ${facts.version} is not what Obsidian needs: ${release.url}`, FIX(facts.version, release), problems, false);
71
+ }
72
+ reporter.success("verify", `assets: ${expected.names.join(", ")}`);
73
+ // The notes travel between two jobs of the workflow (and a person may edit a draft), so they are checked like the bytes.
74
+ if (trimNotes(release.body) !== trimNotes(input.notes)) {
75
+ throw new StepFailure(`the notes of the release ${facts.version} do not match the CHANGELOG at the tag: ${release.url}`, FIX(facts.version, release), [`the draft's notes: ${JSON.stringify(shortNotes(release.body))}`, `the CHANGELOG at ${facts.version}: ${JSON.stringify(shortNotes(input.notes))}`], false);
76
+ }
77
+ reporter.success("verify", `release notes equal the CHANGELOG section of ${facts.version}`);
78
+ mkdirSync(input.dir, { recursive: true });
79
+ const downloaded = new Map();
80
+ for (const name of expected.names) {
81
+ const asset = release.assets.find((candidate) => candidate.name === name);
82
+ if (asset === undefined) {
83
+ continue;
84
+ }
85
+ const bytes = await gh.bytes(["api", "-H", "Accept: application/octet-stream", `repos/${repo}/releases/assets/${String(asset.id)}`]);
86
+ writeFileSync(path.join(input.dir, name), bytes);
87
+ downloaded.set(name, bytes);
88
+ }
89
+ const comparison = `the release asset and a build of the tag ${facts.version} (commit ${local.commit})`;
90
+ const pairs = [["main.js", local.mainJs], ["styles.css", local.css], ["manifest.json", local.manifest]];
91
+ const differences = [];
92
+ for (const [name, mine] of pairs) {
93
+ const theirs = downloaded.get(name);
94
+ const difference = mine === undefined || theirs === undefined ? undefined : firstDifference(mine, theirs);
95
+ if (mine !== undefined && theirs !== undefined && difference !== undefined) {
96
+ differences.push(describeDifference(name, comparison, mine, theirs, difference));
97
+ }
98
+ }
99
+ if (differences.length > 0) {
100
+ throw new StepFailure(`the release assets are not the bytes of the tagged commit: ${release.url}`, `${FIX(facts.version, release)} A different Node or dependency version in CI, or a build that is not reproducible, are the usual causes (\`opdk release check\` builds the committed tree twice).`, differences, false);
101
+ }
102
+ reporter.success("verify", `${expected.attested.join(", ")} equal a local build of ${facts.version} (${local.commit}) byte for byte`);
103
+ for (const name of expected.attested) {
104
+ try {
105
+ await gh.text(["attestation", "verify", path.join(input.dir, name), "--repo", repo, "--cert-identity-regex", KIT_SIGNER_REGEX, "--source-ref", `refs/tags/${facts.version}`, "--source-digest", facts.commit]);
106
+ }
107
+ catch (error) {
108
+ throw new StepFailure(`the attestation of ${name} does not verify: ${error instanceof Error ? error.message : String(error)}`, `${FIX(facts.version, release)} The assets must be attested by ${KIT_WORKFLOW_PATH} for ${repo} at the tag ${facts.version}: the plugin's workflow must call it (a copy of it does not count), and an old gh may not verify new attestations (update it).`, [], false);
109
+ }
110
+ }
111
+ reporter.success("verify", `attestations: ${expected.attested.join(", ")} verified for ${repo} at ${facts.version}`);
112
+ }
@@ -0,0 +1,25 @@
1
+ import type { Reporter } from "../cli/reporter.js";
2
+ import type { RunGh } from "./gh.js";
3
+ import { type RepoSlug } from "./remote.js";
4
+ import { type WorkflowRun } from "./workflow-run.js";
5
+ /** Time, injected so a test does not wait. */
6
+ export interface Clock {
7
+ now(): number;
8
+ sleep(ms: number): Promise<void>;
9
+ }
10
+ export interface WaitInput {
11
+ readonly gh: RunGh;
12
+ readonly slug: RepoSlug;
13
+ readonly version: string;
14
+ /** The commit the tag points at; only a run on it counts. */
15
+ readonly commit: string;
16
+ readonly reporter: Reporter;
17
+ readonly clock: Clock;
18
+ /** How long to wait for the workflow to finish once it started. */
19
+ readonly timeoutMs: number;
20
+ /** How long to wait for the run to show up after the tag was pushed. */
21
+ readonly appearMs: number;
22
+ readonly pollMs: number;
23
+ }
24
+ /** Waits for the run that the tag push started: first for it to appear, then for it to finish. Throws a `StepFailure` that names the run URL. */
25
+ export declare function waitForWorkflow(input: WaitInput): Promise<WorkflowRun>;
@@ -0,0 +1,56 @@
1
+ import { StepFailure } from "./publish-state.js";
2
+ import { slugText } from "./remote.js";
3
+ import { describeRun, KIT_WORKFLOW_PATH, parseRun, parseRuns, pickRun, runOutcome, runPath, runsPath } from "./workflow-run.js";
4
+ const HEARTBEAT_MS = 60_000;
5
+ const minutes = (ms) => `${String(Math.max(1, Math.round(ms / 60_000)))} min`;
6
+ /** Waits for the run that the tag push started: first for it to appear, then for it to finish. Throws a `StepFailure` that names the run URL. */
7
+ export async function waitForWorkflow(input) {
8
+ const { gh, slug, version, commit, reporter, clock } = input;
9
+ const repo = slugText(slug);
10
+ const resume = `After fixing the cause, release a new patch version, or re-run the failed jobs on GitHub and then run \`opdk release publish ${version}\`. A failed run can leave a draft release behind: delete that draft before re-running, because a re-run creates the release again and may fail on the existing one. \`opdk release\` itself stops when it finds two releases for one tag. The tag ${version} stays on origin.`;
11
+ const startedAt = clock.now();
12
+ let run;
13
+ while (run === undefined) {
14
+ const listed = parseRuns(await gh.text(["api", runsPath(repo, commit)]));
15
+ run = pickRun(listed, commit, version);
16
+ if (run !== undefined) {
17
+ break;
18
+ }
19
+ if (clock.now() - startedAt >= input.appearMs) {
20
+ const others = [...new Set(listed.filter((other) => other.event === "push" && other.headSha === commit && other.headBranch === version).map((other) => other.name))];
21
+ const seen = others.length === 0 ? "" : ` The runs on this commit are ${others.map((name) => `"${name}"`).join(", ")}, and none of them calls the kit's release workflow.`;
22
+ throw new StepFailure(`no release workflow run started for the tag ${version} within ${minutes(input.appearMs)}.${seen}`, `The plugin's workflow that runs on \`push: tags\` must call the kit's workflow: \`uses: ${KIT_WORKFLOW_PATH}@<full commit SHA of the kit>\` (copying it does not work, the attestations are checked against the kit's file). Actions must be enabled too (https://github.com/${repo}/actions). Then run \`opdk release publish ${version}\` again: the tag is already on origin and is not pushed twice.`);
23
+ }
24
+ await clock.sleep(input.pollMs);
25
+ }
26
+ reporter.info("wait", `${describeRun(run)} ${run.url}`);
27
+ let last = `${run.status}/${run.conclusion}`;
28
+ let lastBeat = clock.now();
29
+ const watchStart = clock.now();
30
+ for (;;) {
31
+ const outcome = runOutcome(run);
32
+ if (outcome === "success") {
33
+ const waited = clock.now() - watchStart;
34
+ reporter.success("wait", `${run.name === "" ? "workflow" : run.name} succeeded${waited < 1_000 ? "" : ` in ${minutes(waited)}`}`);
35
+ return run;
36
+ }
37
+ if (outcome === "failed") {
38
+ throw new StepFailure(`the release workflow ended with "${run.conclusion}": ${run.url}`, resume);
39
+ }
40
+ if (clock.now() - watchStart >= input.timeoutMs) {
41
+ throw new StepFailure(`the release workflow did not finish within ${minutes(input.timeoutMs)}: ${run.url}`, `It may still be running. When it is done, run \`opdk release publish ${version}\` (use --timeout <minutes> to wait longer).`);
42
+ }
43
+ await clock.sleep(input.pollMs);
44
+ run = parseRun(JSON.parse(await gh.text(["api", runPath(repo, run.id)])));
45
+ const state = `${run.status}/${run.conclusion}`;
46
+ if (state !== last) {
47
+ reporter.info("wait", describeRun(run));
48
+ last = state;
49
+ lastBeat = clock.now();
50
+ }
51
+ else if (clock.now() - lastBeat >= HEARTBEAT_MS) {
52
+ reporter.info("wait", `still ${run.status} after ${minutes(clock.now() - watchStart)}`);
53
+ lastBeat = clock.now();
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,35 @@
1
+ import type { Reporter } from "../cli/reporter.js";
2
+ import type { TaggedBuild } from "./build-tagged.js";
3
+ import type { RunGh } from "./gh.js";
4
+ import type { RunGit } from "./git.js";
5
+ import { CleanupSet, type InterruptHooks } from "./interrupt.js";
6
+ import { type Clock } from "./publish-wait.js";
7
+ export interface PublishInput {
8
+ readonly version: string;
9
+ readonly reporter: Reporter;
10
+ readonly run: RunGit;
11
+ readonly gh: RunGh;
12
+ /** From `release.defaultBranch`; else `origin/HEAD`. */
13
+ readonly defaultBranch: string | undefined;
14
+ /** A production build of the tagged commit; the release assets must equal it. */
15
+ /** The release notes of the tag, as the workflow makes them (`opdk release notes` at the tag). Throws a message with the fix. */
16
+ readonly notes: (version: string) => Promise<string>;
17
+ readonly buildTagged: (cleanups: CleanupSet) => Promise<TaggedBuild>;
18
+ /** Expect `<id>-<version>.zip` among the assets (the workflow's `zip: true`). */
19
+ readonly zip: boolean;
20
+ readonly timeoutMs: number;
21
+ readonly appearMs: number;
22
+ readonly pollMs: number;
23
+ readonly clock: Clock;
24
+ /** Ctrl+C handling: says where the flow stopped and how to resume, then exits with 130. */
25
+ readonly interrupt?: InterruptHooks;
26
+ }
27
+ export declare const DEFAULT_TIMEOUT_MINUTES = 20;
28
+ export declare const DEFAULT_APPEAR_MS: number;
29
+ export declare const DEFAULT_POLL_MS = 10000;
30
+ /**
31
+ * The push flow, from a local annotated tag: push only the tag, wait for the release workflow, verify its draft
32
+ * (assets, bytes against a local build of the tag, attestations), publish it, then push the branch. Each step
33
+ * checks what is already done, so `opdk release publish <version>` continues after any stop. Returns the exit code.
34
+ */
35
+ export declare function runPublish(input: PublishInput): Promise<number>;
@@ -0,0 +1,181 @@
1
+ import { mkdtempSync, realpathSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
4
+ import { checkGhAccess } from "./gh-access.js";
5
+ import { CleanupSet, INTERRUPTED_EXIT } from "./interrupt.js";
6
+ import { asRecord } from "./json.js";
7
+ import { pushBranch, pushTag, readTagFacts } from "./publish-git.js";
8
+ import { StepFailure, stopReport } from "./publish-state.js";
9
+ import { fetchRelease, tagNotes, verifyRelease } from "./publish-verify.js";
10
+ import { waitForWorkflow } from "./publish-wait.js";
11
+ import { slugText } from "./remote.js";
12
+ export const DEFAULT_TIMEOUT_MINUTES = 20;
13
+ export const DEFAULT_APPEAR_MS = 3 * 60_000;
14
+ export const DEFAULT_POLL_MS = 10_000;
15
+ /** After a `gh release edit`, GitHub lists the release as public at once; a short retry covers replication lag. */
16
+ const LATEST_ATTEMPTS = 5;
17
+ async function confirmLatest(gh, slug, version, clock) {
18
+ let seen;
19
+ for (let attempt = 0; attempt < LATEST_ATTEMPTS; attempt++) {
20
+ seen = await latestTag(gh, slug);
21
+ if (seen === version) {
22
+ return { isLatest: true, seen };
23
+ }
24
+ await clock.sleep(2_000);
25
+ }
26
+ return { isLatest: false, seen };
27
+ }
28
+ /** `releases/latest` answers 404 while the repository has no published release: that is "none", not a failure. */
29
+ async function latestTag(gh, slug) {
30
+ let json;
31
+ try {
32
+ json = await gh.text(["api", `repos/${slugText(slug)}/releases/latest`]);
33
+ }
34
+ catch (error) {
35
+ if (error instanceof Error && error.message.includes("HTTP 404")) {
36
+ return undefined;
37
+ }
38
+ throw error;
39
+ }
40
+ const latest = asRecord(JSON.parse(json));
41
+ return typeof latest?.tag_name === "string" ? latest.tag_name : undefined;
42
+ }
43
+ const describeLatest = (seen) => (seen === undefined ? "GitHub has no latest release" : `GitHub's latest release is ${seen}`);
44
+ /**
45
+ * The push flow, from a local annotated tag: push only the tag, wait for the release workflow, verify its draft
46
+ * (assets, bytes against a local build of the tag, attestations), publish it, then push the branch. Each step
47
+ * checks what is already done, so `opdk release publish <version>` continues after any stop. Returns the exit code.
48
+ */
49
+ export async function runPublish(input) {
50
+ const { version, reporter } = input;
51
+ const cleanups = new CleanupSet();
52
+ const state = { stage: "preflight", branch: "<default branch>", interrupted: false, releasePublic: false };
53
+ const unregister = input.interrupt?.onInterrupt(() => {
54
+ state.interrupted = true;
55
+ const report = stopReport(state.stage, version, state.branch, { interrupted: true, releasePublic: state.releasePublic });
56
+ reporter.failure("release", `${version}: ${report.where}`, { details: report.state, hint: `Resume with: ${report.resume}` });
57
+ try {
58
+ cleanups.run();
59
+ }
60
+ catch (error) {
61
+ reporter.failure("release", `cleanup after Ctrl+C failed: ${error instanceof Error ? error.message : String(error)}`, { hint: "Remove the opdk-release-* folders from the temp directory." });
62
+ }
63
+ input.interrupt?.exit(INTERRUPTED_EXIT);
64
+ });
65
+ try {
66
+ await flow(input, cleanups, {
67
+ enter: (next, facts) => {
68
+ state.stage = next;
69
+ if (facts !== undefined) {
70
+ state.branch = facts.branch;
71
+ }
72
+ },
73
+ releaseIsPublic: () => {
74
+ state.releasePublic = true;
75
+ },
76
+ });
77
+ return state.interrupted ? INTERRUPTED_EXIT : 0;
78
+ }
79
+ catch (error) {
80
+ if (state.interrupted) {
81
+ return INTERRUPTED_EXIT;
82
+ }
83
+ const report = stopReport(state.stage, version, state.branch, { interrupted: false, releasePublic: state.releasePublic });
84
+ if (error instanceof StepFailure) {
85
+ reporter.failure("release", `${version}: ${error.message}`, { details: error.details, hint: error.hint });
86
+ }
87
+ else {
88
+ reporter.failure("release", `${version}: ${error instanceof Error ? error.message : String(error)}`);
89
+ }
90
+ const resumable = !(error instanceof StepFailure) || error.resumable;
91
+ reporter.failure("release", `${report.where}.`, { details: report.state, hint: resumable ? `Resume with: ${report.resume}` : "Resuming would stop at the same place. Fix the cause and release a new version: opdk release patch" });
92
+ return 1;
93
+ }
94
+ finally {
95
+ unregister?.();
96
+ try {
97
+ cleanups.run();
98
+ }
99
+ catch (error) {
100
+ reporter.warn("release", `could not remove a temp folder: ${error instanceof Error ? error.message : String(error)}`);
101
+ }
102
+ }
103
+ }
104
+ async function flow(input, cleanups, progress) {
105
+ const { version, reporter, run, gh, clock } = input;
106
+ progress.enter("preflight");
107
+ const facts = await readTagFacts({ run, version, defaultBranchOverride: input.defaultBranch });
108
+ progress.enter("preflight", facts);
109
+ reporter.info("git", `tag ${version} at ${facts.commit.slice(0, 7)}, branch ${facts.branch}`);
110
+ progress.enter("gh");
111
+ const { slug, permission } = await checkGhAccess(run, gh);
112
+ const repo = slugText(slug);
113
+ reporter.success("gh", `${repo}: signed in, ${permission.toLowerCase()} access`);
114
+ progress.enter("tag");
115
+ const pushed = await pushTag(run, facts);
116
+ reporter.success("git", pushed === "pushed" ? `pushed the tag ${version} (only the tag; the branch waits for the release)` : `the tag ${version} is already on origin`);
117
+ progress.enter("release-lookup");
118
+ let release = await fetchRelease(gh, slug, version);
119
+ let runUrl;
120
+ if (release !== undefined && !release.draft) {
121
+ progress.releaseIsPublic();
122
+ }
123
+ if (release === undefined || release.draft) {
124
+ progress.enter("workflow");
125
+ const finished = await waitForWorkflow({ gh, slug, version, commit: facts.commit, reporter, clock, timeoutMs: input.timeoutMs, appearMs: input.appearMs, pollMs: input.pollMs });
126
+ runUrl = finished.url;
127
+ release = await findDraft(gh, slug, version, clock);
128
+ }
129
+ else {
130
+ reporter.info("wait", `the release ${version} is already public, so the workflow is not waited for`);
131
+ }
132
+ progress.enter("verify");
133
+ const local = await input.buildTagged(cleanups);
134
+ const dir = mkdtempSync(path.join(realpathSync(tmpdir()), "opdk-release-assets-"));
135
+ cleanups.add(() => {
136
+ rmSync(dir, { recursive: true, force: true });
137
+ });
138
+ await verifyRelease({ gh, slug, facts, release, local, notes: await tagNotes(input.notes, version), zip: input.zip, dir, reporter });
139
+ progress.enter("publish");
140
+ const wasDraft = release.draft;
141
+ if (wasDraft) {
142
+ await gh.text(["release", "edit", version, "--repo", repo, "--draft=false", "--latest"]);
143
+ const after = await fetchRelease(gh, slug, version);
144
+ if (after === undefined || after.draft) {
145
+ throw new StepFailure(`the release ${version} is still a draft after publishing.`, `Open ${release.url} and publish it by hand, then run \`opdk release publish ${version}\` to push the branch.`);
146
+ }
147
+ release = after;
148
+ progress.releaseIsPublic();
149
+ }
150
+ progress.enter("latest");
151
+ const latest = await confirmLatest(gh, slug, version, clock);
152
+ if (!latest.isLatest && wasDraft) {
153
+ throw new StepFailure(`the release ${version} is public but ${describeLatest(latest.seen)}.`, `Mark it as latest at ${release.url} (Edit, then "Set as the latest release"), then run \`opdk release publish ${version}\`.`);
154
+ }
155
+ if (!latest.isLatest) {
156
+ reporter.warn("release", `${describeLatest(latest.seen)}, not ${version}.`);
157
+ }
158
+ reporter.success("release", `${version} is public${latest.isLatest ? " and the latest release" : ""}: ${release.url}`);
159
+ progress.enter("branch");
160
+ const pushedBranch = await pushBranch(run, facts);
161
+ reporter.success("git", pushedBranch === "pushed" ? `pushed the release commit to ${facts.branch} (no force)` : `${facts.branch} on origin already holds the release commit`);
162
+ summary(reporter, { repo, version, release, runUrl, branch: facts.branch, branchPushed: pushedBranch === "pushed" });
163
+ }
164
+ async function findDraft(gh, slug, version, clock) {
165
+ for (let attempt = 0; attempt < 6; attempt++) {
166
+ const release = await fetchRelease(gh, slug, version);
167
+ if (release !== undefined) {
168
+ return release;
169
+ }
170
+ await clock.sleep(5_000);
171
+ }
172
+ throw new StepFailure(`the workflow succeeded but there is no release for ${version}.`, "The release job's last step creates a draft release; read the run log. Fix the cause, then release a new patch version.", [], false);
173
+ }
174
+ function summary(reporter, { repo, version, release, runUrl, branch, branchPushed }) {
175
+ reporter.success("release", `${repo} ${version} released`);
176
+ reporter.info("release", `release ${release.url}`);
177
+ if (runUrl !== undefined) {
178
+ reporter.info("release", `workflow ${runUrl}`);
179
+ }
180
+ reporter.info("release", `branch ${branch} ${branchPushed ? "pushed" : "already contained the release commit"}; Obsidian now reads ${version} from its manifest.json`);
181
+ }
@@ -0,0 +1,39 @@
1
+ /** A release as the REST API returns it, reduced to what the verification reads. */
2
+ export interface ReleaseInfo {
3
+ readonly id: number;
4
+ readonly tag: string;
5
+ readonly draft: boolean;
6
+ readonly prerelease: boolean;
7
+ readonly url: string;
8
+ /** The release notes; empty when GitHub has none. */
9
+ readonly body: string;
10
+ readonly assets: readonly ReleaseAsset[];
11
+ }
12
+ export interface ReleaseAsset {
13
+ readonly id: number;
14
+ readonly name: string;
15
+ readonly size: number;
16
+ /** `uploaded` once the upload finished. */
17
+ readonly state: string;
18
+ }
19
+ export declare function parseRelease(value: unknown): ReleaseInfo | undefined;
20
+ /** The releases for a tag in one page of `GET /releases` (drafts are listed there, and not by `/releases/tags/<tag>`), and how many entries the page had. */
21
+ export declare function releasesOfTag(json: string, tag: string): {
22
+ readonly found: ReleaseInfo[];
23
+ readonly count: number;
24
+ };
25
+ export interface ExpectedAssets {
26
+ /** `main.js`, `manifest.json`, `styles.css` when the plugin has CSS, and the zip when asked for. */
27
+ readonly names: readonly string[];
28
+ /** The subset that carries an attestation (everything but the zip). */
29
+ readonly attested: readonly string[];
30
+ }
31
+ /** What the release must hold: the three Obsidian files, `styles.css` only if the plugin has one. */
32
+ export declare function expectedAssets(options: {
33
+ readonly hasCss: boolean;
34
+ readonly zipName: string | undefined;
35
+ }): ExpectedAssets;
36
+ /** What is wrong with the asset list of a release: missing, unexpected, unfinished or empty files. */
37
+ export declare function assetProblems(release: ReleaseInfo, expected: ExpectedAssets): string[];
38
+ /** The name of the optional zip asset: the plugin id and the version, as the kit's workflow names it. */
39
+ export declare const zipAssetName: (id: string, version: string) => string;