@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.
- package/LICENSE +201 -0
- package/README.md +448 -0
- package/dist/cloud-status.d.ts +13 -0
- package/dist/cloud-status.js +77 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +104 -0
- package/dist/configured.d.ts +16 -0
- package/dist/configured.js +26 -0
- package/dist/connection/actions.d.ts +40 -0
- package/dist/connection/actions.js +120 -0
- package/dist/connection/announce.d.ts +8 -0
- package/dist/connection/announce.js +20 -0
- package/dist/connection/cloud.d.ts +60 -0
- package/dist/connection/cloud.js +87 -0
- package/dist/connection/content.d.ts +70 -0
- package/dist/connection/content.js +462 -0
- package/dist/connection/current.d.ts +26 -0
- package/dist/connection/current.js +28 -0
- package/dist/connection/device-flow.d.ts +16 -0
- package/dist/connection/device-flow.js +146 -0
- package/dist/connection/refusals.d.ts +51 -0
- package/dist/connection/refusals.js +85 -0
- package/dist/connection/repository.d.ts +28 -0
- package/dist/connection/repository.js +69 -0
- package/dist/connection/seal.d.ts +22 -0
- package/dist/connection/seal.js +47 -0
- package/dist/connection/store.d.ts +294 -0
- package/dist/connection/store.js +165 -0
- package/dist/connection/view.d.ts +39 -0
- package/dist/connection/view.js +39 -0
- package/dist/dashboard/actions.d.ts +40 -0
- package/dist/dashboard/actions.js +115 -0
- package/dist/dashboard/dockerfile.d.ts +34 -0
- package/dist/dashboard/dockerfile.js +71 -0
- package/dist/dashboard/service.d.ts +61 -0
- package/dist/dashboard/service.js +137 -0
- package/dist/dashboard/variables.d.ts +30 -0
- package/dist/dashboard/variables.js +34 -0
- package/dist/deployments/build-log.d.ts +39 -0
- package/dist/deployments/build-log.js +57 -0
- package/dist/deployments/cloud-steps.d.ts +77 -0
- package/dist/deployments/cloud-steps.js +132 -0
- package/dist/deployments/content.d.ts +61 -0
- package/dist/deployments/content.js +268 -0
- package/dist/deployments/deployment.d.ts +96 -0
- package/dist/deployments/deployment.js +3 -0
- package/dist/deployments/follow.d.ts +18 -0
- package/dist/deployments/follow.js +112 -0
- package/dist/deployments/ledger.d.ts +23 -0
- package/dist/deployments/ledger.js +359 -0
- package/dist/deployments/lifecycle.d.ts +123 -0
- package/dist/deployments/lifecycle.js +146 -0
- package/dist/deployments/live.d.ts +28 -0
- package/dist/deployments/live.js +54 -0
- package/dist/deployments/publish-read.d.ts +20 -0
- package/dist/deployments/publish-read.js +24 -0
- package/dist/deployments/refusals.d.ts +13 -0
- package/dist/deployments/refusals.js +35 -0
- package/dist/environments/actions.d.ts +86 -0
- package/dist/environments/actions.js +210 -0
- package/dist/environments/address.d.ts +60 -0
- package/dist/environments/address.js +149 -0
- package/dist/environments/content.d.ts +97 -0
- package/dist/environments/content.js +275 -0
- package/dist/environments/follower.d.ts +32 -0
- package/dist/environments/follower.js +114 -0
- package/dist/environments/pipeline.d.ts +58 -0
- package/dist/environments/pipeline.js +76 -0
- package/dist/environments/publish-targets.d.ts +18 -0
- package/dist/environments/publish-targets.js +55 -0
- package/dist/environments/roles.d.ts +73 -0
- package/dist/environments/roles.js +97 -0
- package/dist/frontend-module.d.ts +12 -0
- package/dist/frontend-module.js +25 -0
- package/dist/git/changed-files.d.ts +30 -0
- package/dist/git/changed-files.js +107 -0
- package/dist/git/changes.d.ts +89 -0
- package/dist/git/changes.js +162 -0
- package/dist/git/command.d.ts +51 -0
- package/dist/git/command.js +231 -0
- package/dist/git/promotion.d.ts +23 -0
- package/dist/git/promotion.js +46 -0
- package/dist/git/publish-input.d.ts +42 -0
- package/dist/git/publish-input.js +62 -0
- package/dist/git/publish-job.d.ts +82 -0
- package/dist/git/publish-job.js +99 -0
- package/dist/git/publish-steps.d.ts +90 -0
- package/dist/git/publish-steps.js +205 -0
- package/dist/git/publisher.d.ts +23 -0
- package/dist/git/publisher.js +206 -0
- package/dist/git/refs.d.ts +99 -0
- package/dist/git/refs.js +178 -0
- package/dist/git/refusal.d.ts +49 -0
- package/dist/git/refusal.js +70 -0
- package/dist/git/repository.d.ts +101 -0
- package/dist/git/repository.js +273 -0
- package/dist/git/versions.d.ts +99 -0
- package/dist/git/versions.js +174 -0
- package/dist/git/write-lock.d.ts +19 -0
- package/dist/git/write-lock.js +49 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +59 -0
- package/dist/lifecycle.d.ts +8 -0
- package/dist/lifecycle.js +78 -0
- package/dist/logs/relay.d.ts +25 -0
- package/dist/logs/relay.js +138 -0
- package/dist/null-prototype.d.ts +7 -0
- package/dist/null-prototype.js +3 -0
- package/dist/overview/content.d.ts +40 -0
- package/dist/overview/content.js +172 -0
- package/dist/pages/changes.d.ts +32 -0
- package/dist/pages/changes.js +141 -0
- package/dist/pages/connection.d.ts +43 -0
- package/dist/pages/connection.js +295 -0
- package/dist/pages/deployment.d.ts +67 -0
- package/dist/pages/deployment.js +261 -0
- package/dist/pages/deployments.d.ts +46 -0
- package/dist/pages/deployments.js +266 -0
- package/dist/pages/environments.d.ts +34 -0
- package/dist/pages/environments.js +368 -0
- package/dist/pages/logs.d.ts +46 -0
- package/dist/pages/logs.js +140 -0
- package/dist/pages/navigation.d.ts +61 -0
- package/dist/pages/navigation.js +107 -0
- package/dist/pages/overview.d.ts +35 -0
- package/dist/pages/overview.js +201 -0
- package/dist/pages/project-guard.d.ts +32 -0
- package/dist/pages/project-guard.js +99 -0
- package/dist/pages/query.d.ts +6 -0
- package/dist/pages/query.js +14 -0
- package/dist/pages/resources.d.ts +37 -0
- package/dist/pages/resources.js +211 -0
- package/dist/pages/setup.d.ts +40 -0
- package/dist/pages/setup.js +271 -0
- package/dist/pages/slugs.d.ts +15 -0
- package/dist/pages/slugs.js +28 -0
- package/dist/pages/variables.d.ts +43 -0
- package/dist/pages/variables.js +327 -0
- package/dist/pages/version.d.ts +26 -0
- package/dist/pages/version.js +214 -0
- package/dist/pages/versions.d.ts +20 -0
- package/dist/pages/versions.js +115 -0
- package/dist/resources/apply.d.ts +15 -0
- package/dist/resources/apply.js +127 -0
- package/dist/resources/cards.d.ts +41 -0
- package/dist/resources/cards.js +211 -0
- package/dist/resources/connect.d.ts +66 -0
- package/dist/resources/connect.js +78 -0
- package/dist/resources/content.d.ts +26 -0
- package/dist/resources/content.js +158 -0
- package/dist/resources/format.d.ts +10 -0
- package/dist/resources/format.js +30 -0
- package/dist/resources/guard.d.ts +23 -0
- package/dist/resources/guard.js +60 -0
- package/dist/resources/modules.d.ts +23 -0
- package/dist/resources/modules.js +39 -0
- package/dist/resources/plan.d.ts +8 -0
- package/dist/resources/plan.js +93 -0
- package/dist/resources/read.d.ts +54 -0
- package/dist/resources/read.js +69 -0
- package/dist/resources/refusals.d.ts +15 -0
- package/dist/resources/refusals.js +33 -0
- package/dist/resources/routes.d.ts +32 -0
- package/dist/resources/routes.js +53 -0
- package/dist/setup/actions.d.ts +79 -0
- package/dist/setup/actions.js +188 -0
- package/dist/setup/apply.d.ts +37 -0
- package/dist/setup/apply.js +172 -0
- package/dist/setup/content.d.ts +50 -0
- package/dist/setup/content.js +440 -0
- package/dist/setup/rollout.d.ts +119 -0
- package/dist/setup/rollout.js +227 -0
- package/dist/setup/steps.d.ts +93 -0
- package/dist/setup/steps.js +95 -0
- package/dist/setup/storage.d.ts +29 -0
- package/dist/setup/storage.js +78 -0
- package/dist/setup/store.d.ts +214 -0
- package/dist/setup/store.js +174 -0
- package/dist/setup/volume.d.ts +31 -0
- package/dist/setup/volume.js +52 -0
- package/dist/slug.d.ts +7 -0
- package/dist/slug.js +26 -0
- package/dist/variables/actions.d.ts +76 -0
- package/dist/variables/actions.js +185 -0
- package/dist/variables/content.d.ts +69 -0
- package/dist/variables/content.js +310 -0
- package/dist/variables/decide.d.ts +27 -0
- package/dist/variables/decide.js +155 -0
- package/dist/variables/decided-dialog.d.ts +11 -0
- package/dist/variables/decided-dialog.js +129 -0
- package/dist/variables/decided.d.ts +80 -0
- package/dist/variables/decided.js +240 -0
- package/dist/variables/dialogs.d.ts +8 -0
- package/dist/variables/dialogs.js +219 -0
- package/dist/variables/model.d.ts +106 -0
- package/dist/variables/model.js +156 -0
- package/dist/variables/project-config.d.ts +117 -0
- package/dist/variables/project-config.js +248 -0
- package/dist/variables/read.d.ts +33 -0
- package/dist/variables/read.js +118 -0
- package/dist/web-url.d.ts +9 -0
- package/dist/web-url.js +19 -0
- package/frontend-vue/app/components/BuildLog.vue +99 -0
- package/frontend-vue/app/components/ChangedFiles.vue +165 -0
- package/frontend-vue/app/components/DashboardEnvironments.vue +102 -0
- package/frontend-vue/app/components/LogLine.vue +33 -0
- package/frontend-vue/app/components/LogViewer.vue +314 -0
- package/frontend-vue/app/components/PublishChipIcon.vue +39 -0
- package/frontend-vue/app/components/PublishForm.vue +505 -0
- package/frontend-vue/app/components/PublishPopover.vue +90 -0
- package/frontend-vue/app/components/PublishRoute.vue +222 -0
- package/frontend-vue/app/composables/usePublishSummary.ts +80 -0
- package/frontend-vue/app/plugins/publish-chip.client.ts +44 -0
- package/frontend-vue/app/types/publishing.ts +154 -0
- package/frontend-vue/app/utils/build-log.ts +96 -0
- package/frontend-vue/app/utils/changed-files.ts +142 -0
- package/frontend-vue/app/utils/log-line.ts +15 -0
- package/frontend-vue/app/utils/log-stream.ts +361 -0
- package/frontend-vue/app/utils/publish-state.ts +299 -0
- package/frontend-vue/dms.frontend.ts +27 -0
- package/frontend-vue/i18n/locales/antelope-cloud-en-GB.json +110 -0
- package/frontend-vue/package.json +38 -0
- package/frontend-vue/pnpm-lock.yaml +2697 -0
- package/package.json +115 -4
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
onBeforeUnmount,
|
|
5
|
+
onMounted,
|
|
6
|
+
ref,
|
|
7
|
+
shallowRef,
|
|
8
|
+
watch,
|
|
9
|
+
} from 'vue'
|
|
10
|
+
import type {
|
|
11
|
+
ChangesSummary,
|
|
12
|
+
PublishInput,
|
|
13
|
+
PublishJob,
|
|
14
|
+
PublishNote,
|
|
15
|
+
PublishSteps,
|
|
16
|
+
} from '../types/publishing'
|
|
17
|
+
import {
|
|
18
|
+
CLOUD_FOLLOW_MS,
|
|
19
|
+
CLOUD_POLL_MS,
|
|
20
|
+
environmentLabel,
|
|
21
|
+
environmentRoute,
|
|
22
|
+
isCloudSettled,
|
|
23
|
+
isCloudUnread,
|
|
24
|
+
isRetry,
|
|
25
|
+
pendingNotice,
|
|
26
|
+
publishHeading,
|
|
27
|
+
refusalOf,
|
|
28
|
+
RUNNING_POLL_MS,
|
|
29
|
+
} from '../utils/publish-state'
|
|
30
|
+
import PublishRoute from './PublishRoute.vue'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Publishes the working copy as a version: a commit message, an optional
|
|
34
|
+
* version name and release notes, and the environment to deploy to, with what
|
|
35
|
+
* the version adds there read from `publishNoteUrl`. A version saved locally
|
|
36
|
+
* that origin lacks shows above the form; when the next publish pushes it
|
|
37
|
+
* again, the form asks only for the environment. Submitting posts to
|
|
38
|
+
* `publishUrl`, opens the route of the job in a dialog and reads `statusUrl`
|
|
39
|
+
* until the job is over. A publish already running when the page opens is
|
|
40
|
+
* read the same way. Once such a publish pushed, the dialog follows its
|
|
41
|
+
* AntelopeJS Cloud steps from `cloudStepsUrl` until they end.
|
|
42
|
+
*/
|
|
43
|
+
const props = defineProps<{
|
|
44
|
+
summaryUrl: string
|
|
45
|
+
publishUrl: string
|
|
46
|
+
statusUrl: string
|
|
47
|
+
publishNoteUrl: string
|
|
48
|
+
cloudStepsUrl: string
|
|
49
|
+
deploymentsUrl: string
|
|
50
|
+
}>()
|
|
51
|
+
|
|
52
|
+
const MAX_POLL_FAILURES = 5
|
|
53
|
+
|
|
54
|
+
/** Why the dialog stopped following the Cloud steps before they ended. */
|
|
55
|
+
const CLOUD_LOST: Record<'unreadable' | 'timeout', string> = {
|
|
56
|
+
unreadable: 'The AntelopeJS Cloud steps could not be read.',
|
|
57
|
+
timeout: 'AntelopeJS Cloud is still deploying after 20 minutes.',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* One follow of a publish's Cloud steps. Only the current follow's answers
|
|
62
|
+
* reach the screen: a read that lands after another follow began is dropped.
|
|
63
|
+
*/
|
|
64
|
+
interface CloudFollow {
|
|
65
|
+
readonly url: string
|
|
66
|
+
readonly deadline: number
|
|
67
|
+
timer?: ReturnType<typeof setTimeout>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { $authFetch } = useAuthFetch()
|
|
71
|
+
const { data: summary, refresh: refreshSummary } =
|
|
72
|
+
useApiData<ChangesSummary | null>(() => props.summaryUrl, {
|
|
73
|
+
default: () => null,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const message = ref('')
|
|
77
|
+
const versionName = ref('')
|
|
78
|
+
const releaseNotes = ref('')
|
|
79
|
+
const chosenEnvironment = ref<string | null>(null)
|
|
80
|
+
const refusalMessage = ref<string | null>(null)
|
|
81
|
+
const isInterrupted = ref(false)
|
|
82
|
+
const job = ref<PublishJob | null>(null)
|
|
83
|
+
const isDialogOpen = ref(false)
|
|
84
|
+
const isSubmitting = ref(false)
|
|
85
|
+
const cloud = ref<PublishSteps | null>(null)
|
|
86
|
+
const follow = shallowRef<CloudFollow | null>(null)
|
|
87
|
+
const isFollowing = computed(() => follow.value !== null)
|
|
88
|
+
const cloudLost = ref<keyof typeof CLOUD_LOST | null>(null)
|
|
89
|
+
|
|
90
|
+
const environment = computed({
|
|
91
|
+
get: () =>
|
|
92
|
+
chosenEnvironment.value ?? summary.value?.environments[0]?.name ?? null,
|
|
93
|
+
set: (name: string | null) => {
|
|
94
|
+
chosenEnvironment.value = name
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
const environmentItems = computed(() =>
|
|
98
|
+
(summary.value?.environments ?? []).map((env) => ({
|
|
99
|
+
value: env.name,
|
|
100
|
+
label: env.branch,
|
|
101
|
+
description: environmentRoute(env, summary.value?.nextVersion.number ?? 0),
|
|
102
|
+
})),
|
|
103
|
+
)
|
|
104
|
+
const noteUrl = computed(() =>
|
|
105
|
+
environment.value === null
|
|
106
|
+
? null
|
|
107
|
+
: `${props.publishNoteUrl}?environment=${encodeURIComponent(environment.value)}`,
|
|
108
|
+
)
|
|
109
|
+
const { data: noteData, error: noteError } = useApiData<PublishNote | null>(
|
|
110
|
+
noteUrl,
|
|
111
|
+
{ default: () => null },
|
|
112
|
+
)
|
|
113
|
+
const note = computed(() =>
|
|
114
|
+
noteError.value || !noteData.value?.title ? null : noteData.value,
|
|
115
|
+
)
|
|
116
|
+
const isRunning = computed(() => job.value?.status === 'running')
|
|
117
|
+
const isUpToDate = computed(
|
|
118
|
+
() =>
|
|
119
|
+
summary.value?.ready === false &&
|
|
120
|
+
summary.value.refusal?.code === 'nothing_to_publish',
|
|
121
|
+
)
|
|
122
|
+
const retryTag = computed(() =>
|
|
123
|
+
summary.value && isRetry(summary.value)
|
|
124
|
+
? summary.value.nextVersion.tag
|
|
125
|
+
: null,
|
|
126
|
+
)
|
|
127
|
+
const notice = computed(() =>
|
|
128
|
+
summary.value && !isRunning.value ? pendingNotice(summary.value) : null,
|
|
129
|
+
)
|
|
130
|
+
const canSubmit = computed(
|
|
131
|
+
() =>
|
|
132
|
+
(retryTag.value !== null || message.value.trim() !== '') &&
|
|
133
|
+
environment.value !== null &&
|
|
134
|
+
!isSubmitting.value &&
|
|
135
|
+
!isRunning.value,
|
|
136
|
+
)
|
|
137
|
+
const submitLabel = computed(() => {
|
|
138
|
+
const target = environmentLabel(environment.value ?? '')
|
|
139
|
+
return retryTag.value === null
|
|
140
|
+
? `Publish to ${target}`.trim()
|
|
141
|
+
: `Push ${retryTag.value} to ${target}`.trim()
|
|
142
|
+
})
|
|
143
|
+
const versionHint = computed(() => {
|
|
144
|
+
const next = summary.value?.nextVersion.number
|
|
145
|
+
return next === undefined
|
|
146
|
+
? 'Leave empty for the default name.'
|
|
147
|
+
: `Tagged as release/v${next}. Leave empty for “Version ${next}”.`
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const heading = computed(() =>
|
|
151
|
+
job.value
|
|
152
|
+
? publishHeading(job.value, cloud.value, isFollowing.value)
|
|
153
|
+
: { title: '', description: '' },
|
|
154
|
+
)
|
|
155
|
+
const isBusy = computed(() => isRunning.value || isFollowing.value)
|
|
156
|
+
|
|
157
|
+
let pollTimer: ReturnType<typeof setTimeout> | undefined
|
|
158
|
+
let isMounted = true
|
|
159
|
+
|
|
160
|
+
onBeforeUnmount(() => {
|
|
161
|
+
isMounted = false
|
|
162
|
+
clearTimeout(pollTimer)
|
|
163
|
+
stopFollowing()
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
function stopFollowing(): void {
|
|
167
|
+
clearTimeout(follow.value?.timer)
|
|
168
|
+
follow.value = null
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The Cloud steps at `url`, or null when the read failed or AntelopeJS Cloud did not answer the DMS. */
|
|
172
|
+
async function readSteps(url: string): Promise<PublishSteps | null> {
|
|
173
|
+
try {
|
|
174
|
+
const answer = await $authFetch<PublishSteps>(url)
|
|
175
|
+
return isCloudUnread(answer) ? null : answer
|
|
176
|
+
} catch {
|
|
177
|
+
return null
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function loseCloud(why: keyof typeof CLOUD_LOST): void {
|
|
182
|
+
stopFollowing()
|
|
183
|
+
cloudLost.value = why
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function readCloud(
|
|
187
|
+
current: CloudFollow,
|
|
188
|
+
failures: number,
|
|
189
|
+
): Promise<void> {
|
|
190
|
+
const answer = await readSteps(current.url)
|
|
191
|
+
if (follow.value !== current) return
|
|
192
|
+
if (answer !== null) cloud.value = answer
|
|
193
|
+
const failed = answer === null ? failures + 1 : 0
|
|
194
|
+
if (answer !== null && isCloudSettled(answer)) {
|
|
195
|
+
stopFollowing()
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
if (failed >= MAX_POLL_FAILURES) {
|
|
199
|
+
loseCloud('unreadable')
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
if (Date.now() + CLOUD_POLL_MS > current.deadline) {
|
|
203
|
+
loseCloud('timeout')
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
current.timer = setTimeout(
|
|
207
|
+
() => void readCloud(current, failed),
|
|
208
|
+
CLOUD_POLL_MS,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function forgetCloud(): void {
|
|
213
|
+
stopFollowing()
|
|
214
|
+
cloud.value = null
|
|
215
|
+
cloudLost.value = null
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Shows a new publish, with its Cloud steps after the push until it pushes. */
|
|
219
|
+
function showNew(next: PublishJob): void {
|
|
220
|
+
forgetCloud()
|
|
221
|
+
job.value = next
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Follows the Cloud steps of a publish this form saw push its commit. */
|
|
225
|
+
function followCloud(pushed: PublishJob): void {
|
|
226
|
+
forgetCloud()
|
|
227
|
+
if (pushed.status !== 'succeeded' || pushed.commit === null) return
|
|
228
|
+
const query = new URLSearchParams({
|
|
229
|
+
environment: pushed.environment,
|
|
230
|
+
commit: pushed.commit,
|
|
231
|
+
})
|
|
232
|
+
const started: CloudFollow = {
|
|
233
|
+
url: `${props.cloudStepsUrl}?${query.toString()}`,
|
|
234
|
+
deadline: Date.now() + CLOUD_FOLLOW_MS,
|
|
235
|
+
}
|
|
236
|
+
follow.value = started
|
|
237
|
+
void readCloud(started, 0)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function buildInput(name: string): PublishInput {
|
|
241
|
+
if (retryTag.value !== null) return { environment: name }
|
|
242
|
+
const input: PublishInput = {
|
|
243
|
+
message: message.value.trim(),
|
|
244
|
+
environment: name,
|
|
245
|
+
}
|
|
246
|
+
if (versionName.value.trim() !== '')
|
|
247
|
+
input.versionName = versionName.value.trim()
|
|
248
|
+
if (releaseNotes.value.trim() !== '')
|
|
249
|
+
input.releaseNotes = releaseNotes.value.trim()
|
|
250
|
+
return input
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async function finish(): Promise<void> {
|
|
254
|
+
if (job.value?.status === 'succeeded') {
|
|
255
|
+
message.value = ''
|
|
256
|
+
versionName.value = ''
|
|
257
|
+
releaseNotes.value = ''
|
|
258
|
+
}
|
|
259
|
+
if (job.value) followCloud(job.value)
|
|
260
|
+
await refreshPageBlocks()
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async function readJob(): Promise<PublishJob | null> {
|
|
264
|
+
const answer = await $authFetch<{ job: PublishJob | null }>(props.statusUrl)
|
|
265
|
+
return answer.job
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function schedulePoll(failures: number): void {
|
|
269
|
+
pollTimer = setTimeout(() => void poll(failures), RUNNING_POLL_MS)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function interrupt(): Promise<void> {
|
|
273
|
+
job.value = null
|
|
274
|
+
isDialogOpen.value = false
|
|
275
|
+
isInterrupted.value = true
|
|
276
|
+
await refreshPageBlocks()
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function poll(failures: number): Promise<void> {
|
|
280
|
+
if (!isMounted) return
|
|
281
|
+
try {
|
|
282
|
+
const latest = await readJob()
|
|
283
|
+
if (!isMounted) return
|
|
284
|
+
if (latest === null) {
|
|
285
|
+
await interrupt()
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
job.value = latest
|
|
289
|
+
if (latest.status === 'running') schedulePoll(0)
|
|
290
|
+
else await finish()
|
|
291
|
+
} catch {
|
|
292
|
+
if (failures + 1 < MAX_POLL_FAILURES) schedulePoll(failures + 1)
|
|
293
|
+
else
|
|
294
|
+
refusalMessage.value =
|
|
295
|
+
'Lost track of the publish. Reload the page to see where it stands.'
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function adopt(latest: PublishJob | null | undefined): void {
|
|
300
|
+
if (latest?.status !== 'running' || isRunning.value) return
|
|
301
|
+
showNew(latest)
|
|
302
|
+
isInterrupted.value = false
|
|
303
|
+
schedulePoll(0)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
onMounted(() => adopt(summary.value?.job))
|
|
307
|
+
watch(() => summary.value?.job, adopt)
|
|
308
|
+
|
|
309
|
+
async function submit(): Promise<void> {
|
|
310
|
+
const name = environment.value
|
|
311
|
+
if (!canSubmit.value || name === null) return
|
|
312
|
+
isSubmitting.value = true
|
|
313
|
+
refusalMessage.value = null
|
|
314
|
+
isInterrupted.value = false
|
|
315
|
+
stopFollowing()
|
|
316
|
+
try {
|
|
317
|
+
const answer = await $authFetch<{ job: PublishJob }>(props.publishUrl, {
|
|
318
|
+
method: 'POST',
|
|
319
|
+
body: buildInput(name),
|
|
320
|
+
})
|
|
321
|
+
showNew(answer.job)
|
|
322
|
+
isDialogOpen.value = true
|
|
323
|
+
if (answer.job.status === 'running') schedulePoll(0)
|
|
324
|
+
else await finish()
|
|
325
|
+
} catch (error) {
|
|
326
|
+
refusalMessage.value =
|
|
327
|
+
refusalOf(error)?.message ?? 'The publish request failed. Try again.'
|
|
328
|
+
await refreshSummary()
|
|
329
|
+
} finally {
|
|
330
|
+
isSubmitting.value = false
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
</script>
|
|
334
|
+
|
|
335
|
+
<template>
|
|
336
|
+
<div class="flex min-w-0 flex-col gap-4 text-sm">
|
|
337
|
+
<UAlert
|
|
338
|
+
v-if="notice"
|
|
339
|
+
color="warning"
|
|
340
|
+
variant="subtle"
|
|
341
|
+
icon="i-ph-cloud-slash-light"
|
|
342
|
+
:title="notice.title"
|
|
343
|
+
:description="notice.description"
|
|
344
|
+
data-testid="publish-pending"
|
|
345
|
+
/>
|
|
346
|
+
<UAlert
|
|
347
|
+
v-if="isInterrupted"
|
|
348
|
+
color="warning"
|
|
349
|
+
variant="subtle"
|
|
350
|
+
icon="i-ph-warning-circle-light"
|
|
351
|
+
title="The publish was interrupted. Check Versions before publishing again."
|
|
352
|
+
data-testid="publish-interrupted"
|
|
353
|
+
/>
|
|
354
|
+
<p
|
|
355
|
+
v-if="isUpToDate"
|
|
356
|
+
class="text-muted m-0"
|
|
357
|
+
data-testid="publish-up-to-date"
|
|
358
|
+
>
|
|
359
|
+
Everything is published. Edits you make appear here.
|
|
360
|
+
</p>
|
|
361
|
+
<UAlert
|
|
362
|
+
v-else-if="summary && !summary.ready && summary.refusal"
|
|
363
|
+
color="warning"
|
|
364
|
+
variant="subtle"
|
|
365
|
+
icon="i-ph-warning-circle-light"
|
|
366
|
+
:title="summary.refusal.message"
|
|
367
|
+
data-testid="publish-not-ready"
|
|
368
|
+
/>
|
|
369
|
+
<form
|
|
370
|
+
v-else-if="summary"
|
|
371
|
+
class="flex flex-col gap-4"
|
|
372
|
+
@submit.prevent="submit"
|
|
373
|
+
>
|
|
374
|
+
<p v-if="retryTag" class="text-muted m-0" data-testid="publish-retry">
|
|
375
|
+
Publishing again pushes {{ retryTag }} as it was made.
|
|
376
|
+
</p>
|
|
377
|
+
<template v-else>
|
|
378
|
+
<UFormField label="Commit message" required>
|
|
379
|
+
<UInput
|
|
380
|
+
v-model="message"
|
|
381
|
+
class="w-full"
|
|
382
|
+
icon="i-ph-git-commit-light"
|
|
383
|
+
:maxlength="500"
|
|
384
|
+
data-testid="publish-message"
|
|
385
|
+
/>
|
|
386
|
+
</UFormField>
|
|
387
|
+
<UFormField label="Version name" :hint="versionHint">
|
|
388
|
+
<UInput
|
|
389
|
+
v-model="versionName"
|
|
390
|
+
class="w-full"
|
|
391
|
+
:maxlength="120"
|
|
392
|
+
data-testid="publish-version-name"
|
|
393
|
+
/>
|
|
394
|
+
</UFormField>
|
|
395
|
+
<UFormField label="Release notes" hint="optional">
|
|
396
|
+
<UTextarea
|
|
397
|
+
v-model="releaseNotes"
|
|
398
|
+
class="w-full"
|
|
399
|
+
:rows="2"
|
|
400
|
+
:maxlength="5000"
|
|
401
|
+
placeholder="What changes for your team or customers…"
|
|
402
|
+
data-testid="publish-release-notes"
|
|
403
|
+
/>
|
|
404
|
+
</UFormField>
|
|
405
|
+
</template>
|
|
406
|
+
<UAlert
|
|
407
|
+
v-if="note"
|
|
408
|
+
:color="note.tone === 'warning' ? 'warning' : 'info'"
|
|
409
|
+
variant="subtle"
|
|
410
|
+
:icon="note.icon ?? 'i-ph-cube'"
|
|
411
|
+
:title="note.title"
|
|
412
|
+
data-testid="publish-note"
|
|
413
|
+
>
|
|
414
|
+
<template #description>
|
|
415
|
+
<p class="m-0">{{ note.description }}</p>
|
|
416
|
+
<DmsLink
|
|
417
|
+
v-for="action in note.actions?.filter((one) => one.to)"
|
|
418
|
+
:key="action.label"
|
|
419
|
+
:to="action.to"
|
|
420
|
+
class="text-primary mt-1 inline-flex items-center gap-1 text-[12.5px] font-medium"
|
|
421
|
+
data-testid="publish-note-action"
|
|
422
|
+
>
|
|
423
|
+
{{ action.label }}
|
|
424
|
+
<UIcon name="i-ph-arrow-right-light" class="size-3.5" />
|
|
425
|
+
</DmsLink>
|
|
426
|
+
</template>
|
|
427
|
+
</UAlert>
|
|
428
|
+
<UFormField label="Deploy to">
|
|
429
|
+
<URadioGroup
|
|
430
|
+
v-model="environment"
|
|
431
|
+
:items="environmentItems"
|
|
432
|
+
value-key="value"
|
|
433
|
+
/>
|
|
434
|
+
</UFormField>
|
|
435
|
+
<UAlert
|
|
436
|
+
v-if="refusalMessage"
|
|
437
|
+
color="error"
|
|
438
|
+
variant="subtle"
|
|
439
|
+
icon="i-ph-warning-circle-light"
|
|
440
|
+
:title="refusalMessage"
|
|
441
|
+
data-testid="publish-refusal"
|
|
442
|
+
/>
|
|
443
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
444
|
+
<UButton
|
|
445
|
+
type="submit"
|
|
446
|
+
icon="i-ph-rocket-launch-light"
|
|
447
|
+
:label="submitLabel"
|
|
448
|
+
:disabled="!canSubmit"
|
|
449
|
+
:loading="isSubmitting"
|
|
450
|
+
data-testid="publish-submit"
|
|
451
|
+
/>
|
|
452
|
+
<UButton
|
|
453
|
+
v-if="job && !isDialogOpen"
|
|
454
|
+
color="neutral"
|
|
455
|
+
variant="ghost"
|
|
456
|
+
icon="i-ph-list-checks-light"
|
|
457
|
+
:label="isBusy ? 'Show progress' : 'Show last publish'"
|
|
458
|
+
data-testid="publish-show"
|
|
459
|
+
@click="isDialogOpen = true"
|
|
460
|
+
/>
|
|
461
|
+
</div>
|
|
462
|
+
</form>
|
|
463
|
+
|
|
464
|
+
<UModal
|
|
465
|
+
v-model:open="isDialogOpen"
|
|
466
|
+
:title="heading.title"
|
|
467
|
+
:description="heading.description"
|
|
468
|
+
>
|
|
469
|
+
<template #body>
|
|
470
|
+
<div class="flex flex-col gap-3">
|
|
471
|
+
<PublishRoute v-if="job" :job="job" :cloud="cloud" />
|
|
472
|
+
<UAlert
|
|
473
|
+
v-if="cloudLost"
|
|
474
|
+
color="warning"
|
|
475
|
+
variant="subtle"
|
|
476
|
+
icon="i-ph-cloud-slash-light"
|
|
477
|
+
:title="CLOUD_LOST[cloudLost]"
|
|
478
|
+
data-testid="publish-cloud-lost"
|
|
479
|
+
>
|
|
480
|
+
<template #description>
|
|
481
|
+
<DmsLink
|
|
482
|
+
:to="props.deploymentsUrl"
|
|
483
|
+
class="text-primary inline-flex items-center gap-1 text-[12.5px] font-medium"
|
|
484
|
+
data-testid="publish-cloud-deployments"
|
|
485
|
+
>
|
|
486
|
+
Follow it on Deployments
|
|
487
|
+
<UIcon name="i-ph-arrow-right-light" class="size-3.5" />
|
|
488
|
+
</DmsLink>
|
|
489
|
+
</template>
|
|
490
|
+
</UAlert>
|
|
491
|
+
</div>
|
|
492
|
+
</template>
|
|
493
|
+
<template #footer>
|
|
494
|
+
<div class="flex w-full items-center justify-end gap-2">
|
|
495
|
+
<UButton
|
|
496
|
+
color="neutral"
|
|
497
|
+
variant="outline"
|
|
498
|
+
:label="isBusy ? 'Run in background' : 'Close'"
|
|
499
|
+
@click="isDialogOpen = false"
|
|
500
|
+
/>
|
|
501
|
+
</div>
|
|
502
|
+
</template>
|
|
503
|
+
</UModal>
|
|
504
|
+
</div>
|
|
505
|
+
</template>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { usePublishSummary } from '../composables/usePublishSummary'
|
|
4
|
+
import {
|
|
5
|
+
CHANGES_PAGE_PATH,
|
|
6
|
+
environmentLabel,
|
|
7
|
+
pendingNotice,
|
|
8
|
+
} from '../utils/publish-state'
|
|
9
|
+
import ChangedFiles from './ChangedFiles.vue'
|
|
10
|
+
import PublishRoute from './PublishRoute.vue'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The body of the publish side panel: what would ship, the environment it
|
|
14
|
+
* would go to, the first files, a link to review and publish, the route of
|
|
15
|
+
* the publish while one runs or after one failed, and a version saved locally
|
|
16
|
+
* that origin lacks.
|
|
17
|
+
*/
|
|
18
|
+
const PREVIEW_LIMIT = 3
|
|
19
|
+
|
|
20
|
+
const { summary, count } = usePublishSummary()
|
|
21
|
+
|
|
22
|
+
const job = computed(() => {
|
|
23
|
+
const latest = summary.value?.job
|
|
24
|
+
return latest && latest.status !== 'succeeded' ? latest : null
|
|
25
|
+
})
|
|
26
|
+
const target = computed(() => summary.value?.environments[0] ?? null)
|
|
27
|
+
const notice = computed(() =>
|
|
28
|
+
summary.value ? pendingNotice(summary.value) : null,
|
|
29
|
+
)
|
|
30
|
+
const heading = computed(
|
|
31
|
+
() => `${count.value} ${count.value === 1 ? 'change' : 'changes'}`,
|
|
32
|
+
)
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div
|
|
37
|
+
v-if="summary"
|
|
38
|
+
class="flex min-h-0 flex-col gap-4 overflow-y-auto p-4 text-sm"
|
|
39
|
+
>
|
|
40
|
+
<div class="flex flex-col gap-1">
|
|
41
|
+
<h3
|
|
42
|
+
class="text-highlighted flex items-center gap-2 text-base font-semibold"
|
|
43
|
+
>
|
|
44
|
+
<UIcon name="i-ph-rocket-launch-light" class="size-4 shrink-0" />
|
|
45
|
+
<span data-testid="popover-heading">{{ heading }}</span>
|
|
46
|
+
<span
|
|
47
|
+
v-if="summary.branch"
|
|
48
|
+
class="text-muted font-mono text-xs font-normal"
|
|
49
|
+
>
|
|
50
|
+
on {{ summary.branch }}
|
|
51
|
+
</span>
|
|
52
|
+
</h3>
|
|
53
|
+
<p
|
|
54
|
+
v-if="target"
|
|
55
|
+
class="text-muted m-0 text-xs"
|
|
56
|
+
data-testid="popover-target"
|
|
57
|
+
>
|
|
58
|
+
Publishes to {{ environmentLabel(target.name) }}
|
|
59
|
+
<span class="font-mono">{{ target.branch }}</span>
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<PublishRoute v-if="job" :job="job" :cloud="null" />
|
|
64
|
+
|
|
65
|
+
<UAlert
|
|
66
|
+
v-if="notice"
|
|
67
|
+
color="warning"
|
|
68
|
+
variant="subtle"
|
|
69
|
+
icon="i-ph-cloud-slash-light"
|
|
70
|
+
:title="notice.title"
|
|
71
|
+
:description="notice.description"
|
|
72
|
+
data-testid="popover-pending"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
<ChangedFiles
|
|
76
|
+
:files="summary.files"
|
|
77
|
+
:limit="PREVIEW_LIMIT"
|
|
78
|
+
:review-href="CHANGES_PAGE_PATH"
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<DmsLink
|
|
82
|
+
:to="CHANGES_PAGE_PATH"
|
|
83
|
+
class="text-primary inline-flex items-center gap-1 text-[12.5px] font-medium"
|
|
84
|
+
data-testid="popover-review"
|
|
85
|
+
>
|
|
86
|
+
Review and publish
|
|
87
|
+
<UIcon name="i-ph-arrow-right-light" class="size-3.5" />
|
|
88
|
+
</DmsLink>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|