@aedis/cli 0.1.3 → 0.2.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/README.md +3 -3
- package/dist/aedis.js +35 -12
- 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.
|
|
10
|
-
npx @aedis/cli@0.
|
|
11
|
-
npx @aedis/cli@0.
|
|
9
|
+
npx @aedis/cli@0.2.0 init
|
|
10
|
+
npx @aedis/cli@0.2.0 add button approval-card
|
|
11
|
+
npx @aedis/cli@0.2.0 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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawnSync } from "node:child_process";
|
|
3
2
|
import { createInterface } from "node:readline/promises";
|
|
4
3
|
import { verify } from "sigstore";
|
|
5
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
5
|
import path from "node:path";
|
|
7
6
|
import { gunzipSync } from "node:zlib";
|
|
8
7
|
import { createHash } from "node:crypto";
|
|
8
|
+
import { spawnSync } from "node:child_process";
|
|
9
9
|
//#region ../../apps/www/lib/untrusted.ts
|
|
10
10
|
/**
|
|
11
11
|
* Invisible code points that carry no visible text but can hide instructions from the person reading while an
|
|
@@ -1588,7 +1588,7 @@ function planFiles(items, config, root) {
|
|
|
1588
1588
|
}
|
|
1589
1589
|
//#endregion
|
|
1590
1590
|
//#region src/cli.ts
|
|
1591
|
-
const VERSION = "0.
|
|
1591
|
+
const VERSION = "0.2.0";
|
|
1592
1592
|
/** What `aedis init` installs: config, theme tokens, cn and the security primitives. */
|
|
1593
1593
|
const INIT_ITEMS = [
|
|
1594
1594
|
"theme",
|
|
@@ -1752,7 +1752,7 @@ async function run(argv, io) {
|
|
|
1752
1752
|
}
|
|
1753
1753
|
if (!existsSync(path.join(root, "package.json"))) throw new Error(`${root} has no package.json; run inside your app`);
|
|
1754
1754
|
if (command === "init") {
|
|
1755
|
-
const config = readConfig(root) ?? defaultConfig(root, flags.release ?? `v0.
|
|
1755
|
+
const config = readConfig(root) ?? defaultConfig(root, flags.release ?? `v0.2.0`);
|
|
1756
1756
|
if (!isRelease(config.release)) throw new Error(`invalid release ${config.release}`);
|
|
1757
1757
|
const decoded = flags.preset === void 0 ? null : decodePreset(flags.preset);
|
|
1758
1758
|
if (decoded && !decoded.ok) throw new Error(`preset refused: ${decoded.error}`);
|
|
@@ -1788,7 +1788,7 @@ ${themeToCss(theme)}
|
|
|
1788
1788
|
}
|
|
1789
1789
|
if (command === "theme" && args[0] === "import") {
|
|
1790
1790
|
if (!args[1]) throw new Error("theme import: give the theme's JSON file");
|
|
1791
|
-
const config = readConfig(root) ?? defaultConfig(root, `v0.
|
|
1791
|
+
const config = readConfig(root) ?? defaultConfig(root, `v0.2.0`);
|
|
1792
1792
|
const input = insideProject(root, path.relative(root, path.resolve(io.cwd, args[1])));
|
|
1793
1793
|
const result = themeImport(readFileSync(input, "utf8"), path.basename(input));
|
|
1794
1794
|
if (!result.ok) {
|
|
@@ -1812,20 +1812,43 @@ ${themeToCss(theme)}
|
|
|
1812
1812
|
}
|
|
1813
1813
|
}
|
|
1814
1814
|
//#endregion
|
|
1815
|
-
//#region src/
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1815
|
+
//#region src/spawn.ts
|
|
1816
|
+
const PLAIN = /^[\w@./:=~-]+$/;
|
|
1817
|
+
/**
|
|
1818
|
+
* Runs a package manager without `shell: true` (Node's DEP0190). On Windows npm, pnpm and yarn are .cmd shims that
|
|
1819
|
+
* only cmd.exe can start (Node refuses to spawn a .cmd directly), so cmd.exe is spawned explicitly, and only with
|
|
1820
|
+
* arguments that hold no metacharacter; elsewhere the command is spawned directly.
|
|
1821
|
+
*/
|
|
1822
|
+
function runPackageManager(command, args, { cwd, env }, spawn = spawnSync, platform = process.platform) {
|
|
1823
|
+
let file = command;
|
|
1824
|
+
let argv = args;
|
|
1825
|
+
if (platform === "win32") {
|
|
1826
|
+
for (const arg of [command, ...args]) if (!PLAIN.test(arg)) throw new Error(`refusing to pass ${JSON.stringify(arg)} to cmd.exe`);
|
|
1827
|
+
file = process.env.ComSpec ?? "cmd.exe";
|
|
1828
|
+
argv = [
|
|
1829
|
+
"/d",
|
|
1830
|
+
"/c",
|
|
1831
|
+
command,
|
|
1832
|
+
...args
|
|
1833
|
+
];
|
|
1834
|
+
}
|
|
1835
|
+
return spawn(file, argv, {
|
|
1821
1836
|
cwd,
|
|
1822
1837
|
env: {
|
|
1823
1838
|
...process.env,
|
|
1824
1839
|
...env
|
|
1825
1840
|
},
|
|
1826
1841
|
stdio: "inherit",
|
|
1827
|
-
|
|
1828
|
-
}).status ?? 1
|
|
1842
|
+
windowsHide: true
|
|
1843
|
+
}).status ?? 1;
|
|
1844
|
+
}
|
|
1845
|
+
//#endregion
|
|
1846
|
+
//#region src/main.ts
|
|
1847
|
+
const code = await run(process.argv.slice(2), {
|
|
1848
|
+
cwd: process.cwd(),
|
|
1849
|
+
fetcher: fetch,
|
|
1850
|
+
check: (bundle, options) => verify(bundle, options),
|
|
1851
|
+
spawn: runPackageManager,
|
|
1829
1852
|
confirm: async (question) => {
|
|
1830
1853
|
if (!process.stdin.isTTY) return false;
|
|
1831
1854
|
const rl = createInterface({
|
package/package.json
CHANGED