@glash/cli 0.2.24 → 0.2.26
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/commands/deploy.mjs +28 -5
- package/package.json +1 -1
package/commands/deploy.mjs
CHANGED
|
@@ -63,8 +63,9 @@ async function resolveProjectId(flags) {
|
|
|
63
63
|
throw err;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
} else if (confirm.toLowerCase()
|
|
67
|
-
|
|
66
|
+
} else if (['n', 'no'].includes(confirm.toLowerCase())) {
|
|
67
|
+
info('Okay, let\'s create a new project instead.');
|
|
68
|
+
return createNewProjectFromCurrentDirectory();
|
|
68
69
|
} else {
|
|
69
70
|
// If they chose 'select' / 's', let them pick from existing projects
|
|
70
71
|
const list = await apiGet('/projects');
|
|
@@ -108,7 +109,11 @@ async function resolveProjectId(flags) {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
return createNewProjectFromCurrentDirectory();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function createNewProjectFromCurrentDirectory() {
|
|
116
|
+
const dirName = basename(process.cwd());
|
|
112
117
|
const name = (await prompt(`What's your project's name? [${dirName}] `)) || dirName;
|
|
113
118
|
const slug = name.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
114
119
|
|
|
@@ -221,13 +226,16 @@ export async function deploy({ flags }) {
|
|
|
221
226
|
|
|
222
227
|
const status = pipe.deployStatus ?? pipe.buildStatus ?? '';
|
|
223
228
|
if (['ready', 'live', 'success'].includes(status)) {
|
|
224
|
-
indicator.stop();
|
|
225
229
|
const url = pipe.hostings?.[0]?.domains?.[0]?.domain;
|
|
226
230
|
if (url) {
|
|
227
|
-
|
|
231
|
+
indicator.setPhase('checking');
|
|
232
|
+
const problem = await waitForLiveUrlProblem(`https://${url.replace(/^https?:\/\//, '')}`);
|
|
233
|
+
indicator.stop();
|
|
228
234
|
if (problem) {
|
|
229
235
|
return fail(`Deployment finished, but the hostname is still not serving your app: ${problem}. Run \`glash logs ${dep.id}\` for details.`);
|
|
230
236
|
}
|
|
237
|
+
} else {
|
|
238
|
+
indicator.stop();
|
|
231
239
|
}
|
|
232
240
|
printDeploySuccess({ url, envSummary });
|
|
233
241
|
return;
|
|
@@ -393,6 +401,21 @@ async function detectLiveUrlProblem(url) {
|
|
|
393
401
|
}
|
|
394
402
|
}
|
|
395
403
|
|
|
404
|
+
async function waitForLiveUrlProblem(url, { timeoutMs = 90_000, intervalMs = 5000 } = {}) {
|
|
405
|
+
const deadline = Date.now() + timeoutMs;
|
|
406
|
+
let problem = '';
|
|
407
|
+
while (Date.now() < deadline) {
|
|
408
|
+
problem = await detectLiveUrlProblem(url);
|
|
409
|
+
if (!problem || !isTransientLiveUrlProblem(problem)) return problem;
|
|
410
|
+
await sleep(intervalMs);
|
|
411
|
+
}
|
|
412
|
+
return problem;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function isTransientLiveUrlProblem(problem) {
|
|
416
|
+
return /no nginx route|parked page|HTTP 5\d\d|live URL check failed/i.test(problem);
|
|
417
|
+
}
|
|
418
|
+
|
|
396
419
|
function printDeploySuccess({ url, envSummary }) {
|
|
397
420
|
const liveUrl = url ? `https://${url.replace(/^https?:\/\//, '')}` : '';
|
|
398
421
|
if (liveUrl) info(`Live: ${terminalLink(liveUrl)}`);
|
package/package.json
CHANGED