@yolo-labs/yolo-cli 0.40.0 → 0.42.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/dist/deploy-ship.js +128 -0
- package/package.json +1 -1
package/dist/deploy-ship.js
CHANGED
|
@@ -44,6 +44,7 @@ export async function runDeployShip(options) {
|
|
|
44
44
|
const runBuild = deps.runBuildImpl ?? defaultRunBuild;
|
|
45
45
|
const readAssetFile = deps.readAssetFileImpl ?? defaultReadAssetFile;
|
|
46
46
|
const resolveGitSha = deps.resolveGitShaImpl ?? defaultResolveGitSha;
|
|
47
|
+
const resolveRepoOrigin = deps.resolveRepoOriginImpl ?? defaultResolveRepoOrigin;
|
|
47
48
|
// 1. Link — .yolo/deploy.json with a projectId is the durable bond.
|
|
48
49
|
const readResult = readConfig(cwd);
|
|
49
50
|
if (!readResult.ok) {
|
|
@@ -210,6 +211,17 @@ export async function runDeployShip(options) {
|
|
|
210
211
|
const gitSha = resolveGitSha(cwd);
|
|
211
212
|
if (gitSha)
|
|
212
213
|
request.gitSha = gitSha;
|
|
214
|
+
// The source repo these exact bytes were built from. This is the only place
|
|
215
|
+
// in the system that can know it — the server sees a bundle, and the owning
|
|
216
|
+
// workspace may be gone by the time anyone asks. Best-effort in the same
|
|
217
|
+
// shape as gitSha: a non-git directory or a remote-less checkout just ships
|
|
218
|
+
// without it. The server re-normalizes and strips credentials; never assume
|
|
219
|
+
// this string is safe to store as sent.
|
|
220
|
+
const origin = resolveRepoOrigin(cwd);
|
|
221
|
+
if (origin.repoUrl)
|
|
222
|
+
request.repoUrl = origin.repoUrl;
|
|
223
|
+
if (origin.branch)
|
|
224
|
+
request.branch = origin.branch;
|
|
213
225
|
const started = await startShipLeg(ctx, projectId, request);
|
|
214
226
|
if (!started.ok)
|
|
215
227
|
return clientFail(started);
|
|
@@ -296,6 +308,11 @@ export async function runDeployShip(options) {
|
|
|
296
308
|
const bootCheck = parseBootCheck(finalized.value.bootCheck);
|
|
297
309
|
if (bootCheck)
|
|
298
310
|
progress(`deploy: warn — deployed Worker failed to boot (HTTP ${bootCheck.status})`);
|
|
311
|
+
const pageCheck = parsePageCheck(finalized.value.pageCheck);
|
|
312
|
+
if (pageCheckHasProblems(pageCheck)) {
|
|
313
|
+
for (const line of pageCheckLines(pageCheck))
|
|
314
|
+
progress(line);
|
|
315
|
+
}
|
|
299
316
|
return {
|
|
300
317
|
ok: true,
|
|
301
318
|
dryRun: false,
|
|
@@ -304,6 +321,7 @@ export async function runDeployShip(options) {
|
|
|
304
321
|
releaseId: finalized.value.releaseId,
|
|
305
322
|
url: finalized.value.url,
|
|
306
323
|
...(bootCheck ? { bootCheck } : {}),
|
|
324
|
+
...(pageCheck ? { pageCheck } : {}),
|
|
307
325
|
};
|
|
308
326
|
}
|
|
309
327
|
/**
|
|
@@ -328,6 +346,11 @@ async function resumeStagedShip(ctx, resume, io) {
|
|
|
328
346
|
const bootCheck = parseBootCheck(finalized.value.bootCheck);
|
|
329
347
|
if (bootCheck)
|
|
330
348
|
progress(`deploy: warn — deployed Worker failed to boot (HTTP ${bootCheck.status})`);
|
|
349
|
+
const pageCheck = parsePageCheck(finalized.value.pageCheck);
|
|
350
|
+
if (pageCheckHasProblems(pageCheck)) {
|
|
351
|
+
for (const line of pageCheckLines(pageCheck))
|
|
352
|
+
progress(line);
|
|
353
|
+
}
|
|
331
354
|
return {
|
|
332
355
|
ok: true,
|
|
333
356
|
dryRun: false,
|
|
@@ -343,6 +366,10 @@ async function resumeStagedShip(ctx, resume, io) {
|
|
|
343
366
|
releaseId: finalized.value.releaseId,
|
|
344
367
|
url: finalized.value.url,
|
|
345
368
|
...(bootCheck ? { bootCheck } : {}),
|
|
369
|
+
// Must be on the RESULT, not only the progress line: under --json the
|
|
370
|
+
// warning goes to stderr and the structured verdict + samples would
|
|
371
|
+
// otherwise be lost entirely for a resumed (approval-parked) ship.
|
|
372
|
+
...(pageCheck ? { pageCheck } : {}),
|
|
346
373
|
};
|
|
347
374
|
}
|
|
348
375
|
// Still parked: the grant hasn't landed yet (approval-pending), or the
|
|
@@ -425,6 +452,71 @@ function parseBootCheck(raw) {
|
|
|
425
452
|
return undefined;
|
|
426
453
|
return { status: r.status, detail: r.detail };
|
|
427
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* True when the page check found something worth a warning line. Mirrors
|
|
457
|
+
* `pageCheckHasProblems` in common-api — a 5xx document is a failure in its own
|
|
458
|
+
* right, not just a source of console noise.
|
|
459
|
+
*
|
|
460
|
+
* Takes `undefined` deliberately: absence means NOT CHECKED, so it returns
|
|
461
|
+
* false and the CLI stays silent rather than printing a reassuring line.
|
|
462
|
+
*/
|
|
463
|
+
function pageCheckHasProblems(p) {
|
|
464
|
+
if (!p)
|
|
465
|
+
return false;
|
|
466
|
+
return p.consoleErrors > 0 || p.failedRequests > 0 || (!!p.httpStatus && p.httpStatus >= 500);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* The warn line PLUS the captured samples.
|
|
470
|
+
*
|
|
471
|
+
* Counts alone are not actionable: "23 console errors" does not tell anyone the
|
|
472
|
+
* allow-list is missing `x-cart-token`, and finalize cannot be safely re-run
|
|
473
|
+
* just to get `--json`, so whatever the human path omits here is lost for good.
|
|
474
|
+
* The samples are already bounded and truncated server-side.
|
|
475
|
+
*/
|
|
476
|
+
function pageCheckLines(p) {
|
|
477
|
+
const lines = [`deploy: warn — ${describeCliPageCheck(p)}`];
|
|
478
|
+
for (const sample of p.samples ?? [])
|
|
479
|
+
lines.push(`deploy: ${sample}`);
|
|
480
|
+
return lines;
|
|
481
|
+
}
|
|
482
|
+
/** One-line human summary for the warn output. */
|
|
483
|
+
function describeCliPageCheck(p) {
|
|
484
|
+
const parts = [];
|
|
485
|
+
if (p.httpStatus && p.httpStatus >= 500)
|
|
486
|
+
parts.push(`the page returned HTTP ${p.httpStatus}`);
|
|
487
|
+
if (p.consoleErrors > 0)
|
|
488
|
+
parts.push(`${p.consoleErrors} console error(s)`);
|
|
489
|
+
if (p.failedRequests > 0)
|
|
490
|
+
parts.push(`${p.failedRequests} failed request(s)`);
|
|
491
|
+
// Name the URL actually checked. A clean-or-dirty verdict about the PREVIEW
|
|
492
|
+
// origin must not be read as one about production — origin-exact CORS is
|
|
493
|
+
// exactly the failure class this check exists for.
|
|
494
|
+
const where = p.url ? ` on ${p.url}` : '';
|
|
495
|
+
return `page check${where}: ${parts.join(', ')}`;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Narrow the backend's optional `pageCheck` envelope; ignore anything malformed.
|
|
499
|
+
*
|
|
500
|
+
* A malformed payload narrows to `undefined`, which the caller renders as "not
|
|
501
|
+
* checked" — the safe direction. Inventing zeros instead would manufacture a
|
|
502
|
+
* clean bill of health out of a parse failure.
|
|
503
|
+
*/
|
|
504
|
+
function parsePageCheck(raw) {
|
|
505
|
+
if (!raw || typeof raw !== 'object')
|
|
506
|
+
return undefined;
|
|
507
|
+
const r = raw;
|
|
508
|
+
if (typeof r.consoleErrors !== 'number' || typeof r.failedRequests !== 'number')
|
|
509
|
+
return undefined;
|
|
510
|
+
const samples = Array.isArray(r.samples) ? r.samples.filter((s) => typeof s === 'string') : [];
|
|
511
|
+
return {
|
|
512
|
+
consoleErrors: r.consoleErrors,
|
|
513
|
+
failedRequests: r.failedRequests,
|
|
514
|
+
samples,
|
|
515
|
+
url: typeof r.url === 'string' ? r.url : '',
|
|
516
|
+
...(typeof r.httpStatus === 'number' ? { httpStatus: r.httpStatus } : {}),
|
|
517
|
+
...(r.origin === 'preview' || r.origin === 'prod' ? { origin: r.origin } : {}),
|
|
518
|
+
};
|
|
519
|
+
}
|
|
428
520
|
// ─── Exit codes (spec §5 — EXACT) ─────────────────────────────────────────
|
|
429
521
|
/**
|
|
430
522
|
* | Exit | Meaning |
|
|
@@ -575,6 +667,42 @@ export function defaultRunBuild(command, cwd, onOutput) {
|
|
|
575
667
|
function defaultReadAssetFile(absolutePath) {
|
|
576
668
|
return fs.readFileSync(absolutePath);
|
|
577
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* `git remote get-url origin` + the checked-out branch, best-effort.
|
|
672
|
+
*
|
|
673
|
+
* `origin` specifically, not "any remote": a checkout can carry several, and
|
|
674
|
+
* picking one by guesswork would attribute a site to a fork or a mirror. No
|
|
675
|
+
* origin ⇒ no claim.
|
|
676
|
+
*
|
|
677
|
+
* Deliberately NOT credential-stripped here — normalizing is the server's job
|
|
678
|
+
* (`services/hosting/repo-ref.ts`), and doing it in two places would let the
|
|
679
|
+
* two definitions drift. The URL never leaves this process except over TLS to
|
|
680
|
+
* the deploy API.
|
|
681
|
+
*/
|
|
682
|
+
function defaultResolveRepoOrigin(cwd) {
|
|
683
|
+
const git = (args) => {
|
|
684
|
+
try {
|
|
685
|
+
const out = execFileSync('git', args, {
|
|
686
|
+
cwd,
|
|
687
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
688
|
+
timeout: 5000,
|
|
689
|
+
})
|
|
690
|
+
.toString()
|
|
691
|
+
.trim();
|
|
692
|
+
return out.length > 0 ? out : undefined;
|
|
693
|
+
}
|
|
694
|
+
catch {
|
|
695
|
+
return undefined;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
const repoUrl = git(['remote', 'get-url', 'origin']);
|
|
699
|
+
const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
700
|
+
return {
|
|
701
|
+
...(repoUrl ? { repoUrl } : {}),
|
|
702
|
+
// 'HEAD' is git's detached-HEAD answer, not a branch name.
|
|
703
|
+
...(branch && branch !== 'HEAD' ? { branch } : {}),
|
|
704
|
+
};
|
|
705
|
+
}
|
|
578
706
|
function defaultResolveGitSha(cwd) {
|
|
579
707
|
try {
|
|
580
708
|
const out = execFileSync('git', ['rev-parse', 'HEAD'], {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolo-labs/yolo-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "YOLO Studio substrate CLI \u2014 owns yolo plan/workspace/artifact substrate-tooling commands. Distinct from yolo-code (the agent CLI) and yolo-router (the LLM gateway client).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|