@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,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishTargetNames = publishTargetNames;
4
+ exports.publishTargetRefusal = publishTargetRefusal;
5
+ const refusal_1 = require("../git/refusal");
6
+ const versions_1 = require("../git/versions");
7
+ const pipeline_1 = require("./pipeline");
8
+ const ENVIRONMENT_FIELD = "environment";
9
+ const PROMOTED_ONLY = "Production only receives promoted versions.";
10
+ function hasStageBeforeProduction(environments) {
11
+ return (0, pipeline_1.pipelineOf)(environments).stages.some(({ name }) => !(0, versions_1.isPromotedOnly)(name));
12
+ }
13
+ /**
14
+ * The environments of a project a publish may move, by name: the pipeline's
15
+ * stages in their order, then the others. Each one alone builds its own
16
+ * `env/<name>` branch, the branch a publish pushes and AntelopeJS Cloud
17
+ * deploys. Production takes promoted versions only once the project has a
18
+ * stage before it; without one, it takes publishes.
19
+ */
20
+ function publishTargetNames(environments) {
21
+ const { stages, others } = (0, pipeline_1.pipelineOf)(environments);
22
+ const isProductionPromoted = hasStageBeforeProduction(environments);
23
+ return [...stages, ...others]
24
+ .filter((environment) => (0, pipeline_1.promotionRoute)(environment, environments).kind === "push")
25
+ .filter(({ name }) => !(0, versions_1.isPromotedOnly)(name) || !isProductionPromoted)
26
+ .map(({ name }) => name);
27
+ }
28
+ function projectRefusal(environments, name) {
29
+ if (publishTargetNames(environments).includes(name))
30
+ return null;
31
+ const label = (0, pipeline_1.environmentLabel)(name);
32
+ const isInProject = environments.some((environment) => environment.preview === null && environment.name === name);
33
+ if (!isInProject) {
34
+ return (0, refusal_1.invalidInput)(ENVIRONMENT_FIELD, `This project has no ${label} environment on AntelopeJS Cloud. Create it on the Environments page, or choose another environment.`);
35
+ }
36
+ if ((0, versions_1.isPromotedOnly)(name) && hasStageBeforeProduction(environments)) {
37
+ return (0, refusal_1.invalidInput)(ENVIRONMENT_FIELD, PROMOTED_ONLY);
38
+ }
39
+ return (0, refusal_1.invalidInput)(ENVIRONMENT_FIELD, `AntelopeJS Cloud does not deploy ${label} from a branch of its own named ${(0, pipeline_1.defaultBranch)(name)}, so a publish does not reach it. Choose another environment.`);
40
+ }
41
+ /**
42
+ * Why a publish to the environment `name` is refused, `null` when it may
43
+ * run. With the linked project's `environments`, only its
44
+ * {@link publishTargetNames} are accepted. Without them, for a DMS that
45
+ * publishes no project or whose project AntelopeJS Cloud did not answer for,
46
+ * any environment but production is.
47
+ */
48
+ function publishTargetRefusal(environments, name) {
49
+ if (environments !== undefined)
50
+ return projectRefusal(environments, name);
51
+ return (0, versions_1.isPromotedOnly)(name)
52
+ ? (0, refusal_1.invalidInput)(ENVIRONMENT_FIELD, PROMOTED_ONLY)
53
+ : null;
54
+ }
55
+ //# sourceMappingURL=publish-targets.js.map
@@ -0,0 +1,73 @@
1
+ import { type CloudApi } from "@antelopejs/cloud-sdk";
2
+ /** The name of the dashboard service the module creates. */
3
+ export declare const DASHBOARD_SERVICE = "dashboard";
4
+ /** A service of an environment, as AntelopeJS Cloud lists it. */
5
+ export interface ListedService {
6
+ readonly id: string;
7
+ readonly name: string;
8
+ }
9
+ /** An environment and the services AntelopeJS Cloud lists for it. */
10
+ export interface ListedEnvironment {
11
+ readonly id: string;
12
+ readonly services: readonly ListedService[];
13
+ }
14
+ /**
15
+ * What the services of an environment are: the databases AntelopeJS Cloud
16
+ * runs for it, the dashboard of the project when it runs one, and the app
17
+ * services, which is every other service.
18
+ */
19
+ export interface ServiceRoles {
20
+ /** The databases, by service id. */
21
+ readonly databases: ReadonlySet<string>;
22
+ /** The services that are neither a database nor the dashboard, in order. */
23
+ readonly apps: readonly string[];
24
+ /** The dashboard, `null` when the environment runs none. */
25
+ readonly dashboard: string | null;
26
+ }
27
+ /**
28
+ * What a service says of the Dockerfile that builds it: its path, `null` for
29
+ * none, or `undefined` when AntelopeJS Cloud does not say, either because it
30
+ * refused the read or because it does not know the setting yet.
31
+ */
32
+ type NamedDockerfile = string | null | undefined;
33
+ /** A service that is not a database, and what it says of its Dockerfile. */
34
+ interface Candidate extends ListedService {
35
+ readonly dockerfile: NamedDockerfile;
36
+ }
37
+ /**
38
+ * The dashboard among the services of an environment that are not databases.
39
+ * One service alone is the app, whatever builds it. Of several, the
40
+ * dashboard is the one a Dockerfile it names builds; when AntelopeJS Cloud
41
+ * does not say what builds a service, the one named `dashboard`. Several
42
+ * such services are told apart by that name, and none is the dashboard when
43
+ * it does not settle it.
44
+ */
45
+ export declare function dashboardAmong(candidates: readonly Candidate[]): string | null;
46
+ /**
47
+ * What each of `services` is, given the databases among them. The Dockerfile
48
+ * of a service is read only when several services are not databases: with
49
+ * one, there is nothing to tell apart.
50
+ *
51
+ * @param databases The ids of the databases AntelopeJS Cloud runs for the environment
52
+ * @throws The `CloudApiError` of a read AntelopeJS Cloud does not answer, or
53
+ * answers with a refused token
54
+ */
55
+ export declare function rolesAmong(api: CloudApi, services: readonly ListedService[], databases: ReadonlySet<string>): Promise<ServiceRoles>;
56
+ /**
57
+ * Reads what each service of an environment is: its databases from
58
+ * AntelopeJS Cloud, then the rest as {@link rolesAmong} tells them apart.
59
+ *
60
+ * @throws The `CloudApiError` of a read AntelopeJS Cloud does not answer, or
61
+ * answers with a refused token
62
+ */
63
+ export declare function serviceRolesOf(api: CloudApi, projectId: string, environment: ListedEnvironment): Promise<ServiceRoles>;
64
+ /** The one app service of an environment: `null` when it runs none, or several. */
65
+ export declare function appOf({ apps }: ServiceRoles): string | null;
66
+ /** A project as AntelopeJS Cloud answers it, with the host of each service. */
67
+ export type ProjectHosts = Awaited<ReturnType<CloudApi["readProject"]>>;
68
+ /**
69
+ * The address a service of an environment answers on, `null` when the
70
+ * internet does not reach it.
71
+ */
72
+ export declare function serviceAddress(project: ProjectHosts, environmentId: string, serviceId: string): string | null;
73
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DASHBOARD_SERVICE = void 0;
4
+ exports.dashboardAmong = dashboardAmong;
5
+ exports.rolesAmong = rolesAmong;
6
+ exports.serviceRolesOf = serviceRolesOf;
7
+ exports.appOf = appOf;
8
+ exports.serviceAddress = serviceAddress;
9
+ const cloud_sdk_1 = require("@antelopejs/cloud-sdk");
10
+ /** The name of the dashboard service the module creates. */
11
+ exports.DASHBOARD_SERVICE = "dashboard";
12
+ const HTTP_UNAUTHORIZED = 401;
13
+ async function dockerfileOf(api, serviceId) {
14
+ try {
15
+ const { source } = await api.serviceSettings(serviceId);
16
+ return source?.dockerfilePath;
17
+ }
18
+ catch (error) {
19
+ const isUnreadable = error instanceof cloud_sdk_1.CloudApiError && error.status !== HTTP_UNAUTHORIZED;
20
+ if (!isUnreadable)
21
+ throw error;
22
+ return undefined;
23
+ }
24
+ }
25
+ function looksLikeDashboard({ name, dockerfile }) {
26
+ return dockerfile === undefined
27
+ ? name === exports.DASHBOARD_SERVICE
28
+ : dockerfile !== null && dockerfile !== "";
29
+ }
30
+ /**
31
+ * The dashboard among the services of an environment that are not databases.
32
+ * One service alone is the app, whatever builds it. Of several, the
33
+ * dashboard is the one a Dockerfile it names builds; when AntelopeJS Cloud
34
+ * does not say what builds a service, the one named `dashboard`. Several
35
+ * such services are told apart by that name, and none is the dashboard when
36
+ * it does not settle it.
37
+ */
38
+ function dashboardAmong(candidates) {
39
+ if (candidates.length < 2)
40
+ return null;
41
+ const dashboards = candidates.filter(looksLikeDashboard);
42
+ if (dashboards.length === 1)
43
+ return dashboards[0].id;
44
+ const named = dashboards.filter(({ name }) => name === exports.DASHBOARD_SERVICE);
45
+ return named.length === 1 ? named[0].id : null;
46
+ }
47
+ /**
48
+ * What each of `services` is, given the databases among them. The Dockerfile
49
+ * of a service is read only when several services are not databases: with
50
+ * one, there is nothing to tell apart.
51
+ *
52
+ * @param databases The ids of the databases AntelopeJS Cloud runs for the environment
53
+ * @throws The `CloudApiError` of a read AntelopeJS Cloud does not answer, or
54
+ * answers with a refused token
55
+ */
56
+ async function rolesAmong(api, services, databases) {
57
+ const others = services.filter(({ id }) => !databases.has(id));
58
+ const candidates = others.length < 2
59
+ ? []
60
+ : await Promise.all(others.map(async ({ id, name }) => ({
61
+ id,
62
+ name,
63
+ dockerfile: await dockerfileOf(api, id),
64
+ })));
65
+ const dashboard = dashboardAmong(candidates);
66
+ return {
67
+ databases,
68
+ apps: others.flatMap(({ id }) => (id === dashboard ? [] : [id])),
69
+ dashboard,
70
+ };
71
+ }
72
+ /**
73
+ * Reads what each service of an environment is: its databases from
74
+ * AntelopeJS Cloud, then the rest as {@link rolesAmong} tells them apart.
75
+ *
76
+ * @throws The `CloudApiError` of a read AntelopeJS Cloud does not answer, or
77
+ * answers with a refused token
78
+ */
79
+ async function serviceRolesOf(api, projectId, environment) {
80
+ const { resources } = await api.environmentResources(projectId, environment.id);
81
+ return rolesAmong(api, environment.services, new Set(resources.map(({ serviceId }) => serviceId)));
82
+ }
83
+ /** The one app service of an environment: `null` when it runs none, or several. */
84
+ function appOf({ apps }) {
85
+ return apps.length === 1 ? apps[0] : null;
86
+ }
87
+ /**
88
+ * The address a service of an environment answers on, `null` when the
89
+ * internet does not reach it.
90
+ */
91
+ function serviceAddress(project, environmentId, serviceId) {
92
+ const host = project.environments
93
+ .find(({ id }) => id === environmentId)
94
+ ?.services.find(({ id }) => id === serviceId)?.primaryHost;
95
+ return host ? `https://${host}` : null;
96
+ }
97
+ //# sourceMappingURL=roles.js.map
@@ -0,0 +1,12 @@
1
+ import type { FrontendModuleRegistration } from "@antelopejs/interface-dms/page";
2
+ import type { AntelopeCloudConfig } from "./config";
3
+ /** The module's Vue frontend registration, as the running module adds it. */
4
+ export declare function frontendRegistration(): FrontendModuleRegistration;
5
+ /**
6
+ * The `config` to registration function `dmsFrontend` in package.json names.
7
+ * `ajs dms dev`, `build` and `start` load this file on its own, so it imports
8
+ * nothing at runtime beyond Node built-ins and `configured.ts`, which imports
9
+ * nothing. A project that gave the module no `secretKey` does not run it, so
10
+ * its dashboard gets no frontend either.
11
+ */
12
+ export declare function frontendModule(config?: AntelopeCloudConfig | null): FrontendModuleRegistration | undefined;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.frontendRegistration = frontendRegistration;
4
+ exports.frontendModule = frontendModule;
5
+ const node_path_1 = require("node:path");
6
+ const configured_1 = require("./configured");
7
+ /** The module's Vue frontend registration, as the running module adds it. */
8
+ function frontendRegistration() {
9
+ return {
10
+ name: "@antelopejs/dms-antelope-cloud-frontend-vue",
11
+ sourcePath: (0, node_path_1.resolve)(__dirname, "../frontend-vue"),
12
+ renderer: { name: "vue", version: "3" },
13
+ };
14
+ }
15
+ /**
16
+ * The `config` to registration function `dmsFrontend` in package.json names.
17
+ * `ajs dms dev`, `build` and `start` load this file on its own, so it imports
18
+ * nothing at runtime beyond Node built-ins and `configured.ts`, which imports
19
+ * nothing. A project that gave the module no `secretKey` does not run it, so
20
+ * its dashboard gets no frontend either.
21
+ */
22
+ function frontendModule(config) {
23
+ return (0, configured_1.isCloudModuleConfigured)(config) ? frontendRegistration() : undefined;
24
+ }
25
+ //# sourceMappingURL=frontend-module.js.map
@@ -0,0 +1,30 @@
1
+ /** How a file differs from the version it is compared with. */
2
+ type ChangeKind = "added" | "modified" | "deleted";
3
+ /** A file that differs between two snapshots of the project. */
4
+ export type ChangedFile = {
5
+ readonly kind: ChangeKind;
6
+ /** Path from the repository root, with forward slashes. */
7
+ readonly path: string;
8
+ /** Lines added, or `null` for a binary file. */
9
+ readonly additions: number | null;
10
+ /** Lines deleted, or `null` for a binary file. */
11
+ readonly deletions: number | null;
12
+ };
13
+ /** How many files and lines a list of changes touches. */
14
+ export type ChangeTotals = {
15
+ readonly files: number;
16
+ readonly additions: number;
17
+ readonly deletions: number;
18
+ };
19
+ /** The number of files and the lines a list of changes adds and deletes. */
20
+ export declare function changeTotals(files: readonly ChangedFile[]): ChangeTotals;
21
+ /** The files that differ between two commits or trees. */
22
+ export declare function filesBetween(repository: string, from: string, to: string): Promise<ChangedFile[]>;
23
+ /**
24
+ * The files of the working copy, tracked and untracked but not ignored, that
25
+ * differ from `base`. Reads them through an index of its own: a copy of the
26
+ * user's index reset to `head` (an empty one for a branch with no commit), so
27
+ * the user's index is never touched.
28
+ */
29
+ export declare function workingCopyFiles(repository: string, head: string | null, base: string): Promise<ChangedFile[]>;
30
+ export {};
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.changeTotals = changeTotals;
4
+ exports.filesBetween = filesBetween;
5
+ exports.workingCopyFiles = workingCopyFiles;
6
+ const promises_1 = require("node:fs/promises");
7
+ const node_os_1 = require("node:os");
8
+ const node_path_1 = require("node:path");
9
+ const command_1 = require("./command");
10
+ const KINDS = new Map([
11
+ ["A", "added"],
12
+ ["D", "deleted"],
13
+ ]);
14
+ const BINARY_COUNT = "-";
15
+ const DIFF_OPTIONS = ["--no-renames", "--no-ext-diff", "--no-textconv", "-z"];
16
+ function lineCount(raw) {
17
+ return raw === undefined || raw === BINARY_COUNT ? null : Number(raw);
18
+ }
19
+ /**
20
+ * Joins the `-z` outputs of `git diff --name-status` and `--numstat`, both
21
+ * run with `--no-renames`, into one entry per path, in git's order.
22
+ */
23
+ function parseChangedFiles(nameStatus, numstat) {
24
+ const counts = new Map();
25
+ for (const record of numstat.split("\0")) {
26
+ const [additions = "", deletions = "", ...path] = record.split("\t");
27
+ if (path.length > 0)
28
+ counts.set(path.join("\t"), [additions, deletions]);
29
+ }
30
+ const fields = nameStatus.split("\0");
31
+ const files = [];
32
+ for (let index = 0; index + 1 < fields.length; index += 2) {
33
+ const status = fields[index]?.charAt(0) ?? "";
34
+ const path = fields[index + 1] ?? "";
35
+ const [additions, deletions] = counts.get(path) ?? [];
36
+ files.push({
37
+ kind: KINDS.get(status) ?? "modified",
38
+ path,
39
+ additions: lineCount(additions),
40
+ deletions: lineCount(deletions),
41
+ });
42
+ }
43
+ return files;
44
+ }
45
+ /** The number of files and the lines a list of changes adds and deletes. */
46
+ function changeTotals(files) {
47
+ return files.reduce((totals, file) => ({
48
+ files: totals.files + 1,
49
+ additions: totals.additions + (file.additions ?? 0),
50
+ deletions: totals.deletions + (file.deletions ?? 0),
51
+ }), { files: 0, additions: 0, deletions: 0 });
52
+ }
53
+ async function diffFiles(repository, range, env) {
54
+ const [nameStatus, numstat] = await Promise.all([
55
+ (0, command_1.git)(repository, ["diff", "--name-status", ...DIFF_OPTIONS, ...range], {
56
+ env,
57
+ }),
58
+ (0, command_1.git)(repository, ["diff", "--numstat", ...DIFF_OPTIONS, ...range], { env }),
59
+ ]);
60
+ return parseChangedFiles(nameStatus, numstat);
61
+ }
62
+ /** The files that differ between two commits or trees. */
63
+ function filesBetween(repository, from, to) {
64
+ return diffFiles(repository, [from, to]);
65
+ }
66
+ /**
67
+ * Copies the user's index to `copy` with its modification time, read before
68
+ * the copy so that it is never newer than the content: git then takes the
69
+ * stat data of the index entries, judges which ones are racily clean as it
70
+ * would on the user's index, and hashes only the files that changed. Reads
71
+ * the user's index and never writes it. Copies nothing when there is no index
72
+ * to read, and git then hashes every file.
73
+ */
74
+ async function copyIndex(repository, copy) {
75
+ const index = (0, node_path_1.resolve)(repository, (await (0, command_1.git)(repository, ["rev-parse", "--git-path", "index"])).trim());
76
+ const stats = await (0, promises_1.stat)(index).catch(() => null);
77
+ if (stats === null)
78
+ return;
79
+ await (0, promises_1.copyFile)(index, copy);
80
+ await (0, promises_1.utimes)(copy, stats.atime, stats.mtime);
81
+ }
82
+ /**
83
+ * The files of the working copy, tracked and untracked but not ignored, that
84
+ * differ from `base`. Reads them through an index of its own: a copy of the
85
+ * user's index reset to `head` (an empty one for a branch with no commit), so
86
+ * the user's index is never touched.
87
+ */
88
+ async function workingCopyFiles(repository, head, base) {
89
+ const folder = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "antelope-cloud-index-"));
90
+ try {
91
+ const index = (0, node_path_1.join)(folder, "index");
92
+ const env = { GIT_INDEX_FILE: index };
93
+ if (head) {
94
+ await copyIndex(repository, index);
95
+ await (0, command_1.git)(repository, ["read-tree", "--reset", head], { env });
96
+ }
97
+ else {
98
+ await (0, command_1.git)(repository, ["read-tree", "--empty"], { env });
99
+ }
100
+ await (0, command_1.git)(repository, ["add", "--all"], { env });
101
+ return await diffFiles(repository, ["--cached", base], env);
102
+ }
103
+ finally {
104
+ await (0, promises_1.rm)(folder, { recursive: true, force: true });
105
+ }
106
+ }
107
+ //# sourceMappingURL=changed-files.js.map
@@ -0,0 +1,89 @@
1
+ import { type ChangedFile, type ChangeTotals } from "./changed-files";
2
+ import type { PublishJob } from "./publish-job";
3
+ import { type WorkBranch } from "./refs";
4
+ import { type Refusal } from "./refusal";
5
+ import { type Release, type RepositorySnapshot } from "./repository";
6
+ import { type Environment, type VersionRef } from "./versions";
7
+ /** What the Changes page shows: what is unpublished, and whether it can be published. */
8
+ export type ChangesSummary = {
9
+ readonly ready: boolean;
10
+ /** Why the project cannot be published now, set when `ready` is false. */
11
+ readonly refusal: Refusal | null;
12
+ /** The branch HEAD names, `develop`. */
13
+ readonly branch: string | null;
14
+ /** The latest version origin holds, `null` before the first one. */
15
+ readonly since: VersionRef | null;
16
+ /** The latest version made here after `since` whose tag origin does not hold, as after a refused push. */
17
+ readonly pending: VersionRef | null;
18
+ /** The working copy's files that differ from `since`, or from the empty tree before the first version. */
19
+ readonly files: readonly ChangedFile[];
20
+ readonly totals: ChangeTotals;
21
+ /** The version the next publish pushes: `pending` again, or a new one. */
22
+ readonly nextVersion: {
23
+ readonly number: number;
24
+ readonly tag: string;
25
+ };
26
+ /** The environments a publish may move. */
27
+ readonly environments: readonly Environment[];
28
+ /** The latest publish of this process. */
29
+ readonly job: PublishJob | null;
30
+ };
31
+ /** Whether the repository lets a publish run, and on which branch. */
32
+ export type RepositoryCheck = {
33
+ readonly kind: "refused";
34
+ readonly refusal: Refusal;
35
+ } | {
36
+ readonly kind: "ready";
37
+ readonly branch: WorkBranch;
38
+ };
39
+ /** The working copy against the latest version origin holds. */
40
+ export type Unpublished = {
41
+ /** The latest version origin holds as this repository has it. */
42
+ readonly since: Release | null;
43
+ /** The latest version after `since` whose tag origin does not hold. */
44
+ readonly pending: Release | null;
45
+ /** The working copy's files that differ from `since`. */
46
+ readonly files: readonly ChangedFile[];
47
+ };
48
+ /**
49
+ * The version the next publish pushes: the pending version again (`retry`),
50
+ * or a `new` one numbered past every release tag, local or on origin.
51
+ */
52
+ export type NextVersion = {
53
+ readonly kind: "retry";
54
+ readonly release: Release;
55
+ } | {
56
+ readonly kind: "new";
57
+ readonly number: number;
58
+ };
59
+ /**
60
+ * Checks what the repository itself must hold for a publish: an origin that
61
+ * answers, and HEAD on a branch other than an environment one.
62
+ */
63
+ export declare function checkRepository(snapshot: RepositorySnapshot): RepositoryCheck;
64
+ /**
65
+ * Why the repository itself keeps a publish from running, or `null`. Reads
66
+ * no file of the working copy.
67
+ */
68
+ export declare function readRepositoryRefusal(path: string): Promise<Refusal | null>;
69
+ /** The working copy's files that differ from the latest version origin holds. */
70
+ export declare function readUnpublished(snapshot: RepositorySnapshot): Promise<Unpublished>;
71
+ /** The working copy's files that differ from HEAD: what a publish commits. */
72
+ export declare function readUncommitted(snapshot: RepositorySnapshot, unpublished: Unpublished): Promise<readonly ChangedFile[]>;
73
+ /**
74
+ * The version the next publish pushes. A pending version goes again only
75
+ * while HEAD is its commit and nothing is left to commit; once HEAD moved, a
76
+ * new version takes HEAD, and the pending tag stays as it is.
77
+ */
78
+ export declare function readNextVersion(snapshot: RepositorySnapshot, unpublished: Unpublished): Promise<NextVersion>;
79
+ /** Whether the working copy is clean and HEAD is the latest published version's commit. */
80
+ export declare function isPublished(snapshot: RepositorySnapshot, unpublished: Unpublished): boolean;
81
+ /**
82
+ * Reads the project's unpublished changes and whether a publish may run.
83
+ * Answers for a folder that is not a repository too, with its refusal.
84
+ *
85
+ * @param targets The names of the environments a publish may move, first the
86
+ * one the form proposes, read while the repository is. When it resolves to
87
+ * `undefined`, the repository's own environment branches decide.
88
+ */
89
+ export declare function readChanges(path: string, job: PublishJob | null, targets?: Promise<readonly string[] | undefined>): Promise<ChangesSummary>;
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkRepository = checkRepository;
4
+ exports.readRepositoryRefusal = readRepositoryRefusal;
5
+ exports.readUnpublished = readUnpublished;
6
+ exports.readUncommitted = readUncommitted;
7
+ exports.readNextVersion = readNextVersion;
8
+ exports.isPublished = isPublished;
9
+ exports.readChanges = readChanges;
10
+ const changed_files_1 = require("./changed-files");
11
+ const refs_1 = require("./refs");
12
+ const refusal_1 = require("./refusal");
13
+ const repository_1 = require("./repository");
14
+ const versions_1 = require("./versions");
15
+ /**
16
+ * Checks what the repository itself must hold for a publish: an origin that
17
+ * answers, and HEAD on a branch other than an environment one.
18
+ */
19
+ function checkRepository(snapshot) {
20
+ const { origin, branch } = snapshot;
21
+ if (origin.kind === "missing") {
22
+ return {
23
+ kind: "refused",
24
+ refusal: (0, refusal_1.noOrigin)("This repository has no origin remote. Add the remote AntelopeJS Cloud builds from as origin."),
25
+ };
26
+ }
27
+ if (origin.kind === "unreachable") {
28
+ return {
29
+ kind: "refused",
30
+ refusal: (0, refusal_1.noOrigin)(`origin (${origin.url}) did not answer: ${origin.reason}`),
31
+ };
32
+ }
33
+ if (branch === null)
34
+ return { kind: "refused", refusal: (0, refusal_1.detachedHead)() };
35
+ if ((0, refs_1.isEnvironmentBranch)(branch)) {
36
+ return { kind: "refused", refusal: (0, refusal_1.onEnvironmentBranch)(branch) };
37
+ }
38
+ return { kind: "ready", branch: (0, refs_1.workBranch)(branch) };
39
+ }
40
+ /**
41
+ * Why the repository itself keeps a publish from running, or `null`. Reads
42
+ * no file of the working copy.
43
+ */
44
+ async function readRepositoryRefusal(path) {
45
+ const read = await (0, repository_1.readRepository)(path, "recent");
46
+ if (read.kind === "refused")
47
+ return read.refusal;
48
+ const check = checkRepository(read.snapshot);
49
+ return check.kind === "refused" ? check.refusal : null;
50
+ }
51
+ /**
52
+ * The latest published version, as {@link publishedReleases} counts them, and
53
+ * the latest local version after it whose tag origin lacks. Without an answer
54
+ * from origin, no version is pending.
55
+ */
56
+ function releaseStanding(snapshot) {
57
+ const since = (0, versions_1.publishedReleases)(snapshot)[0] ?? null;
58
+ const { origin, releases } = snapshot;
59
+ if (origin.kind !== "reachable")
60
+ return { since, pending: null };
61
+ const pending = releases.find((release) => release.number > (since?.number ?? 0) &&
62
+ (0, repository_1.originObject)(origin, (0, refs_1.tagRef)(release.tag)) === undefined) ?? null;
63
+ return { since, pending };
64
+ }
65
+ /** The working copy's files that differ from the latest version origin holds. */
66
+ async function readUnpublished(snapshot) {
67
+ const { since, pending } = releaseStanding(snapshot);
68
+ const files = await (0, changed_files_1.workingCopyFiles)(snapshot.path, snapshot.head, since?.commit ?? snapshot.emptyTree);
69
+ return { since, pending, files };
70
+ }
71
+ /** The working copy's files that differ from HEAD: what a publish commits. */
72
+ async function readUncommitted(snapshot, unpublished) {
73
+ const { head, path, emptyTree } = snapshot;
74
+ if (head === (unpublished.since?.commit ?? null))
75
+ return unpublished.files;
76
+ return (0, changed_files_1.workingCopyFiles)(path, head, head ?? emptyTree);
77
+ }
78
+ /**
79
+ * The version the next publish pushes. A pending version goes again only
80
+ * while HEAD is its commit and nothing is left to commit; once HEAD moved, a
81
+ * new version takes HEAD, and the pending tag stays as it is.
82
+ */
83
+ async function readNextVersion(snapshot, unpublished) {
84
+ const { pending } = unpublished;
85
+ if (pending !== null &&
86
+ pending.commit === snapshot.head &&
87
+ (await readUncommitted(snapshot, unpublished)).length === 0) {
88
+ return { kind: "retry", release: pending };
89
+ }
90
+ return { kind: "new", number: snapshot.highestReleaseNumber + 1 };
91
+ }
92
+ /** Whether the working copy is clean and HEAD is the latest published version's commit. */
93
+ function isPublished(snapshot, unpublished) {
94
+ return (unpublished.files.length === 0 &&
95
+ snapshot.head === (unpublished.since?.commit ?? null));
96
+ }
97
+ function nextVersionRef(next) {
98
+ const number = next.kind === "retry" ? next.release.number : next.number;
99
+ return { number, tag: (0, refs_1.releaseTagOf)(number) };
100
+ }
101
+ function firstRefusal(snapshot, unpublished, job) {
102
+ const check = checkRepository(snapshot);
103
+ if (check.kind === "refused")
104
+ return check.refusal;
105
+ if (job?.status === "running")
106
+ return (0, refusal_1.publishRunning)();
107
+ if (isPublished(snapshot, unpublished))
108
+ return (0, refusal_1.nothingToPublish)();
109
+ return null;
110
+ }
111
+ function targetsAmong(environments, targets) {
112
+ return targets === undefined
113
+ ? (0, versions_1.publishTargets)(environments)
114
+ : (0, versions_1.environmentsNamed)(environments, targets);
115
+ }
116
+ /**
117
+ * Reads the project's unpublished changes and whether a publish may run.
118
+ * Answers for a folder that is not a repository too, with its refusal.
119
+ *
120
+ * @param targets The names of the environments a publish may move, first the
121
+ * one the form proposes, read while the repository is. When it resolves to
122
+ * `undefined`, the repository's own environment branches decide.
123
+ */
124
+ async function readChanges(path, job, targets = Promise.resolve(undefined)) {
125
+ const [read, names] = await Promise.all([
126
+ (0, repository_1.readRepository)(path, "recent"),
127
+ targets,
128
+ ]);
129
+ if (read.kind === "refused") {
130
+ return {
131
+ ready: false,
132
+ refusal: read.refusal,
133
+ branch: null,
134
+ since: null,
135
+ pending: null,
136
+ files: [],
137
+ totals: (0, changed_files_1.changeTotals)([]),
138
+ nextVersion: nextVersionRef({ kind: "new", number: 1 }),
139
+ environments: targetsAmong([], names),
140
+ job,
141
+ };
142
+ }
143
+ const { snapshot } = read;
144
+ const unpublished = await readUnpublished(snapshot);
145
+ const environments = targetsAmong((0, versions_1.listEnvironments)(snapshot), names);
146
+ const refusal = firstRefusal(snapshot, unpublished, job) ??
147
+ (environments.length === 0 ? (0, refusal_1.noPublishTarget)() : null);
148
+ const { since, pending, files } = unpublished;
149
+ return {
150
+ ready: refusal === null,
151
+ refusal,
152
+ branch: snapshot.branch,
153
+ since: since ? (0, versions_1.versionRef)(since) : null,
154
+ pending: pending ? (0, versions_1.versionRef)(pending) : null,
155
+ files,
156
+ totals: (0, changed_files_1.changeTotals)(files),
157
+ nextVersion: nextVersionRef(await readNextVersion(snapshot, unpublished)),
158
+ environments,
159
+ job,
160
+ };
161
+ }
162
+ //# sourceMappingURL=changes.js.map