@aedis/cli 0.4.0 → 0.4.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/README.md +3 -3
- package/dist/aedis.js +30 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ before any file is written, npm dependencies are pinned to exact versions at lea
|
|
|
6
6
|
script runs.
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
npx @aedis/cli@0.4.
|
|
10
|
-
npx @aedis/cli@0.4.
|
|
11
|
-
npx @aedis/cli@0.4.
|
|
9
|
+
npx @aedis/cli@0.4.1 init
|
|
10
|
+
npx @aedis/cli@0.4.1 add button approval-card
|
|
11
|
+
npx @aedis/cli@0.4.1 diff
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Always pin the version, as above. Never run `npx aedis`: the unscoped `aedis` package on npm is not this one.
|
package/dist/aedis.js
CHANGED
|
@@ -978,13 +978,34 @@ function readConfig(root) {
|
|
|
978
978
|
const isRelease = (value) => RELEASE.test(value);
|
|
979
979
|
//#endregion
|
|
980
980
|
//#region src/deps.ts
|
|
981
|
-
|
|
981
|
+
const FROM_FIELD = /^(npm|pnpm|yarn|bun)@(\d+)/;
|
|
982
|
+
/** The package manager a package.json declares in `packageManager` ("pnpm@9.1.0"), if any. */
|
|
983
|
+
function declared(json) {
|
|
984
|
+
try {
|
|
985
|
+
const match = FROM_FIELD.exec(String(JSON.parse(json).packageManager ?? ""));
|
|
986
|
+
if (!match) return null;
|
|
987
|
+
return match[1] === "yarn" ? Number(match[2]) >= 2 ? "yarn" : "yarn1" : match[1];
|
|
988
|
+
} catch {
|
|
989
|
+
return null;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* The package manager the project uses. From `root` up to the folder that holds `.git` (or the filesystem root),
|
|
994
|
+
* the first folder with a lockfile, a pnpm-workspace.yaml or a package.json `packageManager` decides: an app inside a
|
|
995
|
+
* workspace installs with the workspace's manager. npm only when nothing up the tree says otherwise. Yarn 2+
|
|
996
|
+
* lockfiles start with __metadata.
|
|
997
|
+
*/
|
|
982
998
|
function detectPackageManager(root, exists = existsSync, read = (p) => readFileSync(p, "utf8")) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
999
|
+
for (let dir = path.resolve(root);; dir = path.dirname(dir)) {
|
|
1000
|
+
const at = (f) => path.join(dir, f);
|
|
1001
|
+
if (exists(at("pnpm-lock.yaml")) || exists(at("pnpm-workspace.yaml"))) return "pnpm";
|
|
1002
|
+
if (exists(at("bun.lock")) || exists(at("bun.lockb"))) return "bun";
|
|
1003
|
+
if (exists(at("yarn.lock"))) return /__metadata:/.test(read(at("yarn.lock")).slice(0, 4096)) ? "yarn" : "yarn1";
|
|
1004
|
+
if (exists(at("package-lock.json"))) return "npm";
|
|
1005
|
+
const pm = exists(at("package.json")) ? declared(read(at("package.json"))) : null;
|
|
1006
|
+
if (pm) return pm;
|
|
1007
|
+
if (exists(at(".git")) || path.dirname(dir) === dir) return "npm";
|
|
1008
|
+
}
|
|
988
1009
|
}
|
|
989
1010
|
/** Exact versions, no lifecycle scripts, whatever the package manager. */
|
|
990
1011
|
function installCommand(pm, specs) {
|
|
@@ -1618,7 +1639,7 @@ function planFiles(items, config, root) {
|
|
|
1618
1639
|
}
|
|
1619
1640
|
//#endregion
|
|
1620
1641
|
//#region src/cli.ts
|
|
1621
|
-
const VERSION = "0.4.
|
|
1642
|
+
const VERSION = "0.4.1";
|
|
1622
1643
|
/** What `aedis init` installs: config, theme tokens, cn and the security primitives. */
|
|
1623
1644
|
const INIT_ITEMS = [
|
|
1624
1645
|
"theme",
|
|
@@ -1782,7 +1803,7 @@ async function run(argv, io) {
|
|
|
1782
1803
|
}
|
|
1783
1804
|
if (!existsSync(path.join(root, "package.json"))) throw new Error(`${root} has no package.json; run inside your app`);
|
|
1784
1805
|
if (command === "init") {
|
|
1785
|
-
const config = readConfig(root) ?? defaultConfig(root, flags.release ?? `v0.4.
|
|
1806
|
+
const config = readConfig(root) ?? defaultConfig(root, flags.release ?? `v0.4.1`);
|
|
1786
1807
|
if (!isRelease(config.release)) throw new Error(`invalid release ${config.release}`);
|
|
1787
1808
|
const decoded = flags.preset === void 0 ? null : decodePreset(flags.preset);
|
|
1788
1809
|
if (decoded && !decoded.ok) throw new Error(`preset refused: ${decoded.error}`);
|
|
@@ -1818,7 +1839,7 @@ ${themeToCss(theme)}
|
|
|
1818
1839
|
}
|
|
1819
1840
|
if (command === "theme" && args[0] === "import") {
|
|
1820
1841
|
if (!args[1]) throw new Error("theme import: give the theme's JSON file");
|
|
1821
|
-
const config = readConfig(root) ?? defaultConfig(root, `v0.4.
|
|
1842
|
+
const config = readConfig(root) ?? defaultConfig(root, `v0.4.1`);
|
|
1822
1843
|
const input = insideProject(root, path.relative(root, path.resolve(io.cwd, args[1])));
|
|
1823
1844
|
const result = themeImport(readFileSync(input, "utf8"), path.basename(input));
|
|
1824
1845
|
if (!result.ok) {
|
package/package.json
CHANGED