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/build.js
CHANGED
|
@@ -1,110 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public build API for thinkwell.
|
|
3
|
-
*
|
|
4
|
-
* This module exposes schema generation functionality for use by the CLI
|
|
5
|
-
* when running in explicit-config mode. By resolving `thinkwell/build` from
|
|
6
|
-
* a project's `node_modules`, the CLI uses the project-local version of
|
|
7
|
-
* `ts-json-schema-generator` (a transitive dependency of `thinkwell`)
|
|
8
|
-
* without leaking it into the user's dependency contract.
|
|
9
|
-
*
|
|
10
|
-
* The API is intentionally narrow: a single `generateSchemas()` function that
|
|
11
|
-
* takes a file path and type names and returns self-contained JSON schema
|
|
12
|
-
* objects. All details of `ts-json-schema-generator` are encapsulated here.
|
|
13
|
-
*
|
|
14
|
-
* @module thinkwell/build
|
|
15
|
-
*/
|
|
16
1
|
import { dirname, join } from "node:path";
|
|
17
2
|
import { existsSync } from "node:fs";
|
|
18
3
|
import { createGenerator } from "ts-json-schema-generator";
|
|
19
|
-
/**
|
|
20
|
-
* Find tsconfig.json by walking up from the given directory.
|
|
21
|
-
*/
|
|
22
4
|
function findTsConfig(startDir) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
dir = parent;
|
|
34
|
-
}
|
|
5
|
+
let dir = startDir;
|
|
6
|
+
for (; ; ) {
|
|
7
|
+
const configPath = join(dir, "tsconfig.json");
|
|
8
|
+
if (existsSync(configPath))
|
|
9
|
+
return configPath;
|
|
10
|
+
const parent = dirname(dir);
|
|
11
|
+
if (parent === dir)
|
|
12
|
+
return;
|
|
13
|
+
dir = parent;
|
|
14
|
+
}
|
|
35
15
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Recursively inline $ref references to make schemas self-contained.
|
|
38
|
-
*/
|
|
39
16
|
function inlineRefs(obj, definitions) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
// Otherwise, recursively process all properties
|
|
56
|
-
const result = {};
|
|
57
|
-
for (const [key, value] of Object.entries(record)) {
|
|
58
|
-
result[key] = inlineRefs(value, definitions);
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
17
|
+
if (obj === null || typeof obj != "object")
|
|
18
|
+
return obj;
|
|
19
|
+
if (Array.isArray(obj))
|
|
20
|
+
return obj.map((item) => inlineRefs(item, definitions));
|
|
21
|
+
const record = obj;
|
|
22
|
+
if (typeof record.$ref == "string") {
|
|
23
|
+
const match = record.$ref.match(/^#\/definitions\/(.+)$/);
|
|
24
|
+
if (match && definitions[match[1]])
|
|
25
|
+
return inlineRefs(definitions[match[1]], definitions);
|
|
26
|
+
}
|
|
27
|
+
const result = {};
|
|
28
|
+
for (const [key, value] of Object.entries(record))
|
|
29
|
+
result[key] = inlineRefs(value, definitions);
|
|
30
|
+
return result;
|
|
61
31
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Clean a raw schema by inlining `$ref` references and removing root-level
|
|
64
|
-
* `$schema` and `definitions` properties.
|
|
65
|
-
*/
|
|
66
32
|
function cleanSchema(typeName, schema) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const cleaned = { ...result };
|
|
75
|
-
delete cleaned["$schema"];
|
|
76
|
-
delete cleaned["definitions"];
|
|
77
|
-
return cleaned;
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
33
|
+
const definitions = schema.definitions || {};
|
|
34
|
+
let result = definitions[typeName] || schema;
|
|
35
|
+
if (result = inlineRefs(result, definitions), typeof result == "object" && result !== null) {
|
|
36
|
+
const cleaned = { ...result };
|
|
37
|
+
return delete cleaned.$schema, delete cleaned.definitions, cleaned;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
80
40
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Generate self-contained JSON schemas for named types in a TypeScript file.
|
|
83
|
-
*
|
|
84
|
-
* Creates a single schema generator for the file and produces a clean,
|
|
85
|
-
* self-contained schema for each requested type (no `$ref`, `$schema`,
|
|
86
|
-
* or `definitions` in the output).
|
|
87
|
-
*
|
|
88
|
-
* @param filePath - Absolute path to the TypeScript file containing the types
|
|
89
|
-
* @param typeNames - The names of the types to generate schemas for
|
|
90
|
-
* @returns Map from type name to self-contained JSON schema object
|
|
91
|
-
*/
|
|
92
41
|
export function generateSchemas(filePath, typeNames) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return schemas;
|
|
96
|
-
}
|
|
97
|
-
const configPath = findTsConfig(dirname(filePath));
|
|
98
|
-
const generator = createGenerator({
|
|
99
|
-
path: filePath,
|
|
100
|
-
...(configPath && { tsconfig: configPath }),
|
|
101
|
-
skipTypeCheck: true,
|
|
102
|
-
encodeRefs: false,
|
|
103
|
-
});
|
|
104
|
-
for (const typeName of typeNames) {
|
|
105
|
-
const schema = generator.createSchema(typeName);
|
|
106
|
-
schemas.set(typeName, cleanSchema(typeName, schema));
|
|
107
|
-
}
|
|
42
|
+
const schemas = /* @__PURE__ */ new Map();
|
|
43
|
+
if (typeNames.length === 0)
|
|
108
44
|
return schemas;
|
|
45
|
+
const configPath = findTsConfig(dirname(filePath)), generator = createGenerator({
|
|
46
|
+
path: filePath,
|
|
47
|
+
...configPath && { tsconfig: configPath },
|
|
48
|
+
skipTypeCheck: !0,
|
|
49
|
+
encodeRefs: !1
|
|
50
|
+
});
|
|
51
|
+
for (const typeName of typeNames) {
|
|
52
|
+
const schema = generator.createSchema(typeName);
|
|
53
|
+
schemas.set(typeName, cleanSchema(typeName, schema));
|
|
54
|
+
}
|
|
55
|
+
return schemas;
|
|
109
56
|
}
|
|
110
|
-
//# sourceMappingURL=build.js.map
|
package/dist/cli/build.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build command for tsc-based compilation with @JSONSchema transformation.
|
|
3
|
-
*
|
|
4
|
-
* This module provides the `thinkwell build` command that compiles a TypeScript
|
|
5
|
-
* project using the standard TypeScript compiler API with a custom CompilerHost.
|
|
6
|
-
* The CompilerHost intercepts file reads and applies @JSONSchema namespace
|
|
7
|
-
* injection in memory, so user source files are never modified on disk.
|
|
8
|
-
*
|
|
9
|
-
* Output (.js, .d.ts, source maps) is written to the project's configured outDir.
|
|
10
|
-
*/
|
|
11
1
|
import ts from "typescript";
|
|
12
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
3
|
import { resolve, join, matchesGlob } from "node:path";
|
|
@@ -17,239 +7,114 @@ import { cyan, cyanBold, greenBold, whiteBold, dim } from "./fmt.js";
|
|
|
17
7
|
import { fmtError } from "./commands.js";
|
|
18
8
|
import { checkDependencies, hasPackageJson } from "./dependency-check.js";
|
|
19
9
|
import { formatMissingDependencyError, hasMissingDependencies } from "./dependency-errors.js";
|
|
20
|
-
// ============================================================================
|
|
21
|
-
// Package.json Configuration
|
|
22
|
-
// ============================================================================
|
|
23
|
-
/**
|
|
24
|
-
* Read build configuration from package.json in the given directory.
|
|
25
|
-
* Returns undefined if no configuration is found.
|
|
26
|
-
*/
|
|
27
10
|
function readPackageJsonConfig(dir) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
11
|
+
const pkgPath = join(dir, "package.json");
|
|
12
|
+
if (existsSync(pkgPath))
|
|
32
13
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (Array.isArray(config.include)) {
|
|
41
|
-
result.include = config.include.filter((i) => typeof i === "string");
|
|
42
|
-
}
|
|
43
|
-
if (Array.isArray(config.exclude)) {
|
|
44
|
-
result.exclude = config.exclude.filter((e) => typeof e === "string");
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return undefined;
|
|
14
|
+
const content = readFileSync(pkgPath, "utf-8"), config = JSON.parse(content)?.thinkwell?.build;
|
|
15
|
+
if (!config || typeof config != "object")
|
|
16
|
+
return;
|
|
17
|
+
const result = {};
|
|
18
|
+
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;
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
50
21
|
}
|
|
51
22
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Create a file filter function from include/exclude glob patterns.
|
|
54
|
-
*
|
|
55
|
-
* - If include is specified, only files matching at least one include pattern
|
|
56
|
-
* are eligible for transformation.
|
|
57
|
-
* - If exclude is specified, files matching any exclude pattern are skipped.
|
|
58
|
-
* - Exclude takes precedence over include.
|
|
59
|
-
*
|
|
60
|
-
* Returns undefined if no filtering is needed (no include/exclude configured).
|
|
61
|
-
*/
|
|
62
23
|
function createFileFilter(config) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const hasExclude = exclude && exclude.length > 0;
|
|
68
|
-
if (!hasInclude && !hasExclude)
|
|
69
|
-
return undefined;
|
|
24
|
+
if (!config)
|
|
25
|
+
return;
|
|
26
|
+
const { include, exclude } = config, hasInclude = include && include.length > 0, hasExclude = exclude && exclude.length > 0;
|
|
27
|
+
if (!(!hasInclude && !hasExclude))
|
|
70
28
|
return (fileName) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
29
|
+
if (hasExclude) {
|
|
30
|
+
for (const pattern of exclude)
|
|
31
|
+
if (matchesGlob(fileName, pattern))
|
|
32
|
+
return !1;
|
|
33
|
+
}
|
|
34
|
+
if (hasInclude) {
|
|
35
|
+
for (const pattern of include)
|
|
36
|
+
if (matchesGlob(fileName, pattern))
|
|
37
|
+
return !0;
|
|
38
|
+
return !1;
|
|
39
|
+
}
|
|
40
|
+
return !0;
|
|
87
41
|
};
|
|
88
42
|
}
|
|
89
|
-
// ============================================================================
|
|
90
|
-
// Diagnostics Formatting
|
|
91
|
-
// ============================================================================
|
|
92
43
|
const diagnosticsHost = {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
44
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
45
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
46
|
+
getNewLine: () => ts.sys.newLine
|
|
96
47
|
};
|
|
97
48
|
function formatDiagnostics(diagnostics) {
|
|
98
|
-
|
|
99
|
-
return "";
|
|
100
|
-
return ts.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticsHost);
|
|
49
|
+
return diagnostics.length === 0 ? "" : ts.formatDiagnosticsWithColorAndContext(diagnostics, diagnosticsHost);
|
|
101
50
|
}
|
|
102
|
-
// ============================================================================
|
|
103
|
-
// Build Command
|
|
104
|
-
// ============================================================================
|
|
105
51
|
export async function runBuild(options) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (pkgConfig.include) {
|
|
130
|
-
console.error(` @JSONSchema include: ${pkgConfig.include.join(", ")}`);
|
|
131
|
-
}
|
|
132
|
-
if (pkgConfig.exclude) {
|
|
133
|
-
console.error(` @JSONSchema exclude: ${pkgConfig.exclude.join(", ")}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
// Resolve project directory for project-local @JSONSchema processing
|
|
137
|
-
const projectDir = hasPackageJson(cwd) ? cwd : undefined;
|
|
138
|
-
// Watch mode: use TypeScript's watch API for continuous compilation
|
|
139
|
-
if (options.watch) {
|
|
140
|
-
return runWatch(configPath, fileFilter, projectDir);
|
|
141
|
-
}
|
|
142
|
-
// Single-pass build
|
|
143
|
-
const { program, configErrors } = (fileFilter || projectDir)
|
|
144
|
-
? createThinkwellProgram({ configPath, fileFilter, projectDir })
|
|
145
|
-
: createThinkwellProgram(configPath);
|
|
146
|
-
// Report config-level diagnostics
|
|
147
|
-
if (configErrors.length > 0) {
|
|
148
|
-
console.error(formatDiagnostics(configErrors));
|
|
149
|
-
const hasFatal = configErrors.some((d) => d.category === ts.DiagnosticCategory.Error);
|
|
150
|
-
if (hasFatal) {
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
// Get pre-emit diagnostics (type errors, etc.)
|
|
155
|
-
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
156
|
-
if (diagnostics.length > 0) {
|
|
157
|
-
console.error(formatDiagnostics(diagnostics));
|
|
158
|
-
}
|
|
159
|
-
// Emit output files
|
|
160
|
-
const emitResult = program.emit();
|
|
161
|
-
// Report emit diagnostics
|
|
162
|
-
if (emitResult.diagnostics.length > 0) {
|
|
163
|
-
console.error(formatDiagnostics(emitResult.diagnostics));
|
|
164
|
-
}
|
|
165
|
-
// Count all errors
|
|
166
|
-
const allDiagnostics = [...diagnostics, ...emitResult.diagnostics];
|
|
167
|
-
const errorCount = allDiagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error).length;
|
|
168
|
-
if (errorCount > 0) {
|
|
169
|
-
console.error("");
|
|
170
|
-
console.error(`Found ${errorCount} error${errorCount === 1 ? "" : "s"}.`);
|
|
171
|
-
process.exit(1);
|
|
172
|
-
}
|
|
173
|
-
if (!options.quiet) {
|
|
174
|
-
const fileCount = program.getSourceFiles().filter((sf) => !sf.fileName.includes("node_modules") && !sf.fileName.includes("/lib/lib.")).length;
|
|
175
|
-
console.error(styleText("green", "✔") +
|
|
176
|
-
` Build complete (${fileCount} file${fileCount === 1 ? "" : "s"})`);
|
|
177
|
-
}
|
|
52
|
+
const cwd = process.cwd();
|
|
53
|
+
if (hasPackageJson(cwd)) {
|
|
54
|
+
const depCheck = await checkDependencies(cwd);
|
|
55
|
+
hasMissingDependencies(depCheck) && (console.error(formatMissingDependencyError(depCheck)), process.exit(2));
|
|
56
|
+
}
|
|
57
|
+
const configPath = options.project ? resolve(cwd, options.project) : resolve(cwd, "tsconfig.json");
|
|
58
|
+
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));
|
|
59
|
+
const pkgConfig = readPackageJsonConfig(cwd), fileFilter = createFileFilter(pkgConfig);
|
|
60
|
+
options.verbose && pkgConfig && (pkgConfig.include && console.error(` @JSONSchema include: ${pkgConfig.include.join(", ")}`), pkgConfig.exclude && console.error(` @JSONSchema exclude: ${pkgConfig.exclude.join(", ")}`));
|
|
61
|
+
const projectDir = hasPackageJson(cwd) ? cwd : void 0;
|
|
62
|
+
if (options.watch)
|
|
63
|
+
return runWatch(configPath, fileFilter, projectDir);
|
|
64
|
+
const { program, configErrors } = fileFilter || projectDir ? createThinkwellProgram({ configPath, fileFilter, projectDir }) : createThinkwellProgram(configPath);
|
|
65
|
+
configErrors.length > 0 && (console.error(formatDiagnostics(configErrors)), configErrors.some((d) => d.category === ts.DiagnosticCategory.Error) && process.exit(1));
|
|
66
|
+
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
67
|
+
diagnostics.length > 0 && console.error(formatDiagnostics(diagnostics));
|
|
68
|
+
const emitResult = program.emit();
|
|
69
|
+
emitResult.diagnostics.length > 0 && console.error(formatDiagnostics(emitResult.diagnostics));
|
|
70
|
+
const errorCount = [...diagnostics, ...emitResult.diagnostics].filter((d) => d.category === ts.DiagnosticCategory.Error).length;
|
|
71
|
+
if (errorCount > 0 && (console.error(""), console.error(`Found ${errorCount} error${errorCount === 1 ? "" : "s"}.`), process.exit(1)), !options.quiet) {
|
|
72
|
+
const fileCount = program.getSourceFiles().filter((sf) => !sf.fileName.includes("node_modules") && !sf.fileName.includes("/lib/lib.")).length;
|
|
73
|
+
console.error(styleText("green", "\u2714") + ` Build complete (${fileCount} file${fileCount === 1 ? "" : "s"})`);
|
|
74
|
+
}
|
|
178
75
|
}
|
|
179
|
-
// ============================================================================
|
|
180
|
-
// Watch Mode
|
|
181
|
-
// ============================================================================
|
|
182
|
-
/**
|
|
183
|
-
* Run the build in watch mode using TypeScript's watch API.
|
|
184
|
-
*
|
|
185
|
-
* TypeScript handles file watching, debouncing, and incremental re-compilation
|
|
186
|
-
* automatically. The custom CompilerHost's @JSONSchema transformation is applied
|
|
187
|
-
* on each rebuild via the createProgram callback.
|
|
188
|
-
*
|
|
189
|
-
* This function never returns — it runs until the process is killed (Ctrl+C).
|
|
190
|
-
*/
|
|
191
76
|
function runWatch(configPath, fileFilter, projectDir) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
ts.createWatchProgram(watchHost);
|
|
206
|
-
// Keep the process alive. TypeScript's watch system registers file watchers
|
|
207
|
-
// that keep the event loop active, so this promise never resolves.
|
|
208
|
-
// The process exits when the user presses Ctrl+C.
|
|
209
|
-
return new Promise(() => { });
|
|
77
|
+
const watchHost = createThinkwellWatchHost({
|
|
78
|
+
configPath,
|
|
79
|
+
fileFilter,
|
|
80
|
+
projectDir,
|
|
81
|
+
reportDiagnostic: (diagnostic) => {
|
|
82
|
+
console.error(ts.formatDiagnosticsWithColorAndContext([diagnostic], diagnosticsHost));
|
|
83
|
+
},
|
|
84
|
+
reportWatchStatus: (diagnostic) => {
|
|
85
|
+
console.error(ts.formatDiagnostic(diagnostic, diagnosticsHost).trimEnd());
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return ts.createWatchProgram(watchHost), new Promise(() => {
|
|
89
|
+
});
|
|
210
90
|
}
|
|
211
|
-
// ============================================================================
|
|
212
|
-
// Argument Parsing
|
|
213
|
-
// ============================================================================
|
|
214
91
|
export function parseBuildArgs(args) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
else {
|
|
239
|
-
throw new Error(`Unexpected argument: ${arg}\n\n` +
|
|
240
|
-
` "thinkwell build" compiles the project using tsconfig.json.\n` +
|
|
241
|
-
` It does not take an entry file argument.\n\n` +
|
|
242
|
-
` Did you mean "thinkwell bundle ${arg}"?`);
|
|
243
|
-
}
|
|
244
|
-
i++;
|
|
245
|
-
}
|
|
246
|
-
return options;
|
|
92
|
+
const options = {};
|
|
93
|
+
let i = 0;
|
|
94
|
+
for (; i < args.length; ) {
|
|
95
|
+
const arg = args[i];
|
|
96
|
+
if (arg === "-p" || arg === "--project") {
|
|
97
|
+
if (i++, i >= args.length)
|
|
98
|
+
throw new Error("Missing value for --project");
|
|
99
|
+
options.project = args[i];
|
|
100
|
+
} else if (arg === "--watch" || arg === "-w")
|
|
101
|
+
options.watch = !0;
|
|
102
|
+
else if (arg === "--verbose")
|
|
103
|
+
options.verbose = !0;
|
|
104
|
+
else if (arg === "--quiet" || arg === "-q")
|
|
105
|
+
options.quiet = !0;
|
|
106
|
+
else throw arg.startsWith("-") ? new Error(`Unknown option: ${arg}`) : new Error(`Unexpected argument: ${arg}
|
|
107
|
+
|
|
108
|
+
"thinkwell build" compiles the project using tsconfig.json.
|
|
109
|
+
It does not take an entry file argument.
|
|
110
|
+
|
|
111
|
+
Did you mean "thinkwell bundle ${arg}"?`);
|
|
112
|
+
i++;
|
|
113
|
+
}
|
|
114
|
+
return options;
|
|
247
115
|
}
|
|
248
|
-
// ============================================================================
|
|
249
|
-
// Help
|
|
250
|
-
// ============================================================================
|
|
251
116
|
export function showBuildHelp() {
|
|
252
|
-
|
|
117
|
+
console.log(`
|
|
253
118
|
${cyanBold("thinkwell build")} - ${whiteBold("Compile TypeScript with @JSONSchema transformation")}
|
|
254
119
|
|
|
255
120
|
${greenBold("Usage:")}
|
|
@@ -289,7 +154,7 @@ ${greenBold("Configuration via package.json:")}
|
|
|
289
154
|
}
|
|
290
155
|
|
|
291
156
|
${dim("Note: Files not matched by include (or matched by exclude) are still")}
|
|
292
|
-
${dim(" compiled by TypeScript
|
|
293
|
-
`.trim() +
|
|
157
|
+
${dim(" compiled by TypeScript \u2014 they just skip @JSONSchema transformation.")}
|
|
158
|
+
`.trim() + `
|
|
159
|
+
`);
|
|
294
160
|
}
|
|
295
|
-
//# sourceMappingURL=build.js.map
|