thinkwell 0.5.5 → 0.5.7
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/agent.d.ts.map +1 -1
- package/dist/agent.js +232 -278
- package/dist/agent.js.map +1 -1
- package/dist/build.js +44 -98
- package/dist/cli/build.js +92 -227
- package/dist/cli/bundle.js +570 -1136
- package/dist/cli/check.js +125 -214
- package/dist/cli/commands.js +63 -177
- package/dist/cli/compiler-host.js +81 -190
- package/dist/cli/dependency-check.js +125 -269
- package/dist/cli/dependency-errors.js +12 -84
- package/dist/cli/fmt.js +1 -13
- package/dist/cli/init-command.js +21 -68
- package/dist/cli/init.js +90 -220
- package/dist/cli/loader.js +95 -361
- package/dist/cli/new-command.js +25 -73
- package/dist/cli/package-manager.js +50 -117
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +91 -245
- package/dist/cli/schema.js.map +1 -1
- package/dist/cli/workspace.js +92 -226
- package/dist/connectors/index.js +1 -7
- package/dist/generated/features.d.ts +6 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +5 -0
- package/dist/generated/features.js.map +1 -0
- package/dist/index.js +0 -5
- package/dist/schema.js +3 -36
- package/dist/session.js +50 -82
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +287 -368
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-event.d.ts +1 -0
- package/dist/thought-event.d.ts.map +1 -1
- package/dist/thought-event.js +0 -1
- package/dist/thought-stream.js +60 -96
- package/dist-pkg/acp.cjs +13386 -1876
- package/dist-pkg/cli-build.cjs +264 -446
- package/dist-pkg/cli-bundle.cjs +433 -818
- package/dist-pkg/cli-check.cjs +302 -499
- package/dist-pkg/cli-dependency-check.cjs +39 -82
- package/dist-pkg/cli-dependency-errors.cjs +9 -41
- package/dist-pkg/cli-loader.cjs +91 -173
- package/dist-pkg/protocol.cjs +2 -8
- package/dist-pkg/thinkwell.cjs +927 -1846
- package/package.json +9 -7
package/dist-pkg/cli-build.cjs
CHANGED
|
@@ -532,16 +532,16 @@ var require_typescript = __commonJS({
|
|
|
532
532
|
var tsp;
|
|
533
533
|
(function(tsp2) {
|
|
534
534
|
const activeProgramTransformers = /* @__PURE__ */ new Set();
|
|
535
|
-
const { dirname:
|
|
535
|
+
const { dirname: dirname6 } = require("path");
|
|
536
536
|
function getProjectDir(compilerOptions) {
|
|
537
|
-
return compilerOptions.configFilePath &&
|
|
537
|
+
return compilerOptions.configFilePath && dirname6(compilerOptions.configFilePath);
|
|
538
538
|
}
|
|
539
539
|
__name(getProjectDir, "getProjectDir");
|
|
540
540
|
function getProjectConfig(compilerOptions, rootFileNames) {
|
|
541
541
|
let configFilePath = compilerOptions.configFilePath;
|
|
542
542
|
let projectDir = getProjectDir(compilerOptions);
|
|
543
543
|
if (configFilePath === void 0) {
|
|
544
|
-
const baseDir = rootFileNames.length > 0 ?
|
|
544
|
+
const baseDir = rootFileNames.length > 0 ? dirname6(rootFileNames[0]) : projectDir ?? process.cwd();
|
|
545
545
|
configFilePath = tsp2.tsShim.findConfigFile(baseDir, tsp2.tsShim.sys.fileExists);
|
|
546
546
|
if (configFilePath) {
|
|
547
547
|
const config = readConfig(configFilePath);
|
|
@@ -553,7 +553,7 @@ var require_typescript = __commonJS({
|
|
|
553
553
|
}
|
|
554
554
|
__name(getProjectConfig, "getProjectConfig");
|
|
555
555
|
function readConfig(configFileNamePath) {
|
|
556
|
-
const projectDir =
|
|
556
|
+
const projectDir = dirname6(configFileNamePath);
|
|
557
557
|
const result = tsp2.tsShim.readConfigFile(configFileNamePath, tsp2.tsShim.sys.readFile);
|
|
558
558
|
if (result.error)
|
|
559
559
|
throw new tsp2.TsPatchError("Error in tsconfig.json: " + result.error.messageText);
|
|
@@ -131462,7 +131462,7 @@ ${lanes.join("\n")}
|
|
|
131462
131462
|
}
|
|
131463
131463
|
__name(createImportCallExpressionUMD, "createImportCallExpressionUMD");
|
|
131464
131464
|
function createImportCallExpressionAMD(arg, containsLexicalThis) {
|
|
131465
|
-
const
|
|
131465
|
+
const resolve4 = factory2.createUniqueName("resolve");
|
|
131466
131466
|
const reject = factory2.createUniqueName("reject");
|
|
131467
131467
|
const parameters = [
|
|
131468
131468
|
factory2.createParameterDeclaration(
|
|
@@ -131471,7 +131471,7 @@ ${lanes.join("\n")}
|
|
|
131471
131471
|
/*dotDotDotToken*/
|
|
131472
131472
|
void 0,
|
|
131473
131473
|
/*name*/
|
|
131474
|
-
|
|
131474
|
+
resolve4
|
|
131475
131475
|
),
|
|
131476
131476
|
factory2.createParameterDeclaration(
|
|
131477
131477
|
/*modifiers*/
|
|
@@ -131488,7 +131488,7 @@ ${lanes.join("\n")}
|
|
|
131488
131488
|
factory2.createIdentifier("require"),
|
|
131489
131489
|
/*typeArguments*/
|
|
131490
131490
|
void 0,
|
|
131491
|
-
[factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]),
|
|
131491
|
+
[factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve4, reject]
|
|
131492
131492
|
)
|
|
131493
131493
|
)
|
|
131494
131494
|
]);
|
|
@@ -145024,10 +145024,10 @@ ${lanes.join("\n")}
|
|
|
145024
145024
|
/*ignoreCase*/
|
|
145025
145025
|
false
|
|
145026
145026
|
)) {
|
|
145027
|
-
const
|
|
145028
|
-
if (
|
|
145027
|
+
const basename2 = getBaseFileName(a.fileName);
|
|
145028
|
+
if (basename2 === "lib.d.ts" || basename2 === "lib.es6.d.ts")
|
|
145029
145029
|
return 0;
|
|
145030
|
-
const name = removeSuffix(removePrefix(
|
|
145030
|
+
const name = removeSuffix(removePrefix(basename2, "lib."), ".d.ts");
|
|
145031
145031
|
const index = libs.indexOf(name);
|
|
145032
145032
|
if (index !== -1)
|
|
145033
145033
|
return index + 1;
|
|
@@ -211800,8 +211800,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
211800
211800
|
}
|
|
211801
211801
|
}, "createProjectWatcher");
|
|
211802
211802
|
for (const file of files) {
|
|
211803
|
-
const
|
|
211804
|
-
if (
|
|
211803
|
+
const basename2 = getBaseFileName(file);
|
|
211804
|
+
if (basename2 === "package.json" || basename2 === "bower.json") {
|
|
211805
211805
|
createProjectWatcher(
|
|
211806
211806
|
file,
|
|
211807
211807
|
"FileWatcher"
|
|
@@ -215547,8 +215547,8 @@ All files are: ${JSON.stringify(names)}`,
|
|
|
215547
215547
|
var _a;
|
|
215548
215548
|
const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
|
|
215549
215549
|
if (!fileOrDirectoryPath) return;
|
|
215550
|
-
const
|
|
215551
|
-
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (
|
|
215550
|
+
const basename2 = getBaseFileName(fileOrDirectoryPath);
|
|
215551
|
+
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename2 === "package.json" || basename2 === "node_modules")) {
|
|
215552
215552
|
result.affectedModuleSpecifierCacheProjects.forEach((project) => {
|
|
215553
215553
|
var _a2;
|
|
215554
215554
|
(_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
|
|
@@ -222134,8 +222134,8 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
222134
222134
|
installPackage(options) {
|
|
222135
222135
|
this.packageInstallId++;
|
|
222136
222136
|
const request = { kind: "installPackage", ...options, id: this.packageInstallId };
|
|
222137
|
-
const promise = new Promise((
|
|
222138
|
-
(this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve:
|
|
222137
|
+
const promise = new Promise((resolve4, reject) => {
|
|
222138
|
+
(this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve4, reject });
|
|
222139
222139
|
});
|
|
222140
222140
|
this.installer.send(request);
|
|
222141
222141
|
return promise;
|
|
@@ -222538,12 +222538,12 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
222538
222538
|
}
|
|
222539
222539
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
222540
222540
|
function adopt(value) {
|
|
222541
|
-
return value instanceof P ? value : new P(function(
|
|
222542
|
-
|
|
222541
|
+
return value instanceof P ? value : new P(function(resolve4) {
|
|
222542
|
+
resolve4(value);
|
|
222543
222543
|
});
|
|
222544
222544
|
}
|
|
222545
222545
|
__name(adopt, "adopt");
|
|
222546
|
-
return new (P || (P = Promise))(function(
|
|
222546
|
+
return new (P || (P = Promise))(function(resolve4, reject) {
|
|
222547
222547
|
function fulfilled(value) {
|
|
222548
222548
|
try {
|
|
222549
222549
|
step(generator.next(value));
|
|
@@ -222561,7 +222561,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
222561
222561
|
}
|
|
222562
222562
|
__name(rejected, "rejected");
|
|
222563
222563
|
function step(result) {
|
|
222564
|
-
result.done ?
|
|
222564
|
+
result.done ? resolve4(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
222565
222565
|
}
|
|
222566
222566
|
__name(step, "step");
|
|
222567
222567
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -222763,15 +222763,15 @@ function __asyncValues(o) {
|
|
|
222763
222763
|
}, i);
|
|
222764
222764
|
function verb(n) {
|
|
222765
222765
|
i[n] = o[n] && function(v) {
|
|
222766
|
-
return new Promise(function(
|
|
222767
|
-
v = o[n](v), settle(
|
|
222766
|
+
return new Promise(function(resolve4, reject) {
|
|
222767
|
+
v = o[n](v), settle(resolve4, reject, v.done, v.value);
|
|
222768
222768
|
});
|
|
222769
222769
|
};
|
|
222770
222770
|
}
|
|
222771
222771
|
__name(verb, "verb");
|
|
222772
|
-
function settle(
|
|
222772
|
+
function settle(resolve4, reject, d, v) {
|
|
222773
222773
|
Promise.resolve(v).then(function(v2) {
|
|
222774
|
-
|
|
222774
|
+
resolve4({ value: v2, done: d });
|
|
222775
222775
|
}, reject);
|
|
222776
222776
|
}
|
|
222777
222777
|
__name(settle, "settle");
|
|
@@ -223419,7 +223419,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
223419
223419
|
return circularValue;
|
|
223420
223420
|
}
|
|
223421
223421
|
let res = "";
|
|
223422
|
-
let
|
|
223422
|
+
let join9 = ",";
|
|
223423
223423
|
const originalIndentation = indentation;
|
|
223424
223424
|
if (Array.isArray(value)) {
|
|
223425
223425
|
if (value.length === 0) {
|
|
@@ -223433,7 +223433,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
223433
223433
|
indentation += spacer;
|
|
223434
223434
|
res += `
|
|
223435
223435
|
${indentation}`;
|
|
223436
|
-
|
|
223436
|
+
join9 = `,
|
|
223437
223437
|
${indentation}`;
|
|
223438
223438
|
}
|
|
223439
223439
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -223441,13 +223441,13 @@ ${indentation}`;
|
|
|
223441
223441
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
223442
223442
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
223443
223443
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
223444
|
-
res +=
|
|
223444
|
+
res += join9;
|
|
223445
223445
|
}
|
|
223446
223446
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
223447
223447
|
res += tmp !== void 0 ? tmp : "null";
|
|
223448
223448
|
if (value.length - 1 > maximumBreadth) {
|
|
223449
223449
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
223450
|
-
res += `${
|
|
223450
|
+
res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
223451
223451
|
}
|
|
223452
223452
|
if (spacer !== "") {
|
|
223453
223453
|
res += `
|
|
@@ -223468,7 +223468,7 @@ ${originalIndentation}`;
|
|
|
223468
223468
|
let separator = "";
|
|
223469
223469
|
if (spacer !== "") {
|
|
223470
223470
|
indentation += spacer;
|
|
223471
|
-
|
|
223471
|
+
join9 = `,
|
|
223472
223472
|
${indentation}`;
|
|
223473
223473
|
whitespace = " ";
|
|
223474
223474
|
}
|
|
@@ -223482,13 +223482,13 @@ ${indentation}`;
|
|
|
223482
223482
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
223483
223483
|
if (tmp !== void 0) {
|
|
223484
223484
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
223485
|
-
separator =
|
|
223485
|
+
separator = join9;
|
|
223486
223486
|
}
|
|
223487
223487
|
}
|
|
223488
223488
|
if (keyLength > maximumBreadth) {
|
|
223489
223489
|
const removedKeys = keyLength - maximumBreadth;
|
|
223490
223490
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
223491
|
-
separator =
|
|
223491
|
+
separator = join9;
|
|
223492
223492
|
}
|
|
223493
223493
|
if (spacer !== "" && separator.length > 1) {
|
|
223494
223494
|
res = `
|
|
@@ -223530,7 +223530,7 @@ ${originalIndentation}`;
|
|
|
223530
223530
|
}
|
|
223531
223531
|
const originalIndentation = indentation;
|
|
223532
223532
|
let res = "";
|
|
223533
|
-
let
|
|
223533
|
+
let join9 = ",";
|
|
223534
223534
|
if (Array.isArray(value)) {
|
|
223535
223535
|
if (value.length === 0) {
|
|
223536
223536
|
return "[]";
|
|
@@ -223543,7 +223543,7 @@ ${originalIndentation}`;
|
|
|
223543
223543
|
indentation += spacer;
|
|
223544
223544
|
res += `
|
|
223545
223545
|
${indentation}`;
|
|
223546
|
-
|
|
223546
|
+
join9 = `,
|
|
223547
223547
|
${indentation}`;
|
|
223548
223548
|
}
|
|
223549
223549
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -223551,13 +223551,13 @@ ${indentation}`;
|
|
|
223551
223551
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
223552
223552
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
223553
223553
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
223554
|
-
res +=
|
|
223554
|
+
res += join9;
|
|
223555
223555
|
}
|
|
223556
223556
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
223557
223557
|
res += tmp !== void 0 ? tmp : "null";
|
|
223558
223558
|
if (value.length - 1 > maximumBreadth) {
|
|
223559
223559
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
223560
|
-
res += `${
|
|
223560
|
+
res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
223561
223561
|
}
|
|
223562
223562
|
if (spacer !== "") {
|
|
223563
223563
|
res += `
|
|
@@ -223570,7 +223570,7 @@ ${originalIndentation}`;
|
|
|
223570
223570
|
let whitespace = "";
|
|
223571
223571
|
if (spacer !== "") {
|
|
223572
223572
|
indentation += spacer;
|
|
223573
|
-
|
|
223573
|
+
join9 = `,
|
|
223574
223574
|
${indentation}`;
|
|
223575
223575
|
whitespace = " ";
|
|
223576
223576
|
}
|
|
@@ -223579,7 +223579,7 @@ ${indentation}`;
|
|
|
223579
223579
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
223580
223580
|
if (tmp !== void 0) {
|
|
223581
223581
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
223582
|
-
separator =
|
|
223582
|
+
separator = join9;
|
|
223583
223583
|
}
|
|
223584
223584
|
}
|
|
223585
223585
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -223638,20 +223638,20 @@ ${originalIndentation}`;
|
|
|
223638
223638
|
indentation += spacer;
|
|
223639
223639
|
let res2 = `
|
|
223640
223640
|
${indentation}`;
|
|
223641
|
-
const
|
|
223641
|
+
const join10 = `,
|
|
223642
223642
|
${indentation}`;
|
|
223643
223643
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
223644
223644
|
let i = 0;
|
|
223645
223645
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
223646
223646
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
223647
223647
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
223648
|
-
res2 +=
|
|
223648
|
+
res2 += join10;
|
|
223649
223649
|
}
|
|
223650
223650
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
223651
223651
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
223652
223652
|
if (value.length - 1 > maximumBreadth) {
|
|
223653
223653
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
223654
|
-
res2 += `${
|
|
223654
|
+
res2 += `${join10}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
223655
223655
|
}
|
|
223656
223656
|
res2 += `
|
|
223657
223657
|
${originalIndentation}`;
|
|
@@ -223667,16 +223667,16 @@ ${originalIndentation}`;
|
|
|
223667
223667
|
return '"[Object]"';
|
|
223668
223668
|
}
|
|
223669
223669
|
indentation += spacer;
|
|
223670
|
-
const
|
|
223670
|
+
const join9 = `,
|
|
223671
223671
|
${indentation}`;
|
|
223672
223672
|
let res = "";
|
|
223673
223673
|
let separator = "";
|
|
223674
223674
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
223675
223675
|
if (isTypedArrayWithEntries(value)) {
|
|
223676
|
-
res += stringifyTypedArray(value,
|
|
223676
|
+
res += stringifyTypedArray(value, join9, maximumBreadth);
|
|
223677
223677
|
keys = keys.slice(value.length);
|
|
223678
223678
|
maximumPropertiesToStringify -= value.length;
|
|
223679
|
-
separator =
|
|
223679
|
+
separator = join9;
|
|
223680
223680
|
}
|
|
223681
223681
|
if (deterministic) {
|
|
223682
223682
|
keys = sort(keys, comparator);
|
|
@@ -223687,13 +223687,13 @@ ${indentation}`;
|
|
|
223687
223687
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
223688
223688
|
if (tmp !== void 0) {
|
|
223689
223689
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
223690
|
-
separator =
|
|
223690
|
+
separator = join9;
|
|
223691
223691
|
}
|
|
223692
223692
|
}
|
|
223693
223693
|
if (keyLength > maximumBreadth) {
|
|
223694
223694
|
const removedKeys = keyLength - maximumBreadth;
|
|
223695
223695
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
223696
|
-
separator =
|
|
223696
|
+
separator = join9;
|
|
223697
223697
|
}
|
|
223698
223698
|
if (separator !== "") {
|
|
223699
223699
|
res = `
|
|
@@ -235168,10 +235168,10 @@ var require_commonjs5 = __commonJS({
|
|
|
235168
235168
|
* Return a void Promise that resolves once the stream ends.
|
|
235169
235169
|
*/
|
|
235170
235170
|
async promise() {
|
|
235171
|
-
return new Promise((
|
|
235171
|
+
return new Promise((resolve4, reject) => {
|
|
235172
235172
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
235173
235173
|
this.on("error", (er) => reject(er));
|
|
235174
|
-
this.on("end", () =>
|
|
235174
|
+
this.on("end", () => resolve4());
|
|
235175
235175
|
});
|
|
235176
235176
|
}
|
|
235177
235177
|
/**
|
|
@@ -235195,7 +235195,7 @@ var require_commonjs5 = __commonJS({
|
|
|
235195
235195
|
return Promise.resolve({ done: false, value: res });
|
|
235196
235196
|
if (this[EOF])
|
|
235197
235197
|
return stop();
|
|
235198
|
-
let
|
|
235198
|
+
let resolve4;
|
|
235199
235199
|
let reject;
|
|
235200
235200
|
const onerr = /* @__PURE__ */ __name((er) => {
|
|
235201
235201
|
this.off("data", ondata);
|
|
@@ -235209,19 +235209,19 @@ var require_commonjs5 = __commonJS({
|
|
|
235209
235209
|
this.off("end", onend);
|
|
235210
235210
|
this.off(DESTROYED, ondestroy);
|
|
235211
235211
|
this.pause();
|
|
235212
|
-
|
|
235212
|
+
resolve4({ value, done: !!this[EOF] });
|
|
235213
235213
|
}, "ondata");
|
|
235214
235214
|
const onend = /* @__PURE__ */ __name(() => {
|
|
235215
235215
|
this.off("error", onerr);
|
|
235216
235216
|
this.off("data", ondata);
|
|
235217
235217
|
this.off(DESTROYED, ondestroy);
|
|
235218
235218
|
stop();
|
|
235219
|
-
|
|
235219
|
+
resolve4({ done: true, value: void 0 });
|
|
235220
235220
|
}, "onend");
|
|
235221
235221
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
235222
235222
|
return new Promise((res2, rej) => {
|
|
235223
235223
|
reject = rej;
|
|
235224
|
-
|
|
235224
|
+
resolve4 = res2;
|
|
235225
235225
|
this.once(DESTROYED, ondestroy);
|
|
235226
235226
|
this.once("error", onerr);
|
|
235227
235227
|
this.once("end", onend);
|
|
@@ -236246,9 +236246,9 @@ var require_commonjs6 = __commonJS({
|
|
|
236246
236246
|
if (this.#asyncReaddirInFlight) {
|
|
236247
236247
|
await this.#asyncReaddirInFlight;
|
|
236248
236248
|
} else {
|
|
236249
|
-
let
|
|
236249
|
+
let resolve4 = /* @__PURE__ */ __name(() => {
|
|
236250
236250
|
}, "resolve");
|
|
236251
|
-
this.#asyncReaddirInFlight = new Promise((res) =>
|
|
236251
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve4 = res);
|
|
236252
236252
|
try {
|
|
236253
236253
|
for (const e of await this.#fs.promises.readdir(fullpath, {
|
|
236254
236254
|
withFileTypes: true
|
|
@@ -236261,7 +236261,7 @@ var require_commonjs6 = __commonJS({
|
|
|
236261
236261
|
children.provisional = 0;
|
|
236262
236262
|
}
|
|
236263
236263
|
this.#asyncReaddirInFlight = void 0;
|
|
236264
|
-
|
|
236264
|
+
resolve4();
|
|
236265
236265
|
}
|
|
236266
236266
|
return children.slice(0, children.provisional);
|
|
236267
236267
|
}
|
|
@@ -238603,19 +238603,19 @@ __export(build_exports, {
|
|
|
238603
238603
|
});
|
|
238604
238604
|
module.exports = __toCommonJS(build_exports);
|
|
238605
238605
|
var import_typescript3 = __toESM(require_typescript(), 1);
|
|
238606
|
-
var
|
|
238607
|
-
var
|
|
238606
|
+
var import_node_fs7 = require("node:fs");
|
|
238607
|
+
var import_node_path8 = require("node:path");
|
|
238608
238608
|
var import_node_util3 = require("node:util");
|
|
238609
238609
|
|
|
238610
238610
|
// dist/cli/compiler-host.js
|
|
238611
238611
|
var import_typescript2 = __toESM(require_typescript(), 1);
|
|
238612
|
-
var
|
|
238613
|
-
var
|
|
238612
|
+
var import_node_path4 = require("node:path");
|
|
238613
|
+
var import_node_fs3 = require("node:fs");
|
|
238614
238614
|
|
|
238615
238615
|
// dist/cli/schema.js
|
|
238616
238616
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
238617
|
-
var
|
|
238618
|
-
var
|
|
238617
|
+
var import_node_path3 = require("node:path");
|
|
238618
|
+
var import_node_module2 = require("node:module");
|
|
238619
238619
|
|
|
238620
238620
|
// dist/build.js
|
|
238621
238621
|
var import_node_path = require("node:path");
|
|
@@ -238623,61 +238623,49 @@ var import_node_fs = require("node:fs");
|
|
|
238623
238623
|
var import_ts_json_schema_generator = __toESM(require_dist(), 1);
|
|
238624
238624
|
function findTsConfig(startDir) {
|
|
238625
238625
|
let dir = startDir;
|
|
238626
|
-
|
|
238626
|
+
for (; ; ) {
|
|
238627
238627
|
const configPath = (0, import_node_path.join)(dir, "tsconfig.json");
|
|
238628
|
-
if ((0, import_node_fs.existsSync)(configPath))
|
|
238628
|
+
if ((0, import_node_fs.existsSync)(configPath))
|
|
238629
238629
|
return configPath;
|
|
238630
|
-
}
|
|
238631
238630
|
const parent = (0, import_node_path.dirname)(dir);
|
|
238632
|
-
if (parent === dir)
|
|
238633
|
-
return
|
|
238634
|
-
}
|
|
238631
|
+
if (parent === dir)
|
|
238632
|
+
return;
|
|
238635
238633
|
dir = parent;
|
|
238636
238634
|
}
|
|
238637
238635
|
}
|
|
238638
238636
|
__name(findTsConfig, "findTsConfig");
|
|
238639
238637
|
function inlineRefs(obj, definitions) {
|
|
238640
|
-
if (obj === null || typeof obj
|
|
238638
|
+
if (obj === null || typeof obj != "object")
|
|
238641
238639
|
return obj;
|
|
238642
|
-
|
|
238643
|
-
if (Array.isArray(obj)) {
|
|
238640
|
+
if (Array.isArray(obj))
|
|
238644
238641
|
return obj.map((item) => inlineRefs(item, definitions));
|
|
238645
|
-
}
|
|
238646
238642
|
const record = obj;
|
|
238647
|
-
if (typeof record
|
|
238648
|
-
const
|
|
238649
|
-
|
|
238650
|
-
if (match && definitions[match[1]]) {
|
|
238643
|
+
if (typeof record.$ref == "string") {
|
|
238644
|
+
const match = record.$ref.match(/^#\/definitions\/(.+)$/);
|
|
238645
|
+
if (match && definitions[match[1]])
|
|
238651
238646
|
return inlineRefs(definitions[match[1]], definitions);
|
|
238652
|
-
}
|
|
238653
238647
|
}
|
|
238654
238648
|
const result = {};
|
|
238655
|
-
for (const [key2, value] of Object.entries(record))
|
|
238649
|
+
for (const [key2, value] of Object.entries(record))
|
|
238656
238650
|
result[key2] = inlineRefs(value, definitions);
|
|
238657
|
-
}
|
|
238658
238651
|
return result;
|
|
238659
238652
|
}
|
|
238660
238653
|
__name(inlineRefs, "inlineRefs");
|
|
238661
238654
|
function cleanSchema(typeName, schema) {
|
|
238662
238655
|
const definitions = schema.definitions || {};
|
|
238663
238656
|
let result = definitions[typeName] || schema;
|
|
238664
|
-
result = inlineRefs(result, definitions)
|
|
238665
|
-
if (typeof result === "object" && result !== null) {
|
|
238657
|
+
if (result = inlineRefs(result, definitions), typeof result == "object" && result !== null) {
|
|
238666
238658
|
const cleaned = { ...result };
|
|
238667
|
-
delete cleaned
|
|
238668
|
-
delete cleaned["definitions"];
|
|
238669
|
-
return cleaned;
|
|
238659
|
+
return delete cleaned.$schema, delete cleaned.definitions, cleaned;
|
|
238670
238660
|
}
|
|
238671
238661
|
return result;
|
|
238672
238662
|
}
|
|
238673
238663
|
__name(cleanSchema, "cleanSchema");
|
|
238674
238664
|
function generateSchemas(filePath, typeNames) {
|
|
238675
238665
|
const schemas = /* @__PURE__ */ new Map();
|
|
238676
|
-
if (typeNames.length === 0)
|
|
238666
|
+
if (typeNames.length === 0)
|
|
238677
238667
|
return schemas;
|
|
238678
|
-
|
|
238679
|
-
const configPath = findTsConfig((0, import_node_path.dirname)(filePath));
|
|
238680
|
-
const generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
238668
|
+
const configPath = findTsConfig((0, import_node_path.dirname)(filePath)), generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
238681
238669
|
path: filePath,
|
|
238682
238670
|
...configPath && { tsconfig: configPath },
|
|
238683
238671
|
skipTypeCheck: true,
|
|
@@ -238691,11 +238679,25 @@ function generateSchemas(filePath, typeNames) {
|
|
|
238691
238679
|
}
|
|
238692
238680
|
__name(generateSchemas, "generateSchemas");
|
|
238693
238681
|
|
|
238682
|
+
// dist/cli/loader.js
|
|
238683
|
+
var import_node_fs2 = require("node:fs");
|
|
238684
|
+
var import_node_path2 = require("node:path");
|
|
238685
|
+
var import_node_crypto = require("node:crypto");
|
|
238686
|
+
var import_node_module = require("node:module");
|
|
238687
|
+
function extractShebang(source) {
|
|
238688
|
+
if (source.startsWith("#!")) {
|
|
238689
|
+
const newlineIndex = source.indexOf(`
|
|
238690
|
+
`);
|
|
238691
|
+
return newlineIndex !== -1 ? [source.slice(0, newlineIndex + 1), source.slice(newlineIndex + 1)] : [source, ""];
|
|
238692
|
+
}
|
|
238693
|
+
return ["", source];
|
|
238694
|
+
}
|
|
238695
|
+
__name(extractShebang, "extractShebang");
|
|
238696
|
+
|
|
238694
238697
|
// dist/cli/schema.js
|
|
238695
238698
|
var JSONSCHEMA_TAG = "JSONSchema";
|
|
238696
238699
|
function hasJsDocTag(node, tagName) {
|
|
238697
|
-
|
|
238698
|
-
return jsDocNodes.some((tag) => tag.tagName.text === tagName);
|
|
238700
|
+
return import_typescript.default.getJSDocTags(node).some((tag) => tag.tagName.text === tagName);
|
|
238699
238701
|
}
|
|
238700
238702
|
__name(hasJsDocTag, "hasJsDocTag");
|
|
238701
238703
|
function findMarkedTypes(path, source) {
|
|
@@ -238705,48 +238707,36 @@ function findMarkedTypes(path, source) {
|
|
|
238705
238707
|
import_typescript.default.ScriptTarget.Latest,
|
|
238706
238708
|
true
|
|
238707
238709
|
// setParentNodes - needed for JSDoc traversal
|
|
238708
|
-
);
|
|
238709
|
-
|
|
238710
|
-
|
|
238711
|
-
|
|
238712
|
-
if (
|
|
238713
|
-
const
|
|
238714
|
-
|
|
238715
|
-
|
|
238716
|
-
|
|
238717
|
-
|
|
238718
|
-
|
|
238719
|
-
|
|
238720
|
-
|
|
238721
|
-
|
|
238722
|
-
|
|
238723
|
-
|
|
238724
|
-
|
|
238725
|
-
|
|
238726
|
-
|
|
238727
|
-
node,
|
|
238728
|
-
startPosition: node.getStart(),
|
|
238729
|
-
endPosition: node.getEnd(),
|
|
238730
|
-
line: line + 1,
|
|
238731
|
-
column: character + 1,
|
|
238732
|
-
declarationLength,
|
|
238733
|
-
isExported
|
|
238734
|
-
});
|
|
238735
|
-
}
|
|
238710
|
+
), results = [];
|
|
238711
|
+
return import_typescript.default.forEachChild(sourceFile, /* @__PURE__ */ __name(function visit(node) {
|
|
238712
|
+
if ((import_typescript.default.isInterfaceDeclaration(node) || import_typescript.default.isTypeAliasDeclaration(node) || import_typescript.default.isEnumDeclaration(node) || import_typescript.default.isClassDeclaration(node)) && hasJsDocTag(node, JSONSCHEMA_TAG)) {
|
|
238713
|
+
const name = node.name?.text;
|
|
238714
|
+
if (name) {
|
|
238715
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
238716
|
+
let keyword = "interface";
|
|
238717
|
+
import_typescript.default.isTypeAliasDeclaration(node) ? keyword = "type" : import_typescript.default.isEnumDeclaration(node) ? keyword = "enum" : import_typescript.default.isClassDeclaration(node) && (keyword = "class");
|
|
238718
|
+
const declarationLength = keyword.length + 1 + name.length, isExported = node.modifiers?.some((m) => m.kind === import_typescript.default.SyntaxKind.ExportKeyword) ?? false;
|
|
238719
|
+
results.push({
|
|
238720
|
+
name,
|
|
238721
|
+
node,
|
|
238722
|
+
startPosition: node.getStart(),
|
|
238723
|
+
endPosition: node.getEnd(),
|
|
238724
|
+
line: line + 1,
|
|
238725
|
+
column: character + 1,
|
|
238726
|
+
declarationLength,
|
|
238727
|
+
isExported
|
|
238728
|
+
});
|
|
238736
238729
|
}
|
|
238737
238730
|
}
|
|
238738
238731
|
import_typescript.default.forEachChild(node, visit);
|
|
238739
|
-
}, "visit"));
|
|
238740
|
-
return results;
|
|
238732
|
+
}, "visit")), results;
|
|
238741
238733
|
}
|
|
238742
238734
|
__name(findMarkedTypes, "findMarkedTypes");
|
|
238743
238735
|
function resolveGenerateSchemas(projectDir) {
|
|
238744
238736
|
if (projectDir) {
|
|
238745
|
-
const
|
|
238746
|
-
|
|
238747
|
-
if (typeof buildMod.generateSchemas === "function") {
|
|
238737
|
+
const buildMod = (0, import_node_module2.createRequire)((0, import_node_path3.join)(projectDir, "package.json"))("thinkwell/build");
|
|
238738
|
+
if (typeof buildMod.generateSchemas == "function")
|
|
238748
238739
|
return buildMod.generateSchemas;
|
|
238749
|
-
}
|
|
238750
238740
|
throw new Error(`thinkwell/build resolved from ${projectDir} but does not export generateSchemas. This may indicate a version mismatch \u2014 try updating the thinkwell dependency.`);
|
|
238751
238741
|
}
|
|
238752
238742
|
return generateSchemas;
|
|
@@ -238754,18 +238744,14 @@ function resolveGenerateSchemas(projectDir) {
|
|
|
238754
238744
|
__name(resolveGenerateSchemas, "resolveGenerateSchemas");
|
|
238755
238745
|
function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
238756
238746
|
const schemas = /* @__PURE__ */ new Map();
|
|
238757
|
-
if (types.length === 0)
|
|
238747
|
+
if (types.length === 0)
|
|
238758
238748
|
return schemas;
|
|
238759
|
-
}
|
|
238760
238749
|
const buildGenerateSchemas = resolveGenerateSchemas(projectDir);
|
|
238761
238750
|
for (const typeInfo of types) {
|
|
238762
238751
|
const { name, line, column } = typeInfo;
|
|
238763
238752
|
try {
|
|
238764
|
-
const
|
|
238765
|
-
|
|
238766
|
-
if (schema) {
|
|
238767
|
-
schemas.set(name, schema);
|
|
238768
|
-
}
|
|
238753
|
+
const schema = buildGenerateSchemas(path, [name]).get(name);
|
|
238754
|
+
schema && schemas.set(name, schema);
|
|
238769
238755
|
} catch (error) {
|
|
238770
238756
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
238771
238757
|
throw new Error(`Failed to generate schema for type '${name}' at ${path}:${line}:${column}
|
|
@@ -238778,27 +238764,27 @@ function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
|
238778
238764
|
__name(generateSchemas2, "generateSchemas");
|
|
238779
238765
|
var ACP_NAMESPACE = "$$__thinkwell__acp__$$";
|
|
238780
238766
|
function generateNamespace(name, schema, isExported) {
|
|
238781
|
-
const schemaJson = JSON.stringify(schema, null, 2).split(
|
|
238782
|
-
|
|
238767
|
+
const schemaJson = JSON.stringify(schema, null, 2).split(`
|
|
238768
|
+
`).map((line, i) => i === 0 ? line : " " + line).join(`
|
|
238769
|
+
`);
|
|
238783
238770
|
return [
|
|
238784
|
-
`${
|
|
238771
|
+
`${isExported ? "export " : ""}namespace ${name} {`,
|
|
238785
238772
|
` export const Schema: ${ACP_NAMESPACE}.SchemaProvider<${name}> = {`,
|
|
238786
238773
|
` toJsonSchema: () => (${schemaJson}) as ${ACP_NAMESPACE}.JsonSchema,`,
|
|
238787
|
-
|
|
238788
|
-
|
|
238789
|
-
].join(
|
|
238774
|
+
" };",
|
|
238775
|
+
"}"
|
|
238776
|
+
].join(`
|
|
238777
|
+
`);
|
|
238790
238778
|
}
|
|
238791
238779
|
__name(generateNamespace, "generateNamespace");
|
|
238792
238780
|
function generateInsertions(types, schemas) {
|
|
238793
238781
|
const insertions = [];
|
|
238794
238782
|
for (const { name, endPosition, isExported } of types) {
|
|
238795
238783
|
const schema = schemas.get(name);
|
|
238796
|
-
|
|
238797
|
-
continue;
|
|
238798
|
-
}
|
|
238799
|
-
insertions.push({
|
|
238784
|
+
schema && insertions.push({
|
|
238800
238785
|
position: endPosition,
|
|
238801
|
-
code:
|
|
238786
|
+
code: `
|
|
238787
|
+
` + generateNamespace(name, schema, isExported)
|
|
238802
238788
|
});
|
|
238803
238789
|
}
|
|
238804
238790
|
return insertions.sort((a, b) => b.position - a.position);
|
|
@@ -238810,9 +238796,8 @@ function generateSchemaImport() {
|
|
|
238810
238796
|
__name(generateSchemaImport, "generateSchemaImport");
|
|
238811
238797
|
function applyInsertions(source, insertions) {
|
|
238812
238798
|
let result = source;
|
|
238813
|
-
for (const { position, code } of insertions)
|
|
238799
|
+
for (const { position, code } of insertions)
|
|
238814
238800
|
result = result.slice(0, position) + code + result.slice(position);
|
|
238815
|
-
}
|
|
238816
238801
|
return result;
|
|
238817
238802
|
}
|
|
238818
238803
|
__name(applyInsertions, "applyInsertions");
|
|
@@ -238821,43 +238806,38 @@ function hasJsonSchemaMarkers(source) {
|
|
|
238821
238806
|
}
|
|
238822
238807
|
__name(hasJsonSchemaMarkers, "hasJsonSchemaMarkers");
|
|
238823
238808
|
function transformJsonSchemas(path, source, projectDir) {
|
|
238824
|
-
if (!hasJsonSchemaMarkers(source))
|
|
238809
|
+
if (!hasJsonSchemaMarkers(source))
|
|
238825
238810
|
return source;
|
|
238826
|
-
}
|
|
238827
238811
|
const markedTypes = findMarkedTypes(path, source);
|
|
238828
|
-
if (markedTypes.length === 0)
|
|
238812
|
+
if (markedTypes.length === 0)
|
|
238829
238813
|
return source;
|
|
238830
|
-
|
|
238831
|
-
const schemas = generateSchemas2(path, markedTypes, source, projectDir);
|
|
238832
|
-
const insertions = generateInsertions(markedTypes, schemas);
|
|
238814
|
+
const schemas = generateSchemas2(path, markedTypes, source, projectDir), insertions = generateInsertions(markedTypes, schemas);
|
|
238833
238815
|
let modifiedSource = applyInsertions(source, insertions);
|
|
238834
|
-
|
|
238835
|
-
return modifiedSource
|
|
238816
|
+
const [shebang, rest] = extractShebang(modifiedSource);
|
|
238817
|
+
return modifiedSource = shebang + generateSchemaImport() + `
|
|
238818
|
+
` + rest, modifiedSource;
|
|
238836
238819
|
}
|
|
238837
238820
|
__name(transformJsonSchemas, "transformJsonSchemas");
|
|
238838
238821
|
|
|
238839
238822
|
// dist/cli/compiler-host.js
|
|
238840
238823
|
function getTypeScriptLibDir() {
|
|
238841
|
-
if (typeof process.pkg
|
|
238824
|
+
if (typeof process.pkg < "u") {
|
|
238842
238825
|
const snapshotLibDir = "/snapshot/thinkwell/packages/thinkwell/dist-pkg/typescript-lib";
|
|
238843
|
-
if ((0,
|
|
238826
|
+
if ((0, import_node_fs3.existsSync)(snapshotLibDir))
|
|
238844
238827
|
return snapshotLibDir;
|
|
238845
|
-
}
|
|
238846
238828
|
}
|
|
238847
|
-
return (0,
|
|
238829
|
+
return (0, import_node_path4.dirname)(import_typescript2.default.getDefaultLibFilePath({}));
|
|
238848
238830
|
}
|
|
238849
238831
|
__name(getTypeScriptLibDir, "getTypeScriptLibDir");
|
|
238850
238832
|
function parseTsConfig(configPath) {
|
|
238851
238833
|
const configFile = import_typescript2.default.readConfigFile(configPath, import_typescript2.default.sys.readFile);
|
|
238852
|
-
if (configFile.error)
|
|
238834
|
+
if (configFile.error)
|
|
238853
238835
|
return {
|
|
238854
238836
|
options: {},
|
|
238855
238837
|
fileNames: [],
|
|
238856
238838
|
errors: [configFile.error]
|
|
238857
238839
|
};
|
|
238858
|
-
|
|
238859
|
-
const configDir = (0, import_node_path3.dirname)(configPath);
|
|
238860
|
-
const parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238840
|
+
const configDir = (0, import_node_path4.dirname)(configPath), parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238861
238841
|
configFile.config,
|
|
238862
238842
|
import_typescript2.default.sys,
|
|
238863
238843
|
configDir,
|
|
@@ -238873,32 +238853,17 @@ function parseTsConfig(configPath) {
|
|
|
238873
238853
|
}
|
|
238874
238854
|
__name(parseTsConfig, "parseTsConfig");
|
|
238875
238855
|
function shouldTransform(fileName) {
|
|
238876
|
-
|
|
238877
|
-
return false;
|
|
238878
|
-
if (fileName.includes("/lib/lib."))
|
|
238879
|
-
return false;
|
|
238880
|
-
return true;
|
|
238856
|
+
return !(fileName.includes("node_modules") || fileName.includes("/lib/lib."));
|
|
238881
238857
|
}
|
|
238882
238858
|
__name(shouldTransform, "shouldTransform");
|
|
238883
238859
|
function isThinkwellHostOptions(options) {
|
|
238884
|
-
return typeof options.compilerOptions
|
|
238860
|
+
return typeof options.compilerOptions == "object" && options.compilerOptions !== null && !Array.isArray(options.compilerOptions);
|
|
238885
238861
|
}
|
|
238886
238862
|
__name(isThinkwellHostOptions, "isThinkwellHostOptions");
|
|
238887
238863
|
function createThinkwellHost(options) {
|
|
238888
|
-
let compilerOptions;
|
|
238889
|
-
|
|
238890
|
-
|
|
238891
|
-
if (isThinkwellHostOptions(options)) {
|
|
238892
|
-
compilerOptions = options.compilerOptions;
|
|
238893
|
-
fileFilter = options.fileFilter;
|
|
238894
|
-
projectDir = options.projectDir;
|
|
238895
|
-
} else {
|
|
238896
|
-
compilerOptions = options;
|
|
238897
|
-
fileFilter = void 0;
|
|
238898
|
-
projectDir = void 0;
|
|
238899
|
-
}
|
|
238900
|
-
const defaultHost = import_typescript2.default.createCompilerHost(compilerOptions);
|
|
238901
|
-
const tsLibDir = getTypeScriptLibDir();
|
|
238864
|
+
let compilerOptions, fileFilter, projectDir;
|
|
238865
|
+
isThinkwellHostOptions(options) ? (compilerOptions = options.compilerOptions, fileFilter = options.fileFilter, projectDir = options.projectDir) : (compilerOptions = options, fileFilter = void 0, projectDir = void 0);
|
|
238866
|
+
const defaultHost = import_typescript2.default.createCompilerHost(compilerOptions), tsLibDir = getTypeScriptLibDir();
|
|
238902
238867
|
return {
|
|
238903
238868
|
...defaultHost,
|
|
238904
238869
|
// Override getDefaultLibLocation to point to our bundled TypeScript lib files
|
|
@@ -238908,77 +238873,53 @@ function createThinkwellHost(options) {
|
|
|
238908
238873
|
return tsLibDir;
|
|
238909
238874
|
},
|
|
238910
238875
|
getDefaultLibFileName(options2) {
|
|
238911
|
-
return (0,
|
|
238876
|
+
return (0, import_node_path4.join)(tsLibDir, import_typescript2.default.getDefaultLibFileName(options2));
|
|
238912
238877
|
},
|
|
238913
238878
|
getSourceFile(fileName, languageVersionOrOptions) {
|
|
238914
238879
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
238915
|
-
if (source
|
|
238916
|
-
|
|
238917
|
-
}
|
|
238918
|
-
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source)) {
|
|
238919
|
-
if (!fileFilter || fileFilter(fileName)) {
|
|
238880
|
+
if (source !== void 0) {
|
|
238881
|
+
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source) && (!fileFilter || fileFilter(fileName))) {
|
|
238920
238882
|
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238921
238883
|
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238922
238884
|
}
|
|
238885
|
+
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238923
238886
|
}
|
|
238924
|
-
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238925
238887
|
}
|
|
238926
238888
|
};
|
|
238927
238889
|
}
|
|
238928
238890
|
__name(createThinkwellHost, "createThinkwellHost");
|
|
238929
238891
|
function createThinkwellProgram(configPathOrOptions) {
|
|
238930
|
-
const configPath = typeof configPathOrOptions
|
|
238931
|
-
const fileFilter = typeof configPathOrOptions === "object" ? configPathOrOptions.fileFilter : void 0;
|
|
238932
|
-
const projectDir = typeof configPathOrOptions === "object" ? configPathOrOptions.projectDir : void 0;
|
|
238933
|
-
const resolvedConfigPath = (0, import_node_path3.resolve)(configPath);
|
|
238934
|
-
const { options, fileNames, errors } = parseTsConfig(resolvedConfigPath);
|
|
238892
|
+
const configPath = typeof configPathOrOptions == "string" ? configPathOrOptions : configPathOrOptions.configPath, fileFilter = typeof configPathOrOptions == "object" ? configPathOrOptions.fileFilter : void 0, projectDir = typeof configPathOrOptions == "object" ? configPathOrOptions.projectDir : void 0, resolvedConfigPath = (0, import_node_path4.resolve)(configPath), { options, fileNames, errors } = parseTsConfig(resolvedConfigPath);
|
|
238935
238893
|
function makeHost() {
|
|
238936
|
-
return fileFilter || projectDir ?
|
|
238894
|
+
return createThinkwellHost(fileFilter || projectDir ? { compilerOptions: options, fileFilter, projectDir } : options);
|
|
238937
238895
|
}
|
|
238938
238896
|
__name(makeHost, "makeHost");
|
|
238939
|
-
if (errors.length > 0) {
|
|
238940
|
-
const
|
|
238941
|
-
|
|
238942
|
-
const host2 = makeHost();
|
|
238943
|
-
const program2 = import_typescript2.default.createProgram([], options, host2);
|
|
238944
|
-
return { program: program2, configErrors: errors };
|
|
238945
|
-
}
|
|
238897
|
+
if (errors.length > 0 && errors.filter((d) => d.category === import_typescript2.default.DiagnosticCategory.Error).length > 0) {
|
|
238898
|
+
const host2 = makeHost();
|
|
238899
|
+
return { program: import_typescript2.default.createProgram([], options, host2), configErrors: errors };
|
|
238946
238900
|
}
|
|
238947
238901
|
const host = makeHost();
|
|
238948
|
-
|
|
238949
|
-
return { program, configErrors: errors };
|
|
238902
|
+
return { program: import_typescript2.default.createProgram(fileNames, options, host), configErrors: errors };
|
|
238950
238903
|
}
|
|
238951
238904
|
__name(createThinkwellProgram, "createThinkwellProgram");
|
|
238952
238905
|
function patchHost(host, fileFilter, projectDir) {
|
|
238953
|
-
const originalGetSourceFile = host.getSourceFile.bind(host);
|
|
238954
|
-
|
|
238955
|
-
host.getDefaultLibLocation = () => tsLibDir;
|
|
238956
|
-
host.getDefaultLibFileName = (options) => (0, import_node_path3.join)(tsLibDir, import_typescript2.default.getDefaultLibFileName(options));
|
|
238957
|
-
host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
238906
|
+
const originalGetSourceFile = host.getSourceFile.bind(host), tsLibDir = getTypeScriptLibDir();
|
|
238907
|
+
host.getDefaultLibLocation = () => tsLibDir, host.getDefaultLibFileName = (options) => (0, import_node_path4.join)(tsLibDir, import_typescript2.default.getDefaultLibFileName(options)), host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
238958
238908
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
238959
|
-
if (source === void 0)
|
|
238909
|
+
if (source === void 0)
|
|
238960
238910
|
return originalGetSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
238961
|
-
|
|
238962
|
-
|
|
238963
|
-
|
|
238964
|
-
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238965
|
-
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238966
|
-
}
|
|
238911
|
+
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source) && (!fileFilter || fileFilter(fileName))) {
|
|
238912
|
+
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238913
|
+
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238967
238914
|
}
|
|
238968
238915
|
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238969
238916
|
};
|
|
238970
238917
|
}
|
|
238971
238918
|
__name(patchHost, "patchHost");
|
|
238972
238919
|
function createThinkwellWatchHost(options) {
|
|
238973
|
-
const { configPath, fileFilter, projectDir, reportDiagnostic, reportWatchStatus } = options;
|
|
238974
|
-
const createProgram = /* @__PURE__ */ __name((rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
238975
|
-
if (host) {
|
|
238976
|
-
patchHost(host, fileFilter, projectDir);
|
|
238977
|
-
}
|
|
238978
|
-
return import_typescript2.default.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences);
|
|
238979
|
-
}, "createProgram");
|
|
238920
|
+
const { configPath, fileFilter, projectDir, reportDiagnostic, reportWatchStatus } = options, createProgram = /* @__PURE__ */ __name((rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences) => (host && patchHost(host, fileFilter, projectDir), import_typescript2.default.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, compilerOptions, host, oldProgram, configFileParsingDiagnostics, projectReferences)), "createProgram");
|
|
238980
238921
|
return import_typescript2.default.createWatchCompilerHost(
|
|
238981
|
-
(0,
|
|
238922
|
+
(0, import_node_path4.resolve)(configPath),
|
|
238982
238923
|
/* optionsToExtend */
|
|
238983
238924
|
void 0,
|
|
238984
238925
|
import_typescript2.default.sys,
|
|
@@ -238998,8 +238939,8 @@ var whiteBold = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)(["
|
|
|
238998
238939
|
var dim = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)("dim", t), "dim");
|
|
238999
238940
|
|
|
239000
238941
|
// dist/cli/commands.js
|
|
239001
|
-
var
|
|
239002
|
-
var
|
|
238942
|
+
var import_node_fs4 = require("node:fs");
|
|
238943
|
+
var import_node_path5 = require("node:path");
|
|
239003
238944
|
var import_node_os = require("node:os");
|
|
239004
238945
|
var import_node_util2 = require("node:util");
|
|
239005
238946
|
var redBold = /* @__PURE__ */ __name((t) => (0, import_node_util2.styleText)(["red", "bold"], t), "redBold");
|
|
@@ -239009,13 +238950,13 @@ function fmtError(message) {
|
|
|
239009
238950
|
__name(fmtError, "fmtError");
|
|
239010
238951
|
|
|
239011
238952
|
// dist/cli/dependency-check.js
|
|
239012
|
-
var
|
|
239013
|
-
var
|
|
238953
|
+
var import_node_fs6 = require("node:fs");
|
|
238954
|
+
var import_node_path7 = require("node:path");
|
|
239014
238955
|
var import_node_child_process = require("node:child_process");
|
|
239015
238956
|
|
|
239016
238957
|
// dist/cli/package-manager.js
|
|
239017
|
-
var
|
|
239018
|
-
var
|
|
238958
|
+
var import_node_fs5 = require("node:fs");
|
|
238959
|
+
var import_node_path6 = require("node:path");
|
|
239019
238960
|
var LOCKFILES = [
|
|
239020
238961
|
{ file: "pnpm-lock.yaml", pm: "pnpm" },
|
|
239021
238962
|
{ file: "yarn.lock", pm: "yarn" },
|
|
@@ -239023,34 +238964,26 @@ var LOCKFILES = [
|
|
|
239023
238964
|
];
|
|
239024
238965
|
function detectByLockfile(projectDir) {
|
|
239025
238966
|
for (const { file, pm } of LOCKFILES) {
|
|
239026
|
-
const lockfilePath = (0,
|
|
239027
|
-
if ((0,
|
|
238967
|
+
const lockfilePath = (0, import_node_path6.join)(projectDir, file);
|
|
238968
|
+
if ((0, import_node_fs5.existsSync)(lockfilePath))
|
|
239028
238969
|
return { pm, lockfile: file };
|
|
239029
|
-
}
|
|
239030
238970
|
}
|
|
239031
238971
|
return null;
|
|
239032
238972
|
}
|
|
239033
238973
|
__name(detectByLockfile, "detectByLockfile");
|
|
239034
238974
|
function parsePackageManagerField(value) {
|
|
239035
|
-
if (typeof value
|
|
238975
|
+
if (typeof value != "string")
|
|
239036
238976
|
return null;
|
|
239037
|
-
|
|
239038
|
-
|
|
239039
|
-
const name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
239040
|
-
if (name === "pnpm" || name === "npm" || name === "yarn") {
|
|
239041
|
-
return name;
|
|
239042
|
-
}
|
|
239043
|
-
return null;
|
|
238977
|
+
const atIndex = value.indexOf("@"), name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
238978
|
+
return name === "pnpm" || name === "npm" || name === "yarn" ? name : null;
|
|
239044
238979
|
}
|
|
239045
238980
|
__name(parsePackageManagerField, "parsePackageManagerField");
|
|
239046
238981
|
function detectByPackageJson(projectDir) {
|
|
239047
|
-
const pkgPath = (0,
|
|
239048
|
-
if (!(0,
|
|
238982
|
+
const pkgPath = (0, import_node_path6.join)(projectDir, "package.json");
|
|
238983
|
+
if (!(0, import_node_fs5.existsSync)(pkgPath))
|
|
239049
238984
|
return null;
|
|
239050
|
-
}
|
|
239051
238985
|
try {
|
|
239052
|
-
const content = (0,
|
|
239053
|
-
const pkg = JSON.parse(content);
|
|
238986
|
+
const content = (0, import_node_fs5.readFileSync)(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
239054
238987
|
return parsePackageManagerField(pkg.packageManager);
|
|
239055
238988
|
} catch {
|
|
239056
238989
|
return null;
|
|
@@ -239086,25 +239019,20 @@ function createPackageManagerInfo(name, lockfile) {
|
|
|
239086
239019
|
__name(createPackageManagerInfo, "createPackageManagerInfo");
|
|
239087
239020
|
function detectPackageManager(projectDir) {
|
|
239088
239021
|
const lockfileResult = detectByLockfile(projectDir);
|
|
239089
|
-
if (lockfileResult)
|
|
239022
|
+
if (lockfileResult)
|
|
239090
239023
|
return createPackageManagerInfo(lockfileResult.pm, lockfileResult.lockfile);
|
|
239091
|
-
}
|
|
239092
239024
|
const fromField = detectByPackageJson(projectDir);
|
|
239093
|
-
|
|
239094
|
-
return createPackageManagerInfo(fromField, null);
|
|
239095
|
-
}
|
|
239096
|
-
return createPackageManagerInfo("npm", null);
|
|
239025
|
+
return createPackageManagerInfo(fromField || "npm", null);
|
|
239097
239026
|
}
|
|
239098
239027
|
__name(detectPackageManager, "detectPackageManager");
|
|
239099
239028
|
|
|
239100
239029
|
// dist/cli/dependency-check.js
|
|
239101
239030
|
function readPackageJson(dir) {
|
|
239102
|
-
const pkgPath = (0,
|
|
239103
|
-
if (!(0,
|
|
239031
|
+
const pkgPath = (0, import_node_path7.join)(dir, "package.json");
|
|
239032
|
+
if (!(0, import_node_fs6.existsSync)(pkgPath))
|
|
239104
239033
|
return null;
|
|
239105
|
-
}
|
|
239106
239034
|
try {
|
|
239107
|
-
const content = (0,
|
|
239035
|
+
const content = (0, import_node_fs6.readFileSync)(pkgPath, "utf-8");
|
|
239108
239036
|
return JSON.parse(content);
|
|
239109
239037
|
} catch {
|
|
239110
239038
|
return null;
|
|
@@ -239118,42 +239046,31 @@ function checkPackageJsonDirect(pkg, packageName) {
|
|
|
239118
239046
|
pkg.peerDependencies,
|
|
239119
239047
|
pkg.optionalDependencies
|
|
239120
239048
|
];
|
|
239121
|
-
for (const deps of depTypes)
|
|
239122
|
-
if (deps && packageName in deps)
|
|
239049
|
+
for (const deps of depTypes)
|
|
239050
|
+
if (deps && packageName in deps)
|
|
239123
239051
|
return {
|
|
239124
239052
|
found: true,
|
|
239125
239053
|
version: deps[packageName],
|
|
239126
239054
|
source: "package.json"
|
|
239127
239055
|
};
|
|
239128
|
-
}
|
|
239129
|
-
}
|
|
239130
239056
|
return null;
|
|
239131
239057
|
}
|
|
239132
239058
|
__name(checkPackageJsonDirect, "checkPackageJsonDirect");
|
|
239133
239059
|
function execCommand(cmd, cwd) {
|
|
239134
|
-
return new Promise((
|
|
239135
|
-
const [command, ...args] = cmd
|
|
239136
|
-
const proc = (0, import_node_child_process.spawn)(command, args, {
|
|
239060
|
+
return new Promise((resolve4, reject) => {
|
|
239061
|
+
const [command, ...args] = cmd, proc = (0, import_node_child_process.spawn)(command, args, {
|
|
239137
239062
|
cwd,
|
|
239138
239063
|
stdio: ["ignore", "pipe", "pipe"]
|
|
239139
239064
|
});
|
|
239140
|
-
let stdout = "";
|
|
239141
|
-
let stderr = "";
|
|
239065
|
+
let stdout = "", stderr = "";
|
|
239142
239066
|
proc.stdout.on("data", (data) => {
|
|
239143
239067
|
stdout += data.toString();
|
|
239144
|
-
})
|
|
239145
|
-
proc.stderr.on("data", (data) => {
|
|
239068
|
+
}), proc.stderr.on("data", (data) => {
|
|
239146
239069
|
stderr += data.toString();
|
|
239147
|
-
})
|
|
239148
|
-
proc.on("error", (err) => {
|
|
239070
|
+
}), proc.on("error", (err) => {
|
|
239149
239071
|
reject(err);
|
|
239150
|
-
})
|
|
239151
|
-
|
|
239152
|
-
if (code === 0) {
|
|
239153
|
-
resolve3({ stdout, stderr });
|
|
239154
|
-
} else {
|
|
239155
|
-
reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
239156
|
-
}
|
|
239072
|
+
}), proc.on("close", (code) => {
|
|
239073
|
+
code === 0 ? resolve4({ stdout, stderr }) : reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
239157
239074
|
});
|
|
239158
239075
|
});
|
|
239159
239076
|
}
|
|
@@ -239161,15 +239078,11 @@ __name(execCommand, "execCommand");
|
|
|
239161
239078
|
function parsePnpmWhyOutput(stdout, packageName) {
|
|
239162
239079
|
try {
|
|
239163
239080
|
const result = JSON.parse(stdout);
|
|
239164
|
-
|
|
239165
|
-
|
|
239166
|
-
|
|
239167
|
-
|
|
239168
|
-
|
|
239169
|
-
source: "workspace"
|
|
239170
|
-
};
|
|
239171
|
-
}
|
|
239172
|
-
return null;
|
|
239081
|
+
return result && typeof result == "object" && packageName in result ? {
|
|
239082
|
+
found: true,
|
|
239083
|
+
version: result[packageName]?.version,
|
|
239084
|
+
source: "workspace"
|
|
239085
|
+
} : null;
|
|
239173
239086
|
} catch {
|
|
239174
239087
|
return null;
|
|
239175
239088
|
}
|
|
@@ -239178,15 +239091,11 @@ __name(parsePnpmWhyOutput, "parsePnpmWhyOutput");
|
|
|
239178
239091
|
function parseNpmWhyOutput(stdout, _packageName) {
|
|
239179
239092
|
try {
|
|
239180
239093
|
const result = JSON.parse(stdout);
|
|
239181
|
-
|
|
239182
|
-
|
|
239183
|
-
|
|
239184
|
-
|
|
239185
|
-
|
|
239186
|
-
source: "workspace"
|
|
239187
|
-
};
|
|
239188
|
-
}
|
|
239189
|
-
return null;
|
|
239094
|
+
return Array.isArray(result) && result.length > 0 ? {
|
|
239095
|
+
found: true,
|
|
239096
|
+
version: result[0]?.version,
|
|
239097
|
+
source: "workspace"
|
|
239098
|
+
} : null;
|
|
239190
239099
|
} catch {
|
|
239191
239100
|
return null;
|
|
239192
239101
|
}
|
|
@@ -239196,7 +239105,8 @@ function parseYarnWhyOutput(stdout, _packageName) {
|
|
|
239196
239105
|
if (stdout.trim().length > 0) {
|
|
239197
239106
|
let version;
|
|
239198
239107
|
try {
|
|
239199
|
-
const lines = stdout.trim().split(
|
|
239108
|
+
const lines = stdout.trim().split(`
|
|
239109
|
+
`);
|
|
239200
239110
|
for (const line of lines) {
|
|
239201
239111
|
const obj = JSON.parse(line);
|
|
239202
239112
|
if (obj.type === "info" && obj.data) {
|
|
@@ -239236,31 +239146,21 @@ async function checkViaPackageManager(pm, packageName, cwd) {
|
|
|
239236
239146
|
}
|
|
239237
239147
|
__name(checkViaPackageManager, "checkViaPackageManager");
|
|
239238
239148
|
async function checkDependencies(projectDir) {
|
|
239239
|
-
const pm = detectPackageManager(projectDir);
|
|
239240
|
-
|
|
239241
|
-
let thinkwellStatus = { found: false };
|
|
239242
|
-
let typescriptStatus = { found: false };
|
|
239149
|
+
const pm = detectPackageManager(projectDir), pkg = readPackageJson(projectDir);
|
|
239150
|
+
let thinkwellStatus = { found: false }, typescriptStatus = { found: false };
|
|
239243
239151
|
if (pkg) {
|
|
239244
239152
|
const thinkwellDirect = checkPackageJsonDirect(pkg, "thinkwell");
|
|
239245
|
-
|
|
239246
|
-
thinkwellStatus = thinkwellDirect;
|
|
239247
|
-
}
|
|
239153
|
+
thinkwellDirect && (thinkwellStatus = thinkwellDirect);
|
|
239248
239154
|
const typescriptDirect = checkPackageJsonDirect(pkg, "typescript");
|
|
239249
|
-
|
|
239250
|
-
typescriptStatus = typescriptDirect;
|
|
239251
|
-
}
|
|
239155
|
+
typescriptDirect && (typescriptStatus = typescriptDirect);
|
|
239252
239156
|
}
|
|
239253
239157
|
if (!thinkwellStatus.found) {
|
|
239254
239158
|
const result = await checkViaPackageManager(pm, "thinkwell", projectDir);
|
|
239255
|
-
|
|
239256
|
-
thinkwellStatus = result;
|
|
239257
|
-
}
|
|
239159
|
+
result && (thinkwellStatus = result);
|
|
239258
239160
|
}
|
|
239259
239161
|
if (!typescriptStatus.found) {
|
|
239260
239162
|
const result = await checkViaPackageManager(pm, "typescript", projectDir);
|
|
239261
|
-
|
|
239262
|
-
typescriptStatus = result;
|
|
239263
|
-
}
|
|
239163
|
+
result && (typescriptStatus = result);
|
|
239264
239164
|
}
|
|
239265
239165
|
return {
|
|
239266
239166
|
thinkwell: thinkwellStatus,
|
|
@@ -239270,40 +239170,18 @@ async function checkDependencies(projectDir) {
|
|
|
239270
239170
|
}
|
|
239271
239171
|
__name(checkDependencies, "checkDependencies");
|
|
239272
239172
|
function hasPackageJson(projectDir) {
|
|
239273
|
-
return (0,
|
|
239173
|
+
return (0, import_node_fs6.existsSync)((0, import_node_path7.join)(projectDir, "package.json"));
|
|
239274
239174
|
}
|
|
239275
239175
|
__name(hasPackageJson, "hasPackageJson");
|
|
239276
239176
|
|
|
239277
239177
|
// dist/cli/dependency-errors.js
|
|
239278
239178
|
function formatMissingDependencyError(result) {
|
|
239279
|
-
const { thinkwell, typescript, packageManager } = result;
|
|
239280
|
-
|
|
239281
|
-
const missing = [];
|
|
239282
|
-
if (!thinkwell.found)
|
|
239283
|
-
missing.push("thinkwell");
|
|
239284
|
-
if (!typescript.found)
|
|
239285
|
-
missing.push("typescript");
|
|
239286
|
-
if (missing.length === 0) {
|
|
239179
|
+
const { thinkwell, typescript, packageManager } = result, pm = packageManager, missing = [];
|
|
239180
|
+
if (thinkwell.found || missing.push("thinkwell"), typescript.found || missing.push("typescript"), missing.length === 0)
|
|
239287
239181
|
return "";
|
|
239288
|
-
}
|
|
239289
239182
|
const lines = [];
|
|
239290
|
-
|
|
239291
|
-
|
|
239292
|
-
} else {
|
|
239293
|
-
lines.push(`Error: This project has a package.json but is missing required dependencies.`);
|
|
239294
|
-
}
|
|
239295
|
-
lines.push("");
|
|
239296
|
-
lines.push("When a project has explicit configuration, thinkwell expects explicit dependencies.");
|
|
239297
|
-
lines.push("This ensures you get the versions you expect, not versions bundled with the CLI.");
|
|
239298
|
-
lines.push("");
|
|
239299
|
-
lines.push("Run 'thinkwell init' to add the required dependencies, or add them manually:");
|
|
239300
|
-
if (!thinkwell.found) {
|
|
239301
|
-
lines.push(` ${pm.addCommand("thinkwell")}`);
|
|
239302
|
-
}
|
|
239303
|
-
if (!typescript.found) {
|
|
239304
|
-
lines.push(` ${pm.addCommand("typescript", true)}`);
|
|
239305
|
-
}
|
|
239306
|
-
return lines.join("\n");
|
|
239183
|
+
return missing.length === 1 ? lines.push(`Error: This project has a package.json but no dependency on '${missing[0]}'.`) : lines.push("Error: This project has a package.json but is missing required dependencies."), lines.push(""), lines.push("When a project has explicit configuration, thinkwell expects explicit dependencies."), lines.push("This ensures you get the versions you expect, not versions bundled with the CLI."), lines.push(""), lines.push("Run 'thinkwell init' to add the required dependencies, or add them manually:"), thinkwell.found || lines.push(` ${pm.addCommand("thinkwell")}`), typescript.found || lines.push(` ${pm.addCommand("typescript", true)}`), lines.join(`
|
|
239184
|
+
`);
|
|
239307
239185
|
}
|
|
239308
239186
|
__name(formatMissingDependencyError, "formatMissingDependencyError");
|
|
239309
239187
|
function hasMissingDependencies(result) {
|
|
@@ -239313,54 +239191,38 @@ __name(hasMissingDependencies, "hasMissingDependencies");
|
|
|
239313
239191
|
|
|
239314
239192
|
// dist/cli/build.js
|
|
239315
239193
|
function readPackageJsonConfig(dir) {
|
|
239316
|
-
const pkgPath = (0,
|
|
239317
|
-
if (
|
|
239318
|
-
|
|
239319
|
-
|
|
239320
|
-
|
|
239321
|
-
|
|
239322
|
-
|
|
239323
|
-
|
|
239324
|
-
|
|
239325
|
-
return
|
|
239326
|
-
}
|
|
239327
|
-
const result = {};
|
|
239328
|
-
if (Array.isArray(config.include)) {
|
|
239329
|
-
result.include = config.include.filter((i) => typeof i === "string");
|
|
239330
|
-
}
|
|
239331
|
-
if (Array.isArray(config.exclude)) {
|
|
239332
|
-
result.exclude = config.exclude.filter((e) => typeof e === "string");
|
|
239194
|
+
const pkgPath = (0, import_node_path8.join)(dir, "package.json");
|
|
239195
|
+
if ((0, import_node_fs7.existsSync)(pkgPath))
|
|
239196
|
+
try {
|
|
239197
|
+
const content = (0, import_node_fs7.readFileSync)(pkgPath, "utf-8"), config = JSON.parse(content)?.thinkwell?.build;
|
|
239198
|
+
if (!config || typeof config != "object")
|
|
239199
|
+
return;
|
|
239200
|
+
const result = {};
|
|
239201
|
+
return Array.isArray(config.include) && (result.include = config.include.filter((i) => typeof i == "string")), Array.isArray(config.exclude) && (result.exclude = config.exclude.filter((e) => typeof e == "string")), result;
|
|
239202
|
+
} catch {
|
|
239203
|
+
return;
|
|
239333
239204
|
}
|
|
239334
|
-
return result;
|
|
239335
|
-
} catch {
|
|
239336
|
-
return void 0;
|
|
239337
|
-
}
|
|
239338
239205
|
}
|
|
239339
239206
|
__name(readPackageJsonConfig, "readPackageJsonConfig");
|
|
239340
239207
|
function createFileFilter(config) {
|
|
239341
239208
|
if (!config)
|
|
239342
|
-
return
|
|
239343
|
-
const { include, exclude } = config;
|
|
239344
|
-
|
|
239345
|
-
|
|
239346
|
-
|
|
239347
|
-
|
|
239348
|
-
|
|
239349
|
-
|
|
239350
|
-
for (const pattern of exclude) {
|
|
239351
|
-
if ((0, import_node_path7.matchesGlob)(fileName, pattern))
|
|
239352
|
-
return false;
|
|
239209
|
+
return;
|
|
239210
|
+
const { include, exclude } = config, hasInclude = include && include.length > 0, hasExclude = exclude && exclude.length > 0;
|
|
239211
|
+
if (!(!hasInclude && !hasExclude))
|
|
239212
|
+
return (fileName) => {
|
|
239213
|
+
if (hasExclude) {
|
|
239214
|
+
for (const pattern of exclude)
|
|
239215
|
+
if ((0, import_node_path8.matchesGlob)(fileName, pattern))
|
|
239216
|
+
return false;
|
|
239353
239217
|
}
|
|
239354
|
-
|
|
239355
|
-
|
|
239356
|
-
|
|
239357
|
-
|
|
239358
|
-
|
|
239218
|
+
if (hasInclude) {
|
|
239219
|
+
for (const pattern of include)
|
|
239220
|
+
if ((0, import_node_path8.matchesGlob)(fileName, pattern))
|
|
239221
|
+
return true;
|
|
239222
|
+
return false;
|
|
239359
239223
|
}
|
|
239360
|
-
return
|
|
239361
|
-
}
|
|
239362
|
-
return true;
|
|
239363
|
-
};
|
|
239224
|
+
return true;
|
|
239225
|
+
};
|
|
239364
239226
|
}
|
|
239365
239227
|
__name(createFileFilter, "createFileFilter");
|
|
239366
239228
|
var diagnosticsHost = {
|
|
@@ -239369,117 +239231,72 @@ var diagnosticsHost = {
|
|
|
239369
239231
|
getNewLine: /* @__PURE__ */ __name(() => import_typescript3.default.sys.newLine, "getNewLine")
|
|
239370
239232
|
};
|
|
239371
239233
|
function formatDiagnostics(diagnostics) {
|
|
239372
|
-
|
|
239373
|
-
return "";
|
|
239374
|
-
return import_typescript3.default.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticsHost);
|
|
239234
|
+
return diagnostics.length === 0 ? "" : import_typescript3.default.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticsHost);
|
|
239375
239235
|
}
|
|
239376
239236
|
__name(formatDiagnostics, "formatDiagnostics");
|
|
239377
239237
|
async function runBuild(options) {
|
|
239378
239238
|
const cwd = process.cwd();
|
|
239379
239239
|
if (hasPackageJson(cwd)) {
|
|
239380
239240
|
const depCheck = await checkDependencies(cwd);
|
|
239381
|
-
|
|
239382
|
-
console.error(formatMissingDependencyError(depCheck));
|
|
239383
|
-
process.exit(2);
|
|
239384
|
-
}
|
|
239385
|
-
}
|
|
239386
|
-
const configPath = options.project ? (0, import_node_path7.resolve)(cwd, options.project) : (0, import_node_path7.resolve)(cwd, "tsconfig.json");
|
|
239387
|
-
if (!(0, import_node_fs6.existsSync)(configPath)) {
|
|
239388
|
-
console.error(fmtError(`Cannot find ${options.project ?? "tsconfig.json"}`));
|
|
239389
|
-
console.error("");
|
|
239390
|
-
console.error(" Run this command from a directory with a tsconfig.json,");
|
|
239391
|
-
console.error(" or use --project to specify the path.");
|
|
239392
|
-
process.exit(1);
|
|
239393
|
-
}
|
|
239394
|
-
const pkgConfig = readPackageJsonConfig(cwd);
|
|
239395
|
-
const fileFilter = createFileFilter(pkgConfig);
|
|
239396
|
-
if (options.verbose && pkgConfig) {
|
|
239397
|
-
if (pkgConfig.include) {
|
|
239398
|
-
console.error(` @JSONSchema include: ${pkgConfig.include.join(", ")}`);
|
|
239399
|
-
}
|
|
239400
|
-
if (pkgConfig.exclude) {
|
|
239401
|
-
console.error(` @JSONSchema exclude: ${pkgConfig.exclude.join(", ")}`);
|
|
239402
|
-
}
|
|
239241
|
+
hasMissingDependencies(depCheck) && (console.error(formatMissingDependencyError(depCheck)), process.exit(2));
|
|
239403
239242
|
}
|
|
239243
|
+
const configPath = options.project ? (0, import_node_path8.resolve)(cwd, options.project) : (0, import_node_path8.resolve)(cwd, "tsconfig.json");
|
|
239244
|
+
(0, import_node_fs7.existsSync)(configPath) || (console.error(fmtError(`Cannot find ${options.project ?? "tsconfig.json"}`)), console.error(""), console.error(" Run this command from a directory with a tsconfig.json,"), console.error(" or use --project to specify the path."), process.exit(1));
|
|
239245
|
+
const pkgConfig = readPackageJsonConfig(cwd), fileFilter = createFileFilter(pkgConfig);
|
|
239246
|
+
options.verbose && pkgConfig && (pkgConfig.include && console.error(` @JSONSchema include: ${pkgConfig.include.join(", ")}`), pkgConfig.exclude && console.error(` @JSONSchema exclude: ${pkgConfig.exclude.join(", ")}`));
|
|
239404
239247
|
const projectDir = hasPackageJson(cwd) ? cwd : void 0;
|
|
239405
|
-
if (options.watch)
|
|
239248
|
+
if (options.watch)
|
|
239406
239249
|
return runWatch(configPath, fileFilter, projectDir);
|
|
239407
|
-
}
|
|
239408
239250
|
const { program, configErrors } = fileFilter || projectDir ? createThinkwellProgram({ configPath, fileFilter, projectDir }) : createThinkwellProgram(configPath);
|
|
239409
|
-
|
|
239410
|
-
console.error(formatDiagnostics(configErrors));
|
|
239411
|
-
const hasFatal = configErrors.some((d) => d.category === import_typescript3.default.DiagnosticCategory.Error);
|
|
239412
|
-
if (hasFatal) {
|
|
239413
|
-
process.exit(1);
|
|
239414
|
-
}
|
|
239415
|
-
}
|
|
239251
|
+
configErrors.length > 0 && (console.error(formatDiagnostics(configErrors)), configErrors.some((d) => d.category === import_typescript3.default.DiagnosticCategory.Error) && process.exit(1));
|
|
239416
239252
|
const diagnostics = import_typescript3.default.getPreEmitDiagnostics(program);
|
|
239417
|
-
|
|
239418
|
-
console.error(formatDiagnostics(diagnostics));
|
|
239419
|
-
}
|
|
239253
|
+
diagnostics.length > 0 && console.error(formatDiagnostics(diagnostics));
|
|
239420
239254
|
const emitResult = program.emit();
|
|
239421
|
-
|
|
239422
|
-
|
|
239423
|
-
}
|
|
239424
|
-
const allDiagnostics = [...diagnostics, ...emitResult.diagnostics];
|
|
239425
|
-
const errorCount = allDiagnostics.filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error).length;
|
|
239426
|
-
if (errorCount > 0) {
|
|
239427
|
-
console.error("");
|
|
239428
|
-
console.error(`Found ${errorCount} error${errorCount === 1 ? "" : "s"}.`);
|
|
239429
|
-
process.exit(1);
|
|
239430
|
-
}
|
|
239431
|
-
if (!options.quiet) {
|
|
239255
|
+
emitResult.diagnostics.length > 0 && console.error(formatDiagnostics(emitResult.diagnostics));
|
|
239256
|
+
const errorCount = [...diagnostics, ...emitResult.diagnostics].filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error).length;
|
|
239257
|
+
if (errorCount > 0 && (console.error(""), console.error(`Found ${errorCount} error${errorCount === 1 ? "" : "s"}.`), process.exit(1)), !options.quiet) {
|
|
239432
239258
|
const fileCount = program.getSourceFiles().filter((sf) => !sf.fileName.includes("node_modules") && !sf.fileName.includes("/lib/lib.")).length;
|
|
239433
239259
|
console.error((0, import_node_util3.styleText)("green", "\u2714") + ` Build complete (${fileCount} file${fileCount === 1 ? "" : "s"})`);
|
|
239434
239260
|
}
|
|
239435
239261
|
}
|
|
239436
239262
|
__name(runBuild, "runBuild");
|
|
239437
239263
|
function runWatch(configPath, fileFilter, projectDir) {
|
|
239438
|
-
const reportDiagnostic = /* @__PURE__ */ __name((diagnostic) => {
|
|
239439
|
-
console.error(import_typescript3.default.formatDiagnosticsWithColorAndContext([diagnostic], diagnosticsHost));
|
|
239440
|
-
}, "reportDiagnostic");
|
|
239441
|
-
const reportWatchStatus = /* @__PURE__ */ __name((diagnostic) => {
|
|
239442
|
-
console.error(import_typescript3.default.formatDiagnostic(diagnostic, diagnosticsHost).trimEnd());
|
|
239443
|
-
}, "reportWatchStatus");
|
|
239444
239264
|
const watchHost = createThinkwellWatchHost({
|
|
239445
239265
|
configPath,
|
|
239446
239266
|
fileFilter,
|
|
239447
239267
|
projectDir,
|
|
239448
|
-
reportDiagnostic
|
|
239449
|
-
|
|
239268
|
+
reportDiagnostic: /* @__PURE__ */ __name((diagnostic) => {
|
|
239269
|
+
console.error(import_typescript3.default.formatDiagnosticsWithColorAndContext([diagnostic], diagnosticsHost));
|
|
239270
|
+
}, "reportDiagnostic"),
|
|
239271
|
+
reportWatchStatus: /* @__PURE__ */ __name((diagnostic) => {
|
|
239272
|
+
console.error(import_typescript3.default.formatDiagnostic(diagnostic, diagnosticsHost).trimEnd());
|
|
239273
|
+
}, "reportWatchStatus")
|
|
239450
239274
|
});
|
|
239451
|
-
import_typescript3.default.createWatchProgram(watchHost)
|
|
239452
|
-
return new Promise(() => {
|
|
239275
|
+
return import_typescript3.default.createWatchProgram(watchHost), new Promise(() => {
|
|
239453
239276
|
});
|
|
239454
239277
|
}
|
|
239455
239278
|
__name(runWatch, "runWatch");
|
|
239456
239279
|
function parseBuildArgs(args) {
|
|
239457
239280
|
const options = {};
|
|
239458
239281
|
let i = 0;
|
|
239459
|
-
|
|
239282
|
+
for (; i < args.length; ) {
|
|
239460
239283
|
const arg = args[i];
|
|
239461
239284
|
if (arg === "-p" || arg === "--project") {
|
|
239462
|
-
i
|
|
239463
|
-
if (i >= args.length) {
|
|
239285
|
+
if (i++, i >= args.length)
|
|
239464
239286
|
throw new Error("Missing value for --project");
|
|
239465
|
-
}
|
|
239466
239287
|
options.project = args[i];
|
|
239467
|
-
} else if (arg === "--watch" || arg === "-w")
|
|
239288
|
+
} else if (arg === "--watch" || arg === "-w")
|
|
239468
239289
|
options.watch = true;
|
|
239469
|
-
|
|
239290
|
+
else if (arg === "--verbose")
|
|
239470
239291
|
options.verbose = true;
|
|
239471
|
-
|
|
239292
|
+
else if (arg === "--quiet" || arg === "-q")
|
|
239472
239293
|
options.quiet = true;
|
|
239473
|
-
|
|
239474
|
-
throw new Error(`Unknown option: ${arg}`);
|
|
239475
|
-
} else {
|
|
239476
|
-
throw new Error(`Unexpected argument: ${arg}
|
|
239294
|
+
else throw arg.startsWith("-") ? new Error(`Unknown option: ${arg}`) : new Error(`Unexpected argument: ${arg}
|
|
239477
239295
|
|
|
239478
239296
|
"thinkwell build" compiles the project using tsconfig.json.
|
|
239479
239297
|
It does not take an entry file argument.
|
|
239480
239298
|
|
|
239481
239299
|
Did you mean "thinkwell bundle ${arg}"?`);
|
|
239482
|
-
}
|
|
239483
239300
|
i++;
|
|
239484
239301
|
}
|
|
239485
239302
|
return options;
|
|
@@ -239527,7 +239344,8 @@ ${greenBold("Configuration via package.json:")}
|
|
|
239527
239344
|
|
|
239528
239345
|
${dim("Note: Files not matched by include (or matched by exclude) are still")}
|
|
239529
239346
|
${dim(" compiled by TypeScript \u2014 they just skip @JSONSchema transformation.")}
|
|
239530
|
-
`.trim() +
|
|
239347
|
+
`.trim() + `
|
|
239348
|
+
`);
|
|
239531
239349
|
}
|
|
239532
239350
|
__name(showBuildHelp, "showBuildHelp");
|
|
239533
239351
|
// Annotate the CommonJS export names for ESM import in node:
|