@vxil/cli 0.26.0 → 0.26.1

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 (2) hide show
  1. package/dist/vxil-main.js +54 -15
  2. package/package.json +1 -1
package/dist/vxil-main.js CHANGED
@@ -5538,7 +5538,7 @@ function lowerAllTriggerBindings(def, name) {
5538
5538
  var CONFIG_FILENAMES = ["vxil.config.ts", "vxil.config.mjs", "vxil.config.js"];
5539
5539
  var VXIL_CONFIG_PKG_VERSION = "0.19.0";
5540
5540
  var VXIL_SDK_PKG_VERSION = "0.26.0";
5541
- var VXIL_CLI_PKG_VERSION = "0.26.0";
5541
+ var VXIL_CLI_PKG_VERSION = "0.26.1";
5542
5542
  function ensureScaffoldPackageJson(cwd, opts = {}) {
5543
5543
  const file = resolve(cwd, "package.json");
5544
5544
  const wanted = {
@@ -10901,6 +10901,16 @@ function redirectOriginNotice(cfg) {
10901
10901
  }
10902
10902
 
10903
10903
  // src/link.ts
10904
+ function linkEnvLabel(o) {
10905
+ if (o.envFlag !== void 0) return { env: o.envFlag, fromWorkload: false };
10906
+ const wl = o.workload === "production" ? "production" : o.workload === "staging" ? "staging" : o.workload === "development" ? "dev" : void 0;
10907
+ if (wl) {
10908
+ if (o.kept !== void 0 && o.kept === "production" === (wl === "production")) return { env: o.kept, fromWorkload: false };
10909
+ const notice = o.kept !== void 0 ? `relabelled ${o.kept} \u2192 ${wl} from the project's workload; \`--env ${o.kept}\` to keep it` : void 0;
10910
+ return { env: wl, fromWorkload: true, ...notice ? { notice } : {} };
10911
+ }
10912
+ return { env: o.kept ?? envLabelFor(o.base), fromWorkload: false };
10913
+ }
10904
10914
  function data(r) {
10905
10915
  return r.json.data ?? r.json;
10906
10916
  }
@@ -10934,7 +10944,7 @@ async function linkViaSession(dash, cookie, slug, keyName) {
10934
10944
  }
10935
10945
  const apiKey = data(mint).api_key;
10936
10946
  if (!apiKey) throw new Error("mint returned no api_key");
10937
- return { result: { slug, tenant_id: t.id, api_key: apiKey } };
10947
+ return { result: { slug, tenant_id: t.id, api_key: apiKey, ...typeof t.workload === "string" ? { workload: t.workload } : {} } };
10938
10948
  }
10939
10949
  async function linkViaDeviceFlow(dash, slug, io) {
10940
10950
  const now = io.now ?? Date.now;
@@ -10960,7 +10970,7 @@ async function linkViaDeviceFlow(dash, slug, io) {
10960
10970
  if (poll.status === 200) {
10961
10971
  const p = data(poll);
10962
10972
  if (!p.api_key || !p.tenant_id) throw new Error("approval returned no api_key");
10963
- return { slug: p.slug || slug, tenant_id: p.tenant_id, api_key: p.api_key };
10973
+ return { slug: p.slug || slug, tenant_id: p.tenant_id, api_key: p.api_key, ...typeof p.workload === "string" ? { workload: p.workload } : {} };
10964
10974
  }
10965
10975
  throw new Error(`link failed (${errText(poll)})`);
10966
10976
  }
@@ -11520,6 +11530,10 @@ function isWorkload(v) {
11520
11530
  function workloadEnvLabel(w) {
11521
11531
  return w === "production" ? "production" : w === "staging" ? "staging" : "dev";
11522
11532
  }
11533
+ function projectCreateNextHint(slug, workload) {
11534
+ const env = isWorkload(workload) ? ` --env ${workloadEnvLabel(workload)}` : "";
11535
+ return `next: vxil link ${slug} --mint${env} && vxil push (this repo's binding is unchanged until then)`;
11536
+ }
11523
11537
  function quickstartWorkload(workloadFlag, envFlag, dev) {
11524
11538
  if (workloadFlag !== void 0) {
11525
11539
  if (!isWorkload(workloadFlag)) return { error: `--workload must be one of ${PROJECT_WORKLOADS.join(", ")}` };
@@ -15523,6 +15537,17 @@ function formatCompared(c) {
15523
15537
  }
15524
15538
  return parts.join(" \xB7 ");
15525
15539
  }
15540
+ function planFooter(counts, compared) {
15541
+ if (counts.drift > 0) return "(run `vxil push` to apply)";
15542
+ if (counts.ignored > 0 || counts.notCompared > 0) {
15543
+ const parts = [];
15544
+ if (counts.ignored > 0) parts.push(`${counts.ignored} ignored (\`vxil push\` would still apply them)`);
15545
+ if (counts.notCompared > 0) parts.push(`${counts.notCompared} not compared`);
15546
+ return `no unignored drift found \u2014 ${parts.join(" / ")}; not a clean match`;
15547
+ }
15548
+ const what = formatCompared(compared);
15549
+ return `\u2713 no drift \u2014 the target already matches your config${what ? ` (compared ${what})` : ""}; nothing to push`;
15550
+ }
15526
15551
 
15527
15552
  // src/doctor.ts
15528
15553
  var SECRETS_ADVISORY_NOTE = "advisory only: a config push with an unstored `secret:<name>` ref is a WARNING, never a 422 \u2014 vxil's promotion order sets production secrets AFTER the config push (`vxil secrets set <feature>/<name>`); doctor never deletes a stored secret";
@@ -16394,6 +16419,7 @@ async function reuseDevTenantBySlug(dash, cookie, slug) {
16394
16419
  }
16395
16420
 
16396
16421
  // src/try.ts
16422
+ var TRY_ENV_LABEL = "sandbox";
16397
16423
  async function mintTry(fetchImpl, base2, opts = {}) {
16398
16424
  const url = `${base2.replace(/\/$/, "")}/v1/try`;
16399
16425
  const body = opts.turnstileToken ? { turnstile_token: opts.turnstileToken } : {};
@@ -22705,16 +22731,22 @@ async function dashFetch(base2, method, path, body, cookie) {
22705
22731
  function makeDash(base2) {
22706
22732
  return (method, path, body, cookie) => dashFetch(base2, method, path, body, cookie);
22707
22733
  }
22708
- function linkRequest(slug, tenantId, base2) {
22734
+ function linkRequest(slug, tenantId, base2, workload) {
22709
22735
  const as = flag("as");
22710
- const env = flag("env") ?? keptEnvLabel(loadProject(), slug, tenantId, as) ?? envLabelFor(base2);
22711
- return { slug, tenantId, edgeUrl: base2, env, ...as !== void 0 ? { as } : {} };
22736
+ const { env, fromWorkload, notice } = linkEnvLabel({
22737
+ base: base2,
22738
+ envFlag: flag("env"),
22739
+ kept: keptEnvLabel(loadProject(), slug, tenantId, as),
22740
+ workload
22741
+ });
22742
+ if (notice) console.error(`vxil: ${notice}`);
22743
+ return { slug, tenantId, edgeUrl: base2, env, fromWorkload, ...as !== void 0 ? { as } : {} };
22712
22744
  }
22713
- function persistLink(slug, tenantId, apiKey, base2) {
22714
- const req = linkRequest(slug, tenantId, base2);
22745
+ function persistLink(slug, tenantId, apiKey, base2, workload) {
22746
+ const req = linkRequest(slug, tenantId, base2, workload);
22715
22747
  const plan = planLinkBinding(loadProject(), req);
22716
22748
  if ("error" in plan) fail(plan.error);
22717
- const envWarn = envLabelWarning(req.env, base2);
22749
+ const envWarn = req.fromWorkload ? null : envLabelWarning(req.env, base2);
22718
22750
  if (envWarn) console.error(`vxil: ${envWarn}`);
22719
22751
  const creds = loadCredentials();
22720
22752
  creds.keys = { ...creds.keys, [slug]: apiKey };
@@ -23168,7 +23200,7 @@ async function runApply(apply, sel = "prod", opts = {}) {
23168
23200
  const gate = !apply && !!opts.gate;
23169
23201
  const explain = !apply && !!opts.explain;
23170
23202
  const { api, target } = requireApi(sel, apply ? { write: "push" } : gate ? { exitCode: 2 } : {});
23171
- if (!apply) console.error(targetBanner(target, gate ? "diff" : "plan"));
23203
+ if (!apply) console.error(targetBanner(target, gate || opts.verb === "diff" ? "diff" : "plan"));
23172
23204
  const report = { drift: 0, ignored: 0, errors: 0 };
23173
23205
  const pushProblems = { hard: [], strict: [] };
23174
23206
  const strictPush = apply && hasFlag("strict");
@@ -23221,8 +23253,10 @@ async function runApply(apply, sel = "prod", opts = {}) {
23221
23253
  if (gate) report.errors++;
23222
23254
  }
23223
23255
  }
23256
+ let uncompared = 0;
23224
23257
  const notCompared = (u, hint) => {
23225
23258
  console.log(formatNotCompared(u, hint));
23259
+ uncompared++;
23226
23260
  if (gate) report.errors++;
23227
23261
  };
23228
23262
  const runSection = async (label, fn) => {
@@ -23343,6 +23377,7 @@ ${r.feature}.${r.datum} (declared in config):`);
23343
23377
  console.log(formatDeclaredApiState(r, { strict: strictApiState }));
23344
23378
  if (r.skipped) continue;
23345
23379
  if (r.refused) {
23380
+ uncompared++;
23346
23381
  if (gate) report.errors++;
23347
23382
  else console.error(`vxil: warning \u2014 ${r.feature}.${r.datum} not converged: ${r.refused}`);
23348
23383
  if (apply) pushProblems.strict.push(`${r.feature}.${r.datum} refused: ${r.refused}`);
@@ -23350,6 +23385,7 @@ ${r.feature}.${r.datum} (declared in config):`);
23350
23385
  }
23351
23386
  if (r.deferred) {
23352
23387
  console.error(`vxil: warning \u2014 ${r.feature}.${r.datum} not converged yet: ${r.deferred}`);
23388
+ uncompared++;
23353
23389
  if (gate) report.errors++;
23354
23390
  if (apply) pushProblems.strict.push(`${r.feature}.${r.datum} deferred: ${r.deferred}`);
23355
23391
  continue;
@@ -23511,6 +23547,7 @@ api state \u2014 ${self.target.tenantSlug ?? "(env key)"} vs ${other.target.tena
23511
23547
  for (const u of b2.unavailable) notCompared(u, `--against ${other.target.tenantSlug ?? ""}`.trim());
23512
23548
  for (const w of [...truncationWarnings(a, "the target"), ...truncationWarnings(b2, "--against")]) {
23513
23549
  console.log(w);
23550
+ uncompared++;
23514
23551
  if (gate) report.errors++;
23515
23552
  }
23516
23553
  if (a.unavailable.length || b2.unavailable.length) return;
@@ -23556,7 +23593,8 @@ vxil diff \u2192 ${report.drift} drift item(s), ${report.ignored} ignored, ${rep
23556
23593
  }
23557
23594
  process.exit(code);
23558
23595
  }
23559
- if (!apply) console.log("\n(run `vxil push` to apply)");
23596
+ if (!apply) console.log(`
23597
+ ${planFooter({ drift: report.drift, ignored: report.ignored, notCompared: uncompared }, compared)}`);
23560
23598
  if (apply && !hasFlag("no-gen")) await runGen(sel);
23561
23599
  if (apply) {
23562
23600
  const exitWith = pushExitCode(pushProblems, strictPush, target.slot === "primary" && target.tenantSlug ? { slug: target.tenantSlug } : {});
@@ -24346,7 +24384,7 @@ try {
24346
24384
  tenant_id: result.tenant_id,
24347
24385
  slug: result.slug,
24348
24386
  edge_url: base2,
24349
- env: flag("env") ?? envLabelFor(base2),
24387
+ env: flag("env") ?? TRY_ENV_LABEL,
24350
24388
  ephemeral: true,
24351
24389
  ...result.expires_at ? { expires_at: result.expires_at } : {}
24352
24390
  });
@@ -24422,7 +24460,7 @@ try {
24422
24460
  if (linkSession) {
24423
24461
  const r = await linkViaSession(dash, linkSession, slug, keyName);
24424
24462
  if ("result" in r) {
24425
- const bound = persistLink(r.result.slug, r.result.tenant_id, r.result.api_key, base2);
24463
+ const bound = persistLink(r.result.slug, r.result.tenant_id, r.result.api_key, base2, r.result.workload);
24426
24464
  console.log(`\u2713 linked '${slug}' ${bound} (minted a key via your dashboard session)`);
24427
24465
  break;
24428
24466
  }
@@ -24436,7 +24474,7 @@ try {
24436
24474
  log: (l) => console.log(l),
24437
24475
  sleep: (ms) => new Promise((r) => setTimeout(r, ms))
24438
24476
  });
24439
- const bound = persistLink(linked.slug, linked.tenant_id, linked.api_key, base2);
24477
+ const bound = persistLink(linked.slug, linked.tenant_id, linked.api_key, base2, linked.workload);
24440
24478
  console.log(`
24441
24479
  \u2713 linked '${linked.slug}' ${bound} (approved in the browser)`);
24442
24480
  }
@@ -24794,7 +24832,7 @@ try {
24794
24832
  const { project } = await withDashSession(dash, base2, (c) => createProjectViaSession(dash, c, p.body));
24795
24833
  if (jsonOut) console.log(JSON.stringify(project, null, 2));
24796
24834
  else console.log(`\u2713 created '${project.slug}' (${project.display_name}, ${project.tier}${project.workload ? `, ${project.workload}` : ""}) \u2014 no key and no features yet`);
24797
- console.error(`next: vxil link ${project.slug} --mint && vxil push (this repo's binding is unchanged)`);
24835
+ console.error(projectCreateNextHint(project.slug, project.workload));
24798
24836
  break;
24799
24837
  }
24800
24838
  if (sub === "workload") {
@@ -25049,6 +25087,7 @@ ${formatSummary(state)}`);
25049
25087
  await runApply(false, sel, {
25050
25088
  explain: hasFlag("explain"),
25051
25089
  gate: against !== void 0 || hasFlag("exit-code"),
25090
+ verb: "diff",
25052
25091
  ...hasFlag("api-state") ? { apiState: { self: selector(), against: againstSelector(against) } } : {}
25053
25092
  });
25054
25093
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxil/cli",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "private": false,
5
5
  "description": "The vxil CLI — init, quickstart, push, gen, secrets, keys, migrate, doctor, diff, functions, payments; installs the `vxil` command (npm i -g @vxil/cli).",
6
6
  "license": "MIT",