thinkwell 0.5.5 → 0.5.6
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 +207 -279
- 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.js +89 -245
- package/dist/cli/workspace.js +92 -226
- package/dist/connectors/index.js +1 -7
- package/dist/generated/features.d.ts +5 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +4 -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 +269 -370
- 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 +13385 -1876
- package/dist-pkg/cli-build.cjs +171 -369
- package/dist-pkg/cli-bundle.cjs +289 -690
- package/dist-pkg/cli-check.cjs +202 -415
- package/dist-pkg/cli-dependency-check.cjs +39 -82
- package/dist-pkg/cli-dependency-errors.cjs +9 -41
- package/dist-pkg/cli-loader.cjs +90 -173
- package/dist-pkg/protocol.cjs +2 -8
- package/dist-pkg/thinkwell.cjs +876 -1842
- package/package.json +7 -6
package/dist-pkg/cli-build.cjs
CHANGED
|
@@ -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,
|
|
@@ -238694,8 +238682,7 @@ __name(generateSchemas, "generateSchemas");
|
|
|
238694
238682
|
// dist/cli/schema.js
|
|
238695
238683
|
var JSONSCHEMA_TAG = "JSONSchema";
|
|
238696
238684
|
function hasJsDocTag(node, tagName) {
|
|
238697
|
-
|
|
238698
|
-
return jsDocNodes.some((tag) => tag.tagName.text === tagName);
|
|
238685
|
+
return import_typescript.default.getJSDocTags(node).some((tag) => tag.tagName.text === tagName);
|
|
238699
238686
|
}
|
|
238700
238687
|
__name(hasJsDocTag, "hasJsDocTag");
|
|
238701
238688
|
function findMarkedTypes(path, source) {
|
|
@@ -238705,48 +238692,36 @@ function findMarkedTypes(path, source) {
|
|
|
238705
238692
|
import_typescript.default.ScriptTarget.Latest,
|
|
238706
238693
|
true
|
|
238707
238694
|
// 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
|
-
}
|
|
238695
|
+
), results = [];
|
|
238696
|
+
return import_typescript.default.forEachChild(sourceFile, /* @__PURE__ */ __name(function visit(node) {
|
|
238697
|
+
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)) {
|
|
238698
|
+
const name = node.name?.text;
|
|
238699
|
+
if (name) {
|
|
238700
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
238701
|
+
let keyword = "interface";
|
|
238702
|
+
import_typescript.default.isTypeAliasDeclaration(node) ? keyword = "type" : import_typescript.default.isEnumDeclaration(node) ? keyword = "enum" : import_typescript.default.isClassDeclaration(node) && (keyword = "class");
|
|
238703
|
+
const declarationLength = keyword.length + 1 + name.length, isExported = node.modifiers?.some((m) => m.kind === import_typescript.default.SyntaxKind.ExportKeyword) ?? false;
|
|
238704
|
+
results.push({
|
|
238705
|
+
name,
|
|
238706
|
+
node,
|
|
238707
|
+
startPosition: node.getStart(),
|
|
238708
|
+
endPosition: node.getEnd(),
|
|
238709
|
+
line: line + 1,
|
|
238710
|
+
column: character + 1,
|
|
238711
|
+
declarationLength,
|
|
238712
|
+
isExported
|
|
238713
|
+
});
|
|
238736
238714
|
}
|
|
238737
238715
|
}
|
|
238738
238716
|
import_typescript.default.forEachChild(node, visit);
|
|
238739
|
-
}, "visit"));
|
|
238740
|
-
return results;
|
|
238717
|
+
}, "visit")), results;
|
|
238741
238718
|
}
|
|
238742
238719
|
__name(findMarkedTypes, "findMarkedTypes");
|
|
238743
238720
|
function resolveGenerateSchemas(projectDir) {
|
|
238744
238721
|
if (projectDir) {
|
|
238745
|
-
const
|
|
238746
|
-
|
|
238747
|
-
if (typeof buildMod.generateSchemas === "function") {
|
|
238722
|
+
const buildMod = (0, import_node_module.createRequire)((0, import_node_path2.join)(projectDir, "package.json"))("thinkwell/build");
|
|
238723
|
+
if (typeof buildMod.generateSchemas == "function")
|
|
238748
238724
|
return buildMod.generateSchemas;
|
|
238749
|
-
}
|
|
238750
238725
|
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
238726
|
}
|
|
238752
238727
|
return generateSchemas;
|
|
@@ -238754,18 +238729,14 @@ function resolveGenerateSchemas(projectDir) {
|
|
|
238754
238729
|
__name(resolveGenerateSchemas, "resolveGenerateSchemas");
|
|
238755
238730
|
function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
238756
238731
|
const schemas = /* @__PURE__ */ new Map();
|
|
238757
|
-
if (types.length === 0)
|
|
238732
|
+
if (types.length === 0)
|
|
238758
238733
|
return schemas;
|
|
238759
|
-
}
|
|
238760
238734
|
const buildGenerateSchemas = resolveGenerateSchemas(projectDir);
|
|
238761
238735
|
for (const typeInfo of types) {
|
|
238762
238736
|
const { name, line, column } = typeInfo;
|
|
238763
238737
|
try {
|
|
238764
|
-
const
|
|
238765
|
-
|
|
238766
|
-
if (schema) {
|
|
238767
|
-
schemas.set(name, schema);
|
|
238768
|
-
}
|
|
238738
|
+
const schema = buildGenerateSchemas(path, [name]).get(name);
|
|
238739
|
+
schema && schemas.set(name, schema);
|
|
238769
238740
|
} catch (error) {
|
|
238770
238741
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
238771
238742
|
throw new Error(`Failed to generate schema for type '${name}' at ${path}:${line}:${column}
|
|
@@ -238778,27 +238749,27 @@ function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
|
238778
238749
|
__name(generateSchemas2, "generateSchemas");
|
|
238779
238750
|
var ACP_NAMESPACE = "$$__thinkwell__acp__$$";
|
|
238780
238751
|
function generateNamespace(name, schema, isExported) {
|
|
238781
|
-
const schemaJson = JSON.stringify(schema, null, 2).split(
|
|
238782
|
-
|
|
238752
|
+
const schemaJson = JSON.stringify(schema, null, 2).split(`
|
|
238753
|
+
`).map((line, i) => i === 0 ? line : " " + line).join(`
|
|
238754
|
+
`);
|
|
238783
238755
|
return [
|
|
238784
|
-
`${
|
|
238756
|
+
`${isExported ? "export " : ""}namespace ${name} {`,
|
|
238785
238757
|
` export const Schema: ${ACP_NAMESPACE}.SchemaProvider<${name}> = {`,
|
|
238786
238758
|
` toJsonSchema: () => (${schemaJson}) as ${ACP_NAMESPACE}.JsonSchema,`,
|
|
238787
|
-
|
|
238788
|
-
|
|
238789
|
-
].join(
|
|
238759
|
+
" };",
|
|
238760
|
+
"}"
|
|
238761
|
+
].join(`
|
|
238762
|
+
`);
|
|
238790
238763
|
}
|
|
238791
238764
|
__name(generateNamespace, "generateNamespace");
|
|
238792
238765
|
function generateInsertions(types, schemas) {
|
|
238793
238766
|
const insertions = [];
|
|
238794
238767
|
for (const { name, endPosition, isExported } of types) {
|
|
238795
238768
|
const schema = schemas.get(name);
|
|
238796
|
-
|
|
238797
|
-
continue;
|
|
238798
|
-
}
|
|
238799
|
-
insertions.push({
|
|
238769
|
+
schema && insertions.push({
|
|
238800
238770
|
position: endPosition,
|
|
238801
|
-
code:
|
|
238771
|
+
code: `
|
|
238772
|
+
` + generateNamespace(name, schema, isExported)
|
|
238802
238773
|
});
|
|
238803
238774
|
}
|
|
238804
238775
|
return insertions.sort((a, b) => b.position - a.position);
|
|
@@ -238810,9 +238781,8 @@ function generateSchemaImport() {
|
|
|
238810
238781
|
__name(generateSchemaImport, "generateSchemaImport");
|
|
238811
238782
|
function applyInsertions(source, insertions) {
|
|
238812
238783
|
let result = source;
|
|
238813
|
-
for (const { position, code } of insertions)
|
|
238784
|
+
for (const { position, code } of insertions)
|
|
238814
238785
|
result = result.slice(0, position) + code + result.slice(position);
|
|
238815
|
-
}
|
|
238816
238786
|
return result;
|
|
238817
238787
|
}
|
|
238818
238788
|
__name(applyInsertions, "applyInsertions");
|
|
@@ -238821,43 +238791,37 @@ function hasJsonSchemaMarkers(source) {
|
|
|
238821
238791
|
}
|
|
238822
238792
|
__name(hasJsonSchemaMarkers, "hasJsonSchemaMarkers");
|
|
238823
238793
|
function transformJsonSchemas(path, source, projectDir) {
|
|
238824
|
-
if (!hasJsonSchemaMarkers(source))
|
|
238794
|
+
if (!hasJsonSchemaMarkers(source))
|
|
238825
238795
|
return source;
|
|
238826
|
-
}
|
|
238827
238796
|
const markedTypes = findMarkedTypes(path, source);
|
|
238828
|
-
if (markedTypes.length === 0)
|
|
238797
|
+
if (markedTypes.length === 0)
|
|
238829
238798
|
return source;
|
|
238830
|
-
|
|
238831
|
-
const schemas = generateSchemas2(path, markedTypes, source, projectDir);
|
|
238832
|
-
const insertions = generateInsertions(markedTypes, schemas);
|
|
238799
|
+
const schemas = generateSchemas2(path, markedTypes, source, projectDir), insertions = generateInsertions(markedTypes, schemas);
|
|
238833
238800
|
let modifiedSource = applyInsertions(source, insertions);
|
|
238834
|
-
modifiedSource = generateSchemaImport() +
|
|
238835
|
-
|
|
238801
|
+
return modifiedSource = generateSchemaImport() + `
|
|
238802
|
+
` + modifiedSource, modifiedSource;
|
|
238836
238803
|
}
|
|
238837
238804
|
__name(transformJsonSchemas, "transformJsonSchemas");
|
|
238838
238805
|
|
|
238839
238806
|
// dist/cli/compiler-host.js
|
|
238840
238807
|
function getTypeScriptLibDir() {
|
|
238841
|
-
if (typeof process.pkg
|
|
238808
|
+
if (typeof process.pkg < "u") {
|
|
238842
238809
|
const snapshotLibDir = "/snapshot/thinkwell/packages/thinkwell/dist-pkg/typescript-lib";
|
|
238843
|
-
if ((0, import_node_fs2.existsSync)(snapshotLibDir))
|
|
238810
|
+
if ((0, import_node_fs2.existsSync)(snapshotLibDir))
|
|
238844
238811
|
return snapshotLibDir;
|
|
238845
|
-
}
|
|
238846
238812
|
}
|
|
238847
238813
|
return (0, import_node_path3.dirname)(import_typescript2.default.getDefaultLibFilePath({}));
|
|
238848
238814
|
}
|
|
238849
238815
|
__name(getTypeScriptLibDir, "getTypeScriptLibDir");
|
|
238850
238816
|
function parseTsConfig(configPath) {
|
|
238851
238817
|
const configFile = import_typescript2.default.readConfigFile(configPath, import_typescript2.default.sys.readFile);
|
|
238852
|
-
if (configFile.error)
|
|
238818
|
+
if (configFile.error)
|
|
238853
238819
|
return {
|
|
238854
238820
|
options: {},
|
|
238855
238821
|
fileNames: [],
|
|
238856
238822
|
errors: [configFile.error]
|
|
238857
238823
|
};
|
|
238858
|
-
|
|
238859
|
-
const configDir = (0, import_node_path3.dirname)(configPath);
|
|
238860
|
-
const parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238824
|
+
const configDir = (0, import_node_path3.dirname)(configPath), parsed = import_typescript2.default.parseJsonConfigFileContent(
|
|
238861
238825
|
configFile.config,
|
|
238862
238826
|
import_typescript2.default.sys,
|
|
238863
238827
|
configDir,
|
|
@@ -238873,32 +238837,17 @@ function parseTsConfig(configPath) {
|
|
|
238873
238837
|
}
|
|
238874
238838
|
__name(parseTsConfig, "parseTsConfig");
|
|
238875
238839
|
function shouldTransform(fileName) {
|
|
238876
|
-
|
|
238877
|
-
return false;
|
|
238878
|
-
if (fileName.includes("/lib/lib."))
|
|
238879
|
-
return false;
|
|
238880
|
-
return true;
|
|
238840
|
+
return !(fileName.includes("node_modules") || fileName.includes("/lib/lib."));
|
|
238881
238841
|
}
|
|
238882
238842
|
__name(shouldTransform, "shouldTransform");
|
|
238883
238843
|
function isThinkwellHostOptions(options) {
|
|
238884
|
-
return typeof options.compilerOptions
|
|
238844
|
+
return typeof options.compilerOptions == "object" && options.compilerOptions !== null && !Array.isArray(options.compilerOptions);
|
|
238885
238845
|
}
|
|
238886
238846
|
__name(isThinkwellHostOptions, "isThinkwellHostOptions");
|
|
238887
238847
|
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();
|
|
238848
|
+
let compilerOptions, fileFilter, projectDir;
|
|
238849
|
+
isThinkwellHostOptions(options) ? (compilerOptions = options.compilerOptions, fileFilter = options.fileFilter, projectDir = options.projectDir) : (compilerOptions = options, fileFilter = void 0, projectDir = void 0);
|
|
238850
|
+
const defaultHost = import_typescript2.default.createCompilerHost(compilerOptions), tsLibDir = getTypeScriptLibDir();
|
|
238902
238851
|
return {
|
|
238903
238852
|
...defaultHost,
|
|
238904
238853
|
// Override getDefaultLibLocation to point to our bundled TypeScript lib files
|
|
@@ -238912,71 +238861,47 @@ function createThinkwellHost(options) {
|
|
|
238912
238861
|
},
|
|
238913
238862
|
getSourceFile(fileName, languageVersionOrOptions) {
|
|
238914
238863
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
238915
|
-
if (source
|
|
238916
|
-
|
|
238917
|
-
}
|
|
238918
|
-
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source)) {
|
|
238919
|
-
if (!fileFilter || fileFilter(fileName)) {
|
|
238864
|
+
if (source !== void 0) {
|
|
238865
|
+
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source) && (!fileFilter || fileFilter(fileName))) {
|
|
238920
238866
|
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238921
238867
|
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238922
238868
|
}
|
|
238869
|
+
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238923
238870
|
}
|
|
238924
|
-
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238925
238871
|
}
|
|
238926
238872
|
};
|
|
238927
238873
|
}
|
|
238928
238874
|
__name(createThinkwellHost, "createThinkwellHost");
|
|
238929
238875
|
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);
|
|
238876
|
+
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_path3.resolve)(configPath), { options, fileNames, errors } = parseTsConfig(resolvedConfigPath);
|
|
238935
238877
|
function makeHost() {
|
|
238936
|
-
return fileFilter || projectDir ?
|
|
238878
|
+
return createThinkwellHost(fileFilter || projectDir ? { compilerOptions: options, fileFilter, projectDir } : options);
|
|
238937
238879
|
}
|
|
238938
238880
|
__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
|
-
}
|
|
238881
|
+
if (errors.length > 0 && errors.filter((d) => d.category === import_typescript2.default.DiagnosticCategory.Error).length > 0) {
|
|
238882
|
+
const host2 = makeHost();
|
|
238883
|
+
return { program: import_typescript2.default.createProgram([], options, host2), configErrors: errors };
|
|
238946
238884
|
}
|
|
238947
238885
|
const host = makeHost();
|
|
238948
|
-
|
|
238949
|
-
return { program, configErrors: errors };
|
|
238886
|
+
return { program: import_typescript2.default.createProgram(fileNames, options, host), configErrors: errors };
|
|
238950
238887
|
}
|
|
238951
238888
|
__name(createThinkwellProgram, "createThinkwellProgram");
|
|
238952
238889
|
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) => {
|
|
238890
|
+
const originalGetSourceFile = host.getSourceFile.bind(host), tsLibDir = getTypeScriptLibDir();
|
|
238891
|
+
host.getDefaultLibLocation = () => tsLibDir, host.getDefaultLibFileName = (options) => (0, import_node_path3.join)(tsLibDir, import_typescript2.default.getDefaultLibFileName(options)), host.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
238958
238892
|
const source = import_typescript2.default.sys.readFile(fileName);
|
|
238959
|
-
if (source === void 0)
|
|
238893
|
+
if (source === void 0)
|
|
238960
238894
|
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
|
-
}
|
|
238895
|
+
if (shouldTransform(fileName) && hasJsonSchemaMarkers(source) && (!fileFilter || fileFilter(fileName))) {
|
|
238896
|
+
const transformed = transformJsonSchemas(fileName, source, projectDir);
|
|
238897
|
+
return import_typescript2.default.createSourceFile(fileName, transformed, languageVersionOrOptions);
|
|
238967
238898
|
}
|
|
238968
238899
|
return import_typescript2.default.createSourceFile(fileName, source, languageVersionOrOptions);
|
|
238969
238900
|
};
|
|
238970
238901
|
}
|
|
238971
238902
|
__name(patchHost, "patchHost");
|
|
238972
238903
|
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");
|
|
238904
|
+
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
238905
|
return import_typescript2.default.createWatchCompilerHost(
|
|
238981
238906
|
(0, import_node_path3.resolve)(configPath),
|
|
238982
238907
|
/* optionsToExtend */
|
|
@@ -239024,33 +238949,25 @@ var LOCKFILES = [
|
|
|
239024
238949
|
function detectByLockfile(projectDir) {
|
|
239025
238950
|
for (const { file, pm } of LOCKFILES) {
|
|
239026
238951
|
const lockfilePath = (0, import_node_path5.join)(projectDir, file);
|
|
239027
|
-
if ((0, import_node_fs4.existsSync)(lockfilePath))
|
|
238952
|
+
if ((0, import_node_fs4.existsSync)(lockfilePath))
|
|
239028
238953
|
return { pm, lockfile: file };
|
|
239029
|
-
}
|
|
239030
238954
|
}
|
|
239031
238955
|
return null;
|
|
239032
238956
|
}
|
|
239033
238957
|
__name(detectByLockfile, "detectByLockfile");
|
|
239034
238958
|
function parsePackageManagerField(value) {
|
|
239035
|
-
if (typeof value
|
|
238959
|
+
if (typeof value != "string")
|
|
239036
238960
|
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;
|
|
238961
|
+
const atIndex = value.indexOf("@"), name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
238962
|
+
return name === "pnpm" || name === "npm" || name === "yarn" ? name : null;
|
|
239044
238963
|
}
|
|
239045
238964
|
__name(parsePackageManagerField, "parsePackageManagerField");
|
|
239046
238965
|
function detectByPackageJson(projectDir) {
|
|
239047
238966
|
const pkgPath = (0, import_node_path5.join)(projectDir, "package.json");
|
|
239048
|
-
if (!(0, import_node_fs4.existsSync)(pkgPath))
|
|
238967
|
+
if (!(0, import_node_fs4.existsSync)(pkgPath))
|
|
239049
238968
|
return null;
|
|
239050
|
-
}
|
|
239051
238969
|
try {
|
|
239052
|
-
const content = (0, import_node_fs4.readFileSync)(pkgPath, "utf-8");
|
|
239053
|
-
const pkg = JSON.parse(content);
|
|
238970
|
+
const content = (0, import_node_fs4.readFileSync)(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
239054
238971
|
return parsePackageManagerField(pkg.packageManager);
|
|
239055
238972
|
} catch {
|
|
239056
238973
|
return null;
|
|
@@ -239086,23 +239003,18 @@ function createPackageManagerInfo(name, lockfile) {
|
|
|
239086
239003
|
__name(createPackageManagerInfo, "createPackageManagerInfo");
|
|
239087
239004
|
function detectPackageManager(projectDir) {
|
|
239088
239005
|
const lockfileResult = detectByLockfile(projectDir);
|
|
239089
|
-
if (lockfileResult)
|
|
239006
|
+
if (lockfileResult)
|
|
239090
239007
|
return createPackageManagerInfo(lockfileResult.pm, lockfileResult.lockfile);
|
|
239091
|
-
}
|
|
239092
239008
|
const fromField = detectByPackageJson(projectDir);
|
|
239093
|
-
|
|
239094
|
-
return createPackageManagerInfo(fromField, null);
|
|
239095
|
-
}
|
|
239096
|
-
return createPackageManagerInfo("npm", null);
|
|
239009
|
+
return createPackageManagerInfo(fromField || "npm", null);
|
|
239097
239010
|
}
|
|
239098
239011
|
__name(detectPackageManager, "detectPackageManager");
|
|
239099
239012
|
|
|
239100
239013
|
// dist/cli/dependency-check.js
|
|
239101
239014
|
function readPackageJson(dir) {
|
|
239102
239015
|
const pkgPath = (0, import_node_path6.join)(dir, "package.json");
|
|
239103
|
-
if (!(0, import_node_fs5.existsSync)(pkgPath))
|
|
239016
|
+
if (!(0, import_node_fs5.existsSync)(pkgPath))
|
|
239104
239017
|
return null;
|
|
239105
|
-
}
|
|
239106
239018
|
try {
|
|
239107
239019
|
const content = (0, import_node_fs5.readFileSync)(pkgPath, "utf-8");
|
|
239108
239020
|
return JSON.parse(content);
|
|
@@ -239118,42 +239030,31 @@ function checkPackageJsonDirect(pkg, packageName) {
|
|
|
239118
239030
|
pkg.peerDependencies,
|
|
239119
239031
|
pkg.optionalDependencies
|
|
239120
239032
|
];
|
|
239121
|
-
for (const deps of depTypes)
|
|
239122
|
-
if (deps && packageName in deps)
|
|
239033
|
+
for (const deps of depTypes)
|
|
239034
|
+
if (deps && packageName in deps)
|
|
239123
239035
|
return {
|
|
239124
239036
|
found: true,
|
|
239125
239037
|
version: deps[packageName],
|
|
239126
239038
|
source: "package.json"
|
|
239127
239039
|
};
|
|
239128
|
-
}
|
|
239129
|
-
}
|
|
239130
239040
|
return null;
|
|
239131
239041
|
}
|
|
239132
239042
|
__name(checkPackageJsonDirect, "checkPackageJsonDirect");
|
|
239133
239043
|
function execCommand(cmd, cwd) {
|
|
239134
239044
|
return new Promise((resolve3, reject) => {
|
|
239135
|
-
const [command, ...args] = cmd
|
|
239136
|
-
const proc = (0, import_node_child_process.spawn)(command, args, {
|
|
239045
|
+
const [command, ...args] = cmd, proc = (0, import_node_child_process.spawn)(command, args, {
|
|
239137
239046
|
cwd,
|
|
239138
239047
|
stdio: ["ignore", "pipe", "pipe"]
|
|
239139
239048
|
});
|
|
239140
|
-
let stdout = "";
|
|
239141
|
-
let stderr = "";
|
|
239049
|
+
let stdout = "", stderr = "";
|
|
239142
239050
|
proc.stdout.on("data", (data) => {
|
|
239143
239051
|
stdout += data.toString();
|
|
239144
|
-
})
|
|
239145
|
-
proc.stderr.on("data", (data) => {
|
|
239052
|
+
}), proc.stderr.on("data", (data) => {
|
|
239146
239053
|
stderr += data.toString();
|
|
239147
|
-
})
|
|
239148
|
-
proc.on("error", (err) => {
|
|
239054
|
+
}), proc.on("error", (err) => {
|
|
239149
239055
|
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
|
-
}
|
|
239056
|
+
}), proc.on("close", (code) => {
|
|
239057
|
+
code === 0 ? resolve3({ stdout, stderr }) : reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
239157
239058
|
});
|
|
239158
239059
|
});
|
|
239159
239060
|
}
|
|
@@ -239161,15 +239062,11 @@ __name(execCommand, "execCommand");
|
|
|
239161
239062
|
function parsePnpmWhyOutput(stdout, packageName) {
|
|
239162
239063
|
try {
|
|
239163
239064
|
const result = JSON.parse(stdout);
|
|
239164
|
-
|
|
239165
|
-
|
|
239166
|
-
|
|
239167
|
-
|
|
239168
|
-
|
|
239169
|
-
source: "workspace"
|
|
239170
|
-
};
|
|
239171
|
-
}
|
|
239172
|
-
return null;
|
|
239065
|
+
return result && typeof result == "object" && packageName in result ? {
|
|
239066
|
+
found: true,
|
|
239067
|
+
version: result[packageName]?.version,
|
|
239068
|
+
source: "workspace"
|
|
239069
|
+
} : null;
|
|
239173
239070
|
} catch {
|
|
239174
239071
|
return null;
|
|
239175
239072
|
}
|
|
@@ -239178,15 +239075,11 @@ __name(parsePnpmWhyOutput, "parsePnpmWhyOutput");
|
|
|
239178
239075
|
function parseNpmWhyOutput(stdout, _packageName) {
|
|
239179
239076
|
try {
|
|
239180
239077
|
const result = JSON.parse(stdout);
|
|
239181
|
-
|
|
239182
|
-
|
|
239183
|
-
|
|
239184
|
-
|
|
239185
|
-
|
|
239186
|
-
source: "workspace"
|
|
239187
|
-
};
|
|
239188
|
-
}
|
|
239189
|
-
return null;
|
|
239078
|
+
return Array.isArray(result) && result.length > 0 ? {
|
|
239079
|
+
found: true,
|
|
239080
|
+
version: result[0]?.version,
|
|
239081
|
+
source: "workspace"
|
|
239082
|
+
} : null;
|
|
239190
239083
|
} catch {
|
|
239191
239084
|
return null;
|
|
239192
239085
|
}
|
|
@@ -239196,7 +239089,8 @@ function parseYarnWhyOutput(stdout, _packageName) {
|
|
|
239196
239089
|
if (stdout.trim().length > 0) {
|
|
239197
239090
|
let version;
|
|
239198
239091
|
try {
|
|
239199
|
-
const lines = stdout.trim().split(
|
|
239092
|
+
const lines = stdout.trim().split(`
|
|
239093
|
+
`);
|
|
239200
239094
|
for (const line of lines) {
|
|
239201
239095
|
const obj = JSON.parse(line);
|
|
239202
239096
|
if (obj.type === "info" && obj.data) {
|
|
@@ -239236,31 +239130,21 @@ async function checkViaPackageManager(pm, packageName, cwd) {
|
|
|
239236
239130
|
}
|
|
239237
239131
|
__name(checkViaPackageManager, "checkViaPackageManager");
|
|
239238
239132
|
async function checkDependencies(projectDir) {
|
|
239239
|
-
const pm = detectPackageManager(projectDir);
|
|
239240
|
-
|
|
239241
|
-
let thinkwellStatus = { found: false };
|
|
239242
|
-
let typescriptStatus = { found: false };
|
|
239133
|
+
const pm = detectPackageManager(projectDir), pkg = readPackageJson(projectDir);
|
|
239134
|
+
let thinkwellStatus = { found: false }, typescriptStatus = { found: false };
|
|
239243
239135
|
if (pkg) {
|
|
239244
239136
|
const thinkwellDirect = checkPackageJsonDirect(pkg, "thinkwell");
|
|
239245
|
-
|
|
239246
|
-
thinkwellStatus = thinkwellDirect;
|
|
239247
|
-
}
|
|
239137
|
+
thinkwellDirect && (thinkwellStatus = thinkwellDirect);
|
|
239248
239138
|
const typescriptDirect = checkPackageJsonDirect(pkg, "typescript");
|
|
239249
|
-
|
|
239250
|
-
typescriptStatus = typescriptDirect;
|
|
239251
|
-
}
|
|
239139
|
+
typescriptDirect && (typescriptStatus = typescriptDirect);
|
|
239252
239140
|
}
|
|
239253
239141
|
if (!thinkwellStatus.found) {
|
|
239254
239142
|
const result = await checkViaPackageManager(pm, "thinkwell", projectDir);
|
|
239255
|
-
|
|
239256
|
-
thinkwellStatus = result;
|
|
239257
|
-
}
|
|
239143
|
+
result && (thinkwellStatus = result);
|
|
239258
239144
|
}
|
|
239259
239145
|
if (!typescriptStatus.found) {
|
|
239260
239146
|
const result = await checkViaPackageManager(pm, "typescript", projectDir);
|
|
239261
|
-
|
|
239262
|
-
typescriptStatus = result;
|
|
239263
|
-
}
|
|
239147
|
+
result && (typescriptStatus = result);
|
|
239264
239148
|
}
|
|
239265
239149
|
return {
|
|
239266
239150
|
thinkwell: thinkwellStatus,
|
|
@@ -239276,34 +239160,12 @@ __name(hasPackageJson, "hasPackageJson");
|
|
|
239276
239160
|
|
|
239277
239161
|
// dist/cli/dependency-errors.js
|
|
239278
239162
|
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) {
|
|
239163
|
+
const { thinkwell, typescript, packageManager } = result, pm = packageManager, missing = [];
|
|
239164
|
+
if (thinkwell.found || missing.push("thinkwell"), typescript.found || missing.push("typescript"), missing.length === 0)
|
|
239287
239165
|
return "";
|
|
239288
|
-
}
|
|
239289
239166
|
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");
|
|
239167
|
+
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(`
|
|
239168
|
+
`);
|
|
239307
239169
|
}
|
|
239308
239170
|
__name(formatMissingDependencyError, "formatMissingDependencyError");
|
|
239309
239171
|
function hasMissingDependencies(result) {
|
|
@@ -239314,53 +239176,37 @@ __name(hasMissingDependencies, "hasMissingDependencies");
|
|
|
239314
239176
|
// dist/cli/build.js
|
|
239315
239177
|
function readPackageJsonConfig(dir) {
|
|
239316
239178
|
const pkgPath = (0, import_node_path7.join)(dir, "package.json");
|
|
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");
|
|
239179
|
+
if ((0, import_node_fs6.existsSync)(pkgPath))
|
|
239180
|
+
try {
|
|
239181
|
+
const content = (0, import_node_fs6.readFileSync)(pkgPath, "utf-8"), config = JSON.parse(content)?.thinkwell?.build;
|
|
239182
|
+
if (!config || typeof config != "object")
|
|
239183
|
+
return;
|
|
239184
|
+
const result = {};
|
|
239185
|
+
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;
|
|
239186
|
+
} catch {
|
|
239187
|
+
return;
|
|
239333
239188
|
}
|
|
239334
|
-
return result;
|
|
239335
|
-
} catch {
|
|
239336
|
-
return void 0;
|
|
239337
|
-
}
|
|
239338
239189
|
}
|
|
239339
239190
|
__name(readPackageJsonConfig, "readPackageJsonConfig");
|
|
239340
239191
|
function createFileFilter(config) {
|
|
239341
239192
|
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;
|
|
239193
|
+
return;
|
|
239194
|
+
const { include, exclude } = config, hasInclude = include && include.length > 0, hasExclude = exclude && exclude.length > 0;
|
|
239195
|
+
if (!(!hasInclude && !hasExclude))
|
|
239196
|
+
return (fileName) => {
|
|
239197
|
+
if (hasExclude) {
|
|
239198
|
+
for (const pattern of exclude)
|
|
239199
|
+
if ((0, import_node_path7.matchesGlob)(fileName, pattern))
|
|
239200
|
+
return false;
|
|
239353
239201
|
}
|
|
239354
|
-
|
|
239355
|
-
|
|
239356
|
-
|
|
239357
|
-
|
|
239358
|
-
|
|
239202
|
+
if (hasInclude) {
|
|
239203
|
+
for (const pattern of include)
|
|
239204
|
+
if ((0, import_node_path7.matchesGlob)(fileName, pattern))
|
|
239205
|
+
return true;
|
|
239206
|
+
return false;
|
|
239359
239207
|
}
|
|
239360
|
-
return
|
|
239361
|
-
}
|
|
239362
|
-
return true;
|
|
239363
|
-
};
|
|
239208
|
+
return true;
|
|
239209
|
+
};
|
|
239364
239210
|
}
|
|
239365
239211
|
__name(createFileFilter, "createFileFilter");
|
|
239366
239212
|
var diagnosticsHost = {
|
|
@@ -239369,117 +239215,72 @@ var diagnosticsHost = {
|
|
|
239369
239215
|
getNewLine: /* @__PURE__ */ __name(() => import_typescript3.default.sys.newLine, "getNewLine")
|
|
239370
239216
|
};
|
|
239371
239217
|
function formatDiagnostics(diagnostics) {
|
|
239372
|
-
|
|
239373
|
-
return "";
|
|
239374
|
-
return import_typescript3.default.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticsHost);
|
|
239218
|
+
return diagnostics.length === 0 ? "" : import_typescript3.default.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticsHost);
|
|
239375
239219
|
}
|
|
239376
239220
|
__name(formatDiagnostics, "formatDiagnostics");
|
|
239377
239221
|
async function runBuild(options) {
|
|
239378
239222
|
const cwd = process.cwd();
|
|
239379
239223
|
if (hasPackageJson(cwd)) {
|
|
239380
239224
|
const depCheck = await checkDependencies(cwd);
|
|
239381
|
-
|
|
239382
|
-
console.error(formatMissingDependencyError(depCheck));
|
|
239383
|
-
process.exit(2);
|
|
239384
|
-
}
|
|
239225
|
+
hasMissingDependencies(depCheck) && (console.error(formatMissingDependencyError(depCheck)), process.exit(2));
|
|
239385
239226
|
}
|
|
239386
239227
|
const configPath = options.project ? (0, import_node_path7.resolve)(cwd, options.project) : (0, import_node_path7.resolve)(cwd, "tsconfig.json");
|
|
239387
|
-
|
|
239388
|
-
|
|
239389
|
-
|
|
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
|
-
}
|
|
239403
|
-
}
|
|
239228
|
+
(0, import_node_fs6.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));
|
|
239229
|
+
const pkgConfig = readPackageJsonConfig(cwd), fileFilter = createFileFilter(pkgConfig);
|
|
239230
|
+
options.verbose && pkgConfig && (pkgConfig.include && console.error(` @JSONSchema include: ${pkgConfig.include.join(", ")}`), pkgConfig.exclude && console.error(` @JSONSchema exclude: ${pkgConfig.exclude.join(", ")}`));
|
|
239404
239231
|
const projectDir = hasPackageJson(cwd) ? cwd : void 0;
|
|
239405
|
-
if (options.watch)
|
|
239232
|
+
if (options.watch)
|
|
239406
239233
|
return runWatch(configPath, fileFilter, projectDir);
|
|
239407
|
-
}
|
|
239408
239234
|
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
|
-
}
|
|
239235
|
+
configErrors.length > 0 && (console.error(formatDiagnostics(configErrors)), configErrors.some((d) => d.category === import_typescript3.default.DiagnosticCategory.Error) && process.exit(1));
|
|
239416
239236
|
const diagnostics = import_typescript3.default.getPreEmitDiagnostics(program);
|
|
239417
|
-
|
|
239418
|
-
console.error(formatDiagnostics(diagnostics));
|
|
239419
|
-
}
|
|
239237
|
+
diagnostics.length > 0 && console.error(formatDiagnostics(diagnostics));
|
|
239420
239238
|
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) {
|
|
239239
|
+
emitResult.diagnostics.length > 0 && console.error(formatDiagnostics(emitResult.diagnostics));
|
|
239240
|
+
const errorCount = [...diagnostics, ...emitResult.diagnostics].filter((d) => d.category === import_typescript3.default.DiagnosticCategory.Error).length;
|
|
239241
|
+
if (errorCount > 0 && (console.error(""), console.error(`Found ${errorCount} error${errorCount === 1 ? "" : "s"}.`), process.exit(1)), !options.quiet) {
|
|
239432
239242
|
const fileCount = program.getSourceFiles().filter((sf) => !sf.fileName.includes("node_modules") && !sf.fileName.includes("/lib/lib.")).length;
|
|
239433
239243
|
console.error((0, import_node_util3.styleText)("green", "\u2714") + ` Build complete (${fileCount} file${fileCount === 1 ? "" : "s"})`);
|
|
239434
239244
|
}
|
|
239435
239245
|
}
|
|
239436
239246
|
__name(runBuild, "runBuild");
|
|
239437
239247
|
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
239248
|
const watchHost = createThinkwellWatchHost({
|
|
239445
239249
|
configPath,
|
|
239446
239250
|
fileFilter,
|
|
239447
239251
|
projectDir,
|
|
239448
|
-
reportDiagnostic
|
|
239449
|
-
|
|
239252
|
+
reportDiagnostic: /* @__PURE__ */ __name((diagnostic) => {
|
|
239253
|
+
console.error(import_typescript3.default.formatDiagnosticsWithColorAndContext([diagnostic], diagnosticsHost));
|
|
239254
|
+
}, "reportDiagnostic"),
|
|
239255
|
+
reportWatchStatus: /* @__PURE__ */ __name((diagnostic) => {
|
|
239256
|
+
console.error(import_typescript3.default.formatDiagnostic(diagnostic, diagnosticsHost).trimEnd());
|
|
239257
|
+
}, "reportWatchStatus")
|
|
239450
239258
|
});
|
|
239451
|
-
import_typescript3.default.createWatchProgram(watchHost)
|
|
239452
|
-
return new Promise(() => {
|
|
239259
|
+
return import_typescript3.default.createWatchProgram(watchHost), new Promise(() => {
|
|
239453
239260
|
});
|
|
239454
239261
|
}
|
|
239455
239262
|
__name(runWatch, "runWatch");
|
|
239456
239263
|
function parseBuildArgs(args) {
|
|
239457
239264
|
const options = {};
|
|
239458
239265
|
let i = 0;
|
|
239459
|
-
|
|
239266
|
+
for (; i < args.length; ) {
|
|
239460
239267
|
const arg = args[i];
|
|
239461
239268
|
if (arg === "-p" || arg === "--project") {
|
|
239462
|
-
i
|
|
239463
|
-
if (i >= args.length) {
|
|
239269
|
+
if (i++, i >= args.length)
|
|
239464
239270
|
throw new Error("Missing value for --project");
|
|
239465
|
-
}
|
|
239466
239271
|
options.project = args[i];
|
|
239467
|
-
} else if (arg === "--watch" || arg === "-w")
|
|
239272
|
+
} else if (arg === "--watch" || arg === "-w")
|
|
239468
239273
|
options.watch = true;
|
|
239469
|
-
|
|
239274
|
+
else if (arg === "--verbose")
|
|
239470
239275
|
options.verbose = true;
|
|
239471
|
-
|
|
239276
|
+
else if (arg === "--quiet" || arg === "-q")
|
|
239472
239277
|
options.quiet = true;
|
|
239473
|
-
|
|
239474
|
-
throw new Error(`Unknown option: ${arg}`);
|
|
239475
|
-
} else {
|
|
239476
|
-
throw new Error(`Unexpected argument: ${arg}
|
|
239278
|
+
else throw arg.startsWith("-") ? new Error(`Unknown option: ${arg}`) : new Error(`Unexpected argument: ${arg}
|
|
239477
239279
|
|
|
239478
239280
|
"thinkwell build" compiles the project using tsconfig.json.
|
|
239479
239281
|
It does not take an entry file argument.
|
|
239480
239282
|
|
|
239481
239283
|
Did you mean "thinkwell bundle ${arg}"?`);
|
|
239482
|
-
}
|
|
239483
239284
|
i++;
|
|
239484
239285
|
}
|
|
239485
239286
|
return options;
|
|
@@ -239527,7 +239328,8 @@ ${greenBold("Configuration via package.json:")}
|
|
|
239527
239328
|
|
|
239528
239329
|
${dim("Note: Files not matched by include (or matched by exclude) are still")}
|
|
239529
239330
|
${dim(" compiled by TypeScript \u2014 they just skip @JSONSchema transformation.")}
|
|
239530
|
-
`.trim() +
|
|
239331
|
+
`.trim() + `
|
|
239332
|
+
`);
|
|
239531
239333
|
}
|
|
239532
239334
|
__name(showBuildHelp, "showBuildHelp");
|
|
239533
239335
|
// Annotate the CommonJS export names for ESM import in node:
|