@simplysm/sd-cli 13.0.68 → 13.0.70
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/README.md +10 -957
- package/dist/builders/BaseBuilder.d.ts +23 -23
- package/dist/builders/BaseBuilder.d.ts.map +1 -1
- package/dist/builders/BaseBuilder.js +15 -15
- package/dist/builders/DtsBuilder.d.ts +4 -4
- package/dist/builders/DtsBuilder.js +1 -1
- package/dist/builders/LibraryBuilder.d.ts +3 -3
- package/dist/builders/types.d.ts +10 -10
- package/dist/capacitor/capacitor.d.ts +36 -36
- package/dist/capacitor/capacitor.js +63 -63
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/add-client.d.ts +8 -8
- package/dist/commands/add-client.js +15 -15
- package/dist/commands/add-client.js.map +1 -1
- package/dist/commands/add-server.d.ts +9 -9
- package/dist/commands/add-server.js +13 -13
- package/dist/commands/add-server.js.map +1 -1
- package/dist/commands/build.d.ts +9 -9
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +9 -9
- package/dist/commands/device.d.ts +9 -9
- package/dist/commands/device.d.ts.map +1 -1
- package/dist/commands/device.js +17 -17
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/init.d.ts +6 -6
- package/dist/commands/init.js +12 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.d.ts +23 -23
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +25 -25
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish.d.ts +13 -13
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +61 -61
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/replace-deps.d.ts +3 -3
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/commands/typecheck.d.ts +20 -20
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +20 -20
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +7 -7
- package/dist/electron/electron.d.ts +27 -27
- package/dist/electron/electron.js +32 -32
- package/dist/electron/electron.js.map +1 -1
- package/dist/infra/ResultCollector.d.ts +9 -9
- package/dist/infra/ResultCollector.js +5 -5
- package/dist/infra/SignalHandler.d.ts +7 -7
- package/dist/infra/SignalHandler.js +4 -4
- package/dist/infra/WorkerManager.d.ts +14 -14
- package/dist/infra/WorkerManager.js +11 -11
- package/dist/orchestrators/BuildOrchestrator.d.ts +19 -19
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +26 -26
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +25 -25
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +30 -30
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts +13 -13
- package/dist/orchestrators/WatchOrchestrator.js +17 -17
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +2 -2
- package/dist/sd-cli-entry.js +38 -38
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.d.ts +2 -2
- package/dist/sd-cli.js +1 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +84 -84
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/build-env.d.ts +1 -1
- package/dist/utils/config-editor.d.ts +5 -5
- package/dist/utils/config-editor.js +2 -2
- package/dist/utils/config-editor.js.map +1 -1
- package/dist/utils/copy-public.d.ts +9 -9
- package/dist/utils/copy-src.d.ts +9 -9
- package/dist/utils/esbuild-config.d.ts +30 -30
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/output-utils.d.ts +6 -6
- package/dist/utils/package-utils.d.ts +6 -6
- package/dist/utils/package-utils.js +1 -1
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/rebuild-manager.js +3 -3
- package/dist/utils/rebuild-manager.js.map +1 -1
- package/dist/utils/replace-deps.d.ts +25 -25
- package/dist/utils/replace-deps.js +3 -3
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts +3 -3
- package/dist/utils/sd-config.js +3 -3
- package/dist/utils/sd-config.js.map +1 -1
- package/dist/utils/tailwind-config-deps.d.ts +3 -3
- package/dist/utils/template.d.ts +8 -8
- package/dist/utils/tsconfig.d.ts +16 -16
- package/dist/utils/tsconfig.js +2 -2
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts +8 -8
- package/dist/utils/vite-config.d.ts +8 -8
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +3 -3
- package/dist/utils/worker-events.d.ts +12 -12
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-utils.d.ts +3 -3
- package/dist/utils/worker-utils.js +2 -2
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +14 -14
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +1 -1
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/dts.worker.d.ts +13 -13
- package/dist/workers/dts.worker.d.ts.map +1 -1
- package/dist/workers/dts.worker.js +3 -3
- package/dist/workers/dts.worker.js.map +1 -1
- package/dist/workers/library.worker.d.ts +12 -12
- package/dist/workers/library.worker.js +1 -1
- package/dist/workers/library.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +1 -1
- package/dist/workers/server-runtime.worker.d.ts +6 -6
- package/dist/workers/server-runtime.worker.js +6 -6
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/dist/workers/server.worker.d.ts +20 -20
- package/dist/workers/server.worker.d.ts.map +1 -1
- package/dist/workers/server.worker.js +6 -6
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +8 -7
- package/src/builders/BaseBuilder.ts +33 -33
- package/src/builders/DtsBuilder.ts +5 -5
- package/src/builders/LibraryBuilder.ts +9 -9
- package/src/builders/types.ts +10 -10
- package/src/capacitor/capacitor.ts +119 -119
- package/src/commands/add-client.ts +31 -31
- package/src/commands/add-server.ts +34 -34
- package/src/commands/build.ts +9 -9
- package/src/commands/check.ts +5 -5
- package/src/commands/dev.ts +9 -9
- package/src/commands/device.ts +30 -30
- package/src/commands/init.ts +25 -25
- package/src/commands/lint.ts +64 -64
- package/src/commands/publish.ts +139 -139
- package/src/commands/replace-deps.ts +4 -4
- package/src/commands/typecheck.ts +74 -74
- package/src/commands/watch.ts +7 -7
- package/src/electron/electron.ts +51 -51
- package/src/infra/ResultCollector.ts +9 -9
- package/src/infra/SignalHandler.ts +7 -7
- package/src/infra/WorkerManager.ts +14 -14
- package/src/orchestrators/BuildOrchestrator.ts +76 -76
- package/src/orchestrators/DevOrchestrator.ts +88 -88
- package/src/orchestrators/WatchOrchestrator.ts +39 -39
- package/src/sd-cli-entry.ts +43 -43
- package/src/sd-cli.ts +15 -15
- package/src/sd-config.types.ts +85 -85
- package/src/utils/build-env.ts +1 -1
- package/src/utils/config-editor.ts +19 -19
- package/src/utils/copy-public.ts +17 -17
- package/src/utils/copy-src.ts +11 -11
- package/src/utils/esbuild-config.ts +33 -33
- package/src/utils/output-utils.ts +11 -11
- package/src/utils/package-utils.ts +12 -12
- package/src/utils/rebuild-manager.ts +3 -3
- package/src/utils/replace-deps.ts +361 -361
- package/src/utils/sd-config.ts +44 -44
- package/src/utils/tailwind-config-deps.ts +98 -98
- package/src/utils/template.ts +56 -56
- package/src/utils/tsconfig.ts +127 -127
- package/src/utils/typecheck-serialization.ts +86 -86
- package/src/utils/vite-config.ts +341 -341
- package/src/utils/worker-events.ts +16 -16
- package/src/utils/worker-utils.ts +45 -45
- package/src/workers/client.worker.ts +34 -34
- package/src/workers/dts.worker.ts +467 -467
- package/src/workers/library.worker.ts +314 -314
- package/src/workers/lint.worker.ts +16 -16
- package/src/workers/server-runtime.worker.ts +157 -157
- package/src/workers/server.worker.ts +572 -572
- package/templates/add-client/__CLIENT__/package.json.hbs +1 -1
- package/templates/add-server/__SERVER__/package.json.hbs +2 -2
- package/templates/init/package.json.hbs +3 -3
- package/tests/config-editor.spec.ts +160 -0
- package/tests/copy-src.spec.ts +50 -0
- package/tests/get-compiler-options-for-package.spec.ts +139 -0
- package/tests/get-package-source-files.spec.ts +181 -0
- package/tests/get-types-from-package-json.spec.ts +107 -0
- package/tests/infra/ResultCollector.spec.ts +39 -0
- package/tests/infra/SignalHandler.spec.ts +38 -0
- package/tests/infra/WorkerManager.spec.ts +97 -0
- package/tests/load-ignore-patterns.spec.ts +188 -0
- package/tests/load-sd-config.spec.ts +137 -0
- package/tests/package-utils.spec.ts +188 -0
- package/tests/parse-root-tsconfig.spec.ts +89 -0
- package/tests/replace-deps.spec.ts +308 -0
- package/tests/run-lint.spec.ts +415 -0
- package/tests/run-typecheck.spec.ts +653 -0
- package/tests/run-watch.spec.ts +75 -0
- package/tests/sd-cli.spec.ts +330 -0
- package/tests/tailwind-config-deps.spec.ts +30 -0
- package/tests/template.spec.ts +70 -0
- package/tests/utils/rebuild-manager.spec.ts +43 -0
- package/tests/write-changed-output-files.spec.ts +97 -0
|
@@ -3,15 +3,15 @@ import { loadSdConfig } from "../utils/sd-config";
|
|
|
3
3
|
import { setupReplaceDeps } from "../utils/replace-deps";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* replace-deps
|
|
6
|
+
* replace-deps command options
|
|
7
7
|
*/
|
|
8
8
|
export interface ReplaceDepsOptions {
|
|
9
|
-
/** sd.config.ts
|
|
9
|
+
/** Additional options to pass to sd.config.ts */
|
|
10
10
|
options: string[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Replace node_modules packages with symlinks to local source based on replaceDeps config in sd.config.ts.
|
|
15
15
|
*/
|
|
16
16
|
export async function runReplaceDeps(opts: ReplaceDepsOptions): Promise<void> {
|
|
17
17
|
const cwd = process.cwd();
|
|
@@ -19,7 +19,7 @@ export async function runReplaceDeps(opts: ReplaceDepsOptions): Promise<void> {
|
|
|
19
19
|
const sdConfig = await loadSdConfig({ cwd, dev: false, opt: opts.options });
|
|
20
20
|
|
|
21
21
|
if (sdConfig.replaceDeps == null) {
|
|
22
|
-
consola.warn("sd.config.ts
|
|
22
|
+
consola.warn("No replaceDeps config found in sd.config.ts.");
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -14,17 +14,17 @@ import type * as DtsWorkerModule from "../workers/dts.worker";
|
|
|
14
14
|
//#region Types
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* TypeScript
|
|
17
|
+
* TypeScript typecheck options
|
|
18
18
|
*/
|
|
19
19
|
export interface TypecheckOptions {
|
|
20
|
-
/**
|
|
20
|
+
/** Path filter for typecheck (e.g., `packages/core-common`). Empty array targets all files defined in tsconfig.json */
|
|
21
21
|
targets: string[];
|
|
22
|
-
/** sd.config.ts
|
|
22
|
+
/** Additional options to pass to sd.config.ts */
|
|
23
23
|
options: string[];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* TypeScript
|
|
27
|
+
* TypeScript typecheck execution result
|
|
28
28
|
*/
|
|
29
29
|
export interface TypecheckResult {
|
|
30
30
|
success: boolean;
|
|
@@ -33,18 +33,18 @@ export interface TypecheckResult {
|
|
|
33
33
|
formattedOutput: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// Package information (for classifying files under packages/*)
|
|
37
37
|
interface PackageInfo {
|
|
38
38
|
name: string;
|
|
39
39
|
dir: string;
|
|
40
|
-
envs: TypecheckEnv[]; // neutral
|
|
40
|
+
envs: TypecheckEnv[]; // neutral is ["node", "browser"], others are single environment
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
//
|
|
43
|
+
// Typecheck task information (internal use)
|
|
44
44
|
interface TypecheckTask {
|
|
45
|
-
/**
|
|
45
|
+
/** Task display name (e.g., "package: core-common [node]") */
|
|
46
46
|
displayName: string;
|
|
47
|
-
/** dts.worker
|
|
47
|
+
/** Information to pass to dts.worker */
|
|
48
48
|
buildInfo: DtsBuildInfo;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -52,31 +52,31 @@ interface TypecheckTask {
|
|
|
52
52
|
|
|
53
53
|
//#region Utilities
|
|
54
54
|
|
|
55
|
-
/**
|
|
55
|
+
/** Regular expression for path classification */
|
|
56
56
|
const PATH_PATTERNS = {
|
|
57
57
|
/** packages/{pkg}/... */
|
|
58
58
|
PACKAGE: /^packages\/([^/]+)\//,
|
|
59
59
|
} as const;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
* - node/browser:
|
|
64
|
-
* - neutral: node + browser
|
|
65
|
-
* - client: browser
|
|
66
|
-
* @param target
|
|
67
|
-
* @returns
|
|
62
|
+
* Convert package target to typecheck environment list.
|
|
63
|
+
* - node/browser: that environment only
|
|
64
|
+
* - neutral: both node + browser
|
|
65
|
+
* - client: treated as browser
|
|
66
|
+
* @param target package build target
|
|
67
|
+
* @returns list of typecheck environments
|
|
68
68
|
*/
|
|
69
69
|
function toTypecheckEnvs(target: string | undefined): TypecheckEnv[] {
|
|
70
70
|
if (target === "node") return ["node"];
|
|
71
71
|
if (target === "browser" || target === "client") return ["browser"];
|
|
72
|
-
// neutral
|
|
72
|
+
// neutral or unspecified: both
|
|
73
73
|
return ["node", "browser"];
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @internal
|
|
77
|
+
* Extract package information from file paths.
|
|
78
|
+
* Excludes packages with scripts target.
|
|
79
|
+
* @internal exported for testing
|
|
80
80
|
*/
|
|
81
81
|
export function extractPackages(
|
|
82
82
|
fileNames: string[],
|
|
@@ -92,7 +92,7 @@ export function extractPackages(
|
|
|
92
92
|
const packageMatch = relativePath.match(PATH_PATTERNS.PACKAGE);
|
|
93
93
|
if (packageMatch) {
|
|
94
94
|
const pkgName = packageMatch[1];
|
|
95
|
-
//
|
|
95
|
+
// Exclude packages with scripts target
|
|
96
96
|
if (config.packages[pkgName]?.target === "scripts") continue;
|
|
97
97
|
|
|
98
98
|
if (!packages.has(pkgName)) {
|
|
@@ -109,24 +109,24 @@ export function extractPackages(
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* Check if there are files not under packages/ in the tsconfig file list.
|
|
113
113
|
*/
|
|
114
114
|
function hasNonPackageFiles(fileNames: string[], cwd: string): boolean {
|
|
115
115
|
return fileNames.some((f) => {
|
|
116
116
|
const relativePath = pathPosix(path.relative(cwd, f));
|
|
117
117
|
if (!relativePath.startsWith("packages/")) return true;
|
|
118
|
-
//
|
|
118
|
+
// Also treat files directly under package root (config files) as non-package
|
|
119
119
|
return relativePath.split("/").length === 3;
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* @param packages
|
|
127
|
-
* @param cwd
|
|
128
|
-
* @param includeNonPackage non-package
|
|
129
|
-
* @returns
|
|
124
|
+
* Create typecheck task list from package information.
|
|
125
|
+
* Neutral packages are split into node/browser environments and checked separately.
|
|
126
|
+
* @param packages package information map
|
|
127
|
+
* @param cwd current working directory
|
|
128
|
+
* @param includeNonPackage add "other" task if non-package files exist
|
|
129
|
+
* @returns array of typecheck task information
|
|
130
130
|
*/
|
|
131
131
|
function createTypecheckTasks(
|
|
132
132
|
packages: Map<string, PackageInfo>,
|
|
@@ -135,27 +135,27 @@ function createTypecheckTasks(
|
|
|
135
135
|
): TypecheckTask[] {
|
|
136
136
|
const tasks: TypecheckTask[] = [];
|
|
137
137
|
|
|
138
|
-
// packages/* -
|
|
138
|
+
// packages/* - create separate task per env
|
|
139
139
|
for (const info of packages.values()) {
|
|
140
140
|
for (const env of info.envs) {
|
|
141
141
|
const envSuffix = info.envs.length > 1 ? ` [${env}]` : "";
|
|
142
142
|
tasks.push({
|
|
143
|
-
displayName:
|
|
143
|
+
displayName: `package: ${info.name}${envSuffix}`,
|
|
144
144
|
buildInfo: {
|
|
145
145
|
name: info.name,
|
|
146
146
|
cwd,
|
|
147
147
|
pkgDir: info.dir,
|
|
148
148
|
env,
|
|
149
|
-
emit: false, //
|
|
149
|
+
emit: false, // Only typecheck (no dts generation)
|
|
150
150
|
},
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
// non-package
|
|
155
|
+
// non-package files (tests/, root *.ts, etc.)
|
|
156
156
|
if (includeNonPackage) {
|
|
157
157
|
tasks.push({
|
|
158
|
-
displayName: "
|
|
158
|
+
displayName: "other",
|
|
159
159
|
buildInfo: {
|
|
160
160
|
name: "root",
|
|
161
161
|
cwd,
|
|
@@ -172,24 +172,24 @@ function createTypecheckTasks(
|
|
|
172
172
|
//#region Main
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
* TypeScript
|
|
175
|
+
* Execute TypeScript typecheck and return results.
|
|
176
176
|
*
|
|
177
|
-
* - `tsconfig.json
|
|
178
|
-
* - `sd.config.ts
|
|
179
|
-
* -
|
|
180
|
-
* - incremental
|
|
181
|
-
* -
|
|
182
|
-
* -
|
|
177
|
+
* - Load `tsconfig.json` to apply compiler options
|
|
178
|
+
* - Load `sd.config.ts` to check package target info per package (use defaults if missing)
|
|
179
|
+
* - Perform actual parallel typecheck using Worker threads
|
|
180
|
+
* - Use incremental compilation (`.cache/typecheck-{env}.tsbuildinfo`)
|
|
181
|
+
* - Show progress using consola logging
|
|
182
|
+
* - Return results only, no stdout output or exitCode setting
|
|
183
183
|
*
|
|
184
|
-
* @param options -
|
|
185
|
-
* @returns
|
|
184
|
+
* @param options - typecheck execution options
|
|
185
|
+
* @returns typecheck result (success status, error/warning counts, formatted output string)
|
|
186
186
|
*/
|
|
187
187
|
export async function executeTypecheck(options: TypecheckOptions): Promise<TypecheckResult> {
|
|
188
188
|
const { targets } = options;
|
|
189
189
|
const cwd = process.cwd();
|
|
190
190
|
const logger = consola.withTag("sd:cli:typecheck");
|
|
191
191
|
|
|
192
|
-
logger.debug("
|
|
192
|
+
logger.debug("start typecheck", { targets });
|
|
193
193
|
|
|
194
194
|
const formatHost: ts.FormatDiagnosticsHost = {
|
|
195
195
|
getCanonicalFileName: (f) => f,
|
|
@@ -197,7 +197,7 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
197
197
|
getNewLine: () => ts.sys.newLine,
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
// tsconfig.json
|
|
200
|
+
// Load and parse tsconfig.json
|
|
201
201
|
let parsedConfig: ts.ParsedCommandLine;
|
|
202
202
|
try {
|
|
203
203
|
parsedConfig = parseRootTsconfig(cwd);
|
|
@@ -206,38 +206,38 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
206
206
|
return { success: false, errorCount: 1, warningCount: 0, formattedOutput: "" };
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// sd.config.ts
|
|
209
|
+
// Load sd.config.ts
|
|
210
210
|
let sdConfig: SdConfig;
|
|
211
211
|
try {
|
|
212
212
|
sdConfig = await loadSdConfig({ cwd, dev: false, opt: options.options });
|
|
213
|
-
logger.debug("sd.config.ts
|
|
213
|
+
logger.debug("sd.config.ts loaded");
|
|
214
214
|
} catch (err) {
|
|
215
|
-
// sd.config.ts
|
|
215
|
+
// Use defaults if sd.config.ts is missing or load fails
|
|
216
216
|
sdConfig = { packages: {} };
|
|
217
|
-
logger.debug("sd.config.ts
|
|
217
|
+
logger.debug("sd.config.ts load failed, using defaults", err);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
//
|
|
220
|
+
// Filter fileNames if targets specified
|
|
221
221
|
const fileNames = pathFilterByTargets(parsedConfig.fileNames, targets, cwd);
|
|
222
222
|
|
|
223
223
|
if (fileNames.length === 0) {
|
|
224
|
-
logger.info("
|
|
224
|
+
logger.info("no files to typecheck");
|
|
225
225
|
return {
|
|
226
226
|
success: true,
|
|
227
227
|
errorCount: 0,
|
|
228
228
|
warningCount: 0,
|
|
229
|
-
formattedOutput: "✔
|
|
229
|
+
formattedOutput: "✔ No files to typecheck.\n",
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
//
|
|
233
|
+
// Extract package information
|
|
234
234
|
const packages = extractPackages(fileNames, cwd, sdConfig);
|
|
235
|
-
logger.debug("
|
|
235
|
+
logger.debug("package extraction complete", {
|
|
236
236
|
packageCount: packages.size,
|
|
237
237
|
packages: [...packages.keys()],
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
//
|
|
240
|
+
// Create typecheck tasks
|
|
241
241
|
const nonPackage = hasNonPackageFiles(fileNames, cwd);
|
|
242
242
|
const tasks = createTypecheckTasks(packages, cwd, nonPackage);
|
|
243
243
|
|
|
@@ -246,16 +246,16 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
246
246
|
success: true,
|
|
247
247
|
errorCount: 0,
|
|
248
248
|
warningCount: 0,
|
|
249
|
-
formattedOutput: "✔
|
|
249
|
+
formattedOutput: "✔ No typecheck targets.\n",
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
//
|
|
253
|
+
// Concurrency setting: use 7/8 of CPU cores (standard default for parallel build tools, reserves for OS/other processes, minimum 1, at most task count)
|
|
254
254
|
const maxConcurrency = Math.max(Math.floor((os.cpus().length * 7) / 8), 1);
|
|
255
255
|
const concurrency = Math.min(maxConcurrency, tasks.length);
|
|
256
|
-
logger.debug("
|
|
256
|
+
logger.debug("concurrency configuration", { concurrency, maxConcurrency, taskCount: tasks.length });
|
|
257
257
|
|
|
258
|
-
// Worker
|
|
258
|
+
// Create Worker pool
|
|
259
259
|
const workerPath = import.meta.resolve("../workers/dts.worker");
|
|
260
260
|
const workers: WorkerProxy<typeof DtsWorkerModule>[] = [];
|
|
261
261
|
for (let i = 0; i < concurrency; i++) {
|
|
@@ -272,17 +272,17 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
272
272
|
const currentIndex = taskIndex++;
|
|
273
273
|
const task = tasks[currentIndex];
|
|
274
274
|
|
|
275
|
-
logger.debug(`[${task.displayName}]
|
|
275
|
+
logger.debug(`[${task.displayName}] typecheck started`);
|
|
276
276
|
try {
|
|
277
277
|
const result = await worker.build(task.buildInfo);
|
|
278
278
|
allResults.push({ displayName: task.displayName, result });
|
|
279
279
|
if (result.success) {
|
|
280
|
-
logger.debug(`[${task.displayName}]
|
|
280
|
+
logger.debug(`[${task.displayName}] typecheck completed`);
|
|
281
281
|
} else {
|
|
282
|
-
logger.debug(`[${task.displayName}]
|
|
282
|
+
logger.debug(`[${task.displayName}] typecheck failed`, { errorCount: result.errorCount });
|
|
283
283
|
}
|
|
284
284
|
} catch (err) {
|
|
285
|
-
logger.error(`Worker
|
|
285
|
+
logger.error(`Worker error: ${task.displayName}`, {
|
|
286
286
|
error: errorMessage(err),
|
|
287
287
|
});
|
|
288
288
|
allResults.push({
|
|
@@ -299,18 +299,18 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
logger.start(
|
|
302
|
+
logger.start(`Running typecheck... (${tasks.length} targets, concurrency: ${concurrency})`);
|
|
303
303
|
await Promise.all(workers.map((worker) => runNextTask(worker)));
|
|
304
|
-
logger.success("
|
|
304
|
+
logger.success("Typecheck execution completed");
|
|
305
305
|
} finally {
|
|
306
306
|
await Promise.all(workers.map((w) => w.terminate()));
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
//
|
|
309
|
+
// Aggregate results
|
|
310
310
|
const allDiagnostics: ts.Diagnostic[] = [];
|
|
311
311
|
let totalErrorCount = 0;
|
|
312
312
|
let totalWarningCount = 0;
|
|
313
|
-
const fileCache = new Map<string, string>(); //
|
|
313
|
+
const fileCache = new Map<string, string>(); // File content cache (prevent duplicate reads of same file)
|
|
314
314
|
for (const { result } of allResults) {
|
|
315
315
|
totalErrorCount += result.errorCount;
|
|
316
316
|
totalWarningCount += result.warningCount;
|
|
@@ -320,17 +320,17 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
if (totalErrorCount > 0) {
|
|
323
|
-
logger.error("
|
|
323
|
+
logger.error("typecheck errors occurred", {
|
|
324
324
|
errorCount: totalErrorCount,
|
|
325
325
|
warningCount: totalWarningCount,
|
|
326
326
|
});
|
|
327
327
|
} else if (totalWarningCount > 0) {
|
|
328
|
-
logger.info("
|
|
328
|
+
logger.info("typecheck complete (warnings present)", {
|
|
329
329
|
errorCount: totalErrorCount,
|
|
330
330
|
warningCount: totalWarningCount,
|
|
331
331
|
});
|
|
332
332
|
} else {
|
|
333
|
-
logger.info("
|
|
333
|
+
logger.info("typecheck complete", { errorCount: totalErrorCount, warningCount: totalWarningCount });
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
let formattedOutput = "";
|
|
@@ -348,12 +348,12 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
/**
|
|
351
|
-
* TypeScript
|
|
351
|
+
* Run TypeScript typecheck.
|
|
352
352
|
*
|
|
353
|
-
* `executeTypecheck()
|
|
353
|
+
* Calls `executeTypecheck()`, outputs results to stdout, and sets `process.exitCode` if errors occur.
|
|
354
354
|
*
|
|
355
|
-
* @param options -
|
|
356
|
-
* @returns
|
|
355
|
+
* @param options - typecheck execution options
|
|
356
|
+
* @returns resolves when complete. If errors are found, sets `process.exitCode` to 1 and resolves (does not throw)
|
|
357
357
|
*/
|
|
358
358
|
export async function runTypecheck(options: TypecheckOptions): Promise<void> {
|
|
359
359
|
const result = await executeTypecheck(options);
|
package/src/commands/watch.ts
CHANGED
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
} from "../orchestrators/WatchOrchestrator";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Build library packages in watch mode.
|
|
9
9
|
*
|
|
10
|
-
* - `sd.config.ts
|
|
11
|
-
* - `node`/`browser`/`neutral`
|
|
12
|
-
* -
|
|
13
|
-
* - SIGINT/SIGTERM
|
|
10
|
+
* - Load `sd.config.ts` to check build target info per package (required)
|
|
11
|
+
* - `node`/`browser`/`neutral` target: build in esbuild watch mode + generate .d.ts
|
|
12
|
+
* - Auto rebuild on file changes
|
|
13
|
+
* - Terminate with SIGINT/SIGTERM signals
|
|
14
14
|
*
|
|
15
|
-
* @param options - watch
|
|
16
|
-
* @returns
|
|
15
|
+
* @param options - watch execution options
|
|
16
|
+
* @returns resolves on termination signal
|
|
17
17
|
*/
|
|
18
18
|
export async function runWatch(options: WatchOrchestratorOptions): Promise<void> {
|
|
19
19
|
const orchestrator = new WatchOrchestrator(options);
|