@darkrymit/crunes-cli 0.7.2 → 0.8.2
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 -4
- package/dist/chunks/{add-OWYVF3IE.js → add-CBHWFGCA.js} +2 -2
- package/dist/chunks/{apply-OMEVXCHC.js → apply-YC6JEPUN.js} +6 -5
- package/dist/chunks/args-repl-TX3YWUOO.js +81 -0
- package/dist/chunks/banner-repl-DD22Z33A.js +52 -0
- package/dist/chunks/benchmark-BJEAAFWG.js +234 -0
- package/dist/chunks/{browse-COH6IJEX.js → browse-JZFU52ET.js} +2 -2
- package/dist/chunks/{chunk-2Q24YPGL.js → chunk-2PBPDTRD.js} +2 -2
- package/dist/chunks/chunk-63H5VXZY.js +101 -0
- package/dist/chunks/{chunk-GHQOK4L7.js → chunk-65J65MAP.js} +1 -1
- package/dist/chunks/{chunk-HMU2J25D.js → chunk-6MRZXASS.js} +3 -3
- package/dist/chunks/{chunk-BEVULQIG.js → chunk-ASZKAC24.js} +2 -1
- package/dist/chunks/{chunk-AIEWOUXT.js → chunk-DZJRYFOP.js} +104 -41
- package/dist/chunks/{chunk-QMWGQXEZ.js → chunk-G4ZAUHHA.js} +2 -4
- package/dist/chunks/{chunk-67I2J474.js → chunk-J3GZ3DXD.js} +14 -55
- package/dist/chunks/{chunk-XIXND2M4.js → chunk-JOAL437H.js} +5 -1
- package/dist/chunks/{chunk-6I7RHSAA.js → chunk-JU6FKUBY.js} +30394 -26055
- package/dist/chunks/{chunk-5RGDIMK6.js → chunk-NAEVMRNA.js} +22031 -13353
- package/dist/chunks/{chunk-NXSDVVTW.js → chunk-NDEYEYSU.js} +22 -69
- package/dist/chunks/{chunk-L72BG6DS.js → chunk-NYLRTAAA.js} +1 -1
- package/dist/chunks/{chunk-UGN3FFEF.js → chunk-V35LVVNV.js} +5113 -2117
- package/dist/chunks/chunk-ZJDKCC2Y.js +105 -0
- package/dist/chunks/{clear-Y5POLIMF.js → clear-YBDIPEEH.js} +5 -9
- package/dist/chunks/commands-repl-IPLJ4M7X.js +65 -0
- package/dist/chunks/complete-input-repl-IDSCMRYL.js +71 -0
- package/dist/chunks/{create-I6BNYZ5Q.js → create-ZFFV3Z2P.js} +2 -1
- package/dist/chunks/{delete-UB5SXO5I.js → delete-C4UJ7X5K.js} +5 -9
- package/dist/chunks/delete-E4TEBRPX.js +27 -0
- package/dist/chunks/{delete-7CQFYIXS.js → delete-LNOYM5KG.js} +5 -9
- package/dist/chunks/{disable-FCBW7WVG.js → disable-TMG2K3BF.js} +6 -6
- package/dist/chunks/{doctor-DS57HDLJ.js → doctor-N43QEMAH.js} +2 -2
- package/dist/chunks/{enable-IXRVUXJM.js → enable-327OMBPC.js} +6 -6
- package/dist/chunks/{globals-YCJ2DGWC.js → globals-H2WF344Y.js} +2 -2
- package/dist/chunks/{init-WGKQVAZE.js → init-HU5OMHEH.js} +1 -1
- package/dist/chunks/input-repl-ZBH6FVPV.js +87 -0
- package/dist/chunks/{install-BCTBOPBS.js → install-RRLUOYFO.js} +6 -6
- package/dist/chunks/intro-4CICBP2J.js +2727 -0
- package/dist/chunks/{kill-LWRXZVM5.js → kill-2UG7PHUV.js} +4 -10
- package/dist/chunks/list-4X3JFQGS.js +41 -0
- package/dist/chunks/{list-ZBYPMUID.js → list-7VHJIUDX.js} +2 -2
- package/dist/chunks/list-A5WVDBWF.js +53 -0
- package/dist/chunks/{list-NGOCMJXE.js → list-CK5X2YN3.js} +5 -4
- package/dist/chunks/{list-TTKLNJKI.js → list-FLAYJQKN.js} +2 -2
- package/dist/chunks/list-PTAWQYWG.js +35 -0
- package/dist/chunks/list-U7PAYNAH.js +47 -0
- package/dist/chunks/{list-OTOMCFLA.js → list-WH7KESMV.js} +12 -11
- package/dist/chunks/{query-NY4SCO77.js → query-AW7WYILM.js} +5 -9
- package/dist/chunks/{registry-W5XFI5T6.js → registry-3QIL5SVL.js} +2 -2
- package/dist/chunks/{remove-WEAZFZCO.js → remove-QUH2D3S5.js} +2 -2
- package/dist/chunks/repl-STBZC4P2.js +180 -0
- package/dist/chunks/repl-VGC5FUJG.js +378 -0
- package/dist/chunks/resolver-QMIY33FM.js +26 -0
- package/dist/chunks/run-T33CMCFZ.js +26 -0
- package/dist/chunks/{run-J2A5YTTY.js → run-Y4TG3EM3.js} +22 -3
- package/dist/chunks/rune-UBRVWG5A.js +139 -0
- package/dist/chunks/{search-XENXL3GC.js → search-MSSDGJTF.js} +2 -2
- package/dist/chunks/{uninstall-MX5PLGDI.js → uninstall-55YTHZRH.js} +5 -5
- package/dist/chunks/unset-YASSMSE5.js +24 -0
- package/dist/chunks/{update-7XDTVFZ3.js → update-EWWDROKW.js} +2 -2
- package/dist/chunks/{update-IEE54GPY.js → update-G6XO4RIM.js} +6 -6
- package/dist/chunks/{utils-JKGIWZTS.js → utils-XOWJQWNR.js} +2 -2
- package/dist/chunks/{version-OPTLR63W.js → version-W7MA4ZCA.js} +9 -4
- package/dist/cli.js +114 -81
- package/package.json +8 -3
- package/dist/chunks/benchmark-ATSRQIDC.js +0 -164
- package/dist/chunks/check-G72VZKIP.js +0 -144
- package/dist/chunks/chunk-3TM6B4E5.js +0 -70
- package/dist/chunks/chunk-XXUNHQIB.js +0 -129
- package/dist/chunks/intro-QVSLNH4R.js +0 -1510
- package/dist/chunks/list-5DVVP7HX.js +0 -50
- package/dist/chunks/list-6WL5LGIZ.js +0 -80
- package/dist/chunks/list-YPI7YDKK.js +0 -80
- package/dist/chunks/run-AUAGELWL.js +0 -23
- package/dist/chunks/rune-ZYEVEYID.js +0 -87
- package/dist/chunks/unset-KQOZYVTE.js +0 -28
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runRune
|
|
3
|
-
} from "./chunk-6I7RHSAA.js";
|
|
4
|
-
import "./chunk-67I2J474.js";
|
|
5
|
-
import "./chunk-XXUNHQIB.js";
|
|
6
|
-
import "./chunk-NXSDVVTW.js";
|
|
7
|
-
import "./chunk-QMWGQXEZ.js";
|
|
8
|
-
import "./chunk-3TM6B4E5.js";
|
|
9
|
-
import {
|
|
10
|
-
loadConfig
|
|
11
|
-
} from "./chunk-H3BVJCIL.js";
|
|
12
|
-
import {
|
|
13
|
-
output
|
|
14
|
-
} from "./chunk-6XLT25GS.js";
|
|
15
|
-
import "./chunk-WCODTMDN.js";
|
|
16
|
-
import "./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/rune/commands/check.js
|
|
24
|
-
init_require_shim();
|
|
25
|
-
import { readFileSync } from "node:fs";
|
|
26
|
-
import { join } from "node:path";
|
|
27
|
-
function scanPermissionWarnings(runeSource) {
|
|
28
|
-
const warnings = [];
|
|
29
|
-
const GATED_UTILS = ["utils.fs", "utils.shell", "utils.fetch", "utils.env", "utils.archive", "utils.cache"];
|
|
30
|
-
for (const u of GATED_UTILS) {
|
|
31
|
-
if (runeSource.includes(u)) {
|
|
32
|
-
warnings.push(u);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const importRegex = /import\s*\{\s*([^}]+)\s*\}\s*from\s*['"]@utils['"]/g;
|
|
36
|
-
let match;
|
|
37
|
-
const importedNames = /* @__PURE__ */ new Set();
|
|
38
|
-
while ((match = importRegex.exec(runeSource)) !== null) {
|
|
39
|
-
const names = match[1].split(",").map((n) => n.trim().split(/\s+as\s+/)[0]);
|
|
40
|
-
for (const name of names) {
|
|
41
|
-
if (name) importedNames.add(name);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const namespaces = ["fs", "shell", "fetch", "env", "archive", "cache"];
|
|
45
|
-
for (const ns of namespaces) {
|
|
46
|
-
if (importedNames.has(ns)) {
|
|
47
|
-
const warningKey = `utils.${ns}`;
|
|
48
|
-
if (!warnings.includes(warningKey)) {
|
|
49
|
-
warnings.push(warningKey);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return warnings;
|
|
54
|
-
}
|
|
55
|
-
var KEBAB_RE = /^[a-z0-9-]+$/;
|
|
56
|
-
function checkSections(sections) {
|
|
57
|
-
const errors = [];
|
|
58
|
-
if (!Array.isArray(sections)) {
|
|
59
|
-
errors.push({ section: null, message: "use() must return an array" });
|
|
60
|
-
return errors;
|
|
61
|
-
}
|
|
62
|
-
const seen = /* @__PURE__ */ new Set();
|
|
63
|
-
for (const sec of sections) {
|
|
64
|
-
const name = sec?.name;
|
|
65
|
-
if (typeof name !== "string" || name.length === 0) {
|
|
66
|
-
errors.push({ section: null, message: "section is missing a non-empty name" });
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
if (!KEBAB_RE.test(name)) {
|
|
70
|
-
errors.push({ section: name, message: `section "${name}" must be kebab-case (a-z, 0-9, -)` });
|
|
71
|
-
}
|
|
72
|
-
if (seen.has(name)) {
|
|
73
|
-
errors.push({ section: name, message: `duplicate section name "${name}"` });
|
|
74
|
-
}
|
|
75
|
-
seen.add(name);
|
|
76
|
-
if (sec.data == null) {
|
|
77
|
-
errors.push({ section: name, message: `section "${name}" is missing data` });
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const { type } = sec.data;
|
|
81
|
-
if (type !== "markdown" && type !== "tree") {
|
|
82
|
-
errors.push({ section: name, message: `section "${name}" has unknown type "${type ?? "undefined"}"` });
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (type === "markdown") {
|
|
86
|
-
if (typeof sec.data.content !== "string" || sec.data.content.length === 0) {
|
|
87
|
-
errors.push({ section: name, message: `section "${name}" markdown content must be a non-empty string` });
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (type === "tree") {
|
|
91
|
-
const root = sec.data.root;
|
|
92
|
-
if (!root || typeof root.name === "undefined" || !Array.isArray(root.children)) {
|
|
93
|
-
errors.push({ section: name, message: `section "${name}" tree root must have name and children` });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return errors;
|
|
98
|
-
}
|
|
99
|
-
async function handler({ key, runeArgs = [], sections = null, projectRoot = process.cwd(), configRoot = projectRoot } = {}) {
|
|
100
|
-
let config;
|
|
101
|
-
try {
|
|
102
|
-
config = loadConfig(configRoot);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
output.error(`Config unreadable: ${err.message}`);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
const entry = config.runes?.[key];
|
|
108
|
-
if (entry?.path && !entry.permissions?.allow?.length) {
|
|
109
|
-
let src = "";
|
|
110
|
-
try {
|
|
111
|
-
src = readFileSync(join(configRoot, entry.path), "utf8");
|
|
112
|
-
} catch {
|
|
113
|
-
}
|
|
114
|
-
for (const util of scanPermissionWarnings(src)) {
|
|
115
|
-
output.warn(`${key} \u2014 permissions.allow is empty but rune uses ${util}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
let result;
|
|
119
|
-
try {
|
|
120
|
-
result = await runRune(projectRoot, config, key, runeArgs, { configDir: configRoot });
|
|
121
|
-
} catch (err) {
|
|
122
|
-
output.error(`${key}: ${err.message}`);
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
if (!result) {
|
|
126
|
-
output.error(`${key}: rune not found`);
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
const errors = checkSections(result);
|
|
130
|
-
if (errors.length === 0) {
|
|
131
|
-
output.success(`${key} \u2014 ${result.length} section${result.length === 1 ? "" : "s"}`);
|
|
132
|
-
} else {
|
|
133
|
-
for (const { message } of errors) {
|
|
134
|
-
output.error(`${key} \u2014 ${message}`);
|
|
135
|
-
}
|
|
136
|
-
console.log(`
|
|
137
|
-
${errors.length} problem${errors.length === 1 ? "" : "s"} found.`);
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
handler,
|
|
143
|
-
scanPermissionWarnings
|
|
144
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getProjectsJsonPath
|
|
3
|
-
} from "./chunk-HMU2J25D.js";
|
|
4
|
-
import {
|
|
5
|
-
init_require_shim
|
|
6
|
-
} from "./chunk-TPK5AGRA.js";
|
|
7
|
-
|
|
8
|
-
// src/project/index.js
|
|
9
|
-
init_require_shim();
|
|
10
|
-
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
11
|
-
import { dirname } from "node:path";
|
|
12
|
-
import { createHash } from "node:crypto";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
function shortHash(str) {
|
|
15
|
-
return createHash("sha1").update(str).digest("hex").slice(0, 8);
|
|
16
|
-
}
|
|
17
|
-
async function ensureProjectIdentity(dir) {
|
|
18
|
-
const localJsonPath = path.join(dir, ".crunes", "project.local.json");
|
|
19
|
-
try {
|
|
20
|
-
const raw = await readFile(localJsonPath, "utf8");
|
|
21
|
-
return JSON.parse(raw);
|
|
22
|
-
} catch {
|
|
23
|
-
}
|
|
24
|
-
let alias = path.basename(dir);
|
|
25
|
-
try {
|
|
26
|
-
const config = JSON.parse(await readFile(path.join(dir, ".crunes", "config.json"), "utf8"));
|
|
27
|
-
if (typeof config.name === "string" && config.name.length > 0) alias = config.name;
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
const id = `${path.basename(dir).slice(0, 15)}-${shortHash(dir + "-" + Math.random())}`;
|
|
31
|
-
const identity = { id, alias };
|
|
32
|
-
await mkdir(path.join(dir, ".crunes"), { recursive: true });
|
|
33
|
-
await writeFile(localJsonPath, JSON.stringify(identity, null, 2), "utf8");
|
|
34
|
-
return identity;
|
|
35
|
-
}
|
|
36
|
-
async function loadProjects() {
|
|
37
|
-
try {
|
|
38
|
-
const raw = await readFile(getProjectsJsonPath(), "utf8");
|
|
39
|
-
return JSON.parse(raw);
|
|
40
|
-
} catch {
|
|
41
|
-
return { format: "1", projects: {} };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function upsertProject(id, projectDir) {
|
|
45
|
-
const data = await loadProjects();
|
|
46
|
-
let alias = path.basename(projectDir);
|
|
47
|
-
try {
|
|
48
|
-
const raw = await readFile(path.join(projectDir, ".crunes", "project.local.json"), "utf8");
|
|
49
|
-
const parsed = JSON.parse(raw);
|
|
50
|
-
if (typeof parsed.alias === "string" && parsed.alias.length > 0) alias = parsed.alias;
|
|
51
|
-
} catch {
|
|
52
|
-
}
|
|
53
|
-
const existing = data.projects[id];
|
|
54
|
-
data.projects[id] = {
|
|
55
|
-
path: projectDir,
|
|
56
|
-
alias,
|
|
57
|
-
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
58
|
-
firstSeenAt: existing?.firstSeenAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
59
|
-
};
|
|
60
|
-
const p = getProjectsJsonPath();
|
|
61
|
-
await mkdir(dirname(p), { recursive: true });
|
|
62
|
-
await writeFile(p, JSON.stringify(data, null, 2), "utf8");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export {
|
|
66
|
-
shortHash,
|
|
67
|
-
ensureProjectIdentity,
|
|
68
|
-
loadProjects,
|
|
69
|
-
upsertProject
|
|
70
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ensureProjectIdentity,
|
|
3
|
-
upsertProject
|
|
4
|
-
} from "./chunk-3TM6B4E5.js";
|
|
5
|
-
import {
|
|
6
|
-
getStorePath
|
|
7
|
-
} from "./chunk-HMU2J25D.js";
|
|
8
|
-
import {
|
|
9
|
-
init_require_shim
|
|
10
|
-
} from "./chunk-TPK5AGRA.js";
|
|
11
|
-
|
|
12
|
-
// src/job/registry.js
|
|
13
|
-
init_require_shim();
|
|
14
|
-
import { readFile, writeFile, mkdir, readdir, rm } from "node:fs/promises";
|
|
15
|
-
import { join } from "node:path";
|
|
16
|
-
import { randomUUID } from "node:crypto";
|
|
17
|
-
function jobsBase() {
|
|
18
|
-
return join(getStorePath(), "jobs");
|
|
19
|
-
}
|
|
20
|
-
function projectJobsDir(key) {
|
|
21
|
-
return join(jobsBase(), "project", key);
|
|
22
|
-
}
|
|
23
|
-
function jobPath(key, id) {
|
|
24
|
-
return join(projectJobsDir(key), `${id}.json`);
|
|
25
|
-
}
|
|
26
|
-
function jobStdoutPath(key, id) {
|
|
27
|
-
return join(projectJobsDir(key), `${id}.stdout.log`);
|
|
28
|
-
}
|
|
29
|
-
function jobStderrPath(key, id) {
|
|
30
|
-
return join(projectJobsDir(key), `${id}.stderr.log`);
|
|
31
|
-
}
|
|
32
|
-
async function updateJobPid(key, id, pid) {
|
|
33
|
-
const record = await getJob(key, id);
|
|
34
|
-
if (!record) return;
|
|
35
|
-
record.pid = pid;
|
|
36
|
-
await writeFile(jobPath(key, id), JSON.stringify(record, null, 2), "utf8");
|
|
37
|
-
}
|
|
38
|
-
async function createJob(pid, { type = "rune", spawnedBy, runeKey, projectDir, args = [] } = {}) {
|
|
39
|
-
const { id: key } = await ensureProjectIdentity(projectDir);
|
|
40
|
-
const id = randomUUID();
|
|
41
|
-
const record = { id, type, pid, startedAt: (/* @__PURE__ */ new Date()).toISOString(), projectKey: key, projectDir, spawnedBy, runeKey, args };
|
|
42
|
-
await mkdir(projectJobsDir(key), { recursive: true });
|
|
43
|
-
await writeFile(jobPath(key, id), JSON.stringify(record, null, 2), "utf8");
|
|
44
|
-
await upsertProject(key, projectDir);
|
|
45
|
-
return { id, projectKey: key };
|
|
46
|
-
}
|
|
47
|
-
async function getJob(key, id) {
|
|
48
|
-
try {
|
|
49
|
-
const raw = await readFile(jobPath(key, id), "utf8");
|
|
50
|
-
return JSON.parse(raw);
|
|
51
|
-
} catch {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async function listJobs(key) {
|
|
56
|
-
if (key) {
|
|
57
|
-
let files;
|
|
58
|
-
try {
|
|
59
|
-
files = await readdir(projectJobsDir(key));
|
|
60
|
-
} catch {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
const records = await Promise.all(
|
|
64
|
-
files.filter((f) => f.endsWith(".json")).map((f) => getJob(key, f.slice(0, -5)))
|
|
65
|
-
);
|
|
66
|
-
return records.filter(Boolean);
|
|
67
|
-
}
|
|
68
|
-
let keys;
|
|
69
|
-
try {
|
|
70
|
-
keys = await readdir(join(jobsBase(), "project"));
|
|
71
|
-
} catch {
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
const all = await Promise.all(keys.map((k) => listJobs(k)));
|
|
75
|
-
return all.flat();
|
|
76
|
-
}
|
|
77
|
-
async function deleteJob(key, id) {
|
|
78
|
-
await rm(jobPath(key, id), { force: true });
|
|
79
|
-
}
|
|
80
|
-
async function cleanJobs(key) {
|
|
81
|
-
const dir = key ? projectJobsDir(key) : join(jobsBase(), "project");
|
|
82
|
-
let entries;
|
|
83
|
-
try {
|
|
84
|
-
entries = await readdir(dir);
|
|
85
|
-
} catch {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (key) {
|
|
89
|
-
await Promise.all(
|
|
90
|
-
entries.filter((f) => f.endsWith(".json")).map(async (f) => {
|
|
91
|
-
const id = f.slice(0, -5);
|
|
92
|
-
const record = await getJob(key, id);
|
|
93
|
-
if (!record) return;
|
|
94
|
-
if (!isAlive(record.pid)) await rm(jobPath(key, id), { force: true });
|
|
95
|
-
})
|
|
96
|
-
);
|
|
97
|
-
} else {
|
|
98
|
-
await Promise.all(entries.map((k) => cleanJobs(k)));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function resolveJobId(id, jobs) {
|
|
102
|
-
const exact = jobs.find((j) => j.id === id);
|
|
103
|
-
if (exact) return exact.id;
|
|
104
|
-
const matches = jobs.filter((j) => j.id.startsWith(id));
|
|
105
|
-
if (matches.length === 1) return matches[0].id;
|
|
106
|
-
if (matches.length === 0) throw new Error(`No job matching "${id}".`);
|
|
107
|
-
throw new Error(`Ambiguous id "${id}" \u2014 matches: ${matches.map((j) => j.id).join(", ")}.`);
|
|
108
|
-
}
|
|
109
|
-
function isAlive(pid) {
|
|
110
|
-
try {
|
|
111
|
-
process.kill(pid, 0);
|
|
112
|
-
return true;
|
|
113
|
-
} catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export {
|
|
119
|
-
jobStdoutPath,
|
|
120
|
-
jobStderrPath,
|
|
121
|
-
updateJobPid,
|
|
122
|
-
createJob,
|
|
123
|
-
getJob,
|
|
124
|
-
listJobs,
|
|
125
|
-
deleteJob,
|
|
126
|
-
cleanJobs,
|
|
127
|
-
resolveJobId,
|
|
128
|
-
isAlive
|
|
129
|
-
};
|