@darkrymit/crunes-cli 0.12.0 → 0.14.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/{benchmark-2TVN6HDF.js → benchmark-HBIZCVFR.js} +3 -3
- package/dist/chunks/{chunk-THGPCLJD.js → chunk-2N6X32LY.js} +5 -3
- package/dist/chunks/{chunk-TXCUSUZ6.js → chunk-32GEHGUV.js} +2500 -2347
- package/dist/chunks/{chunk-CBWT3DFR.js → chunk-5L2GJWCD.js} +4 -0
- package/dist/chunks/{chunk-ATI5HNNC.js → chunk-C3FADOZT.js} +2 -2
- package/dist/chunks/{chunk-3VFNNPQI.js → chunk-PICTIOYJ.js} +3 -3
- package/dist/chunks/{chunk-PBQDFAR4.js → chunk-QFW2V36K.js} +16 -2
- package/dist/chunks/chunk-SMFHRQH4.js +83 -0
- package/dist/chunks/{chunk-QAP63JIK.js → chunk-WUNDVEEL.js} +5 -5
- package/dist/chunks/chunk-XPEVUBUK.js +40 -0
- package/dist/chunks/{chunk-KP4EW2DS.js → chunk-ZFIRPZPE.js} +153 -15
- 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/{doctor-SXKAEYUF.js → doctor-HLQE7TVE.js} +1 -1
- package/dist/chunks/{install-FSJAC3CL.js → install-2K5BNXDO.js} +1 -1
- package/dist/chunks/{intro-PN7LT6ZG.js → intro-L5WBDL2P.js} +1 -1
- package/dist/chunks/{kill-Z7ZDY5MB.js → kill-IX7HNMVP.js} +12 -4
- package/dist/chunks/{list-45SHVKXO.js → list-BJTV6SPK.js} +1 -1
- package/dist/chunks/{repl-PSADU3MJ.js → repl-GNA342PP.js} +4 -4
- package/dist/chunks/{resolver-YEUZSOS4.js → resolver-II54EHPA.js} +2 -2
- package/dist/chunks/{run-CYGL3HTA.js → run-PXTN5GYH.js} +3 -3
- package/dist/chunks/{rune-OQX5EYSQ.js → rune-7YEZJTHK.js} +5 -4
- package/dist/chunks/{runner-VUSHR2OR.js → runner-OKVKI7FP.js} +3 -2
- package/dist/chunks/{uninstall-MSCIWDWV.js → uninstall-X75QTERD.js} +1 -1
- package/dist/chunks/{update-IHCYA3JW.js → update-HHIDPHGX.js} +1 -1
- package/dist/chunks/{utils-DJ3BXOQC.js → utils-K7DAKWGS.js} +1 -1
- package/dist/chunks/{version-QBWEJ45I.js → version-RZVOIMQG.js} +6 -1
- package/dist/cli.js +17 -17
- package/dist/test/index.js +76056 -0
- package/dist/test/register.js +9 -0
- package/package.json +6 -1
|
@@ -22,6 +22,9 @@ function jobStderrPath(projectDir, id) {
|
|
|
22
22
|
function jobStdinPath(projectDir, id) {
|
|
23
23
|
return join(jobDir(projectDir, id), "stdin.log");
|
|
24
24
|
}
|
|
25
|
+
function jobPgidPath(projectDir, id) {
|
|
26
|
+
return join(jobDir(projectDir, id), "pgid");
|
|
27
|
+
}
|
|
25
28
|
async function updateJobPid(projectDir, id, pid) {
|
|
26
29
|
const record = await getJob(projectDir, id);
|
|
27
30
|
if (!record) return;
|
|
@@ -97,6 +100,7 @@ export {
|
|
|
97
100
|
jobStdoutPath,
|
|
98
101
|
jobStderrPath,
|
|
99
102
|
jobStdinPath,
|
|
103
|
+
jobPgidPath,
|
|
100
104
|
updateJobPid,
|
|
101
105
|
createJob,
|
|
102
106
|
getJob,
|
|
@@ -440,7 +440,7 @@ async function getRunBlockSchema(desc, projectDir, { vars = {}, runeKey = null }
|
|
|
440
440
|
if (/\.json$/i.test(desc.argsModule)) {
|
|
441
441
|
return loadJsonSchema(desc.argsModule, relative(projectDir, desc.argsModule).replace(/\\/g, "/") || desc.argsModule);
|
|
442
442
|
}
|
|
443
|
-
const { getArgsSchema } = await import("./runner-
|
|
443
|
+
const { getArgsSchema } = await import("./runner-OKVKI7FP.js");
|
|
444
444
|
return getArgsSchema(desc.argsModule, blockGrants({ permissions: desc.argsPermissions }), projectDir, { vars, runeKey });
|
|
445
445
|
}
|
|
446
446
|
function parseOutputLine(line) {
|
|
@@ -474,7 +474,7 @@ async function runRunBlock({ dir, key, args, entry, opts = {}, configDir, runeCa
|
|
|
474
474
|
const desc = describeRunBlock(entry, configDir);
|
|
475
475
|
let callArgs = [...desc.argv, ...args];
|
|
476
476
|
if (desc.runtime === "isolate") {
|
|
477
|
-
const { runRuneInIsolate } = await import("./runner-
|
|
477
|
+
const { runRuneInIsolate } = await import("./runner-OKVKI7FP.js");
|
|
478
478
|
return runRuneInIsolate(desc.command, blockGrants(desc), callArgs, dir, {
|
|
479
479
|
runeCallback,
|
|
480
480
|
sections: opts.sections ?? null,
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
describeConfigLayers,
|
|
7
7
|
runRune
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WUNDVEEL.js";
|
|
9
9
|
import {
|
|
10
10
|
renderSection
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-C3FADOZT.js";
|
|
12
12
|
import {
|
|
13
13
|
loadConfig
|
|
14
14
|
} from "./chunk-YUI5RTLD.js";
|
|
@@ -216,7 +216,7 @@ async function handler({
|
|
|
216
216
|
process.exit(1);
|
|
217
217
|
}
|
|
218
218
|
if (isBatch) {
|
|
219
|
-
const { resolvePluginRune } = await import("./resolver-
|
|
219
|
+
const { resolvePluginRune } = await import("./resolver-II54EHPA.js");
|
|
220
220
|
const { loadPluginJson } = await import("./manifest-6KLIS7BL.js");
|
|
221
221
|
for (const seg of segments) {
|
|
222
222
|
let entry = config.runes?.[seg.key] ?? {};
|
|
@@ -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
|
runRunBlock
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-C3FADOZT.js";
|
|
4
4
|
import {
|
|
5
5
|
isNativeRune,
|
|
6
6
|
trustDigest,
|
|
@@ -127,7 +127,7 @@ async function runPluginMatch({ match, pluginJson, projectPerms, projectVars, ke
|
|
|
127
127
|
});
|
|
128
128
|
return result2?.directExitCode !== void 0 ? result2 : normaliseResult(result2);
|
|
129
129
|
}
|
|
130
|
-
const { executePluginRune } = await import("./runner-
|
|
130
|
+
const { executePluginRune } = await import("./runner-OKVKI7FP.js");
|
|
131
131
|
const result = await executePluginRune({
|
|
132
132
|
pluginDir,
|
|
133
133
|
pluginCacheDir,
|
|
@@ -225,7 +225,7 @@ async function resolveRuneEntry(projectDir, config, key, configDir = projectDir)
|
|
|
225
225
|
const vars = { ...pluginJson.runes[runeKey]?.vars ?? {}, ...config.runes?.[`${pluginKey}:${runeKey}`]?.vars ?? {} };
|
|
226
226
|
return {
|
|
227
227
|
async createReplSession(args, opts = {}) {
|
|
228
|
-
const { getPluginRunePath, runRuneInRepl } = await import("./runner-
|
|
228
|
+
const { getPluginRunePath, runRuneInRepl } = await import("./runner-OKVKI7FP.js");
|
|
229
229
|
const runeFile = getPluginRunePath(pluginDir, runeKey, pluginJson, "repl");
|
|
230
230
|
const nodeModulesDir = join(pluginCacheDir, "node_modules");
|
|
231
231
|
return runRuneInRepl(runeFile, effective, args, projectDir, {
|
|
@@ -251,7 +251,7 @@ async function resolveRuneEntry(projectDir, config, key, configDir = projectDir)
|
|
|
251
251
|
const vars = entry.vars ?? {};
|
|
252
252
|
return {
|
|
253
253
|
async createReplSession(args, opts = {}) {
|
|
254
|
-
const { runRuneInRepl } = await import("./runner-
|
|
254
|
+
const { runRuneInRepl } = await import("./runner-OKVKI7FP.js");
|
|
255
255
|
return runRuneInRepl(runeFile, effective, args, projectDir, {
|
|
256
256
|
vars,
|
|
257
257
|
runeKey: key,
|
|
@@ -275,7 +275,7 @@ async function resolveRuneEntry(projectDir, config, key, configDir = projectDir)
|
|
|
275
275
|
const vars = { ...pluginJson.runes[runeKey]?.vars ?? {}, ...config.runes?.[`${pluginKey}:${runeKey}`]?.vars ?? {} };
|
|
276
276
|
return {
|
|
277
277
|
async createReplSession(args, opts = {}) {
|
|
278
|
-
const { getPluginRunePath, runRuneInRepl } = await import("./runner-
|
|
278
|
+
const { getPluginRunePath, runRuneInRepl } = await import("./runner-OKVKI7FP.js");
|
|
279
279
|
const runeFile = getPluginRunePath(pluginDir, runeKey, pluginJson, "repl");
|
|
280
280
|
const nodeModulesDir = join(pluginCacheDir, "node_modules");
|
|
281
281
|
return runRuneInRepl(runeFile, effective, args, projectDir, {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAlive,
|
|
3
|
+
jobPgidPath
|
|
4
|
+
} from "./chunk-5L2GJWCD.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveShell
|
|
7
|
+
} from "./chunk-ZT4QFTQM.js";
|
|
8
|
+
import {
|
|
9
|
+
init_require_shim
|
|
10
|
+
} from "./chunk-FATG2PA7.js";
|
|
11
|
+
|
|
12
|
+
// src/job/kill-tree.js
|
|
13
|
+
init_require_shim();
|
|
14
|
+
import { spawn } from "node:child_process";
|
|
15
|
+
import { readFile } from "node:fs/promises";
|
|
16
|
+
function run(command, args) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const child = spawn(command, args, { stdio: "ignore", windowsHide: true });
|
|
19
|
+
child.on("error", resolve);
|
|
20
|
+
child.on("close", resolve);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function readGroup(projectDir, id) {
|
|
24
|
+
const raw = (await readFile(jobPgidPath(projectDir, id), "utf8").catch(() => "")).trim();
|
|
25
|
+
return /^\d+$/.test(raw) && Number(raw) > 1 ? raw : null;
|
|
26
|
+
}
|
|
27
|
+
async function killWindowsShellJob(projectDir, record) {
|
|
28
|
+
const group = isAlive(record.pid) ? await readGroup(projectDir, record.id) : null;
|
|
29
|
+
if (group) {
|
|
30
|
+
try {
|
|
31
|
+
await run(resolveShell("bash").path, ["-c", `kill -9 -- -${group}`]);
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
await run("taskkill", ["/F", "/T", "/PID", String(record.pid)]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
killWindowsShellJob
|
|
40
|
+
};
|