@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
|
@@ -27,17 +27,17 @@ import { formatBuildMessages } from "../utils/output-utils";
|
|
|
27
27
|
//#region Types
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Build Orchestrator
|
|
30
|
+
* Build Orchestrator options
|
|
31
31
|
*/
|
|
32
32
|
export interface BuildOrchestratorOptions {
|
|
33
|
-
/**
|
|
33
|
+
/** Package filter for build (empty array includes all packages) */
|
|
34
34
|
targets: string[];
|
|
35
|
-
/** sd.config.ts
|
|
35
|
+
/** Additional options to pass to sd.config.ts */
|
|
36
36
|
options: string[];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Build result
|
|
41
41
|
*/
|
|
42
42
|
interface BuildStepResult {
|
|
43
43
|
name: string;
|
|
@@ -50,14 +50,14 @@ interface BuildStepResult {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Package classification result
|
|
54
54
|
*/
|
|
55
55
|
interface ClassifiedPackages {
|
|
56
|
-
/** node/browser/neutral
|
|
56
|
+
/** node/browser/neutral target (JS + dts) */
|
|
57
57
|
buildPackages: Array<{ name: string; config: SdBuildPackageConfig }>;
|
|
58
|
-
/** client
|
|
58
|
+
/** client target (Vite build + typecheck) */
|
|
59
59
|
clientPackages: Array<{ name: string; config: SdClientPackageConfig }>;
|
|
60
|
-
/** server
|
|
60
|
+
/** server target (JS build, no dts) */
|
|
61
61
|
serverPackages: Array<{ name: string; config: SdServerPackageConfig }>;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -66,11 +66,11 @@ interface ClassifiedPackages {
|
|
|
66
66
|
//#region Utilities
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Classify packages by target
|
|
70
70
|
* - node/browser/neutral: buildPackages (JS + dts)
|
|
71
71
|
* - client: clientPackages (Vite build + typecheck)
|
|
72
|
-
* - server: serverPackages (JS
|
|
73
|
-
* - scripts:
|
|
72
|
+
* - server: serverPackages (JS build, no dts)
|
|
73
|
+
* - scripts: excluded
|
|
74
74
|
*/
|
|
75
75
|
function classifyPackages(
|
|
76
76
|
packages: Record<
|
|
@@ -91,7 +91,7 @@ function classifyPackages(
|
|
|
91
91
|
if (config == null) continue;
|
|
92
92
|
if (config.target === "scripts") continue;
|
|
93
93
|
|
|
94
|
-
//
|
|
94
|
+
// Include only specified packages if targets is specified
|
|
95
95
|
if (targets.length > 0 && !targets.includes(name)) continue;
|
|
96
96
|
|
|
97
97
|
if (config.target === "client") {
|
|
@@ -107,7 +107,7 @@ function classifyPackages(
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* dist
|
|
110
|
+
* Delete dist folders
|
|
111
111
|
*/
|
|
112
112
|
async function cleanDistFolders(cwd: string, packageNames: string[]): Promise<void> {
|
|
113
113
|
await Promise.all(packageNames.map((name) => fsRm(path.join(cwd, "packages", name, "dist"))));
|
|
@@ -118,14 +118,14 @@ async function cleanDistFolders(cwd: string, packageNames: string[]): Promise<vo
|
|
|
118
118
|
//#region BuildOrchestrator
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
121
|
+
* Orchestrator for coordinating production builds
|
|
122
122
|
*
|
|
123
|
-
* sd.config.ts
|
|
124
|
-
* - dist
|
|
125
|
-
* - lint +
|
|
126
|
-
* - node/browser/neutral
|
|
127
|
-
* - client
|
|
128
|
-
* - server
|
|
123
|
+
* Classifies packages based on sd.config.ts and executes builds.
|
|
124
|
+
* - Clean dist folders (clean build)
|
|
125
|
+
* - Run lint + build concurrently
|
|
126
|
+
* - node/browser/neutral targets: esbuild JS build + dts generation
|
|
127
|
+
* - client targets: Vite production build + typecheck + Capacitor/Electron builds
|
|
128
|
+
* - server targets: esbuild JS build
|
|
129
129
|
*/
|
|
130
130
|
export class BuildOrchestrator {
|
|
131
131
|
private readonly _cwd: string;
|
|
@@ -143,34 +143,34 @@ export class BuildOrchestrator {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
|
-
* Orchestrator
|
|
147
|
-
* - sd.config.ts
|
|
148
|
-
* - replaceDeps
|
|
149
|
-
* -
|
|
150
|
-
* -
|
|
146
|
+
* Initialize Orchestrator
|
|
147
|
+
* - Load sd.config.ts
|
|
148
|
+
* - Configure replaceDeps
|
|
149
|
+
* - Classify packages
|
|
150
|
+
* - Prepare environment variables
|
|
151
151
|
*/
|
|
152
152
|
async initialize(): Promise<void> {
|
|
153
|
-
this._logger.debug("
|
|
153
|
+
this._logger.debug("build started", { targets: this._options.targets });
|
|
154
154
|
|
|
155
|
-
// sd.config.ts
|
|
155
|
+
// Load sd.config.ts
|
|
156
156
|
try {
|
|
157
157
|
this._sdConfig = await loadSdConfig({
|
|
158
158
|
cwd: this._cwd,
|
|
159
159
|
dev: false,
|
|
160
160
|
opt: this._options.options,
|
|
161
161
|
});
|
|
162
|
-
this._logger.debug("sd.config.ts
|
|
162
|
+
this._logger.debug("sd.config.ts loaded");
|
|
163
163
|
} catch (err) {
|
|
164
|
-
this._logger.error(`sd.config.ts
|
|
164
|
+
this._logger.error(`sd.config.ts load failed: ${err instanceof Error ? err.message : err}`);
|
|
165
165
|
process.exitCode = 1;
|
|
166
166
|
throw err;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
// VER
|
|
169
|
+
// Prepare VER and DEV environment variables
|
|
170
170
|
const version = await getVersion(this._cwd);
|
|
171
171
|
this._baseEnv = { VER: version, DEV: "false" };
|
|
172
172
|
|
|
173
|
-
//
|
|
173
|
+
// Classify packages
|
|
174
174
|
this._classified = classifyPackages(this._sdConfig.packages, this._options.targets);
|
|
175
175
|
this._allPackageNames = [
|
|
176
176
|
...this._classified.buildPackages.map((p) => p.name),
|
|
@@ -179,11 +179,11 @@ export class BuildOrchestrator {
|
|
|
179
179
|
];
|
|
180
180
|
|
|
181
181
|
if (this._allPackageNames.length === 0) {
|
|
182
|
-
process.stdout.write("✔
|
|
182
|
+
process.stdout.write("✔ No packages to build.\n");
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
this._logger.debug("
|
|
186
|
+
this._logger.debug("package classification complete", {
|
|
187
187
|
buildPackages: this._classified.buildPackages.map((p) => p.name),
|
|
188
188
|
clientPackages: this._classified.clientPackages.map((p) => p.name),
|
|
189
189
|
serverPackages: this._classified.serverPackages.map((p) => p.name),
|
|
@@ -191,12 +191,12 @@ export class BuildOrchestrator {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
194
|
+
* Execute build
|
|
195
195
|
* - Clean
|
|
196
196
|
* - Lint + Build (concurrent)
|
|
197
|
-
* -
|
|
197
|
+
* - Output results
|
|
198
198
|
*
|
|
199
|
-
* @returns
|
|
199
|
+
* @returns whether errors occurred (true: errors present)
|
|
200
200
|
*/
|
|
201
201
|
async start(): Promise<boolean> {
|
|
202
202
|
if (this._allPackageNames.length === 0) {
|
|
@@ -206,29 +206,29 @@ export class BuildOrchestrator {
|
|
|
206
206
|
const classified = this._classified!;
|
|
207
207
|
const baseEnv = this._baseEnv!;
|
|
208
208
|
|
|
209
|
-
//
|
|
209
|
+
// Collect results
|
|
210
210
|
const results: BuildStepResult[] = [];
|
|
211
|
-
//
|
|
211
|
+
// Track errors (wrapped in object to allow mutation tracking in callbacks)
|
|
212
212
|
const state = { hasError: false };
|
|
213
213
|
|
|
214
|
-
// Worker
|
|
214
|
+
// Worker paths
|
|
215
215
|
const libraryWorkerPath = import.meta.resolve("../workers/library.worker");
|
|
216
216
|
const serverWorkerPath = import.meta.resolve("../workers/server.worker");
|
|
217
217
|
const clientWorkerPath = import.meta.resolve("../workers/client.worker");
|
|
218
218
|
const dtsWorkerPath = import.meta.resolve("../workers/dts.worker");
|
|
219
219
|
const lintWorkerPath = import.meta.resolve("../workers/lint.worker");
|
|
220
220
|
|
|
221
|
-
//
|
|
221
|
+
// File cache (for diagnostics output)
|
|
222
222
|
const fileCache = new Map<string, string>();
|
|
223
223
|
|
|
224
|
-
// formatHost (diagnostics
|
|
224
|
+
// formatHost (for diagnostics output)
|
|
225
225
|
const formatHost: ts.FormatDiagnosticsHost = {
|
|
226
226
|
getCanonicalFileName: (f) => f,
|
|
227
227
|
getCurrentDirectory: () => this._cwd,
|
|
228
228
|
getNewLine: () => ts.sys.newLine,
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
// Lint
|
|
231
|
+
// Lint options (target all packages)
|
|
232
232
|
const lintOptions: LintOptions = {
|
|
233
233
|
targets: this._allPackageNames.map((name) => `packages/${name}`),
|
|
234
234
|
fix: false,
|
|
@@ -243,17 +243,17 @@ export class BuildOrchestrator {
|
|
|
243
243
|
// Phase 2: Lint + Build (concurrent)
|
|
244
244
|
this._logger.start("Lint + Build");
|
|
245
245
|
|
|
246
|
-
//
|
|
246
|
+
// Create list of build tasks
|
|
247
247
|
const buildTasks: Array<() => Promise<void>> = [];
|
|
248
248
|
|
|
249
|
-
// buildPackages: JS
|
|
249
|
+
// buildPackages: JS build + dts generation
|
|
250
250
|
for (const { name, config } of classified.buildPackages) {
|
|
251
251
|
const pkgDir = path.join(this._cwd, "packages", name);
|
|
252
252
|
const env: TypecheckEnv = config.target === "node" ? "node" : "browser";
|
|
253
253
|
|
|
254
254
|
buildTasks.push(async () => {
|
|
255
|
-
this._logger.debug(`${name} (${config.target})
|
|
256
|
-
// JS
|
|
255
|
+
this._logger.debug(`${name} (${config.target}) started`);
|
|
256
|
+
// Run JS build and DTS generation in parallel
|
|
257
257
|
const libraryWorker: WorkerProxy<typeof LibraryWorkerModule> =
|
|
258
258
|
Worker.create<typeof LibraryWorkerModule>(libraryWorkerPath);
|
|
259
259
|
const dtsWorker: WorkerProxy<typeof DtsWorkerModule> =
|
|
@@ -261,13 +261,13 @@ export class BuildOrchestrator {
|
|
|
261
261
|
|
|
262
262
|
try {
|
|
263
263
|
const [buildResult, dtsResult] = await Promise.all([
|
|
264
|
-
// JS
|
|
264
|
+
// JS build
|
|
265
265
|
libraryWorker.build({ name, config, cwd: this._cwd, pkgDir }),
|
|
266
|
-
// DTS
|
|
266
|
+
// DTS generation
|
|
267
267
|
dtsWorker.build({ name, cwd: this._cwd, pkgDir, env, emit: true }),
|
|
268
268
|
]);
|
|
269
269
|
|
|
270
|
-
// JS
|
|
270
|
+
// Handle JS build results
|
|
271
271
|
results.push({
|
|
272
272
|
name,
|
|
273
273
|
target: config.target,
|
|
@@ -278,7 +278,7 @@ export class BuildOrchestrator {
|
|
|
278
278
|
});
|
|
279
279
|
if (!buildResult.success) state.hasError = true;
|
|
280
280
|
|
|
281
|
-
// DTS
|
|
281
|
+
// Handle DTS results
|
|
282
282
|
const diagnostics = dtsResult.diagnostics.map((d) => deserializeDiagnostic(d, fileCache));
|
|
283
283
|
results.push({
|
|
284
284
|
name,
|
|
@@ -293,21 +293,21 @@ export class BuildOrchestrator {
|
|
|
293
293
|
await Promise.all([libraryWorker.terminate(), dtsWorker.terminate()]);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
// copySrc
|
|
296
|
+
// Copy copySrc files
|
|
297
297
|
if (config.copySrc != null && config.copySrc.length > 0) {
|
|
298
298
|
await copySrcFiles(pkgDir, config.copySrc);
|
|
299
299
|
}
|
|
300
|
-
this._logger.debug(`${name} (${config.target})
|
|
300
|
+
this._logger.debug(`${name} (${config.target}) completed`);
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
// clientPackages: Vite
|
|
304
|
+
// clientPackages: Vite build + typecheck + Capacitor build
|
|
305
305
|
for (const { name, config } of classified.clientPackages) {
|
|
306
306
|
const pkgDir = path.join(this._cwd, "packages", name);
|
|
307
307
|
|
|
308
308
|
buildTasks.push(async () => {
|
|
309
|
-
this._logger.debug(`${name} (client)
|
|
310
|
-
// Vite
|
|
309
|
+
this._logger.debug(`${name} (client) started`);
|
|
310
|
+
// Run Vite build and typecheck in parallel
|
|
311
311
|
const clientWorker: WorkerProxy<typeof ClientWorkerModule> =
|
|
312
312
|
Worker.create<typeof ClientWorkerModule>(clientWorkerPath);
|
|
313
313
|
const dtsWorker: WorkerProxy<typeof DtsWorkerModule> =
|
|
@@ -319,9 +319,9 @@ export class BuildOrchestrator {
|
|
|
319
319
|
env: { ...baseEnv, ...config.env },
|
|
320
320
|
};
|
|
321
321
|
const [clientResult, dtsResult] = await Promise.all([
|
|
322
|
-
// Vite production
|
|
322
|
+
// Vite production build
|
|
323
323
|
clientWorker.build({ name, config: clientConfig, cwd: this._cwd, pkgDir }),
|
|
324
|
-
// typecheck (dts
|
|
324
|
+
// typecheck (without dts)
|
|
325
325
|
dtsWorker.build({
|
|
326
326
|
name,
|
|
327
327
|
cwd: this._cwd,
|
|
@@ -331,7 +331,7 @@ export class BuildOrchestrator {
|
|
|
331
331
|
}),
|
|
332
332
|
]);
|
|
333
333
|
|
|
334
|
-
// Vite
|
|
334
|
+
// Handle Vite build results
|
|
335
335
|
results.push({
|
|
336
336
|
name,
|
|
337
337
|
target: "client",
|
|
@@ -341,7 +341,7 @@ export class BuildOrchestrator {
|
|
|
341
341
|
});
|
|
342
342
|
if (!clientResult.success) state.hasError = true;
|
|
343
343
|
|
|
344
|
-
//
|
|
344
|
+
// Handle typecheck results
|
|
345
345
|
const diagnostics = dtsResult.diagnostics.map((d) => deserializeDiagnostic(d, fileCache));
|
|
346
346
|
results.push({
|
|
347
347
|
name,
|
|
@@ -356,7 +356,7 @@ export class BuildOrchestrator {
|
|
|
356
356
|
await Promise.all([clientWorker.terminate(), dtsWorker.terminate()]);
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
// Capacitor
|
|
359
|
+
// Capacitor build (only if configured)
|
|
360
360
|
if (config.capacitor != null) {
|
|
361
361
|
const outPath = path.join(pkgDir, "dist");
|
|
362
362
|
try {
|
|
@@ -381,7 +381,7 @@ export class BuildOrchestrator {
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
// Electron
|
|
384
|
+
// Electron build (only if configured)
|
|
385
385
|
if (config.electron != null) {
|
|
386
386
|
const outPath = path.join(pkgDir, "dist");
|
|
387
387
|
try {
|
|
@@ -405,16 +405,16 @@ export class BuildOrchestrator {
|
|
|
405
405
|
state.hasError = true;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
this._logger.debug(`${name} (client)
|
|
408
|
+
this._logger.debug(`${name} (client) completed`);
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
// serverPackages: JS
|
|
412
|
+
// serverPackages: JS build only (dts generation excluded)
|
|
413
413
|
for (const { name, config } of classified.serverPackages) {
|
|
414
414
|
const pkgDir = path.join(this._cwd, "packages", name);
|
|
415
415
|
|
|
416
416
|
buildTasks.push(async () => {
|
|
417
|
-
this._logger.debug(`${name} (server)
|
|
417
|
+
this._logger.debug(`${name} (server) started`);
|
|
418
418
|
const serverWorker: WorkerProxy<typeof ServerWorkerModule> =
|
|
419
419
|
Worker.create<typeof ServerWorkerModule>(serverWorkerPath);
|
|
420
420
|
|
|
@@ -442,11 +442,11 @@ export class BuildOrchestrator {
|
|
|
442
442
|
} finally {
|
|
443
443
|
await serverWorker.terminate();
|
|
444
444
|
}
|
|
445
|
-
this._logger.debug(`${name} (server)
|
|
445
|
+
this._logger.debug(`${name} (server) completed`);
|
|
446
446
|
});
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
-
// Lint +
|
|
449
|
+
// Run Lint + all builds in parallel
|
|
450
450
|
const lintWorker = Worker.create<typeof LintWorkerModule>(lintWorkerPath);
|
|
451
451
|
const lintTask = async (): Promise<void> => {
|
|
452
452
|
try {
|
|
@@ -459,17 +459,17 @@ export class BuildOrchestrator {
|
|
|
459
459
|
await Promise.allSettled([lintTask(), ...buildTasks.map((task) => task())]);
|
|
460
460
|
this._logger.success("Lint + Build");
|
|
461
461
|
|
|
462
|
-
//
|
|
462
|
+
// Output results
|
|
463
463
|
const allDiagnostics: ts.Diagnostic[] = [];
|
|
464
464
|
for (const result of results) {
|
|
465
465
|
const typeLabel = result.type === "dts" ? "dts" : result.target;
|
|
466
466
|
|
|
467
|
-
// warnings
|
|
467
|
+
// Output warnings
|
|
468
468
|
if (result.warnings != null) {
|
|
469
469
|
this._logger.warn(formatBuildMessages(result.name, typeLabel, result.warnings));
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
-
// errors
|
|
472
|
+
// Output errors
|
|
473
473
|
if (!result.success) {
|
|
474
474
|
if (result.errors != null) {
|
|
475
475
|
this._logger.error(formatBuildMessages(result.name, typeLabel, result.errors));
|
|
@@ -482,29 +482,29 @@ export class BuildOrchestrator {
|
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
// diagnostics
|
|
485
|
+
// Output diagnostics (deduplicated)
|
|
486
486
|
if (allDiagnostics.length > 0) {
|
|
487
487
|
const uniqueDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
|
|
488
488
|
const message = ts.formatDiagnosticsWithColorAndContext(uniqueDiagnostics, formatHost);
|
|
489
489
|
process.stdout.write(message);
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
//
|
|
492
|
+
// Output result log
|
|
493
493
|
if (state.hasError) {
|
|
494
|
-
this._logger.error("
|
|
494
|
+
this._logger.error("Build failed");
|
|
495
495
|
} else {
|
|
496
|
-
this._logger.info("
|
|
496
|
+
this._logger.info("Build completed");
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
return state.hasError;
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
/**
|
|
503
|
-
* Orchestrator
|
|
503
|
+
* Shutdown Orchestrator (no resources to clean up currently)
|
|
504
504
|
*/
|
|
505
505
|
async shutdown(): Promise<void> {
|
|
506
|
-
//
|
|
507
|
-
//
|
|
506
|
+
// Production builds are one-time operations, so there are no resources to clean up at shutdown
|
|
507
|
+
// Workers are cleaned up with terminate() within each build task
|
|
508
508
|
await Promise.resolve();
|
|
509
509
|
}
|
|
510
510
|
}
|