@marinoscar/platform-cli 0.1.0-next.3 → 0.1.0-next.4

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 (743) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +126 -31
  3. package/dist/android/build.d.ts +30 -0
  4. package/dist/android/build.d.ts.map +1 -0
  5. package/dist/android/build.js +126 -0
  6. package/dist/android/build.js.map +1 -0
  7. package/dist/android/command.d.ts +21 -0
  8. package/dist/android/command.d.ts.map +1 -0
  9. package/dist/android/command.js +355 -0
  10. package/dist/android/command.js.map +1 -0
  11. package/dist/android/deploy-step.d.ts +85 -0
  12. package/dist/android/deploy-step.d.ts.map +1 -0
  13. package/dist/android/deploy-step.js +268 -0
  14. package/dist/android/deploy-step.js.map +1 -0
  15. package/dist/android/doctor.d.ts +47 -0
  16. package/dist/android/doctor.d.ts.map +1 -0
  17. package/dist/android/doctor.js +219 -0
  18. package/dist/android/doctor.js.map +1 -0
  19. package/dist/android/exec.d.ts +42 -0
  20. package/dist/android/exec.d.ts.map +1 -0
  21. package/dist/android/exec.js +103 -0
  22. package/dist/android/exec.js.map +1 -0
  23. package/dist/android/fix-plan.d.ts +44 -0
  24. package/dist/android/fix-plan.d.ts.map +1 -0
  25. package/dist/android/fix-plan.js +86 -0
  26. package/dist/android/fix-plan.js.map +1 -0
  27. package/dist/android/git-freshness.d.ts +34 -0
  28. package/dist/android/git-freshness.d.ts.map +1 -0
  29. package/dist/android/git-freshness.js +120 -0
  30. package/dist/android/git-freshness.js.map +1 -0
  31. package/dist/android/gradle.d.ts +32 -0
  32. package/dist/android/gradle.d.ts.map +1 -0
  33. package/dist/android/gradle.js +55 -0
  34. package/dist/android/gradle.js.map +1 -0
  35. package/dist/android/identity.d.ts +27 -0
  36. package/dist/android/identity.d.ts.map +1 -0
  37. package/dist/android/identity.js +60 -0
  38. package/dist/android/identity.js.map +1 -0
  39. package/dist/android/index.d.ts +7 -0
  40. package/dist/android/index.d.ts.map +1 -0
  41. package/dist/android/index.js +8 -0
  42. package/dist/android/index.js.map +1 -0
  43. package/dist/android/installer.d.ts +28 -0
  44. package/dist/android/installer.d.ts.map +1 -0
  45. package/dist/android/installer.js +96 -0
  46. package/dist/android/installer.js.map +1 -0
  47. package/dist/android/java.d.ts +26 -0
  48. package/dist/android/java.d.ts.map +1 -0
  49. package/dist/android/java.js +65 -0
  50. package/dist/android/java.js.map +1 -0
  51. package/dist/android/keystore.d.ts +54 -0
  52. package/dist/android/keystore.d.ts.map +1 -0
  53. package/dist/android/keystore.js +159 -0
  54. package/dist/android/keystore.js.map +1 -0
  55. package/dist/android/metadata.d.ts +39 -0
  56. package/dist/android/metadata.d.ts.map +1 -0
  57. package/dist/android/metadata.js +61 -0
  58. package/dist/android/metadata.js.map +1 -0
  59. package/dist/android/operations.d.ts +42 -0
  60. package/dist/android/operations.d.ts.map +1 -0
  61. package/dist/android/operations.js +59 -0
  62. package/dist/android/operations.js.map +1 -0
  63. package/dist/android/paths.d.ts +29 -0
  64. package/dist/android/paths.d.ts.map +1 -0
  65. package/dist/android/paths.js +97 -0
  66. package/dist/android/paths.js.map +1 -0
  67. package/dist/android/publish.d.ts +37 -0
  68. package/dist/android/publish.d.ts.map +1 -0
  69. package/dist/android/publish.js +119 -0
  70. package/dist/android/publish.js.map +1 -0
  71. package/dist/android/registrations.d.ts +92 -0
  72. package/dist/android/registrations.d.ts.map +1 -0
  73. package/dist/android/registrations.js +112 -0
  74. package/dist/android/registrations.js.map +1 -0
  75. package/dist/android/release-status.d.ts +73 -0
  76. package/dist/android/release-status.d.ts.map +1 -0
  77. package/dist/android/release-status.js +161 -0
  78. package/dist/android/release-status.js.map +1 -0
  79. package/dist/android/release.d.ts +33 -0
  80. package/dist/android/release.d.ts.map +1 -0
  81. package/dist/android/release.js +59 -0
  82. package/dist/android/release.js.map +1 -0
  83. package/dist/android/screen-layout.d.ts +26 -0
  84. package/dist/android/screen-layout.d.ts.map +1 -0
  85. package/dist/android/screen-layout.js +24 -0
  86. package/dist/android/screen-layout.js.map +1 -0
  87. package/dist/android/screen-model.d.ts +56 -0
  88. package/dist/android/screen-model.d.ts.map +1 -0
  89. package/dist/android/screen-model.js +207 -0
  90. package/dist/android/screen-model.js.map +1 -0
  91. package/dist/android/screen.d.ts +8 -0
  92. package/dist/android/screen.d.ts.map +1 -0
  93. package/dist/android/screen.js +395 -0
  94. package/dist/android/screen.js.map +1 -0
  95. package/dist/android/sdk.d.ts +48 -0
  96. package/dist/android/sdk.d.ts.map +1 -0
  97. package/dist/android/sdk.js +82 -0
  98. package/dist/android/sdk.js.map +1 -0
  99. package/dist/android/server-url.d.ts +19 -0
  100. package/dist/android/server-url.d.ts.map +1 -0
  101. package/dist/android/server-url.js +36 -0
  102. package/dist/android/server-url.js.map +1 -0
  103. package/dist/android/upload-progress.d.ts +3 -0
  104. package/dist/android/upload-progress.d.ts.map +1 -0
  105. package/dist/android/upload-progress.js +47 -0
  106. package/dist/android/upload-progress.js.map +1 -0
  107. package/dist/android/version.d.ts +47 -0
  108. package/dist/android/version.d.ts.map +1 -0
  109. package/dist/android/version.js +136 -0
  110. package/dist/android/version.js.map +1 -0
  111. package/dist/api-client/index.d.ts +3 -0
  112. package/dist/api-client/index.d.ts.map +1 -0
  113. package/dist/api-client/index.js +5 -0
  114. package/dist/api-client/index.js.map +1 -0
  115. package/dist/commands/index.d.ts +52 -0
  116. package/dist/commands/index.d.ts.map +1 -0
  117. package/dist/commands/index.js +63 -0
  118. package/dist/commands/index.js.map +1 -0
  119. package/dist/core/cli-registry.d.ts +41 -0
  120. package/dist/core/cli-registry.d.ts.map +1 -0
  121. package/dist/core/cli-registry.js +49 -0
  122. package/dist/core/cli-registry.js.map +1 -0
  123. package/dist/core/command-registry.d.ts +10 -0
  124. package/dist/core/command-registry.d.ts.map +1 -1
  125. package/dist/core/command-registry.js +17 -0
  126. package/dist/core/command-registry.js.map +1 -1
  127. package/dist/core/env-annotation-registry.d.ts +58 -0
  128. package/dist/core/env-annotation-registry.d.ts.map +1 -0
  129. package/dist/core/env-annotation-registry.js +80 -0
  130. package/dist/core/env-annotation-registry.js.map +1 -0
  131. package/dist/core/env-generator-registry.d.ts +59 -0
  132. package/dist/core/env-generator-registry.d.ts.map +1 -0
  133. package/dist/core/env-generator-registry.js +102 -0
  134. package/dist/core/env-generator-registry.js.map +1 -0
  135. package/dist/core/env-group-registry.d.ts +65 -0
  136. package/dist/core/env-group-registry.d.ts.map +1 -0
  137. package/dist/core/env-group-registry.js +77 -0
  138. package/dist/core/env-group-registry.js.map +1 -0
  139. package/dist/core/env-spec-registry.d.ts +16 -2
  140. package/dist/core/env-spec-registry.d.ts.map +1 -1
  141. package/dist/core/env-spec-registry.js +15 -0
  142. package/dist/core/env-spec-registry.js.map +1 -1
  143. package/dist/core/env-values.d.ts +3 -2
  144. package/dist/core/env-values.d.ts.map +1 -1
  145. package/dist/core/env-values.js +5 -3
  146. package/dist/core/env-values.js.map +1 -1
  147. package/dist/core/index.d.ts +10 -2
  148. package/dist/core/index.d.ts.map +1 -1
  149. package/dist/core/index.js +6 -2
  150. package/dist/core/index.js.map +1 -1
  151. package/dist/deploy/index.d.ts +3 -0
  152. package/dist/deploy/index.d.ts.map +1 -0
  153. package/dist/deploy/index.js +5 -0
  154. package/dist/deploy/index.js.map +1 -0
  155. package/dist/engine/api-client.d.ts +211 -0
  156. package/dist/engine/api-client.d.ts.map +1 -0
  157. package/dist/engine/api-client.js +350 -0
  158. package/dist/engine/api-client.js.map +1 -0
  159. package/dist/engine/browser.d.ts +18 -0
  160. package/dist/engine/browser.d.ts.map +1 -0
  161. package/dist/engine/browser.js +115 -0
  162. package/dist/engine/browser.js.map +1 -0
  163. package/dist/engine/builtin-registrations.d.ts +20 -0
  164. package/dist/engine/builtin-registrations.d.ts.map +1 -0
  165. package/dist/engine/builtin-registrations.js +86 -0
  166. package/dist/engine/builtin-registrations.js.map +1 -0
  167. package/dist/engine/commands/api.d.ts +88 -0
  168. package/dist/engine/commands/api.d.ts.map +1 -0
  169. package/dist/engine/commands/api.js +398 -0
  170. package/dist/engine/commands/api.js.map +1 -0
  171. package/dist/engine/commands/config.d.ts +5 -0
  172. package/dist/engine/commands/config.d.ts.map +1 -0
  173. package/dist/engine/commands/config.js +83 -0
  174. package/dist/engine/commands/config.js.map +1 -0
  175. package/dist/engine/commands/deploy.d.ts +243 -0
  176. package/dist/engine/commands/deploy.d.ts.map +1 -0
  177. package/dist/engine/commands/deploy.js +1159 -0
  178. package/dist/engine/commands/deploy.js.map +1 -0
  179. package/dist/engine/commands/init.d.ts +18 -0
  180. package/dist/engine/commands/init.d.ts.map +1 -0
  181. package/dist/engine/commands/init.js +50 -0
  182. package/dist/engine/commands/init.js.map +1 -0
  183. package/dist/engine/commands/login.d.ts +4 -0
  184. package/dist/engine/commands/login.d.ts.map +1 -0
  185. package/dist/engine/commands/login.js +205 -0
  186. package/dist/engine/commands/login.js.map +1 -0
  187. package/dist/engine/commands/node.d.ts +21 -0
  188. package/dist/engine/commands/node.d.ts.map +1 -0
  189. package/dist/engine/commands/node.js +436 -0
  190. package/dist/engine/commands/node.js.map +1 -0
  191. package/dist/engine/config.d.ts +246 -0
  192. package/dist/engine/config.d.ts.map +1 -0
  193. package/dist/engine/config.js +414 -0
  194. package/dist/engine/config.js.map +1 -0
  195. package/dist/engine/conformance.d.ts +187 -0
  196. package/dist/engine/conformance.d.ts.map +1 -0
  197. package/dist/engine/conformance.js +227 -0
  198. package/dist/engine/conformance.js.map +1 -0
  199. package/dist/engine/create-cli.d.ts +94 -0
  200. package/dist/engine/create-cli.d.ts.map +1 -0
  201. package/dist/engine/create-cli.js +60 -0
  202. package/dist/engine/create-cli.js.map +1 -0
  203. package/dist/engine/deploy/about.d.ts +12 -0
  204. package/dist/engine/deploy/about.d.ts.map +1 -0
  205. package/dist/engine/deploy/about.js +110 -0
  206. package/dist/engine/deploy/about.js.map +1 -0
  207. package/dist/engine/deploy/adopt.d.ts +21 -0
  208. package/dist/engine/deploy/adopt.d.ts.map +1 -0
  209. package/dist/engine/deploy/adopt.js +78 -0
  210. package/dist/engine/deploy/adopt.js.map +1 -0
  211. package/dist/engine/deploy/answers-file.d.ts +7 -0
  212. package/dist/engine/deploy/answers-file.d.ts.map +1 -0
  213. package/dist/engine/deploy/answers-file.js +49 -0
  214. package/dist/engine/deploy/answers-file.js.map +1 -0
  215. package/dist/engine/deploy/app-role.d.ts +278 -0
  216. package/dist/engine/deploy/app-role.d.ts.map +1 -0
  217. package/dist/engine/deploy/app-role.js +826 -0
  218. package/dist/engine/deploy/app-role.js.map +1 -0
  219. package/dist/engine/deploy/app-version.d.ts +47 -0
  220. package/dist/engine/deploy/app-version.d.ts.map +1 -0
  221. package/dist/engine/deploy/app-version.js +232 -0
  222. package/dist/engine/deploy/app-version.js.map +1 -0
  223. package/dist/engine/deploy/checks/database.d.ts +83 -0
  224. package/dist/engine/deploy/checks/database.d.ts.map +1 -0
  225. package/dist/engine/deploy/checks/database.js +455 -0
  226. package/dist/engine/deploy/checks/database.js.map +1 -0
  227. package/dist/engine/deploy/checks/dns.d.ts +3 -0
  228. package/dist/engine/deploy/checks/dns.d.ts.map +1 -0
  229. package/dist/engine/deploy/checks/dns.js +85 -0
  230. package/dist/engine/deploy/checks/dns.js.map +1 -0
  231. package/dist/engine/deploy/checks/host.d.ts +19 -0
  232. package/dist/engine/deploy/checks/host.d.ts.map +1 -0
  233. package/dist/engine/deploy/checks/host.js +530 -0
  234. package/dist/engine/deploy/checks/host.js.map +1 -0
  235. package/dist/engine/deploy/checks/index.d.ts +33 -0
  236. package/dist/engine/deploy/checks/index.d.ts.map +1 -0
  237. package/dist/engine/deploy/checks/index.js +67 -0
  238. package/dist/engine/deploy/checks/index.js.map +1 -0
  239. package/dist/engine/deploy/checks/registry.d.ts +102 -0
  240. package/dist/engine/deploy/checks/registry.d.ts.map +1 -0
  241. package/dist/engine/deploy/checks/registry.js +103 -0
  242. package/dist/engine/deploy/checks/registry.js.map +1 -0
  243. package/dist/engine/deploy/checks/source.d.ts +45 -0
  244. package/dist/engine/deploy/checks/source.d.ts.map +1 -0
  245. package/dist/engine/deploy/checks/source.js +175 -0
  246. package/dist/engine/deploy/checks/source.js.map +1 -0
  247. package/dist/engine/deploy/checks/tls.d.ts +87 -0
  248. package/dist/engine/deploy/checks/tls.d.ts.map +1 -0
  249. package/dist/engine/deploy/checks/tls.js +552 -0
  250. package/dist/engine/deploy/checks/tls.js.map +1 -0
  251. package/dist/engine/deploy/checks/types.d.ts +178 -0
  252. package/dist/engine/deploy/checks/types.d.ts.map +1 -0
  253. package/dist/engine/deploy/checks/types.js +199 -0
  254. package/dist/engine/deploy/checks/types.js.map +1 -0
  255. package/dist/engine/deploy/compose-files.d.ts +29 -0
  256. package/dist/engine/deploy/compose-files.d.ts.map +1 -0
  257. package/dist/engine/deploy/compose-files.js +118 -0
  258. package/dist/engine/deploy/compose-files.js.map +1 -0
  259. package/dist/engine/deploy/consent.d.ts +29 -0
  260. package/dist/engine/deploy/consent.d.ts.map +1 -0
  261. package/dist/engine/deploy/consent.js +35 -0
  262. package/dist/engine/deploy/consent.js.map +1 -0
  263. package/dist/engine/deploy/database-drop.d.ts +22 -0
  264. package/dist/engine/deploy/database-drop.d.ts.map +1 -0
  265. package/dist/engine/deploy/database-drop.js +135 -0
  266. package/dist/engine/deploy/database-drop.js.map +1 -0
  267. package/dist/engine/deploy/database.d.ts +116 -0
  268. package/dist/engine/deploy/database.d.ts.map +1 -0
  269. package/dist/engine/deploy/database.js +252 -0
  270. package/dist/engine/deploy/database.js.map +1 -0
  271. package/dist/engine/deploy/deploy-info.d.ts +48 -0
  272. package/dist/engine/deploy/deploy-info.d.ts.map +1 -0
  273. package/dist/engine/deploy/deploy-info.js +163 -0
  274. package/dist/engine/deploy/deploy-info.js.map +1 -0
  275. package/dist/engine/deploy/deployment-evidence.d.ts +38 -0
  276. package/dist/engine/deploy/deployment-evidence.d.ts.map +1 -0
  277. package/dist/engine/deploy/deployment-evidence.js +92 -0
  278. package/dist/engine/deploy/deployment-evidence.js.map +1 -0
  279. package/dist/engine/deploy/edge-config.d.ts +103 -0
  280. package/dist/engine/deploy/edge-config.d.ts.map +1 -0
  281. package/dist/engine/deploy/edge-config.js +170 -0
  282. package/dist/engine/deploy/edge-config.js.map +1 -0
  283. package/dist/engine/deploy/env-absence.d.ts +61 -0
  284. package/dist/engine/deploy/env-absence.d.ts.map +1 -0
  285. package/dist/engine/deploy/env-absence.js +33 -0
  286. package/dist/engine/deploy/env-absence.js.map +1 -0
  287. package/dist/engine/deploy/env-file.d.ts +14 -0
  288. package/dist/engine/deploy/env-file.d.ts.map +1 -0
  289. package/dist/engine/deploy/env-file.js +58 -0
  290. package/dist/engine/deploy/env-file.js.map +1 -0
  291. package/dist/engine/deploy/env-fragments.d.ts +29 -0
  292. package/dist/engine/deploy/env-fragments.d.ts.map +1 -0
  293. package/dist/engine/deploy/env-fragments.js +73 -0
  294. package/dist/engine/deploy/env-fragments.js.map +1 -0
  295. package/dist/engine/deploy/env-metadata.d.ts +73 -0
  296. package/dist/engine/deploy/env-metadata.d.ts.map +1 -0
  297. package/dist/engine/deploy/env-metadata.js +227 -0
  298. package/dist/engine/deploy/env-metadata.js.map +1 -0
  299. package/dist/engine/deploy/env-spec.d.ts +75 -0
  300. package/dist/engine/deploy/env-spec.d.ts.map +1 -0
  301. package/dist/engine/deploy/env-spec.js +239 -0
  302. package/dist/engine/deploy/env-spec.js.map +1 -0
  303. package/dist/engine/deploy/env-wizard.d.ts +56 -0
  304. package/dist/engine/deploy/env-wizard.d.ts.map +1 -0
  305. package/dist/engine/deploy/env-wizard.js +235 -0
  306. package/dist/engine/deploy/env-wizard.js.map +1 -0
  307. package/dist/engine/deploy/executor.d.ts +81 -0
  308. package/dist/engine/deploy/executor.d.ts.map +1 -0
  309. package/dist/engine/deploy/executor.js +247 -0
  310. package/dist/engine/deploy/executor.js.map +1 -0
  311. package/dist/engine/deploy/health.d.ts +146 -0
  312. package/dist/engine/deploy/health.d.ts.map +1 -0
  313. package/dist/engine/deploy/health.js +323 -0
  314. package/dist/engine/deploy/health.js.map +1 -0
  315. package/dist/engine/deploy/hooks.d.ts +66 -0
  316. package/dist/engine/deploy/hooks.d.ts.map +1 -0
  317. package/dist/engine/deploy/hooks.js +19 -0
  318. package/dist/engine/deploy/hooks.js.map +1 -0
  319. package/dist/engine/deploy/host-facts.d.ts +23 -0
  320. package/dist/engine/deploy/host-facts.d.ts.map +1 -0
  321. package/dist/engine/deploy/host-facts.js +67 -0
  322. package/dist/engine/deploy/host-facts.js.map +1 -0
  323. package/dist/engine/deploy/install.d.ts +233 -0
  324. package/dist/engine/deploy/install.d.ts.map +1 -0
  325. package/dist/engine/deploy/install.js +1304 -0
  326. package/dist/engine/deploy/install.js.map +1 -0
  327. package/dist/engine/deploy/inventory.d.ts +30 -0
  328. package/dist/engine/deploy/inventory.d.ts.map +1 -0
  329. package/dist/engine/deploy/inventory.js +122 -0
  330. package/dist/engine/deploy/inventory.js.map +1 -0
  331. package/dist/engine/deploy/journal.d.ts +77 -0
  332. package/dist/engine/deploy/journal.d.ts.map +1 -0
  333. package/dist/engine/deploy/journal.js +221 -0
  334. package/dist/engine/deploy/journal.js.map +1 -0
  335. package/dist/engine/deploy/layout.d.ts +77 -0
  336. package/dist/engine/deploy/layout.d.ts.map +1 -0
  337. package/dist/engine/deploy/layout.js +191 -0
  338. package/dist/engine/deploy/layout.js.map +1 -0
  339. package/dist/engine/deploy/oauth-check.d.ts +58 -0
  340. package/dist/engine/deploy/oauth-check.d.ts.map +1 -0
  341. package/dist/engine/deploy/oauth-check.js +213 -0
  342. package/dist/engine/deploy/oauth-check.js.map +1 -0
  343. package/dist/engine/deploy/proxy-bootstrap.d.ts +149 -0
  344. package/dist/engine/deploy/proxy-bootstrap.d.ts.map +1 -0
  345. package/dist/engine/deploy/proxy-bootstrap.js +416 -0
  346. package/dist/engine/deploy/proxy-bootstrap.js.map +1 -0
  347. package/dist/engine/deploy/proxy-streams.d.ts +110 -0
  348. package/dist/engine/deploy/proxy-streams.d.ts.map +1 -0
  349. package/dist/engine/deploy/proxy-streams.js +208 -0
  350. package/dist/engine/deploy/proxy-streams.js.map +1 -0
  351. package/dist/engine/deploy/proxy.d.ts +375 -0
  352. package/dist/engine/deploy/proxy.d.ts.map +1 -0
  353. package/dist/engine/deploy/proxy.js +758 -0
  354. package/dist/engine/deploy/proxy.js.map +1 -0
  355. package/dist/engine/deploy/renewal.d.ts +54 -0
  356. package/dist/engine/deploy/renewal.d.ts.map +1 -0
  357. package/dist/engine/deploy/renewal.js +169 -0
  358. package/dist/engine/deploy/renewal.js.map +1 -0
  359. package/dist/engine/deploy/repo.d.ts +101 -0
  360. package/dist/engine/deploy/repo.d.ts.map +1 -0
  361. package/dist/engine/deploy/repo.js +250 -0
  362. package/dist/engine/deploy/repo.js.map +1 -0
  363. package/dist/engine/deploy/run-record.d.ts +28 -0
  364. package/dist/engine/deploy/run-record.d.ts.map +1 -0
  365. package/dist/engine/deploy/run-record.js +44 -0
  366. package/dist/engine/deploy/run-record.js.map +1 -0
  367. package/dist/engine/deploy/state.d.ts +262 -0
  368. package/dist/engine/deploy/state.d.ts.map +1 -0
  369. package/dist/engine/deploy/state.js +163 -0
  370. package/dist/engine/deploy/state.js.map +1 -0
  371. package/dist/engine/deploy/steps/app-step-context.d.ts +24 -0
  372. package/dist/engine/deploy/steps/app-step-context.d.ts.map +1 -0
  373. package/dist/engine/deploy/steps/app-step-context.js +45 -0
  374. package/dist/engine/deploy/steps/app-step-context.js.map +1 -0
  375. package/dist/engine/deploy/steps/pipeline.d.ts +46 -0
  376. package/dist/engine/deploy/steps/pipeline.d.ts.map +1 -0
  377. package/dist/engine/deploy/steps/pipeline.js +73 -0
  378. package/dist/engine/deploy/steps/pipeline.js.map +1 -0
  379. package/dist/engine/deploy/steps/plan.d.ts +28 -0
  380. package/dist/engine/deploy/steps/plan.d.ts.map +1 -0
  381. package/dist/engine/deploy/steps/plan.js +32 -0
  382. package/dist/engine/deploy/steps/plan.js.map +1 -0
  383. package/dist/engine/deploy/steps/registry.d.ts +182 -0
  384. package/dist/engine/deploy/steps/registry.d.ts.map +1 -0
  385. package/dist/engine/deploy/steps/registry.js +212 -0
  386. package/dist/engine/deploy/steps/registry.js.map +1 -0
  387. package/dist/engine/deploy/steps/step-values.d.ts +28 -0
  388. package/dist/engine/deploy/steps/step-values.d.ts.map +1 -0
  389. package/dist/engine/deploy/steps/step-values.js +33 -0
  390. package/dist/engine/deploy/steps/step-values.js.map +1 -0
  391. package/dist/engine/deploy/testing/fake-postgres.d.ts +88 -0
  392. package/dist/engine/deploy/testing/fake-postgres.d.ts.map +1 -0
  393. package/dist/engine/deploy/testing/fake-postgres.js +236 -0
  394. package/dist/engine/deploy/testing/fake-postgres.js.map +1 -0
  395. package/dist/engine/deploy/testing/fake-vps.d.ts +147 -0
  396. package/dist/engine/deploy/testing/fake-vps.d.ts.map +1 -0
  397. package/dist/engine/deploy/testing/fake-vps.js +365 -0
  398. package/dist/engine/deploy/testing/fake-vps.js.map +1 -0
  399. package/dist/engine/deploy/uninstall.d.ts +87 -0
  400. package/dist/engine/deploy/uninstall.d.ts.map +1 -0
  401. package/dist/engine/deploy/uninstall.js +320 -0
  402. package/dist/engine/deploy/uninstall.js.map +1 -0
  403. package/dist/engine/deploy/update.d.ts +111 -0
  404. package/dist/engine/deploy/update.d.ts.map +1 -0
  405. package/dist/engine/deploy/update.js +1228 -0
  406. package/dist/engine/deploy/update.js.map +1 -0
  407. package/dist/engine/deploy/version-step.d.ts +65 -0
  408. package/dist/engine/deploy/version-step.d.ts.map +1 -0
  409. package/dist/engine/deploy/version-step.js +176 -0
  410. package/dist/engine/deploy/version-step.js.map +1 -0
  411. package/dist/engine/device-auth.d.ts +240 -0
  412. package/dist/engine/device-auth.d.ts.map +1 -0
  413. package/dist/engine/device-auth.js +442 -0
  414. package/dist/engine/device-auth.js.map +1 -0
  415. package/dist/engine/device-login.d.ts +126 -0
  416. package/dist/engine/device-login.d.ts.map +1 -0
  417. package/dist/engine/device-login.js +164 -0
  418. package/dist/engine/device-login.js.map +1 -0
  419. package/dist/engine/errors.d.ts +314 -0
  420. package/dist/engine/errors.d.ts.map +1 -0
  421. package/dist/engine/errors.js +561 -0
  422. package/dist/engine/errors.js.map +1 -0
  423. package/dist/engine/identity.d.ts +169 -0
  424. package/dist/engine/identity.d.ts.map +1 -0
  425. package/dist/engine/identity.js +227 -0
  426. package/dist/engine/identity.js.map +1 -0
  427. package/dist/engine/index.d.ts +104 -0
  428. package/dist/engine/index.d.ts.map +1 -0
  429. package/dist/engine/index.js +126 -0
  430. package/dist/engine/index.js.map +1 -0
  431. package/dist/engine/init/local-profile.d.ts +93 -0
  432. package/dist/engine/init/local-profile.d.ts.map +1 -0
  433. package/dist/engine/init/local-profile.js +295 -0
  434. package/dist/engine/init/local-profile.js.map +1 -0
  435. package/dist/engine/init/run-init.d.ts +41 -0
  436. package/dist/engine/init/run-init.d.ts.map +1 -0
  437. package/dist/engine/init/run-init.js +297 -0
  438. package/dist/engine/init/run-init.js.map +1 -0
  439. package/dist/engine/node/capabilities.d.ts +238 -0
  440. package/dist/engine/node/capabilities.d.ts.map +1 -0
  441. package/dist/engine/node/capabilities.js +316 -0
  442. package/dist/engine/node/capabilities.js.map +1 -0
  443. package/dist/engine/node/daemon.d.ts +63 -0
  444. package/dist/engine/node/daemon.d.ts.map +1 -0
  445. package/dist/engine/node/daemon.js +227 -0
  446. package/dist/engine/node/daemon.js.map +1 -0
  447. package/dist/engine/node/doctor.d.ts +58 -0
  448. package/dist/engine/node/doctor.d.ts.map +1 -0
  449. package/dist/engine/node/doctor.js +394 -0
  450. package/dist/engine/node/doctor.js.map +1 -0
  451. package/dist/engine/node/enrollment.d.ts +98 -0
  452. package/dist/engine/node/enrollment.d.ts.map +1 -0
  453. package/dist/engine/node/enrollment.js +189 -0
  454. package/dist/engine/node/enrollment.js.map +1 -0
  455. package/dist/engine/node/env-flags.d.ts +5 -0
  456. package/dist/engine/node/env-flags.d.ts.map +1 -0
  457. package/dist/engine/node/env-flags.js +22 -0
  458. package/dist/engine/node/env-flags.js.map +1 -0
  459. package/dist/engine/node/executors/credential-hygiene.d.ts +63 -0
  460. package/dist/engine/node/executors/credential-hygiene.d.ts.map +1 -0
  461. package/dist/engine/node/executors/credential-hygiene.js +189 -0
  462. package/dist/engine/node/executors/credential-hygiene.js.map +1 -0
  463. package/dist/engine/node/executors/db-backup-run.d.ts +73 -0
  464. package/dist/engine/node/executors/db-backup-run.d.ts.map +1 -0
  465. package/dist/engine/node/executors/db-backup-run.js +362 -0
  466. package/dist/engine/node/executors/db-backup-run.js.map +1 -0
  467. package/dist/engine/node/executors/example-checksum.d.ts +30 -0
  468. package/dist/engine/node/executors/example-checksum.d.ts.map +1 -0
  469. package/dist/engine/node/executors/example-checksum.js +56 -0
  470. package/dist/engine/node/executors/example-checksum.js.map +1 -0
  471. package/dist/engine/node/executors/index.d.ts +168 -0
  472. package/dist/engine/node/executors/index.d.ts.map +1 -0
  473. package/dist/engine/node/executors/index.js +44 -0
  474. package/dist/engine/node/executors/index.js.map +1 -0
  475. package/dist/engine/node/executors/registry.d.ts +38 -0
  476. package/dist/engine/node/executors/registry.d.ts.map +1 -0
  477. package/dist/engine/node/executors/registry.js +92 -0
  478. package/dist/engine/node/executors/registry.js.map +1 -0
  479. package/dist/engine/node/heap-snapshot.d.ts +37 -0
  480. package/dist/engine/node/heap-snapshot.d.ts.map +1 -0
  481. package/dist/engine/node/heap-snapshot.js +160 -0
  482. package/dist/engine/node/heap-snapshot.js.map +1 -0
  483. package/dist/engine/node/install-deps.d.ts +73 -0
  484. package/dist/engine/node/install-deps.d.ts.map +1 -0
  485. package/dist/engine/node/install-deps.js +150 -0
  486. package/dist/engine/node/install-deps.js.map +1 -0
  487. package/dist/engine/node/ipc-protocol.d.ts +67 -0
  488. package/dist/engine/node/ipc-protocol.d.ts.map +1 -0
  489. package/dist/engine/node/ipc-protocol.js +83 -0
  490. package/dist/engine/node/ipc-protocol.js.map +1 -0
  491. package/dist/engine/node/lifecycle.d.ts +103 -0
  492. package/dist/engine/node/lifecycle.d.ts.map +1 -0
  493. package/dist/engine/node/lifecycle.js +259 -0
  494. package/dist/engine/node/lifecycle.js.map +1 -0
  495. package/dist/engine/node/logger.d.ts +82 -0
  496. package/dist/engine/node/logger.d.ts.map +1 -0
  497. package/dist/engine/node/logger.js +241 -0
  498. package/dist/engine/node/logger.js.map +1 -0
  499. package/dist/engine/node/memory-watchdog.d.ts +78 -0
  500. package/dist/engine/node/memory-watchdog.d.ts.map +1 -0
  501. package/dist/engine/node/memory-watchdog.js +224 -0
  502. package/dist/engine/node/memory-watchdog.js.map +1 -0
  503. package/dist/engine/node/node-api.d.ts +391 -0
  504. package/dist/engine/node/node-api.d.ts.map +1 -0
  505. package/dist/engine/node/node-api.js +123 -0
  506. package/dist/engine/node/node-api.js.map +1 -0
  507. package/dist/engine/node/node-config.d.ts +128 -0
  508. package/dist/engine/node/node-config.d.ts.map +1 -0
  509. package/dist/engine/node/node-config.js +237 -0
  510. package/dist/engine/node/node-config.js.map +1 -0
  511. package/dist/engine/node/node-dashboard-source.d.ts +56 -0
  512. package/dist/engine/node/node-dashboard-source.d.ts.map +1 -0
  513. package/dist/engine/node/node-dashboard-source.js +213 -0
  514. package/dist/engine/node/node-dashboard-source.js.map +1 -0
  515. package/dist/engine/node/node-engine.d.ts +229 -0
  516. package/dist/engine/node/node-engine.d.ts.map +1 -0
  517. package/dist/engine/node/node-engine.js +723 -0
  518. package/dist/engine/node/node-engine.js.map +1 -0
  519. package/dist/engine/node/node-errors.d.ts +54 -0
  520. package/dist/engine/node/node-errors.d.ts.map +1 -0
  521. package/dist/engine/node/node-errors.js +71 -0
  522. package/dist/engine/node/node-errors.js.map +1 -0
  523. package/dist/engine/node/node-events.d.ts +132 -0
  524. package/dist/engine/node/node-events.d.ts.map +1 -0
  525. package/dist/engine/node/node-events.js +2 -0
  526. package/dist/engine/node/node-events.js.map +1 -0
  527. package/dist/engine/node/node-vitals.d.ts +123 -0
  528. package/dist/engine/node/node-vitals.d.ts.map +1 -0
  529. package/dist/engine/node/node-vitals.js +266 -0
  530. package/dist/engine/node/node-vitals.js.map +1 -0
  531. package/dist/engine/node/paths.d.ts +39 -0
  532. package/dist/engine/node/paths.d.ts.map +1 -0
  533. package/dist/engine/node/paths.js +60 -0
  534. package/dist/engine/node/paths.js.map +1 -0
  535. package/dist/engine/node/pg-dump.d.ts +126 -0
  536. package/dist/engine/node/pg-dump.d.ts.map +1 -0
  537. package/dist/engine/node/pg-dump.js +223 -0
  538. package/dist/engine/node/pg-dump.js.map +1 -0
  539. package/dist/engine/node/pidfile.d.ts +38 -0
  540. package/dist/engine/node/pidfile.d.ts.map +1 -0
  541. package/dist/engine/node/pidfile.js +156 -0
  542. package/dist/engine/node/pidfile.js.map +1 -0
  543. package/dist/engine/node/runtime-tuning.d.ts +65 -0
  544. package/dist/engine/node/runtime-tuning.d.ts.map +1 -0
  545. package/dist/engine/node/runtime-tuning.js +198 -0
  546. package/dist/engine/node/runtime-tuning.js.map +1 -0
  547. package/dist/engine/node/service.d.ts +39 -0
  548. package/dist/engine/node/service.d.ts.map +1 -0
  549. package/dist/engine/node/service.js +211 -0
  550. package/dist/engine/node/service.js.map +1 -0
  551. package/dist/engine/node/start.d.ts +62 -0
  552. package/dist/engine/node/start.d.ts.map +1 -0
  553. package/dist/engine/node/start.js +245 -0
  554. package/dist/engine/node/start.js.map +1 -0
  555. package/dist/engine/node/worker-env-table.d.ts +15 -0
  556. package/dist/engine/node/worker-env-table.d.ts.map +1 -0
  557. package/dist/engine/node/worker-env-table.js +97 -0
  558. package/dist/engine/node/worker-env-table.js.map +1 -0
  559. package/dist/engine/node/worker-env.d.ts +50 -0
  560. package/dist/engine/node/worker-env.d.ts.map +1 -0
  561. package/dist/engine/node/worker-env.js +101 -0
  562. package/dist/engine/node/worker-env.js.map +1 -0
  563. package/dist/engine/output.d.ts +97 -0
  564. package/dist/engine/output.d.ts.map +1 -0
  565. package/dist/engine/output.js +274 -0
  566. package/dist/engine/output.js.map +1 -0
  567. package/dist/engine/package-info.d.ts +7 -0
  568. package/dist/engine/package-info.d.ts.map +1 -0
  569. package/dist/engine/package-info.js +38 -0
  570. package/dist/engine/package-info.js.map +1 -0
  571. package/dist/engine/program.d.ts +50 -0
  572. package/dist/engine/program.d.ts.map +1 -0
  573. package/dist/engine/program.js +197 -0
  574. package/dist/engine/program.js.map +1 -0
  575. package/dist/engine/prompt.d.ts +69 -0
  576. package/dist/engine/prompt.d.ts.map +1 -0
  577. package/dist/engine/prompt.js +205 -0
  578. package/dist/engine/prompt.js.map +1 -0
  579. package/dist/engine/registries.d.ts +5 -0
  580. package/dist/engine/registries.d.ts.map +1 -0
  581. package/dist/engine/registries.js +52 -0
  582. package/dist/engine/registries.js.map +1 -0
  583. package/dist/engine/request-body.d.ts +31 -0
  584. package/dist/engine/request-body.d.ts.map +1 -0
  585. package/dist/engine/request-body.js +156 -0
  586. package/dist/engine/request-body.js.map +1 -0
  587. package/dist/engine/test-support.d.ts +50 -0
  588. package/dist/engine/test-support.d.ts.map +1 -0
  589. package/dist/engine/test-support.js +86 -0
  590. package/dist/engine/test-support.js.map +1 -0
  591. package/dist/engine/tui/app.d.ts +3 -0
  592. package/dist/engine/tui/app.d.ts.map +1 -0
  593. package/dist/engine/tui/app.js +100 -0
  594. package/dist/engine/tui/app.js.map +1 -0
  595. package/dist/engine/tui/builtin-screens.d.ts +6 -0
  596. package/dist/engine/tui/builtin-screens.d.ts.map +1 -0
  597. package/dist/engine/tui/builtin-screens.js +54 -0
  598. package/dist/engine/tui/builtin-screens.js.map +1 -0
  599. package/dist/engine/tui/index.d.ts +23 -0
  600. package/dist/engine/tui/index.d.ts.map +1 -0
  601. package/dist/engine/tui/index.js +71 -0
  602. package/dist/engine/tui/index.js.map +1 -0
  603. package/dist/engine/tui/layout.d.ts +132 -0
  604. package/dist/engine/tui/layout.d.ts.map +1 -0
  605. package/dist/engine/tui/layout.js +200 -0
  606. package/dist/engine/tui/layout.js.map +1 -0
  607. package/dist/engine/tui/routes.d.ts +5 -0
  608. package/dist/engine/tui/routes.d.ts.map +1 -0
  609. package/dist/engine/tui/routes.js +16 -0
  610. package/dist/engine/tui/routes.js.map +1 -0
  611. package/dist/engine/tui/screen-registry.d.ts +100 -0
  612. package/dist/engine/tui/screen-registry.d.ts.map +1 -0
  613. package/dist/engine/tui/screen-registry.js +96 -0
  614. package/dist/engine/tui/screen-registry.js.map +1 -0
  615. package/dist/engine/tui/screen-sections.d.ts +9 -0
  616. package/dist/engine/tui/screen-sections.d.ts.map +1 -0
  617. package/dist/engine/tui/screen-sections.js +45 -0
  618. package/dist/engine/tui/screen-sections.js.map +1 -0
  619. package/dist/engine/tui/screens/deploy/advanced-model.d.ts +69 -0
  620. package/dist/engine/tui/screens/deploy/advanced-model.d.ts.map +1 -0
  621. package/dist/engine/tui/screens/deploy/advanced-model.js +228 -0
  622. package/dist/engine/tui/screens/deploy/advanced-model.js.map +1 -0
  623. package/dist/engine/tui/screens/deploy/doctor-model.d.ts +37 -0
  624. package/dist/engine/tui/screens/deploy/doctor-model.d.ts.map +1 -0
  625. package/dist/engine/tui/screens/deploy/doctor-model.js +89 -0
  626. package/dist/engine/tui/screens/deploy/doctor-model.js.map +1 -0
  627. package/dist/engine/tui/screens/deploy/doctor.d.ts +8 -0
  628. package/dist/engine/tui/screens/deploy/doctor.d.ts.map +1 -0
  629. package/dist/engine/tui/screens/deploy/doctor.js +153 -0
  630. package/dist/engine/tui/screens/deploy/doctor.js.map +1 -0
  631. package/dist/engine/tui/screens/deploy/fields.d.ts +123 -0
  632. package/dist/engine/tui/screens/deploy/fields.d.ts.map +1 -0
  633. package/dist/engine/tui/screens/deploy/fields.js +202 -0
  634. package/dist/engine/tui/screens/deploy/fields.js.map +1 -0
  635. package/dist/engine/tui/screens/deploy/flags-model.d.ts +67 -0
  636. package/dist/engine/tui/screens/deploy/flags-model.d.ts.map +1 -0
  637. package/dist/engine/tui/screens/deploy/flags-model.js +302 -0
  638. package/dist/engine/tui/screens/deploy/flags-model.js.map +1 -0
  639. package/dist/engine/tui/screens/deploy/index.d.ts +6 -0
  640. package/dist/engine/tui/screens/deploy/index.d.ts.map +1 -0
  641. package/dist/engine/tui/screens/deploy/index.js +83 -0
  642. package/dist/engine/tui/screens/deploy/index.js.map +1 -0
  643. package/dist/engine/tui/screens/deploy/install-model.d.ts +159 -0
  644. package/dist/engine/tui/screens/deploy/install-model.d.ts.map +1 -0
  645. package/dist/engine/tui/screens/deploy/install-model.js +319 -0
  646. package/dist/engine/tui/screens/deploy/install-model.js.map +1 -0
  647. package/dist/engine/tui/screens/deploy/install.d.ts +8 -0
  648. package/dist/engine/tui/screens/deploy/install.d.ts.map +1 -0
  649. package/dist/engine/tui/screens/deploy/install.js +361 -0
  650. package/dist/engine/tui/screens/deploy/install.js.map +1 -0
  651. package/dist/engine/tui/screens/deploy/model.d.ts +49 -0
  652. package/dist/engine/tui/screens/deploy/model.d.ts.map +1 -0
  653. package/dist/engine/tui/screens/deploy/model.js +59 -0
  654. package/dist/engine/tui/screens/deploy/model.js.map +1 -0
  655. package/dist/engine/tui/screens/deploy/run-model.d.ts +58 -0
  656. package/dist/engine/tui/screens/deploy/run-model.d.ts.map +1 -0
  657. package/dist/engine/tui/screens/deploy/run-model.js +117 -0
  658. package/dist/engine/tui/screens/deploy/run-model.js.map +1 -0
  659. package/dist/engine/tui/screens/deploy/run.d.ts +75 -0
  660. package/dist/engine/tui/screens/deploy/run.d.ts.map +1 -0
  661. package/dist/engine/tui/screens/deploy/run.js +201 -0
  662. package/dist/engine/tui/screens/deploy/run.js.map +1 -0
  663. package/dist/engine/tui/screens/deploy/status.d.ts +17 -0
  664. package/dist/engine/tui/screens/deploy/status.d.ts.map +1 -0
  665. package/dist/engine/tui/screens/deploy/status.js +107 -0
  666. package/dist/engine/tui/screens/deploy/status.js.map +1 -0
  667. package/dist/engine/tui/screens/deploy/update.d.ts +41 -0
  668. package/dist/engine/tui/screens/deploy/update.d.ts.map +1 -0
  669. package/dist/engine/tui/screens/deploy/update.js +175 -0
  670. package/dist/engine/tui/screens/deploy/update.js.map +1 -0
  671. package/dist/engine/tui/screens/deploy.d.ts +12 -0
  672. package/dist/engine/tui/screens/deploy.d.ts.map +1 -0
  673. package/dist/engine/tui/screens/deploy.js +23 -0
  674. package/dist/engine/tui/screens/deploy.js.map +1 -0
  675. package/dist/engine/tui/screens/invoke.d.ts +6 -0
  676. package/dist/engine/tui/screens/invoke.d.ts.map +1 -0
  677. package/dist/engine/tui/screens/invoke.js +193 -0
  678. package/dist/engine/tui/screens/invoke.js.map +1 -0
  679. package/dist/engine/tui/screens/login.d.ts +6 -0
  680. package/dist/engine/tui/screens/login.d.ts.map +1 -0
  681. package/dist/engine/tui/screens/login.js +255 -0
  682. package/dist/engine/tui/screens/login.js.map +1 -0
  683. package/dist/engine/tui/screens/logout.d.ts +6 -0
  684. package/dist/engine/tui/screens/logout.d.ts.map +1 -0
  685. package/dist/engine/tui/screens/logout.js +142 -0
  686. package/dist/engine/tui/screens/logout.js.map +1 -0
  687. package/dist/engine/tui/screens/menu.d.ts +22 -0
  688. package/dist/engine/tui/screens/menu.d.ts.map +1 -0
  689. package/dist/engine/tui/screens/menu.js +84 -0
  690. package/dist/engine/tui/screens/menu.js.map +1 -0
  691. package/dist/engine/tui/screens/node.d.ts +6 -0
  692. package/dist/engine/tui/screens/node.d.ts.map +1 -0
  693. package/dist/engine/tui/screens/node.js +228 -0
  694. package/dist/engine/tui/screens/node.js.map +1 -0
  695. package/dist/engine/tui/screens/status.d.ts +6 -0
  696. package/dist/engine/tui/screens/status.d.ts.map +1 -0
  697. package/dist/engine/tui/screens/status.js +134 -0
  698. package/dist/engine/tui/screens/status.js.map +1 -0
  699. package/dist/engine/tui/scroll-box.d.ts +27 -0
  700. package/dist/engine/tui/scroll-box.d.ts.map +1 -0
  701. package/dist/engine/tui/scroll-box.js +52 -0
  702. package/dist/engine/tui/scroll-box.js.map +1 -0
  703. package/dist/engine/tui/section-registry.d.ts +65 -0
  704. package/dist/engine/tui/section-registry.d.ts.map +1 -0
  705. package/dist/engine/tui/section-registry.js +90 -0
  706. package/dist/engine/tui/section-registry.js.map +1 -0
  707. package/dist/engine/tui/terminal.d.ts +31 -0
  708. package/dist/engine/tui/terminal.d.ts.map +1 -0
  709. package/dist/engine/tui/terminal.js +142 -0
  710. package/dist/engine/tui/terminal.js.map +1 -0
  711. package/dist/engine/tui/tty.d.ts +49 -0
  712. package/dist/engine/tui/tty.d.ts.map +1 -0
  713. package/dist/engine/tui/tty.js +139 -0
  714. package/dist/engine/tui/tty.js.map +1 -0
  715. package/dist/index.d.ts +4 -5
  716. package/dist/index.d.ts.map +1 -1
  717. package/dist/index.js +5 -5
  718. package/dist/index.js.map +1 -1
  719. package/dist/node/index.d.ts +3 -0
  720. package/dist/node/index.d.ts.map +1 -0
  721. package/dist/node/index.js +5 -0
  722. package/dist/node/index.js.map +1 -0
  723. package/dist/telemetry/index.d.ts +2 -1
  724. package/dist/telemetry/index.d.ts.map +1 -1
  725. package/dist/telemetry/index.js +1 -0
  726. package/dist/telemetry/index.js.map +1 -1
  727. package/dist/telemetry/node-span-relay.d.ts +1 -1
  728. package/dist/telemetry/node-span-relay.d.ts.map +1 -1
  729. package/dist/telemetry/node-span-relay.js +39 -6
  730. package/dist/telemetry/node-span-relay.js.map +1 -1
  731. package/dist/telemetry/node-span.d.ts +39 -7
  732. package/dist/telemetry/node-span.d.ts.map +1 -1
  733. package/dist/telemetry/node-span.js +19 -1
  734. package/dist/telemetry/node-span.js.map +1 -1
  735. package/dist/testing/index.d.ts +3 -0
  736. package/dist/testing/index.d.ts.map +1 -0
  737. package/dist/testing/index.js +4 -0
  738. package/dist/testing/index.js.map +1 -0
  739. package/dist/tui/index.d.ts +3 -0
  740. package/dist/tui/index.d.ts.map +1 -0
  741. package/dist/tui/index.js +5 -0
  742. package/dist/tui/index.js.map +1 -0
  743. package/package.json +43 -5
@@ -0,0 +1,1228 @@
1
+ import { existsSync, mkdirSync, readFileSync } from 'node:fs';
2
+ import { basename, join } from 'node:path';
3
+ import { cliName, cliVersion } from '../identity.js';
4
+ import { PreconditionError, UsageError } from '../errors.js';
5
+ import { allChecks, listRegisteredDeployChecks, SOURCE_CHECK_IDS, checksPassed, databaseSettings, gitCredentialStateFor, readRoleAttributes, runChecks, runPsql, severityOf, } from './checks/index.js';
6
+ import { diffEnv, parseEnvExample, parseEnvFile } from './env-spec.js';
7
+ import { genuinelyNewKeys } from './env-absence.js';
8
+ import { effectiveGroups } from './compose-files.js';
9
+ import { adoptDeployment } from './adopt.js';
10
+ import { describeEvidence } from './deployment-evidence.js';
11
+ import { readEnvFile, writeEnvContents, writeEnvFile } from './env-file.js';
12
+ import { generateValue, metadataFor, needsAutoGenerate, } from './env-metadata.js';
13
+ import { runEnvWizard } from './env-wizard.js';
14
+ import { runCommand as defaultRunCommand } from './executor.js';
15
+ import { reconcileEdgeConfig, parseSha256sum, edgeConfigFiles } from './edge-config.js';
16
+ import { ensureApplicationRole, resolveAdminLogin, roleOptionsFrom, superuserAllowedFor, superuserConsequence, superuserRecord, } from './app-role.js';
17
+ import { ensureDatabase } from './database.js';
18
+ import { collectHealth, isHealthy, waitForHealthy } from './health.js';
19
+ import { openJournal } from './journal.js';
20
+ import { certificateStatus, describeProxyRuntime, installVhost, issueCertificate, resolveRecordedProxyRuntime, } from './proxy.js';
21
+ import { ensureCheckout, normaliseRepoUrl, resolveRepoTarget } from './repo.js';
22
+ import { NotInstalledError, appendHistory, readState, writeState, } from './state.js';
23
+ import { runPipeline } from './steps/pipeline.js';
24
+ import { appStepContext } from './steps/app-step-context.js';
25
+ import { withRegisteredSteps } from './steps/registry.js';
26
+ import { checkoutPathFor, publishVersion, runVersionStep, stampAppVersion, } from './version-step.js';
27
+ import { writeDeployInfo } from './deploy-info.js';
28
+ import { collectHostFacts } from './host-facts.js';
29
+ import { observeProxy, proxyInfoOf } from './run-record.js';
30
+ import { composeArgv, composeCwd, composeProjectFor, consentOptions, ensureStackNetworks, oauthSmokeTarget, reportOAuthSmoke, scheduleRenewal, secretsFrom, } from './install.js';
31
+ /**
32
+ * The groups this run acts under: the flag, else what install recorded --
33
+ * NEVER read from the `.env`, for the reason `state.groups` gives -- plus the
34
+ * always-on ones (`effectiveGroups`, #567). They decide both which new keys
35
+ * count as drift and which compose files make up the stack (compose-files.ts).
36
+ *
37
+ * The always-on union is what upgrades a deployment recorded without
38
+ * `observability`: its GREPTIME_* / OTEL_* keys become drift and its compose
39
+ * file list gains the telemetry files, on this update.
40
+ */
41
+ function groupsOf(context) {
42
+ return effectiveGroups(context.options.groups ?? context.state.groups);
43
+ }
44
+ /** Collected ONCE per run and reused; see install.ts's `hostFactsOf`. */
45
+ async function hostFactsOf(context) {
46
+ context.hostFacts ??= await collectHostFacts({ runCommand: context.runCommand });
47
+ return context.hostFacts;
48
+ }
49
+ /** The proxy mode/container this run knows: resolved now, else as recorded. */
50
+ function currentRuntime(context) {
51
+ return context.proxyRuntime === undefined
52
+ ? { mode: context.state.proxyMode, container: context.state.proxyContainer }
53
+ : { mode: context.proxyRuntime.mode, container: context.proxyRuntime.container };
54
+ }
55
+ /**
56
+ * The info.json input for this run, as known at `at`. One builder for the
57
+ * health-gate write and the end-of-run rewrite; see install.ts's
58
+ * `installDeployInfo` for why.
59
+ */
60
+ function updateDeployInfo(context, at) {
61
+ const state = context.state;
62
+ const ref = context.target?.ref ?? state.ref;
63
+ const runtime = currentRuntime(context);
64
+ return {
65
+ name: basename(context.options.deployRoot),
66
+ ...(context.version?.version === undefined ? {} : { version: context.version.version }),
67
+ ...(context.commitSha === undefined ? {} : { commitSha: context.commitSha }),
68
+ ...(ref === undefined ? {} : { ref }),
69
+ installedAt: state.installedAt,
70
+ updatedAt: at,
71
+ cliVersion: cliVersion(),
72
+ ...(state.domain === undefined ? {} : { domain: state.domain }),
73
+ // What THIS run has finished so far -- not the resume set, which is what
74
+ // a PREVIOUS run finished.
75
+ completed: [...(context.progress ?? [])],
76
+ lastCommand: 'update',
77
+ bindPort: state.bindPort,
78
+ proxy: proxyInfoOf(state.domain === undefined
79
+ ? undefined
80
+ : {
81
+ domain: state.domain,
82
+ bindPort: state.bindPort,
83
+ mode: runtime.mode ?? null,
84
+ container: runtime.container ?? null,
85
+ // Until the end-of-run rewrite, what the last successful run read.
86
+ certificateExpiresAt: state.proxy?.domain === state.domain ? state.proxy.certificateExpiresAt : null,
87
+ }),
88
+ ...(context.hostFacts === undefined ? {} : { host: context.hostFacts }),
89
+ // Success-only: THIS run is not in it until it has succeeded.
90
+ history: state.history ?? [],
91
+ };
92
+ }
93
+ /** Certificates are renewed within this window, not on every deploy. */
94
+ function envFilePath(deployRoot) {
95
+ return join(composeCwd(deployRoot), '.env');
96
+ }
97
+ /** The environment this update acts on: the drift step's, else the file on disk (a resumed run). */
98
+ function environmentOfUpdate(context) {
99
+ if (context.env !== undefined)
100
+ return context.env;
101
+ const path = envFilePath(context.options.deployRoot);
102
+ return existsSync(path) ? parseEnvFile(readFileSync(path, 'utf8')) : undefined;
103
+ }
104
+ async function compose(context, extra, options) {
105
+ // See `ensureBindSources` in install.ts: Docker creates a missing bind
106
+ // source as root:root the moment it instantiates the service, and `compose
107
+ // run` does that as thoroughly as `up`.
108
+ mkdirSync(join(context.options.deployRoot, 'deploy-info'), { recursive: true });
109
+ // A network deleted since install (a `docker network prune`) fails `up`
110
+ // with a message about compose, not about the network. See install.ts.
111
+ await ensureStackNetworks(context, extra, groupsOf(context));
112
+ const argv = composeArgv(extra, composeProjectFor(context.state), groupsOf(context), composeCwd(context.options.deployRoot));
113
+ const result = await context.runCommand(argv, {
114
+ cwd: composeCwd(context.options.deployRoot),
115
+ timeoutMs: options?.timeoutMs ?? 30 * 60_000,
116
+ ...(options?.allowExitCodes === undefined ? {} : { allowExitCodes: options.allowExitCodes }),
117
+ redact: context.journal.redact,
118
+ ...(context.hooks?.onLog === undefined
119
+ ? {}
120
+ : { onLine: (line) => context.hooks?.onLog?.(line) }),
121
+ });
122
+ context.journal.command(result);
123
+ return result;
124
+ }
125
+ /**
126
+ * Recreates the app's nginx, and only it.
127
+ *
128
+ * `--force-recreate` because nothing in the compose MODEL changes when a
129
+ * bind-mounted file's content does, so a plain `up -d` leaves the container
130
+ * alone; `--no-deps` so api and web are not recreated along with it.
131
+ */
132
+ const RECREATE_NGINX = ['up', '-d', '--no-deps', '--force-recreate', 'nginx'];
133
+ /**
134
+ * Recreates the api container, and only it: `--no-deps` so nginx/web are not
135
+ * recreated along with it, and `--force-recreate` because nothing in the
136
+ * compose MODEL changes when `.env`'s content does, so a plain `up -d` would
137
+ * leave the container alone. Used to force a maintenance-mode toggle into
138
+ * effect immediately -- see `enableMaintenanceMode`/`disableMaintenanceMode`
139
+ * below (#648).
140
+ */
141
+ const RECREATE_API = ['up', '-d', '--no-deps', '--force-recreate', 'api'];
142
+ /**
143
+ * Forces `MAINTENANCE_MODE=true` into the deployment's `.env` and recreates
144
+ * `api` so it takes effect immediately -- `MAINTENANCE_MODE` is read from
145
+ * `process.env`, which an already-running container does not re-read
146
+ * (`docs/specs/maintenance-mode.md` §2.3). The environment layer is the only
147
+ * one the CLI can use at all: it holds no admin session to call
148
+ * `PUT /api/admin/maintenance` with, and the doc names this layer exactly
149
+ * this kind of break-glass.
150
+ *
151
+ * ⚠ CALLED BEFORE `build`, NOT BEFORE `migrate`'s OWN `stop api`. Setting it
152
+ * any later would leave the live, pre-update api answering real traffic for
153
+ * the whole build -- several minutes a real user could hit mid-migration-prep
154
+ * for nothing this step could have prevented.
155
+ *
156
+ * Never fails the update: a protective measure that could not be applied is
157
+ * a loud warning, not a reason to abandon an otherwise-working release. See
158
+ * `scheduleRenewal`'s identical stance.
159
+ */
160
+ async function enableMaintenanceMode(context) {
161
+ const envPath = envFilePath(context.options.deployRoot);
162
+ const templatePath = join(composeCwd(context.options.deployRoot), '.env.example');
163
+ if (!existsSync(envPath) || !existsSync(templatePath)) {
164
+ context.journal.line('No environment file yet; maintenance mode was not set.');
165
+ return;
166
+ }
167
+ const specs = parseEnvExample(readFileSync(templatePath, 'utf8'));
168
+ const values = readEnvFile(envPath);
169
+ values.set('MAINTENANCE_MODE', 'true');
170
+ writeEnvFile(envPath, values, specs);
171
+ try {
172
+ await compose(context, [...RECREATE_API], { timeoutMs: 5 * 60_000 });
173
+ context.journal.line('Maintenance mode is on: real traffic sees a 503 until it is turned off.');
174
+ }
175
+ catch (error) {
176
+ const message = error instanceof Error ? error.message : String(error);
177
+ context.journal.line(`warning: could not restart api into maintenance mode: ${message}`);
178
+ context.hooks?.onProgress?.(`warning: maintenance mode may not be in effect (${message})`);
179
+ }
180
+ }
181
+ /**
182
+ * Clears the environment override this run set, and recreates `api` so real
183
+ * requests reach it again.
184
+ *
185
+ * ⚠ DELETES THE KEY. NEVER WRITES `false`. The environment layer resolves
186
+ * ahead of the persisted one (§2.1 of the maintenance-mode spec): writing
187
+ * `false` here would silently force shut a window an admin opened through
188
+ * `/admin/settings/maintenance` for reasons of their own, the moment this
189
+ * update happened to run concurrently with it. Deleting the key returns
190
+ * resolution to whatever that other layer already says, which is correct
191
+ * whether or not it was ever touched.
192
+ *
193
+ * ⚠ RUNS BEFORE `health`/`verify`, NOT AFTER. Those read `/api/health/ready`,
194
+ * which a maintenance window deliberately drains to `503` (§2.6/§2.7) --
195
+ * running them first would make every maintenance update time out waiting
196
+ * for a readiness that is never coming while the window stays open.
197
+ *
198
+ * Unlike `enableMaintenanceMode`, this is allowed to throw: if the recreate
199
+ * does not actually take, the very next step (`health`) would time out
200
+ * waiting on a still-drained `/ready` anyway, for the real reason, not an
201
+ * invented one -- so there is nothing this needs to swallow.
202
+ */
203
+ async function disableMaintenanceMode(context) {
204
+ const envPath = envFilePath(context.options.deployRoot);
205
+ const templatePath = join(composeCwd(context.options.deployRoot), '.env.example');
206
+ if (!existsSync(envPath) || !existsSync(templatePath))
207
+ return;
208
+ const specs = parseEnvExample(readFileSync(templatePath, 'utf8'));
209
+ const values = readEnvFile(envPath);
210
+ if (!values.has('MAINTENANCE_MODE'))
211
+ return;
212
+ values.delete('MAINTENANCE_MODE');
213
+ writeEnvFile(envPath, values, specs);
214
+ await compose(context, [...RECREATE_API], { timeoutMs: 5 * 60_000 });
215
+ context.journal.line('Maintenance mode is off.');
216
+ }
217
+ /** What the container reads; see edge-config.ts. */
218
+ async function readRunningEdgeConfig(context) {
219
+ try {
220
+ // Exit 1 is sha256sum's "some file could not be read" -- the hashes it
221
+ // DID print are still worth having, and a missing one counts as drift.
222
+ const result = await compose(context, ['exec', '-T', 'nginx', 'sha256sum', ...edgeConfigFiles().map((file) => file.container)], { timeoutMs: 60_000, allowExitCodes: [1] });
223
+ return {
224
+ hashes: parseSha256sum(result.stdout),
225
+ ...(result.exitCode === 0
226
+ ? {}
227
+ : { error: `exit ${result.exitCode}: ${result.stderr.trim() || 'no output'}` }),
228
+ };
229
+ }
230
+ catch (error) {
231
+ // nginx not running at all, or docker refusing the exec: nothing to
232
+ // compare, which `reconcileEdgeConfig` treats as drift.
233
+ return {
234
+ hashes: new Map(),
235
+ error: error instanceof Error ? error.message.split('\n')[0] : String(error),
236
+ };
237
+ }
238
+ }
239
+ /**
240
+ * Records, or clears, `--allow-superuser` in the state (#980): `kept` is the
241
+ * privileged login kept in this run, if any; otherwise a previous record
242
+ * survives only while `.env` still holds that login.
243
+ */
244
+ function recordSuperuser(context, kept, currentUser) {
245
+ const record = superuserRecord(kept, context.state, currentUser);
246
+ if (record.allowSuperuser === context.state.allowSuperuser &&
247
+ record.allowSuperuserLogin === context.state.allowSuperuserLogin) {
248
+ return;
249
+ }
250
+ context.state = { ...context.state, ...record };
251
+ writeState(context.state);
252
+ }
253
+ /** Whether the flags ask for database-role work even when the revision has not moved. */
254
+ function wantsRoleWork(options) {
255
+ return (options.provisionAppRole === true ||
256
+ options.rotateAppPassword === true ||
257
+ options.allowSuperuser === true ||
258
+ options.adminUser !== undefined ||
259
+ options.appDbUser !== undefined);
260
+ }
261
+ /** Every step after `fetch` stands down when the remote has not moved. */
262
+ /**
263
+ * Where this deployment's vhost lives.
264
+ *
265
+ * Prefers the recorded value. The fallback reproduces the old derivation only
266
+ * for records written before the field existed -- it is a compatibility path,
267
+ * not the answer.
268
+ */
269
+ function proxyRootFor(context) {
270
+ return (context.state.proxyRoot ?? join(context.options.deployRoot, '..', '..', 'proxy'));
271
+ }
272
+ /**
273
+ * The proxy runtime this update acts under, resolved once and reused.
274
+ *
275
+ * Flags, then the record install left, then detection -- never a fresh guess
276
+ * that could disagree with how install published this deployment.
277
+ */
278
+ async function proxyRuntimeOf(context) {
279
+ if (context.proxyRuntime !== undefined)
280
+ return context.proxyRuntime;
281
+ const runtime = await resolveRecordedProxyRuntime({
282
+ proxyRoot: proxyRootFor(context),
283
+ flags: { mode: context.options.proxyMode, container: context.options.proxyContainer },
284
+ recorded: context.state,
285
+ runCommand: context.runCommand,
286
+ });
287
+ context.proxyRuntime = runtime;
288
+ context.journal.line(describeProxyRuntime(runtime));
289
+ return runtime;
290
+ }
291
+ function skipWhenUnchanged(context) {
292
+ return context.unchanged === true ? 'already up to date' : undefined;
293
+ }
294
+ export function buildUpdateSteps() {
295
+ return [
296
+ {
297
+ id: 'preflight',
298
+ title: 'Check the essentials',
299
+ async run(context) {
300
+ // A LIGHT preflight, not the full doctor. DNS and certificate checks
301
+ // are install-time concerns; a site that is already serving does not
302
+ // need them re-litigated on every update.
303
+ const appCheckIds = new Set(listRegisteredDeployChecks().map((check) => check.id));
304
+ const wanted = new Set([
305
+ 'docker-installed',
306
+ 'docker-daemon',
307
+ 'docker-compose-v2',
308
+ 'git-installed',
309
+ 'disk-space',
310
+ ]);
311
+ // `fetch` talks to the recorded repository, so whether git can still
312
+ // read it is an essential too -- but only as the REQUIRED subset of
313
+ // the source checks: gh is advice everywhere except an HTTPS GitHub
314
+ // URL git cannot read (#390).
315
+ const repoUrl = normaliseRepoUrl(context.state.repoUrl);
316
+ const gitCredentialed = await gitCredentialStateFor(repoUrl, context.runCommand);
317
+ const checkContext = {
318
+ runCommand: context.runCommand,
319
+ deployRoot: context.options.deployRoot,
320
+ bindPort: context.state.bindPort,
321
+ // From the record, not reconstructed. Deriving it as
322
+ // `<deployRoot>/../../proxy` silently ignored a non-default
323
+ // --proxy-root given at install time, and wrote the vhost somewhere
324
+ // the proxy does not read.
325
+ proxyRoot: proxyRootFor(context),
326
+ // Resolved here only when this update may touch the proxy; the
327
+ // checks above do not read it today, but a check promoted by the
328
+ // runtime must see the same one `publish` will use.
329
+ ...(context.options.skipProxy === true || context.state.domain === undefined
330
+ ? {}
331
+ : { proxyRuntime: await proxyRuntimeOf(context) }),
332
+ repoUrl,
333
+ ...(gitCredentialed === undefined ? {} : { gitCredentialed }),
334
+ ...(context.options.skipProxy === true ? { skipProxy: true } : {}),
335
+ };
336
+ const results = await runChecks(allChecks().filter((check) => wanted.has(check.id) ||
337
+ (SOURCE_CHECK_IDS.has(check.id) && severityOf(check, checkContext) === 'required') ||
338
+ // An app check (registerDeployCheck) that is required blocks an update too.
339
+ (appCheckIds.has(check.id) && severityOf(check, checkContext) === 'required')), checkContext);
340
+ for (const result of results) {
341
+ context.journal.line(`${result.status} ${result.id}: ${result.detail}`);
342
+ }
343
+ if (!checksPassed(results)) {
344
+ throw new PreconditionError(results
345
+ .filter((result) => result.status === 'fail')
346
+ .map((result) => `${result.id}: ${result.detail}`)
347
+ .join('\n'));
348
+ }
349
+ },
350
+ },
351
+ {
352
+ id: 'fetch',
353
+ title: 'Look for a new revision',
354
+ async run(context) {
355
+ const target = await resolveRepoTarget({
356
+ cwd: context.options.cwd ?? process.cwd(),
357
+ runCommand: context.runCommand,
358
+ state: context.state,
359
+ ...(context.options.ref === undefined ? {} : { refFlag: context.options.ref }),
360
+ });
361
+ const checkout = await ensureCheckout(target, {
362
+ deployRoot: context.options.deployRoot,
363
+ runCommand: context.runCommand,
364
+ ...(context.hooks === undefined ? {} : { hooks: context.hooks }),
365
+ ...(context.options.force === undefined ? {} : { force: context.options.force }),
366
+ });
367
+ context.target = target;
368
+ context.previousSha = checkout.previousSha;
369
+ context.commitSha = checkout.sha;
370
+ const moved = checkout.changed;
371
+ const rebuildAnyway = context.options.force === true || context.options.noCache === true;
372
+ if (!moved && !rebuildAnyway) {
373
+ // Several minutes of build and a restart for a no-op is exactly the
374
+ // friction that stops people updating often.
375
+ context.unchanged = true;
376
+ context.journal.line(`Already at ${checkout.sha}; nothing to do.`);
377
+ return;
378
+ }
379
+ context.journal.line(`${checkout.previousSha ?? 'unknown'} -> ${checkout.sha} (${target.ref})`);
380
+ // Recorded BEFORE anything is mutated, so a failed update still leaves
381
+ // behind what it was replacing.
382
+ writeState({
383
+ ...context.state,
384
+ previousSha: checkout.previousSha,
385
+ lastDeployedAt: new Date().toISOString(),
386
+ });
387
+ },
388
+ },
389
+ {
390
+ id: 'environment-drift',
391
+ title: 'Check for new environment variables',
392
+ skip: skipWhenUnchanged,
393
+ async run(context) {
394
+ const templatePath = join(composeCwd(context.options.deployRoot), '.env.example');
395
+ const path = envFilePath(context.options.deployRoot);
396
+ if (!existsSync(templatePath) || !existsSync(path))
397
+ return;
398
+ const specs = parseEnvExample(readFileSync(templatePath, 'utf8'));
399
+ const current = parseEnvFile(readFileSync(path, 'utf8'));
400
+ // ⚠ HEAL A DEPLOYMENT THAT PREDATES THE MARKER, or the fix only ever
401
+ // reaches fresh installs and every deployment in the field keeps
402
+ // mounting an empty deploy-info directory for ever. Writing it is
403
+ // inert: nothing derives container identity from it, unlike
404
+ // COMPOSE_PROJECT_NAME -- see install.ts's environment step for why
405
+ // that one is deliberately never written.
406
+ //
407
+ // Done BEFORE the drift diff below, so a value this CLI supplies is
408
+ // never mistaken for a variable the operator has to answer.
409
+ if (current.get('DEPLOY_ROOT') !== context.options.deployRoot) {
410
+ current.set('DEPLOY_ROOT', context.options.deployRoot);
411
+ writeEnvFile(path, current, specs);
412
+ context.journal.line(`Recorded DEPLOY_ROOT=${context.options.deployRoot}`);
413
+ }
414
+ const { missing, unknown } = diffEnv(specs, current);
415
+ if (unknown.length > 0) {
416
+ // Carried through, never dropped: it may be a fork's own variable.
417
+ context.journal.line(`Keeping ${unknown.length} variable(s) not in the template`);
418
+ }
419
+ const groups = groupsOf(context);
420
+ // ⚠ A PLACEHOLDER IS NOT A VALUE for a key the CLI generates itself
421
+ // (#567). A deployment whose `.env` still carries `change-me-*` for a
422
+ // GreptimeDB password -- or an empty one -- gets a generated value
423
+ // here, without a question. A real value is never touched.
424
+ const placeholders = specs.filter((spec) => {
425
+ const metadata = metadataFor(spec.key);
426
+ return (metadata.autoGenerate === true &&
427
+ current.has(spec.key) &&
428
+ (metadata.group === undefined || groups.includes(metadata.group)) &&
429
+ needsAutoGenerate(current.get(spec.key), spec.defaultValue));
430
+ });
431
+ if (missing.length === 0 && placeholders.length === 0)
432
+ return;
433
+ // "In the template and not in the file" is NOT the same question as
434
+ // "what did this revision add?". A key is permanently absent for three
435
+ // unrelated reasons - a declined optional, a `never` key, and an
436
+ // opt-in feature group the deployment never enabled - and none of them
437
+ // is drift. `genuinelyNewKeys` applies all three; filtering on
438
+ // `essential || secret` alone re-asked the ENTIRE wizard, database
439
+ // connection included, on an update whose template had not changed.
440
+ //
441
+ // The feature-group class is the one that looks handled and is not:
442
+ // those keys are NOT commented out, so `spec.optional` misses them.
443
+ // Enabled groups come from the flag, else from what install recorded -
444
+ // NEVER from reading the `.env`, for the reason `state.groups` gives.
445
+ //
446
+ // The always-on `observability` group (#567) is the upgrade path: a
447
+ // deployment recorded without it has none of its keys, and they count
448
+ // as genuinely new here -- GREPTIME_*_PASSWORD generated, the rest
449
+ // their template defaults.
450
+ const added = genuinelyNewKeys(missing, { groups });
451
+ if (added.length === 0 && placeholders.length === 0) {
452
+ context.journal.line(`Template has ${missing.length} variable(s) this deployment does not use; nothing new.`);
453
+ return;
454
+ }
455
+ const isAuto = (spec) => {
456
+ const metadata = metadataFor(spec.key);
457
+ return metadata.autoGenerate === true && metadata.generate !== undefined;
458
+ };
459
+ // Keys the CLI generates itself need no answer, no domain and no
460
+ // wizard (#567): an interactive update must not stop to ask about a
461
+ // password nobody has to know, and a deployment published without a
462
+ // domain must still be able to take them.
463
+ const generated = [...added.filter(isAuto), ...placeholders];
464
+ const rest = added.filter((spec) => !isAuto(spec));
465
+ // An `allowBlank` key does not NEED an answer: blank is a legitimate
466
+ // value for it, which is exactly what its template default gives. The
467
+ // PostgreSQL monitor login (#598) is the case: an upgrade must not stop
468
+ // to ask for an optional hardening, nor refuse a deployment recorded
469
+ // without a domain, when blank means "reuse the API's login". It is
470
+ // still asked when the wizard runs for some other key.
471
+ const needsAnswer = rest.filter((spec) => {
472
+ const metadata = metadataFor(spec.key);
473
+ if (metadata.allowBlank === true)
474
+ return false;
475
+ return metadata.essential === true || metadata.secret === true;
476
+ });
477
+ if (added.length > 0) {
478
+ context.journal.line(`This revision adds ${added.length} variable(s); ${needsAnswer.length} need a value.`);
479
+ }
480
+ const merged = new Map(current);
481
+ for (const spec of generated) {
482
+ // A value from --answers is an operator's choice, kept like one.
483
+ const supplied = context.options.answers?.get(spec.key);
484
+ const kind = metadataFor(spec.key).generate;
485
+ merged.set(spec.key, needsAutoGenerate(supplied, spec.defaultValue) ? generateValue(kind) : supplied);
486
+ }
487
+ if (generated.length > 0) {
488
+ // Names only. The values are secrets and never reach the journal.
489
+ context.journal.line(`Generated ${generated.length} value(s): ${generated.map((spec) => spec.key).join(', ')}`);
490
+ }
491
+ if (needsAnswer.length === 0) {
492
+ // Everything new has a usable default; add them and say so.
493
+ for (const spec of rest) {
494
+ merged.set(spec.key, spec.defaultValue);
495
+ }
496
+ // The WRITER still gets the full template spec list, so section
497
+ // banners and key order survive. Only the question list narrows.
498
+ writeEnvFile(path, merged, specs);
499
+ context.env = merged;
500
+ return;
501
+ }
502
+ const domain = context.state.domain;
503
+ if (domain === undefined) {
504
+ throw new UsageError('This revision needs new environment values, but no domain is recorded for this deployment. Re-run install, or set them by hand.');
505
+ }
506
+ const { values } = await runEnvWizard({
507
+ // ONLY the new keys. Handing over the full list is the other half of
508
+ // the same defect: even a genuine one-variable revision re-asked
509
+ // everything.
510
+ specs: rest,
511
+ domain,
512
+ groups,
513
+ // The generated values last, so an --answers placeholder cannot
514
+ // put back what was just replaced.
515
+ existing: context.options.answers === undefined
516
+ ? merged
517
+ : new Map([
518
+ ...current,
519
+ ...context.options.answers,
520
+ ...generated.map((spec) => [spec.key, merged.get(spec.key)]),
521
+ ]),
522
+ ...(context.options.nonInteractive === undefined
523
+ ? {}
524
+ : { nonInteractive: context.options.nonInteractive }),
525
+ ...(context.options.promptContext === undefined
526
+ ? {}
527
+ : { ctx: context.options.promptContext }),
528
+ });
529
+ writeEnvFile(path, values, specs);
530
+ context.env = values;
531
+ },
532
+ },
533
+ {
534
+ id: 'database-role',
535
+ title: 'Check the database role',
536
+ // ⚠ NOT `skipWhenUnchanged`, but not unconditional either. A cron'd
537
+ // `update` that finds nothing new must stay cheap and quiet, so on an
538
+ // unchanged revision this runs only when the operator asked for role work
539
+ // -- which is also the only way an unchanged deployment ever gets
540
+ // migrated off a superuser login. A moved revision always checks.
541
+ skip: (context) => {
542
+ if (context.unchanged === true && !wantsRoleWork(context.options)) {
543
+ return `already up to date; pass --provision-app-role to check the database role anyway`;
544
+ }
545
+ return undefined;
546
+ },
547
+ async run(context) {
548
+ // #980: a deployment whose POSTGRES_USER is a superuser runs with
549
+ // row-level security inert. Offer the same migration install does --
550
+ // provision, transfer ownership, rewrite .env, restart -- from the
551
+ // login already in .env (it is the administrator), or --admin-user.
552
+ const env = environmentOfUpdate(context);
553
+ if (env === undefined) {
554
+ context.journal.line('No environment file; nothing to check.');
555
+ return;
556
+ }
557
+ const currentUser = env.get('POSTGRES_USER');
558
+ const warn = (message) => {
559
+ context.journal.line(message);
560
+ context.hooks?.onProgress?.(message);
561
+ };
562
+ // --skip-role-provisioning creates nothing, but a superuser login is
563
+ // still worth the same warning every other path gives.
564
+ if (context.options.skipRoleProvisioning === true) {
565
+ const settings = databaseSettings(env);
566
+ const probe = settings === undefined ? undefined : await readRoleAttributes(context.runCommand, settings);
567
+ if (probe?.attributes !== undefined && (probe.attributes.superuser || probe.attributes.bypassRls)) {
568
+ warn(`warning: --skip-role-provisioning: ${superuserConsequence(currentUser ?? 'the database login')}`);
569
+ }
570
+ else {
571
+ context.journal.line('--skip-role-provisioning: no role is created; database-role-ordinary verifies the one supplied');
572
+ }
573
+ return;
574
+ }
575
+ const admin = await resolveAdminLogin(context.options, {
576
+ promptContext: context.options.promptContext,
577
+ nonInteractive: context.options.nonInteractive,
578
+ });
579
+ if (admin !== undefined) {
580
+ context.journal.addSecrets([{ key: 'DB_ADMIN_PASSWORD', value: admin.password }]);
581
+ }
582
+ // The file as it is now: put back if the server refuses the new password,
583
+ // and the target of a revert if the API does not come up on it.
584
+ const envPath = envFilePath(context.options.deployRoot);
585
+ const templatePath = join(composeCwd(context.options.deployRoot), '.env.example');
586
+ const specs = existsSync(templatePath) ? parseEnvExample(readFileSync(templatePath, 'utf8')) : [];
587
+ const previousContents = existsSync(envPath) ? readFileSync(envPath, 'utf8') : undefined;
588
+ const previousLogin = { user: currentUser, password: env.get('POSTGRES_PASSWORD') ?? '' };
589
+ const role = await ensureApplicationRole({
590
+ env,
591
+ recordedEnv: env,
592
+ runCommand: context.runCommand,
593
+ onLine: (line) => context.journal.line(line),
594
+ onSecrets: (secrets) => context.journal.addSecrets(secrets),
595
+ // Atomic, 0600, over the file on disk (not the in-memory map, which a
596
+ // drift step may have only half-built) and BEFORE the server's password
597
+ // changes; put back byte for byte if that fails.
598
+ store: {
599
+ write: (credentials) => {
600
+ const values = existsSync(envPath) ? readEnvFile(envPath) : new Map(env);
601
+ values.set('POSTGRES_USER', credentials.user);
602
+ values.set('POSTGRES_PASSWORD', credentials.password);
603
+ writeEnvFile(envPath, values, specs);
604
+ },
605
+ restore: () => {
606
+ if (previousContents !== undefined)
607
+ writeEnvContents(envPath, previousContents);
608
+ },
609
+ },
610
+ // An unattended update must not start failing on a deployment that
611
+ // predates this: not consented, and anything wrong before the server
612
+ // changed, is a loud warning; install is where it is a refusal.
613
+ whenNotConsented: 'warn',
614
+ ...roleOptionsFrom(context.options, admin),
615
+ });
616
+ context.journal.line(`Database role: ${role.outcome}: ${role.detail}`);
617
+ if (role.outcome === 'superuser-allowed') {
618
+ warn(`warning: --allow-superuser: ${superuserConsequence(currentUser ?? 'the database login')}`);
619
+ recordSuperuser(context, currentUser, currentUser);
620
+ return;
621
+ }
622
+ if (role.outcome === 'declined') {
623
+ context.hooks?.onProgress?.(`warning: ${role.detail}`);
624
+ return;
625
+ }
626
+ // An ordinary login (it already was one, or it is now) means any recorded
627
+ // --allow-superuser no longer applies. Anything that could not tell leaves it.
628
+ if (role.outcome !== 'unknown')
629
+ recordSuperuser(context, undefined, undefined);
630
+ if (role.credentials === undefined)
631
+ return;
632
+ const credentials = role.credentials;
633
+ context.env = readEnvFile(envPath);
634
+ context.appCredentials = credentials;
635
+ context.hooks?.onProgress?.(`${role.outcome === 'rotated' ? 'Rotated' : 'Moved the deployment onto'} database role "${credentials.user}"; the generated password is saved to .env only.`);
636
+ // A moved revision restarts the stack further on, with this .env. An
637
+ // unchanged one restarts nothing, so the api is recreated here and
638
+ // proved up: it must not be left running on the old login or dead on the new.
639
+ if (context.unchanged === true) {
640
+ await compose(context, [...RECREATE_API], { timeoutMs: 5 * 60_000 });
641
+ const probe = await waitForHealthy({
642
+ runCommand: context.runCommand,
643
+ deployRoot: context.options.deployRoot,
644
+ bindPort: context.state.bindPort,
645
+ composeProject: composeProjectFor(context.state),
646
+ ...(context.options.healthWaitMs === undefined
647
+ ? {}
648
+ : { waitMs: context.options.healthWaitMs, intervalMs: Math.min(50, context.options.healthWaitMs) }),
649
+ ...(context.hooks === undefined ? {} : { hooks: context.hooks }),
650
+ });
651
+ if (!probe.ok) {
652
+ const why = `The API did not become ready on database role "${credentials.user}": ${probe.error ?? `HTTP ${probe.status ?? '?'}`}.`;
653
+ // The previous login can be returned to only if it still opens the
654
+ // database: the old administrator does; a rotated password does not.
655
+ const settings = databaseSettings(env);
656
+ const previousWorks = settings !== undefined &&
657
+ previousContents !== undefined &&
658
+ previousLogin.user !== undefined &&
659
+ previousLogin.user !== credentials.user &&
660
+ (await runPsql(context.runCommand, { ...settings, ...previousLogin, user: previousLogin.user }, 'postgres', 'select 1')).ok;
661
+ if (previousWorks && previousContents !== undefined) {
662
+ writeEnvContents(envPath, previousContents);
663
+ context.env = parseEnvFile(previousContents);
664
+ await compose(context, [...RECREATE_API], { timeoutMs: 5 * 60_000 }).catch(() => undefined);
665
+ throw new Error(`${why} .env was put back to the previous login "${previousLogin.user}", which still works, and the api was restarted on it. ` +
666
+ `The role "${credentials.user}" exists and owns the database; check the API logs (pg_hba.conf from the container network is the usual cause) and re-run.`);
667
+ }
668
+ throw new Error(`${why} .env now holds the login "${credentials.user}" with its NEW password` +
669
+ (previousLogin.user === credentials.user
670
+ ? ' (the previous password no longer works)'
671
+ : ' (the previous login could not be used again)') +
672
+ '. Check the API logs (pg_hba.conf from the container network is the usual cause); nothing else was changed.');
673
+ }
674
+ }
675
+ },
676
+ },
677
+ {
678
+ id: 'ensure-database',
679
+ title: 'Make sure the database exists',
680
+ skip: skipWhenUnchanged,
681
+ async run(context) {
682
+ // #391: the same gate install uses. A database that vanished (a
683
+ // restore gone wrong, a renamed POSTGRES_DB) is otherwise found by the
684
+ // migration, with the api container already stopped. #396: the same
685
+ // FUNCTION, too -- offer, create, re-verify -- so the two cannot drift.
686
+ const env = context.env;
687
+ if (env === undefined) {
688
+ context.journal.line('No environment file; nothing to check.');
689
+ return;
690
+ }
691
+ const result = await ensureDatabase({
692
+ env,
693
+ runCommand: context.runCommand,
694
+ createDatabase: context.options.createDatabase,
695
+ ...(context.options.allowSuperuser === true || superuserAllowedFor(context.state, env.get('POSTGRES_USER'))
696
+ ? { allowSuperuser: true }
697
+ : {}),
698
+ ...consentOptions(context),
699
+ envPath: envFilePath(context.options.deployRoot),
700
+ onLine: (line) => context.journal.line(line),
701
+ });
702
+ context.journal.line(result.detail);
703
+ if (result.outcome === 'created')
704
+ context.hooks?.onProgress?.(result.detail);
705
+ },
706
+ },
707
+ {
708
+ id: 'version',
709
+ title: 'Choose the release version',
710
+ // ⚠ `skipWhenUnchanged` FIRST, and it is load-bearing. An update that
711
+ // finds the remote has not moved rebuilds nothing -- so bumping the
712
+ // version here would commit and push a release for code nobody changed,
713
+ // then find the remote HAS moved next time and do it again: a bump
714
+ // treadmill driven entirely by its own commits. A version belongs to a
715
+ // deploy that actually deployed something.
716
+ // ⚠ `skipWhenUnchanged` ONLY, and it is load-bearing. An update that
717
+ // finds the remote has not moved rebuilds nothing -- so bumping here
718
+ // would commit and push a release for code nobody changed, then find the
719
+ // remote HAS moved next time and do it again: a bump treadmill driven
720
+ // entirely by its own commits. `--no-version-bump` is handled INSIDE the
721
+ // step instead, because it still stamps the current version.
722
+ skip: skipWhenUnchanged,
723
+ async run(context) {
724
+ // ⚠ IMMEDIATELY BEFORE `build`, AND IT COMMITS. The checkout step
725
+ // refuses a dirty tree, so leaving manifests dirty across a
726
+ // four-minute build would wedge the NEXT update behind a refusal about
727
+ // files the operator never touched. See version-step.ts's header.
728
+ const result = await runVersionStep({
729
+ checkoutPath: checkoutPathFor(context.options.deployRoot),
730
+ ...(context.options.appVersion === undefined
731
+ ? {}
732
+ : { requested: context.options.appVersion }),
733
+ ...(context.options.noVersionBump === undefined
734
+ ? {}
735
+ : { disabled: context.options.noVersionBump }),
736
+ runCommand: context.runCommand,
737
+ });
738
+ context.version = result;
739
+ context.journal.line(`Version: ${result.detail}`);
740
+ // ⚠ The DEPLOYED COMMIT IS THE BUMP COMMIT. Recording the pre-bump one
741
+ // leaves every server reporting itself a commit behind for ever,
742
+ // rebuilding identical code and bumping again on every update. It is
743
+ // also more accurate: the commit happens before `build`, so the images
744
+ // really were built with HEAD here.
745
+ if (result.commitSha !== undefined)
746
+ context.commitSha = result.commitSha;
747
+ // ⚠ STAMPED ON DISK, NOT JUST IN MEMORY. `context.env` is the wizard's
748
+ // map and nothing writes it again after the `environment` step, so an
749
+ // in-memory set alone would leave the running container on whatever
750
+ // APP_VERSION the last deploy wrote. The disk write is what the build
751
+ // and the api container actually read.
752
+ const stamped = stampAppVersion(envFilePath(context.options.deployRoot), join(composeCwd(context.options.deployRoot), '.env.example'), result.version);
753
+ context.env?.set('APP_VERSION', result.version);
754
+ if (!stamped) {
755
+ context.journal.line('APP_VERSION was not stamped: no .env on disk yet.');
756
+ }
757
+ },
758
+ },
759
+ {
760
+ id: 'maintenance-on',
761
+ title: 'Enter maintenance mode',
762
+ skip: (context) => skipWhenUnchanged(context) ??
763
+ (context.options.maintenance === true
764
+ ? undefined
765
+ : 'not requested; pass --maintenance to use it'),
766
+ async run(context) {
767
+ await enableMaintenanceMode(context);
768
+ },
769
+ },
770
+ {
771
+ id: 'build',
772
+ title: 'Build images',
773
+ skip: skipWhenUnchanged,
774
+ async run(context) {
775
+ await compose(context, [
776
+ 'build',
777
+ ...(context.options.noCache === true ? ['--no-cache'] : []),
778
+ ]);
779
+ },
780
+ },
781
+ {
782
+ id: 'migrate',
783
+ title: 'Apply migrations',
784
+ skip: skipWhenUnchanged,
785
+ async run(context) {
786
+ // The api container is stopped first so two instances cannot race the
787
+ // same migration, and brought back if the migration fails - leaving a
788
+ // working deployment down because a migration failed would turn a
789
+ // failed update into an outage.
790
+ await compose(context, ['stop', 'api'], { timeoutMs: 5 * 60_000 });
791
+ try {
792
+ await compose(context, ['run', '--rm', '--no-deps', 'api', 'npm', 'run', 'prisma:migrate'], { timeoutMs: 10 * 60_000 });
793
+ }
794
+ catch (error) {
795
+ await compose(context, ['start', 'api'], { timeoutMs: 5 * 60_000 }).catch(() => undefined);
796
+ throw error;
797
+ }
798
+ },
799
+ },
800
+ {
801
+ id: 'seed',
802
+ title: 'Refresh roles and permissions',
803
+ skip: (context) => skipWhenUnchanged(context) ??
804
+ (context.options.skipSeed === true ? 'skipped with --skip-seed' : undefined),
805
+ async run(context) {
806
+ // Idempotent, and the only way new permissions reach an existing
807
+ // deployment. See the header.
808
+ await compose(context, ['run', '--rm', '--no-deps', 'api', 'npm', 'run', 'prisma:seed'], { timeoutMs: 10 * 60_000 });
809
+ },
810
+ },
811
+ {
812
+ id: 'restart',
813
+ title: 'Restart the stack',
814
+ skip: skipWhenUnchanged,
815
+ async run(context) {
816
+ await compose(context, ['up', '-d']);
817
+ // nginx caches the api container's address, and a rebuilt container
818
+ // gets a new one, so a stale resolution outlives the update.
819
+ //
820
+ // ⚠ RECREATED, NOT RESTARTED. nginx.conf and csp.conf are
821
+ // SINGLE-FILE bind mounts, and git replaces a file's inode rather than
822
+ // editing it: `restart` keeps the old container and the old inode, so
823
+ // a config change in the release never reached the running site.
824
+ // Recreating re-binds the mounts as well as re-resolving the api.
825
+ await compose(context, [...RECREATE_NGINX], { timeoutMs: 5 * 60_000 });
826
+ },
827
+ },
828
+ {
829
+ id: 'maintenance-off',
830
+ title: 'Exit maintenance mode',
831
+ // ⚠ NO GATE ON `--maintenance`, unlike `maintenance-on`. This also
832
+ // self-heals a window a PREVIOUS run's `maintenance-on` set and never
833
+ // got to clear (a failure in `build`/`migrate`/`seed` before this step
834
+ // runs) -- the next update, flag or no flag, finds the leftover key and
835
+ // clears it, rather than leaving the deployment stuck until someone
836
+ // notices by hand.
837
+ skip: skipWhenUnchanged,
838
+ async run(context) {
839
+ await disableMaintenanceMode(context);
840
+ },
841
+ },
842
+ {
843
+ id: 'edge-config',
844
+ title: 'Check the nginx config is current',
845
+ // ⚠ NO `skipWhenUnchanged`, and that is the point of this step. Every
846
+ // other step after `fetch` stands down when the checkout has not
847
+ // moved -- so a checkout updated BY HAND (a `git pull` over SSH, a
848
+ // previous run that failed after `fetch`) would otherwise never get its
849
+ // nginx config applied: each later run finds "nothing to do". This asks
850
+ // the running container directly, which costs one `exec` when all is
851
+ // well.
852
+ //
853
+ // AFTER `restart` so a changed run checks what the recreate just did,
854
+ // and BEFORE `health` because the health probe goes through this nginx:
855
+ // a stale edge config is the stack's problem, not the API's, and should
856
+ // be named as such.
857
+ async run(context) {
858
+ const project = composeProjectFor(context.state);
859
+ await reconcileEdgeConfig({
860
+ checkoutPath: checkoutPathFor(context.options.deployRoot),
861
+ readRunning: () => readRunningEdgeConfig(context),
862
+ recreate: async () => {
863
+ await compose(context, [...RECREATE_NGINX], { timeoutMs: 5 * 60_000 });
864
+ },
865
+ manualCommand: `cd ${composeCwd(context.options.deployRoot)} && ` +
866
+ composeArgv([...RECREATE_NGINX], project, groupsOf(context), composeCwd(context.options.deployRoot)).join(' '),
867
+ line: (text) => context.journal.line(text),
868
+ notice: (text) => context.hooks?.onProgress?.(text),
869
+ });
870
+ },
871
+ },
872
+ {
873
+ id: 'health',
874
+ title: 'Wait for the API',
875
+ skip: skipWhenUnchanged,
876
+ async run(context) {
877
+ const probe = await waitForHealthy({
878
+ runCommand: context.runCommand,
879
+ deployRoot: context.options.deployRoot,
880
+ bindPort: context.state.bindPort,
881
+ ...(composeProjectFor(context.state) === undefined
882
+ ? {}
883
+ : { composeProject: composeProjectFor(context.state) }),
884
+ ...(context.hooks === undefined ? {} : { hooks: context.hooks }),
885
+ });
886
+ if (!probe.ok) {
887
+ throw new Error(`The API did not become ready: ${probe.error ?? `HTTP ${probe.status ?? '?'}`}`);
888
+ }
889
+ },
890
+ },
891
+ {
892
+ id: 'deploy-info',
893
+ title: 'Record what was deployed',
894
+ async run(context) {
895
+ // ⚠ IMMEDIATELY AFTER `health`, NOT AT THE END. If the API is
896
+ // answering, the application demonstrably IS deployed and the About
897
+ // page should say so. Written at the end, a failure in `publish` --
898
+ // which runs between here and there -- would leave that page reporting
899
+ // nothing at all about a deployment that is up and serving, which is
900
+ // exactly when somebody is looking at it.
901
+ //
902
+ // ⚠ AND REWRITTEN AT THE END of a successful update (see `runUpdate`),
903
+ // the only point at which this run's history entry and a freshly read
904
+ // certificate expiry exist.
905
+ await hostFactsOf(context);
906
+ const result = writeDeployInfo(context.options.deployRoot, updateDeployInfo(context, new Date().toISOString()));
907
+ // ⚠ BOOKKEEPING, NOT THE DEPLOYMENT. By this point the stack is up and
908
+ // answering; a file this CLI could not write is a warning, never a
909
+ // failure that undoes a successful deploy.
910
+ context.journal.line(result.written
911
+ ? `Wrote ${result.path}`
912
+ : `warning: could not write ${result.path}: ${result.error ?? 'unknown'}`);
913
+ if (!result.written) {
914
+ context.hooks?.onProgress?.(`warning: deployment record not written (${result.error ?? 'unknown'})`);
915
+ }
916
+ },
917
+ },
918
+ {
919
+ id: 'publish',
920
+ title: 'Refresh the vhost and certificate',
921
+ skip: (context) => {
922
+ if (context.unchanged === true)
923
+ return 'already up to date';
924
+ if (context.options.skipProxy === true)
925
+ return 'skipped with --skip-proxy';
926
+ if (context.state.domain === undefined)
927
+ return 'this deployment is not published';
928
+ return undefined;
929
+ },
930
+ async run(context) {
931
+ const runtime = await proxyRuntimeOf(context);
932
+ const target = {
933
+ domain: context.state.domain,
934
+ bindPort: context.state.bindPort,
935
+ // From the record, not reconstructed. Deriving it as
936
+ // `<deployRoot>/../../proxy` silently ignored a non-default
937
+ // --proxy-root given at install time, and wrote the vhost somewhere
938
+ // the proxy does not read.
939
+ proxyRoot: proxyRootFor(context),
940
+ };
941
+ const status = certificateStatus(target);
942
+ if (!status.exists) {
943
+ const email = context.env?.get('INITIAL_ADMIN_EMAIL') ?? '';
944
+ if (email !== '') {
945
+ await issueCertificate(target, {
946
+ runCommand: context.runCommand,
947
+ runtime,
948
+ email,
949
+ ...(context.hooks === undefined ? {} : { hooks: context.hooks }),
950
+ });
951
+ }
952
+ }
953
+ // Rewritten and re-validated so a change to the template reaches an
954
+ // existing deployment; identical content is a no-op with no reload.
955
+ //
956
+ // ⚠ `maxBodyBytes` must be passed here exactly as install passes it.
957
+ // Omitting it does not leave the existing value alone -- the vhost is
958
+ // RE-RENDERED from scratch, so a missing option silently reverts
959
+ // `client_max_body_size` to the 100m default and every upload larger
960
+ // than that starts failing with a 413 after an unrelated update.
961
+ await installVhost(target, {
962
+ runCommand: context.runCommand,
963
+ runtime,
964
+ ...(context.hooks === undefined ? {} : { hooks: context.hooks }),
965
+ ...(context.env?.get('MAX_FILE_SIZE') === undefined
966
+ ? {}
967
+ : { maxBodyBytes: Number(context.env.get('MAX_FILE_SIZE')) }),
968
+ });
969
+ },
970
+ },
971
+ {
972
+ id: 'renewal',
973
+ title: 'Schedule certificate renewal',
974
+ skip: (context) => {
975
+ if (context.unchanged === true)
976
+ return 'already up to date';
977
+ if (context.options.skipRenewal === true)
978
+ return 'skipped with --skip-renewal';
979
+ if (context.options.skipProxy === true)
980
+ return 'skipped with --skip-proxy';
981
+ if (context.state.domain === undefined)
982
+ return 'this deployment is not published';
983
+ return undefined;
984
+ },
985
+ async run(context) {
986
+ const proxyRoot = proxyRootFor(context);
987
+ const status = certificateStatus({
988
+ domain: context.state.domain,
989
+ bindPort: context.state.bindPort,
990
+ proxyRoot,
991
+ });
992
+ if (!status.exists) {
993
+ context.journal.line(`No certificate at ${status.path}; nothing to renew yet.`);
994
+ return;
995
+ }
996
+ await scheduleRenewal(context, proxyRoot, await proxyRuntimeOf(context));
997
+ },
998
+ },
999
+ {
1000
+ id: 'verify',
1001
+ title: 'Verify the deployment',
1002
+ skip: skipWhenUnchanged,
1003
+ async run(context) {
1004
+ const report = await collectHealth({
1005
+ runCommand: context.runCommand,
1006
+ deployRoot: context.options.deployRoot,
1007
+ bindPort: context.state.bindPort,
1008
+ ...(composeProjectFor(context.state) === undefined
1009
+ ? {}
1010
+ : { composeProject: composeProjectFor(context.state) }),
1011
+ ...(context.state.domain === undefined || context.options.skipProxy === true
1012
+ ? {}
1013
+ : { domain: context.state.domain }),
1014
+ ...(context.options.fetch === undefined ? {} : { fetch: context.options.fetch }),
1015
+ ...oauthSmokeTarget(context.options.skipOAuthCheck, context.env),
1016
+ groups: groupsOf(context),
1017
+ });
1018
+ if (!isHealthy(report)) {
1019
+ // See install.ts's equivalent comment (#640, #642): the external
1020
+ // HTTPS probe can fail because the proxy is serving a different
1021
+ // certificate than the one on disk, which `deploy certs` is the
1022
+ // command that actually diagnoses.
1023
+ const certHint = report.external !== undefined && !report.external.probe.ok
1024
+ ? ` If the domain shows a certificate/SSL error in a browser, run \`${cliName()} deploy certs --domain ${context.state.domain}\` to check whether the proxy needs reloading.`
1025
+ : '';
1026
+ throw new Error(`The stack restarted but is not healthy. Run \`${cliName()} deploy status\` for the detail.${certHint}`);
1027
+ }
1028
+ reportOAuthSmoke(context, report.oauth);
1029
+ },
1030
+ },
1031
+ {
1032
+ id: 'publish-version',
1033
+ title: 'Publish the release version',
1034
+ // Keyed on what the `version` step actually did, so every reason it did
1035
+ // not bump -- unchanged remote, --no-version-bump, a version already
1036
+ // ahead -- lands here as one condition rather than three.
1037
+ skip: (context) => context.version?.bumped === true ? undefined : 'no version was bumped',
1038
+ async run(context) {
1039
+ // ⚠ PUSH LAST, AFTER VERIFY -- not at the health gate. Pushing to a
1040
+ // shared repository is irreversible and externally visible: a version
1041
+ // not pushed is re-derived next run, while a version pushed for a
1042
+ // deploy that did not finish is a commit someone has to reason about.
1043
+ const result = await publishVersion({
1044
+ checkoutPath: checkoutPathFor(context.options.deployRoot),
1045
+ ref: context.target?.ref ?? context.state?.ref ?? 'main',
1046
+ result: context.version,
1047
+ runCommand: context.runCommand,
1048
+ });
1049
+ // ⚠ A FAILED PUSH IS A WARNING, NEVER A FAILURE. By this point the app
1050
+ // is built, migrated, started, answering and verified. The rollback
1051
+ // keeps the clone level with origin; the deployment keeps the version.
1052
+ context.journal.line(`Publish: ${result.detail}`);
1053
+ if (!result.pushed)
1054
+ context.hooks?.onProgress?.(`warning: ${result.detail}`);
1055
+ },
1056
+ },
1057
+ ];
1058
+ }
1059
+ /**
1060
+ * The recorded state, or one rebuilt from the deployment itself.
1061
+ *
1062
+ * ⚠ An UNREADABLE state file is not an unrecorded deployment: the file is
1063
+ * there and this build cannot interpret it, which is a different problem
1064
+ * deserving a different message. `readState` throws in that case, and this
1065
+ * function deliberately does not catch it.
1066
+ */
1067
+ async function resolveStateForUpdate(options) {
1068
+ const recorded = readState(options.deployRoot);
1069
+ if (recorded !== undefined)
1070
+ return recorded;
1071
+ const evidence = describeEvidence(options.deployRoot);
1072
+ if (!evidence.isDeployment) {
1073
+ // Genuinely nothing here. Name which half is missing rather than asserting
1074
+ // a bare negative the operator cannot act on.
1075
+ const missing = [
1076
+ evidence.hasCheckout ? undefined : 'a checkout at repo/',
1077
+ evidence.hasEnv ? undefined : 'a readable environment file',
1078
+ ].filter((part) => part !== undefined);
1079
+ throw new NotInstalledError(`No deployment found at ${options.deployRoot}: it is missing ${missing.join(' and ')}. ` +
1080
+ `Run \`${cliName()} deploy install\` first, or pass --root if it is somewhere else.`);
1081
+ }
1082
+ // The clone's own origin is the only honest source for these; the CLI must
1083
+ // never name a repository of its own.
1084
+ const target = await resolveRepoTarget({
1085
+ ...(options.ref === undefined ? {} : { refFlag: options.ref }),
1086
+ cwd: join(options.deployRoot, 'repo'),
1087
+ runCommand: options.runCommand ?? defaultRunCommand,
1088
+ });
1089
+ return adoptDeployment({
1090
+ deployRoot: options.deployRoot,
1091
+ repoUrl: target.url,
1092
+ ref: target.ref,
1093
+ // Left empty on purpose: the `fetch` step resolves the real HEAD, and a
1094
+ // guess here would be recorded as the deployed commit.
1095
+ commitSha: '',
1096
+ fallbackBindPort: DEFAULT_ADOPTED_BIND_PORT,
1097
+ });
1098
+ }
1099
+ /** Only used when an adopted `.env` names no APP_BIND_PORT. */
1100
+ const DEFAULT_ADOPTED_BIND_PORT = 3535;
1101
+ export async function runUpdate(options) {
1102
+ // The precondition install does not have, and the reason this is its own
1103
+ // command: nothing to update is a different situation from nothing installed.
1104
+ //
1105
+ // But "nothing to update" is a question about the DEPLOYMENT, not about the
1106
+ // CLI's bookkeeping. Asking the second refused to update a live, serving
1107
+ // deployment because a JSON file was missing -- telling the operator there
1108
+ // was no deployment while they stood in one, and pointing them at `install`,
1109
+ // whose precondition is the opposite. Where the record is missing and the
1110
+ // evidence is there, ADOPT.
1111
+ const state = await resolveStateForUpdate(options);
1112
+ const startedAt = Date.now();
1113
+ const path = envFilePath(options.deployRoot);
1114
+ const journal = openJournal({
1115
+ deployRoot: options.deployRoot,
1116
+ command: 'update',
1117
+ secrets: existsSync(path) ? secretsFrom(parseEnvFile(readFileSync(path, 'utf8'))) : [],
1118
+ });
1119
+ // Announced at once, so a screen can show where the log is while it runs.
1120
+ options.hooks?.onJournal?.(journal.path);
1121
+ const context = {
1122
+ options,
1123
+ runCommand: options.runCommand ?? defaultRunCommand,
1124
+ journal,
1125
+ hooks: options.hooks,
1126
+ completed: new Set(),
1127
+ // Appended by `runPipeline` as each step finishes; read by `deploy-info`.
1128
+ progress: [],
1129
+ state,
1130
+ ...(existsSync(path) ? { env: parseEnvFile(readFileSync(path, 'utf8')) } : {}),
1131
+ };
1132
+ // The app's steps (`registerDeployStep`, #715) go in after the built-in
1133
+ // step each one names; they see a narrow context, never this one.
1134
+ const steps = withRegisteredSteps('update', buildUpdateSteps(), (step) => appStepContext('update', step, () => environmentOfUpdate(step)));
1135
+ const result = await runPipeline(steps, context);
1136
+ if (result.failed !== undefined) {
1137
+ journal.finish('failure', `${result.failed.id}: ${result.failed.detail ?? ''}`);
1138
+ const previous = context.previousSha ?? state.commitSha;
1139
+ throw new Error(`${result.failed.title} failed: ${result.failed.detail ?? 'unknown error'}\n` +
1140
+ `The full log is at ${journal.path}\n` +
1141
+ // An honest manual recovery path. A partially-applied migration cannot
1142
+ // be undone by checking out the old code, so this does not pretend to.
1143
+ `To go back to the previous revision: ${cliName()} deploy update --ref ${previous} --force`);
1144
+ }
1145
+ if (context.unchanged === true) {
1146
+ journal.finish('success', 'already up to date');
1147
+ return {
1148
+ changed: false,
1149
+ commitSha: context.commitSha ?? state.commitSha,
1150
+ journalPath: journal.path,
1151
+ durationMs: Date.now() - startedAt,
1152
+ ...shownCredentials(options, context),
1153
+ };
1154
+ }
1155
+ // ⚠ ONLY THIS PATH APPENDS HISTORY: a failed update throws above, and an
1156
+ // unchanged one deployed nothing, so both leave the prior list untouched.
1157
+ const now = new Date().toISOString();
1158
+ const host = await hostFactsOf(context);
1159
+ const runtime = currentRuntime(context);
1160
+ const proxy = await observeProxy({
1161
+ domain: state.domain,
1162
+ bindPort: state.bindPort,
1163
+ proxyRoot: proxyRootFor(context),
1164
+ mode: runtime.mode,
1165
+ container: runtime.container,
1166
+ runCommand: context.runCommand,
1167
+ });
1168
+ const history = appendHistory(state.history, {
1169
+ at: now,
1170
+ command: 'update',
1171
+ commitSha: (context.commitSha ?? state.commitSha) || null,
1172
+ previousCommitSha: (context.previousSha ?? state.commitSha) || null,
1173
+ ref: context.target?.ref ?? state.ref ?? null,
1174
+ durationMs: Date.now() - startedAt,
1175
+ cliVersion: cliVersion(),
1176
+ outcome: 'success',
1177
+ });
1178
+ writeState({
1179
+ // `context.state`, not `state`: a step may have recorded something on it
1180
+ // (`database-role` records --allow-superuser, #980).
1181
+ ...context.state,
1182
+ ref: context.target?.ref ?? state.ref,
1183
+ commitSha: context.commitSha ?? state.commitSha,
1184
+ previousSha: context.previousSha,
1185
+ lastDeployedAt: now,
1186
+ lastCommand: 'update',
1187
+ appctlVersion: cliVersion(),
1188
+ // The groups this run acted under: an explicit --group set replaces the
1189
+ // recorded one, and the always-on groups are added either way (#567). The
1190
+ // stack was just brought up with THOSE compose files, so `status`, the
1191
+ // next `update` and `uninstall` must name the same ones.
1192
+ groups: [...groupsOf(context)],
1193
+ // Only when `publish` ran: an update that did not touch the proxy has
1194
+ // learned nothing new about it, and keeps what was recorded.
1195
+ ...(context.proxyRuntime === undefined
1196
+ ? {}
1197
+ : { proxyMode: context.proxyRuntime.mode, proxyContainer: context.proxyRuntime.container }),
1198
+ host,
1199
+ history,
1200
+ proxy,
1201
+ });
1202
+ // The end-of-run rewrite of info.json; see install.ts's for why.
1203
+ const info = writeDeployInfo(options.deployRoot, {
1204
+ ...updateDeployInfo(context, now),
1205
+ proxy: proxyInfoOf(proxy),
1206
+ host,
1207
+ history,
1208
+ });
1209
+ journal.line(info.written
1210
+ ? `Wrote ${info.path}`
1211
+ : `warning: could not write ${info.path}: ${info.error ?? 'unknown'}`);
1212
+ journal.finish('success');
1213
+ return {
1214
+ changed: true,
1215
+ ...(context.previousSha === undefined ? {} : { previousSha: context.previousSha }),
1216
+ commitSha: context.commitSha ?? state.commitSha,
1217
+ journalPath: journal.path,
1218
+ durationMs: Date.now() - startedAt,
1219
+ ...shownCredentials(options, context),
1220
+ };
1221
+ }
1222
+ /** The credentials a run provisioned, when -- and only when -- `--show-credentials` asked. */
1223
+ function shownCredentials(options, context) {
1224
+ return options.showCredentials === true && context.appCredentials !== undefined
1225
+ ? { credentials: context.appCredentials }
1226
+ : {};
1227
+ }
1228
+ //# sourceMappingURL=update.js.map