@darkrymit/crunes-cli 0.5.10 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/chunks/add-OWYVF3IE.js +22 -0
- package/dist/chunks/apply-OMEVXCHC.js +183 -0
- package/dist/chunks/args-32BVYW77.js +42 -0
- package/dist/chunks/benchmark-CLUBISCR.js +164 -0
- package/dist/chunks/browse-COH6IJEX.js +34 -0
- package/dist/chunks/check-BS6TZGRR.js +144 -0
- package/dist/chunks/chunk-2Q24YPGL.js +369 -0
- package/dist/chunks/chunk-3TM6B4E5.js +70 -0
- package/dist/chunks/chunk-67I2J474.js +153 -0
- package/dist/chunks/chunk-6XLT25GS.js +50 -0
- package/dist/chunks/chunk-BVY5LN7X.js +25091 -0
- package/dist/chunks/chunk-CGZL5SSH.js +926 -0
- package/dist/chunks/chunk-DMMC4X27.js +1836 -0
- package/dist/chunks/chunk-G3U4V32O.js +46 -0
- package/dist/chunks/chunk-GHQOK4L7.js +59 -0
- package/dist/chunks/chunk-H3BVJCIL.js +105 -0
- package/dist/chunks/chunk-HMU2J25D.js +63 -0
- package/dist/chunks/chunk-HOH7WZX4.js +95 -0
- package/dist/chunks/chunk-L72BG6DS.js +225 -0
- package/dist/chunks/chunk-NXSDVVTW.js +181 -0
- package/dist/chunks/chunk-QLDB3FO2.js +73059 -0
- package/dist/chunks/chunk-QMWGQXEZ.js +26 -0
- package/dist/chunks/chunk-TPK5AGRA.js +54 -0
- package/dist/chunks/chunk-UGN3FFEF.js +8379 -0
- package/dist/chunks/chunk-WCODTMDN.js +508 -0
- package/dist/chunks/chunk-XIXND2M4.js +296 -0
- package/dist/chunks/chunk-XXUNHQIB.js +129 -0
- package/dist/chunks/chunk-ZXIP4Z5V.js +281 -0
- package/dist/chunks/clear-Y5POLIMF.js +32 -0
- package/dist/chunks/completions-2MSEWWTG.js +232 -0
- package/dist/chunks/create-5FXQYCGM.js +165 -0
- package/dist/chunks/create-I6BNYZ5Q.js +247 -0
- package/dist/chunks/create-O3HMODSL.js +130 -0
- package/dist/chunks/delete-7CQFYIXS.js +40 -0
- package/dist/chunks/delete-UB5SXO5I.js +40 -0
- package/dist/chunks/disable-FCBW7WVG.js +47 -0
- package/dist/chunks/doctor-DS57HDLJ.js +53 -0
- package/dist/chunks/enable-IXRVUXJM.js +47 -0
- package/dist/chunks/esm-7MEWZCHY.js +5162 -0
- package/dist/chunks/globals-YCJ2DGWC.js +60 -0
- package/dist/chunks/init-WGKQVAZE.js +59 -0
- package/dist/chunks/install-BCTBOPBS.js +57 -0
- package/dist/chunks/intro-2UDWF6D4.js +1482 -0
- package/dist/chunks/kill-LWRXZVM5.js +37 -0
- package/dist/chunks/list-5DVVP7HX.js +50 -0
- package/dist/chunks/list-6WL5LGIZ.js +80 -0
- package/dist/chunks/list-NGOCMJXE.js +104 -0
- package/dist/chunks/list-TTKLNJKI.js +28 -0
- package/dist/chunks/list-WUAOSO3M.js +110 -0
- package/dist/chunks/list-YPI7YDKK.js +80 -0
- package/dist/chunks/list-ZBYPMUID.js +23 -0
- package/dist/chunks/manifest-7RVNKBOH.js +9 -0
- package/dist/chunks/output-RJ6JSNY7.js +12 -0
- package/dist/chunks/promise-DUSIQMA2.js +19400 -0
- package/dist/chunks/query-NY4SCO77.js +41 -0
- package/dist/chunks/registry-W5XFI5T6.js +16 -0
- package/dist/chunks/remove-WEAZFZCO.js +22 -0
- package/dist/chunks/run-I6TZX347.js +23 -0
- package/dist/chunks/run-MVIZQVJ6.js +36 -0
- package/dist/chunks/rune-TAX26NH2.js +76 -0
- package/dist/chunks/search-XENXL3GC.js +25 -0
- package/dist/chunks/uninstall-MX5PLGDI.js +49 -0
- package/dist/chunks/unset-KQOZYVTE.js +28 -0
- package/dist/chunks/update-7XDTVFZ3.js +39 -0
- package/dist/chunks/update-IEE54GPY.js +79 -0
- package/dist/chunks/utils-PO3ZK53L.js +50 -0
- package/dist/chunks/version-DIEA5FVV.js +145 -0
- package/dist/cli.js +3360 -125840
- package/package.json +23 -15
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
querySqliteDb
|
|
3
|
+
} from "./chunk-67I2J474.js";
|
|
4
|
+
import "./chunk-QMWGQXEZ.js";
|
|
5
|
+
import {
|
|
6
|
+
ensureProjectIdentity
|
|
7
|
+
} from "./chunk-3TM6B4E5.js";
|
|
8
|
+
import "./chunk-HMU2J25D.js";
|
|
9
|
+
import {
|
|
10
|
+
init_require_shim
|
|
11
|
+
} from "./chunk-TPK5AGRA.js";
|
|
12
|
+
|
|
13
|
+
// src/sqlite/commands/query.js
|
|
14
|
+
init_require_shim();
|
|
15
|
+
function pad(s, n) {
|
|
16
|
+
return String(s ?? "").padEnd(n);
|
|
17
|
+
}
|
|
18
|
+
async function handler({ id, sql, projectDir, global: isGlobal }) {
|
|
19
|
+
const key = isGlobal ? void 0 : (await ensureProjectIdentity(projectDir)).id;
|
|
20
|
+
let rows;
|
|
21
|
+
try {
|
|
22
|
+
rows = await querySqliteDb(id, sql, key);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(`Error: ${err.message}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
if (rows.length === 0) {
|
|
28
|
+
console.log("No rows.");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const cols = Object.keys(rows[0]);
|
|
32
|
+
const widths = cols.map((c) => Math.max(c.length, ...rows.map((r) => String(r[c] ?? "").length)));
|
|
33
|
+
console.log(cols.map((c, i) => pad(c, widths[i])).join(" "));
|
|
34
|
+
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
console.log(cols.map((c, i) => pad(row[c], widths[i])).join(" "));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
handler
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadRegistry,
|
|
3
|
+
registerPlugin,
|
|
4
|
+
removePlugin,
|
|
5
|
+
resolvePluginKey,
|
|
6
|
+
saveRegistry
|
|
7
|
+
} from "./chunk-GHQOK4L7.js";
|
|
8
|
+
import "./chunk-HMU2J25D.js";
|
|
9
|
+
import "./chunk-TPK5AGRA.js";
|
|
10
|
+
export {
|
|
11
|
+
loadRegistry,
|
|
12
|
+
registerPlugin,
|
|
13
|
+
removePlugin,
|
|
14
|
+
resolvePluginKey,
|
|
15
|
+
saveRegistry
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
removeMarketplace
|
|
3
|
+
} from "./chunk-L72BG6DS.js";
|
|
4
|
+
import "./chunk-HMU2J25D.js";
|
|
5
|
+
import {
|
|
6
|
+
init_require_shim
|
|
7
|
+
} from "./chunk-TPK5AGRA.js";
|
|
8
|
+
|
|
9
|
+
// src/marketplace/commands/remove.js
|
|
10
|
+
init_require_shim();
|
|
11
|
+
async function handler({ url }) {
|
|
12
|
+
try {
|
|
13
|
+
await removeMarketplace(url);
|
|
14
|
+
console.log(`Marketplace "${url}" removed.`);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error(`Error: ${err.message}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
handler
|
|
22
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handler,
|
|
3
|
+
parseRunArgs,
|
|
4
|
+
parseSegment
|
|
5
|
+
} from "./chunk-ZXIP4Z5V.js";
|
|
6
|
+
import "./chunk-QLDB3FO2.js";
|
|
7
|
+
import "./chunk-67I2J474.js";
|
|
8
|
+
import "./chunk-XXUNHQIB.js";
|
|
9
|
+
import "./chunk-NXSDVVTW.js";
|
|
10
|
+
import "./chunk-QMWGQXEZ.js";
|
|
11
|
+
import "./chunk-3TM6B4E5.js";
|
|
12
|
+
import "./chunk-H3BVJCIL.js";
|
|
13
|
+
import "./chunk-6XLT25GS.js";
|
|
14
|
+
import "./chunk-WCODTMDN.js";
|
|
15
|
+
import "./chunk-GHQOK4L7.js";
|
|
16
|
+
import "./chunk-HMU2J25D.js";
|
|
17
|
+
import "./chunk-G3U4V32O.js";
|
|
18
|
+
import "./chunk-TPK5AGRA.js";
|
|
19
|
+
export {
|
|
20
|
+
handler,
|
|
21
|
+
parseRunArgs,
|
|
22
|
+
parseSegment
|
|
23
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_require_shim
|
|
3
|
+
} from "./chunk-TPK5AGRA.js";
|
|
4
|
+
|
|
5
|
+
// src/docs/commands/run.js
|
|
6
|
+
init_require_shim();
|
|
7
|
+
async function handler() {
|
|
8
|
+
process.stdout.write(`# Docs: The run(args) Export
|
|
9
|
+
|
|
10
|
+
The entrypoint \`export async function run(args)\` executes the rune's main script lifecycle, receiving a parsed, type-coerced arguments object.
|
|
11
|
+
|
|
12
|
+
## 1. Parsed Arguments Structure
|
|
13
|
+
|
|
14
|
+
Inside \`run(args)\`, the \`args\` parameter contains:
|
|
15
|
+
- **\`args.$command\`** *(string)*: The full, space-separated matched command path (e.g. \`"remote add"\`).
|
|
16
|
+
- **\`args.$commands\`** *(string[])*: The array of matched command levels (e.g. \`["remote", "add"]\`).
|
|
17
|
+
- **\`args._\`** *(string[])*: Data positionals only \u2014 command tokens are stripped, so \`args._[0]\` is always the first user-supplied value after the matched command.
|
|
18
|
+
- **\`args.$raw\`** *(string[])*: The exact raw string array before parsing.
|
|
19
|
+
- **Named Options**: Values parsed from option flags (e.g., \`args.verbose\`).
|
|
20
|
+
|
|
21
|
+
## 2. Named Positional Mapping
|
|
22
|
+
Positional parameters defined in \`args(builder)\` are **automatically mapped** to their named keys:
|
|
23
|
+
- **Root Level**: If you define \`.positional('<who>', ...)\` and run \`crunes run greeting "Alice"\`, you can access \`args.who\` directly!
|
|
24
|
+
- **Subcommands**: If you define \`remote add <name> <url>\`, after matching \`remote add\` the parser maps \`args.name\` and \`args.url\` from the remaining data positionals.
|
|
25
|
+
|
|
26
|
+
## 3. Strict 3-Tier Parsing Boundary
|
|
27
|
+
1. **Global Flags**: Scoped to the process prefix (e.g. \`crunes --cwd ./project\`).
|
|
28
|
+
2. **Command Flags**: Scoped to the command (e.g. \`run --format json\`).
|
|
29
|
+
3. **Rune Arguments**: Scoped after the rune key (e.g. \`myrune remote add origin --verbose\`).
|
|
30
|
+
Placing global or command flags after the rune key will cause them to be passed as raw rune arguments!
|
|
31
|
+
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
handler
|
|
36
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatHelp
|
|
3
|
+
} from "./chunk-HOH7WZX4.js";
|
|
4
|
+
import {
|
|
5
|
+
computeEffectivePermissions,
|
|
6
|
+
getArgsSchema,
|
|
7
|
+
getRune
|
|
8
|
+
} from "./chunk-QLDB3FO2.js";
|
|
9
|
+
import "./chunk-67I2J474.js";
|
|
10
|
+
import "./chunk-XXUNHQIB.js";
|
|
11
|
+
import "./chunk-NXSDVVTW.js";
|
|
12
|
+
import "./chunk-QMWGQXEZ.js";
|
|
13
|
+
import "./chunk-3TM6B4E5.js";
|
|
14
|
+
import {
|
|
15
|
+
loadConfig
|
|
16
|
+
} from "./chunk-H3BVJCIL.js";
|
|
17
|
+
import {
|
|
18
|
+
output
|
|
19
|
+
} from "./chunk-6XLT25GS.js";
|
|
20
|
+
import "./chunk-WCODTMDN.js";
|
|
21
|
+
import "./chunk-GHQOK4L7.js";
|
|
22
|
+
import "./chunk-HMU2J25D.js";
|
|
23
|
+
import "./chunk-G3U4V32O.js";
|
|
24
|
+
import {
|
|
25
|
+
init_require_shim
|
|
26
|
+
} from "./chunk-TPK5AGRA.js";
|
|
27
|
+
|
|
28
|
+
// src/docs/commands/rune.js
|
|
29
|
+
init_require_shim();
|
|
30
|
+
import { join, relative } from "node:path";
|
|
31
|
+
async function handler({ keys, format = "text", projectRoot = process.cwd(), configRoot = projectRoot }) {
|
|
32
|
+
let config;
|
|
33
|
+
try {
|
|
34
|
+
config = loadConfig(configRoot);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
output.error(`Config unreadable: ${err.message}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const results = [];
|
|
40
|
+
let anyFailed = false;
|
|
41
|
+
for (const key of keys) {
|
|
42
|
+
const entry = getRune(config, key);
|
|
43
|
+
if (!entry) {
|
|
44
|
+
output.warn(`Unknown rune: "${key}"`);
|
|
45
|
+
anyFailed = true;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const runeFile = join(configRoot, entry.path ?? `.crunes/runes/${key}.js`);
|
|
49
|
+
const relativePath = relative(projectRoot, runeFile).replace(/\\/g, "/");
|
|
50
|
+
const basePerms = entry.permissions ?? { allow: [], deny: [] };
|
|
51
|
+
const effective = computeEffectivePermissions(basePerms, config.permissions?.[key], "args", projectRoot);
|
|
52
|
+
let schema = null;
|
|
53
|
+
try {
|
|
54
|
+
schema = await getArgsSchema(runeFile, effective, projectRoot, { vars: entry.vars ?? {} });
|
|
55
|
+
} catch (err) {
|
|
56
|
+
output.warn(`Could not load args schema for "${key}": ${err.message}`);
|
|
57
|
+
}
|
|
58
|
+
results.push({
|
|
59
|
+
key,
|
|
60
|
+
name: entry.name ?? key,
|
|
61
|
+
description: entry.description ?? null,
|
|
62
|
+
relativePath,
|
|
63
|
+
schema
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (format === "json") {
|
|
67
|
+
process.stdout.write(JSON.stringify(results, null, 2) + "\n");
|
|
68
|
+
} else {
|
|
69
|
+
const blocks = results.map((r) => formatHelp(r.schema, { key: r.key, name: r.name, description: r.description, relativePath: r.relativePath }));
|
|
70
|
+
if (blocks.length > 0) process.stdout.write(blocks.join("\n\n") + "\n");
|
|
71
|
+
}
|
|
72
|
+
if (anyFailed) process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
handler
|
|
76
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
searchMarketplaces
|
|
3
|
+
} from "./chunk-L72BG6DS.js";
|
|
4
|
+
import "./chunk-HMU2J25D.js";
|
|
5
|
+
import {
|
|
6
|
+
init_require_shim
|
|
7
|
+
} from "./chunk-TPK5AGRA.js";
|
|
8
|
+
|
|
9
|
+
// src/marketplace/commands/search.js
|
|
10
|
+
init_require_shim();
|
|
11
|
+
async function handler({ query }) {
|
|
12
|
+
const results = await searchMarketplaces(query);
|
|
13
|
+
if (results.length === 0) {
|
|
14
|
+
console.log(`No plugins found matching "${query}".`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
for (const plugin of results) {
|
|
18
|
+
const desc = plugin.description ? ` ${plugin.description}` : "";
|
|
19
|
+
console.log(`${plugin.name}${plugin.version ? `@${plugin.version}` : ""}${desc}`);
|
|
20
|
+
if (plugin.source) console.log(` ${plugin.source}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
handler
|
|
25
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
uninstallPlugin
|
|
3
|
+
} from "./chunk-2Q24YPGL.js";
|
|
4
|
+
import {
|
|
5
|
+
R,
|
|
6
|
+
fe,
|
|
7
|
+
ge,
|
|
8
|
+
le
|
|
9
|
+
} from "./chunk-CGZL5SSH.js";
|
|
10
|
+
import {
|
|
11
|
+
loadRegistry,
|
|
12
|
+
resolvePluginKey
|
|
13
|
+
} from "./chunk-GHQOK4L7.js";
|
|
14
|
+
import "./chunk-HMU2J25D.js";
|
|
15
|
+
import "./chunk-G3U4V32O.js";
|
|
16
|
+
import {
|
|
17
|
+
init_require_shim
|
|
18
|
+
} from "./chunk-TPK5AGRA.js";
|
|
19
|
+
|
|
20
|
+
// src/plugin/commands/uninstall.js
|
|
21
|
+
init_require_shim();
|
|
22
|
+
async function handler({ name, yes, projectRoot }) {
|
|
23
|
+
let pluginKey;
|
|
24
|
+
try {
|
|
25
|
+
const registry = await loadRegistry();
|
|
26
|
+
pluginKey = resolvePluginKey(name, registry);
|
|
27
|
+
if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
ge(`Error: ${err.message}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
if (!yes) {
|
|
33
|
+
const confirm = await le({ message: `Uninstall plugin "${pluginKey}"?` });
|
|
34
|
+
if (R(confirm) || !confirm) {
|
|
35
|
+
ge("Cancelled.");
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await uninstallPlugin(pluginKey, projectRoot);
|
|
41
|
+
fe(`Uninstalled ${pluginKey}`);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
ge(`Failed: ${err.message}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
handler
|
|
49
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deleteCacheKey
|
|
3
|
+
} from "./chunk-NXSDVVTW.js";
|
|
4
|
+
import "./chunk-QMWGQXEZ.js";
|
|
5
|
+
import {
|
|
6
|
+
ensureProjectIdentity
|
|
7
|
+
} from "./chunk-3TM6B4E5.js";
|
|
8
|
+
import "./chunk-HMU2J25D.js";
|
|
9
|
+
import {
|
|
10
|
+
init_require_shim
|
|
11
|
+
} from "./chunk-TPK5AGRA.js";
|
|
12
|
+
|
|
13
|
+
// src/cache/commands/unset.js
|
|
14
|
+
init_require_shim();
|
|
15
|
+
async function handler({ id, key: keyName, projectDir, global: isGlobal }) {
|
|
16
|
+
const projKey = isGlobal ? void 0 : (await ensureProjectIdentity(projectDir)).id;
|
|
17
|
+
let result;
|
|
18
|
+
try {
|
|
19
|
+
result = await deleteCacheKey(id, keyName, projKey);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error(`Error: ${err.message}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
console.log(`Removed key "${keyName}" from "${result.name}".`);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
handler
|
|
28
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listMarketplaces,
|
|
3
|
+
updateMarketplace
|
|
4
|
+
} from "./chunk-L72BG6DS.js";
|
|
5
|
+
import "./chunk-HMU2J25D.js";
|
|
6
|
+
import {
|
|
7
|
+
init_require_shim
|
|
8
|
+
} from "./chunk-TPK5AGRA.js";
|
|
9
|
+
|
|
10
|
+
// src/marketplace/commands/update.js
|
|
11
|
+
init_require_shim();
|
|
12
|
+
async function handler({ url }) {
|
|
13
|
+
try {
|
|
14
|
+
if (url) {
|
|
15
|
+
await updateMarketplace(url);
|
|
16
|
+
console.log(`Marketplace "${url}" updated.`);
|
|
17
|
+
} else {
|
|
18
|
+
const sources = await listMarketplaces();
|
|
19
|
+
if (sources.length === 0) {
|
|
20
|
+
console.log("No marketplaces configured.");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const source of sources) {
|
|
24
|
+
try {
|
|
25
|
+
await updateMarketplace(source);
|
|
26
|
+
console.log(`Updated: ${source}`);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.error(`Warning: could not update "${source}": ${err.message}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(`Error: ${err.message}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
handler
|
|
39
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveFromMarketplace
|
|
3
|
+
} from "./chunk-L72BG6DS.js";
|
|
4
|
+
import {
|
|
5
|
+
installPlugin
|
|
6
|
+
} from "./chunk-2Q24YPGL.js";
|
|
7
|
+
import {
|
|
8
|
+
R2 as R,
|
|
9
|
+
fe,
|
|
10
|
+
ge,
|
|
11
|
+
ye
|
|
12
|
+
} from "./chunk-CGZL5SSH.js";
|
|
13
|
+
import {
|
|
14
|
+
loadRegistry,
|
|
15
|
+
resolvePluginKey
|
|
16
|
+
} from "./chunk-GHQOK4L7.js";
|
|
17
|
+
import "./chunk-HMU2J25D.js";
|
|
18
|
+
import "./chunk-G3U4V32O.js";
|
|
19
|
+
import {
|
|
20
|
+
init_require_shim
|
|
21
|
+
} from "./chunk-TPK5AGRA.js";
|
|
22
|
+
|
|
23
|
+
// src/plugin/commands/update.js
|
|
24
|
+
init_require_shim();
|
|
25
|
+
async function handler({ name, projectRoot }) {
|
|
26
|
+
const registry = await loadRegistry();
|
|
27
|
+
let plugins;
|
|
28
|
+
if (name) {
|
|
29
|
+
const pluginKey = resolvePluginKey(name, registry);
|
|
30
|
+
if (!pluginKey) {
|
|
31
|
+
ge(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
plugins = [pluginKey];
|
|
35
|
+
} else {
|
|
36
|
+
plugins = Object.keys(registry.plugins ?? {});
|
|
37
|
+
}
|
|
38
|
+
if (plugins.length === 0) {
|
|
39
|
+
console.log("No plugins installed.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
ye(name ? `Updating ${name}\u2026` : "Updating all plugins\u2026");
|
|
43
|
+
for (const pluginName of plugins) {
|
|
44
|
+
const entry = registry.plugins[pluginName];
|
|
45
|
+
if (!entry) {
|
|
46
|
+
R.warn(`Plugin "${pluginName}" is not installed.`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const atIdx = pluginName.indexOf("@");
|
|
50
|
+
if (atIdx === -1) {
|
|
51
|
+
R.warn(`Skipping ${pluginName}: no marketplace provenance (legacy entry).`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const marketplaceName = pluginName.slice(0, atIdx);
|
|
55
|
+
const pluginNamePart = pluginName.slice(atIdx + 1);
|
|
56
|
+
let resolvedSource, provenance;
|
|
57
|
+
try {
|
|
58
|
+
;
|
|
59
|
+
({ resolvedSource, ...provenance } = await resolveFromMarketplace(marketplaceName, pluginNamePart));
|
|
60
|
+
} catch (err) {
|
|
61
|
+
R.error(`Failed to resolve ${pluginName} from marketplace: ${err.message}`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const result = await installPlugin(resolvedSource, projectRoot, provenance);
|
|
66
|
+
if (result.installed) {
|
|
67
|
+
R.success(`Updated ${pluginName}@${result.version}`);
|
|
68
|
+
} else {
|
|
69
|
+
R.warn(`Update of ${pluginName} cancelled (permission consent declined).`);
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
R.error(`Failed to update ${pluginName}: ${err.message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
fe("Done.");
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
handler
|
|
79
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
utils_api_default
|
|
3
|
+
} from "./chunk-BVY5LN7X.js";
|
|
4
|
+
import {
|
|
5
|
+
formatNode,
|
|
6
|
+
walk
|
|
7
|
+
} from "./chunk-XIXND2M4.js";
|
|
8
|
+
import {
|
|
9
|
+
output
|
|
10
|
+
} from "./chunk-6XLT25GS.js";
|
|
11
|
+
import "./chunk-WCODTMDN.js";
|
|
12
|
+
import {
|
|
13
|
+
init_require_shim
|
|
14
|
+
} from "./chunk-TPK5AGRA.js";
|
|
15
|
+
|
|
16
|
+
// src/docs/commands/utils.js
|
|
17
|
+
init_require_shim();
|
|
18
|
+
var ALL_NAMESPACES = walk(utils_api_default);
|
|
19
|
+
function formatIndex(namespaces) {
|
|
20
|
+
const lines = ["Available utils namespaces:", ""];
|
|
21
|
+
for (const ns of namespaces) {
|
|
22
|
+
lines.push(` ${ns.name} ${ns.description ?? ""}`.trimEnd());
|
|
23
|
+
}
|
|
24
|
+
return lines.join("\n");
|
|
25
|
+
}
|
|
26
|
+
async function handler({ namespaces = [], format = "text" } = {}) {
|
|
27
|
+
let anyFailed = false;
|
|
28
|
+
const targets = namespaces.length === 0 ? ALL_NAMESPACES : namespaces.map((name) => {
|
|
29
|
+
const ns = ALL_NAMESPACES.find((n) => n.name === name);
|
|
30
|
+
if (!ns) {
|
|
31
|
+
output.warn(`Unknown utils namespace: "${name}"`);
|
|
32
|
+
anyFailed = true;
|
|
33
|
+
}
|
|
34
|
+
return ns;
|
|
35
|
+
}).filter(Boolean);
|
|
36
|
+
if (format === "json") {
|
|
37
|
+
process.stdout.write(JSON.stringify(targets, null, 2) + "\n");
|
|
38
|
+
} else {
|
|
39
|
+
if (namespaces.length === 0) {
|
|
40
|
+
process.stdout.write(formatIndex(targets) + "\n");
|
|
41
|
+
} else {
|
|
42
|
+
const blocks = targets.map((ns) => formatNode(ns));
|
|
43
|
+
if (blocks.length > 0) process.stdout.write(blocks.join("\n\n") + "\n");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (anyFailed) process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
handler
|
|
50
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
source_default
|
|
3
|
+
} from "./chunk-WCODTMDN.js";
|
|
4
|
+
import {
|
|
5
|
+
getStorePath
|
|
6
|
+
} from "./chunk-HMU2J25D.js";
|
|
7
|
+
import {
|
|
8
|
+
init_require_shim
|
|
9
|
+
} from "./chunk-TPK5AGRA.js";
|
|
10
|
+
|
|
11
|
+
// src/cli/commands/version.js
|
|
12
|
+
init_require_shim();
|
|
13
|
+
import fs from "node:fs/promises";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
|
|
16
|
+
// package.json
|
|
17
|
+
var package_default = {
|
|
18
|
+
name: "@darkrymit/crunes-cli",
|
|
19
|
+
version: "0.7.0",
|
|
20
|
+
description: "CLI tool for querying crunes enrichers",
|
|
21
|
+
type: "module",
|
|
22
|
+
bin: {
|
|
23
|
+
crunes: "./dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
files: [
|
|
26
|
+
"dist/"
|
|
27
|
+
],
|
|
28
|
+
scripts: {
|
|
29
|
+
build: "typedoc --options typedoc.json && typedoc --options typedoc-lifecycle.json && typedoc --options typedoc-globals.json && node build.mjs",
|
|
30
|
+
prepack: "node build.mjs",
|
|
31
|
+
test: "vitest run"
|
|
32
|
+
},
|
|
33
|
+
dependencies: {
|
|
34
|
+
"isolated-vm": "^6.1.2"
|
|
35
|
+
},
|
|
36
|
+
optionalDependencies: {
|
|
37
|
+
"better-sqlite3": "^12.10.0"
|
|
38
|
+
},
|
|
39
|
+
devDependencies: {
|
|
40
|
+
"@clack/prompts": "^1.5.0",
|
|
41
|
+
archiver: "^8.0.0",
|
|
42
|
+
chalk: "^5.4.1",
|
|
43
|
+
"cli-table3": "^0.6.5",
|
|
44
|
+
commander: "^15.0.0",
|
|
45
|
+
dotenv: "^17.4.2",
|
|
46
|
+
esbuild: "^0.28.0",
|
|
47
|
+
"fast-text-encoding": "^1.0.6",
|
|
48
|
+
"fast-xml-parser": "^5.8.0",
|
|
49
|
+
"jsonpath-plus": "^10.4.0",
|
|
50
|
+
micromatch: "^4.0.8",
|
|
51
|
+
mysql2: "^3.12.0",
|
|
52
|
+
pg: "^8.11.0",
|
|
53
|
+
tar: "^7.5.15",
|
|
54
|
+
tinyglobby: "^0.2.17",
|
|
55
|
+
typedoc: "^0.28.19",
|
|
56
|
+
typescript: "^6.0.3",
|
|
57
|
+
unzipper: "^0.12.3",
|
|
58
|
+
vitest: "^4.1.7",
|
|
59
|
+
"web-streams-polyfill": "^4.3.0",
|
|
60
|
+
ws: "^8.21.0",
|
|
61
|
+
yaml: "^2.9.0",
|
|
62
|
+
"yargs-parser": "^22.0.0"
|
|
63
|
+
},
|
|
64
|
+
repository: {
|
|
65
|
+
type: "git",
|
|
66
|
+
url: "https://github.com/darkrymit/crunes-cli"
|
|
67
|
+
},
|
|
68
|
+
license: "MIT",
|
|
69
|
+
author: "DarkRymit",
|
|
70
|
+
engines: {
|
|
71
|
+
node: ">=22"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/cli/commands/version.js
|
|
76
|
+
var PKG_VERSION = package_default.version;
|
|
77
|
+
var CACHE_PATH = path.join(getStorePath(), "update-check.json");
|
|
78
|
+
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
79
|
+
var CHECK_URL = "https://registry.npmjs.org/@darkrymit/crunes-cli/latest";
|
|
80
|
+
var CHECK_TIMEOUT_MS = 2e3;
|
|
81
|
+
async function readCache() {
|
|
82
|
+
try {
|
|
83
|
+
const raw = await fs.readFile(CACHE_PATH, "utf8");
|
|
84
|
+
const data = JSON.parse(raw);
|
|
85
|
+
if (data.format !== "1") return null;
|
|
86
|
+
const age = Date.now() - new Date(data.checkedAt).getTime();
|
|
87
|
+
if (age > CACHE_TTL_MS) return null;
|
|
88
|
+
return data.latestVersion ?? null;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function fetchLatest() {
|
|
94
|
+
try {
|
|
95
|
+
const controller = new AbortController();
|
|
96
|
+
const timer = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
|
|
97
|
+
let res;
|
|
98
|
+
try {
|
|
99
|
+
res = await fetch(CHECK_URL, { signal: controller.signal });
|
|
100
|
+
} finally {
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
}
|
|
103
|
+
if (!res.ok) return null;
|
|
104
|
+
const json = await res.json();
|
|
105
|
+
const latestVersion = json.version ?? null;
|
|
106
|
+
if (!latestVersion) return null;
|
|
107
|
+
await fs.mkdir(getStorePath(), { recursive: true });
|
|
108
|
+
await fs.writeFile(CACHE_PATH, JSON.stringify({
|
|
109
|
+
format: "1",
|
|
110
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111
|
+
latestVersion
|
|
112
|
+
}), "utf8");
|
|
113
|
+
return latestVersion;
|
|
114
|
+
} catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function checkForUpdate() {
|
|
119
|
+
const cached = await readCache();
|
|
120
|
+
const latest = cached ?? await fetchLatest();
|
|
121
|
+
if (!latest) return null;
|
|
122
|
+
return latest !== PKG_VERSION ? latest : null;
|
|
123
|
+
}
|
|
124
|
+
async function handler({ check = true, plain = false } = {}) {
|
|
125
|
+
if (plain) {
|
|
126
|
+
process.stdout.write(`${PKG_VERSION}
|
|
127
|
+
`);
|
|
128
|
+
} else {
|
|
129
|
+
console.log(`crunes ${source_default.bold(PKG_VERSION)}`);
|
|
130
|
+
}
|
|
131
|
+
if (!check) return;
|
|
132
|
+
const latest = await checkForUpdate();
|
|
133
|
+
if (!latest) return;
|
|
134
|
+
if (plain) {
|
|
135
|
+
process.stdout.write(`update-available ${latest}
|
|
136
|
+
`);
|
|
137
|
+
} else {
|
|
138
|
+
console.log();
|
|
139
|
+
console.log(` ${source_default.yellow("Update available:")} ${source_default.dim(PKG_VERSION)} \u2192 ${source_default.green(latest)}`);
|
|
140
|
+
console.log(` Run ${source_default.cyan("npm install -g @darkrymit/crunes-cli")} to update.`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
handler
|
|
145
|
+
};
|