@orkestrel/probe 0.0.14 → 0.0.16
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/src/server/index.cjs +37 -37
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +38 -38
- package/dist/src/server/index.js.map +1 -1
- package/package.json +10 -10
|
@@ -61,11 +61,11 @@ function normalizePath(path) {
|
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
function readFaultCode(error) {
|
|
64
|
-
if (
|
|
64
|
+
if (!(0, _orkestrel_contract.isObject)(error)) return void 0;
|
|
65
65
|
const fault = error;
|
|
66
66
|
const reading = (0, _orkestrel_contract.attempt)(() => "code" in fault ? fault.code : void 0);
|
|
67
67
|
if (!reading.success) return void 0;
|
|
68
|
-
return
|
|
68
|
+
return (0, _orkestrel_contract.isString)(reading.value) ? reading.value : void 0;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Reports whether one path resolves outside the root it is read against.
|
|
@@ -152,7 +152,7 @@ function resolveWorkspaceFile(workspace, target, mutate = false) {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
} catch (error) {
|
|
155
|
-
if (
|
|
155
|
+
if ((0, _src_core.isProbeError)(error)) throw error;
|
|
156
156
|
const code = readFaultCode(error);
|
|
157
157
|
const claimant = code === "ENAMETOOLONG" || code === "ERR_INVALID_ARG_VALUE";
|
|
158
158
|
throw new _src_core.ProbeError(`The workspace path cannot be inspected: ${target}`, {
|
|
@@ -460,7 +460,7 @@ function readWorkspaceManifest(workspace, name) {
|
|
|
460
460
|
try {
|
|
461
461
|
path = resolveWorkspaceModule(workspace, `${name}/package.json`);
|
|
462
462
|
} catch (error) {
|
|
463
|
-
if (!(
|
|
463
|
+
if (!(0, _src_core.isProbeError)(error)) throw error;
|
|
464
464
|
throw new _src_core.ProbeError(`${name} does not publish a readable manifest`, {
|
|
465
465
|
origin: "workspace",
|
|
466
466
|
code: error.code,
|
|
@@ -537,14 +537,14 @@ function resolveWorkspaceBinary(workspace, name, command = name) {
|
|
|
537
537
|
code: "missing",
|
|
538
538
|
context: { name }
|
|
539
539
|
});
|
|
540
|
-
if (
|
|
540
|
+
if ((0, _orkestrel_contract.isString)(bin)) return (0, node_path.resolve)(manifest.path, "..", bin);
|
|
541
541
|
if (!(0, _orkestrel_contract.isRecord)(bin) || !(command in bin)) throw new _src_core.ProbeError(`${name} does not publish the ${command} binary`, {
|
|
542
542
|
origin: "workspace",
|
|
543
543
|
code: "missing",
|
|
544
544
|
context: { name }
|
|
545
545
|
});
|
|
546
546
|
const entry = bin[command];
|
|
547
|
-
if (
|
|
547
|
+
if (!(0, _orkestrel_contract.isString)(entry)) throw new _src_core.ProbeError(`${name} publishes an invalid ${command} binary`, {
|
|
548
548
|
origin: "workspace",
|
|
549
549
|
code: "malformed",
|
|
550
550
|
context: {
|
|
@@ -711,7 +711,7 @@ function matchesWorkspaceModule(path) {
|
|
|
711
711
|
* ```
|
|
712
712
|
*/
|
|
713
713
|
function matchesLiveProcess(id) {
|
|
714
|
-
if (!Number.isSafeInteger(id) || id <= 0) return true;
|
|
714
|
+
if (!(0, _orkestrel_contract.isNumber)(id) || !Number.isSafeInteger(id) || id <= 0) return true;
|
|
715
715
|
try {
|
|
716
716
|
process.kill(id, 0);
|
|
717
717
|
return true;
|
|
@@ -775,8 +775,8 @@ function collectWorkspaceFiles(workspace) {
|
|
|
775
775
|
* ```
|
|
776
776
|
*/
|
|
777
777
|
function describeUnknown(value) {
|
|
778
|
-
if (
|
|
779
|
-
if (
|
|
778
|
+
if ((0, _orkestrel_contract.isError)(value)) return value.message;
|
|
779
|
+
if ((0, _orkestrel_contract.isObject)(value) && "message" in value && (0, _orkestrel_contract.isString)(value.message)) return value.message;
|
|
780
780
|
return String(value);
|
|
781
781
|
}
|
|
782
782
|
/**
|
|
@@ -796,7 +796,7 @@ async function guardStage(stage, operation) {
|
|
|
796
796
|
try {
|
|
797
797
|
return await operation;
|
|
798
798
|
} catch (error) {
|
|
799
|
-
if (
|
|
799
|
+
if ((0, _src_core.isProbeError)(error)) throw error;
|
|
800
800
|
throw new _src_core.ProbeError(`The ${stage} stage could not serve (${describeUnknown(error)})`, {
|
|
801
801
|
origin: "instrument",
|
|
802
802
|
code: "malformed",
|
|
@@ -873,7 +873,7 @@ function findRefusedPaths(value) {
|
|
|
873
873
|
*/
|
|
874
874
|
function normalizeValue(workspace, value) {
|
|
875
875
|
const root = (0, node_path.resolve)(workspace);
|
|
876
|
-
if (
|
|
876
|
+
if ((0, _orkestrel_contract.isString)(value)) {
|
|
877
877
|
if (!(0, node_path.isAbsolute)(value)) return value;
|
|
878
878
|
const path = (0, node_path.relative)(root, (0, node_path.resolve)(value));
|
|
879
879
|
if (path === "") return ".";
|
|
@@ -983,14 +983,14 @@ function releaseListeners(emitter, capture) {
|
|
|
983
983
|
* ```
|
|
984
984
|
*/
|
|
985
985
|
function parseProjectConfig(text) {
|
|
986
|
-
const parsed = (0, _orkestrel_contract.
|
|
987
|
-
if (!
|
|
988
|
-
const files = parsed.
|
|
989
|
-
const include = parsed.
|
|
986
|
+
const parsed = (0, _orkestrel_contract.parseJSON)(text);
|
|
987
|
+
if (!(0, _orkestrel_contract.isRecord)(parsed)) return void 0;
|
|
988
|
+
const files = parsed.files;
|
|
989
|
+
const include = parsed.include;
|
|
990
990
|
return {
|
|
991
|
-
compilerOptions: parsed.
|
|
992
|
-
...(0, _orkestrel_contract.isArray)(files) && files.every(
|
|
993
|
-
...(0, _orkestrel_contract.isArray)(include) && include.every(
|
|
991
|
+
compilerOptions: parsed.compilerOptions,
|
|
992
|
+
...(0, _orkestrel_contract.isArray)(files) && files.every(_orkestrel_contract.isString) ? { files } : {},
|
|
993
|
+
...(0, _orkestrel_contract.isArray)(include) && include.every(_orkestrel_contract.isString) ? { include } : {}
|
|
994
994
|
};
|
|
995
995
|
}
|
|
996
996
|
/**
|
|
@@ -1104,7 +1104,7 @@ var Overlay = class {
|
|
|
1104
1104
|
};
|
|
1105
1105
|
//#endregion
|
|
1106
1106
|
//#region package.json
|
|
1107
|
-
var version = "0.0.
|
|
1107
|
+
var version = "0.0.16";
|
|
1108
1108
|
var peerDependencies = {
|
|
1109
1109
|
"oxlint": "^1.82.0",
|
|
1110
1110
|
"typescript": "^6.0.3",
|
|
@@ -1279,7 +1279,7 @@ var LintStage = class {
|
|
|
1279
1279
|
if (this.#closing !== void 0) return (0, _src_core.createDestroyedError)("lint stage");
|
|
1280
1280
|
const ending = this.#ending;
|
|
1281
1281
|
if (ending !== void 0) return this.#fault(`The Oxlint language server exited with ${ending}`, error, path);
|
|
1282
|
-
if (
|
|
1282
|
+
if ((0, _orkestrel_contract.isError)(error)) return error;
|
|
1283
1283
|
return this.#fault(describeUnknown(error), error, path);
|
|
1284
1284
|
}
|
|
1285
1285
|
#fault(message, cause, path) {
|
|
@@ -1450,7 +1450,7 @@ var RuntimeStage = class {
|
|
|
1450
1450
|
for (const draft of subject.files) overlay.set(resolveWorkspaceFile(this.#workspace, draft.path), draft.text);
|
|
1451
1451
|
this.#revalidate(vitest);
|
|
1452
1452
|
const specification = this.#specification(subject.test);
|
|
1453
|
-
if (
|
|
1453
|
+
if (!(0, _orkestrel_contract.isString)(specification)) return {
|
|
1454
1454
|
stage: this.stage,
|
|
1455
1455
|
elapsed: Math.round(performance.now() - started),
|
|
1456
1456
|
issues: [specification]
|
|
@@ -1467,7 +1467,7 @@ var RuntimeStage = class {
|
|
|
1467
1467
|
const result = await vitest.runTestSpecifications([task], false);
|
|
1468
1468
|
issues = [...this.#issues(result, file, subject.test.path), ...this.#misses(project, file)];
|
|
1469
1469
|
} catch (error) {
|
|
1470
|
-
if (
|
|
1470
|
+
if ((0, _src_core.isProbeError)(error)) throw error;
|
|
1471
1471
|
throw new _src_core.ProbeError(`The runtime stage could not run the generated specification (${describeUnknown(error)})`, {
|
|
1472
1472
|
origin: "instrument",
|
|
1473
1473
|
code: "malformed",
|
|
@@ -1488,7 +1488,7 @@ var RuntimeStage = class {
|
|
|
1488
1488
|
if ((0, node_fs.existsSync)(contained)) (0, node_fs.unlinkSync)(contained);
|
|
1489
1489
|
} catch (error) {
|
|
1490
1490
|
cleanup = [...cleanup, {
|
|
1491
|
-
origin:
|
|
1491
|
+
origin: (0, _src_core.isProbeError)(error) && error.origin === "workspace" ? "workspace" : "instrument",
|
|
1492
1492
|
path: relativeWorkspaceFile(this.#workspace, file),
|
|
1493
1493
|
message: `The runtime stage could not delete the generated specification (${describeUnknown(error)})`
|
|
1494
1494
|
}];
|
|
@@ -1567,7 +1567,7 @@ var RuntimeStage = class {
|
|
|
1567
1567
|
test.projects = test.projects.map((project) => this.#augment(project));
|
|
1568
1568
|
}
|
|
1569
1569
|
#augment(project) {
|
|
1570
|
-
if (
|
|
1570
|
+
if ((0, _orkestrel_contract.isString)(project)) return project;
|
|
1571
1571
|
if (typeof project === "function") return this.#wrap(project);
|
|
1572
1572
|
return Promise.resolve(project).then(this.#instrument.bind(this));
|
|
1573
1573
|
}
|
|
@@ -1635,7 +1635,7 @@ var RuntimeStage = class {
|
|
|
1635
1635
|
return file;
|
|
1636
1636
|
});
|
|
1637
1637
|
if (outcome.success) return outcome.value;
|
|
1638
|
-
if (outcome.error
|
|
1638
|
+
if ((0, _src_core.isProbeError)(outcome.error) && outcome.error.origin === "claimant") throw new _src_core.ProbeError(outcome.error.message, {
|
|
1639
1639
|
origin: outcome.error.origin,
|
|
1640
1640
|
code: outcome.error.code,
|
|
1641
1641
|
context: {
|
|
@@ -1654,7 +1654,7 @@ var RuntimeStage = class {
|
|
|
1654
1654
|
cause: outcome.error
|
|
1655
1655
|
});
|
|
1656
1656
|
return {
|
|
1657
|
-
origin: outcome.error
|
|
1657
|
+
origin: (0, _src_core.isProbeError)(outcome.error) && outcome.error.origin === "workspace" || creating ? "workspace" : "instrument",
|
|
1658
1658
|
path: test.path,
|
|
1659
1659
|
message: `The runtime stage could not write the generated specification (${describeUnknown(outcome.error)})`
|
|
1660
1660
|
};
|
|
@@ -1914,29 +1914,29 @@ var RuntimeStage = class {
|
|
|
1914
1914
|
}
|
|
1915
1915
|
#issue(error, specification, original) {
|
|
1916
1916
|
const message = relativeWorkspaceMessage(this.#workspace, describeUnknown(error)).replaceAll((0, node_path.basename)(specification), (0, node_path.basename)(original));
|
|
1917
|
-
if (
|
|
1917
|
+
if (!(0, _orkestrel_contract.isObject)(error) || !("stacks" in error)) return {
|
|
1918
1918
|
origin: "claimant",
|
|
1919
1919
|
path: original,
|
|
1920
1920
|
message
|
|
1921
1921
|
};
|
|
1922
1922
|
const stacks = error.stacks;
|
|
1923
|
-
if (!
|
|
1923
|
+
if (!(0, _orkestrel_contract.isArray)(stacks)) return {
|
|
1924
1924
|
origin: "claimant",
|
|
1925
1925
|
path: original,
|
|
1926
1926
|
message
|
|
1927
1927
|
};
|
|
1928
1928
|
for (const stack of stacks) {
|
|
1929
|
-
if (
|
|
1930
|
-
if (!("file" in stack) ||
|
|
1929
|
+
if (!(0, _orkestrel_contract.isObject)(stack)) continue;
|
|
1930
|
+
if (!("file" in stack) || !(0, _orkestrel_contract.isString)(stack.file)) continue;
|
|
1931
1931
|
const declared = stack.file.startsWith("file:") ? (0, node_url.fileURLToPath)(stack.file) : (0, node_path.isAbsolute)(stack.file) ? stack.file : (0, node_path.resolve)(this.#workspace, stack.file);
|
|
1932
1932
|
const reported = this.#real(declared);
|
|
1933
1933
|
const path = reported === specification ? original : relativeWorkspaceFile(this.#real(this.#workspace), reported);
|
|
1934
|
-
if (!("line" in stack) ||
|
|
1934
|
+
if (!("line" in stack) || !(0, _orkestrel_contract.isNumber)(stack.line)) return {
|
|
1935
1935
|
origin: "claimant",
|
|
1936
1936
|
path,
|
|
1937
1937
|
message
|
|
1938
1938
|
};
|
|
1939
|
-
const character = "column" in stack &&
|
|
1939
|
+
const character = "column" in stack && (0, _orkestrel_contract.isNumber)(stack.column) ? stack.column - 1 : 0;
|
|
1940
1940
|
const position = {
|
|
1941
1941
|
line: stack.line - 1,
|
|
1942
1942
|
character
|
|
@@ -2582,7 +2582,7 @@ var Probe = class {
|
|
|
2582
2582
|
this.#emitter.emit("prove", verdict);
|
|
2583
2583
|
return verdict;
|
|
2584
2584
|
} catch (error) {
|
|
2585
|
-
if (!(
|
|
2585
|
+
if (!(0, _src_core.isProbeError)(error) || !this.#surfaced.has(error)) this.#emitter.emit("error", error);
|
|
2586
2586
|
throw error;
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
@@ -2627,7 +2627,7 @@ var Probe = class {
|
|
|
2627
2627
|
this.#emitter.emit("arm", this.#toolchain);
|
|
2628
2628
|
}
|
|
2629
2629
|
#surface(error) {
|
|
2630
|
-
if (
|
|
2630
|
+
if ((0, _src_core.isProbeError)(error)) this.#surfaced.add(error);
|
|
2631
2631
|
this.#emitter.emit("error", error);
|
|
2632
2632
|
}
|
|
2633
2633
|
#workbench() {
|
|
@@ -2637,7 +2637,7 @@ var Probe = class {
|
|
|
2637
2637
|
try {
|
|
2638
2638
|
(0, node_fs.mkdirSync)(resolveWorkspaceFile(this.#workspace, path, true), { recursive: true });
|
|
2639
2639
|
} catch (error) {
|
|
2640
|
-
const code =
|
|
2640
|
+
const code = (0, _src_core.isProbeError)(error) && error.origin === "workspace" ? error.code : "malformed";
|
|
2641
2641
|
throw new _src_core.ProbeError(`The probe could not create the boot workbench (${describeUnknown(error)})`, {
|
|
2642
2642
|
origin: "workspace",
|
|
2643
2643
|
code,
|
|
@@ -2873,12 +2873,12 @@ var Probe = class {
|
|
|
2873
2873
|
try {
|
|
2874
2874
|
await this.#bound(() => stage.destroy(), `The ${stage.stage} stage teardown exceeded ${this.#deadline} ms`, stage, stage.progress);
|
|
2875
2875
|
} catch (error) {
|
|
2876
|
-
if (!(
|
|
2876
|
+
if (!(0, _src_core.isProbeError)(error) || !this.#deadlines.has(error)) throw error;
|
|
2877
2877
|
}
|
|
2878
2878
|
}
|
|
2879
2879
|
#version(name) {
|
|
2880
2880
|
const version = readWorkspaceManifest(this.#workspace, name).contents.version;
|
|
2881
|
-
if (
|
|
2881
|
+
if (!(0, _orkestrel_contract.isString)(version)) throw new _src_core.ProbeError(`${name} publishes no readable version`, {
|
|
2882
2882
|
origin: "workspace",
|
|
2883
2883
|
code: "malformed",
|
|
2884
2884
|
context: { name }
|