@darkrymit/crunes-cli 0.9.0 → 0.10.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/dist/chunks/add-2OM5KGN5.js +67 -0
- package/dist/chunks/{apply-YY7MIM64.js → apply-GBUQQ4XF.js} +21 -9
- package/dist/chunks/{benchmark-BQNMULOO.js → benchmark-QWGVX3BX.js} +21 -15
- package/dist/chunks/chunk-2DNYVKBF.js +109 -0
- package/dist/chunks/chunk-2HM5Q52B.js +131 -0
- package/dist/chunks/chunk-3KKRNQQU.js +275 -0
- package/dist/chunks/chunk-55GTJG5I.js +1154 -0
- package/dist/chunks/chunk-7KYCYDAS.js +325 -0
- package/dist/chunks/{chunk-SNC7AOT7.js → chunk-AL37NFWR.js} +45 -94
- package/dist/chunks/chunk-ARIFLX5E.js +9525 -0
- package/dist/chunks/{chunk-X7PZN73N.js → chunk-E7CZPAM2.js} +1 -1
- package/dist/chunks/chunk-EO3CSXWK.js +70 -0
- package/dist/chunks/chunk-FIAFVIAN.js +79 -0
- package/dist/chunks/{chunk-MRNZFUXZ.js → chunk-KQMTTEJV.js} +22 -7
- package/dist/chunks/chunk-KX6QEHM5.js +578 -0
- package/dist/chunks/{chunk-VST6HAB6.js → chunk-MTJ2KW3V.js} +2 -0
- package/dist/chunks/chunk-MUWDZJN2.js +71 -0
- package/dist/chunks/{chunk-CY6C6ADU.js → chunk-MVCBPI4J.js} +45 -478
- package/dist/chunks/{chunk-34F4ZURL.js → chunk-NJVPLN5D.js} +29 -12
- package/dist/chunks/chunk-UBCAZGLE.js +15 -0
- package/dist/chunks/chunk-VP7YLCQP.js +244 -0
- package/dist/chunks/chunk-VSMAZISQ.js +303 -0
- package/dist/chunks/chunk-WE4HDHFU.js +37 -0
- package/dist/chunks/{create-ET6DT5ZE.js → create-2CQZF53Z.js} +5 -2
- package/dist/chunks/{create-LM7U3CJS.js → create-36F6V4WP.js} +99 -6
- package/dist/chunks/{create-TLPM7HJE.js → create-DXW4YYLJ.js} +5 -5
- package/dist/chunks/{disable-TNTEIAKO.js → disable-FB64CSYV.js} +5 -2
- package/dist/chunks/doctor-PVO4JLYN.js +208 -0
- package/dist/chunks/{enable-GUQCB4CU.js → enable-UVXHTKCJ.js} +6 -3
- package/dist/chunks/{init-PJSCFOC6.js → init-GPNC7TR5.js} +5 -2
- package/dist/chunks/{install-4YP7FALO.js → install-3G7U5ZIO.js} +10 -5
- package/dist/chunks/{intro-SA7MWV3Z.js → intro-YI5HUZCF.js} +45 -19
- package/dist/chunks/{list-WKNPZZOV.js → list-J2UCBYAY.js} +9 -6
- package/dist/chunks/list-JB4447YK.js +62 -0
- package/dist/chunks/{list-7R6NASFI.js → list-W4JAYPAA.js} +19 -19
- package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
- package/dist/chunks/{registry-K5DV5NAK.js → registry-IWP7JMNI.js} +1 -1
- package/dist/chunks/{repl-ZB3DIJ4K.js → repl-MWFEZ65P.js} +30 -20
- package/dist/chunks/resolver-URPQMOIV.js +36 -0
- package/dist/chunks/{run-22B65ZWZ.js → run-3VKWSRLO.js} +17 -11
- package/dist/chunks/rune-L5EP645W.js +283 -0
- package/dist/chunks/runner-VPTLUQJE.js +34 -0
- package/dist/chunks/{shell-explain-QLITLHW7.js → shell-explain-LKBBP2BG.js} +5 -2
- package/dist/chunks/trust-LXXYSF6W.js +109 -0
- package/dist/chunks/{uninstall-4WR5IHLC.js → uninstall-J7JUYETA.js} +10 -5
- package/dist/chunks/{update-ACLDK6E6.js → update-ZJRLDCUT.js} +10 -5
- package/dist/chunks/{version-EULYWNXN.js → version-ZULO6CV3.js} +2 -2
- package/dist/cli.js +47 -34
- package/package.json +2 -2
- package/dist/chunks/chunk-G3U4V32O.js +0 -46
- package/dist/chunks/chunk-QYRF3R35.js +0 -154
- package/dist/chunks/chunk-YXCHIMLW.js +0 -75308
- package/dist/chunks/doctor-VXAQYMTR.js +0 -101
- package/dist/chunks/list-OMMZAQ23.js +0 -28
- package/dist/chunks/resolver-QIYYFIDX.js +0 -34
- package/dist/chunks/rune-SYK4N642.js +0 -425
- package/dist/chunks/{delete-5R3WBLVD.js → delete-2EXPFBFC.js} +4 -4
- package/dist/chunks/{delete-U4STA2QZ.js → delete-MJAECXXV.js} +4 -4
|
@@ -2,8 +2,7 @@ import {
|
|
|
2
2
|
getConfigPath,
|
|
3
3
|
readRawConfig,
|
|
4
4
|
writeRawConfig
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-QYRF3R35.js";
|
|
5
|
+
} from "./chunk-E7CZPAM2.js";
|
|
7
6
|
import {
|
|
8
7
|
output
|
|
9
8
|
} from "./chunk-MIKWIFYR.js";
|
|
@@ -14,9 +13,13 @@ import {
|
|
|
14
13
|
ye
|
|
15
14
|
} from "./chunk-CGZL5SSH.js";
|
|
16
15
|
import "./chunk-WCODTMDN.js";
|
|
16
|
+
import "./chunk-3KKRNQQU.js";
|
|
17
|
+
import "./chunk-UBCAZGLE.js";
|
|
18
|
+
import "./chunk-VP7YLCQP.js";
|
|
17
19
|
import {
|
|
18
20
|
getStorePath
|
|
19
21
|
} from "./chunk-2Q3KLBE6.js";
|
|
22
|
+
import "./chunk-55GTJG5I.js";
|
|
20
23
|
import {
|
|
21
24
|
init_require_shim
|
|
22
25
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -2,8 +2,7 @@ import {
|
|
|
2
2
|
getConfigPath,
|
|
3
3
|
readRawConfig,
|
|
4
4
|
writeRawConfig
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-QYRF3R35.js";
|
|
5
|
+
} from "./chunk-E7CZPAM2.js";
|
|
7
6
|
import {
|
|
8
7
|
output
|
|
9
8
|
} from "./chunk-MIKWIFYR.js";
|
|
@@ -15,9 +14,13 @@ import {
|
|
|
15
14
|
ye
|
|
16
15
|
} from "./chunk-CGZL5SSH.js";
|
|
17
16
|
import "./chunk-WCODTMDN.js";
|
|
17
|
+
import "./chunk-3KKRNQQU.js";
|
|
18
|
+
import "./chunk-UBCAZGLE.js";
|
|
19
|
+
import "./chunk-VP7YLCQP.js";
|
|
18
20
|
import {
|
|
19
21
|
getStorePath
|
|
20
22
|
} from "./chunk-2Q3KLBE6.js";
|
|
23
|
+
import "./chunk-55GTJG5I.js";
|
|
21
24
|
import {
|
|
22
25
|
init_require_shim
|
|
23
26
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -27,6 +30,86 @@ init_require_shim();
|
|
|
27
30
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
28
31
|
import { join, dirname } from "node:path";
|
|
29
32
|
var VALID_FORMATS = ["tree", "markdown"];
|
|
33
|
+
var SCRIPT_LANGS = {
|
|
34
|
+
python: {
|
|
35
|
+
ext: "py",
|
|
36
|
+
body: (key) => [
|
|
37
|
+
`import json`,
|
|
38
|
+
`import os`,
|
|
39
|
+
`import sys`,
|
|
40
|
+
``,
|
|
41
|
+
`# A script rune: crunes runs this with the project's Python and passes`,
|
|
42
|
+
`# sys.argv[1:] the caller's arguments, unchanged`,
|
|
43
|
+
`# CRUNES_ARGS the parsed arguments as JSON, when the rune has an args schema`,
|
|
44
|
+
`# CRUNES_VARS the rune's configured vars as JSON`,
|
|
45
|
+
`# Whatever it prints is the rune's output.`,
|
|
46
|
+
``,
|
|
47
|
+
`args = json.loads(os.environ.get("CRUNES_ARGS", "null"))`,
|
|
48
|
+
`rune_vars = json.loads(os.environ.get("CRUNES_VARS", "{}"))`,
|
|
49
|
+
``,
|
|
50
|
+
`print("${key}:", sys.argv[1:])`,
|
|
51
|
+
``
|
|
52
|
+
].join("\n")
|
|
53
|
+
},
|
|
54
|
+
bash: {
|
|
55
|
+
ext: "sh",
|
|
56
|
+
body: (key) => [
|
|
57
|
+
`# A script rune: crunes runs this with bash and passes`,
|
|
58
|
+
`# "$@" the caller's arguments, unchanged`,
|
|
59
|
+
`# CRUNES_ARGS the parsed arguments as JSON, when the rune has an args schema`,
|
|
60
|
+
`# CRUNES_VARS the rune's configured vars as JSON`,
|
|
61
|
+
`# Whatever it prints is the rune's output; its exit code is crunes's.`,
|
|
62
|
+
``,
|
|
63
|
+
`echo "${key}: $*"`,
|
|
64
|
+
``
|
|
65
|
+
].join("\n")
|
|
66
|
+
},
|
|
67
|
+
node: {
|
|
68
|
+
ext: "js",
|
|
69
|
+
body: (key) => [
|
|
70
|
+
`// A script rune: crunes runs this with Node, outside the sandbox, and passes`,
|
|
71
|
+
`// process.argv.slice(2) the caller's arguments, unchanged`,
|
|
72
|
+
`// CRUNES_ARGS the parsed arguments as JSON, when the rune has an args schema`,
|
|
73
|
+
`// CRUNES_VARS the rune's configured vars as JSON`,
|
|
74
|
+
`// Whatever it prints is the rune's output. To run in the sandbox instead, use a *.rune.js file.`,
|
|
75
|
+
``,
|
|
76
|
+
`const args = JSON.parse(process.env.CRUNES_ARGS ?? 'null')`,
|
|
77
|
+
`const vars = JSON.parse(process.env.CRUNES_VARS ?? '{}')`,
|
|
78
|
+
``,
|
|
79
|
+
`console.log('${key}:', process.argv.slice(2))`,
|
|
80
|
+
``
|
|
81
|
+
].join("\n")
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var VALID_LANGS = Object.keys(SCRIPT_LANGS);
|
|
85
|
+
async function createScriptRune({ key, lang, runeRelPath, name, description, configRoot, global }) {
|
|
86
|
+
const spec = SCRIPT_LANGS[lang];
|
|
87
|
+
if (!spec) {
|
|
88
|
+
output.error(`Invalid --lang. Must be one of: ${VALID_LANGS.join(", ")}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
if (!key) {
|
|
92
|
+
output.error("Missing required argument: <key>");
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
runeRelPath = runeRelPath ?? (global ? `runes/${key}.${spec.ext}` : `.crunes/runes/${key}.${spec.ext}`);
|
|
96
|
+
const runeAbsPath = join(global ? getStorePath() : configRoot, runeRelPath);
|
|
97
|
+
const configPath = getConfigPath({ configRoot, global });
|
|
98
|
+
const config = readRawConfig(configPath) ?? { runes: {} };
|
|
99
|
+
if (config.runes?.[key] != null) {
|
|
100
|
+
output.error(`Rune "${key}" already exists in ${configPath}.`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
await mkdir(dirname(runeAbsPath), { recursive: true });
|
|
104
|
+
await writeFile(runeAbsPath, spec.body(key));
|
|
105
|
+
config.runes = {
|
|
106
|
+
...config.runes ?? {},
|
|
107
|
+
[key]: { ...name && { name }, ...description && { description }, run: runeRelPath }
|
|
108
|
+
};
|
|
109
|
+
await writeRawConfig(configPath, config);
|
|
110
|
+
output.success(`Created ${runeRelPath} (${lang}, native)`);
|
|
111
|
+
output.info(`Run: crunes run ${key}`);
|
|
112
|
+
}
|
|
30
113
|
function template(key, format) {
|
|
31
114
|
const imports = format === "tree" ? `import { md, section, tree } from '@utils'` : `import { md, section } from '@utils'`;
|
|
32
115
|
const header = [
|
|
@@ -74,6 +157,7 @@ function template(key, format) {
|
|
|
74
157
|
async function handler({
|
|
75
158
|
key,
|
|
76
159
|
format,
|
|
160
|
+
lang,
|
|
77
161
|
path: runeRelPath,
|
|
78
162
|
name,
|
|
79
163
|
description,
|
|
@@ -82,6 +166,10 @@ async function handler({
|
|
|
82
166
|
configRoot = projectRoot,
|
|
83
167
|
global = false
|
|
84
168
|
} = {}) {
|
|
169
|
+
if (lang) {
|
|
170
|
+
await createScriptRune({ key, lang, runeRelPath, name, description, configRoot, global });
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
85
173
|
const isNonInteractive = yes || !process.stdout.isTTY;
|
|
86
174
|
if (isNonInteractive) {
|
|
87
175
|
if (!key) {
|
|
@@ -121,7 +209,7 @@ async function handler({
|
|
|
121
209
|
format = result;
|
|
122
210
|
}
|
|
123
211
|
if (!runeRelPath) {
|
|
124
|
-
const defaultPath = global ? `runes/${key}.js` : `.crunes/runes/${key}.js`;
|
|
212
|
+
const defaultPath = global ? `runes/${key}.rune.js` : `.crunes/runes/${key}.rune.js`;
|
|
125
213
|
const result = await Re({ message: "File path?", initialValue: defaultPath });
|
|
126
214
|
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
127
215
|
ge("Cancelled.");
|
|
@@ -146,7 +234,11 @@ async function handler({
|
|
|
146
234
|
description = result || void 0;
|
|
147
235
|
}
|
|
148
236
|
}
|
|
149
|
-
runeRelPath = runeRelPath ?? (global ? `runes/${key}.js` : `.crunes/runes/${key}.js`);
|
|
237
|
+
runeRelPath = runeRelPath ?? (global ? `runes/${key}.rune.js` : `.crunes/runes/${key}.rune.js`);
|
|
238
|
+
if (!/\.rune\.m?js$/i.test(runeRelPath)) {
|
|
239
|
+
output.error(`${runeRelPath}: a sandboxed rune's file must be named *.rune.js \u2014 the name is what runs it in the isolate.`);
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
150
242
|
const baseRoot = global ? getStorePath() : configRoot;
|
|
151
243
|
const runeAbsPath = join(baseRoot, runeRelPath);
|
|
152
244
|
await mkdir(dirname(runeAbsPath), { recursive: true });
|
|
@@ -154,9 +246,9 @@ async function handler({
|
|
|
154
246
|
const configPath = getConfigPath({ configRoot, global });
|
|
155
247
|
const config = readRawConfig(configPath) ?? { runes: {} };
|
|
156
248
|
const entry = {
|
|
157
|
-
path: runeRelPath,
|
|
158
249
|
...name && { name },
|
|
159
|
-
...description && { description }
|
|
250
|
+
...description && { description },
|
|
251
|
+
run: runeRelPath
|
|
160
252
|
};
|
|
161
253
|
config.runes = { ...config.runes ?? {}, [key]: entry };
|
|
162
254
|
await writeRawConfig(configPath, config);
|
|
@@ -169,6 +261,7 @@ Run: crunes run ${key}`);
|
|
|
169
261
|
}
|
|
170
262
|
}
|
|
171
263
|
export {
|
|
264
|
+
VALID_LANGS,
|
|
172
265
|
handler,
|
|
173
266
|
template
|
|
174
267
|
};
|
|
@@ -25,8 +25,9 @@ function pluginJson({ name, description, author, license }) {
|
|
|
25
25
|
example: {
|
|
26
26
|
name: "Example Rune",
|
|
27
27
|
description: "Replace with your rune description",
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
run: {
|
|
29
|
+
command: "runes/example.rune.js",
|
|
30
|
+
permissions: {
|
|
30
31
|
allow: [],
|
|
31
32
|
deny: []
|
|
32
33
|
}
|
|
@@ -62,8 +63,7 @@ function exampleRune() {
|
|
|
62
63
|
return `// Ready-to-run rune \u2014 runs directly from the plugin install location.
|
|
63
64
|
// Users activate it by adding your plugin to their project config.
|
|
64
65
|
//
|
|
65
|
-
// permissions (plugin.json):
|
|
66
|
-
// run:
|
|
66
|
+
// permissions (plugin.json, inside this rune's run block):
|
|
67
67
|
// allow: [] \u2014 add patterns like fs.read:./** if you use utils.fs
|
|
68
68
|
// deny: []
|
|
69
69
|
|
|
@@ -216,7 +216,7 @@ async function handler({
|
|
|
216
216
|
const files = [
|
|
217
217
|
[join(outDir, ".crunes-plugin", "plugin.json"), pluginJson(opts)],
|
|
218
218
|
[join(outDir, ".crunes-plugin", "marketplace.json"), marketplaceJson(opts)],
|
|
219
|
-
[join(outDir, "runes", "example.js"), exampleRune()],
|
|
219
|
+
[join(outDir, "runes", "example.rune.js"), exampleRune()],
|
|
220
220
|
[join(outDir, "templates", "example-template.js"), exampleTemplate()],
|
|
221
221
|
[join(outDir, "README.md"), readmeMd(opts)],
|
|
222
222
|
[join(outDir, "CHANGELOG.md"), changelogMd()]
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfigPath,
|
|
3
3
|
setPluginEnabled
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-E7CZPAM2.js";
|
|
5
5
|
import {
|
|
6
6
|
enabledPluginKeys,
|
|
7
7
|
loadConfig
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-3KKRNQQU.js";
|
|
9
|
+
import "./chunk-UBCAZGLE.js";
|
|
10
|
+
import "./chunk-VP7YLCQP.js";
|
|
9
11
|
import "./chunk-2Q3KLBE6.js";
|
|
12
|
+
import "./chunk-55GTJG5I.js";
|
|
10
13
|
import {
|
|
11
14
|
init_require_shim
|
|
12
15
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfigPath,
|
|
3
|
+
readRawConfig
|
|
4
|
+
} from "./chunk-E7CZPAM2.js";
|
|
5
|
+
import {
|
|
6
|
+
output
|
|
7
|
+
} from "./chunk-MIKWIFYR.js";
|
|
8
|
+
import "./chunk-CGZL5SSH.js";
|
|
9
|
+
import "./chunk-WCODTMDN.js";
|
|
10
|
+
import {
|
|
11
|
+
describeRunBlock
|
|
12
|
+
} from "./chunk-KX6QEHM5.js";
|
|
13
|
+
import {
|
|
14
|
+
assertNotMissedRename,
|
|
15
|
+
onPath,
|
|
16
|
+
resolveInterpreter
|
|
17
|
+
} from "./chunk-2DNYVKBF.js";
|
|
18
|
+
import {
|
|
19
|
+
isNativeRune,
|
|
20
|
+
trustDigest,
|
|
21
|
+
trustState
|
|
22
|
+
} from "./chunk-MUWDZJN2.js";
|
|
23
|
+
import {
|
|
24
|
+
coercePlugins,
|
|
25
|
+
loadConfig
|
|
26
|
+
} from "./chunk-3KKRNQQU.js";
|
|
27
|
+
import "./chunk-UBCAZGLE.js";
|
|
28
|
+
import {
|
|
29
|
+
loadRegistry
|
|
30
|
+
} from "./chunk-MTJ2KW3V.js";
|
|
31
|
+
import {
|
|
32
|
+
loadPluginJson
|
|
33
|
+
} from "./chunk-FIAFVIAN.js";
|
|
34
|
+
import {
|
|
35
|
+
loadJsonSchema
|
|
36
|
+
} from "./chunk-VP7YLCQP.js";
|
|
37
|
+
import "./chunk-WE4HDHFU.js";
|
|
38
|
+
import "./chunk-MVCBPI4J.js";
|
|
39
|
+
import "./chunk-GVMT55GH.js";
|
|
40
|
+
import "./chunk-2HM5Q52B.js";
|
|
41
|
+
import "./chunk-WJII3LZK.js";
|
|
42
|
+
import "./chunk-G4ZAUHHA.js";
|
|
43
|
+
import "./chunk-2Q3KLBE6.js";
|
|
44
|
+
import "./chunk-55GTJG5I.js";
|
|
45
|
+
import {
|
|
46
|
+
init_require_shim
|
|
47
|
+
} from "./chunk-TPK5AGRA.js";
|
|
48
|
+
|
|
49
|
+
// src/cli/commands/doctor.js
|
|
50
|
+
init_require_shim();
|
|
51
|
+
import { spawnSync } from "node:child_process";
|
|
52
|
+
import { existsSync } from "node:fs";
|
|
53
|
+
import { relative } from "node:path";
|
|
54
|
+
async function checkPluginNativeTrust(config) {
|
|
55
|
+
const results = [];
|
|
56
|
+
let registry;
|
|
57
|
+
try {
|
|
58
|
+
registry = await loadRegistry();
|
|
59
|
+
} catch {
|
|
60
|
+
return results;
|
|
61
|
+
}
|
|
62
|
+
const enabled = new Set(Object.entries(config?.plugins ?? {}).filter(([, v]) => v).map(([k]) => k));
|
|
63
|
+
for (const [pluginKey, regEntry] of Object.entries(registry.plugins ?? {})) {
|
|
64
|
+
if (!enabled.has(pluginKey) || !regEntry?.path) continue;
|
|
65
|
+
try {
|
|
66
|
+
const pj = await loadPluginJson(regEntry.path);
|
|
67
|
+
for (const [runeKey, runeDef] of Object.entries(pj.runes ?? {})) {
|
|
68
|
+
if (!isNativeRune(runeDef)) continue;
|
|
69
|
+
const digest = trustDigest(regEntry.path, runeDef);
|
|
70
|
+
const state = trustState(regEntry, runeKey, digest);
|
|
71
|
+
if (state === "trusted") {
|
|
72
|
+
results.push({ ok: true, message: `plugin ${pluginKey}:${runeKey} native script trusted` });
|
|
73
|
+
} else if (state === "changed") {
|
|
74
|
+
results.push({ ok: false, message: `plugin ${pluginKey}:${runeKey} changed since trusted (run: crunes plugin trust ${pluginKey} ${runeKey})` });
|
|
75
|
+
} else {
|
|
76
|
+
results.push({ ok: false, message: `plugin ${pluginKey}:${runeKey} runs natively outside sandbox and is not yet trusted (run: crunes plugin trust ${pluginKey} ${runeKey})` });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
function checkRunBlockRunes(config, projectRoot) {
|
|
85
|
+
const results = [];
|
|
86
|
+
for (const [key, entry] of Object.entries(config?.runes ?? {})) {
|
|
87
|
+
if (entry?.run == null) continue;
|
|
88
|
+
const run = typeof entry.run === "string" ? { command: entry.run } : entry.run;
|
|
89
|
+
if (!run?.command) continue;
|
|
90
|
+
const desc = describeRunBlock(entry, projectRoot);
|
|
91
|
+
if (desc.runtime === "isolate") {
|
|
92
|
+
results.push({ ok: true, message: `${key} \u2192 isolate` });
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
if (desc.runtime === "program") {
|
|
97
|
+
if (!onPath(desc.command)) throw new Error(`"${desc.command}" is not on PATH`);
|
|
98
|
+
} else if (!existsSync(desc.command)) {
|
|
99
|
+
throw new Error(`${relative(projectRoot, desc.command).replace(/\\/g, "/")} does not exist`);
|
|
100
|
+
}
|
|
101
|
+
assertNotMissedRename(desc.command, desc.runtime, projectRoot);
|
|
102
|
+
if (desc.argsModule && /\.json$/i.test(desc.argsModule)) {
|
|
103
|
+
loadJsonSchema(desc.argsModule, relative(projectRoot, desc.argsModule).replace(/\\/g, "/"));
|
|
104
|
+
}
|
|
105
|
+
const found = resolveInterpreter(desc.runtime, projectRoot);
|
|
106
|
+
const how = found ? `${desc.runtime}: ${[found.command, ...found.args].join(" ")}` : desc.runtime === "program" ? `program: ${onPath(desc.command)}` : `${desc.runtime}: run directly`;
|
|
107
|
+
results.push({ ok: true, message: `${key} \u2192 ${how} (native)` });
|
|
108
|
+
} catch (err) {
|
|
109
|
+
results.push({ ok: false, message: `${key}: ${err.message}` });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return results;
|
|
113
|
+
}
|
|
114
|
+
var KNOWN_FORMATS = /* @__PURE__ */ new Set(["1"]);
|
|
115
|
+
function collectLayerWarnings({ global = {}, project = {} } = {}) {
|
|
116
|
+
const warnings = [];
|
|
117
|
+
for (const key of Object.keys(project.runes ?? {})) {
|
|
118
|
+
if (global.runes?.[key]) {
|
|
119
|
+
warnings.push(`rune "${key}" shadows the global rune of the same name`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const globalPlugins = coercePlugins(global.plugins);
|
|
123
|
+
const projectPlugins = coercePlugins(project.plugins);
|
|
124
|
+
for (const [key, enabled] of Object.entries(projectPlugins)) {
|
|
125
|
+
if (globalPlugins[key] === true && enabled === false) {
|
|
126
|
+
warnings.push(`plugin "${key}" is enabled globally but disabled in this project`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return warnings;
|
|
130
|
+
}
|
|
131
|
+
async function handler({ projectRoot = process.cwd() } = {}) {
|
|
132
|
+
let anyFailed = false;
|
|
133
|
+
const major = parseInt(process.versions.node.split(".")[0], 10);
|
|
134
|
+
if (major >= 22) {
|
|
135
|
+
output.success(`Node.js v${process.versions.node}`);
|
|
136
|
+
} else {
|
|
137
|
+
output.error(`Node.js v${process.versions.node} \u2014 requires >= 22`);
|
|
138
|
+
anyFailed = true;
|
|
139
|
+
}
|
|
140
|
+
const versionResult = spawnSync("crunes", ["--version"], { encoding: "utf8", shell: true });
|
|
141
|
+
if (versionResult.status === 0) {
|
|
142
|
+
output.success(`crunes ${versionResult.stdout.trim()} in PATH`);
|
|
143
|
+
} else {
|
|
144
|
+
output.warn("crunes not found globally in PATH (you can still run it locally or via npx)");
|
|
145
|
+
}
|
|
146
|
+
let config;
|
|
147
|
+
try {
|
|
148
|
+
config = loadConfig(projectRoot);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
output.error(`Config: ${err.message}`);
|
|
151
|
+
anyFailed = true;
|
|
152
|
+
}
|
|
153
|
+
if (config) {
|
|
154
|
+
const runeCount = Object.keys(config.runes ?? {}).length;
|
|
155
|
+
if (config.format !== void 0 && !KNOWN_FORMATS.has(String(config.format))) {
|
|
156
|
+
output.error(`Config format "${config.format}" not recognised by this CLI version`);
|
|
157
|
+
anyFailed = true;
|
|
158
|
+
} else {
|
|
159
|
+
output.success(`Config valid \u2014 ${runeCount} rune${runeCount === 1 ? "" : "s"} registered`);
|
|
160
|
+
}
|
|
161
|
+
for (const { ok, message } of checkRunBlockRunes(config, projectRoot)) {
|
|
162
|
+
if (ok) output.success(message);
|
|
163
|
+
else {
|
|
164
|
+
output.error(message);
|
|
165
|
+
anyFailed = true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const { ok, message } of await checkPluginNativeTrust(config)) {
|
|
169
|
+
if (ok) output.success(message);
|
|
170
|
+
else {
|
|
171
|
+
output.info(message);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const globalPath = getConfigPath({ global: true });
|
|
176
|
+
let globalRaw = null;
|
|
177
|
+
try {
|
|
178
|
+
globalRaw = readRawConfig(globalPath);
|
|
179
|
+
} catch {
|
|
180
|
+
}
|
|
181
|
+
if (process.env.CRUNES_NO_GLOBAL === "1") {
|
|
182
|
+
output.warn("Global config skipped (CRUNES_NO_GLOBAL=1)");
|
|
183
|
+
} else if (globalRaw) {
|
|
184
|
+
output.success(`Global config found at ${globalPath}`);
|
|
185
|
+
} else {
|
|
186
|
+
output.info(`No global config at ${globalPath}`);
|
|
187
|
+
}
|
|
188
|
+
let projectRaw = null;
|
|
189
|
+
try {
|
|
190
|
+
projectRaw = readRawConfig(getConfigPath({ configRoot: projectRoot }));
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
if (!projectRaw) {
|
|
194
|
+
output.info("No project config \u2014 crunes runs rootless here, writing no local state");
|
|
195
|
+
}
|
|
196
|
+
for (const warning of collectLayerWarnings({ global: globalRaw ?? {}, project: projectRaw ?? {} })) {
|
|
197
|
+
output.warn(warning);
|
|
198
|
+
}
|
|
199
|
+
if (anyFailed) {
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
checkPluginNativeTrust,
|
|
205
|
+
checkRunBlockRunes,
|
|
206
|
+
collectLayerWarnings,
|
|
207
|
+
handler
|
|
208
|
+
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfigPath,
|
|
3
3
|
setPluginEnabled
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-E7CZPAM2.js";
|
|
5
|
+
import "./chunk-3KKRNQQU.js";
|
|
6
|
+
import "./chunk-UBCAZGLE.js";
|
|
6
7
|
import {
|
|
7
8
|
loadRegistry,
|
|
8
9
|
resolvePluginKey
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MTJ2KW3V.js";
|
|
11
|
+
import "./chunk-VP7YLCQP.js";
|
|
10
12
|
import "./chunk-2Q3KLBE6.js";
|
|
13
|
+
import "./chunk-55GTJG5I.js";
|
|
11
14
|
import {
|
|
12
15
|
init_require_shim
|
|
13
16
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfigPath
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-QYRF3R35.js";
|
|
3
|
+
} from "./chunk-E7CZPAM2.js";
|
|
5
4
|
import {
|
|
6
5
|
output
|
|
7
6
|
} from "./chunk-MIKWIFYR.js";
|
|
@@ -12,7 +11,11 @@ import {
|
|
|
12
11
|
ye
|
|
13
12
|
} from "./chunk-CGZL5SSH.js";
|
|
14
13
|
import "./chunk-WCODTMDN.js";
|
|
14
|
+
import "./chunk-3KKRNQQU.js";
|
|
15
|
+
import "./chunk-UBCAZGLE.js";
|
|
16
|
+
import "./chunk-VP7YLCQP.js";
|
|
15
17
|
import "./chunk-2Q3KLBE6.js";
|
|
18
|
+
import "./chunk-55GTJG5I.js";
|
|
16
19
|
import {
|
|
17
20
|
init_require_shim
|
|
18
21
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -3,17 +3,22 @@ import {
|
|
|
3
3
|
} from "./chunk-YVN3VDRE.js";
|
|
4
4
|
import {
|
|
5
5
|
installPlugin
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-QYRF3R35.js";
|
|
6
|
+
} from "./chunk-NJVPLN5D.js";
|
|
7
|
+
import "./chunk-E7CZPAM2.js";
|
|
9
8
|
import {
|
|
10
9
|
output
|
|
11
10
|
} from "./chunk-MIKWIFYR.js";
|
|
12
11
|
import "./chunk-CGZL5SSH.js";
|
|
13
12
|
import "./chunk-WCODTMDN.js";
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-MUWDZJN2.js";
|
|
14
|
+
import "./chunk-3KKRNQQU.js";
|
|
15
|
+
import "./chunk-UBCAZGLE.js";
|
|
16
|
+
import "./chunk-MTJ2KW3V.js";
|
|
17
|
+
import "./chunk-FIAFVIAN.js";
|
|
18
|
+
import "./chunk-VP7YLCQP.js";
|
|
19
|
+
import "./chunk-WE4HDHFU.js";
|
|
15
20
|
import "./chunk-2Q3KLBE6.js";
|
|
16
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-55GTJG5I.js";
|
|
17
22
|
import {
|
|
18
23
|
init_require_shim
|
|
19
24
|
} from "./chunk-TPK5AGRA.js";
|