@orkestrel/guide 0.0.18 → 0.0.20
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 +4 -3
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +2 -1
- package/dist/src/core/index.d.ts +2 -1
- package/dist/src/core/index.js +4 -3
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +12 -12
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +13 -13
- package/dist/src/server/index.js.map +1 -1
- package/package.json +7 -7
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);
|
|
@@ -2044,7 +2043,8 @@ function extractBodyLines(lines) {
|
|
|
2044
2043
|
* and {@link locateComment} matches a caller's key against the whole map. A change to the head
|
|
2045
2044
|
* shape or to the member shape reaches every one of them at once.
|
|
2046
2045
|
*
|
|
2047
|
-
* An owner opens at a column-zero `export class` or `export interface`
|
|
2046
|
+
* An owner opens at a column-zero `export class`, `export abstract class`, or `export interface`
|
|
2047
|
+
* head and closes at the
|
|
2048
2048
|
* first column-zero `}`, so a member declared past that brace keys nothing. A column-zero `export` declaration carrying any other keyword closes the owner it follows,
|
|
2049
2049
|
* because a member belongs to the head enclosing it. Reading runs over {@link extractSourceLines}'s
|
|
2050
2050
|
* projection, so a head or
|
|
@@ -2063,7 +2063,7 @@ function collectKeys(lines) {
|
|
|
2063
2063
|
const keys = /* @__PURE__ */ new Map();
|
|
2064
2064
|
let owner;
|
|
2065
2065
|
for (const line of lines) {
|
|
2066
|
-
const head = /^export (?:async )?(function\*?|class|const|interface|type) (\w+)/.exec(line.code);
|
|
2066
|
+
const head = /^export (?:async )?(?:abstract )?(function\*?|class|const|interface|type) (\w+)/.exec(line.code);
|
|
2067
2067
|
const keyword = head?.[1]?.replace(/\*$/, "");
|
|
2068
2068
|
const name = head?.[2];
|
|
2069
2069
|
if (isNonEmptyString(keyword) && isNonEmptyString(name) && isExportKeyword(keyword)) {
|
|
@@ -3711,7 +3711,7 @@ var GuideCommand = class {
|
|
|
3711
3711
|
try {
|
|
3712
3712
|
await this.#executeNative();
|
|
3713
3713
|
} catch (error) {
|
|
3714
|
-
process.stderr.write(`${error
|
|
3714
|
+
process.stderr.write(`${isError(error) ? error.message : String(error)}\n`);
|
|
3715
3715
|
this.#raise(1);
|
|
3716
3716
|
}
|
|
3717
3717
|
}
|
|
@@ -3823,8 +3823,8 @@ var GuideCommand = class {
|
|
|
3823
3823
|
}
|
|
3824
3824
|
#raise(code) {
|
|
3825
3825
|
const current = process.exitCode;
|
|
3826
|
-
const numeric =
|
|
3827
|
-
if (
|
|
3826
|
+
const numeric = isString(current) ? Number.parseInt(current, 10) : current;
|
|
3827
|
+
if (!isFiniteNumber(numeric) || numeric < code) process.exitCode = code;
|
|
3828
3828
|
}
|
|
3829
3829
|
};
|
|
3830
3830
|
//#endregion
|