@plexus-ms/cli 0.128.0 → 0.129.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.
- package/dist/plx.js +200 -50
- package/package.json +2 -2
package/dist/plx.js
CHANGED
|
@@ -103,7 +103,7 @@ var require_visit = __commonJS({
|
|
|
103
103
|
var BREAK = /* @__PURE__ */ Symbol("break visit");
|
|
104
104
|
var SKIP = /* @__PURE__ */ Symbol("skip children");
|
|
105
105
|
var REMOVE = /* @__PURE__ */ Symbol("remove node");
|
|
106
|
-
function
|
|
106
|
+
function visit2(node, visitor) {
|
|
107
107
|
const visitor_ = initVisitor(visitor);
|
|
108
108
|
if (identity2.isDocument(node)) {
|
|
109
109
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
@@ -112,9 +112,9 @@ var require_visit = __commonJS({
|
|
|
112
112
|
} else
|
|
113
113
|
visit_(null, node, visitor_, Object.freeze([]));
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
visit2.BREAK = BREAK;
|
|
116
|
+
visit2.SKIP = SKIP;
|
|
117
|
+
visit2.REMOVE = REMOVE;
|
|
118
118
|
function visit_(key, node, visitor, path3) {
|
|
119
119
|
const ctrl = callVisitor(key, node, visitor, path3);
|
|
120
120
|
if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
|
|
@@ -248,7 +248,7 @@ var require_visit = __commonJS({
|
|
|
248
248
|
throw new Error(`Cannot replace node with ${pt} parent`);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
exports.visit =
|
|
251
|
+
exports.visit = visit2;
|
|
252
252
|
exports.visitAsync = visitAsync;
|
|
253
253
|
}
|
|
254
254
|
});
|
|
@@ -258,7 +258,7 @@ var require_directives = __commonJS({
|
|
|
258
258
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/directives.js"(exports) {
|
|
259
259
|
"use strict";
|
|
260
260
|
var identity2 = require_identity();
|
|
261
|
-
var
|
|
261
|
+
var visit2 = require_visit();
|
|
262
262
|
var escapeChars = {
|
|
263
263
|
"!": "%21",
|
|
264
264
|
",": "%2C",
|
|
@@ -402,7 +402,7 @@ var require_directives = __commonJS({
|
|
|
402
402
|
let tagNames;
|
|
403
403
|
if (doc && tagEntries.length > 0 && identity2.isNode(doc.contents)) {
|
|
404
404
|
const tags = {};
|
|
405
|
-
|
|
405
|
+
visit2.visit(doc.contents, (_key, node) => {
|
|
406
406
|
if (identity2.isNode(node) && node.tag)
|
|
407
407
|
tags[node.tag] = true;
|
|
408
408
|
});
|
|
@@ -429,7 +429,7 @@ var require_anchors = __commonJS({
|
|
|
429
429
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/anchors.js"(exports) {
|
|
430
430
|
"use strict";
|
|
431
431
|
var identity2 = require_identity();
|
|
432
|
-
var
|
|
432
|
+
var visit2 = require_visit();
|
|
433
433
|
function anchorIsValid(anchor) {
|
|
434
434
|
if (/[\x00-\x19\s,[\]{}]/.test(anchor)) {
|
|
435
435
|
const sa = JSON.stringify(anchor);
|
|
@@ -440,7 +440,7 @@ var require_anchors = __commonJS({
|
|
|
440
440
|
}
|
|
441
441
|
function anchorNames(root) {
|
|
442
442
|
const anchors = /* @__PURE__ */ new Set();
|
|
443
|
-
|
|
443
|
+
visit2.visit(root, {
|
|
444
444
|
Value(_key, node) {
|
|
445
445
|
if (node.anchor)
|
|
446
446
|
anchors.add(node.anchor);
|
|
@@ -620,7 +620,7 @@ var require_Alias = __commonJS({
|
|
|
620
620
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Alias.js"(exports) {
|
|
621
621
|
"use strict";
|
|
622
622
|
var anchors = require_anchors();
|
|
623
|
-
var
|
|
623
|
+
var visit2 = require_visit();
|
|
624
624
|
var identity2 = require_identity();
|
|
625
625
|
var Node = require_Node();
|
|
626
626
|
var toJS = require_toJS();
|
|
@@ -646,7 +646,7 @@ var require_Alias = __commonJS({
|
|
|
646
646
|
nodes = ctx.aliasResolveCache;
|
|
647
647
|
} else {
|
|
648
648
|
nodes = [];
|
|
649
|
-
|
|
649
|
+
visit2.visit(doc, {
|
|
650
650
|
Node: (_key, node) => {
|
|
651
651
|
if (identity2.isAlias(node) || identity2.hasAnchor(node))
|
|
652
652
|
nodes.push(node);
|
|
@@ -5568,15 +5568,15 @@ var require_cst_visit = __commonJS({
|
|
|
5568
5568
|
var BREAK = /* @__PURE__ */ Symbol("break visit");
|
|
5569
5569
|
var SKIP = /* @__PURE__ */ Symbol("skip children");
|
|
5570
5570
|
var REMOVE = /* @__PURE__ */ Symbol("remove item");
|
|
5571
|
-
function
|
|
5571
|
+
function visit2(cst, visitor) {
|
|
5572
5572
|
if ("type" in cst && cst.type === "document")
|
|
5573
5573
|
cst = { start: cst.start, value: cst.value };
|
|
5574
5574
|
_visit(Object.freeze([]), cst, visitor);
|
|
5575
5575
|
}
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5576
|
+
visit2.BREAK = BREAK;
|
|
5577
|
+
visit2.SKIP = SKIP;
|
|
5578
|
+
visit2.REMOVE = REMOVE;
|
|
5579
|
+
visit2.itemAtPath = (cst, path3) => {
|
|
5580
5580
|
let item = cst;
|
|
5581
5581
|
for (const [field, index] of path3) {
|
|
5582
5582
|
const tok = item?.[field];
|
|
@@ -5587,8 +5587,8 @@ var require_cst_visit = __commonJS({
|
|
|
5587
5587
|
}
|
|
5588
5588
|
return item;
|
|
5589
5589
|
};
|
|
5590
|
-
|
|
5591
|
-
const parent =
|
|
5590
|
+
visit2.parentCollection = (cst, path3) => {
|
|
5591
|
+
const parent = visit2.itemAtPath(cst, path3.slice(0, -1));
|
|
5592
5592
|
const field = path3[path3.length - 1][0];
|
|
5593
5593
|
const coll = parent?.[field];
|
|
5594
5594
|
if (coll && "items" in coll)
|
|
@@ -5619,7 +5619,7 @@ var require_cst_visit = __commonJS({
|
|
|
5619
5619
|
}
|
|
5620
5620
|
return typeof ctrl === "function" ? ctrl(item, path3) : ctrl;
|
|
5621
5621
|
}
|
|
5622
|
-
exports.visit =
|
|
5622
|
+
exports.visit = visit2;
|
|
5623
5623
|
}
|
|
5624
5624
|
});
|
|
5625
5625
|
|
|
@@ -7249,7 +7249,7 @@ var require_public_api = __commonJS({
|
|
|
7249
7249
|
return docs;
|
|
7250
7250
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
7251
7251
|
}
|
|
7252
|
-
function
|
|
7252
|
+
function parseDocument3(source, options = {}) {
|
|
7253
7253
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
7254
7254
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
7255
7255
|
const composer$1 = new composer.Composer(options);
|
|
@@ -7275,7 +7275,7 @@ var require_public_api = __commonJS({
|
|
|
7275
7275
|
} else if (options === void 0 && reviver && typeof reviver === "object") {
|
|
7276
7276
|
options = reviver;
|
|
7277
7277
|
}
|
|
7278
|
-
const doc =
|
|
7278
|
+
const doc = parseDocument3(src, options);
|
|
7279
7279
|
if (!doc)
|
|
7280
7280
|
return null;
|
|
7281
7281
|
doc.warnings.forEach((warning) => log.warn(doc.options.logLevel, warning));
|
|
@@ -7311,7 +7311,7 @@ var require_public_api = __commonJS({
|
|
|
7311
7311
|
}
|
|
7312
7312
|
exports.parse = parse7;
|
|
7313
7313
|
exports.parseAllDocuments = parseAllDocuments;
|
|
7314
|
-
exports.parseDocument =
|
|
7314
|
+
exports.parseDocument = parseDocument3;
|
|
7315
7315
|
exports.stringify = stringify2;
|
|
7316
7316
|
}
|
|
7317
7317
|
});
|
|
@@ -7335,7 +7335,7 @@ var require_dist = __commonJS({
|
|
|
7335
7335
|
var lineCounter = require_line_counter();
|
|
7336
7336
|
var parser = require_parser();
|
|
7337
7337
|
var publicApi = require_public_api();
|
|
7338
|
-
var
|
|
7338
|
+
var visit2 = require_visit();
|
|
7339
7339
|
exports.Composer = composer.Composer;
|
|
7340
7340
|
exports.Document = Document.Document;
|
|
7341
7341
|
exports.Schema = Schema.Schema;
|
|
@@ -7363,8 +7363,8 @@ var require_dist = __commonJS({
|
|
|
7363
7363
|
exports.parseAllDocuments = publicApi.parseAllDocuments;
|
|
7364
7364
|
exports.parseDocument = publicApi.parseDocument;
|
|
7365
7365
|
exports.stringify = publicApi.stringify;
|
|
7366
|
-
exports.visit =
|
|
7367
|
-
exports.visitAsync =
|
|
7366
|
+
exports.visit = visit2.visit;
|
|
7367
|
+
exports.visitAsync = visit2.visitAsync;
|
|
7368
7368
|
}
|
|
7369
7369
|
});
|
|
7370
7370
|
|
|
@@ -10378,6 +10378,8 @@ function parseCompose(text, path3) {
|
|
|
10378
10378
|
return { services, ...isMapping(doc) && doc.include != null ? { includes: true } : {} };
|
|
10379
10379
|
}
|
|
10380
10380
|
var IMAGE_PLACEHOLDER = /\$\{PLEXUS_DEPLOYMENT_IMAGE(:[^}]*)?\}/g;
|
|
10381
|
+
var DISPLAY_VERSION_PLACEHOLDER = /\$\{PLEXUS_DISPLAY_VERSION(:[^}]*)?\}/g;
|
|
10382
|
+
var COMMIT_SHA_PLACEHOLDER = /\$\{PLEXUS_COMMIT_SHA(:[^}]*)?\}/g;
|
|
10381
10383
|
var normalImage = (image) => image.replace(IMAGE_PLACEHOLDER, "${PLEXUS_DEPLOYMENT_IMAGE}");
|
|
10382
10384
|
var CONCATENATED = /* @__PURE__ */ new Set([
|
|
10383
10385
|
"ports",
|
|
@@ -10635,7 +10637,7 @@ var holdsApp = (entries) => entries.some((e) => !e.name.startsWith(".")) && !ent
|
|
|
10635
10637
|
var isOperations = (dir) => dir.copier?.src !== void 0 && templateOf(dir.copier.src, [OPERATIONS_TEMPLATE]) !== void 0;
|
|
10636
10638
|
function unitsOf(root) {
|
|
10637
10639
|
const units = [];
|
|
10638
|
-
const
|
|
10640
|
+
const visit2 = (dir, repo, inApps) => {
|
|
10639
10641
|
let here = repo;
|
|
10640
10642
|
if (dir.gitRoot) {
|
|
10641
10643
|
here = dir;
|
|
@@ -10646,12 +10648,12 @@ function unitsOf(root) {
|
|
|
10646
10648
|
for (const child of dir.children) {
|
|
10647
10649
|
if (child.name === APPS_DIR && here === dir)
|
|
10648
10650
|
for (const app of child.children)
|
|
10649
|
-
|
|
10651
|
+
visit2(app, here, true);
|
|
10650
10652
|
else
|
|
10651
|
-
|
|
10653
|
+
visit2(child, here, false);
|
|
10652
10654
|
}
|
|
10653
10655
|
};
|
|
10654
|
-
|
|
10656
|
+
visit2(root, void 0, false);
|
|
10655
10657
|
return units;
|
|
10656
10658
|
}
|
|
10657
10659
|
function shortRemote(url) {
|
|
@@ -10893,7 +10895,7 @@ function expectedBranch(repo) {
|
|
|
10893
10895
|
async function findConsumers(ctx, root, templates) {
|
|
10894
10896
|
const consumers = /* @__PURE__ */ new Map();
|
|
10895
10897
|
const orphans = [];
|
|
10896
|
-
const
|
|
10898
|
+
const visit2 = (dir, repo, inTemplate) => {
|
|
10897
10899
|
const here = dir.git ? dir : repo;
|
|
10898
10900
|
const within = inTemplate || Boolean(dir.template);
|
|
10899
10901
|
const template = dir.copier?.src ? templateOf(dir.copier.src, templates) : void 0;
|
|
@@ -10918,9 +10920,9 @@ async function findConsumers(ctx, root, templates) {
|
|
|
10918
10920
|
}
|
|
10919
10921
|
}
|
|
10920
10922
|
for (const child of dir.children)
|
|
10921
|
-
|
|
10923
|
+
visit2(child, here, within);
|
|
10922
10924
|
};
|
|
10923
|
-
|
|
10925
|
+
visit2(root, void 0, false);
|
|
10924
10926
|
for (const site2 of orphans)
|
|
10925
10927
|
ctx.say(`\u26A0 ${site2.rel}: not inside a git repo \u2014 skipped`);
|
|
10926
10928
|
for (const c of consumers.values()) {
|
|
@@ -11094,6 +11096,7 @@ function indent(text) {
|
|
|
11094
11096
|
}
|
|
11095
11097
|
|
|
11096
11098
|
// ../lib/dist/deploy.js
|
|
11099
|
+
var import_yaml6 = __toESM(require_dist(), 1);
|
|
11097
11100
|
import { randomBytes } from "node:crypto";
|
|
11098
11101
|
import { tmpdir } from "node:os";
|
|
11099
11102
|
import { join as join6 } from "node:path";
|
|
@@ -11220,6 +11223,90 @@ function renderCompose(text, image, path3) {
|
|
|
11220
11223
|
throw new UsageError(`${path3} references \${PLEXUS_DEPLOYMENT_IMAGE} but no image ref was given`);
|
|
11221
11224
|
return text;
|
|
11222
11225
|
}
|
|
11226
|
+
var DISPLAY_VERSION_PIN = {
|
|
11227
|
+
key: "displayVersion",
|
|
11228
|
+
placeholder: DISPLAY_VERSION_PLACEHOLDER,
|
|
11229
|
+
held: "[0-9A-Za-z][0-9A-Za-z.+_-]*",
|
|
11230
|
+
sentinel: "PLEXUSDISPLAYVERSION0"
|
|
11231
|
+
};
|
|
11232
|
+
var COMMIT_SHA_PIN = {
|
|
11233
|
+
key: "commitSha",
|
|
11234
|
+
placeholder: COMMIT_SHA_PLACEHOLDER,
|
|
11235
|
+
held: "[0-9a-f]+",
|
|
11236
|
+
sentinel: "PLEXUSCOMMITSHA0"
|
|
11237
|
+
};
|
|
11238
|
+
var PINS = [DISPLAY_VERSION_PIN, COMMIT_SHA_PIN];
|
|
11239
|
+
function pinValue(text, pin, value, path3) {
|
|
11240
|
+
const placeholder = new RegExp(pin.placeholder.source, "g");
|
|
11241
|
+
if (!placeholder.test(text))
|
|
11242
|
+
return text;
|
|
11243
|
+
const whole = new RegExp(`^${pin.placeholder.source}$`);
|
|
11244
|
+
const plain = [];
|
|
11245
|
+
const doc = (0, import_yaml6.parseDocument)(text);
|
|
11246
|
+
if (doc.errors.length > 0)
|
|
11247
|
+
throw new UsageError(`${path3} is not valid YAML: ${doc.errors[0]?.message}`);
|
|
11248
|
+
(0, import_yaml6.visit)(doc, {
|
|
11249
|
+
Scalar(_key, node) {
|
|
11250
|
+
if (node.type === "PLAIN" && typeof node.value === "string" && whole.test(node.value) && node.range)
|
|
11251
|
+
plain.push([node.range[0], node.range[1]]);
|
|
11252
|
+
}
|
|
11253
|
+
});
|
|
11254
|
+
let out = text;
|
|
11255
|
+
for (const [start, end] of plain.sort((a, b) => b[0] - a[0]))
|
|
11256
|
+
out = `${out.slice(0, start)}${JSON.stringify(value)}${out.slice(end)}`;
|
|
11257
|
+
return out.replace(new RegExp(pin.placeholder.source, "g"), value);
|
|
11258
|
+
}
|
|
11259
|
+
var DISPLAY_VERSION = /^[0-9A-Za-z][0-9A-Za-z.+_-]*$/;
|
|
11260
|
+
function renderDisplayVersion(text, displayVersion, path3) {
|
|
11261
|
+
if (!displayVersion)
|
|
11262
|
+
return text;
|
|
11263
|
+
if (!DISPLAY_VERSION.test(displayVersion))
|
|
11264
|
+
throw new UsageError(`display version ${JSON.stringify(displayVersion)}: only letters, digits and . + _ - are allowed, starting with a letter or digit`);
|
|
11265
|
+
return pinValue(text, DISPLAY_VERSION_PIN, displayVersion, path3);
|
|
11266
|
+
}
|
|
11267
|
+
var COMMIT_SHA = /^([0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
11268
|
+
function renderCommitSha(text, commitSha, path3) {
|
|
11269
|
+
if (!commitSha)
|
|
11270
|
+
return text;
|
|
11271
|
+
if (!COMMIT_SHA.test(commitSha))
|
|
11272
|
+
throw new UsageError(`commit sha ${JSON.stringify(commitSha)}: a full commit hash, 40 or 64 hex digits in lower case`);
|
|
11273
|
+
return pinValue(text, COMMIT_SHA_PIN, commitSha, path3);
|
|
11274
|
+
}
|
|
11275
|
+
function shownBy(shape, given, serving) {
|
|
11276
|
+
let marked = shape;
|
|
11277
|
+
const used = [];
|
|
11278
|
+
for (const pin of PINS) {
|
|
11279
|
+
if (!given[pin.key])
|
|
11280
|
+
continue;
|
|
11281
|
+
const next = pinValue(marked, pin, pin.sentinel, "");
|
|
11282
|
+
if (next !== marked)
|
|
11283
|
+
used.push(pin);
|
|
11284
|
+
marked = next;
|
|
11285
|
+
}
|
|
11286
|
+
marked = marked.trimEnd();
|
|
11287
|
+
if (used.length === 0)
|
|
11288
|
+
return serving.trimEnd() === marked ? {} : void 0;
|
|
11289
|
+
const groups = /* @__PURE__ */ new Map();
|
|
11290
|
+
let source = "";
|
|
11291
|
+
for (const part of marked.split(new RegExp(`(${used.map((pin) => pin.sentinel).join("|")})`))) {
|
|
11292
|
+
const pin = used.find((u) => u.sentinel === part);
|
|
11293
|
+
if (!pin) {
|
|
11294
|
+
source += part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11295
|
+
continue;
|
|
11296
|
+
}
|
|
11297
|
+
const group = groups.get(pin.key);
|
|
11298
|
+
if (group === void 0) {
|
|
11299
|
+
groups.set(pin.key, groups.size + 1);
|
|
11300
|
+
source += `(${pin.held})`;
|
|
11301
|
+
} else
|
|
11302
|
+
source += `\\${group}`;
|
|
11303
|
+
}
|
|
11304
|
+
const match = new RegExp(`^${source}$`).exec(serving.trimEnd());
|
|
11305
|
+
if (!match)
|
|
11306
|
+
return void 0;
|
|
11307
|
+
return Object.fromEntries([...groups].map(([key, group]) => [key, match[group]]));
|
|
11308
|
+
}
|
|
11309
|
+
var describeShown = (shown) => [shown.displayVersion, shown.commitSha && `at ${shown.commitSha.slice(0, 7)}`].filter(Boolean).join(" ");
|
|
11223
11310
|
function defaultAppDir(app, environment = DEFAULT_ENVIRONMENT) {
|
|
11224
11311
|
return `/opt/stacks/${deploymentSlug(app, environment)}`;
|
|
11225
11312
|
}
|
|
@@ -11311,7 +11398,13 @@ async function deploy(ctx, options) {
|
|
|
11311
11398
|
}
|
|
11312
11399
|
if (compose === void 0)
|
|
11313
11400
|
throw new UsageError(`no compose.yaml under ${source}; run from the app's source repo (\xA7 2 PLX-App)`);
|
|
11314
|
-
const
|
|
11401
|
+
const withImage = renderCompose(text, image, compose);
|
|
11402
|
+
const withVersion = renderDisplayVersion(withImage, options.displayVersion || void 0, compose);
|
|
11403
|
+
const rendered = renderCommitSha(withVersion, options.commitSha || void 0, compose);
|
|
11404
|
+
const pinned = {
|
|
11405
|
+
...withVersion === withImage ? {} : { displayVersion: options.displayVersion },
|
|
11406
|
+
...rendered === withVersion ? {} : { commitSha: options.commitSha }
|
|
11407
|
+
};
|
|
11315
11408
|
const budget = retries * 2;
|
|
11316
11409
|
const check = healthcheckOf(parseCompose(rendered, compose));
|
|
11317
11410
|
if (!declaresHealthcheck(check))
|
|
@@ -11322,6 +11415,14 @@ async function deploy(ctx, options) {
|
|
|
11322
11415
|
ctx.say(` host: ${host}`);
|
|
11323
11416
|
ctx.say(` dir: ${appDir}`);
|
|
11324
11417
|
ctx.say(` compose: ${compose}`);
|
|
11418
|
+
if (pinned.displayVersion)
|
|
11419
|
+
ctx.say(` display: ${pinned.displayVersion}`);
|
|
11420
|
+
else if (options.displayVersion)
|
|
11421
|
+
ctx.say(` (${compose} does not use \${PLEXUS_DISPLAY_VERSION}; the display version is not pinned)`, 1);
|
|
11422
|
+
if (pinned.commitSha)
|
|
11423
|
+
ctx.say(` commit: ${pinned.commitSha}`);
|
|
11424
|
+
else if (options.commitSha)
|
|
11425
|
+
ctx.say(` (${compose} does not use \${PLEXUS_COMMIT_SHA}; the commit sha is not pinned)`, 1);
|
|
11325
11426
|
ctx.say(" health: the healthcheck of service web, as Docker reports it");
|
|
11326
11427
|
if (slow)
|
|
11327
11428
|
ctx.say(`\u26A0 ${compose}: the web healthcheck ${slow}, so Docker may probe it only every interval while the deploy waits, which then sees it healthy late or rolls it back; set start_interval: 1s and start_period: ${budget}s`);
|
|
@@ -11337,7 +11438,17 @@ async function deploy(ctx, options) {
|
|
|
11337
11438
|
// one fixed loopback port (§ 4 PLX-App), which a second replica could not.
|
|
11338
11439
|
liveImage: `${dc} ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{.Config.Image}}' 2>/dev/null || true`,
|
|
11339
11440
|
image,
|
|
11340
|
-
|
|
11441
|
+
shows: (ref, serving) => shownBy(renderCompose(text, ref, compose), pinned, serving),
|
|
11442
|
+
pinned,
|
|
11443
|
+
result: {
|
|
11444
|
+
host,
|
|
11445
|
+
appDir,
|
|
11446
|
+
compose,
|
|
11447
|
+
image,
|
|
11448
|
+
...pinned,
|
|
11449
|
+
healthy: false,
|
|
11450
|
+
rolledBack: false
|
|
11451
|
+
}
|
|
11341
11452
|
};
|
|
11342
11453
|
const { result } = s;
|
|
11343
11454
|
let staged = false;
|
|
@@ -11382,18 +11493,41 @@ async function alreadyServing(s) {
|
|
|
11382
11493
|
ctx.say(" (nothing more runs when the host already serves this image from this file, healthy)");
|
|
11383
11494
|
return false;
|
|
11384
11495
|
}
|
|
11385
|
-
if (
|
|
11386
|
-
return false;
|
|
11387
|
-
if (!await s.remote.test(`cd ${s.D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`))
|
|
11496
|
+
if (result.previous === void 0)
|
|
11388
11497
|
return false;
|
|
11498
|
+
let same;
|
|
11499
|
+
let shown = {};
|
|
11500
|
+
if (s.image === void 0 || result.previous === s.image && Object.keys(s.pinned).length === 0) {
|
|
11501
|
+
if (!await s.remote.test(`cd ${s.D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`))
|
|
11502
|
+
return false;
|
|
11503
|
+
} else {
|
|
11504
|
+
if (result.previous !== s.image) {
|
|
11505
|
+
if (!await sameImage(s, s.image))
|
|
11506
|
+
return false;
|
|
11507
|
+
same = s.image;
|
|
11508
|
+
}
|
|
11509
|
+
const serving = await s.remote.read(`cat ${s.D}/compose.yaml`);
|
|
11510
|
+
const live = serving === void 0 ? void 0 : s.shows(result.previous, serving);
|
|
11511
|
+
if (live === void 0)
|
|
11512
|
+
return false;
|
|
11513
|
+
shown = live;
|
|
11514
|
+
}
|
|
11389
11515
|
if (!await awaitHealthy(s, 1))
|
|
11390
11516
|
return false;
|
|
11391
11517
|
result.live = result.previous;
|
|
11392
11518
|
result.healthy = true;
|
|
11393
11519
|
result.unchanged = true;
|
|
11394
|
-
|
|
11520
|
+
delete result.displayVersion;
|
|
11521
|
+
delete result.commitSha;
|
|
11522
|
+
Object.assign(result, shown);
|
|
11523
|
+
const showing = describeShown(shown);
|
|
11524
|
+
ctx.done(`${result.previous}${same ? ` (the image ${same} names)` : ""}${showing ? `, showing ${showing},` : ""} is already live and healthy; nothing to do`);
|
|
11395
11525
|
return true;
|
|
11396
11526
|
}
|
|
11527
|
+
function sameImage(s, ref) {
|
|
11528
|
+
const running = `docker compose ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{.Image}}' 2>/dev/null`;
|
|
11529
|
+
return s.remote.test(`cd ${s.D} && docker pull -q ${q(ref)} >/dev/null && id=$(docker image inspect --format '{{.Id}}' ${q(ref)}) && [ -n "$id" ] && [ "$id" = "$(${running})" ]`);
|
|
11530
|
+
}
|
|
11397
11531
|
async function pullAndMigrate(s) {
|
|
11398
11532
|
await s.remote.exec(`${s.dci} pull`);
|
|
11399
11533
|
const migrate = await s.remote.test(`${s.dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
|
|
@@ -11440,7 +11574,7 @@ import { dirname as dirname3, join as join7, relative as relative2, resolve } fr
|
|
|
11440
11574
|
|
|
11441
11575
|
// ../lib/dist/standard-index.json
|
|
11442
11576
|
var standard_index_default = {
|
|
11443
|
-
version: "0.
|
|
11577
|
+
version: "0.129.1",
|
|
11444
11578
|
citable: [
|
|
11445
11579
|
"\xA7 1 PLX",
|
|
11446
11580
|
"\xA7 1.1 PLX",
|
|
@@ -11486,6 +11620,7 @@ var standard_index_default = {
|
|
|
11486
11620
|
"\xA7 6.7 PLX",
|
|
11487
11621
|
"\xA7 6.8 PLX",
|
|
11488
11622
|
"\xA7 6.9 PLX",
|
|
11623
|
+
"\xA7 6.10 PLX",
|
|
11489
11624
|
"\xA7 7 PLX",
|
|
11490
11625
|
"\xA7 7.1 PLX",
|
|
11491
11626
|
"\xA7 7.2 PLX",
|
|
@@ -11651,6 +11786,12 @@ var standard_index_default = {
|
|
|
11651
11786
|
"PLX-Platform/AppRecord",
|
|
11652
11787
|
"PLX-Platform/UniqueAppName",
|
|
11653
11788
|
"PLX-Platform/RecordValues",
|
|
11789
|
+
"\xA7 1 PLX-Releases",
|
|
11790
|
+
"\xA7 2 PLX-Releases",
|
|
11791
|
+
"\xA7 3 PLX-Releases",
|
|
11792
|
+
"\xA7 4 PLX-Releases",
|
|
11793
|
+
"\xA7 5 PLX-Releases",
|
|
11794
|
+
"\xA7 6 PLX-Releases",
|
|
11654
11795
|
"\xA7 1 PLX-Secrets",
|
|
11655
11796
|
"\xA7 2 PLX-Secrets",
|
|
11656
11797
|
"\xA7 3 PLX-Secrets",
|
|
@@ -11911,7 +12052,7 @@ async function examine(ctx, dir) {
|
|
|
11911
12052
|
}
|
|
11912
12053
|
const examination = { root: given, inRepo: false, facts: [], skipped: [], links: [], unreadable: [] };
|
|
11913
12054
|
const rel = (path3) => relative2(given, path3) || ".";
|
|
11914
|
-
const
|
|
12055
|
+
const visit2 = async (d) => {
|
|
11915
12056
|
if (d.unreadable)
|
|
11916
12057
|
examination.unreadable.push({ path: rel(d.path), why: d.unreadable });
|
|
11917
12058
|
if (d.symlink)
|
|
@@ -11924,10 +12065,10 @@ async function examine(ctx, dir) {
|
|
|
11924
12065
|
examination.skipped.push(rel(d.path));
|
|
11925
12066
|
}
|
|
11926
12067
|
for (const child of d.children)
|
|
11927
|
-
await
|
|
12068
|
+
await visit2(child);
|
|
11928
12069
|
};
|
|
11929
12070
|
if (tree)
|
|
11930
|
-
await
|
|
12071
|
+
await visit2(tree);
|
|
11931
12072
|
return examination;
|
|
11932
12073
|
}
|
|
11933
12074
|
var holdsGitRoot = (d) => Boolean(d.gitRoot) || d.children.some(holdsGitRoot);
|
|
@@ -12330,11 +12471,12 @@ function pullBody(p) {
|
|
|
12330
12471
|
...p.lockfile && !p.checked ? ["- The lockfile did not refresh: run `pnpm install` after resolving, and commit the lockfile."] : []
|
|
12331
12472
|
];
|
|
12332
12473
|
const lockfile = p.lockfile && p.checked ? ["- Run `pnpm install` once resolved, and commit the lockfile."] : [];
|
|
12474
|
+
const settled = lockfile.length ? ["- Run `pnpm install`, and commit the lockfile if it changes."] : [];
|
|
12333
12475
|
const head = hand.length > 0 ? `**Needs a hand.** \`plx update\` marks this pull request ready once no tracked file holds a conflict marker and every site's answers record the version.
|
|
12334
12476
|
|
|
12335
|
-
${[...hand, ...lockfile].join("\n")}` : p.checked ? `Ready for review: no tracked file holds a conflict marker, and every site's answers record ${p.version}.${
|
|
12477
|
+
${[...hand, ...lockfile].join("\n")}` : p.checked ? `Ready for review: no tracked file holds a conflict marker, and every site's answers record ${p.version}.${settled.length ? `
|
|
12336
12478
|
|
|
12337
|
-
${
|
|
12479
|
+
${settled.join("\n")}` : ""}` : "Nothing needs a hand: every site merged clean.";
|
|
12338
12480
|
return [
|
|
12339
12481
|
head,
|
|
12340
12482
|
`Plexus ${p.version} (\xA7 1.5 PLX): \`copier update\` at ${p.sites.map(site).join(", ")}, the lockfile where manifests moved, and the workflow refs.`,
|
|
@@ -13222,7 +13364,7 @@ function renderSummary(s, realCommand, verb = "update") {
|
|
|
13222
13364
|
|
|
13223
13365
|
// ../lib/dist/umbrella.js
|
|
13224
13366
|
var import_semver = __toESM(require_semver2(), 1);
|
|
13225
|
-
var
|
|
13367
|
+
var import_yaml7 = __toESM(require_dist(), 1);
|
|
13226
13368
|
import { join as join11 } from "node:path";
|
|
13227
13369
|
var UMBRELLA_MARK = "Generated by `plx umbrella up`; `plx umbrella down` removes it.";
|
|
13228
13370
|
var UMBRELLA_STATE = ".plx-umbrella";
|
|
@@ -13266,7 +13408,7 @@ function mergeWorkspaces(repos2) {
|
|
|
13266
13408
|
let settings = {};
|
|
13267
13409
|
const seen = {};
|
|
13268
13410
|
for (const repo of repos2) {
|
|
13269
|
-
const own = (0,
|
|
13411
|
+
const own = (0, import_yaml7.parse)(repo.workspace);
|
|
13270
13412
|
const { packages: globs, ...rest } = isMapping2(own) ? own : {};
|
|
13271
13413
|
packages.push(repo.name);
|
|
13272
13414
|
for (const glob of Array.isArray(globs) ? globs.map(String) : [])
|
|
@@ -13344,7 +13486,7 @@ function planUp(dir, repos2) {
|
|
|
13344
13486
|
stopWatcher(dir),
|
|
13345
13487
|
run("mkdir", ["-p", join11(dir, UMBRELLA_STATE)]),
|
|
13346
13488
|
write(join11(dir, WORKSPACE), `# ${UMBRELLA_MARK}
|
|
13347
|
-
${(0,
|
|
13489
|
+
${(0, import_yaml7.stringify)(settings)}`),
|
|
13348
13490
|
write(join11(dir, MISE), `# ${UMBRELLA_MARK}
|
|
13349
13491
|
[env]
|
|
13350
13492
|
${UMBRELLA_ROOT_VAR} = "{{config_root}}"
|
|
@@ -13396,7 +13538,7 @@ async function expand2(ctx, root, glob) {
|
|
|
13396
13538
|
return entries.filter((e) => e.directory && !e.name.startsWith(".")).map((e) => join11(parent, e.name));
|
|
13397
13539
|
}
|
|
13398
13540
|
async function readRepo2(ctx, dir, name, workspace) {
|
|
13399
|
-
const own = (0,
|
|
13541
|
+
const own = (0, import_yaml7.parse)(workspace);
|
|
13400
13542
|
const globs = isMapping2(own) && Array.isArray(own.packages) ? own.packages.map(String) : [];
|
|
13401
13543
|
const packages = [];
|
|
13402
13544
|
for (const glob of globs.filter((g) => !g.startsWith("!"))) {
|
|
@@ -13466,7 +13608,7 @@ async function readUmbrellaDown(ctx, dir) {
|
|
|
13466
13608
|
throw refuse(dir, foreign);
|
|
13467
13609
|
if (!up)
|
|
13468
13610
|
return { repos: [], plan: [] };
|
|
13469
|
-
const own = (0,
|
|
13611
|
+
const own = (0, import_yaml7.parse)(await ctx.readFile(join11(dir, WORKSPACE)));
|
|
13470
13612
|
const globs = isMapping2(own) && Array.isArray(own.packages) ? own.packages.map(String) : [];
|
|
13471
13613
|
const repos2 = globs.filter((g) => !g.includes("/") && !g.startsWith("!"));
|
|
13472
13614
|
return { repos: repos2, plan: planDown(dir, repos2) };
|
|
@@ -18362,7 +18504,13 @@ import { resolve as resolve3 } from "node:path";
|
|
|
18362
18504
|
function register2(program2) {
|
|
18363
18505
|
program2.command("deploy").description(
|
|
18364
18506
|
"render the app\u2019s compose file with the image pinned, stage it on the host, pull, migrate, swap, up, wait for the healthcheck, roll back on failure"
|
|
18365
|
-
).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(
|
|
18507
|
+
).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(
|
|
18508
|
+
"--display-version <string>",
|
|
18509
|
+
"the string the app shows as its version, pinned where its compose.yaml uses ${PLEXUS_DISPLAY_VERSION}; ignored where it does not"
|
|
18510
|
+
).option(
|
|
18511
|
+
"--commit-sha <sha>",
|
|
18512
|
+
"the commit the deployment is started from, a full hash, pinned where its compose.yaml uses ${PLEXUS_COMMIT_SHA}; ignored where it does not"
|
|
18513
|
+
).option("--retries <n>", "looks at the app container\u2019s health status, two seconds apart", "30").option(
|
|
18366
18514
|
"-e, --environment <name>",
|
|
18367
18515
|
"the environment deployed into; decides the app dir\u2019s slug (default: production)"
|
|
18368
18516
|
).option(
|
|
@@ -18374,6 +18522,8 @@ function register2(program2) {
|
|
|
18374
18522
|
host,
|
|
18375
18523
|
app,
|
|
18376
18524
|
image: opts.image,
|
|
18525
|
+
displayVersion: opts.displayVersion,
|
|
18526
|
+
commitSha: opts.commitSha,
|
|
18377
18527
|
retries: Number(opts.retries),
|
|
18378
18528
|
environment: opts.environment,
|
|
18379
18529
|
appDir: opts.appDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexus-ms/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.129.1",
|
|
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.8.0",
|
|
27
|
-
"@plexus-ms/lib": "0.
|
|
27
|
+
"@plexus-ms/lib": "0.129.1",
|
|
28
28
|
"commander": "^15.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|