@biffo/cli 0.324.6 → 0.324.7
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 +13 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9791,30 +9791,6 @@ function findInstalledPlugins(cwd) {
|
|
|
9791
9791
|
import { existsSync as existsSync31, readdirSync as readdirSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
|
|
9792
9792
|
import { join as join32 } from "path";
|
|
9793
9793
|
import { parse as parseToml } from "smol-toml";
|
|
9794
|
-
function readTomlStringArray(text, key) {
|
|
9795
|
-
const open = new RegExp(`^${key}\\s*=\\s*\\[`, "m").exec(text);
|
|
9796
|
-
if (!open) return [];
|
|
9797
|
-
const strings = [];
|
|
9798
|
-
let depth = 1;
|
|
9799
|
-
let i = open.index + open[0].length;
|
|
9800
|
-
while (i < text.length && depth > 0) {
|
|
9801
|
-
const c = text[i];
|
|
9802
|
-
if (c === "#") {
|
|
9803
|
-
const nl = text.indexOf("\n", i);
|
|
9804
|
-
i = nl === -1 ? text.length : nl;
|
|
9805
|
-
} else if (c === '"' || c === "'") {
|
|
9806
|
-
const close = text.indexOf(c, i + 1);
|
|
9807
|
-
if (close === -1) break;
|
|
9808
|
-
if (depth === 1) strings.push(text.slice(i + 1, close));
|
|
9809
|
-
i = close + 1;
|
|
9810
|
-
} else {
|
|
9811
|
-
if (c === "[") depth++;
|
|
9812
|
-
else if (c === "]") depth--;
|
|
9813
|
-
i++;
|
|
9814
|
-
}
|
|
9815
|
-
}
|
|
9816
|
-
return depth === 0 ? strings : [];
|
|
9817
|
-
}
|
|
9818
9794
|
function normaliseName(name) {
|
|
9819
9795
|
return name.replace(/[-_.]+/g, "-").toLowerCase();
|
|
9820
9796
|
}
|
|
@@ -9842,15 +9818,17 @@ function requirementsIn(groups) {
|
|
|
9842
9818
|
return Object.values(groups).filter(Array.isArray).flat().filter((entry) => typeof entry === "string");
|
|
9843
9819
|
}
|
|
9844
9820
|
function readDeclaredDependencyNames(doc) {
|
|
9821
|
+
return readDeclaredRequirements(doc).map(requirementName).filter((name) => name !== null);
|
|
9822
|
+
}
|
|
9823
|
+
function readDeclaredRequirements(doc) {
|
|
9845
9824
|
const project = isTable(doc.project) ? doc.project : {};
|
|
9846
|
-
|
|
9825
|
+
return [
|
|
9847
9826
|
...(Array.isArray(project.dependencies) ? project.dependencies : []).filter(
|
|
9848
9827
|
(dep) => typeof dep === "string"
|
|
9849
9828
|
),
|
|
9850
9829
|
...requirementsIn(project["optional-dependencies"]),
|
|
9851
9830
|
...requirementsIn(doc["dependency-groups"])
|
|
9852
9831
|
];
|
|
9853
|
-
return requirements.map(requirementName).filter((name) => name !== null);
|
|
9854
9832
|
}
|
|
9855
9833
|
function existingSourceNames(doc) {
|
|
9856
9834
|
const tool = isTable(doc.tool) ? doc.tool : {};
|
|
@@ -12037,6 +12015,7 @@ import { join as join44, relative as relative7, resolve as resolve19 } from "pat
|
|
|
12037
12015
|
import chalk19 from "chalk";
|
|
12038
12016
|
import { Command as Command21 } from "commander";
|
|
12039
12017
|
import inquirer7 from "inquirer";
|
|
12018
|
+
import { parse as parseToml2 } from "smol-toml";
|
|
12040
12019
|
var pluginUpgradeCommand = new Command21("upgrade").description(
|
|
12041
12020
|
"Upgrade an installed plugin to a new minor version (biffo plugin upgrade <name>@<new-minor>) or refresh it in place from a local, unpublished checkout (biffo plugin upgrade --local <path>)"
|
|
12042
12021
|
).argument(
|
|
@@ -12409,28 +12388,17 @@ function readPyprojectIfPresent(targetDir) {
|
|
|
12409
12388
|
}
|
|
12410
12389
|
function dependenciesChanged(before, after) {
|
|
12411
12390
|
if (before === after) return false;
|
|
12412
|
-
const beforeItems = before ? dependencySurface(before)
|
|
12413
|
-
const afterItems = after ? dependencySurface(after)
|
|
12391
|
+
const beforeItems = before === null ? [] : dependencySurface(before);
|
|
12392
|
+
const afterItems = after === null ? [] : dependencySurface(after);
|
|
12393
|
+
if (beforeItems === null || afterItems === null) return true;
|
|
12414
12394
|
return JSON.stringify(beforeItems) !== JSON.stringify(afterItems);
|
|
12415
12395
|
}
|
|
12416
12396
|
function dependencySurface(text) {
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
items.push(...readTomlStringArray(body, m[1]));
|
|
12423
|
-
}
|
|
12424
|
-
}
|
|
12425
|
-
return items.sort();
|
|
12426
|
-
}
|
|
12427
|
-
function tomlTableBody(text, header) {
|
|
12428
|
-
const escaped = header.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12429
|
-
const headerMatch = new RegExp(`^\\[${escaped}\\]\\s*$`, "m").exec(text);
|
|
12430
|
-
if (!headerMatch) return null;
|
|
12431
|
-
const rest = text.slice(headerMatch.index + headerMatch[0].length);
|
|
12432
|
-
const nextHeader = /^\[/m.exec(rest);
|
|
12433
|
-
return nextHeader ? rest.slice(0, nextHeader.index) : rest;
|
|
12397
|
+
try {
|
|
12398
|
+
return readDeclaredRequirements(parseToml2(text)).sort();
|
|
12399
|
+
} catch {
|
|
12400
|
+
return null;
|
|
12401
|
+
}
|
|
12434
12402
|
}
|
|
12435
12403
|
function readInstalledVersion(targetDir) {
|
|
12436
12404
|
const manifestPath = join44(targetDir, "biffo.plugin.json");
|