@plexus-ms/cli 0.113.0 → 0.115.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/plx.js +46 -25
- package/package.json +2 -2
package/dist/plx.js
CHANGED
|
@@ -7566,23 +7566,24 @@ function frontmatterField(text, key) {
|
|
|
7566
7566
|
}
|
|
7567
7567
|
|
|
7568
7568
|
// ../lib/dist/bookkeeping.js
|
|
7569
|
+
var COLLECTIONS = ["host", "platform", "infrastructure", "ci"];
|
|
7570
|
+
var galaxyFile = (collection) => `ansible/${collection}/galaxy.yml`;
|
|
7569
7571
|
var bumpGalaxyVersion = (text, train) => text.replace(/^(version: )\d+\.\d+\.\d+/m, `$1${train}`);
|
|
7570
7572
|
var COLLECTION_SOURCE = "plexus-ms/primitives.git";
|
|
7571
7573
|
function bumpCollectionPin(text, train) {
|
|
7572
7574
|
const lines = text.split("\n");
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7575
|
+
let ours = false;
|
|
7576
|
+
for (let i = 0; i < lines.length; i++) {
|
|
7577
|
+
const line = lines[i] ?? "";
|
|
7578
|
+
if (/^\s*- /.test(line))
|
|
7579
|
+
ours = line.includes(COLLECTION_SOURCE);
|
|
7580
|
+
const m = /^(\s*version: )v?[\d.]+$/.exec(line);
|
|
7581
|
+
if (ours && m)
|
|
7579
7582
|
lines[i] = `${m[1]}${train}`;
|
|
7580
|
-
break;
|
|
7581
|
-
}
|
|
7582
7583
|
}
|
|
7583
7584
|
return lines.join("\n");
|
|
7584
7585
|
}
|
|
7585
|
-
var RUNNER_IMAGE_PIN_FILE = "ansible/roles/
|
|
7586
|
+
var RUNNER_IMAGE_PIN_FILE = "ansible/ci/roles/actions_runners/defaults/main.yml";
|
|
7586
7587
|
var bumpRunnerImagePin = (text, train) => text.replace(/(ghcr\.io\/plexus-ms\/ci-runner:)\d+\.\d+\.\d+/g, `$1${train}`);
|
|
7587
7588
|
var WORKFLOW_REF = "plexus-ms/primitives/.github/workflows/";
|
|
7588
7589
|
var bumpWorkflowRefs = (text, train) => text.replace(/(plexus-ms\/primitives\/\.github\/workflows\/[A-Za-z0-9._-]+)@v?[0-9.]+/g, `$1@${train}`);
|
|
@@ -7913,14 +7914,26 @@ function expectedBranch(declaration, answers = {}) {
|
|
|
7913
7914
|
return void 0;
|
|
7914
7915
|
}
|
|
7915
7916
|
var presetSource = (preset) => `gh:plexus-ms/${preset}`;
|
|
7917
|
+
var RENAMED_PRESETS = {
|
|
7918
|
+
"preset-repo-web": "preset-repo-turbo",
|
|
7919
|
+
"preset-repo-platform": "preset-repo-operations"
|
|
7920
|
+
};
|
|
7921
|
+
function presetOf(src, presets) {
|
|
7922
|
+
for (const p of presets)
|
|
7923
|
+
if (presetSource(p) === src)
|
|
7924
|
+
return p;
|
|
7925
|
+
for (const [old, current] of Object.entries(RENAMED_PRESETS))
|
|
7926
|
+
if (presetSource(old) === src && presets.includes(current))
|
|
7927
|
+
return current;
|
|
7928
|
+
return void 0;
|
|
7929
|
+
}
|
|
7916
7930
|
async function findConsumers(ctx, root, presets) {
|
|
7917
|
-
const sources = new Map(presets.map((p) => [presetSource(p), p]));
|
|
7918
7931
|
const consumers = /* @__PURE__ */ new Map();
|
|
7919
7932
|
const orphans = [];
|
|
7920
7933
|
const visit = (dir, repo, inTemplate) => {
|
|
7921
7934
|
const here = dir.git ? dir : repo;
|
|
7922
7935
|
const template = inTemplate || Boolean(dir.template);
|
|
7923
|
-
const preset = dir.copier?.src ?
|
|
7936
|
+
const preset = dir.copier?.src ? presetOf(dir.copier.src, presets) : void 0;
|
|
7924
7937
|
if (preset && !template) {
|
|
7925
7938
|
const site = { path: dir.path, rel: relative(root.path, dir.path) || ".", preset };
|
|
7926
7939
|
if (!here)
|
|
@@ -8182,9 +8195,9 @@ function compareTrains(a, b) {
|
|
|
8182
8195
|
var PRIMITIVES = "primitives";
|
|
8183
8196
|
var TRAIN_REPOS = [
|
|
8184
8197
|
PRIMITIVES,
|
|
8185
|
-
"preset-repo-
|
|
8198
|
+
"preset-repo-turbo",
|
|
8186
8199
|
"preset-app-nextjs",
|
|
8187
|
-
"preset-repo-
|
|
8200
|
+
"preset-repo-operations",
|
|
8188
8201
|
"compendium"
|
|
8189
8202
|
];
|
|
8190
8203
|
var PHASES = [[PRIMITIVES], TRAIN_REPOS.filter((r) => r !== PRIMITIVES)];
|
|
@@ -8367,8 +8380,8 @@ function renderCompose(text, image, path3) {
|
|
|
8367
8380
|
throw new UsageError(`${path3} references \${PLEXUS_DEPLOYMENT_IMAGE} but no image ref was given`);
|
|
8368
8381
|
return text;
|
|
8369
8382
|
}
|
|
8370
|
-
function defaultAppDir(
|
|
8371
|
-
return `/opt/stacks/${
|
|
8383
|
+
function defaultAppDir(app, environment = DEFAULT_ENVIRONMENT) {
|
|
8384
|
+
return `/opt/stacks/${deploymentSlug(app, environment)}`;
|
|
8372
8385
|
}
|
|
8373
8386
|
var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
|
|
8374
8387
|
var Remote = class {
|
|
@@ -8426,11 +8439,11 @@ var Remote = class {
|
|
|
8426
8439
|
}
|
|
8427
8440
|
};
|
|
8428
8441
|
async function deploy(ctx, options) {
|
|
8429
|
-
const { host,
|
|
8442
|
+
const { host, app } = options;
|
|
8430
8443
|
const dir = options.dir ?? ".";
|
|
8431
8444
|
const image = options.image || void 0;
|
|
8432
8445
|
const environment = options.environment || DEFAULT_ENVIRONMENT;
|
|
8433
|
-
const appDir = options.appDir || defaultAppDir(
|
|
8446
|
+
const appDir = options.appDir || defaultAppDir(app, environment);
|
|
8434
8447
|
const source = options.source || `apps/${app}`;
|
|
8435
8448
|
const retries = options.retries ?? 30;
|
|
8436
8449
|
let compose;
|
|
@@ -8780,6 +8793,14 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
|
8780
8793
|
await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
|
|
8781
8794
|
} else {
|
|
8782
8795
|
ctx.say(`\u2192 ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ""}`);
|
|
8796
|
+
const answers = await ctx.readFile(join7(target, ANSWERS_FILE));
|
|
8797
|
+
const current = presetSource(site.preset);
|
|
8798
|
+
const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
|
|
8799
|
+
if (recorded && recorded !== current && Object.keys(RENAMED_PRESETS).some((old) => presetSource(old) === recorded)) {
|
|
8800
|
+
ctx.say(` ${site.rel}: the preset is ${current} now; the answers follow`);
|
|
8801
|
+
await ctx.stage(write(join7(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
|
|
8802
|
+
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the preset's name since its rename`);
|
|
8803
|
+
}
|
|
8783
8804
|
const args = [
|
|
8784
8805
|
"update",
|
|
8785
8806
|
"--skip-answered",
|
|
@@ -9235,14 +9256,15 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
|
|
|
9235
9256
|
const grep = async (r, needle, pathspecs) => (await ctx.read("git", ["grep", "-l", needle, "--", ...pathspecs], { cwd: r.path }).catch(() => "")).split("\n").filter(Boolean);
|
|
9236
9257
|
const primitives = repo(PRIMITIVES);
|
|
9237
9258
|
if (primitives) {
|
|
9238
|
-
|
|
9259
|
+
for (const c of COLLECTIONS)
|
|
9260
|
+
await edit(primitives, galaxyFile(c), `plexus.${c} version \u2192 ${next}`, (t) => bumpGalaxyVersion(t, next));
|
|
9239
9261
|
await edit(primitives, RUNNER_IMAGE_PIN_FILE, `runner image \u2192 ${next}`, (t) => bumpRunnerImagePin(t, next));
|
|
9240
9262
|
for (const p of TRAIN_PACKAGES)
|
|
9241
9263
|
await edit(primitives, `${p.dir}/package.json`, `${p.name} \u2192 ${next}`, (t) => bumpManifestVersion(t, next));
|
|
9242
9264
|
}
|
|
9243
|
-
const
|
|
9244
|
-
if (
|
|
9245
|
-
await edit(
|
|
9265
|
+
const operationsPreset = repo("preset-repo-operations");
|
|
9266
|
+
if (operationsPreset)
|
|
9267
|
+
await edit(operationsPreset, "template/requirements.yml", `plexus.* pins \u2192 ${next}`, (t) => bumpCollectionPin(t, next));
|
|
9246
9268
|
for (const r of repos2) {
|
|
9247
9269
|
for (const f of await grep(r, WORKFLOW_REF, ["*.yml", "*.yaml", "*.jinja"]))
|
|
9248
9270
|
await edit(r, f, `workflow refs \u2192 @${next}`, (t) => bumpWorkflowRefs(t, next));
|
|
@@ -14229,7 +14251,7 @@ import { resolve as resolve2 } from "node:path";
|
|
|
14229
14251
|
function register2(program2) {
|
|
14230
14252
|
program2.command("deploy").description(
|
|
14231
14253
|
"render the app\u2019s compose file with the image pinned, stage it on the host, pull, migrate, swap, up, poll readiness, roll back on failure"
|
|
14232
|
-
).argument("<host>", "ssh target, deploy@host").argument("<
|
|
14254
|
+
).argument("<host>", "ssh target, deploy@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(
|
|
14233
14255
|
"--health-url <url>",
|
|
14234
14256
|
"readiness URL polled on the host (default: /healthz, or the plexus.healthz label, on the loopback port)"
|
|
14235
14257
|
).option("--retries <n>", "poll attempts, two seconds apart", "30").option(
|
|
@@ -14237,12 +14259,11 @@ function register2(program2) {
|
|
|
14237
14259
|
"the environment deployed into; decides the app dir\u2019s slug (default: production)"
|
|
14238
14260
|
).option(
|
|
14239
14261
|
"--app-dir <path>",
|
|
14240
|
-
"the app dir on the host (default: /opt/stacks/<
|
|
14241
|
-
).option("--source <path>", "the app\u2019s dir in the checkout (default: apps/<app>)").option("-C, --dir <dir>", "the checkout to read", ".").action(async (host,
|
|
14262
|
+
"the app dir on the host (default: /opt/stacks/<app>, or <app>-<environment> outside production)"
|
|
14263
|
+
).option("--source <path>", "the app\u2019s dir in the checkout (default: apps/<app>)").option("-C, --dir <dir>", "the checkout to read", ".").action(async (host, app, opts, command) => {
|
|
14242
14264
|
const ctx = contextOf2(command);
|
|
14243
14265
|
const result = await deploy(ctx, {
|
|
14244
14266
|
host,
|
|
14245
|
-
tenant,
|
|
14246
14267
|
app,
|
|
14247
14268
|
image: opts.image,
|
|
14248
14269
|
healthUrl: opts.healthUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexus-ms/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.115.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,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@inquirer/prompts": "^8.7.5",
|
|
27
|
-
"@plexus-ms/lib": "0.
|
|
27
|
+
"@plexus-ms/lib": "0.115.0",
|
|
28
28
|
"commander": "^15.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|