@biffo/cli 0.199.1 → 0.199.2
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 +43 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -216,6 +216,34 @@ function latestCoreVersionFromTags(repo, git = defaultTagRunner, options = {}) {
|
|
|
216
216
|
var CORE_TAG_PREFIX = "core-v";
|
|
217
217
|
var defaultTagRunner = (args) => execFileSync("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
218
218
|
|
|
219
|
+
// src/lib/git-tracked-files.ts
|
|
220
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
221
|
+
import { realpathSync } from "fs";
|
|
222
|
+
var defaultGit = (args) => execFileSync2("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
223
|
+
function gitTrackedFiles(root, git = defaultGit) {
|
|
224
|
+
let top;
|
|
225
|
+
try {
|
|
226
|
+
top = git(["-C", root, "rev-parse", "--show-toplevel"]).trim();
|
|
227
|
+
} catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
if (!top) return null;
|
|
231
|
+
try {
|
|
232
|
+
if (realpathSync(top) !== realpathSync(root)) return null;
|
|
233
|
+
} catch {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
let out;
|
|
237
|
+
try {
|
|
238
|
+
out = git(["-C", root, "ls-files", "-z"]);
|
|
239
|
+
} catch {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const files = out.split("\0").filter((p) => p !== "");
|
|
243
|
+
if (files.length === 0) return null;
|
|
244
|
+
return new Set(files);
|
|
245
|
+
}
|
|
246
|
+
|
|
219
247
|
// src/lib/core-manifest.ts
|
|
220
248
|
var CORE_MANIFEST_FILE = "core-manifest.json";
|
|
221
249
|
var CoreManifestSchema2 = z2.object({
|
|
@@ -315,8 +343,9 @@ function isTemplateOwned(relPath, manifest) {
|
|
|
315
343
|
function toPosix(p) {
|
|
316
344
|
return sep === "/" ? p : p.split(sep).join("/");
|
|
317
345
|
}
|
|
318
|
-
function listTemplateOwnedFiles(root, manifest) {
|
|
346
|
+
function listTemplateOwnedFiles(root, manifest, options = {}) {
|
|
319
347
|
const out = [];
|
|
348
|
+
const tracked = options.trackedOnly ? options.git ? gitTrackedFiles(root, options.git) : gitTrackedFiles(root) : null;
|
|
320
349
|
function walk(dir) {
|
|
321
350
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
322
351
|
if (entry.isDirectory() && HARD_EXCLUDED_DIRS.has(entry.name)) continue;
|
|
@@ -325,6 +354,7 @@ function listTemplateOwnedFiles(root, manifest) {
|
|
|
325
354
|
walk(abs);
|
|
326
355
|
} else if (entry.isFile()) {
|
|
327
356
|
const rel = toPosix(relative(root, abs));
|
|
357
|
+
if (tracked && !tracked.has(rel)) continue;
|
|
328
358
|
if (isTemplateOwned(rel, manifest)) out.push(rel);
|
|
329
359
|
}
|
|
330
360
|
}
|
|
@@ -335,10 +365,11 @@ function listTemplateOwnedFiles(root, manifest) {
|
|
|
335
365
|
function sameFile(a, b) {
|
|
336
366
|
return readFileSync2(a).equals(readFileSync2(b));
|
|
337
367
|
}
|
|
338
|
-
function computeCoreDiff(templateRoot, instanceRoot, manifest, baseRoot) {
|
|
339
|
-
const
|
|
368
|
+
function computeCoreDiff(templateRoot, instanceRoot, manifest, baseRoot, options = {}) {
|
|
369
|
+
const trackedOnly = options.git ? { trackedOnly: true, git: options.git } : { trackedOnly: true };
|
|
370
|
+
const templateFiles = new Set(listTemplateOwnedFiles(templateRoot, manifest, trackedOnly));
|
|
340
371
|
const instanceFiles = new Set(listTemplateOwnedFiles(instanceRoot, manifest));
|
|
341
|
-
const baseFiles = baseRoot ? new Set(listTemplateOwnedFiles(baseRoot, manifest)) : void 0;
|
|
372
|
+
const baseFiles = baseRoot ? new Set(listTemplateOwnedFiles(baseRoot, manifest, trackedOnly)) : void 0;
|
|
342
373
|
const diff = {
|
|
343
374
|
added: [],
|
|
344
375
|
removed: [],
|
|
@@ -687,9 +718,10 @@ var EMPTY_SUMMARY = () => ({
|
|
|
687
718
|
});
|
|
688
719
|
async function planCoreUpgrade(options) {
|
|
689
720
|
const mergeFile = options.mergeFile ?? gitMergeFile;
|
|
690
|
-
const
|
|
721
|
+
const trackedOnly = { trackedOnly: true };
|
|
722
|
+
const base = new Set(listTemplateOwnedFiles(options.baseDir, options.manifest, trackedOnly));
|
|
691
723
|
const ours = new Set(listTemplateOwnedFiles(options.oursDir, options.manifest));
|
|
692
|
-
const theirs = new Set(listTemplateOwnedFiles(options.theirsDir, options.manifest));
|
|
724
|
+
const theirs = new Set(listTemplateOwnedFiles(options.theirsDir, options.manifest, trackedOnly));
|
|
693
725
|
const divergentPrefixes = readDivergenceConfig(options.oursDir).warnOnly.map((e) => e.prefix);
|
|
694
726
|
const isDeclaredDivergent = (path) => divergentPrefixes.some((prefix) => path.startsWith(prefix));
|
|
695
727
|
const paths = [.../* @__PURE__ */ new Set([...base, ...ours, ...theirs])].sort();
|
|
@@ -2401,7 +2433,7 @@ function applyMigrationCarry(instanceDir, plan) {
|
|
|
2401
2433
|
}
|
|
2402
2434
|
|
|
2403
2435
|
// src/lib/core-template-trees.ts
|
|
2404
|
-
import { execFileSync as
|
|
2436
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
2405
2437
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync3 } from "fs";
|
|
2406
2438
|
import { tmpdir as tmpdir3 } from "os";
|
|
2407
2439
|
import { join as join8 } from "path";
|
|
@@ -2409,8 +2441,8 @@ function coreTag(version) {
|
|
|
2409
2441
|
parseCoreVersion(version);
|
|
2410
2442
|
return `core-v${version}`;
|
|
2411
2443
|
}
|
|
2412
|
-
var
|
|
2413
|
-
function workingTreeMatchesTag(repo, version, git =
|
|
2444
|
+
var defaultGit2 = (args) => execFileSync3("git", args, { encoding: "utf8" });
|
|
2445
|
+
function workingTreeMatchesTag(repo, version, git = defaultGit2) {
|
|
2414
2446
|
const tag = coreTag(version);
|
|
2415
2447
|
try {
|
|
2416
2448
|
const head = git(["-C", repo, "rev-parse", "HEAD"]).trim();
|
|
@@ -2430,7 +2462,7 @@ function tagExists(repo, tag, git) {
|
|
|
2430
2462
|
return false;
|
|
2431
2463
|
}
|
|
2432
2464
|
}
|
|
2433
|
-
function materializeTemplateAtTag(repo, version, git =
|
|
2465
|
+
function materializeTemplateAtTag(repo, version, git = defaultGit2) {
|
|
2434
2466
|
const tag = coreTag(version);
|
|
2435
2467
|
if (!tagExists(repo, tag, git)) {
|
|
2436
2468
|
try {
|
|
@@ -2447,7 +2479,7 @@ function materializeTemplateAtTag(repo, version, git = defaultGit) {
|
|
|
2447
2479
|
const tarball = join8(dir, ".tree.tar");
|
|
2448
2480
|
try {
|
|
2449
2481
|
git(["-C", repo, "archive", "--format=tar", "-o", tarball, tag]);
|
|
2450
|
-
|
|
2482
|
+
execFileSync3("tar", ["-x", "-f", tarball, "-C", dir]);
|
|
2451
2483
|
rmSync3(tarball, { force: true });
|
|
2452
2484
|
} catch (err) {
|
|
2453
2485
|
rmSync3(dir, { recursive: true, force: true });
|