@darkrymit/crunes-cli 0.8.5 → 0.10.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/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
- package/dist/chunks/add-MSX6XSU3.js +68 -0
- package/dist/chunks/{apply-J4YICV6H.js → apply-LOIJIPLR.js} +21 -12
- package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-3IHFP3V2.js} +27 -18
- package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
- package/dist/chunks/chunk-2DNYVKBF.js +109 -0
- package/dist/chunks/chunk-2FI6KN3C.js +283 -0
- package/dist/chunks/chunk-2HM5Q52B.js +131 -0
- package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
- package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
- package/dist/chunks/chunk-55GTJG5I.js +1154 -0
- package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
- package/dist/chunks/chunk-7KYCYDAS.js +325 -0
- package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
- package/dist/chunks/chunk-EO3CSXWK.js +70 -0
- package/dist/chunks/chunk-FIAFVIAN.js +79 -0
- package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
- package/dist/chunks/chunk-H2OT7D6N.js +303 -0
- package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
- package/dist/chunks/chunk-KSQDFE5N.js +85 -0
- package/dist/chunks/{chunk-BTIPUR5S.js → chunk-KUEMDPNG.js} +108 -91
- package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
- package/dist/chunks/{chunk-GTCPZ22N.js → chunk-MTJ2KW3V.js} +3 -1
- package/dist/chunks/chunk-MVCBPI4J.js +2354 -0
- package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
- package/dist/chunks/{chunk-KII6KW5Z.js → chunk-RVBAAXRY.js} +64 -44
- package/dist/chunks/chunk-SUCYDYMU.js +44 -0
- package/dist/chunks/chunk-UBCAZGLE.js +15 -0
- package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
- package/dist/chunks/chunk-VP7YLCQP.js +244 -0
- package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
- package/dist/chunks/chunk-XDMMSZIL.js +71 -0
- package/dist/chunks/chunk-YKIKJHYO.js +94 -0
- package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
- package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
- package/dist/chunks/{create-L6DJN4ME.js → create-DXW4YYLJ.js} +8 -8
- package/dist/chunks/create-LPLNCOW4.js +268 -0
- package/dist/chunks/{create-GPDE2YKL.js → create-Y4LHLWGL.js} +26 -18
- package/dist/chunks/{delete-LNOYM5KG.js → delete-2EXPFBFC.js} +2 -2
- package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
- package/dist/chunks/{delete-C4UJ7X5K.js → delete-MJAECXXV.js} +2 -2
- package/dist/chunks/disable-TITOSMXB.js +43 -0
- package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
- package/dist/chunks/enable-LGTPDWPV.js +35 -0
- package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
- package/dist/chunks/{init-HU5OMHEH.js → init-KO2HLED5.js} +18 -8
- package/dist/chunks/install-7IRUAGSF.js +64 -0
- package/dist/chunks/{intro-36OLGNYN.js → intro-JNJ6A75J.js} +89 -21
- package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
- package/dist/chunks/{list-2JYMBMZC.js → list-BCCM3TLP.js} +12 -7
- package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
- package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
- package/dist/chunks/list-MLKZE36K.js +92 -0
- package/dist/chunks/list-QVZKR3IE.js +62 -0
- package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
- package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
- package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
- package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
- package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
- package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
- package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
- package/dist/chunks/{registry-RG34DPD7.js → registry-IWP7JMNI.js} +2 -2
- package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
- package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
- package/dist/chunks/{repl-BPEWARN7.js → repl-5GDN3RAO.js} +99 -31
- package/dist/chunks/resolver-CA2A32AC.js +36 -0
- package/dist/chunks/run-WL3IZBXF.js +35 -0
- package/dist/chunks/rune-YA4TFHTB.js +283 -0
- package/dist/chunks/runner-QNZMBHQY.js +34 -0
- package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
- package/dist/chunks/shell-explain-LKBBP2BG.js +77 -0
- package/dist/chunks/trust-BFIDANXD.js +109 -0
- package/dist/chunks/uninstall-3MWZIZVA.js +58 -0
- package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
- package/dist/chunks/{update-KSC6VRMU.js → update-W4MJUTTW.js} +25 -19
- package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
- package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
- package/dist/chunks/{version-YG2M7HER.js → version-FLHI5KFS.js} +3 -3
- package/dist/cli.js +115 -70
- package/package.json +2 -2
- package/dist/chunks/chunk-ASZKAC24.js +0 -103
- package/dist/chunks/chunk-G3U4V32O.js +0 -46
- package/dist/chunks/chunk-GSA432UC.js +0 -90
- package/dist/chunks/chunk-WJRZN7BR.js +0 -77492
- package/dist/chunks/create-VYZRWRGQ.js +0 -170
- package/dist/chunks/disable-FGJ7VMPO.js +0 -47
- package/dist/chunks/doctor-7NWBJAH7.js +0 -53
- package/dist/chunks/enable-ZL6QOC2I.js +0 -47
- package/dist/chunks/install-FIYRMVLR.js +0 -57
- package/dist/chunks/list-AIYNOPNZ.js +0 -28
- package/dist/chunks/list-NZ5DHXJF.js +0 -111
- package/dist/chunks/resolver-36V72VKR.js +0 -28
- package/dist/chunks/run-IVL23SMW.js +0 -26
- package/dist/chunks/rune-XRREUL56.js +0 -186
- package/dist/chunks/uninstall-G56DZRFG.js +0 -49
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_require_shim
|
|
3
|
+
} from "./chunk-TPK5AGRA.js";
|
|
4
|
+
|
|
5
|
+
// src/core/rune-entry.js
|
|
6
|
+
init_require_shim();
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
+
import { join, isAbsolute } from "node:path";
|
|
9
|
+
var ISOLATE_MODULE = /\.rune\.m?js$/i;
|
|
10
|
+
var REPL_EXPORT = /\bexport\s+(?:async\s+)?(?:function\s*\*?\s*|const\s+|let\s+|var\s+)repl\b|\bexport\s*\{[^}]*\brepl\b[^}]*\}/;
|
|
11
|
+
function blockOf(entry, name) {
|
|
12
|
+
const block2 = entry?.[name];
|
|
13
|
+
if (block2 == null) return null;
|
|
14
|
+
return typeof block2 === "string" ? { command: block2 } : block2;
|
|
15
|
+
}
|
|
16
|
+
function scopedPermissions(entry) {
|
|
17
|
+
const out = {};
|
|
18
|
+
for (const mode of ["run", "repl"]) {
|
|
19
|
+
const permissions = blockOf(entry, mode)?.permissions;
|
|
20
|
+
if (permissions) out[mode] = permissions;
|
|
21
|
+
}
|
|
22
|
+
return Object.keys(out).length ? out : void 0;
|
|
23
|
+
}
|
|
24
|
+
function blockModule(entry, mode, base) {
|
|
25
|
+
const command = blockOf(entry, mode)?.command;
|
|
26
|
+
if (!command) return null;
|
|
27
|
+
return isAbsolute(command) ? command : join(base, command);
|
|
28
|
+
}
|
|
29
|
+
function isolateName(file) {
|
|
30
|
+
if (ISOLATE_MODULE.test(file)) return file;
|
|
31
|
+
return file.replace(/\.(m?js)$/i, ".rune.$1");
|
|
32
|
+
}
|
|
33
|
+
function exportsRepl(file) {
|
|
34
|
+
try {
|
|
35
|
+
return REPL_EXPORT.test(readFileSync(file, "utf8"));
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function block(command, permissions) {
|
|
41
|
+
return permissions ? { ...command && { command }, permissions } : command;
|
|
42
|
+
}
|
|
43
|
+
function migrateEntry(entry, { base, defaultFile }) {
|
|
44
|
+
if (entry == null || typeof entry !== "object" || Array.isArray(entry)) return null;
|
|
45
|
+
const perms = entry.permissions;
|
|
46
|
+
const isV1 = entry.path !== void 0 || perms !== void 0 || entry.run == null && entry.plugin == null && defaultFile && existsSync(join(base, defaultFile));
|
|
47
|
+
if (!isV1) return null;
|
|
48
|
+
const renames = [];
|
|
49
|
+
const file = entry.path ?? (entry.plugin == null && defaultFile && existsSync(join(base, defaultFile)) ? defaultFile : null);
|
|
50
|
+
const blocks = {};
|
|
51
|
+
if (file) {
|
|
52
|
+
const command = isolateName(file);
|
|
53
|
+
if (command !== file) renames.push({ from: file, to: command });
|
|
54
|
+
const absolute = isAbsolute(file) ? file : join(base, file);
|
|
55
|
+
blocks.run = block(command, perms?.run);
|
|
56
|
+
if (perms?.repl || exportsRepl(absolute)) blocks.repl = block(command, perms?.repl);
|
|
57
|
+
} else {
|
|
58
|
+
if (perms?.run) blocks.run = { permissions: perms.run };
|
|
59
|
+
if (perms?.repl) blocks.repl = { permissions: perms.repl };
|
|
60
|
+
}
|
|
61
|
+
const out = {};
|
|
62
|
+
let placed = false;
|
|
63
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
64
|
+
if (key === "path" || key === "permissions") {
|
|
65
|
+
if (!placed) {
|
|
66
|
+
Object.assign(out, blocks);
|
|
67
|
+
placed = true;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
out[key] = value;
|
|
72
|
+
}
|
|
73
|
+
if (!placed) Object.assign(out, blocks);
|
|
74
|
+
return { entry: out, renames };
|
|
75
|
+
}
|
|
76
|
+
function v1EntryError(fileName, where, rewritten) {
|
|
77
|
+
return new Error(
|
|
78
|
+
`${fileName}: ${where} uses the old entry shape (path / permissions.run / an implicit REPL), which is no longer read. Rewritten, it is:
|
|
79
|
+
|
|
80
|
+
${JSON.stringify(rewritten.entry, null, 2).replace(/^/gm, " ")}
|
|
81
|
+
` + (rewritten.renames.length ? `
|
|
82
|
+
and the module is renamed: ${rewritten.renames.map((r) => `${r.from} \u2192 ${r.to}`).join(", ")}
|
|
83
|
+
` : "") + `
|
|
84
|
+
Run \`crunes migrate\` to rewrite every entry and rename the modules.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
blockOf,
|
|
90
|
+
scopedPermissions,
|
|
91
|
+
blockModule,
|
|
92
|
+
migrateEntry,
|
|
93
|
+
v1EntryError
|
|
94
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
output
|
|
3
|
+
} from "./chunk-MIKWIFYR.js";
|
|
1
4
|
import {
|
|
2
5
|
Re,
|
|
3
6
|
fe,
|
|
@@ -5,9 +8,6 @@ import {
|
|
|
5
8
|
le,
|
|
6
9
|
ye
|
|
7
10
|
} from "./chunk-CGZL5SSH.js";
|
|
8
|
-
import {
|
|
9
|
-
output
|
|
10
|
-
} from "./chunk-6XLT25GS.js";
|
|
11
11
|
import "./chunk-WCODTMDN.js";
|
|
12
12
|
import {
|
|
13
13
|
init_require_shim
|
|
@@ -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()]
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfigPath,
|
|
3
|
+
readRawConfig,
|
|
4
|
+
writeRawConfig
|
|
5
|
+
} from "./chunk-SUCYDYMU.js";
|
|
6
|
+
import {
|
|
7
|
+
output
|
|
8
|
+
} from "./chunk-MIKWIFYR.js";
|
|
9
|
+
import {
|
|
10
|
+
Ee,
|
|
11
|
+
Re,
|
|
12
|
+
fe,
|
|
13
|
+
ge,
|
|
14
|
+
ye
|
|
15
|
+
} from "./chunk-CGZL5SSH.js";
|
|
16
|
+
import "./chunk-WCODTMDN.js";
|
|
17
|
+
import "./chunk-2FI6KN3C.js";
|
|
18
|
+
import "./chunk-UBCAZGLE.js";
|
|
19
|
+
import "./chunk-VP7YLCQP.js";
|
|
20
|
+
import "./chunk-YKIKJHYO.js";
|
|
21
|
+
import {
|
|
22
|
+
getStorePath
|
|
23
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
24
|
+
import "./chunk-55GTJG5I.js";
|
|
25
|
+
import {
|
|
26
|
+
init_require_shim
|
|
27
|
+
} from "./chunk-TPK5AGRA.js";
|
|
28
|
+
|
|
29
|
+
// src/rune/commands/create.js
|
|
30
|
+
init_require_shim();
|
|
31
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
32
|
+
import { join, dirname } from "node:path";
|
|
33
|
+
var VALID_FORMATS = ["tree", "markdown"];
|
|
34
|
+
var SCRIPT_LANGS = {
|
|
35
|
+
python: {
|
|
36
|
+
ext: "py",
|
|
37
|
+
body: (key) => [
|
|
38
|
+
`import json`,
|
|
39
|
+
`import os`,
|
|
40
|
+
`import sys`,
|
|
41
|
+
``,
|
|
42
|
+
`# A script rune: crunes runs this with the project's Python and passes`,
|
|
43
|
+
`# sys.argv[1:] the caller's arguments, unchanged`,
|
|
44
|
+
`# CRUNES_ARGS the parsed arguments as JSON, when the rune has an args schema`,
|
|
45
|
+
`# CRUNES_VARS the rune's configured vars as JSON`,
|
|
46
|
+
`# Whatever it prints is the rune's output.`,
|
|
47
|
+
``,
|
|
48
|
+
`args = json.loads(os.environ.get("CRUNES_ARGS", "null"))`,
|
|
49
|
+
`rune_vars = json.loads(os.environ.get("CRUNES_VARS", "{}"))`,
|
|
50
|
+
``,
|
|
51
|
+
`print("${key}:", sys.argv[1:])`,
|
|
52
|
+
``
|
|
53
|
+
].join("\n")
|
|
54
|
+
},
|
|
55
|
+
bash: {
|
|
56
|
+
ext: "sh",
|
|
57
|
+
body: (key) => [
|
|
58
|
+
`# A script rune: crunes runs this with bash and passes`,
|
|
59
|
+
`# "$@" the caller's arguments, unchanged`,
|
|
60
|
+
`# CRUNES_ARGS the parsed arguments as JSON, when the rune has an args schema`,
|
|
61
|
+
`# CRUNES_VARS the rune's configured vars as JSON`,
|
|
62
|
+
`# Whatever it prints is the rune's output; its exit code is crunes's.`,
|
|
63
|
+
``,
|
|
64
|
+
`echo "${key}: $*"`,
|
|
65
|
+
``
|
|
66
|
+
].join("\n")
|
|
67
|
+
},
|
|
68
|
+
node: {
|
|
69
|
+
ext: "js",
|
|
70
|
+
body: (key) => [
|
|
71
|
+
`// A script rune: crunes runs this with Node, outside the sandbox, and passes`,
|
|
72
|
+
`// process.argv.slice(2) the caller's arguments, unchanged`,
|
|
73
|
+
`// CRUNES_ARGS the parsed arguments as JSON, when the rune has an args schema`,
|
|
74
|
+
`// CRUNES_VARS the rune's configured vars as JSON`,
|
|
75
|
+
`// Whatever it prints is the rune's output. To run in the sandbox instead, use a *.rune.js file.`,
|
|
76
|
+
``,
|
|
77
|
+
`const args = JSON.parse(process.env.CRUNES_ARGS ?? 'null')`,
|
|
78
|
+
`const vars = JSON.parse(process.env.CRUNES_VARS ?? '{}')`,
|
|
79
|
+
``,
|
|
80
|
+
`console.log('${key}:', process.argv.slice(2))`,
|
|
81
|
+
``
|
|
82
|
+
].join("\n")
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var VALID_LANGS = Object.keys(SCRIPT_LANGS);
|
|
86
|
+
async function createScriptRune({ key, lang, runeRelPath, name, description, configRoot, global }) {
|
|
87
|
+
const spec = SCRIPT_LANGS[lang];
|
|
88
|
+
if (!spec) {
|
|
89
|
+
output.error(`Invalid --lang. Must be one of: ${VALID_LANGS.join(", ")}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
if (!key) {
|
|
93
|
+
output.error("Missing required argument: <key>");
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
runeRelPath = runeRelPath ?? (global ? `runes/${key}.${spec.ext}` : `.crunes/runes/${key}.${spec.ext}`);
|
|
97
|
+
const runeAbsPath = join(global ? getStorePath() : configRoot, runeRelPath);
|
|
98
|
+
const configPath = getConfigPath({ configRoot, global });
|
|
99
|
+
const config = readRawConfig(configPath) ?? { runes: {} };
|
|
100
|
+
if (config.runes?.[key] != null) {
|
|
101
|
+
output.error(`Rune "${key}" already exists in ${configPath}.`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
await mkdir(dirname(runeAbsPath), { recursive: true });
|
|
105
|
+
await writeFile(runeAbsPath, spec.body(key));
|
|
106
|
+
config.runes = {
|
|
107
|
+
...config.runes ?? {},
|
|
108
|
+
[key]: { ...name && { name }, ...description && { description }, run: runeRelPath }
|
|
109
|
+
};
|
|
110
|
+
await writeRawConfig(configPath, config);
|
|
111
|
+
output.success(`Created ${runeRelPath} (${lang}, native)`);
|
|
112
|
+
output.info(`Run: crunes run ${key}`);
|
|
113
|
+
}
|
|
114
|
+
function template(key, format) {
|
|
115
|
+
const imports = format === "tree" ? `import { md, section, tree } from '@utils'` : `import { md, section } from '@utils'`;
|
|
116
|
+
const header = [
|
|
117
|
+
`// permissions:`,
|
|
118
|
+
`// run:`,
|
|
119
|
+
`// allow: [] \u2014 add patterns like fs.read:./** if you use utils.fs`,
|
|
120
|
+
`// deny: []`,
|
|
121
|
+
``,
|
|
122
|
+
imports,
|
|
123
|
+
``,
|
|
124
|
+
`// export async function args(b) {`,
|
|
125
|
+
`// return b`,
|
|
126
|
+
`// .option('-v, --verbose', 'Verbose output', false)`,
|
|
127
|
+
`// .build()`,
|
|
128
|
+
`// }`,
|
|
129
|
+
``,
|
|
130
|
+
`export async function run(args) {`,
|
|
131
|
+
` // args._ \u2014 data positionals (command tokens stripped)`,
|
|
132
|
+
` // args.$rest \u2014 unmapped positional arguments`,
|
|
133
|
+
` // args.verbose \u2014 named flag (if args export is defined above)`,
|
|
134
|
+
` // utils.fs.cwd() \u2014 absolute path to the project root`
|
|
135
|
+
].join("\n");
|
|
136
|
+
if (format === "tree") {
|
|
137
|
+
return header + "\n" + [
|
|
138
|
+
``,
|
|
139
|
+
` const root = tree.node('${key}', 'Root description', [`,
|
|
140
|
+
` tree.node('child', 'Child description'),`,
|
|
141
|
+
` ]);`,
|
|
142
|
+
` return section.create('example-tree', { type: 'tree', root });`,
|
|
143
|
+
`}`,
|
|
144
|
+
``
|
|
145
|
+
].join("\n");
|
|
146
|
+
}
|
|
147
|
+
return header + "\n" + [
|
|
148
|
+
``,
|
|
149
|
+
` const content = [`,
|
|
150
|
+
` md.h3('${key}'),`,
|
|
151
|
+
` md.ul(['Replace with real data']),`,
|
|
152
|
+
` ].join('\\n');`,
|
|
153
|
+
` return section.create('example-md', { type: 'markdown', content });`,
|
|
154
|
+
`}`,
|
|
155
|
+
``
|
|
156
|
+
].join("\n");
|
|
157
|
+
}
|
|
158
|
+
async function handler({
|
|
159
|
+
key,
|
|
160
|
+
format,
|
|
161
|
+
lang,
|
|
162
|
+
path: runeRelPath,
|
|
163
|
+
name,
|
|
164
|
+
description,
|
|
165
|
+
yes = false,
|
|
166
|
+
projectRoot = process.cwd(),
|
|
167
|
+
configRoot = projectRoot,
|
|
168
|
+
global = false
|
|
169
|
+
} = {}) {
|
|
170
|
+
if (lang) {
|
|
171
|
+
await createScriptRune({ key, lang, runeRelPath, name, description, configRoot, global });
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const isNonInteractive = yes || !process.stdout.isTTY;
|
|
175
|
+
if (isNonInteractive) {
|
|
176
|
+
if (!key) {
|
|
177
|
+
output.error("Missing required argument: <key>");
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
if (format && !VALID_FORMATS.includes(format)) {
|
|
181
|
+
output.error(`Invalid --format. Must be one of: ${VALID_FORMATS.join(", ")}`);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
if (!format) {
|
|
185
|
+
format = "markdown";
|
|
186
|
+
output.info('--format not specified, defaulting to "markdown"');
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
ye("crunes create");
|
|
190
|
+
if (!key) {
|
|
191
|
+
const result = await Re({ message: "Rune key?", validate: (v) => v ? void 0 : "Required" });
|
|
192
|
+
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
193
|
+
ge("Cancelled.");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
key = result;
|
|
197
|
+
}
|
|
198
|
+
if (!format) {
|
|
199
|
+
const result = await Ee({
|
|
200
|
+
message: "Output format?",
|
|
201
|
+
options: [
|
|
202
|
+
{ value: "tree", label: "tree", hint: "hierarchical ASCII tree structure" },
|
|
203
|
+
{ value: "markdown", label: "markdown", hint: "freeform markdown content" }
|
|
204
|
+
]
|
|
205
|
+
});
|
|
206
|
+
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
207
|
+
ge("Cancelled.");
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
format = result;
|
|
211
|
+
}
|
|
212
|
+
if (!runeRelPath) {
|
|
213
|
+
const defaultPath = global ? `runes/${key}.rune.js` : `.crunes/runes/${key}.rune.js`;
|
|
214
|
+
const result = await Re({ message: "File path?", initialValue: defaultPath });
|
|
215
|
+
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
216
|
+
ge("Cancelled.");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
runeRelPath = result;
|
|
220
|
+
}
|
|
221
|
+
if (!name) {
|
|
222
|
+
const result = await Re({ message: "Name? (optional)", placeholder: "Human-readable label for crunes list" });
|
|
223
|
+
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
224
|
+
ge("Cancelled.");
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
name = result || void 0;
|
|
228
|
+
}
|
|
229
|
+
if (!description) {
|
|
230
|
+
const result = await Re({ message: "Description? (optional)", placeholder: "What context does this rune provide?" });
|
|
231
|
+
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
232
|
+
ge("Cancelled.");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
description = result || void 0;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
runeRelPath = runeRelPath ?? (global ? `runes/${key}.rune.js` : `.crunes/runes/${key}.rune.js`);
|
|
239
|
+
if (!/\.rune\.m?js$/i.test(runeRelPath)) {
|
|
240
|
+
output.error(`${runeRelPath}: a sandboxed rune's file must be named *.rune.js \u2014 the name is what runs it in the isolate.`);
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
const baseRoot = global ? getStorePath() : configRoot;
|
|
244
|
+
const runeAbsPath = join(baseRoot, runeRelPath);
|
|
245
|
+
await mkdir(dirname(runeAbsPath), { recursive: true });
|
|
246
|
+
await writeFile(runeAbsPath, template(key, format));
|
|
247
|
+
const configPath = getConfigPath({ configRoot, global });
|
|
248
|
+
const config = readRawConfig(configPath) ?? { runes: {} };
|
|
249
|
+
const entry = {
|
|
250
|
+
...name && { name },
|
|
251
|
+
...description && { description },
|
|
252
|
+
run: runeRelPath
|
|
253
|
+
};
|
|
254
|
+
config.runes = { ...config.runes ?? {}, [key]: entry };
|
|
255
|
+
await writeRawConfig(configPath, config);
|
|
256
|
+
if (!isNonInteractive) {
|
|
257
|
+
fe(`Created ${runeRelPath}
|
|
258
|
+
Run: crunes run ${key}`);
|
|
259
|
+
} else {
|
|
260
|
+
output.success(`Created ${runeRelPath}`);
|
|
261
|
+
output.info(`Run: crunes run ${key}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
export {
|
|
265
|
+
VALID_LANGS,
|
|
266
|
+
handler,
|
|
267
|
+
template
|
|
268
|
+
};
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfigPath,
|
|
3
|
+
readRawConfig,
|
|
4
|
+
writeRawConfig
|
|
5
|
+
} from "./chunk-SUCYDYMU.js";
|
|
6
|
+
import {
|
|
7
|
+
output
|
|
8
|
+
} from "./chunk-MIKWIFYR.js";
|
|
1
9
|
import {
|
|
2
10
|
Re,
|
|
3
11
|
fe,
|
|
4
12
|
ge,
|
|
5
13
|
ye
|
|
6
14
|
} from "./chunk-CGZL5SSH.js";
|
|
7
|
-
import {
|
|
8
|
-
output
|
|
9
|
-
} from "./chunk-6XLT25GS.js";
|
|
10
15
|
import "./chunk-WCODTMDN.js";
|
|
16
|
+
import "./chunk-2FI6KN3C.js";
|
|
17
|
+
import "./chunk-UBCAZGLE.js";
|
|
18
|
+
import "./chunk-VP7YLCQP.js";
|
|
19
|
+
import "./chunk-YKIKJHYO.js";
|
|
20
|
+
import {
|
|
21
|
+
getStorePath
|
|
22
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
23
|
+
import "./chunk-55GTJG5I.js";
|
|
11
24
|
import {
|
|
12
25
|
init_require_shim
|
|
13
26
|
} from "./chunk-TPK5AGRA.js";
|
|
14
27
|
|
|
15
28
|
// src/template/commands/create.js
|
|
16
29
|
init_require_shim();
|
|
17
|
-
import { mkdir, writeFile
|
|
30
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
18
31
|
import { join, dirname } from "node:path";
|
|
19
32
|
function templateStub(name) {
|
|
20
33
|
return [
|
|
@@ -53,7 +66,8 @@ async function handler({
|
|
|
53
66
|
description,
|
|
54
67
|
yes = false,
|
|
55
68
|
projectRoot = process.cwd(),
|
|
56
|
-
configRoot = projectRoot
|
|
69
|
+
configRoot = projectRoot,
|
|
70
|
+
global = false
|
|
57
71
|
} = {}) {
|
|
58
72
|
const isNonInteractive = yes || !process.stdout.isTTY;
|
|
59
73
|
if (isNonInteractive) {
|
|
@@ -72,7 +86,7 @@ async function handler({
|
|
|
72
86
|
name = result;
|
|
73
87
|
}
|
|
74
88
|
if (!templateRelPath) {
|
|
75
|
-
const defaultPath = `.crunes/templates/${name}.js`;
|
|
89
|
+
const defaultPath = global ? `templates/${name}.js` : `.crunes/templates/${name}.js`;
|
|
76
90
|
const result = await Re({ message: "File path?", initialValue: defaultPath });
|
|
77
91
|
if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
|
|
78
92
|
ge("Cancelled.");
|
|
@@ -97,26 +111,20 @@ async function handler({
|
|
|
97
111
|
description = result || void 0;
|
|
98
112
|
}
|
|
99
113
|
}
|
|
100
|
-
templateRelPath = templateRelPath ?? `.crunes/templates/${name}.js
|
|
101
|
-
const
|
|
114
|
+
templateRelPath = templateRelPath ?? (global ? `templates/${name}.js` : `.crunes/templates/${name}.js`);
|
|
115
|
+
const baseRoot = global ? getStorePath() : configRoot;
|
|
116
|
+
const templateAbsPath = join(baseRoot, templateRelPath);
|
|
102
117
|
await mkdir(dirname(templateAbsPath), { recursive: true });
|
|
103
118
|
await writeFile(templateAbsPath, templateStub(name));
|
|
104
|
-
const configPath =
|
|
105
|
-
|
|
106
|
-
let config = { runes: {} };
|
|
107
|
-
try {
|
|
108
|
-
config = JSON.parse(await readFile(configPath, "utf8"));
|
|
109
|
-
} catch {
|
|
110
|
-
}
|
|
119
|
+
const configPath = getConfigPath({ configRoot, global });
|
|
120
|
+
const config = readRawConfig(configPath) ?? { runes: {} };
|
|
111
121
|
const entry = {
|
|
112
122
|
path: templateRelPath,
|
|
113
123
|
...templateName && { name: templateName },
|
|
114
124
|
...description && { description }
|
|
115
125
|
};
|
|
116
126
|
config.templates = { ...config.templates ?? {}, [name]: entry };
|
|
117
|
-
|
|
118
|
-
await writeFile(tmpPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
119
|
-
await rename(tmpPath, configPath);
|
|
127
|
+
await writeRawConfig(configPath, config);
|
|
120
128
|
if (!isNonInteractive) {
|
|
121
129
|
fe(`Created ${templateRelPath}
|
|
122
130
|
Use it with: crunes template apply ${name}`);
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
} from "./chunk-CGZL5SSH.js";
|
|
6
6
|
import {
|
|
7
7
|
deleteCacheBucket
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WJII3LZK.js";
|
|
9
9
|
import "./chunk-G4ZAUHHA.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-2Q3KLBE6.js";
|
|
11
11
|
import {
|
|
12
12
|
init_require_shim
|
|
13
13
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deleteSchemaCache,
|
|
3
3
|
listSchemaCaches
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UEUUOAJY.js";
|
|
5
5
|
import {
|
|
6
6
|
output
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MIKWIFYR.js";
|
|
8
|
+
import "./chunk-CGZL5SSH.js";
|
|
8
9
|
import "./chunk-WCODTMDN.js";
|
|
10
|
+
import "./chunk-2Q3KLBE6.js";
|
|
9
11
|
import {
|
|
10
12
|
init_require_shim
|
|
11
13
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
} from "./chunk-CGZL5SSH.js";
|
|
6
6
|
import {
|
|
7
7
|
deleteSqliteDb
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GVMT55GH.js";
|
|
9
9
|
import "./chunk-G4ZAUHHA.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-2Q3KLBE6.js";
|
|
11
11
|
import {
|
|
12
12
|
init_require_shim
|
|
13
13
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfigPath,
|
|
3
|
+
setPluginEnabled
|
|
4
|
+
} from "./chunk-SUCYDYMU.js";
|
|
5
|
+
import {
|
|
6
|
+
enabledPluginKeys,
|
|
7
|
+
loadConfig
|
|
8
|
+
} from "./chunk-2FI6KN3C.js";
|
|
9
|
+
import "./chunk-UBCAZGLE.js";
|
|
10
|
+
import "./chunk-VP7YLCQP.js";
|
|
11
|
+
import "./chunk-YKIKJHYO.js";
|
|
12
|
+
import "./chunk-2Q3KLBE6.js";
|
|
13
|
+
import "./chunk-55GTJG5I.js";
|
|
14
|
+
import {
|
|
15
|
+
init_require_shim
|
|
16
|
+
} from "./chunk-TPK5AGRA.js";
|
|
17
|
+
|
|
18
|
+
// src/plugin/commands/disable.js
|
|
19
|
+
init_require_shim();
|
|
20
|
+
function resolveEnabledPluginKey(nameOrKey, enabledPlugins) {
|
|
21
|
+
if (nameOrKey.includes("@")) return nameOrKey;
|
|
22
|
+
const matches = enabledPlugins.filter((k) => k.slice(k.indexOf("@") + 1) === nameOrKey);
|
|
23
|
+
if (matches.length > 1) {
|
|
24
|
+
throw new Error(`Ambiguous plugin "${nameOrKey}". Use the full key: ${matches.join(", ")}`);
|
|
25
|
+
}
|
|
26
|
+
return matches[0] ?? null;
|
|
27
|
+
}
|
|
28
|
+
async function handler({ name, projectRoot, configRoot, global = false }) {
|
|
29
|
+
try {
|
|
30
|
+
const root = configRoot ?? projectRoot;
|
|
31
|
+
const enabled = enabledPluginKeys(loadConfig(root));
|
|
32
|
+
const pluginKey = resolveEnabledPluginKey(name, enabled);
|
|
33
|
+
if (!pluginKey) throw new Error(`Plugin "${name}" is not enabled.`);
|
|
34
|
+
await setPluginEnabled(getConfigPath({ configRoot: root, global }), pluginKey, false);
|
|
35
|
+
console.log(`Plugin "${pluginKey}" disabled${global ? " globally" : " for this project"}.`);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error(`Error: ${err.message}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
handler
|
|
43
|
+
};
|