@darkrymit/crunes-cli 0.12.0 → 0.13.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/{chunk-PBQDFAR4.js → chunk-QFW2V36K.js} +16 -2
- package/dist/chunks/chunk-SMFHRQH4.js +83 -0
- package/dist/chunks/{create-YLXRZQXI.js → create-676JD63L.js} +2 -10
- package/dist/chunks/{create-ZWBV7PPT.js → create-UUYJ76JB.js} +1 -1
- package/dist/chunks/{create-4DEH53O6.js → create-WHYUMBIP.js} +1 -1
- package/dist/chunks/{version-QBWEJ45I.js → version-SBE7LQ5C.js} +6 -1
- package/dist/cli.js +5 -5
- package/dist/test/index.js +75924 -0
- package/dist/test/register.js +9 -0
- package/package.json +6 -1
|
@@ -31,10 +31,24 @@ function runeTestTemplate(key) {
|
|
|
31
31
|
return [
|
|
32
32
|
`import { describe, it } from 'node:test'`,
|
|
33
33
|
`import assert from 'node:assert/strict'`,
|
|
34
|
+
`import fs from 'node:fs'`,
|
|
35
|
+
`import os from 'node:os'`,
|
|
36
|
+
`import path from 'node:path'`,
|
|
37
|
+
`import { setupCrunesTest } from '@darkrymit/crunes-cli/test'`,
|
|
38
|
+
``,
|
|
39
|
+
`const { run } = await import('../src/index.rune.js')`,
|
|
34
40
|
``,
|
|
35
41
|
`describe('${key} rune', () => {`,
|
|
36
|
-
` it('
|
|
37
|
-
`
|
|
42
|
+
` it('runs with @utils test shim', async () => {`,
|
|
43
|
+
` const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'crunes-${key}-'))`,
|
|
44
|
+
` const env = setupCrunesTest({ cwd: tmp })`,
|
|
45
|
+
` try {`,
|
|
46
|
+
` const sections = await run({ $command: '', $commands: [], $rest: [], $raw: [], _: [] })`,
|
|
47
|
+
` assert.ok(sections)`,
|
|
48
|
+
` } finally {`,
|
|
49
|
+
` await env.cleanup()`,
|
|
50
|
+
` fs.rmSync(tmp, { recursive: true, force: true })`,
|
|
51
|
+
` }`,
|
|
38
52
|
` })`,
|
|
39
53
|
`})`,
|
|
40
54
|
``
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_require_shim
|
|
3
|
+
} from "./chunk-FATG2PA7.js";
|
|
4
|
+
|
|
5
|
+
// src/test/register.js
|
|
6
|
+
init_require_shim();
|
|
7
|
+
import { registerHooks } from "node:module";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
var installed = false;
|
|
11
|
+
var roots = { projectRoot: null, pluginRoot: null };
|
|
12
|
+
function setCrunesTestRoots({ projectRoot, pluginRoot } = {}) {
|
|
13
|
+
if (projectRoot !== void 0) roots.projectRoot = projectRoot ? path.resolve(projectRoot) : null;
|
|
14
|
+
if (pluginRoot !== void 0) roots.pluginRoot = pluginRoot ? path.resolve(pluginRoot) : null;
|
|
15
|
+
}
|
|
16
|
+
function installCrunesTestHooks({ projectRoot, pluginRoot } = {}) {
|
|
17
|
+
setCrunesTestRoots({ projectRoot, pluginRoot });
|
|
18
|
+
if (installed) return;
|
|
19
|
+
installed = true;
|
|
20
|
+
registerHooks({
|
|
21
|
+
resolve(specifier, context, nextResolve) {
|
|
22
|
+
if (specifier === "@utils") {
|
|
23
|
+
return { shortCircuit: true, url: "crunes-test:@utils" };
|
|
24
|
+
}
|
|
25
|
+
if (roots.pluginRoot && specifier.startsWith("@plugin/")) {
|
|
26
|
+
const target = path.resolve(roots.pluginRoot, specifier.slice("@plugin/".length));
|
|
27
|
+
return { shortCircuit: true, url: pathToFileURL(target).href };
|
|
28
|
+
}
|
|
29
|
+
if (roots.projectRoot && specifier.startsWith("@project/")) {
|
|
30
|
+
const target = path.resolve(roots.projectRoot, specifier.slice("@project/".length));
|
|
31
|
+
return { shortCircuit: true, url: pathToFileURL(target).href };
|
|
32
|
+
}
|
|
33
|
+
return nextResolve(specifier, context);
|
|
34
|
+
},
|
|
35
|
+
load(url, context, nextLoad) {
|
|
36
|
+
if (url === "crunes-test:@utils") {
|
|
37
|
+
return {
|
|
38
|
+
shortCircuit: true,
|
|
39
|
+
format: "module",
|
|
40
|
+
source: [
|
|
41
|
+
`const get = ns => {`,
|
|
42
|
+
` const u = globalThis.__CRUNES_TEST_UTILS__`,
|
|
43
|
+
` if (!u) throw new Error('Call setupCrunesTest() before invoking @utils')`,
|
|
44
|
+
` return u[ns]`,
|
|
45
|
+
`}`,
|
|
46
|
+
`const proxy = ns => new Proxy({}, { get: (_, k) => get(ns)[k] })`,
|
|
47
|
+
`export const fs = proxy('fs')`,
|
|
48
|
+
`export const shell = proxy('shell')`,
|
|
49
|
+
`export const section = proxy('section')`,
|
|
50
|
+
`export const rune = proxy('rune')`,
|
|
51
|
+
`export const json = proxy('json')`,
|
|
52
|
+
`export const yaml = proxy('yaml')`,
|
|
53
|
+
`export const xml = proxy('xml')`,
|
|
54
|
+
`export const csv = proxy('csv')`,
|
|
55
|
+
`export const http = proxy('http')`,
|
|
56
|
+
`export const env = proxy('env')`,
|
|
57
|
+
`export const vars = proxy('vars')`,
|
|
58
|
+
`export const os = proxy('os')`,
|
|
59
|
+
`export const stdin = proxy('stdin')`,
|
|
60
|
+
`export const archive = proxy('archive')`,
|
|
61
|
+
`export const cache = proxy('cache')`,
|
|
62
|
+
`export const sqlite = proxy('sqlite')`,
|
|
63
|
+
`export const db = proxy('db')`,
|
|
64
|
+
`export const crypt = proxy('crypt')`,
|
|
65
|
+
`export const codec = proxy('codec')`,
|
|
66
|
+
`export const ws = proxy('ws')`,
|
|
67
|
+
`export const time = proxy('time')`,
|
|
68
|
+
`export const notify = proxy('notify')`,
|
|
69
|
+
`export const md = proxy('md')`,
|
|
70
|
+
`export const tree = proxy('tree')`
|
|
71
|
+
].join("\n")
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return nextLoad(url, context);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
installCrunesTestHooks();
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
setCrunesTestRoots,
|
|
82
|
+
installCrunesTestHooks
|
|
83
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runeTestTemplate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QFW2V36K.js";
|
|
4
4
|
import "./chunk-J33GQMPV.js";
|
|
5
5
|
import {
|
|
6
6
|
output
|
|
@@ -146,15 +146,7 @@ function changelogMd() {
|
|
|
146
146
|
`;
|
|
147
147
|
}
|
|
148
148
|
function exampleTest() {
|
|
149
|
-
return
|
|
150
|
-
import assert from 'node:assert/strict'
|
|
151
|
-
|
|
152
|
-
describe('example rune', () => {
|
|
153
|
-
it('placeholder', () => {
|
|
154
|
-
assert.ok(true)
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
`;
|
|
149
|
+
return runeTestTemplate("example");
|
|
158
150
|
}
|
|
159
151
|
function getGitAuthor() {
|
|
160
152
|
const result = spawnSync("git", ["config", "user.name"], { encoding: "utf8" });
|
|
@@ -16,7 +16,7 @@ import path from "node:path";
|
|
|
16
16
|
// package.json
|
|
17
17
|
var package_default = {
|
|
18
18
|
name: "@darkrymit/crunes-cli",
|
|
19
|
-
version: "0.
|
|
19
|
+
version: "0.13.0",
|
|
20
20
|
description: "CLI tool for querying crunes enrichers",
|
|
21
21
|
type: "module",
|
|
22
22
|
bin: {
|
|
@@ -75,6 +75,11 @@ var package_default = {
|
|
|
75
75
|
author: "DarkRymit",
|
|
76
76
|
engines: {
|
|
77
77
|
node: ">=24"
|
|
78
|
+
},
|
|
79
|
+
exports: {
|
|
80
|
+
".": "./dist/cli.js",
|
|
81
|
+
"./test": "./dist/test/index.js",
|
|
82
|
+
"./test/register": "./dist/test/register.js"
|
|
78
83
|
}
|
|
79
84
|
};
|
|
80
85
|
|
package/dist/cli.js
CHANGED
|
@@ -3397,7 +3397,7 @@ var program = new Command();
|
|
|
3397
3397
|
// src/cli/program.js
|
|
3398
3398
|
function buildProgram() {
|
|
3399
3399
|
const program3 = new Command();
|
|
3400
|
-
program3.name("crunes").description("CLI tool for managing context runes").version("0.
|
|
3400
|
+
program3.name("crunes").description("CLI tool for managing context runes").version("0.13.0", "-v, --version").enablePositionalOptions().option("-y, --yes", "assume yes to all prompts and skip interactive mode (also auto-detected in non-TTY environments)").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").option("--cwd <path>", "project root to use instead of the current working directory").option("--ccd <path>", "config directory \u2014 where .crunes/config.json and local rune files live (default: --cwd)").option("--verbose", "print full error stack traces and other verbose output");
|
|
3401
3401
|
program3.hook("preAction", (_thisCommand, actionCommand) => {
|
|
3402
3402
|
const opts = { ...program3.opts(), ...actionCommand.opts() };
|
|
3403
3403
|
configure({ plain: !!opts.plain, verbose: !!opts.verbose });
|
|
@@ -3482,7 +3482,7 @@ function buildProgram() {
|
|
|
3482
3482
|
await handler();
|
|
3483
3483
|
});
|
|
3484
3484
|
program3.command("version").description("Print the installed version and check for updates").option("--no-check", "skip the npm update check").action(async (opts) => {
|
|
3485
|
-
const { handler } = await import("./chunks/version-
|
|
3485
|
+
const { handler } = await import("./chunks/version-SBE7LQ5C.js");
|
|
3486
3486
|
await handler({ check: opts.check, plain: !!program3.opts().plain });
|
|
3487
3487
|
});
|
|
3488
3488
|
program3.command("doctor").description("Verify environment and project setup").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").action(async () => {
|
|
@@ -3564,7 +3564,7 @@ function buildProgram() {
|
|
|
3564
3564
|
await handler({ yes: !!program3.opts().yes, projectRoot: projectRoot(), global: !!opts.global });
|
|
3565
3565
|
});
|
|
3566
3566
|
program3.command("create [new-rune]").description("Scaffold a new rune and register it in config").addOption(new Option("--format <format>", "rune output format").choices(["tree", "markdown"])).option("--path <path>", "file path for the rune (default: .crunes/runes/<key>/src/index.rune.js)").addOption(new Option("--lang <lang>", "scaffold a script rune instead of a sandboxed JS one").choices(["python", "bash", "node"])).option("--name <name>", "human-readable label shown in crunes list").option("--description <description>", "short description of what context this rune provides").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").option("--plugin", "register the rune in .crunes-plugin/plugin.json instead of .crunes/config.json").option("--project", "register the rune in .crunes/config.json even when .crunes-plugin/plugin.json exists").action(async (key, opts) => {
|
|
3567
|
-
const { handler } = await import("./chunks/create-
|
|
3567
|
+
const { handler } = await import("./chunks/create-UUYJ76JB.js");
|
|
3568
3568
|
await handler({ key, format: opts.format, lang: opts.lang, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global, plugin: !!opts.plugin, project: !!opts.project });
|
|
3569
3569
|
});
|
|
3570
3570
|
program3.command("add <key> <command> [argv...]").description("Register an existing script or program as a rune (fixed arguments go after --)").option("--name <name>", "human-readable label shown in crunes list").option("--description <description>", "short description of what the rune does").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").addHelpText("after", '\nExamples:\n crunes add coverage tools/coverage.py --description "Test coverage per module"\n crunes add log git -- log --oneline -n 20').action(async (key, command, argv, opts) => {
|
|
@@ -3601,7 +3601,7 @@ function buildProgram() {
|
|
|
3601
3601
|
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3602
3602
|
});
|
|
3603
3603
|
plugin.command("create [new-plugin]").description("Scaffold a new plugin directory with all required files").option("--description <text>", "short description for plugin.json and marketplace.json").option("--author <name>", "author name (default: git config user.name)").option("--license <spdx>", "SPDX license identifier (default: MIT)").option("--out <path>", "output directory (default: ./<name>)").option("--multi", "scaffold under runes/example/{src,test}/ for a multi-rune plugin").action(async (name, opts) => {
|
|
3604
|
-
const { handler } = await import("./chunks/create-
|
|
3604
|
+
const { handler } = await import("./chunks/create-676JD63L.js");
|
|
3605
3605
|
await handler({ name, description: opts.description, author: opts.author, license: opts.license, out: opts.out, multi: !!opts.multi, yes: !!program3.opts().yes, projectRoot: projectRoot() });
|
|
3606
3606
|
});
|
|
3607
3607
|
const template = program3.command("template").description("Manage rune templates");
|
|
@@ -3617,7 +3617,7 @@ function buildProgram() {
|
|
|
3617
3617
|
await handler({ ref, key: opts.as, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3618
3618
|
});
|
|
3619
3619
|
template.command("create [new-template]").description("Scaffold a new template folder and register it in config").option("--path <path>", "folder for the template (default: .crunes/templates/<name>)").addOption(new Option("--lang <lang>", "scaffold a script template instead of a sandboxed JS one").choices(["python", "bash", "node"])).option("--name <name>", "display label shown in crunes template list (separate from the template key)").option("--description <description>", "short description of what kind of rune this template produces").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").action(async (name, opts) => {
|
|
3620
|
-
const { handler } = await import("./chunks/create-
|
|
3620
|
+
const { handler } = await import("./chunks/create-WHYUMBIP.js");
|
|
3621
3621
|
await handler({ name, path: opts.path, lang: opts.lang, templateName: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3622
3622
|
});
|
|
3623
3623
|
const marketplace = program3.command("marketplace").description("Manage plugin marketplace sources");
|