@plexus-ms/cli 0.104.0 → 0.106.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.
Files changed (2) hide show
  1. package/dist/plx.js +161 -81
  2. package/package.json +3 -3
package/dist/plx.js CHANGED
@@ -7586,7 +7586,7 @@ var WORKFLOW_REF = "plexus-ms/primitives/.github/workflows/";
7586
7586
  var bumpWorkflowRefs = (text, train) => text.replace(/(plexus-ms\/primitives\/\.github\/workflows\/[A-Za-z0-9._-]+)@v?[0-9.]+/g, `$1@${train}`);
7587
7587
  var bumpManifestVersion = (text, train) => text.replace(/^(\s*"version":\s*")[^"]*(")/m, `$1${train}$2`);
7588
7588
  var PLX_PIN = "npm:@plexus-ms/cli";
7589
- var bumpPlxPin = (text, train) => text.replace(/("npm:@plexus-ms\/cli"\s*=\s*(?:\{\s*version\s*=\s*)?")[^"]*(")/g, `$1${train}$2`);
7589
+ var bumpPlxPin = (text, train) => text.replace(/("npm:@plexus-ms\/cli(?:-ci)?"\s*=\s*(?:\{\s*version\s*=\s*)?")[^"]*(")/g, `$1${train}$2`);
7590
7590
  var CONFIG_PIN = "@plexus-ms/config";
7591
7591
  var bumpConfigPin = (text, train) => text.replace(/("@plexus-ms\/config":\s*")(?!workspace:|catalog:)[^"]*(")/g, `$1${train}$2`);
7592
7592
  var bumpCatalogPin = (text, train) => text.replace(/^(\s+"@plexus-ms\/config":\s*)\S+$/m, `$1${train}`);
@@ -8108,6 +8108,20 @@ var Context = class {
8108
8108
  await this.perform(step);
8109
8109
  }
8110
8110
  }
8111
+ /**
8112
+ * One effect whose output the verb needs to go on (a create call's
8113
+ * operation, a registration's config): narrated and performed like apply,
8114
+ * and undefined under --dry-run, where the caller stands in a placeholder.
8115
+ */
8116
+ async effect(step) {
8117
+ this.say(`${this.dryRun ? "[dry-run] " : ""}${describe(step)}`);
8118
+ const input = body(step);
8119
+ if (input !== void 0)
8120
+ this.say(indent(input), step.kind === "write" ? 2 : 1);
8121
+ if (this.dryRun)
8122
+ return void 0;
8123
+ return this.perform(step);
8124
+ }
8111
8125
  /**
8112
8126
  * Perform a step on scratch state, whatever the mode: the one exception to
8113
8127
  * "a dry run performs no effect", for a preview that has to run a tool
@@ -8124,7 +8138,12 @@ var Context = class {
8124
8138
  const inherit = this.verbose >= 2 || step.kind === "run" && step.interactive === true;
8125
8139
  switch (step.kind) {
8126
8140
  case "run":
8127
- return this.io.exec(step.command, step.args, { cwd: step.cwd, input: step.input, inherit });
8141
+ return this.io.exec(step.command, step.args, {
8142
+ cwd: step.cwd,
8143
+ input: step.input,
8144
+ inherit,
8145
+ env: step.env === void 0 ? void 0 : { ...process.env, ...step.env }
8146
+ });
8128
8147
  case "write":
8129
8148
  await this.io.writeFile(step.path, step.content);
8130
8149
  return void 0;
@@ -8163,6 +8182,10 @@ function parseAnswers(text) {
8163
8182
  // ../lib/dist/deploy.js
8164
8183
  import { randomBytes } from "node:crypto";
8165
8184
  import { tmpdir } from "node:os";
8185
+ import { join as join6 } from "node:path";
8186
+
8187
+ // ../lib/dist/deployTargets.js
8188
+ var import_yaml4 = __toESM(require_dist(), 1);
8166
8189
  import { join as join5 } from "node:path";
8167
8190
 
8168
8191
  // ../lib/dist/train.js
@@ -8239,6 +8262,7 @@ var TRAIN_REPOS = [
8239
8262
  var PHASES = [[PRIMITIVES], TRAIN_REPOS.filter((r) => r !== PRIMITIVES)];
8240
8263
  var TRAIN_PACKAGES = [
8241
8264
  { name: "@plexus-ms/cli", dir: "packages/cli" },
8265
+ { name: "@plexus-ms/cli-ci", dir: "packages/cli-ci" },
8242
8266
  { name: "@plexus-ms/lib", dir: "packages/lib" },
8243
8267
  { name: "@plexus-ms/config", dir: "packages/config" }
8244
8268
  ];
@@ -8319,6 +8343,75 @@ pass the version explicitly (--train ${train.last}) to finish the half-tagged tr
8319
8343
  var UsageError = class extends Error {
8320
8344
  };
8321
8345
 
8346
+ // ../lib/dist/deployTargets.js
8347
+ var VARS_DIRS = ["group_vars", "host_vars"];
8348
+ var DEFAULT_ENVIRONMENT = "production";
8349
+ function deploymentSlug(app, environment = DEFAULT_ENVIRONMENT) {
8350
+ return environment === DEFAULT_ENVIRONMENT ? app : `${app}-${environment}`;
8351
+ }
8352
+ function parseInventoryFile(path3, text) {
8353
+ const data = (0, import_yaml4.parse)(text);
8354
+ const vars = data !== null && typeof data === "object" ? data : {};
8355
+ const target = typeof vars.plexus_deploy_target === "string" ? vars.plexus_deploy_target : void 0;
8356
+ const records = Array.isArray(vars.plexus_apps) ? vars.plexus_apps : [];
8357
+ const apps = records.flatMap((r) => {
8358
+ if (r === null || typeof r !== "object")
8359
+ return [];
8360
+ const { name, environment } = r;
8361
+ if (typeof name !== "string")
8362
+ return [];
8363
+ return [{ app: name, environment: typeof environment === "string" ? environment : DEFAULT_ENVIRONMENT }];
8364
+ });
8365
+ return { path: path3, target, apps };
8366
+ }
8367
+ function selectDeployTargets(files) {
8368
+ const targets = {};
8369
+ const declaredIn = {};
8370
+ for (const file of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
8371
+ if (file.target === void 0)
8372
+ continue;
8373
+ for (const { app, environment } of file.apps) {
8374
+ const key = `${app}@${environment}`;
8375
+ if (key in declaredIn)
8376
+ throw new Error(`app "${app}" in ${environment} is declared with a deploy target in both ${declaredIn[key]} and ${file.path}`);
8377
+ const envs = targets[app] ?? {};
8378
+ envs[environment] = file.target;
8379
+ targets[app] = envs;
8380
+ declaredIn[key] = file.path;
8381
+ }
8382
+ }
8383
+ return Object.fromEntries(Object.entries(targets).sort(([a], [b]) => a.localeCompare(b)).map(([app, envs]) => [app, Object.fromEntries(Object.entries(envs).sort(([a], [b]) => a.localeCompare(b)))]));
8384
+ }
8385
+ function targetsIn(targets, environment) {
8386
+ const flat = {};
8387
+ for (const [app, envs] of Object.entries(targets)) {
8388
+ const target = envs[environment];
8389
+ if (target !== void 0)
8390
+ flat[app] = target;
8391
+ }
8392
+ return flat;
8393
+ }
8394
+ async function readDeployTargets(ctx, inventory) {
8395
+ const files = [];
8396
+ let found = false;
8397
+ for (const sub of VARS_DIRS) {
8398
+ const dir = join5(inventory, sub);
8399
+ const entries = await ctx.readDir(dir).catch(() => void 0);
8400
+ if (entries === void 0)
8401
+ continue;
8402
+ found = true;
8403
+ for (const e of entries) {
8404
+ if (e.directory || !/\.ya?ml$/.test(e.name))
8405
+ continue;
8406
+ const path3 = join5(dir, e.name);
8407
+ files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
8408
+ }
8409
+ }
8410
+ if (!found && await ctx.readDir(inventory).catch(() => void 0) === void 0)
8411
+ throw new UsageError(`no inventory directory at ${inventory}`);
8412
+ return selectDeployTargets(files);
8413
+ }
8414
+
8322
8415
  // ../lib/dist/deploy.js
8323
8416
  var PLACEHOLDER = /\$\{PLEXUS_DEPLOYMENT_IMAGE(:[^}]*)?\}/g;
8324
8417
  var INCOMING = ".incoming";
@@ -8334,9 +8427,12 @@ function renderCompose(text, image, path3) {
8334
8427
  throw new UsageError(`${path3} references \${PLEXUS_DEPLOYMENT_IMAGE} but no image ref was given`);
8335
8428
  return text;
8336
8429
  }
8430
+ function defaultAppDir(tenant, app, environment = DEFAULT_ENVIRONMENT) {
8431
+ return `/opt/stacks/${tenant}/${deploymentSlug(app, environment)}`;
8432
+ }
8337
8433
  var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
8338
8434
  var Remote = class {
8339
- socket = join5(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
8435
+ socket = join6(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
8340
8436
  ctx;
8341
8437
  host;
8342
8438
  constructor(ctx, host) {
@@ -8393,14 +8489,15 @@ async function deploy(ctx, options) {
8393
8489
  const { host, tenant, app } = options;
8394
8490
  const dir = options.dir ?? ".";
8395
8491
  const image = options.image || void 0;
8396
- const appDir = options.appDir || `/opt/stacks/${tenant}/${app}`;
8492
+ const environment = options.environment || DEFAULT_ENVIRONMENT;
8493
+ const appDir = options.appDir || defaultAppDir(tenant, app, environment);
8397
8494
  const source = options.source || `apps/${app}`;
8398
8495
  const retries = options.retries ?? 30;
8399
8496
  let compose;
8400
8497
  let text = "";
8401
8498
  for (const candidate of [`${source}/docker/compose.yaml`, `${source}/compose.yaml`]) {
8402
8499
  try {
8403
- text = await ctx.readFile(join5(dir, candidate));
8500
+ text = await ctx.readFile(join6(dir, candidate));
8404
8501
  compose = candidate;
8405
8502
  break;
8406
8503
  } catch {
@@ -8426,6 +8523,28 @@ async function deploy(ctx, options) {
8426
8523
  staged = true;
8427
8524
  result.previous = await remote.read(liveImage) || void 0;
8428
8525
  ctx.say(` previous: ${result.previous ?? (ctx.dryRun ? "<read on host>" : "<none>")}`);
8526
+ const poll = (attempts) => `cd ${D} && for _ in $(seq 1 ${attempts}); do curl -fsS --max-time 5 -o /dev/null ${q(url())} && exit 0; sleep 2; done; exit 1`;
8527
+ let resolvedUrl;
8528
+ const url = () => {
8529
+ if (resolvedUrl === void 0)
8530
+ throw new Error("health URL read before it was resolved");
8531
+ return resolvedUrl;
8532
+ };
8533
+ if (ctx.dryRun)
8534
+ ctx.say(" (nothing more runs when the host already serves this image from this file, healthy)");
8535
+ else if (image && result.previous === image) {
8536
+ const sameFile = await remote.test(`cd ${D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`);
8537
+ if (sameFile) {
8538
+ resolvedUrl = options.healthUrl || await resolveHealthUrl(remote, D, dc, ctx);
8539
+ if (await remote.test(poll(1))) {
8540
+ result.live = image;
8541
+ result.healthy = true;
8542
+ result.unchanged = true;
8543
+ ctx.done(`${image} is already live and healthy; nothing to do`);
8544
+ return result;
8545
+ }
8546
+ }
8547
+ }
8429
8548
  await remote.exec(`${dci} pull`);
8430
8549
  const migrate = await remote.test(`${dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
8431
8550
  if (migrate === void 0)
@@ -8437,10 +8556,9 @@ async function deploy(ctx, options) {
8437
8556
  await remote.exec(`cd ${D} && cp -p compose.yaml ${INCOMING}/compose.yaml.prev`);
8438
8557
  await remote.exec(`cd ${D} && mv ${INCOMING}/compose.yaml compose.yaml`);
8439
8558
  await remote.exec(`${dc} up -d`);
8440
- const url = options.healthUrl || await resolveHealthUrl(remote, D, dc, ctx);
8441
- const poll = `cd ${D} && for _ in $(seq 1 ${retries}); do curl -fsS --max-time 5 -o /dev/null ${q(url)} && exit 0; sleep 2; done; exit 1`;
8559
+ resolvedUrl ??= options.healthUrl || await resolveHealthUrl(remote, D, dc, ctx);
8442
8560
  const started = Date.now();
8443
- const healthy = await remote.test(poll, true);
8561
+ const healthy = await remote.test(poll(retries), true);
8444
8562
  if (healthy !== false) {
8445
8563
  result.live = await remote.read(liveImage) || image;
8446
8564
  result.healthy = true;
@@ -8463,7 +8581,7 @@ async function deploy(ctx, options) {
8463
8581
  ctx.say(`\u21A9 rolling back to ${result.previous ?? "the previous compose.yaml"}`);
8464
8582
  await remote.exec(`${dc} up -d`);
8465
8583
  result.rolledBack = true;
8466
- if (await remote.test(poll)) {
8584
+ if (await remote.test(poll(retries))) {
8467
8585
  result.live = result.previous;
8468
8586
  ctx.done(`rolled back to ${result.previous ?? "the previous compose.yaml"}`);
8469
8587
  } else {
@@ -8484,54 +8602,6 @@ async function resolveHealthUrl(remote, D, dc, ctx) {
8484
8602
  return url;
8485
8603
  }
8486
8604
 
8487
- // ../lib/dist/deployTargets.js
8488
- var import_yaml4 = __toESM(require_dist(), 1);
8489
- import { join as join6 } from "node:path";
8490
- var VARS_DIRS = ["group_vars", "host_vars"];
8491
- function parseInventoryFile(path3, text) {
8492
- const data = (0, import_yaml4.parse)(text);
8493
- const vars = data !== null && typeof data === "object" ? data : {};
8494
- const target = typeof vars.plexus_deploy_target === "string" ? vars.plexus_deploy_target : void 0;
8495
- const records = Array.isArray(vars.plexus_apps) ? vars.plexus_apps : [];
8496
- const apps = records.map((r) => r !== null && typeof r === "object" ? r.name : void 0).filter((n) => typeof n === "string");
8497
- return { path: path3, target, apps };
8498
- }
8499
- function selectDeployTargets(files) {
8500
- const targets = {};
8501
- const declaredIn = {};
8502
- for (const file of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
8503
- if (file.target === void 0)
8504
- continue;
8505
- for (const app of file.apps) {
8506
- if (app in targets)
8507
- throw new Error(`app "${app}" is declared with a deploy target in both ${declaredIn[app]} and ${file.path}`);
8508
- targets[app] = file.target;
8509
- declaredIn[app] = file.path;
8510
- }
8511
- }
8512
- return Object.fromEntries(Object.entries(targets).sort(([a], [b]) => a.localeCompare(b)));
8513
- }
8514
- async function readDeployTargets(ctx, inventory) {
8515
- const files = [];
8516
- let found = false;
8517
- for (const sub of VARS_DIRS) {
8518
- const dir = join6(inventory, sub);
8519
- const entries = await ctx.readDir(dir).catch(() => void 0);
8520
- if (entries === void 0)
8521
- continue;
8522
- found = true;
8523
- for (const e of entries) {
8524
- if (e.directory || !/\.ya?ml$/.test(e.name))
8525
- continue;
8526
- const path3 = join6(dir, e.name);
8527
- files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
8528
- }
8529
- }
8530
- if (!found && await ctx.readDir(inventory).catch(() => void 0) === void 0)
8531
- throw new UsageError(`no inventory directory at ${inventory}`);
8532
- return selectDeployTargets(files);
8533
- }
8534
-
8535
8605
  // ../lib/dist/model.js
8536
8606
  function kindOf(declaration) {
8537
8607
  const has = (code) => declaration.modules.includes(code);
@@ -9337,7 +9407,7 @@ async function newestTrain(ctx, preset) {
9337
9407
  // src/program.ts
9338
9408
  import { createRequire } from "node:module";
9339
9409
 
9340
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/key.js
9410
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/key.js
9341
9411
  var keybindings = ["emacs", "vim"];
9342
9412
  var keybindingLookup = new Set(keybindings);
9343
9413
  function isKeybinding(value) {
@@ -9352,7 +9422,7 @@ function getDefaultKeybindings() {
9352
9422
  var isTabKey = (key) => key.name === "tab";
9353
9423
  var isEnterKey = (key) => key.name === "enter" || key.name === "return";
9354
9424
 
9355
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/errors.js
9425
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/errors.js
9356
9426
  var AbortPromptError = class extends Error {
9357
9427
  name = "AbortPromptError";
9358
9428
  message = "Prompt was aborted";
@@ -9375,10 +9445,10 @@ var ValidationError = class extends Error {
9375
9445
  name = "ValidationError";
9376
9446
  };
9377
9447
 
9378
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-state.js
9448
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/use-state.js
9379
9449
  import { AsyncResource as AsyncResource2 } from "node:async_hooks";
9380
9450
 
9381
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/hook-engine.js
9451
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/hook-engine.js
9382
9452
  import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
9383
9453
  var hookStorage = new AsyncLocalStorage();
9384
9454
  function createStore(rl) {
@@ -9482,7 +9552,7 @@ var effectScheduler = {
9482
9552
  }
9483
9553
  };
9484
9554
 
9485
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-state.js
9555
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/use-state.js
9486
9556
  function isFactory(value) {
9487
9557
  return typeof value === "function";
9488
9558
  }
@@ -9508,7 +9578,7 @@ function useState(defaultValue) {
9508
9578
  });
9509
9579
  }
9510
9580
 
9511
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-effect.js
9581
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/use-effect.js
9512
9582
  function useEffect(cb, depArray) {
9513
9583
  withPointer((pointer) => {
9514
9584
  const oldDeps = pointer.get();
@@ -9520,7 +9590,7 @@ function useEffect(cb, depArray) {
9520
9590
  });
9521
9591
  }
9522
9592
 
9523
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/theme.js
9593
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/theme.js
9524
9594
  import { styleText } from "node:util";
9525
9595
 
9526
9596
  // ../../node_modules/.pnpm/@inquirer+figures@2.0.10/node_modules/@inquirer/figures/dist/index.js
@@ -9816,7 +9886,7 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
9816
9886
  var dist_default = figures;
9817
9887
  var replacements = Object.entries(specialMainSymbols);
9818
9888
 
9819
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/theme.js
9889
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/theme.js
9820
9890
  var defaultTheme = {
9821
9891
  prefix: {
9822
9892
  idle: styleText("blue", "?"),
@@ -9844,7 +9914,7 @@ function getDefaultTheme() {
9844
9914
  };
9845
9915
  }
9846
9916
 
9847
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/make-theme.js
9917
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/make-theme.js
9848
9918
  function isPlainObject(value) {
9849
9919
  if (typeof value !== "object" || value === null)
9850
9920
  return false;
@@ -9872,7 +9942,7 @@ function makeTheme(...themes) {
9872
9942
  return deepMerge(...themesToMerge);
9873
9943
  }
9874
9944
 
9875
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-prefix.js
9945
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/use-prefix.js
9876
9946
  function usePrefix({ status = "idle", theme }) {
9877
9947
  const [showLoader, setShowLoader] = useState(false);
9878
9948
  const [tick, setTick] = useState(0);
@@ -9903,12 +9973,12 @@ function usePrefix({ status = "idle", theme }) {
9903
9973
  return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
9904
9974
  }
9905
9975
 
9906
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-ref.js
9976
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/use-ref.js
9907
9977
  function useRef(val) {
9908
9978
  return useState({ current: val })[0];
9909
9979
  }
9910
9980
 
9911
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-keypress.js
9981
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/use-keypress.js
9912
9982
  function useKeypress(userHandler) {
9913
9983
  const signal = useRef(userHandler);
9914
9984
  signal.current = userHandler;
@@ -9927,7 +9997,7 @@ function useKeypress(userHandler) {
9927
9997
  }, []);
9928
9998
  }
9929
9999
 
9930
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/utils.js
10000
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/utils.js
9931
10001
  var import_cli_width = __toESM(require_cli_width(), 1);
9932
10002
 
9933
10003
  // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
@@ -10266,7 +10336,7 @@ function wrapAnsi(string, columns, options) {
10266
10336
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
10267
10337
  }
10268
10338
 
10269
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/utils.js
10339
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/utils.js
10270
10340
  function breakLines(content, width) {
10271
10341
  return content.split("\n").flatMap((line) => wrapAnsi(line, width, { trim: false, wordWrap: false }).split("\n").map((str) => str.trimEnd())).join("\n");
10272
10342
  }
@@ -10274,11 +10344,11 @@ function readlineWidth() {
10274
10344
  return (0, import_cli_width.default)({ defaultWidth: 80, output: readline().output });
10275
10345
  }
10276
10346
 
10277
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
10347
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
10278
10348
  import * as readline2 from "node:readline";
10279
10349
  import { AsyncResource as AsyncResource3 } from "node:async_hooks";
10280
10350
 
10281
- // ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@26.6.5/node_modules/@inquirer/type/dist/utils.js
10351
+ // ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
10282
10352
  function withResolver() {
10283
10353
  let resolve11;
10284
10354
  let reject;
@@ -10289,7 +10359,7 @@ function withResolver() {
10289
10359
  return { promise, resolve: resolve11, reject };
10290
10360
  }
10291
10361
 
10292
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
10362
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
10293
10363
  var import_mute_stream = __toESM(require_lib(), 1);
10294
10364
 
10295
10365
  // ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
@@ -10543,7 +10613,7 @@ var {
10543
10613
  unload
10544
10614
  } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback());
10545
10615
 
10546
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/screen-manager.js
10616
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/screen-manager.js
10547
10617
  import { stripVTControlCharacters } from "node:util";
10548
10618
 
10549
10619
  // ../../node_modules/.pnpm/@inquirer+ansi@2.0.10/node_modules/@inquirer/ansi/dist/index.js
@@ -10562,7 +10632,7 @@ var cursorTo = (x, y) => {
10562
10632
  var eraseLine = ESC2 + "2K";
10563
10633
  var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
10564
10634
 
10565
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/screen-manager.js
10635
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/screen-manager.js
10566
10636
  var height = (content) => content.split("\n").length;
10567
10637
  var lastLine = (content) => content.split("\n").pop() ?? "";
10568
10638
  var ScreenManager = class {
@@ -10623,7 +10693,7 @@ var ScreenManager = class {
10623
10693
  }
10624
10694
  };
10625
10695
 
10626
- // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
10696
+ // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
10627
10697
  import path from "node:path";
10628
10698
  var nativeSetImmediate = globalThis.setImmediate;
10629
10699
  var nativeClearImmediate = globalThis.clearImmediate;
@@ -10743,7 +10813,7 @@ function createPrompt(view) {
10743
10813
  return prompt;
10744
10814
  }
10745
10815
 
10746
- // ../../node_modules/.pnpm/@inquirer+confirm@6.3.5_@types+node@26.6.5/node_modules/@inquirer/confirm/dist/index.js
10816
+ // ../../node_modules/.pnpm/@inquirer+confirm@6.3.5_@types+node@24.19.2/node_modules/@inquirer/confirm/dist/index.js
10747
10817
  import { styleText as styleText2 } from "node:util";
10748
10818
  var confirmTheme = {
10749
10819
  keywords: {
@@ -14231,7 +14301,13 @@ function register3(program2) {
14231
14301
  ).argument("<host>", "ssh target, deploy@host").argument("<tenant>", "tenant slug, the first segment of the app dir on the host").argument("<app>", "the app, apps/<app> in the checkout").option("--image <ref>", "the image ref to pin; absent for a third-party app whose compose.yaml pins its own").option(
14232
14302
  "--health-url <url>",
14233
14303
  "readiness URL polled on the host (default: /healthz, or the plexus.healthz label, on the loopback port)"
14234
- ).option("--retries <n>", "poll attempts, two seconds apart", "30").option("--app-dir <path>", "the app dir on the host (default: /opt/stacks/<tenant>/<app>)").option("--source <path>", "the app\u2019s dir in the checkout (default: apps/<app>)").option("-C, --dir <dir>", "the checkout to read", ".").action(async (host, tenant, app, opts, command) => {
14304
+ ).option("--retries <n>", "poll attempts, two seconds apart", "30").option(
14305
+ "-e, --environment <name>",
14306
+ "the environment deployed into; decides the app dir\u2019s slug (default: production)"
14307
+ ).option(
14308
+ "--app-dir <path>",
14309
+ "the app dir on the host (default: /opt/stacks/<tenant>/<app>, or <app>-<environment> outside production)"
14310
+ ).option("--source <path>", "the app\u2019s dir in the checkout (default: apps/<app>)").option("-C, --dir <dir>", "the checkout to read", ".").action(async (host, tenant, app, opts, command) => {
14235
14311
  const ctx = contextOf2(command);
14236
14312
  const result = await deploy(ctx, {
14237
14313
  host,
@@ -14240,6 +14316,7 @@ function register3(program2) {
14240
14316
  image: opts.image,
14241
14317
  healthUrl: opts.healthUrl,
14242
14318
  retries: Number(opts.retries),
14319
+ environment: opts.environment,
14243
14320
  appDir: opts.appDir,
14244
14321
  source: opts.source,
14245
14322
  dir: resolve3(opts.dir)
@@ -14256,10 +14333,13 @@ function renderDeploy(d) {
14256
14333
  // src/commands/deploy-targets.ts
14257
14334
  import { resolve as resolve4 } from "node:path";
14258
14335
  function register4(program2) {
14259
- program2.command("deploy-targets").description("map each app of a platform repo to the deploy target of the inventory file that declares it").argument("[inventory]", "the inventory directory", "inventory").action(async (inventory, _opts, command) => {
14336
+ program2.command("deploy-targets").description(
14337
+ "map each app of a platform repo, per environment, to the deploy target of the inventory file that declares it"
14338
+ ).argument("[inventory]", "the inventory directory", "inventory").option("-e, --environment <name>", "one environment only, as a flat app \u2192 target map").action(async (inventory, opts, command) => {
14260
14339
  const ctx = contextOf2(command);
14261
14340
  const targets = await readDeployTargets(ctx, resolve4(inventory));
14262
- ctx.result(targets, (t) => JSON.stringify(t));
14341
+ const result = opts.environment ? targetsIn(targets, opts.environment) : targets;
14342
+ ctx.result(result, (t) => JSON.stringify(t));
14263
14343
  });
14264
14344
  }
14265
14345
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexus-ms/cli",
3
- "version": "0.104.0",
3
+ "version": "0.106.0",
4
4
  "description": "plx, the Plexus command-line tool: a single-script adapter over @plexus-ms/lib",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@inquirer/prompts": "^8.7.5",
27
- "@plexus-ms/lib": "0.104.0",
27
+ "@plexus-ms/lib": "0.106.0",
28
28
  "commander": "^15.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^26.6.5",
31
+ "@types/node": "^24.19.2",
32
32
  "esbuild": "^0.28.2",
33
33
  "typescript": "^6.0.3"
34
34
  },