@darkrymit/crunes-cli 0.8.5 → 0.9.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/{apply-J4YICV6H.js → apply-YY7MIM64.js} +9 -9
- package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-BQNMULOO.js} +17 -14
- package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
- package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
- package/dist/chunks/{chunk-KII6KW5Z.js → chunk-34F4ZURL.js} +40 -37
- package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
- package/dist/chunks/chunk-CY6C6ADU.js +2787 -0
- package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
- package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
- package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
- package/dist/chunks/chunk-MRNZFUXZ.js +70 -0
- package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
- package/dist/chunks/chunk-QYRF3R35.js +154 -0
- package/dist/chunks/{chunk-BTIPUR5S.js → chunk-SNC7AOT7.js} +78 -12
- package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
- package/dist/chunks/{chunk-GTCPZ22N.js → chunk-VST6HAB6.js} +1 -1
- package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
- package/dist/chunks/chunk-X7PZN73N.js +44 -0
- package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
- package/dist/chunks/{chunk-WJRZN7BR.js → chunk-YXCHIMLW.js} +843 -3027
- package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
- package/dist/chunks/{create-GPDE2YKL.js → create-ET6DT5ZE.js} +22 -18
- package/dist/chunks/{create-VYZRWRGQ.js → create-LM7U3CJS.js} +22 -18
- package/dist/chunks/{create-L6DJN4ME.js → create-TLPM7HJE.js} +3 -3
- package/dist/chunks/{delete-LNOYM5KG.js → delete-5R3WBLVD.js} +5 -5
- package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
- package/dist/chunks/{delete-C4UJ7X5K.js → delete-U4STA2QZ.js} +5 -5
- package/dist/chunks/disable-TNTEIAKO.js +39 -0
- package/dist/chunks/doctor-VXAQYMTR.js +101 -0
- package/dist/chunks/enable-GUQCB4CU.js +31 -0
- package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
- package/dist/chunks/{init-HU5OMHEH.js → init-PJSCFOC6.js} +14 -8
- package/dist/chunks/{install-FIYRMVLR.js → install-4YP7FALO.js} +18 -16
- package/dist/chunks/{intro-36OLGNYN.js → intro-SA7MWV3Z.js} +50 -8
- package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
- package/dist/chunks/list-7R6NASFI.js +92 -0
- 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-AIYNOPNZ.js → list-OMMZAQ23.js} +2 -2
- 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/{list-2JYMBMZC.js → list-WKNPZZOV.js} +5 -4
- 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-K5DV5NAK.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-ZB3DIJ4K.js} +84 -26
- package/dist/chunks/resolver-QIYYFIDX.js +34 -0
- package/dist/chunks/run-22B65ZWZ.js +29 -0
- package/dist/chunks/rune-SYK4N642.js +425 -0
- package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
- package/dist/chunks/shell-explain-QLITLHW7.js +74 -0
- package/dist/chunks/{uninstall-G56DZRFG.js → uninstall-4WR5IHLC.js} +15 -11
- package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
- package/dist/chunks/{update-KSC6VRMU.js → update-ACLDK6E6.js} +19 -18
- 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-EULYWNXN.js} +2 -2
- package/dist/cli.js +92 -64
- package/package.json +1 -1
- package/dist/chunks/chunk-ASZKAC24.js +0 -103
- package/dist/chunks/chunk-GSA432UC.js +0 -90
- 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/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
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_require_shim
|
|
3
|
-
} from "./chunk-TPK5AGRA.js";
|
|
4
|
-
|
|
5
|
-
// src/plugin/commands/disable.js
|
|
6
|
-
init_require_shim();
|
|
7
|
-
import fs from "node:fs/promises";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
function resolveEnabledPluginKey(nameOrKey, enabledPlugins) {
|
|
10
|
-
if (nameOrKey.includes("@")) return nameOrKey;
|
|
11
|
-
const matches = enabledPlugins.filter((k) => k.slice(k.indexOf("@") + 1) === nameOrKey);
|
|
12
|
-
if (matches.length > 1) {
|
|
13
|
-
throw new Error(`Ambiguous plugin "${nameOrKey}". Use the full key: ${matches.join(", ")}`);
|
|
14
|
-
}
|
|
15
|
-
return matches[0] ?? null;
|
|
16
|
-
}
|
|
17
|
-
async function handler({ name, projectRoot, configRoot }) {
|
|
18
|
-
const configPath = path.join(configRoot ?? projectRoot, ".crunes", "config.json");
|
|
19
|
-
let config;
|
|
20
|
-
try {
|
|
21
|
-
config = JSON.parse(await fs.readFile(configPath, "utf8"));
|
|
22
|
-
} catch (err) {
|
|
23
|
-
if (err.code === "ENOENT") {
|
|
24
|
-
console.error("Error: No .crunes/config.json found. Run: crunes init");
|
|
25
|
-
} else {
|
|
26
|
-
console.error(`Error: ${err.message}`);
|
|
27
|
-
}
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
const enabledPlugins = config.plugins ?? [];
|
|
31
|
-
let pluginKey;
|
|
32
|
-
try {
|
|
33
|
-
pluginKey = resolveEnabledPluginKey(name, enabledPlugins);
|
|
34
|
-
if (!pluginKey) throw new Error(`Plugin "${name}" is not enabled in this project.`);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.error(`Error: ${err.message}`);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
config.plugins = enabledPlugins.filter((p) => p !== pluginKey);
|
|
40
|
-
const tmp = configPath + ".tmp";
|
|
41
|
-
await fs.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
|
|
42
|
-
await fs.rename(tmp, configPath);
|
|
43
|
-
console.log(`Plugin "${pluginKey}" disabled.`);
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
handler
|
|
47
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadConfig
|
|
3
|
-
} from "./chunk-GSA432UC.js";
|
|
4
|
-
import {
|
|
5
|
-
output
|
|
6
|
-
} from "./chunk-6XLT25GS.js";
|
|
7
|
-
import "./chunk-WCODTMDN.js";
|
|
8
|
-
import {
|
|
9
|
-
init_require_shim
|
|
10
|
-
} from "./chunk-TPK5AGRA.js";
|
|
11
|
-
|
|
12
|
-
// src/cli/commands/doctor.js
|
|
13
|
-
init_require_shim();
|
|
14
|
-
import { spawnSync } from "node:child_process";
|
|
15
|
-
var KNOWN_FORMATS = /* @__PURE__ */ new Set(["1"]);
|
|
16
|
-
async function handler({ projectRoot = process.cwd() } = {}) {
|
|
17
|
-
let anyFailed = false;
|
|
18
|
-
const major = parseInt(process.versions.node.split(".")[0], 10);
|
|
19
|
-
if (major >= 22) {
|
|
20
|
-
output.success(`Node.js v${process.versions.node}`);
|
|
21
|
-
} else {
|
|
22
|
-
output.error(`Node.js v${process.versions.node} \u2014 requires >= 22`);
|
|
23
|
-
anyFailed = true;
|
|
24
|
-
}
|
|
25
|
-
const versionResult = spawnSync("crunes", ["--version"], { encoding: "utf8", shell: true });
|
|
26
|
-
if (versionResult.status === 0) {
|
|
27
|
-
output.success(`crunes ${versionResult.stdout.trim()} in PATH`);
|
|
28
|
-
} else {
|
|
29
|
-
output.warn("crunes not found globally in PATH (you can still run it locally or via npx)");
|
|
30
|
-
}
|
|
31
|
-
let config;
|
|
32
|
-
try {
|
|
33
|
-
config = loadConfig(projectRoot);
|
|
34
|
-
} catch (err) {
|
|
35
|
-
output.error(`Config: ${err.message}`);
|
|
36
|
-
anyFailed = true;
|
|
37
|
-
}
|
|
38
|
-
if (config) {
|
|
39
|
-
const runeCount = Object.keys(config.runes ?? {}).length;
|
|
40
|
-
if (config.format !== void 0 && !KNOWN_FORMATS.has(String(config.format))) {
|
|
41
|
-
output.error(`Config format "${config.format}" not recognised by this CLI version`);
|
|
42
|
-
anyFailed = true;
|
|
43
|
-
} else {
|
|
44
|
-
output.success(`Config valid \u2014 ${runeCount} rune${runeCount === 1 ? "" : "s"} registered`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (anyFailed) {
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
handler
|
|
53
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadRegistry,
|
|
3
|
-
resolvePluginKey
|
|
4
|
-
} from "./chunk-GTCPZ22N.js";
|
|
5
|
-
import "./chunk-6MRZXASS.js";
|
|
6
|
-
import {
|
|
7
|
-
init_require_shim
|
|
8
|
-
} from "./chunk-TPK5AGRA.js";
|
|
9
|
-
|
|
10
|
-
// src/plugin/commands/enable.js
|
|
11
|
-
init_require_shim();
|
|
12
|
-
import fs from "node:fs/promises";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
async function handler({ name, projectRoot, configRoot }) {
|
|
15
|
-
try {
|
|
16
|
-
const registry = await loadRegistry();
|
|
17
|
-
const pluginKey = resolvePluginKey(name, registry);
|
|
18
|
-
if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
19
|
-
await setProjectPluginEnabled(configRoot ?? projectRoot, pluginKey, true);
|
|
20
|
-
console.log(`Plugin "${pluginKey}" enabled.`);
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error(`Error: ${err.message}`);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function setProjectPluginEnabled(configRoot, pluginKey, enabled) {
|
|
27
|
-
const configPath = path.join(configRoot, ".crunes", "config.json");
|
|
28
|
-
let config;
|
|
29
|
-
try {
|
|
30
|
-
config = JSON.parse(await fs.readFile(configPath, "utf8"));
|
|
31
|
-
} catch (err) {
|
|
32
|
-
if (err.code === "ENOENT") throw new Error("No .crunes/config.json found. Run: crunes init");
|
|
33
|
-
throw err;
|
|
34
|
-
}
|
|
35
|
-
const plugins = config.plugins ?? [];
|
|
36
|
-
if (enabled && !plugins.includes(pluginKey)) {
|
|
37
|
-
config.plugins = [...plugins, pluginKey];
|
|
38
|
-
} else if (!enabled) {
|
|
39
|
-
config.plugins = plugins.filter((p) => p !== pluginKey);
|
|
40
|
-
}
|
|
41
|
-
const tmp = configPath + ".tmp";
|
|
42
|
-
await fs.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
|
|
43
|
-
await fs.rename(tmp, configPath);
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
handler
|
|
47
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
require_cli_table3
|
|
3
|
-
} from "./chunk-DMMC4X27.js";
|
|
4
|
-
import {
|
|
5
|
-
loadConfig
|
|
6
|
-
} from "./chunk-GSA432UC.js";
|
|
7
|
-
import {
|
|
8
|
-
getRune
|
|
9
|
-
} from "./chunk-WJRZN7BR.js";
|
|
10
|
-
import "./chunk-J3GZ3DXD.js";
|
|
11
|
-
import "./chunk-ZJDKCC2Y.js";
|
|
12
|
-
import "./chunk-NDEYEYSU.js";
|
|
13
|
-
import "./chunk-G4ZAUHHA.js";
|
|
14
|
-
import "./chunk-63H5VXZY.js";
|
|
15
|
-
import "./chunk-ASZKAC24.js";
|
|
16
|
-
import {
|
|
17
|
-
output
|
|
18
|
-
} from "./chunk-6XLT25GS.js";
|
|
19
|
-
import "./chunk-WCODTMDN.js";
|
|
20
|
-
import "./chunk-GTCPZ22N.js";
|
|
21
|
-
import "./chunk-6MRZXASS.js";
|
|
22
|
-
import "./chunk-G3U4V32O.js";
|
|
23
|
-
import {
|
|
24
|
-
__toESM,
|
|
25
|
-
init_require_shim
|
|
26
|
-
} from "./chunk-TPK5AGRA.js";
|
|
27
|
-
|
|
28
|
-
// src/rune/commands/list.js
|
|
29
|
-
init_require_shim();
|
|
30
|
-
var import_cli_table3 = __toESM(require_cli_table3(), 1);
|
|
31
|
-
async function handler({
|
|
32
|
-
format = "md",
|
|
33
|
-
plain = false,
|
|
34
|
-
projectRoot = process.cwd(),
|
|
35
|
-
configRoot = projectRoot
|
|
36
|
-
} = {}) {
|
|
37
|
-
let config;
|
|
38
|
-
try {
|
|
39
|
-
config = loadConfig(configRoot);
|
|
40
|
-
} catch (err) {
|
|
41
|
-
output.error(`Config unreadable: ${err.message}`);
|
|
42
|
-
output.info("Run `crunes init` to create a config file.");
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
const runes = config.runes ?? {};
|
|
46
|
-
const keys = Object.keys(runes);
|
|
47
|
-
const entries = [];
|
|
48
|
-
for (const key of keys) {
|
|
49
|
-
const entry = getRune(config, key);
|
|
50
|
-
const source = entry.plugin ? `\u2192 ${entry.plugin}` : entry.path ?? "";
|
|
51
|
-
entries.push({ key, source, name: entry.name ?? null, description: entry.description ?? null });
|
|
52
|
-
}
|
|
53
|
-
const enabledPlugins = config.plugins ?? [];
|
|
54
|
-
if (enabledPlugins.length > 0) {
|
|
55
|
-
try {
|
|
56
|
-
const { loadRegistry } = await import("./registry-RG34DPD7.js");
|
|
57
|
-
const { loadPluginJson } = await import("./manifest-7RVNKBOH.js");
|
|
58
|
-
const registry = await loadRegistry();
|
|
59
|
-
for (const pluginKey of enabledPlugins) {
|
|
60
|
-
const entry = registry.plugins?.[pluginKey];
|
|
61
|
-
if (!entry) continue;
|
|
62
|
-
let pluginJson;
|
|
63
|
-
try {
|
|
64
|
-
pluginJson = await loadPluginJson(entry.path);
|
|
65
|
-
} catch {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
for (const [runeKey, runeEntry] of Object.entries(pluginJson.runes ?? {})) {
|
|
69
|
-
const idx = pluginKey.indexOf("@");
|
|
70
|
-
const shortName = idx !== -1 ? pluginKey.slice(idx + 1) : pluginKey;
|
|
71
|
-
const displayKey = `${shortName}:${runeKey}`;
|
|
72
|
-
if (!entries.some((e) => e.key === displayKey)) {
|
|
73
|
-
entries.push({
|
|
74
|
-
key: displayKey,
|
|
75
|
-
source: `plugin: ${pluginKey}`,
|
|
76
|
-
name: runeEntry.name ?? null,
|
|
77
|
-
description: runeEntry.description ?? null
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} catch (e) {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (entries.length === 0) {
|
|
86
|
-
process.stdout.write("No runes configured. Run `crunes create <key>` to add one.\n");
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (format === "json") {
|
|
90
|
-
process.stdout.write(JSON.stringify(entries, null, 2) + "\n");
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (plain) {
|
|
94
|
-
for (const { key, name, description, source } of entries) {
|
|
95
|
-
process.stdout.write(`${key} ${name ?? ""} ${description ?? ""} ${source}
|
|
96
|
-
`);
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const table = new import_cli_table3.default({
|
|
101
|
-
head: ["Key", "Name", "Description", "Source"],
|
|
102
|
-
style: { head: ["cyan"] }
|
|
103
|
-
});
|
|
104
|
-
for (const { key, name, description, source } of entries) {
|
|
105
|
-
table.push([key, name ?? "", description ?? "", source]);
|
|
106
|
-
}
|
|
107
|
-
process.stdout.write(table.toString() + "\n");
|
|
108
|
-
}
|
|
109
|
-
export {
|
|
110
|
-
handler
|
|
111
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getRune,
|
|
3
|
-
normaliseRune,
|
|
4
|
-
resolvePluginRune,
|
|
5
|
-
resolveRuneEntry,
|
|
6
|
-
resolveRuneFromPlugins,
|
|
7
|
-
runRune
|
|
8
|
-
} from "./chunk-WJRZN7BR.js";
|
|
9
|
-
import "./chunk-J3GZ3DXD.js";
|
|
10
|
-
import "./chunk-ZJDKCC2Y.js";
|
|
11
|
-
import "./chunk-NDEYEYSU.js";
|
|
12
|
-
import "./chunk-G4ZAUHHA.js";
|
|
13
|
-
import "./chunk-63H5VXZY.js";
|
|
14
|
-
import "./chunk-ASZKAC24.js";
|
|
15
|
-
import "./chunk-6XLT25GS.js";
|
|
16
|
-
import "./chunk-WCODTMDN.js";
|
|
17
|
-
import "./chunk-GTCPZ22N.js";
|
|
18
|
-
import "./chunk-6MRZXASS.js";
|
|
19
|
-
import "./chunk-G3U4V32O.js";
|
|
20
|
-
import "./chunk-TPK5AGRA.js";
|
|
21
|
-
export {
|
|
22
|
-
getRune,
|
|
23
|
-
normaliseRune,
|
|
24
|
-
resolvePluginRune,
|
|
25
|
-
resolveRuneEntry,
|
|
26
|
-
resolveRuneFromPlugins,
|
|
27
|
-
runRune
|
|
28
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handler,
|
|
3
|
-
parseBracketKey,
|
|
4
|
-
parseRunArgs,
|
|
5
|
-
parseSegment
|
|
6
|
-
} from "./chunk-BTIPUR5S.js";
|
|
7
|
-
import "./chunk-GSA432UC.js";
|
|
8
|
-
import "./chunk-WJRZN7BR.js";
|
|
9
|
-
import "./chunk-J3GZ3DXD.js";
|
|
10
|
-
import "./chunk-ZJDKCC2Y.js";
|
|
11
|
-
import "./chunk-NDEYEYSU.js";
|
|
12
|
-
import "./chunk-G4ZAUHHA.js";
|
|
13
|
-
import "./chunk-63H5VXZY.js";
|
|
14
|
-
import "./chunk-ASZKAC24.js";
|
|
15
|
-
import "./chunk-6XLT25GS.js";
|
|
16
|
-
import "./chunk-WCODTMDN.js";
|
|
17
|
-
import "./chunk-GTCPZ22N.js";
|
|
18
|
-
import "./chunk-6MRZXASS.js";
|
|
19
|
-
import "./chunk-G3U4V32O.js";
|
|
20
|
-
import "./chunk-TPK5AGRA.js";
|
|
21
|
-
export {
|
|
22
|
-
handler,
|
|
23
|
-
parseBracketKey,
|
|
24
|
-
parseRunArgs,
|
|
25
|
-
parseSegment
|
|
26
|
-
};
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadConfig
|
|
3
|
-
} from "./chunk-GSA432UC.js";
|
|
4
|
-
import {
|
|
5
|
-
computeEffectivePermissions,
|
|
6
|
-
getArgsSchema,
|
|
7
|
-
getPluginRunePath,
|
|
8
|
-
getReplSchema,
|
|
9
|
-
getRune,
|
|
10
|
-
resolvePluginRune,
|
|
11
|
-
resolveRuneFromPlugins
|
|
12
|
-
} from "./chunk-WJRZN7BR.js";
|
|
13
|
-
import "./chunk-J3GZ3DXD.js";
|
|
14
|
-
import "./chunk-ZJDKCC2Y.js";
|
|
15
|
-
import "./chunk-NDEYEYSU.js";
|
|
16
|
-
import "./chunk-G4ZAUHHA.js";
|
|
17
|
-
import "./chunk-63H5VXZY.js";
|
|
18
|
-
import {
|
|
19
|
-
formatHelp
|
|
20
|
-
} from "./chunk-ASZKAC24.js";
|
|
21
|
-
import {
|
|
22
|
-
output
|
|
23
|
-
} from "./chunk-6XLT25GS.js";
|
|
24
|
-
import "./chunk-WCODTMDN.js";
|
|
25
|
-
import "./chunk-GTCPZ22N.js";
|
|
26
|
-
import "./chunk-6MRZXASS.js";
|
|
27
|
-
import {
|
|
28
|
-
loadPluginJson
|
|
29
|
-
} from "./chunk-G3U4V32O.js";
|
|
30
|
-
import {
|
|
31
|
-
init_require_shim
|
|
32
|
-
} from "./chunk-TPK5AGRA.js";
|
|
33
|
-
|
|
34
|
-
// src/docs/commands/rune.js
|
|
35
|
-
init_require_shim();
|
|
36
|
-
import { join, relative } from "node:path";
|
|
37
|
-
var SUGGESTIONS = {
|
|
38
|
-
run: "crunes docs run",
|
|
39
|
-
args: "crunes docs args",
|
|
40
|
-
intro: "crunes docs intro",
|
|
41
|
-
utils: "crunes docs utils",
|
|
42
|
-
globals: "crunes docs globals"
|
|
43
|
-
};
|
|
44
|
-
function formatSlashCommands(commands, indent = "") {
|
|
45
|
-
const lines = [`${indent}REPL Slash Commands:`];
|
|
46
|
-
for (const cmd of commands) {
|
|
47
|
-
lines.push(`${indent} /${cmd.name.padEnd(12)} ${cmd.description ?? ""}`);
|
|
48
|
-
for (const pos of cmd.positionals ?? []) {
|
|
49
|
-
lines.push(`${indent} ${pos.spec.padEnd(14)} ${pos.description ?? ""}`);
|
|
50
|
-
}
|
|
51
|
-
for (const opt of cmd.options ?? []) {
|
|
52
|
-
lines.push(`${indent} ${opt.flags.padEnd(14)} ${opt.description ?? ""}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return lines.join("\n");
|
|
56
|
-
}
|
|
57
|
-
function formatBatch(batch) {
|
|
58
|
-
const lines = ["Batch:"];
|
|
59
|
-
if (!batch) {
|
|
60
|
-
lines.push(" (not permitted \u2014 no batch block declared)");
|
|
61
|
-
return lines.join("\n");
|
|
62
|
-
}
|
|
63
|
-
const allow = batch.allow ?? [];
|
|
64
|
-
const deny = batch.deny ?? [];
|
|
65
|
-
lines.push(` allow: ${allow.length ? allow.join(", ") : "(none)"}`);
|
|
66
|
-
if (deny.length) lines.push(` deny: ${deny.join(", ")}`);
|
|
67
|
-
return lines.join("\n");
|
|
68
|
-
}
|
|
69
|
-
async function handler({ keys, format = "text", projectRoot = process.cwd(), configRoot = projectRoot }) {
|
|
70
|
-
let config;
|
|
71
|
-
try {
|
|
72
|
-
config = loadConfig(configRoot);
|
|
73
|
-
} catch (err) {
|
|
74
|
-
output.error(`Config unreadable: ${err.message}`);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
const results = [];
|
|
78
|
-
let anyFailed = false;
|
|
79
|
-
for (const key of keys) {
|
|
80
|
-
let pluginMatch;
|
|
81
|
-
try {
|
|
82
|
-
pluginMatch = await resolvePluginRune(config, key);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
output.warn(err.message);
|
|
85
|
-
anyFailed = true;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const localEntry = pluginMatch ? null : getRune(config, key);
|
|
89
|
-
let autoMatch = null;
|
|
90
|
-
if (!pluginMatch && !localEntry) {
|
|
91
|
-
try {
|
|
92
|
-
autoMatch = await resolveRuneFromPlugins(config, key);
|
|
93
|
-
} catch (err) {
|
|
94
|
-
output.warn(err.message);
|
|
95
|
-
anyFailed = true;
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const resolved = pluginMatch ?? autoMatch;
|
|
100
|
-
if (!localEntry && !resolved) {
|
|
101
|
-
if (SUGGESTIONS[key]) {
|
|
102
|
-
output.warn(`Unknown rune: "${key}". (Tip: Did you mean "${SUGGESTIONS[key]}"?)`);
|
|
103
|
-
} else {
|
|
104
|
-
output.warn(`Unknown rune: "${key}"`);
|
|
105
|
-
}
|
|
106
|
-
anyFailed = true;
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
let runeFile, relativePath, basePerms, vars, displayName, displayDescription, batch;
|
|
110
|
-
if (resolved) {
|
|
111
|
-
const { runeKey, pluginDir } = resolved;
|
|
112
|
-
let pluginJson;
|
|
113
|
-
try {
|
|
114
|
-
pluginJson = await loadPluginJson(pluginDir);
|
|
115
|
-
} catch (err) {
|
|
116
|
-
output.warn(`Could not load plugin for "${key}": ${err.message}`);
|
|
117
|
-
anyFailed = true;
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
const runeDef = pluginJson.runes[runeKey] ?? {};
|
|
121
|
-
runeFile = getPluginRunePath(pluginDir, runeKey, pluginJson);
|
|
122
|
-
relativePath = void 0;
|
|
123
|
-
basePerms = runeDef.permissions ?? { allow: [], deny: [] };
|
|
124
|
-
vars = runeDef.vars ?? {};
|
|
125
|
-
displayName = runeDef.name ?? runeKey;
|
|
126
|
-
displayDescription = runeDef.description ?? null;
|
|
127
|
-
batch = runeDef.batch != null ? { allow: runeDef.batch.allow ?? [], deny: runeDef.batch.deny ?? [] } : null;
|
|
128
|
-
} else {
|
|
129
|
-
runeFile = join(configRoot, localEntry.path ?? `.crunes/runes/${key}.js`);
|
|
130
|
-
relativePath = relative(projectRoot, runeFile).replace(/\\/g, "/");
|
|
131
|
-
basePerms = localEntry.permissions ?? { allow: [], deny: [] };
|
|
132
|
-
vars = localEntry.vars ?? {};
|
|
133
|
-
displayName = localEntry.name ?? key;
|
|
134
|
-
displayDescription = localEntry.description ?? null;
|
|
135
|
-
batch = localEntry.batch != null ? { allow: localEntry.batch.allow ?? [], deny: localEntry.batch.deny ?? [] } : null;
|
|
136
|
-
}
|
|
137
|
-
const runEffective = computeEffectivePermissions(basePerms, void 0, "run");
|
|
138
|
-
const replEffective = computeEffectivePermissions(basePerms, void 0, "repl");
|
|
139
|
-
let schema = null;
|
|
140
|
-
try {
|
|
141
|
-
schema = await getArgsSchema(runeFile, runEffective, projectRoot, { vars, runeKey: key });
|
|
142
|
-
} catch (err) {
|
|
143
|
-
output.warn(`Could not load args schema for "${key}": ${err.message}`);
|
|
144
|
-
}
|
|
145
|
-
let repl = null;
|
|
146
|
-
try {
|
|
147
|
-
const { argsSchema, commandsSchema } = await getReplSchema(runeFile, replEffective, [], projectRoot, { vars, runeKey: key });
|
|
148
|
-
if (argsSchema !== null || commandsSchema !== null) {
|
|
149
|
-
repl = { argsSchema, commandsSchema };
|
|
150
|
-
}
|
|
151
|
-
} catch (err) {
|
|
152
|
-
output.warn(`Could not load REPL schema for "${key}": ${err.message}`);
|
|
153
|
-
}
|
|
154
|
-
results.push({
|
|
155
|
-
key,
|
|
156
|
-
name: displayName,
|
|
157
|
-
description: displayDescription,
|
|
158
|
-
relativePath,
|
|
159
|
-
schema,
|
|
160
|
-
repl,
|
|
161
|
-
batch
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
if (format === "json") {
|
|
165
|
-
process.stdout.write(JSON.stringify(results, null, 2) + "\n");
|
|
166
|
-
} else {
|
|
167
|
-
const blocks = [];
|
|
168
|
-
for (const r of results) {
|
|
169
|
-
const parts = [];
|
|
170
|
-
parts.push(formatHelp(r.schema, { key: r.key, name: r.name, description: r.description, relativePath: r.relativePath }));
|
|
171
|
-
if (r.repl?.argsSchema) {
|
|
172
|
-
parts.push(formatHelp(r.repl.argsSchema, { key: r.key, name: r.name, description: r.description, relativePath: r.relativePath, lifecycle: "repl" }));
|
|
173
|
-
}
|
|
174
|
-
if (r.repl?.commandsSchema?.commands?.length) {
|
|
175
|
-
parts.push(formatSlashCommands(r.repl.commandsSchema.commands));
|
|
176
|
-
}
|
|
177
|
-
parts.push(formatBatch(r.batch));
|
|
178
|
-
blocks.push(parts.join("\n\n"));
|
|
179
|
-
}
|
|
180
|
-
if (blocks.length > 0) process.stdout.write(blocks.join("\n\n") + "\n");
|
|
181
|
-
}
|
|
182
|
-
if (anyFailed) process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
export {
|
|
185
|
-
handler
|
|
186
|
-
};
|