@glash/cli 0.2.40 → 0.2.42
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 +30 -31
- package/lib/project-build.mjs +7 -1
- package/lib/zip.mjs +9 -0
- package/package.json +1 -1
package/commands/deploy.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import fg from 'fast-glob';
|
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
7
|
import { zipDirectory } from '../lib/zip.mjs';
|
|
8
|
-
import { buildProjectBeforeDeploy
|
|
8
|
+
import { buildProjectBeforeDeploy } from '../lib/project-build.mjs';
|
|
9
9
|
import { join, basename, extname } from 'node:path';
|
|
10
10
|
import { tmpdir } from 'node:os';
|
|
11
11
|
import { createReadStream, openAsBlob } from 'node:fs';
|
|
@@ -182,13 +182,7 @@ export async function deploy({ flags }) {
|
|
|
182
182
|
localBuild = await buildProjectBeforeDeploy(process.cwd(), {
|
|
183
183
|
packageJson: projectProfile.runtime?.pkg,
|
|
184
184
|
skip: Boolean(flags['no-build']) || process.env.GLASH_CLI_BUILD_RUNNING === '1',
|
|
185
|
-
onStart: (
|
|
186
|
-
indicator.setPhase('prebuilding', `Building project (${plan.displayCommand})`);
|
|
187
|
-
},
|
|
188
|
-
onLine: ({ line }) => {
|
|
189
|
-
const detail = compactBuildOutputLine(line);
|
|
190
|
-
if (detail) indicator.setDetail(`Building project — ${detail}`);
|
|
191
|
-
},
|
|
185
|
+
onStart: () => indicator.setPhase('prebuilding'),
|
|
192
186
|
});
|
|
193
187
|
report.localBuild = localBuild;
|
|
194
188
|
} catch (e) {
|
|
@@ -197,7 +191,7 @@ export async function deploy({ flags }) {
|
|
|
197
191
|
command: e.buildPlan?.displayCommand || '',
|
|
198
192
|
};
|
|
199
193
|
report.localBuild = localBuild;
|
|
200
|
-
indicator.fail('failed'
|
|
194
|
+
indicator.fail('failed');
|
|
201
195
|
printBuildFailureOutput(e.buildOutput);
|
|
202
196
|
printDeployReport({ ...report, status: 'failed', error: `Project build failed: ${e.message}` });
|
|
203
197
|
return fail(`Project build failed: ${e.message}`);
|
|
@@ -1443,7 +1437,7 @@ function createDeployIndicator() {
|
|
|
1443
1437
|
function updateProgress(nextProgress, nextPhase = phase, nextDetail) {
|
|
1444
1438
|
const bounded = Math.max(0, Math.min(100, Number(nextProgress) || 0));
|
|
1445
1439
|
const advanced = Math.max(progress, bounded);
|
|
1446
|
-
const resolvedDetail = nextDetail || (nextPhase !== phase ? detailFromPhase(nextPhase) : detail);
|
|
1440
|
+
const resolvedDetail = twoWordAction(nextDetail || (nextPhase !== phase ? detailFromPhase(nextPhase) : detail));
|
|
1447
1441
|
const changed = nextPhase !== phase || advanced !== progress || resolvedDetail !== detail;
|
|
1448
1442
|
phase = nextPhase;
|
|
1449
1443
|
progress = advanced;
|
|
@@ -1469,7 +1463,7 @@ function createDeployIndicator() {
|
|
|
1469
1463
|
updateProgress(nextProgress, nextPhase, nextDetail);
|
|
1470
1464
|
},
|
|
1471
1465
|
setDetail(nextDetail) {
|
|
1472
|
-
const value =
|
|
1466
|
+
const value = twoWordAction(nextDetail);
|
|
1473
1467
|
if (!value || value === detail) return;
|
|
1474
1468
|
detail = value;
|
|
1475
1469
|
render();
|
|
@@ -1477,7 +1471,7 @@ function createDeployIndicator() {
|
|
|
1477
1471
|
finish(finalPhase = 'complete', finalDetail = detailFromPhase(finalPhase)) {
|
|
1478
1472
|
stopTimer();
|
|
1479
1473
|
phase = finalPhase;
|
|
1480
|
-
detail = finalDetail;
|
|
1474
|
+
detail = twoWordAction(finalDetail);
|
|
1481
1475
|
progress = 100;
|
|
1482
1476
|
render({ force: true });
|
|
1483
1477
|
if (interactive) stdout.write('\n');
|
|
@@ -1485,7 +1479,7 @@ function createDeployIndicator() {
|
|
|
1485
1479
|
fail(finalPhase = 'failed', finalDetail = detailFromPhase(finalPhase)) {
|
|
1486
1480
|
stopTimer();
|
|
1487
1481
|
phase = finalPhase;
|
|
1488
|
-
detail = finalDetail;
|
|
1482
|
+
detail = twoWordAction(finalDetail);
|
|
1489
1483
|
render({ force: true });
|
|
1490
1484
|
if (interactive) stdout.write('\n');
|
|
1491
1485
|
},
|
|
@@ -1500,27 +1494,32 @@ function createDeployIndicator() {
|
|
|
1500
1494
|
};
|
|
1501
1495
|
}
|
|
1502
1496
|
|
|
1497
|
+
function twoWordAction(value) {
|
|
1498
|
+
const words = String(value || '').trim().split(/\s+/).filter(Boolean);
|
|
1499
|
+
return words.length >= 2 ? words.slice(0, 2).join(' ') : (words[0] ? `${words[0]} Now` : 'Working Now');
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1503
1502
|
function detailFromPhase(phase) {
|
|
1504
1503
|
const details = {
|
|
1505
|
-
doing: 'Preparing
|
|
1506
|
-
prebuilding: 'Building
|
|
1507
|
-
syncing: 'Syncing
|
|
1508
|
-
assets: 'Preparing
|
|
1509
|
-
packaging: 'Packaging
|
|
1510
|
-
uploading: 'Uploading
|
|
1511
|
-
glashing: 'Uploading
|
|
1512
|
-
hatching: 'Waiting
|
|
1513
|
-
waiting: 'Waiting
|
|
1514
|
-
building: 'Building
|
|
1515
|
-
deploying: 'Deploying
|
|
1516
|
-
routing: 'Configuring
|
|
1517
|
-
checking: 'Checking
|
|
1518
|
-
complete: 'Deployment
|
|
1519
|
-
queued: 'Deployment
|
|
1520
|
-
failed: 'Deployment
|
|
1521
|
-
'timed out': 'Deployment
|
|
1504
|
+
doing: 'Preparing Deploy',
|
|
1505
|
+
prebuilding: 'Building Project',
|
|
1506
|
+
syncing: 'Syncing Environment',
|
|
1507
|
+
assets: 'Preparing Assets',
|
|
1508
|
+
packaging: 'Packaging Source',
|
|
1509
|
+
uploading: 'Uploading Chunks',
|
|
1510
|
+
glashing: 'Uploading Bundle',
|
|
1511
|
+
hatching: 'Waiting Worker',
|
|
1512
|
+
waiting: 'Waiting Updates',
|
|
1513
|
+
building: 'Building Project',
|
|
1514
|
+
deploying: 'Deploying App',
|
|
1515
|
+
routing: 'Configuring Routing',
|
|
1516
|
+
checking: 'Checking Deployment',
|
|
1517
|
+
complete: 'Deployment Complete',
|
|
1518
|
+
queued: 'Deployment Queued',
|
|
1519
|
+
failed: 'Deployment Failed',
|
|
1520
|
+
'timed out': 'Deployment Timeout',
|
|
1522
1521
|
};
|
|
1523
|
-
return details[phase] ||
|
|
1522
|
+
return details[phase] || 'Working Now';
|
|
1524
1523
|
}
|
|
1525
1524
|
|
|
1526
1525
|
function progressFromPhase(phase) {
|
package/lib/project-build.mjs
CHANGED
|
@@ -63,9 +63,15 @@ export async function buildProjectBeforeDeploy(cwd, {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
await new Promise((resolve, reject) => {
|
|
66
|
+
// Build scripts are arbitrary project code. Do not hand them Glash control
|
|
67
|
+
// plane or package-publishing credentials inherited by the CLI process.
|
|
68
|
+
const buildEnv = { ...env, GLASH_CLI_BUILD_RUNNING: '1' };
|
|
69
|
+
for (const key of ['GLASH_TOKEN', 'GLASH_API_TOKEN', 'NPM_TOKEN', 'NODE_AUTH_TOKEN']) {
|
|
70
|
+
delete buildEnv[key];
|
|
71
|
+
}
|
|
66
72
|
const child = spawnImpl(plan.command, plan.args, {
|
|
67
73
|
cwd,
|
|
68
|
-
env:
|
|
74
|
+
env: buildEnv,
|
|
69
75
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
70
76
|
});
|
|
71
77
|
|
package/lib/zip.mjs
CHANGED
|
@@ -72,6 +72,15 @@ export async function zipDirectory(sourceDir, outPath, { ignore = [], includeGla
|
|
|
72
72
|
'**/.env.production',
|
|
73
73
|
'.env.development',
|
|
74
74
|
'**/.env.development',
|
|
75
|
+
'.env.*',
|
|
76
|
+
'**/.env.*',
|
|
77
|
+
'.npmrc',
|
|
78
|
+
'**/.npmrc',
|
|
79
|
+
'**/credentials*.json',
|
|
80
|
+
'**/*service-account*.json',
|
|
81
|
+
'**/*.pem',
|
|
82
|
+
'**/*.key',
|
|
83
|
+
'**/.ssh/**',
|
|
75
84
|
];
|
|
76
85
|
const allIgnore = [...new Set([...defaultIgnore, ...loadIgnorePatterns(sourceDir), ...ignore])];
|
|
77
86
|
const overridePaths = new Set(Object.keys(overrides));
|
package/package.json
CHANGED