@antelopejs/dms-antelope-cloud 0.0.0 → 0.1.0

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 (224) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +448 -0
  3. package/dist/cloud-status.d.ts +13 -0
  4. package/dist/cloud-status.js +77 -0
  5. package/dist/config.d.ts +84 -0
  6. package/dist/config.js +104 -0
  7. package/dist/configured.d.ts +16 -0
  8. package/dist/configured.js +26 -0
  9. package/dist/connection/actions.d.ts +40 -0
  10. package/dist/connection/actions.js +120 -0
  11. package/dist/connection/announce.d.ts +8 -0
  12. package/dist/connection/announce.js +20 -0
  13. package/dist/connection/cloud.d.ts +60 -0
  14. package/dist/connection/cloud.js +87 -0
  15. package/dist/connection/content.d.ts +70 -0
  16. package/dist/connection/content.js +462 -0
  17. package/dist/connection/current.d.ts +26 -0
  18. package/dist/connection/current.js +28 -0
  19. package/dist/connection/device-flow.d.ts +16 -0
  20. package/dist/connection/device-flow.js +146 -0
  21. package/dist/connection/refusals.d.ts +51 -0
  22. package/dist/connection/refusals.js +85 -0
  23. package/dist/connection/repository.d.ts +28 -0
  24. package/dist/connection/repository.js +69 -0
  25. package/dist/connection/seal.d.ts +22 -0
  26. package/dist/connection/seal.js +47 -0
  27. package/dist/connection/store.d.ts +294 -0
  28. package/dist/connection/store.js +165 -0
  29. package/dist/connection/view.d.ts +39 -0
  30. package/dist/connection/view.js +39 -0
  31. package/dist/dashboard/actions.d.ts +40 -0
  32. package/dist/dashboard/actions.js +115 -0
  33. package/dist/dashboard/dockerfile.d.ts +34 -0
  34. package/dist/dashboard/dockerfile.js +71 -0
  35. package/dist/dashboard/service.d.ts +61 -0
  36. package/dist/dashboard/service.js +137 -0
  37. package/dist/dashboard/variables.d.ts +30 -0
  38. package/dist/dashboard/variables.js +34 -0
  39. package/dist/deployments/build-log.d.ts +39 -0
  40. package/dist/deployments/build-log.js +57 -0
  41. package/dist/deployments/cloud-steps.d.ts +77 -0
  42. package/dist/deployments/cloud-steps.js +132 -0
  43. package/dist/deployments/content.d.ts +61 -0
  44. package/dist/deployments/content.js +268 -0
  45. package/dist/deployments/deployment.d.ts +96 -0
  46. package/dist/deployments/deployment.js +3 -0
  47. package/dist/deployments/follow.d.ts +18 -0
  48. package/dist/deployments/follow.js +112 -0
  49. package/dist/deployments/ledger.d.ts +23 -0
  50. package/dist/deployments/ledger.js +359 -0
  51. package/dist/deployments/lifecycle.d.ts +123 -0
  52. package/dist/deployments/lifecycle.js +146 -0
  53. package/dist/deployments/live.d.ts +28 -0
  54. package/dist/deployments/live.js +54 -0
  55. package/dist/deployments/publish-read.d.ts +20 -0
  56. package/dist/deployments/publish-read.js +24 -0
  57. package/dist/deployments/refusals.d.ts +13 -0
  58. package/dist/deployments/refusals.js +35 -0
  59. package/dist/environments/actions.d.ts +86 -0
  60. package/dist/environments/actions.js +210 -0
  61. package/dist/environments/address.d.ts +60 -0
  62. package/dist/environments/address.js +149 -0
  63. package/dist/environments/content.d.ts +97 -0
  64. package/dist/environments/content.js +275 -0
  65. package/dist/environments/follower.d.ts +32 -0
  66. package/dist/environments/follower.js +114 -0
  67. package/dist/environments/pipeline.d.ts +58 -0
  68. package/dist/environments/pipeline.js +76 -0
  69. package/dist/environments/publish-targets.d.ts +18 -0
  70. package/dist/environments/publish-targets.js +55 -0
  71. package/dist/environments/roles.d.ts +73 -0
  72. package/dist/environments/roles.js +97 -0
  73. package/dist/frontend-module.d.ts +12 -0
  74. package/dist/frontend-module.js +25 -0
  75. package/dist/git/changed-files.d.ts +30 -0
  76. package/dist/git/changed-files.js +107 -0
  77. package/dist/git/changes.d.ts +89 -0
  78. package/dist/git/changes.js +162 -0
  79. package/dist/git/command.d.ts +51 -0
  80. package/dist/git/command.js +231 -0
  81. package/dist/git/promotion.d.ts +23 -0
  82. package/dist/git/promotion.js +46 -0
  83. package/dist/git/publish-input.d.ts +42 -0
  84. package/dist/git/publish-input.js +62 -0
  85. package/dist/git/publish-job.d.ts +82 -0
  86. package/dist/git/publish-job.js +99 -0
  87. package/dist/git/publish-steps.d.ts +90 -0
  88. package/dist/git/publish-steps.js +205 -0
  89. package/dist/git/publisher.d.ts +23 -0
  90. package/dist/git/publisher.js +206 -0
  91. package/dist/git/refs.d.ts +99 -0
  92. package/dist/git/refs.js +178 -0
  93. package/dist/git/refusal.d.ts +49 -0
  94. package/dist/git/refusal.js +70 -0
  95. package/dist/git/repository.d.ts +101 -0
  96. package/dist/git/repository.js +273 -0
  97. package/dist/git/versions.d.ts +99 -0
  98. package/dist/git/versions.js +174 -0
  99. package/dist/git/write-lock.d.ts +19 -0
  100. package/dist/git/write-lock.js +49 -0
  101. package/dist/index.d.ts +5 -0
  102. package/dist/index.js +59 -0
  103. package/dist/lifecycle.d.ts +8 -0
  104. package/dist/lifecycle.js +78 -0
  105. package/dist/logs/relay.d.ts +25 -0
  106. package/dist/logs/relay.js +138 -0
  107. package/dist/null-prototype.d.ts +7 -0
  108. package/dist/null-prototype.js +3 -0
  109. package/dist/overview/content.d.ts +40 -0
  110. package/dist/overview/content.js +172 -0
  111. package/dist/pages/changes.d.ts +32 -0
  112. package/dist/pages/changes.js +141 -0
  113. package/dist/pages/connection.d.ts +43 -0
  114. package/dist/pages/connection.js +295 -0
  115. package/dist/pages/deployment.d.ts +67 -0
  116. package/dist/pages/deployment.js +261 -0
  117. package/dist/pages/deployments.d.ts +46 -0
  118. package/dist/pages/deployments.js +266 -0
  119. package/dist/pages/environments.d.ts +34 -0
  120. package/dist/pages/environments.js +368 -0
  121. package/dist/pages/logs.d.ts +46 -0
  122. package/dist/pages/logs.js +140 -0
  123. package/dist/pages/navigation.d.ts +61 -0
  124. package/dist/pages/navigation.js +107 -0
  125. package/dist/pages/overview.d.ts +35 -0
  126. package/dist/pages/overview.js +201 -0
  127. package/dist/pages/project-guard.d.ts +32 -0
  128. package/dist/pages/project-guard.js +99 -0
  129. package/dist/pages/query.d.ts +6 -0
  130. package/dist/pages/query.js +14 -0
  131. package/dist/pages/resources.d.ts +37 -0
  132. package/dist/pages/resources.js +211 -0
  133. package/dist/pages/setup.d.ts +40 -0
  134. package/dist/pages/setup.js +271 -0
  135. package/dist/pages/slugs.d.ts +15 -0
  136. package/dist/pages/slugs.js +28 -0
  137. package/dist/pages/variables.d.ts +43 -0
  138. package/dist/pages/variables.js +327 -0
  139. package/dist/pages/version.d.ts +26 -0
  140. package/dist/pages/version.js +214 -0
  141. package/dist/pages/versions.d.ts +20 -0
  142. package/dist/pages/versions.js +115 -0
  143. package/dist/resources/apply.d.ts +15 -0
  144. package/dist/resources/apply.js +127 -0
  145. package/dist/resources/cards.d.ts +41 -0
  146. package/dist/resources/cards.js +211 -0
  147. package/dist/resources/connect.d.ts +66 -0
  148. package/dist/resources/connect.js +78 -0
  149. package/dist/resources/content.d.ts +26 -0
  150. package/dist/resources/content.js +158 -0
  151. package/dist/resources/format.d.ts +10 -0
  152. package/dist/resources/format.js +30 -0
  153. package/dist/resources/guard.d.ts +23 -0
  154. package/dist/resources/guard.js +60 -0
  155. package/dist/resources/modules.d.ts +23 -0
  156. package/dist/resources/modules.js +39 -0
  157. package/dist/resources/plan.d.ts +8 -0
  158. package/dist/resources/plan.js +93 -0
  159. package/dist/resources/read.d.ts +54 -0
  160. package/dist/resources/read.js +69 -0
  161. package/dist/resources/refusals.d.ts +15 -0
  162. package/dist/resources/refusals.js +33 -0
  163. package/dist/resources/routes.d.ts +32 -0
  164. package/dist/resources/routes.js +53 -0
  165. package/dist/setup/actions.d.ts +79 -0
  166. package/dist/setup/actions.js +188 -0
  167. package/dist/setup/apply.d.ts +37 -0
  168. package/dist/setup/apply.js +172 -0
  169. package/dist/setup/content.d.ts +50 -0
  170. package/dist/setup/content.js +440 -0
  171. package/dist/setup/rollout.d.ts +119 -0
  172. package/dist/setup/rollout.js +227 -0
  173. package/dist/setup/steps.d.ts +93 -0
  174. package/dist/setup/steps.js +95 -0
  175. package/dist/setup/storage.d.ts +29 -0
  176. package/dist/setup/storage.js +78 -0
  177. package/dist/setup/store.d.ts +214 -0
  178. package/dist/setup/store.js +174 -0
  179. package/dist/setup/volume.d.ts +31 -0
  180. package/dist/setup/volume.js +52 -0
  181. package/dist/slug.d.ts +7 -0
  182. package/dist/slug.js +26 -0
  183. package/dist/variables/actions.d.ts +76 -0
  184. package/dist/variables/actions.js +185 -0
  185. package/dist/variables/content.d.ts +69 -0
  186. package/dist/variables/content.js +310 -0
  187. package/dist/variables/decide.d.ts +27 -0
  188. package/dist/variables/decide.js +155 -0
  189. package/dist/variables/decided-dialog.d.ts +11 -0
  190. package/dist/variables/decided-dialog.js +129 -0
  191. package/dist/variables/decided.d.ts +80 -0
  192. package/dist/variables/decided.js +240 -0
  193. package/dist/variables/dialogs.d.ts +8 -0
  194. package/dist/variables/dialogs.js +219 -0
  195. package/dist/variables/model.d.ts +106 -0
  196. package/dist/variables/model.js +156 -0
  197. package/dist/variables/project-config.d.ts +117 -0
  198. package/dist/variables/project-config.js +248 -0
  199. package/dist/variables/read.d.ts +33 -0
  200. package/dist/variables/read.js +118 -0
  201. package/dist/web-url.d.ts +9 -0
  202. package/dist/web-url.js +19 -0
  203. package/frontend-vue/app/components/BuildLog.vue +99 -0
  204. package/frontend-vue/app/components/ChangedFiles.vue +165 -0
  205. package/frontend-vue/app/components/DashboardEnvironments.vue +102 -0
  206. package/frontend-vue/app/components/LogLine.vue +33 -0
  207. package/frontend-vue/app/components/LogViewer.vue +314 -0
  208. package/frontend-vue/app/components/PublishChipIcon.vue +39 -0
  209. package/frontend-vue/app/components/PublishForm.vue +505 -0
  210. package/frontend-vue/app/components/PublishPopover.vue +90 -0
  211. package/frontend-vue/app/components/PublishRoute.vue +222 -0
  212. package/frontend-vue/app/composables/usePublishSummary.ts +80 -0
  213. package/frontend-vue/app/plugins/publish-chip.client.ts +44 -0
  214. package/frontend-vue/app/types/publishing.ts +154 -0
  215. package/frontend-vue/app/utils/build-log.ts +96 -0
  216. package/frontend-vue/app/utils/changed-files.ts +142 -0
  217. package/frontend-vue/app/utils/log-line.ts +15 -0
  218. package/frontend-vue/app/utils/log-stream.ts +361 -0
  219. package/frontend-vue/app/utils/publish-state.ts +299 -0
  220. package/frontend-vue/dms.frontend.ts +27 -0
  221. package/frontend-vue/i18n/locales/antelope-cloud-en-GB.json +110 -0
  222. package/frontend-vue/package.json +38 -0
  223. package/frontend-vue/pnpm-lock.yaml +2697 -0
  224. package/package.json +115 -4
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyRollout = applyRollout;
4
+ exports.servicesPlanOf = servicesPlanOf;
5
+ exports.rolloutPlan = rolloutPlan;
6
+ const actions_1 = require("../connection/actions");
7
+ const cloud_1 = require("../connection/cloud");
8
+ const refusals_1 = require("../connection/refusals");
9
+ const dockerfile_1 = require("../dashboard/dockerfile");
10
+ const service_1 = require("../dashboard/service");
11
+ const address_1 = require("../environments/address");
12
+ const pipeline_1 = require("../environments/pipeline");
13
+ const project_config_1 = require("../variables/project-config");
14
+ const storage_1 = require("./storage");
15
+ const volume_1 = require("./volume");
16
+ const ENVIRONMENT_LIMIT = "cloud.errors.limits.environments_per_project";
17
+ const ENVIRONMENT_NAME_TAKEN = "cloud.errors.project.environment_name_taken";
18
+ const PRODUCTION = "production";
19
+ async function applyStage(connection, projectId, name, existing) {
20
+ if (existing.some((environment) => environment.name === name)) {
21
+ return "existing";
22
+ }
23
+ const production = existing.find((environment) => environment.name === PRODUCTION);
24
+ const created = await (0, cloud_1.callCloud)(connection, (api) => api.environments.create(projectId, {
25
+ name,
26
+ branch: (0, pipeline_1.defaultBranch)(name),
27
+ cloneFrom: production?.id ?? null,
28
+ }));
29
+ if (created.kind === "ok")
30
+ return "created";
31
+ if (created.kind === "refused" && created.code === ENVIRONMENT_LIMIT) {
32
+ return "not_on_plan";
33
+ }
34
+ if (created.kind === "refused" && created.code === ENVIRONMENT_NAME_TAKEN) {
35
+ return "existing";
36
+ }
37
+ throw await (0, refusals_1.refuseCloud)(connection._id, created, actions_1.PROJECT_REFUSALS);
38
+ }
39
+ function listEnvironments(connection, projectId) {
40
+ return (0, refusals_1.callOrRefuse)(connection, (api) => api.environments.list(projectId), actions_1.PROJECT_REFUSALS);
41
+ }
42
+ /**
43
+ * Opens each of `names` that `environments` lists without an address: its
44
+ * app gets the port, then its address. One that has an address is reported
45
+ * as it is.
46
+ */
47
+ async function openEnvironments(connection, projectId, port, environments, names) {
48
+ const items = [];
49
+ for (const environment of environments) {
50
+ if (!names.includes(environment.name))
51
+ continue;
52
+ const outcome = await (0, refusals_1.callOrRefuse)(connection, (api) => (0, address_1.openEnvironment)(api, projectId, environment, port), address_1.ADDRESS_REFUSALS);
53
+ const { name } = environment;
54
+ items.push(outcome === "opened"
55
+ ? { step: "address", name, outcome, port }
56
+ : { step: "address", name, outcome });
57
+ }
58
+ return items;
59
+ }
60
+ async function applyEnvironments(connection, projectId, stages, existing) {
61
+ const applied = {
62
+ items: existing.some(({ name }) => name === PRODUCTION)
63
+ ? [{ step: "environment", name: PRODUCTION, outcome: "existing" }]
64
+ : [],
65
+ notOnPlan: [],
66
+ };
67
+ for (const name of stages) {
68
+ const outcome = await applyStage(connection, projectId, name, existing);
69
+ applied.items.push({ step: "environment", name, outcome });
70
+ if (outcome === "not_on_plan")
71
+ applied.notOnPlan.push(name);
72
+ }
73
+ return applied;
74
+ }
75
+ /**
76
+ * Gives each of `names` that `environments` lists its dashboard: created
77
+ * where the environment runs none, opened where it has no address, left as
78
+ * it is otherwise.
79
+ */
80
+ async function applyDashboards(connection, source, environments, names) {
81
+ const items = [];
82
+ for (const environment of environments) {
83
+ if (!names.includes(environment.name))
84
+ continue;
85
+ const outcome = await (0, refusals_1.callOrRefuse)(connection, (api) => (0, service_1.ensureDashboard)(api, source, environment), service_1.DASHBOARD_REFUSALS);
86
+ const { name } = environment;
87
+ items.push({ step: "dashboard", name, outcome, port: source.port });
88
+ }
89
+ return items;
90
+ }
91
+ function storageItem(name, outcome, key) {
92
+ return outcome.kind === "attached" || outcome.kind === "existing"
93
+ ? {
94
+ step: "storage",
95
+ name,
96
+ outcome: outcome.kind,
97
+ mountPath: outcome.mountPath,
98
+ }
99
+ : { step: "storage", name, outcome: outcome.kind, key };
100
+ }
101
+ /**
102
+ * Gives the app of each of `names` that `environments` lists the volume its
103
+ * files go to, unless it has one.
104
+ *
105
+ * @param key The variable that points the files at a folder of it
106
+ */
107
+ async function applyVolumes(connection, projectId, key, environments, names) {
108
+ const items = [];
109
+ for (const environment of environments) {
110
+ if (!names.includes(environment.name))
111
+ continue;
112
+ const outcome = await (0, refusals_1.callOrRefuse)(connection, (api) => (0, volume_1.giveAppVolume)(api, projectId, environment), volume_1.VOLUME_REFUSALS);
113
+ items.push(storageItem(environment.name, outcome, key));
114
+ }
115
+ return items;
116
+ }
117
+ /** The address of the app, its volume, then the dashboard, of each of `names`. */
118
+ async function reachEnvironments(connection, projectId, { port, dashboard, volume }, environments, names) {
119
+ const opened = port === null
120
+ ? []
121
+ : await openEnvironments(connection, projectId, port, environments, names);
122
+ const volumes = volume === null
123
+ ? []
124
+ : await applyVolumes(connection, projectId, volume.key, environments, names);
125
+ const dashboards = dashboard === null
126
+ ? []
127
+ : await applyDashboards(connection, dashboard, environments, names);
128
+ return [...opened, ...volumes, ...dashboards];
129
+ }
130
+ /**
131
+ * What the stages of the plan that exist once it ran still lack: AntelopeJS
132
+ * Cloud copies the services of Production into a stage it creates, their
133
+ * address and the dashboard included, so this reads the environments again
134
+ * only for a plan that has stages, and writes only what a stage lacks.
135
+ */
136
+ async function reachStages(connection, projectId, reach, { items }) {
137
+ const stages = items.flatMap((item) => item.step === "environment" &&
138
+ item.name !== PRODUCTION &&
139
+ item.outcome !== "not_on_plan"
140
+ ? [item.name]
141
+ : []);
142
+ const reachesNothing = reach.port === null && reach.dashboard === null && reach.volume === null;
143
+ if (stages.length === 0 || reachesNothing)
144
+ return [];
145
+ return reachEnvironments(connection, projectId, reach, await listEnvironments(connection, projectId), stages);
146
+ }
147
+ function reachOf(projectId, plan) {
148
+ const { address, dashboard, storage } = plan;
149
+ return {
150
+ port: address?.kind === "public" ? address.port : null,
151
+ volume: storage?.kind === "local_disk" ? { key: storage.key } : null,
152
+ dashboard: dashboard?.build.kind === "public"
153
+ ? {
154
+ projectId,
155
+ repository: dashboard.repository,
156
+ port: dashboard.build.port,
157
+ }
158
+ : null,
159
+ };
160
+ }
161
+ /**
162
+ * Why the plan gave the app no address, created no dashboard, or has no
163
+ * variable to point the app's files at its volume, once for the project.
164
+ */
165
+ function leftAsItIs({ address, dashboard, storage, }) {
166
+ const items = [];
167
+ if (address !== null && address.kind !== "public") {
168
+ items.push({ step: "address", outcome: address.kind });
169
+ }
170
+ if (dashboard?.build.kind === "port_out_of_range") {
171
+ const { kind: outcome, port } = dashboard.build;
172
+ items.push({ step: "dashboard", outcome, port });
173
+ }
174
+ if (storage?.kind === "local_disk" && storage.key === null) {
175
+ items.push({ step: "storage", outcome: "no_variable" });
176
+ }
177
+ return items;
178
+ }
179
+ /**
180
+ * The environments of the plan, their addresses, the app's volume and their
181
+ * dashboard: Production's app is opened on the plan's port first, then gets
182
+ * the volume its files go to when the project keeps them on its disk, then
183
+ * Production gets the dashboard, then each chosen stage is created with the
184
+ * services of Production, their volume declared empty, and a stage still
185
+ * without an address, a volume or a dashboard gets one.
186
+ * With no port to open the apps on, or a dashboard AntelopeJS Cloud cannot
187
+ * run, the rest is done and the reason is reported once; a plan that links a
188
+ * project opens and creates nothing.
189
+ */
190
+ async function applyRollout(connection, projectId, stages, plan) {
191
+ const listed = await listEnvironments(connection, projectId);
192
+ const reach = reachOf(projectId, plan);
193
+ const production = await reachEnvironments(connection, projectId, reach, listed, [PRODUCTION]);
194
+ const applied = await applyEnvironments(connection, projectId, stages, listed);
195
+ const staged = await reachStages(connection, projectId, reach, applied);
196
+ return {
197
+ items: [...production, ...applied.items, ...staged, ...leftAsItIs(plan)],
198
+ notOnPlan: applied.notOnPlan,
199
+ };
200
+ }
201
+ /**
202
+ * What the plan does with Production's services: it gives them to a project
203
+ * it creates and to the managed project, and keeps those of a project it links.
204
+ */
205
+ function servicesPlanOf(draft, managed) {
206
+ return draft?.kind === "new" || managed ? "give" : "keep";
207
+ }
208
+ /**
209
+ * What the plan gives the project beside its environments: when it gives
210
+ * the services, the address its config allows and the dashboard its work
211
+ * tree builds; nothing when it keeps them.
212
+ */
213
+ async function rolloutPlan(services, repository) {
214
+ if (services === "keep") {
215
+ return { address: null, dashboard: null, storage: null };
216
+ }
217
+ const [config, build] = await Promise.all([
218
+ (0, project_config_1.readProjectConfig)(),
219
+ (0, dockerfile_1.readDashboardBuild)(),
220
+ ]);
221
+ return {
222
+ address: (0, address_1.appAddressOf)(config),
223
+ dashboard: build === null ? null : { build, repository },
224
+ storage: (0, storage_1.appStorageOf)(config),
225
+ };
226
+ }
227
+ //# sourceMappingURL=rollout.js.map
@@ -0,0 +1,93 @@
1
+ import type { Repository } from "../connection/repository";
2
+ import type { ConnectionView } from "../connection/view";
3
+ import type { DashboardBuild } from "../dashboard/dockerfile";
4
+ import type { AppAddress } from "../environments/address";
5
+ import type { AppStorage } from "./storage";
6
+ import type { StoredSetup } from "./store";
7
+ /** The project the first-run setup puts online, as its steps name it. */
8
+ export interface SetupProject {
9
+ readonly slug: string;
10
+ /** `null` when AntelopeJS Cloud did not say. */
11
+ readonly region: string | null;
12
+ /** Whether applying the plan creates it. */
13
+ readonly isNew: boolean;
14
+ }
15
+ /** What the first-run setup's steps are derived from. */
16
+ export interface SetupFacts {
17
+ readonly connection: ConnectionView;
18
+ /** `null` until the owner chooses one, here or on the Connection page. */
19
+ readonly project: SetupProject | null;
20
+ /** The repository the module publishes. */
21
+ readonly repository: Repository;
22
+ /** The project the plan was last applied to, `null` before. */
23
+ readonly appliedTo: string | null;
24
+ /** The address the project's config lets its app have on AntelopeJS Cloud. */
25
+ readonly address: AppAddress;
26
+ /**
27
+ * How the dashboard of the project is built on AntelopeJS Cloud, `null`
28
+ * when its work tree has no `frontend.Dockerfile`.
29
+ */
30
+ readonly dashboard: DashboardBuild | null;
31
+ /** What the project's app keeps its files on, as its config says. */
32
+ readonly storage: AppStorage;
33
+ }
34
+ /** Where a step stands: behind, the one to do now, or waiting on an earlier one. */
35
+ export type StepStatus = "done" | "current" | "blocked";
36
+ /** One step of the first-run setup, as the page lists it. */
37
+ export interface SetupStep {
38
+ readonly id: SetupStepId;
39
+ readonly label: string;
40
+ readonly status: StepStatus;
41
+ readonly summary: string;
42
+ }
43
+ declare function connectSummary({ connection }: SetupFacts): string;
44
+ declare function projectSummary({ project }: SetupFacts): string;
45
+ declare function repositorySummary({ repository }: SetupFacts): string;
46
+ declare function isApplied({ connection, appliedTo }: SetupFacts): boolean;
47
+ declare const STEPS: readonly [{
48
+ readonly id: "connect";
49
+ readonly label: "Connect";
50
+ readonly isDone: ({ connection }: SetupFacts) => boolean;
51
+ readonly summary: typeof connectSummary;
52
+ }, {
53
+ readonly id: "project";
54
+ readonly label: "Project";
55
+ readonly isDone: ({ project }: SetupFacts) => boolean;
56
+ readonly summary: typeof projectSummary;
57
+ }, {
58
+ readonly id: "repository";
59
+ readonly label: "Repository";
60
+ readonly isDone: ({ repository }: SetupFacts) => boolean;
61
+ readonly summary: typeof repositorySummary;
62
+ }, {
63
+ readonly id: "plan";
64
+ readonly label: "Plan";
65
+ readonly isDone: typeof isApplied;
66
+ readonly summary: (facts: SetupFacts) => "Applied" | "Review what AntelopeJS Cloud creates";
67
+ }, {
68
+ readonly id: "apply";
69
+ readonly label: "Apply";
70
+ readonly isDone: typeof isApplied;
71
+ readonly summary: (facts: SetupFacts) => "Done: running it again creates only what is missing" | "Creates the project, its environments and the repository link";
72
+ }, {
73
+ readonly id: "done";
74
+ readonly label: "Done";
75
+ readonly isDone: typeof isApplied;
76
+ readonly summary: (facts: SetupFacts) => string;
77
+ }];
78
+ /** A step of the first-run setup. */
79
+ export type SetupStepId = (typeof STEPS)[number]["id"];
80
+ /**
81
+ * The six steps of the first-run setup, in order. The first step not done is
82
+ * the current one; every step after it waits on it, whatever its own facts.
83
+ */
84
+ export declare function setupSteps(facts: SetupFacts): SetupStep[];
85
+ /** The step to do now, or `done` once every step is. */
86
+ export declare function currentStep(steps: readonly SetupStep[]): SetupStepId;
87
+ /** What the first-run setup stands on: its facts, what the owner chose, and its steps. */
88
+ export interface SetupState {
89
+ readonly facts: SetupFacts;
90
+ readonly setup: StoredSetup | undefined;
91
+ readonly steps: readonly SetupStep[];
92
+ }
93
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupSteps = setupSteps;
4
+ exports.currentStep = currentStep;
5
+ function connectSummary({ connection }) {
6
+ if (connection.state === "connected") {
7
+ if (connection.managed)
8
+ return "Managed by AntelopeJS Cloud";
9
+ const { id, name } = connection.workspace;
10
+ return `${name ?? id} · ${connection.connectedBy}`;
11
+ }
12
+ if (connection.state === "pending")
13
+ return "Waiting for approval";
14
+ if (connection.state === "failed")
15
+ return "The sign-in did not finish";
16
+ return "Sign in with your AntelopeJS Cloud account";
17
+ }
18
+ function projectSummary({ project }) {
19
+ if (!project)
20
+ return "Create one, or link one the workspace has";
21
+ return [project.slug, project.region, project.isNew ? "new" : null]
22
+ .filter(Boolean)
23
+ .join(" · ");
24
+ }
25
+ function repositorySummary({ repository }) {
26
+ const { remote, branch } = repository;
27
+ if (!remote?.webUrl)
28
+ return "No GitHub remote";
29
+ return branch ? `${remote.label} · ${branch}` : remote.label;
30
+ }
31
+ function isApplied({ connection, appliedTo }) {
32
+ return (connection.state === "connected" &&
33
+ appliedTo !== null &&
34
+ appliedTo === connection.projectId);
35
+ }
36
+ const STEPS = [
37
+ {
38
+ id: "connect",
39
+ label: "Connect",
40
+ isDone: ({ connection }) => connection.state === "connected",
41
+ summary: connectSummary,
42
+ },
43
+ {
44
+ id: "project",
45
+ label: "Project",
46
+ isDone: ({ project }) => project !== null,
47
+ summary: projectSummary,
48
+ },
49
+ {
50
+ id: "repository",
51
+ label: "Repository",
52
+ isDone: ({ repository }) => Boolean(repository.remote?.webUrl),
53
+ summary: repositorySummary,
54
+ },
55
+ {
56
+ id: "plan",
57
+ label: "Plan",
58
+ isDone: isApplied,
59
+ summary: (facts) => isApplied(facts) ? "Applied" : "Review what AntelopeJS Cloud creates",
60
+ },
61
+ {
62
+ id: "apply",
63
+ label: "Apply",
64
+ isDone: isApplied,
65
+ summary: (facts) => isApplied(facts)
66
+ ? "Done: running it again creates only what is missing"
67
+ : "Creates the project, its environments and the repository link",
68
+ },
69
+ {
70
+ id: "done",
71
+ label: "Done",
72
+ isDone: isApplied,
73
+ summary: (facts) => isApplied(facts) && facts.project
74
+ ? `${facts.project.slug} is ready on AntelopeJS Cloud`
75
+ : "Once the plan is applied",
76
+ },
77
+ ];
78
+ /**
79
+ * The six steps of the first-run setup, in order. The first step not done is
80
+ * the current one; every step after it waits on it, whatever its own facts.
81
+ */
82
+ function setupSteps(facts) {
83
+ let reached = true;
84
+ return STEPS.map(({ id, label, isDone, summary }) => {
85
+ const done = reached && isDone(facts);
86
+ const status = done ? "done" : reached ? "current" : "blocked";
87
+ reached = done;
88
+ return { id, label, status, summary: summary(facts) };
89
+ });
90
+ }
91
+ /** The step to do now, or `done` once every step is. */
92
+ function currentStep(steps) {
93
+ return steps.find(({ status }) => status === "current")?.id ?? "done";
94
+ }
95
+ //# sourceMappingURL=steps.js.map
@@ -0,0 +1,29 @@
1
+ import type { KeyValueListItem } from "@antelopejs/interface-dms/base/key-value-list";
2
+ import { type ProjectConfig } from "../variables/project-config";
3
+ import type { StorageItem } from "./rollout";
4
+ /** The module that keeps the files a project stores on its app's own disk. */
5
+ export declare const FILE_STORAGE_PACKAGE = "@antelopejs/file-storage-local";
6
+ /**
7
+ * What the app of a project keeps its files on, as its `antelope.config.ts`
8
+ * says: nothing of its own (`none`), or the folder `@antelopejs/file-storage-local`
9
+ * writes to (`local_disk`), which must sit on a persistent, writable disk for
10
+ * the app to start in production. `key` is the `envOverrides` variable that
11
+ * feeds its `storagePath`, `null` when none does.
12
+ */
13
+ export type AppStorage = {
14
+ readonly kind: "none";
15
+ } | {
16
+ readonly kind: "local_disk";
17
+ readonly key: string | null;
18
+ };
19
+ /** What the app of a project with this config keeps its files on. */
20
+ export declare function appStorageOf(config: ProjectConfig): AppStorage;
21
+ /**
22
+ * What an applied plan says of the app's files whatever the apply did: that
23
+ * no variable points them at the app's volume, when none does.
24
+ */
25
+ export declare function plannedNotes(storage: AppStorage | null): string[];
26
+ /** What an applied plan says of the volumes it could not give, in sentences. */
27
+ export declare function notesOf(items: readonly StorageItem[]): string[];
28
+ /** The plan's line for an app that keeps its files on its disk. */
29
+ export declare function storageItem(key: string | null): KeyValueListItem;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FILE_STORAGE_PACKAGE = void 0;
4
+ exports.appStorageOf = appStorageOf;
5
+ exports.plannedNotes = plannedNotes;
6
+ exports.notesOf = notesOf;
7
+ exports.storageItem = storageItem;
8
+ const project_config_1 = require("../variables/project-config");
9
+ const pipeline_1 = require("../environments/pipeline");
10
+ const volume_1 = require("./volume");
11
+ /** The module that keeps the files a project stores on its app's own disk. */
12
+ exports.FILE_STORAGE_PACKAGE = "@antelopejs/file-storage-local";
13
+ /** What the app of a project with this config keeps its files on. */
14
+ function appStorageOf(config) {
15
+ const moduleKeys = (0, project_config_1.moduleKeysOf)(config, exports.FILE_STORAGE_PACKAGE);
16
+ if (moduleKeys.length === 0)
17
+ return { kind: "none" };
18
+ const fed = new Set(moduleKeys.map((moduleKey) => `modules.${moduleKey}.config.storagePath`));
19
+ const [key] = Object.entries(config.envOverrides).flatMap(([name, paths]) => paths.some((path) => fed.has(path)) ? [name] : []);
20
+ return { kind: "local_disk", key: key ?? null };
21
+ }
22
+ const MOUNT_PATH = volume_1.FILES_VOLUME.mountPath;
23
+ const NO_VARIABLE = `No envOverrides variable feeds the storagePath of ${exports.FILE_STORAGE_PACKAGE}, so the app's files can't go to its volume at ${MOUNT_PATH}, and the app can't start in production. Add one, such as FILE_STORAGE_PATH, then set it on the Variables page.`;
24
+ /**
25
+ * What an applied plan says of the app's files whatever the apply did: that
26
+ * no variable points them at the app's volume, when none does.
27
+ */
28
+ function plannedNotes(storage) {
29
+ return storage?.kind === "local_disk" && storage.key === null
30
+ ? [NO_VARIABLE]
31
+ : [];
32
+ }
33
+ /** The variable that points the app's files at a folder, or the option it would feed. */
34
+ function targetOf(key) {
35
+ return key ?? `the storagePath of ${exports.FILE_STORAGE_PACKAGE}`;
36
+ }
37
+ /**
38
+ * What an applied plan says of an environment whose app got no volume: its
39
+ * plan holds no more (`not_on_plan`), or it runs no app service or several,
40
+ * so none can be told to be the app (`not_one_app`).
41
+ */
42
+ function noVolumeNote(environment, outcome, key) {
43
+ const target = targetOf(key);
44
+ return outcome === "not_on_plan"
45
+ ? `The app of ${environment} has no volume for its files: your plan includes no more. It can't start until ${target} names a folder on a persistent volume: free one or change plans, then apply the plan again.`
46
+ : `${environment} runs no app service or several, so no app got a volume for its files. Add a volume to its app in the service settings on AntelopeJS Cloud, then set ${target} to a folder on it.`;
47
+ }
48
+ /** What an applied plan says of the volumes it could not give, in sentences. */
49
+ function notesOf(items) {
50
+ return items.flatMap((item) => {
51
+ if (item.outcome === "no_variable")
52
+ return [NO_VARIABLE];
53
+ return item.outcome === "not_on_plan" || item.outcome === "not_one_app"
54
+ ? [noVolumeNote((0, pipeline_1.environmentLabel)(item.name), item.outcome, item.key)]
55
+ : [];
56
+ });
57
+ }
58
+ /** The plan's line for an app that keeps its files on its disk. */
59
+ function storageItem(key) {
60
+ if (key === null) {
61
+ return {
62
+ id: "storage",
63
+ label: "Storage",
64
+ value: "No variable for its folder",
65
+ type: "status",
66
+ tone: "warning",
67
+ detail: NO_VARIABLE,
68
+ };
69
+ }
70
+ return {
71
+ id: "storage",
72
+ label: "Storage",
73
+ value: `Volume at ${MOUNT_PATH}`,
74
+ type: "mono",
75
+ detail: `A persistent volume on the app of each environment, for the files ${exports.FILE_STORAGE_PACKAGE} keeps: the app runs one instance with it. The Variables page then sets ${key} to it.`,
76
+ };
77
+ }
78
+ //# sourceMappingURL=storage.js.map