@orkestrel/guide 0.0.19 → 0.0.21
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/core/index.cjs +1 -1
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.js +1 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +9 -10
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +10 -11
- package/dist/src/server/index.js.map +1 -1
- package/package.json +11 -11
package/dist/src/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { arrayOf, isArray, isEmptyString, isFunction, isNonEmptyArray, isNonEmptyString, isObject, isRecord, isString, literalOf,
|
|
1
|
+
import { arrayOf, isArray, isEmptyString, isError, isFiniteNumber, isFunction, isInstance, isNonEmptyArray, isNonEmptyString, isObject, isRecord, isString, literalOf, parseEnum, parseJSONAs, recordOf, unionOf } from "@orkestrel/contract";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { globSync, writeFileSync } from "node:fs";
|
|
@@ -68,7 +68,7 @@ function matchesGuideResult(result) {
|
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
function resolveGuideRoot(root) {
|
|
71
|
-
return resolve(root
|
|
71
|
+
return resolve(isInstance(root, URL) ? fileURLToPath(root) : root);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Selects the indexed guide matching a package's bare name.
|
|
@@ -102,8 +102,7 @@ function selectGuidePitch(entries, name) {
|
|
|
102
102
|
*/
|
|
103
103
|
function parseGuideDirection(args) {
|
|
104
104
|
if (args.length !== 2 || args[0] !== "--to") return void 0;
|
|
105
|
-
|
|
106
|
-
return direction === "guide" || direction === "source" ? direction : void 0;
|
|
105
|
+
return parseEnum(args[1], ["guide", "source"]);
|
|
107
106
|
}
|
|
108
107
|
/**
|
|
109
108
|
* Reads the bare package name from package manifest JSON.
|
|
@@ -117,10 +116,10 @@ function parseGuideDirection(args) {
|
|
|
117
116
|
* ```
|
|
118
117
|
*/
|
|
119
118
|
function parsePackageName(manifest) {
|
|
120
|
-
const parsed =
|
|
121
|
-
if (
|
|
119
|
+
const parsed = parseJSONAs(manifest, isRecord);
|
|
120
|
+
if (parsed === void 0) return void 0;
|
|
122
121
|
const name = parsed.name;
|
|
123
|
-
if (
|
|
122
|
+
if (!isNonEmptyString(name)) return void 0;
|
|
124
123
|
return name.slice(name.lastIndexOf("/") + 1);
|
|
125
124
|
}
|
|
126
125
|
//#endregion
|
|
@@ -773,7 +772,7 @@ function hasCanonicalSegments(key) {
|
|
|
773
772
|
function normalizeDirectories(module) {
|
|
774
773
|
const directories = [];
|
|
775
774
|
const seen = /* @__PURE__ */ new Set();
|
|
776
|
-
for (const value of
|
|
775
|
+
for (const value of isString(module) ? [module] : module) {
|
|
777
776
|
const directory = resolvePath(".", value);
|
|
778
777
|
if (seen.has(directory)) continue;
|
|
779
778
|
seen.add(directory);
|
|
@@ -3712,7 +3711,7 @@ var GuideCommand = class {
|
|
|
3712
3711
|
try {
|
|
3713
3712
|
await this.#executeNative();
|
|
3714
3713
|
} catch (error) {
|
|
3715
|
-
process.stderr.write(`${error
|
|
3714
|
+
process.stderr.write(`${isError(error) ? error.message : String(error)}\n`);
|
|
3716
3715
|
this.#raise(1);
|
|
3717
3716
|
}
|
|
3718
3717
|
}
|
|
@@ -3824,8 +3823,8 @@ var GuideCommand = class {
|
|
|
3824
3823
|
}
|
|
3825
3824
|
#raise(code) {
|
|
3826
3825
|
const current = process.exitCode;
|
|
3827
|
-
const numeric =
|
|
3828
|
-
if (
|
|
3826
|
+
const numeric = isString(current) ? Number.parseInt(current, 10) : current;
|
|
3827
|
+
if (!isFiniteNumber(numeric) || numeric < code) process.exitCode = code;
|
|
3829
3828
|
}
|
|
3830
3829
|
};
|
|
3831
3830
|
//#endregion
|