@biffo/cli 0.404.1 → 0.406.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/index.js +81 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import chalk2 from "chalk";
|
|
|
13
13
|
import { Command } from "commander";
|
|
14
14
|
|
|
15
15
|
// src/lib/core-manifest.ts
|
|
16
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync } from "fs";
|
|
16
|
+
import { existsSync as existsSync2, lstatSync, readFileSync as readFileSync2, readdirSync, readlinkSync } from "fs";
|
|
17
17
|
import { tmpdir } from "os";
|
|
18
18
|
import { dirname as dirname2, join as join2, relative, resolve, sep } from "path";
|
|
19
19
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -427,7 +427,7 @@ function listTemplateOwnedFiles(root, manifest, options = {}) {
|
|
|
427
427
|
const abs = join2(dir, entry.name);
|
|
428
428
|
if (entry.isDirectory()) {
|
|
429
429
|
walk2(abs);
|
|
430
|
-
} else if (entry.isFile()) {
|
|
430
|
+
} else if (entry.isFile() || entry.isSymbolicLink()) {
|
|
431
431
|
const rel = toPosix(relative(root, abs));
|
|
432
432
|
if (tracked && !tracked.has(rel)) continue;
|
|
433
433
|
if (isTemplateOwned(rel, manifest)) out.push(rel);
|
|
@@ -438,6 +438,9 @@ function listTemplateOwnedFiles(root, manifest, options = {}) {
|
|
|
438
438
|
return out.sort();
|
|
439
439
|
}
|
|
440
440
|
function sameFile(a, b) {
|
|
441
|
+
const la = lstatSync(a).isSymbolicLink();
|
|
442
|
+
const lb = lstatSync(b).isSymbolicLink();
|
|
443
|
+
if (la || lb) return la && lb && readlinkSync(a) === readlinkSync(b);
|
|
441
444
|
return readFileSync2(a).equals(readFileSync2(b));
|
|
442
445
|
}
|
|
443
446
|
function computeCoreDiff(templateRoot, instanceRoot, manifest, baseRoot, options = {}) {
|
|
@@ -514,7 +517,7 @@ async function runCoreDiff(options) {
|
|
|
514
517
|
const diff = computeCoreDiff(templateRoot, options.cwd, manifest);
|
|
515
518
|
const total = diff.added.length + diff.removed.length + diff.modified.length;
|
|
516
519
|
if (options.json) {
|
|
517
|
-
const
|
|
520
|
+
const payload2 = {
|
|
518
521
|
schemaVersion: 1,
|
|
519
522
|
instanceCore: instanceVersion ?? null,
|
|
520
523
|
templateCore: templateVersion,
|
|
@@ -524,7 +527,7 @@ async function runCoreDiff(options) {
|
|
|
524
527
|
instanceOnly: diff.instanceOnly,
|
|
525
528
|
unchanged: diff.unchanged
|
|
526
529
|
};
|
|
527
|
-
console.log(JSON.stringify(
|
|
530
|
+
console.log(JSON.stringify(payload2, null, 2));
|
|
528
531
|
return;
|
|
529
532
|
}
|
|
530
533
|
console.log(chalk2.bold("\n Biffo core diff\n"));
|
|
@@ -650,11 +653,14 @@ import { isUtf8 } from "buffer";
|
|
|
650
653
|
import {
|
|
651
654
|
chmodSync,
|
|
652
655
|
existsSync as existsSync5,
|
|
656
|
+
lstatSync as lstatSync2,
|
|
653
657
|
mkdirSync,
|
|
654
658
|
mkdtempSync,
|
|
655
659
|
readFileSync as readFileSync4,
|
|
660
|
+
readlinkSync as readlinkSync2,
|
|
656
661
|
rmSync,
|
|
657
662
|
statSync,
|
|
663
|
+
symlinkSync,
|
|
658
664
|
writeFileSync as writeFileSync2
|
|
659
665
|
} from "fs";
|
|
660
666
|
import { tmpdir as tmpdir2 } from "os";
|
|
@@ -826,8 +832,18 @@ var gitMergeFile = async (base, ours, theirs) => {
|
|
|
826
832
|
}
|
|
827
833
|
};
|
|
828
834
|
function readFile(root, rel) {
|
|
829
|
-
const
|
|
830
|
-
|
|
835
|
+
const abs = join5(root, rel);
|
|
836
|
+
if (lstatSync2(abs).isSymbolicLink()) {
|
|
837
|
+
return { buffer: Buffer.from(readlinkSync2(abs), "utf8"), text: null, link: true };
|
|
838
|
+
}
|
|
839
|
+
const buffer = readFileSync4(abs);
|
|
840
|
+
return { buffer, text: isUtf8(buffer) ? buffer.toString("utf8") : null, link: false };
|
|
841
|
+
}
|
|
842
|
+
function sameRead(a, b) {
|
|
843
|
+
return a.link === b.link && a.buffer.equals(b.buffer);
|
|
844
|
+
}
|
|
845
|
+
function payload(file) {
|
|
846
|
+
return file.link ? { content: file.buffer, symlink: true } : { content: contentOf(file) };
|
|
831
847
|
}
|
|
832
848
|
function contentOf(file) {
|
|
833
849
|
return file.text ?? file.buffer;
|
|
@@ -981,18 +997,16 @@ async function classify(path, base, ours, theirs, opts, mergeFile, isDeclaredDiv
|
|
|
981
997
|
}
|
|
982
998
|
if (!inBase && inTheirs) {
|
|
983
999
|
const theirsFile2 = readFile(opts.theirsDir, path);
|
|
984
|
-
if (!inOurs) return { path, status: "added", conflicted: false,
|
|
1000
|
+
if (!inOurs) return { path, status: "added", conflicted: false, ...payload(theirsFile2) };
|
|
985
1001
|
const oursFile2 = readFile(opts.oursDir, path);
|
|
986
|
-
if (oursFile2
|
|
987
|
-
|
|
988
|
-
return { path, status: "add-conflict", conflicted: true, content: contentOf(theirsFile2) };
|
|
1002
|
+
if (sameRead(oursFile2, theirsFile2)) return { path, status: "unchanged", conflicted: false };
|
|
1003
|
+
return { path, status: "add-conflict", conflicted: true, ...payload(theirsFile2) };
|
|
989
1004
|
}
|
|
990
1005
|
if (inBase && !inTheirs) {
|
|
991
1006
|
if (!inOurs) return { path, status: "removed", conflicted: false };
|
|
992
1007
|
const baseFile2 = readFile(opts.baseDir, path);
|
|
993
1008
|
const oursFile2 = readFile(opts.oursDir, path);
|
|
994
|
-
if (oursFile2
|
|
995
|
-
return { path, status: "removed", conflicted: false };
|
|
1009
|
+
if (sameRead(oursFile2, baseFile2)) return { path, status: "removed", conflicted: false };
|
|
996
1010
|
return { path, status: "remove-conflict", conflicted: true };
|
|
997
1011
|
}
|
|
998
1012
|
const baseFile = readFile(opts.baseDir, path);
|
|
@@ -1002,26 +1016,33 @@ async function classify(path, base, ours, theirs, opts, mergeFile, isDeclaredDiv
|
|
|
1002
1016
|
noteDivergenceSkip(path);
|
|
1003
1017
|
return { path, status: "removed", conflicted: false };
|
|
1004
1018
|
}
|
|
1005
|
-
return { path, status: "restored", conflicted: false,
|
|
1019
|
+
return { path, status: "restored", conflicted: false, ...payload(theirsFile) };
|
|
1006
1020
|
}
|
|
1007
1021
|
const oursFile = readFile(opts.oursDir, path);
|
|
1008
|
-
const oursChanged = !oursFile
|
|
1009
|
-
const theirsChanged = !theirsFile
|
|
1022
|
+
const oursChanged = !sameRead(oursFile, baseFile);
|
|
1023
|
+
const theirsChanged = !sameRead(theirsFile, baseFile);
|
|
1010
1024
|
if (!theirsChanged) {
|
|
1011
1025
|
return { path, status: oursChanged ? "keep-ours" : "unchanged", conflicted: false };
|
|
1012
1026
|
}
|
|
1013
1027
|
if (!oursChanged) {
|
|
1014
|
-
return { path, status: "take-theirs", conflicted: false,
|
|
1028
|
+
return { path, status: "take-theirs", conflicted: false, ...payload(theirsFile) };
|
|
1015
1029
|
}
|
|
1016
|
-
if (oursFile
|
|
1030
|
+
if (sameRead(oursFile, theirsFile)) {
|
|
1017
1031
|
return { path, status: "unchanged", conflicted: false };
|
|
1018
1032
|
}
|
|
1019
1033
|
if (baseFile.text === null || oursFile.text === null || theirsFile.text === null) {
|
|
1020
|
-
return { path, status: "conflict", conflicted: true,
|
|
1034
|
+
return { path, status: "conflict", conflicted: true, ...payload(theirsFile) };
|
|
1021
1035
|
}
|
|
1022
1036
|
const { conflicted, content } = await mergeFile(baseFile.text, oursFile.text, theirsFile.text);
|
|
1023
1037
|
return { path, status: conflicted ? "conflict" : "merged", conflicted, content };
|
|
1024
1038
|
}
|
|
1039
|
+
function isSymlink(abs) {
|
|
1040
|
+
try {
|
|
1041
|
+
return lstatSync2(abs).isSymbolicLink();
|
|
1042
|
+
} catch {
|
|
1043
|
+
return false;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1025
1046
|
function applyUpgradePlan(instanceDir, plan, theirsDir) {
|
|
1026
1047
|
const written = [];
|
|
1027
1048
|
const deleted = [];
|
|
@@ -1036,6 +1057,12 @@ function applyUpgradePlan(instanceDir, plan, theirsDir) {
|
|
|
1036
1057
|
}
|
|
1037
1058
|
if (e.content !== void 0) {
|
|
1038
1059
|
mkdirSync(dirname3(abs), { recursive: true });
|
|
1060
|
+
if (isSymlink(abs) || e.symlink === true && existsSync5(abs)) rmSync(abs);
|
|
1061
|
+
if (e.symlink === true) {
|
|
1062
|
+
symlinkSync(e.content.toString("utf8"), abs);
|
|
1063
|
+
written.push(e.path);
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1039
1066
|
writeFileSync2(abs, e.content);
|
|
1040
1067
|
if (theirsDir !== void 0) {
|
|
1041
1068
|
const source = join5(theirsDir, e.path);
|
|
@@ -3338,7 +3365,7 @@ function materializeTemplateAtTag(repo, version, git = defaultGit2) {
|
|
|
3338
3365
|
// src/lib/core-upgrade-target-fidelity.ts
|
|
3339
3366
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
3340
3367
|
import { createHash as createHash2 } from "crypto";
|
|
3341
|
-
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "fs";
|
|
3368
|
+
import { existsSync as existsSync8, lstatSync as lstatSync3, readFileSync as readFileSync6 } from "fs";
|
|
3342
3369
|
import { join as join9 } from "path";
|
|
3343
3370
|
var VERBATIM_STATUSES = /* @__PURE__ */ new Set(["take-theirs", "added", "add-conflict", "restored"]);
|
|
3344
3371
|
var DERIVED_STATUSES = /* @__PURE__ */ new Set(["merged", "conflict"]);
|
|
@@ -3347,7 +3374,7 @@ function blobId(content) {
|
|
|
3347
3374
|
const bytes = Buffer.isBuffer(content) ? content : Buffer.from(content, "utf8");
|
|
3348
3375
|
return createHash2("sha1").update(`blob ${String(bytes.length)}\0`).update(bytes).digest("hex");
|
|
3349
3376
|
}
|
|
3350
|
-
function tagBlobIds(repo, tag, git) {
|
|
3377
|
+
function tagBlobIds(repo, tag, git, symlinks = /* @__PURE__ */ new Set()) {
|
|
3351
3378
|
const out = git(["-C", repo, "ls-tree", "-r", "-z", tag]);
|
|
3352
3379
|
const blobs = /* @__PURE__ */ new Map();
|
|
3353
3380
|
for (const record of out.split("\0")) {
|
|
@@ -3358,6 +3385,7 @@ function tagBlobIds(repo, tag, git) {
|
|
|
3358
3385
|
const id = meta[2];
|
|
3359
3386
|
if (meta[1] !== "blob" || id === void 0) continue;
|
|
3360
3387
|
blobs.set(record.slice(tab + 1), id);
|
|
3388
|
+
if (meta[0] === "120000") symlinks.add(record.slice(tab + 1));
|
|
3361
3389
|
}
|
|
3362
3390
|
return blobs;
|
|
3363
3391
|
}
|
|
@@ -3372,8 +3400,9 @@ function assertTargetFidelity(options) {
|
|
|
3372
3400
|
}
|
|
3373
3401
|
const tag = coreTag(options.toVersion);
|
|
3374
3402
|
let blobs;
|
|
3403
|
+
const tagSymlinks = /* @__PURE__ */ new Set();
|
|
3375
3404
|
try {
|
|
3376
|
-
blobs = tagBlobIds(options.templateRepo, tag, git);
|
|
3405
|
+
blobs = tagBlobIds(options.templateRepo, tag, git, tagSymlinks);
|
|
3377
3406
|
} catch (err) {
|
|
3378
3407
|
return {
|
|
3379
3408
|
checked: 0,
|
|
@@ -3405,6 +3434,30 @@ function assertTargetFidelity(options) {
|
|
|
3405
3434
|
}
|
|
3406
3435
|
if (blobId(content) !== expected) {
|
|
3407
3436
|
findings.push({ path: entry.path, reason: "content-differs", source });
|
|
3437
|
+
continue;
|
|
3438
|
+
}
|
|
3439
|
+
if (tagSymlinks.has(entry.path)) {
|
|
3440
|
+
const delivered = source === "output" ? entry.symlink === true : (() => {
|
|
3441
|
+
try {
|
|
3442
|
+
return lstatSync3(join9(options.theirsDir, entry.path)).isSymbolicLink();
|
|
3443
|
+
} catch {
|
|
3444
|
+
return false;
|
|
3445
|
+
}
|
|
3446
|
+
})();
|
|
3447
|
+
if (!delivered) {
|
|
3448
|
+
findings.push({ path: entry.path, reason: "symlink-not-delivered", source });
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
if (options.manifest !== void 0) {
|
|
3453
|
+
const byPath = new Map(options.entries.map((e) => [e.path, e]));
|
|
3454
|
+
for (const path of [...tagSymlinks].sort()) {
|
|
3455
|
+
if (!isTemplateOwned(path, options.manifest)) continue;
|
|
3456
|
+
checked++;
|
|
3457
|
+
const entry = byPath.get(path);
|
|
3458
|
+
if (entry === void 0 || entry.status === "removed" || entry.status === "remove-conflict") {
|
|
3459
|
+
findings.push({ path, reason: "symlink-missing", source: "output" });
|
|
3460
|
+
}
|
|
3408
3461
|
}
|
|
3409
3462
|
}
|
|
3410
3463
|
for (const migration of options.migrations ?? []) {
|
|
@@ -3438,7 +3491,7 @@ function assertTargetFidelity(options) {
|
|
|
3438
3491
|
}
|
|
3439
3492
|
function fidelityFailure(report, toVersion) {
|
|
3440
3493
|
const lines = report.findings.map((f) => {
|
|
3441
|
-
const why = f.reason === "absent-from-tag" ? "resolved content for a path the tag does not contain" : "content differs from the tag";
|
|
3494
|
+
const why = f.reason === "absent-from-tag" ? "resolved content for a path the tag does not contain" : f.reason === "symlink-missing" ? "the tag ships a symlink here and the upgrade does not deliver it" : f.reason === "symlink-not-delivered" ? "the tag ships a symlink here but the upgrade resolved a regular file" : "content differs from the tag";
|
|
3442
3495
|
return ` ${f.path} \u2014 ${why} (${f.source})`;
|
|
3443
3496
|
});
|
|
3444
3497
|
return `This upgrade resolved content that is not what core-v${toVersion} ships, for ${String(report.findings.length)} of ${String(report.checked)} checked path(s):
|
|
@@ -4236,7 +4289,8 @@ async function runCoreUpgradeResolved(options, deps, cleanups) {
|
|
|
4236
4289
|
templateRepo,
|
|
4237
4290
|
toVersion,
|
|
4238
4291
|
theirsDir,
|
|
4239
|
-
explicitTargetTree: options.theirsDir !== void 0
|
|
4292
|
+
explicitTargetTree: options.theirsDir !== void 0,
|
|
4293
|
+
manifest
|
|
4240
4294
|
});
|
|
4241
4295
|
const heading = options.apply ? "Biffo core upgrade" : "Biffo core upgrade (dry run)";
|
|
4242
4296
|
console.log(chalk4.bold(`
|
|
@@ -5353,13 +5407,13 @@ var AwsAdapter = class {
|
|
|
5353
5407
|
* failure it's Lambda's own error envelope (`errorMessage`, `errorType`,
|
|
5354
5408
|
* `stackTrace`).
|
|
5355
5409
|
*/
|
|
5356
|
-
async invokeLambda(functionName,
|
|
5410
|
+
async invokeLambda(functionName, payload2) {
|
|
5357
5411
|
const lambda = new LambdaClient({ region: this.region });
|
|
5358
5412
|
const response = await lambda.send(
|
|
5359
5413
|
new InvokeCommand({
|
|
5360
5414
|
FunctionName: functionName,
|
|
5361
5415
|
InvocationType: "RequestResponse",
|
|
5362
|
-
Payload: Buffer.from(JSON.stringify(
|
|
5416
|
+
Payload: Buffer.from(JSON.stringify(payload2))
|
|
5363
5417
|
})
|
|
5364
5418
|
);
|
|
5365
5419
|
const rawBody = response.Payload ? Buffer.from(response.Payload).toString("utf-8") : "{}";
|
|
@@ -6736,7 +6790,7 @@ var RealCommandRunner = class {
|
|
|
6736
6790
|
// src/lib/plugin-compose/compose-stack.ts
|
|
6737
6791
|
import { spawn } from "child_process";
|
|
6738
6792
|
import { createServer as createServer2 } from "net";
|
|
6739
|
-
import { mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync4, readFileSync as readFileSync15, rmSync as rmSync7, symlinkSync, writeFileSync as writeFileSync6 } from "fs";
|
|
6793
|
+
import { mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync4, readFileSync as readFileSync15, rmSync as rmSync7, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
6740
6794
|
import { existsSync as existsSync22 } from "fs";
|
|
6741
6795
|
import { homedir as homedir2 } from "os";
|
|
6742
6796
|
import { join as join21 } from "path";
|
|
@@ -7455,7 +7509,7 @@ async function composeStack(options, deps) {
|
|
|
7455
7509
|
const appDir = join21(workDir, "apps");
|
|
7456
7510
|
mkdirSync6(servicesRoot, { recursive: true });
|
|
7457
7511
|
mkdirSync6(appDir, { recursive: true });
|
|
7458
|
-
|
|
7512
|
+
symlinkSync2(options.pluginRoot, join21(servicesRoot, manifest.name), "dir");
|
|
7459
7513
|
writeFileSync6(join21(appDir, "core_app.py"), CORE_APP_PY);
|
|
7460
7514
|
writeFileSync6(join21(appDir, "host_app.py"), HOST_APP_PY);
|
|
7461
7515
|
writeFileSync6(join21(appDir, "bootstrap.py"), BOOTSTRAP_PY);
|