@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getStorePath
|
|
3
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_require_shim
|
|
6
|
+
} from "./chunk-TPK5AGRA.js";
|
|
7
|
+
|
|
8
|
+
// src/core/config.js
|
|
9
|
+
init_require_shim();
|
|
10
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
function isObject(item) {
|
|
13
|
+
return item && typeof item === "object" && !Array.isArray(item);
|
|
14
|
+
}
|
|
15
|
+
var LAYER = /* @__PURE__ */ Symbol.for("crunes.layer");
|
|
16
|
+
function absolutizeSection(section, kind, baseDir, layer) {
|
|
17
|
+
const out = {};
|
|
18
|
+
for (const [key, entry] of Object.entries(section)) {
|
|
19
|
+
if (!isObject(entry)) {
|
|
20
|
+
out[key] = entry;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const copy = { ...entry, [LAYER]: layer };
|
|
24
|
+
const isPluginRef = Boolean(entry.plugin) || key.includes(":");
|
|
25
|
+
if (entry.path) copy.path = resolve(baseDir, entry.path);
|
|
26
|
+
else if (layer === "global" && !isPluginRef) copy.path = resolve(baseDir, `${kind}/${key}.js`);
|
|
27
|
+
out[key] = copy;
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
function absolutizeEntryPaths(config, baseDir, layer) {
|
|
32
|
+
const out = { ...config };
|
|
33
|
+
if (isObject(config.runes)) out.runes = absolutizeSection(config.runes, "runes", baseDir, layer);
|
|
34
|
+
if (isObject(config.templates)) out.templates = absolutizeSection(config.templates, "templates", baseDir, layer);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function coercePlugins(plugins) {
|
|
38
|
+
if (Array.isArray(plugins)) return Object.fromEntries(plugins.map((k) => [k, true]));
|
|
39
|
+
return isObject(plugins) ? { ...plugins } : {};
|
|
40
|
+
}
|
|
41
|
+
function enabledPluginKeys(config) {
|
|
42
|
+
return Object.entries(coercePlugins(config?.plugins)).filter(([, enabled]) => enabled === true).map(([key]) => key);
|
|
43
|
+
}
|
|
44
|
+
function mergeConfigs(shared, local) {
|
|
45
|
+
const merged = { ...shared };
|
|
46
|
+
for (const [key, value] of Object.entries(local)) {
|
|
47
|
+
if (key !== "runes" && key !== "templates" && key !== "plugins") {
|
|
48
|
+
merged[key] = value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (local.runes) {
|
|
52
|
+
merged.runes = { ...shared.runes };
|
|
53
|
+
for (const [key, localEntry] of Object.entries(local.runes)) {
|
|
54
|
+
const sharedEntry = shared.runes?.[key];
|
|
55
|
+
if (sharedEntry && isObject(sharedEntry) && isObject(localEntry)) {
|
|
56
|
+
merged.runes[key] = {
|
|
57
|
+
...sharedEntry,
|
|
58
|
+
...localEntry,
|
|
59
|
+
vars: { ...sharedEntry.vars, ...localEntry.vars }
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
merged.runes[key] = localEntry;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (local.templates) {
|
|
67
|
+
merged.templates = { ...shared.templates };
|
|
68
|
+
for (const [key, localEntry] of Object.entries(local.templates)) {
|
|
69
|
+
const sharedEntry = shared.templates?.[key];
|
|
70
|
+
merged.templates[key] = isObject(sharedEntry) && isObject(localEntry) ? { ...sharedEntry, ...localEntry } : localEntry;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (shared.plugins || local.plugins) {
|
|
74
|
+
merged.plugins = { ...coercePlugins(shared.plugins), ...coercePlugins(local.plugins) };
|
|
75
|
+
}
|
|
76
|
+
return merged;
|
|
77
|
+
}
|
|
78
|
+
function validateConfig(config, fileName = "config.json") {
|
|
79
|
+
if (config.runes && typeof config.runes === "object") {
|
|
80
|
+
for (const [runeKey, entry] of Object.entries(config.runes)) {
|
|
81
|
+
if (entry && typeof entry === "object" && entry.permissions) {
|
|
82
|
+
const perms = entry.permissions;
|
|
83
|
+
if (Array.isArray(perms)) {
|
|
84
|
+
throw new Error(`${fileName}: runes["${runeKey}"].permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
|
|
85
|
+
}
|
|
86
|
+
if (perms && typeof perms === "object") {
|
|
87
|
+
if (Array.isArray(perms.allow) || Array.isArray(perms.deny)) {
|
|
88
|
+
throw new Error(`${fileName}: runes["${runeKey}"].permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
|
|
89
|
+
}
|
|
90
|
+
if (perms.run && typeof perms.run === "object" && Object.keys(perms.run).length === 0) {
|
|
91
|
+
console.warn(`[crunes:warn] ${fileName}: runes["${runeKey}"].permissions.run is empty. No extra permissions will be granted.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (entry && typeof entry === "object" && !entry.path && !entry.plugin) {
|
|
96
|
+
const colonIdx = runeKey.indexOf(":");
|
|
97
|
+
if (colonIdx !== -1) {
|
|
98
|
+
const pluginPart = runeKey.slice(0, colonIdx);
|
|
99
|
+
if (!pluginPart.includes("@")) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`${fileName}: runes["${runeKey}"] has no path or plugin, so it can only be a plugin-rune override \u2014 but "${pluginPart}" is missing the marketplace prefix. Use the full "marketplace@plugin:${runeKey.slice(colonIdx + 1)}" form.`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (config.plugins && !Array.isArray(config.plugins) && typeof config.plugins === "object") {
|
|
109
|
+
for (const [key, value] of Object.entries(config.plugins)) {
|
|
110
|
+
if (typeof value !== "boolean") {
|
|
111
|
+
throw new Error(`${fileName}: plugins["${key}"] must be true or false, got ${JSON.stringify(value)}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
var ROOTLESS = /* @__PURE__ */ Symbol.for("crunes.rootless");
|
|
117
|
+
function readLayer(filePath, label) {
|
|
118
|
+
if (!existsSync(filePath)) return null;
|
|
119
|
+
let parsed;
|
|
120
|
+
try {
|
|
121
|
+
parsed = JSON.parse(readFileSync(filePath, "utf8"));
|
|
122
|
+
} catch (err) {
|
|
123
|
+
throw new Error(`${label} is invalid JSON: ${err.message}`);
|
|
124
|
+
}
|
|
125
|
+
validateConfig(parsed, label);
|
|
126
|
+
return parsed;
|
|
127
|
+
}
|
|
128
|
+
function loadConfig(dir) {
|
|
129
|
+
const layers = [];
|
|
130
|
+
if (process.env.CRUNES_NO_GLOBAL !== "1") {
|
|
131
|
+
const storeRoot = getStorePath();
|
|
132
|
+
const globalPath = join(storeRoot, "config.json");
|
|
133
|
+
const globalRaw = readLayer(globalPath, globalPath);
|
|
134
|
+
if (globalRaw) layers.push(absolutizeEntryPaths(globalRaw, storeRoot, "global"));
|
|
135
|
+
}
|
|
136
|
+
const sharedRaw = readLayer(join(dir, ".crunes", "config.json"), "config.json");
|
|
137
|
+
const rootless = sharedRaw === null;
|
|
138
|
+
if (sharedRaw) {
|
|
139
|
+
layers.push(absolutizeEntryPaths(sharedRaw, dir, "project"));
|
|
140
|
+
const localRaw = readLayer(join(dir, ".crunes", "config.local.json"), "config.local.json");
|
|
141
|
+
if (localRaw) layers.push(absolutizeEntryPaths(localRaw, dir, "local"));
|
|
142
|
+
}
|
|
143
|
+
const merged = layers.reduce((acc, layer) => mergeConfigs(acc, layer), {});
|
|
144
|
+
merged[ROOTLESS] = rootless;
|
|
145
|
+
return merged;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
LAYER,
|
|
150
|
+
coercePlugins,
|
|
151
|
+
enabledPluginKeys,
|
|
152
|
+
ROOTLESS,
|
|
153
|
+
loadConfig
|
|
154
|
+
};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
describeConfigLayers,
|
|
3
|
+
runRune
|
|
4
|
+
} from "./chunk-YXCHIMLW.js";
|
|
4
5
|
import {
|
|
5
6
|
isGlobMatch,
|
|
6
|
-
isWildcardMatch
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
isWildcardMatch
|
|
8
|
+
} from "./chunk-CY6C6ADU.js";
|
|
9
|
+
import {
|
|
10
|
+
loadConfig
|
|
11
|
+
} from "./chunk-QYRF3R35.js";
|
|
9
12
|
import {
|
|
10
13
|
isVerbose,
|
|
11
14
|
output
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MIKWIFYR.js";
|
|
13
16
|
import {
|
|
14
17
|
init_require_shim
|
|
15
18
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -17,6 +20,44 @@ import {
|
|
|
17
20
|
// src/rune/commands/run.js
|
|
18
21
|
init_require_shim();
|
|
19
22
|
|
|
23
|
+
// src/rune/commands/denial-hint.js
|
|
24
|
+
init_require_shim();
|
|
25
|
+
var UNGRANTED = /^'([a-z]+(?:\.[a-z]+)*):([\s\S]*)' is not permitted\.$/;
|
|
26
|
+
var UNSCANNABLE = /^Cannot scan command: /;
|
|
27
|
+
function permissionHint(message, { key, lifecycle = "run", configLayers }) {
|
|
28
|
+
const text = String(message ?? "").trim();
|
|
29
|
+
if (UNSCANNABLE.test(text)) {
|
|
30
|
+
return [
|
|
31
|
+
"",
|
|
32
|
+
" This construct cannot be split into command positions, so it cannot be permission-checked.",
|
|
33
|
+
" No grant overrides this \u2014 rewrite the command as plain invocations, or move the logic into",
|
|
34
|
+
" the rune and call the programs directly."
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
const m = UNGRANTED.exec(text);
|
|
38
|
+
if (!m) return null;
|
|
39
|
+
const [, capability, value] = m;
|
|
40
|
+
const token = `${capability}:${value}`;
|
|
41
|
+
const lines = [
|
|
42
|
+
"",
|
|
43
|
+
` Add the grant to the rune's entry in the config that declares it:`,
|
|
44
|
+
"",
|
|
45
|
+
` "runes": { "${key}": { "permissions": { "${lifecycle}": { "allow": ["${token}"] } } } }`,
|
|
46
|
+
"",
|
|
47
|
+
` Looked in: ${configLayers}.`
|
|
48
|
+
];
|
|
49
|
+
if (capability === "shell.run") {
|
|
50
|
+
lines.push(` Every command in a pipeline needs its own grant \u2014 \`crunes shell explain '<command>'\` lists them.`);
|
|
51
|
+
}
|
|
52
|
+
if (capability === "fs.glob") {
|
|
53
|
+
lines.push(` fs.glob grants match the pattern string exactly; only \`fs.glob:*\` is a wildcard.`);
|
|
54
|
+
}
|
|
55
|
+
if (lifecycle === "repl") {
|
|
56
|
+
lines.push(` "repl" grants are separate from "run" \u2014 neither inherits from the other.`);
|
|
57
|
+
}
|
|
58
|
+
return lines.join("\n");
|
|
59
|
+
}
|
|
60
|
+
|
|
20
61
|
// src/shared/render.js
|
|
21
62
|
init_require_shim();
|
|
22
63
|
function render(data) {
|
|
@@ -99,8 +140,16 @@ function parseBracketKey(token) {
|
|
|
99
140
|
const bracketArgs = inner.trim() ? inner.trim().split(/\s+/) : [];
|
|
100
141
|
return { key: key || null, bracketArgs };
|
|
101
142
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
143
|
+
function joinBracketTokens(argv) {
|
|
144
|
+
const first = argv[0];
|
|
145
|
+
if (!first || !first.includes("[") || first.includes("]")) return argv;
|
|
146
|
+
const end = argv.findIndex((tok, i) => i > 0 && tok.includes("]"));
|
|
147
|
+
if (end === -1) return argv;
|
|
148
|
+
return [argv.slice(0, end + 1).join(" "), ...argv.slice(end + 1)];
|
|
149
|
+
}
|
|
150
|
+
function parseSegment(rawArgv) {
|
|
151
|
+
if (!rawArgv.length) return { key: null, sections: null, runeArgs: [] };
|
|
152
|
+
const argv = joinBracketTokens(rawArgv);
|
|
104
153
|
const { key, bracketArgs } = parseBracketKey(argv[0]);
|
|
105
154
|
if (key && key.startsWith("-")) {
|
|
106
155
|
output.error(`Unknown option or misplaced flag: "${key}"`);
|
|
@@ -195,7 +244,7 @@ async function handler({
|
|
|
195
244
|
process.exit(1);
|
|
196
245
|
}
|
|
197
246
|
if (isBatch) {
|
|
198
|
-
const { resolvePluginRune } = await import("./resolver-
|
|
247
|
+
const { resolvePluginRune } = await import("./resolver-QIYYFIDX.js");
|
|
199
248
|
const { loadPluginJson } = await import("./manifest-7RVNKBOH.js");
|
|
200
249
|
for (const seg of segments) {
|
|
201
250
|
let entry = config.runes?.[seg.key] ?? {};
|
|
@@ -214,7 +263,17 @@ async function handler({
|
|
|
214
263
|
const matchString = buildMatchString(seg.key, seg.runeArgs);
|
|
215
264
|
const result = checkBatchPermission(entry, matchString);
|
|
216
265
|
if (!result.allowed) {
|
|
217
|
-
|
|
266
|
+
const spaceIdx = matchString.indexOf(" ");
|
|
267
|
+
const subject = spaceIdx === -1 ? matchString : matchString.slice(spaceIdx + 1);
|
|
268
|
+
const lines = [`Batch not permitted for "${matchString}" \u2014 ${result.reason}.`, ""];
|
|
269
|
+
lines.push(` "batch" is a sibling of "permissions" on the rune entry, not inside it:`);
|
|
270
|
+
lines.push("");
|
|
271
|
+
lines.push(` "runes": { "${seg.key}": { "batch": { "allow": ["${subject}"] } } }`);
|
|
272
|
+
lines.push("");
|
|
273
|
+
lines.push(` Patterns match the rune's arguments \u2014 here "${subject}" \u2014 or its bare key when it is`);
|
|
274
|
+
lines.push(` invoked with none. Edit the config that declares this rune: ${describeConfigLayers(configRoot ?? projectRoot)}.`);
|
|
275
|
+
lines.push(` Or drop -b and run the segments separately.`);
|
|
276
|
+
output.error(lines.join("\n"));
|
|
218
277
|
process.exit(1);
|
|
219
278
|
}
|
|
220
279
|
}
|
|
@@ -285,15 +344,20 @@ ${message}
|
|
|
285
344
|
if (isVerbose) console.error(`[crunes:debug] Rune "${key}" completed with ${sections?.length ?? 0} sections`);
|
|
286
345
|
} catch (err) {
|
|
287
346
|
const msg = isVerbose ? err.stack || err.message : err.message;
|
|
347
|
+
const hint = permissionHint(err.message, {
|
|
348
|
+
key,
|
|
349
|
+
lifecycle: "run",
|
|
350
|
+
configLayers: describeConfigLayers(configRoot ?? projectRoot)
|
|
351
|
+
});
|
|
288
352
|
output.error(`Rune "${key}" failed:
|
|
289
|
-
${msg}`);
|
|
353
|
+
${msg}${hint ?? ""}`);
|
|
290
354
|
anyFailed = true;
|
|
291
355
|
if (failFast) process.exit(1);
|
|
292
356
|
continue;
|
|
293
357
|
}
|
|
294
358
|
if (!sections) {
|
|
295
359
|
const available = Object.keys(config.runes ?? {}).join(", ") || "(none)";
|
|
296
|
-
output.error(`Unknown key: "${key}". Available: ${available}
|
|
360
|
+
output.error(`Unknown key: "${key}". Available: ${available}. Looked in: ${describeConfigLayers(configRoot ?? projectRoot)}.`);
|
|
297
361
|
anyFailed = true;
|
|
298
362
|
if (failFast) process.exit(1);
|
|
299
363
|
continue;
|
|
@@ -336,8 +400,10 @@ ${content}
|
|
|
336
400
|
}
|
|
337
401
|
|
|
338
402
|
export {
|
|
403
|
+
permissionHint,
|
|
339
404
|
formatSection,
|
|
340
405
|
parseBracketKey,
|
|
406
|
+
joinBracketTokens,
|
|
341
407
|
parseSegment,
|
|
342
408
|
parseRunArgs,
|
|
343
409
|
handler
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLocalBase
|
|
3
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
1
4
|
import {
|
|
2
5
|
init_require_shim
|
|
3
6
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -12,7 +15,7 @@ function safeKey(runeKey) {
|
|
|
12
15
|
return runeKey.replace(/:/g, "__");
|
|
13
16
|
}
|
|
14
17
|
function schemasDir(projectDir) {
|
|
15
|
-
return join(projectDir, "
|
|
18
|
+
return join(getLocalBase(projectDir), "schemas");
|
|
16
19
|
}
|
|
17
20
|
function cacheFilePath(runeKey, type, projectDir) {
|
|
18
21
|
return join(schemasDir(projectDir), `${safeKey(runeKey)}-${type}.json`);
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-G4ZAUHHA.js";
|
|
4
4
|
import {
|
|
5
5
|
getCacheBasePath,
|
|
6
|
-
getCacheJsonPath
|
|
7
|
-
|
|
6
|
+
getCacheJsonPath,
|
|
7
|
+
getLocalBase
|
|
8
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
8
9
|
import {
|
|
9
10
|
init_require_shim
|
|
10
11
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -30,7 +31,7 @@ async function listCacheBuckets() {
|
|
|
30
31
|
}
|
|
31
32
|
async function listLocalCacheBuckets(projectDir) {
|
|
32
33
|
const results = [];
|
|
33
|
-
const localCacheDir = path.join(projectDir, "
|
|
34
|
+
const localCacheDir = path.join(getLocalBase(projectDir), "caches");
|
|
34
35
|
async function scanScope(scopeDir, scope, pluginId = null) {
|
|
35
36
|
let entries;
|
|
36
37
|
try {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
coercePlugins
|
|
3
|
+
} from "./chunk-QYRF3R35.js";
|
|
4
|
+
import {
|
|
5
|
+
getStorePath
|
|
6
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
7
|
+
import {
|
|
8
|
+
init_require_shim
|
|
9
|
+
} from "./chunk-TPK5AGRA.js";
|
|
10
|
+
|
|
11
|
+
// src/core/config-writer.js
|
|
12
|
+
init_require_shim();
|
|
13
|
+
import fs from "node:fs/promises";
|
|
14
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
function getConfigPath({ configRoot, global = false } = {}) {
|
|
17
|
+
if (global) return path.join(getStorePath(), "config.json");
|
|
18
|
+
return path.join(configRoot, ".crunes", "config.json");
|
|
19
|
+
}
|
|
20
|
+
function readRawConfig(configPath) {
|
|
21
|
+
if (!existsSync(configPath)) return null;
|
|
22
|
+
return JSON.parse(readFileSync(configPath, "utf8"));
|
|
23
|
+
}
|
|
24
|
+
async function writeRawConfig(configPath, config) {
|
|
25
|
+
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
|
26
|
+
const tmp = `${configPath}.${Date.now()}${Math.random().toString(36).slice(2)}.tmp`;
|
|
27
|
+
await fs.writeFile(tmp, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
28
|
+
await fs.rename(tmp, configPath);
|
|
29
|
+
}
|
|
30
|
+
async function setPluginEnabled(configPath, pluginKey, enabled) {
|
|
31
|
+
const config = readRawConfig(configPath);
|
|
32
|
+
if (config === null) {
|
|
33
|
+
throw new Error(`No config found at ${configPath}. Run: crunes init (or crunes init -g for the global config)`);
|
|
34
|
+
}
|
|
35
|
+
config.plugins = { ...coercePlugins(config.plugins), [pluginKey]: enabled };
|
|
36
|
+
await writeRawConfig(configPath, config);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
getConfigPath,
|
|
41
|
+
readRawConfig,
|
|
42
|
+
writeRawConfig,
|
|
43
|
+
setPluginEnabled
|
|
44
|
+
};
|