@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
|
@@ -16,7 +16,7 @@ import type { FsWatcher } from "@simplysm/core-node";
|
|
|
16
16
|
import type { SdBuildPackageConfig } from "../sd-config.types";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Watch
|
|
19
|
+
* Watch command options
|
|
20
20
|
*/
|
|
21
21
|
export interface WatchOrchestratorOptions {
|
|
22
22
|
targets: string[];
|
|
@@ -24,11 +24,11 @@ export interface WatchOrchestratorOptions {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Orchestrator that coordinates watch mode execution
|
|
28
28
|
*
|
|
29
|
-
* Library
|
|
29
|
+
* Manages watch mode execution for Library packages (node/browser/neutral).
|
|
30
30
|
* - LibraryBuilder: esbuild watch
|
|
31
|
-
* - DtsBuilder: .d.ts
|
|
31
|
+
* - DtsBuilder: .d.ts generation
|
|
32
32
|
*/
|
|
33
33
|
export class WatchOrchestrator {
|
|
34
34
|
private readonly _cwd: string;
|
|
@@ -50,15 +50,15 @@ export class WatchOrchestrator {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Orchestrator
|
|
54
|
-
* - sd.config.ts
|
|
55
|
-
* -
|
|
56
|
-
* -
|
|
53
|
+
* Initialize Orchestrator
|
|
54
|
+
* - Load sd.config.ts
|
|
55
|
+
* - Classify packages
|
|
56
|
+
* - Create and initialize builders
|
|
57
57
|
*/
|
|
58
58
|
async initialize(): Promise<void> {
|
|
59
|
-
this._logger.debug("watch
|
|
59
|
+
this._logger.debug("watch start", { targets: this._options.targets });
|
|
60
60
|
|
|
61
|
-
// sd.config.ts
|
|
61
|
+
// Load sd.config.ts
|
|
62
62
|
let sdConfig: SdConfig;
|
|
63
63
|
try {
|
|
64
64
|
sdConfig = await loadSdConfig({
|
|
@@ -66,22 +66,22 @@ export class WatchOrchestrator {
|
|
|
66
66
|
dev: true,
|
|
67
67
|
opt: this._options.options,
|
|
68
68
|
});
|
|
69
|
-
this._logger.debug("sd.config.ts
|
|
69
|
+
this._logger.debug("sd.config.ts loaded");
|
|
70
70
|
} catch (err) {
|
|
71
|
-
this._logger.error(`sd.config.ts
|
|
71
|
+
this._logger.error(`Failed to load sd.config.ts: ${err instanceof Error ? err.message : err}`);
|
|
72
72
|
process.exitCode = 1;
|
|
73
73
|
throw err;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
//
|
|
76
|
+
// Start watch if replaceDeps config exists (initial replacement handled in sd-cli.ts)
|
|
77
77
|
if (sdConfig.replaceDeps != null) {
|
|
78
78
|
this._replaceDepWatcher = await watchReplaceDeps(this._cwd, sdConfig.replaceDeps);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
// targets
|
|
81
|
+
// Filter by targets
|
|
82
82
|
const allPackages = filterPackagesByTargets(sdConfig.packages, this._options.targets);
|
|
83
83
|
|
|
84
|
-
// library
|
|
84
|
+
// Filter only library packages (node, browser, neutral)
|
|
85
85
|
const isLibraryTarget = (target: string): target is BuildTarget =>
|
|
86
86
|
target === "node" || target === "browser" || target === "neutral";
|
|
87
87
|
|
|
@@ -93,28 +93,28 @@ export class WatchOrchestrator {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
if (Object.keys(libraryConfigs).length === 0) {
|
|
96
|
-
process.stdout.write("⚠
|
|
96
|
+
process.stdout.write("⚠ No library packages to watch.\n");
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// PackageInfo
|
|
100
|
+
// Create PackageInfo array
|
|
101
101
|
this._packages = Object.entries(libraryConfigs).map(([name, config]) => ({
|
|
102
102
|
name,
|
|
103
103
|
dir: path.join(this._cwd, "packages", name),
|
|
104
104
|
config,
|
|
105
105
|
}));
|
|
106
106
|
|
|
107
|
-
//
|
|
107
|
+
// Initialize infrastructure
|
|
108
108
|
this._resultCollector = new ResultCollector();
|
|
109
109
|
this._signalHandler = new SignalHandler();
|
|
110
110
|
this._rebuildManager = new RebuildManager(this._logger);
|
|
111
111
|
|
|
112
|
-
//
|
|
112
|
+
// Print errors on batch completion
|
|
113
113
|
this._rebuildManager.on("batchComplete", () => {
|
|
114
114
|
printErrors(this._resultCollector.toMap());
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
//
|
|
117
|
+
// Create builders
|
|
118
118
|
const builderOptions = {
|
|
119
119
|
cwd: this._cwd,
|
|
120
120
|
packages: this._packages,
|
|
@@ -125,25 +125,25 @@ export class WatchOrchestrator {
|
|
|
125
125
|
this._libraryBuilder = new LibraryBuilder(builderOptions);
|
|
126
126
|
this._dtsBuilder = new DtsBuilder(builderOptions);
|
|
127
127
|
|
|
128
|
-
//
|
|
128
|
+
// Initialize builders
|
|
129
129
|
await Promise.all([this._libraryBuilder.initialize(), this._dtsBuilder.initialize()]);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
* -
|
|
135
|
-
* -
|
|
133
|
+
* Start watch mode
|
|
134
|
+
* - Run initial build
|
|
135
|
+
* - Output results
|
|
136
136
|
*/
|
|
137
137
|
async start(): Promise<void> {
|
|
138
138
|
if (this._packages.length === 0) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
//
|
|
142
|
+
// Set up initial build promises
|
|
143
143
|
const buildPromises = this._libraryBuilder.getInitialBuildPromises();
|
|
144
144
|
const dtsPromises = this._dtsBuilder.getInitialBuildPromises();
|
|
145
145
|
|
|
146
|
-
// copySrc watch
|
|
146
|
+
// Start copySrc watch
|
|
147
147
|
for (const pkg of this._packages) {
|
|
148
148
|
const buildConfig = pkg.config as SdBuildPackageConfig;
|
|
149
149
|
if (buildConfig.copySrc != null && buildConfig.copySrc.length > 0) {
|
|
@@ -152,17 +152,17 @@ export class WatchOrchestrator {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
//
|
|
155
|
+
// Start watch (run in background)
|
|
156
156
|
void this._libraryBuilder.startWatch();
|
|
157
157
|
void this._dtsBuilder.startWatch();
|
|
158
158
|
|
|
159
|
-
//
|
|
160
|
-
this._logger.start("
|
|
159
|
+
// Start initial build
|
|
160
|
+
this._logger.start("Running initial build...");
|
|
161
161
|
|
|
162
|
-
//
|
|
162
|
+
// Set up complete promise array for library build and DTS build
|
|
163
163
|
const allBuildTasks: Array<{ name: string; promise: Promise<void> }> = [];
|
|
164
164
|
|
|
165
|
-
// Library
|
|
165
|
+
// Library build tasks
|
|
166
166
|
for (const pkg of this._packages) {
|
|
167
167
|
const promise = buildPromises.get(`${pkg.name}:build`) ?? Promise.resolve();
|
|
168
168
|
allBuildTasks.push({
|
|
@@ -171,7 +171,7 @@ export class WatchOrchestrator {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// DTS
|
|
174
|
+
// DTS tasks
|
|
175
175
|
for (const pkg of this._packages) {
|
|
176
176
|
const promise = dtsPromises.get(`${pkg.name}:dts`) ?? Promise.resolve();
|
|
177
177
|
allBuildTasks.push({
|
|
@@ -180,17 +180,17 @@ export class WatchOrchestrator {
|
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
//
|
|
183
|
+
// Run all build tasks concurrently (wait until initial build completes)
|
|
184
184
|
await Promise.allSettled(allBuildTasks.map((task) => task.promise));
|
|
185
185
|
|
|
186
|
-
this._logger.success("
|
|
186
|
+
this._logger.success("Initial build completed");
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// Output initial build results
|
|
189
189
|
printErrors(this._resultCollector.toMap());
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
|
-
*
|
|
193
|
+
* Wait for termination signal
|
|
194
194
|
*/
|
|
195
195
|
async awaitTermination(): Promise<void> {
|
|
196
196
|
if (this._packages.length === 0) {
|
|
@@ -200,14 +200,14 @@ export class WatchOrchestrator {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
|
-
* Orchestrator
|
|
203
|
+
* Shutdown Orchestrator
|
|
204
204
|
*/
|
|
205
205
|
async shutdown(): Promise<void> {
|
|
206
206
|
if (this._packages.length === 0) {
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
process.stdout.write("⏳
|
|
210
|
+
process.stdout.write("⏳ Shutting down...\n");
|
|
211
211
|
|
|
212
212
|
await Promise.all([
|
|
213
213
|
this._libraryBuilder.shutdown(),
|
|
@@ -217,6 +217,6 @@ export class WatchOrchestrator {
|
|
|
217
217
|
this._copySrcWatchers = [];
|
|
218
218
|
this._replaceDepWatcher?.dispose();
|
|
219
219
|
|
|
220
|
-
process.stdout.write("✔
|
|
220
|
+
process.stdout.write("✔ Done\n");
|
|
221
221
|
}
|
|
222
222
|
}
|
package/src/sd-cli-entry.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// side-effect: Map/Array
|
|
3
|
+
// side-effect: Map/Array prototype extensions (getOrCreate, etc.)
|
|
4
4
|
import "@simplysm/core-common";
|
|
5
5
|
import yargs, { type Argv } from "yargs";
|
|
6
6
|
import { hideBin } from "yargs/helpers";
|
|
@@ -23,16 +23,16 @@ Error.stackTraceLimit = Infinity;
|
|
|
23
23
|
EventEmitter.defaultMaxListeners = 100;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* CLI
|
|
27
|
-
* @internal
|
|
26
|
+
* Create CLI parser
|
|
27
|
+
* @internal exported for testing
|
|
28
28
|
*/
|
|
29
29
|
export function createCliParser(argv: string[]): Argv {
|
|
30
30
|
return yargs(argv)
|
|
31
|
-
.help("help", "
|
|
31
|
+
.help("help", "Show help")
|
|
32
32
|
.alias("help", "h")
|
|
33
33
|
.option("debug", {
|
|
34
34
|
type: "boolean",
|
|
35
|
-
describe: "debug
|
|
35
|
+
describe: "Output debug logs",
|
|
36
36
|
default: false,
|
|
37
37
|
global: true,
|
|
38
38
|
})
|
|
@@ -41,7 +41,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
41
41
|
})
|
|
42
42
|
.command(
|
|
43
43
|
"lint [targets..]",
|
|
44
|
-
"ESLint + Stylelint
|
|
44
|
+
"Run ESLint + Stylelint",
|
|
45
45
|
(cmd) =>
|
|
46
46
|
cmd
|
|
47
47
|
.version(false)
|
|
@@ -49,18 +49,18 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
49
49
|
.positional("targets", {
|
|
50
50
|
type: "string",
|
|
51
51
|
array: true,
|
|
52
|
-
describe: "
|
|
52
|
+
describe: "Paths to lint (e.g., packages/core-common, tests/orm)",
|
|
53
53
|
default: [],
|
|
54
54
|
})
|
|
55
55
|
.options({
|
|
56
56
|
fix: {
|
|
57
57
|
type: "boolean",
|
|
58
|
-
describe: "
|
|
58
|
+
describe: "Auto-fix issues",
|
|
59
59
|
default: false,
|
|
60
60
|
},
|
|
61
61
|
timing: {
|
|
62
62
|
type: "boolean",
|
|
63
|
-
describe: "
|
|
63
|
+
describe: "Print execution time per rule",
|
|
64
64
|
default: false,
|
|
65
65
|
},
|
|
66
66
|
}),
|
|
@@ -74,7 +74,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
74
74
|
)
|
|
75
75
|
.command(
|
|
76
76
|
"typecheck [targets..]",
|
|
77
|
-
"TypeScript
|
|
77
|
+
"Run TypeScript type checking",
|
|
78
78
|
(cmd) =>
|
|
79
79
|
cmd
|
|
80
80
|
.version(false)
|
|
@@ -82,7 +82,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
82
82
|
.positional("targets", {
|
|
83
83
|
type: "string",
|
|
84
84
|
array: true,
|
|
85
|
-
describe: "
|
|
85
|
+
describe: "Paths to typecheck (e.g., packages/core-common, tests/orm)",
|
|
86
86
|
default: [],
|
|
87
87
|
})
|
|
88
88
|
.options({
|
|
@@ -90,7 +90,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
90
90
|
type: "string",
|
|
91
91
|
array: true,
|
|
92
92
|
alias: "o",
|
|
93
|
-
description: "sd.config.ts
|
|
93
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
94
94
|
default: [] as string[],
|
|
95
95
|
},
|
|
96
96
|
}),
|
|
@@ -103,7 +103,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
103
103
|
)
|
|
104
104
|
.command(
|
|
105
105
|
"check [targets..]",
|
|
106
|
-
"Typecheck, Lint, Test
|
|
106
|
+
"Run Typecheck, Lint, Test in parallel",
|
|
107
107
|
(cmd) =>
|
|
108
108
|
cmd
|
|
109
109
|
.version(false)
|
|
@@ -111,13 +111,13 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
111
111
|
.positional("targets", {
|
|
112
112
|
type: "string",
|
|
113
113
|
array: true,
|
|
114
|
-
describe: "
|
|
114
|
+
describe: "Paths to check (e.g., packages/core-common, tests/orm)",
|
|
115
115
|
default: [],
|
|
116
116
|
})
|
|
117
117
|
.options({
|
|
118
118
|
type: {
|
|
119
119
|
type: "string",
|
|
120
|
-
describe: "
|
|
120
|
+
describe: "Check types to run (comma-separated: typecheck,lint,test)",
|
|
121
121
|
default: "typecheck,lint,test",
|
|
122
122
|
},
|
|
123
123
|
}),
|
|
@@ -130,7 +130,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
130
130
|
)
|
|
131
131
|
.command(
|
|
132
132
|
"watch [targets..]",
|
|
133
|
-
"
|
|
133
|
+
"Build packages in watch mode",
|
|
134
134
|
(cmd) =>
|
|
135
135
|
cmd
|
|
136
136
|
.version(false)
|
|
@@ -138,7 +138,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
138
138
|
.positional("targets", {
|
|
139
139
|
type: "string",
|
|
140
140
|
array: true,
|
|
141
|
-
describe: "watch
|
|
141
|
+
describe: "Packages to watch (e.g., solid, solid-demo)",
|
|
142
142
|
default: [],
|
|
143
143
|
})
|
|
144
144
|
.options({
|
|
@@ -146,7 +146,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
146
146
|
type: "string",
|
|
147
147
|
array: true,
|
|
148
148
|
alias: "o",
|
|
149
|
-
description: "sd.config.ts
|
|
149
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
150
150
|
default: [] as string[],
|
|
151
151
|
},
|
|
152
152
|
}),
|
|
@@ -159,7 +159,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
159
159
|
)
|
|
160
160
|
.command(
|
|
161
161
|
"dev [targets..]",
|
|
162
|
-
"Client
|
|
162
|
+
"Run Client and Server packages in dev mode",
|
|
163
163
|
(cmd) =>
|
|
164
164
|
cmd
|
|
165
165
|
.version(false)
|
|
@@ -167,7 +167,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
167
167
|
.positional("targets", {
|
|
168
168
|
type: "string",
|
|
169
169
|
array: true,
|
|
170
|
-
describe: "
|
|
170
|
+
describe: "Packages to run (e.g., solid-demo)",
|
|
171
171
|
default: [],
|
|
172
172
|
})
|
|
173
173
|
.options({
|
|
@@ -175,7 +175,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
175
175
|
type: "string",
|
|
176
176
|
array: true,
|
|
177
177
|
alias: "o",
|
|
178
|
-
description: "sd.config.ts
|
|
178
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
179
179
|
default: [] as string[],
|
|
180
180
|
},
|
|
181
181
|
}),
|
|
@@ -188,7 +188,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
188
188
|
)
|
|
189
189
|
.command(
|
|
190
190
|
"build [targets..]",
|
|
191
|
-
"
|
|
191
|
+
"Run production build",
|
|
192
192
|
(cmd) =>
|
|
193
193
|
cmd
|
|
194
194
|
.version(false)
|
|
@@ -196,7 +196,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
196
196
|
.positional("targets", {
|
|
197
197
|
type: "string",
|
|
198
198
|
array: true,
|
|
199
|
-
describe: "
|
|
199
|
+
describe: "Packages to build (e.g., solid, core-common)",
|
|
200
200
|
default: [],
|
|
201
201
|
})
|
|
202
202
|
.options({
|
|
@@ -204,7 +204,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
204
204
|
type: "string",
|
|
205
205
|
array: true,
|
|
206
206
|
alias: "o",
|
|
207
|
-
description: "sd.config.ts
|
|
207
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
208
208
|
default: [] as string[],
|
|
209
209
|
},
|
|
210
210
|
}),
|
|
@@ -217,7 +217,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
217
217
|
)
|
|
218
218
|
.command(
|
|
219
219
|
"device",
|
|
220
|
-
"
|
|
220
|
+
"Run app on Android device",
|
|
221
221
|
(cmd) =>
|
|
222
222
|
cmd
|
|
223
223
|
.version(false)
|
|
@@ -226,19 +226,19 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
226
226
|
package: {
|
|
227
227
|
type: "string",
|
|
228
228
|
alias: "p",
|
|
229
|
-
describe: "
|
|
229
|
+
describe: "Package name",
|
|
230
230
|
demandOption: true,
|
|
231
231
|
},
|
|
232
232
|
url: {
|
|
233
233
|
type: "string",
|
|
234
234
|
alias: "u",
|
|
235
|
-
describe: "
|
|
235
|
+
describe: "Development server URL (if not specified, use server config from sd.config.ts)",
|
|
236
236
|
},
|
|
237
237
|
opt: {
|
|
238
238
|
type: "string",
|
|
239
239
|
array: true,
|
|
240
240
|
alias: "o",
|
|
241
|
-
description: "sd.config.ts
|
|
241
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
242
242
|
default: [] as string[],
|
|
243
243
|
},
|
|
244
244
|
}),
|
|
@@ -252,20 +252,20 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
252
252
|
)
|
|
253
253
|
.command(
|
|
254
254
|
"init",
|
|
255
|
-
"
|
|
255
|
+
"Initialize new project",
|
|
256
256
|
(cmd) => cmd.version(false).hide("help"),
|
|
257
257
|
async () => {
|
|
258
258
|
const { runInit } = await import("./commands/init.js");
|
|
259
259
|
await runInit({});
|
|
260
260
|
},
|
|
261
261
|
)
|
|
262
|
-
.command("add", "
|
|
262
|
+
.command("add", "Add package to project", (cmd) =>
|
|
263
263
|
cmd
|
|
264
264
|
.version(false)
|
|
265
265
|
.hide("help")
|
|
266
266
|
.command(
|
|
267
267
|
"client",
|
|
268
|
-
"
|
|
268
|
+
"Add client package",
|
|
269
269
|
(subCmd) => subCmd.version(false).hide("help"),
|
|
270
270
|
async () => {
|
|
271
271
|
const { runAddClient } = await import("./commands/add-client.js");
|
|
@@ -274,18 +274,18 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
274
274
|
)
|
|
275
275
|
.command(
|
|
276
276
|
"server",
|
|
277
|
-
"
|
|
277
|
+
"Add server package",
|
|
278
278
|
(subCmd) => subCmd.version(false).hide("help"),
|
|
279
279
|
async () => {
|
|
280
280
|
const { runAddServer } = await import("./commands/add-server.js");
|
|
281
281
|
await runAddServer({});
|
|
282
282
|
},
|
|
283
283
|
)
|
|
284
|
-
.demandCommand(1, "
|
|
284
|
+
.demandCommand(1, "Please specify package type. (client, server)"),
|
|
285
285
|
)
|
|
286
286
|
.command(
|
|
287
287
|
"publish [targets..]",
|
|
288
|
-
"
|
|
288
|
+
"Publish packages",
|
|
289
289
|
(cmd) =>
|
|
290
290
|
cmd
|
|
291
291
|
.version(false)
|
|
@@ -293,25 +293,25 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
293
293
|
.positional("targets", {
|
|
294
294
|
type: "string",
|
|
295
295
|
array: true,
|
|
296
|
-
describe: "
|
|
296
|
+
describe: "Packages to publish (e.g., solid, core-common)",
|
|
297
297
|
default: [],
|
|
298
298
|
})
|
|
299
299
|
.options({
|
|
300
300
|
"build": {
|
|
301
301
|
type: "boolean",
|
|
302
|
-
describe: "
|
|
302
|
+
describe: "Run build (skip with --no-build)",
|
|
303
303
|
default: true,
|
|
304
304
|
},
|
|
305
305
|
"dry-run": {
|
|
306
306
|
type: "boolean",
|
|
307
|
-
describe: "
|
|
307
|
+
describe: "Simulate without actual deployment",
|
|
308
308
|
default: false,
|
|
309
309
|
},
|
|
310
310
|
"opt": {
|
|
311
311
|
type: "string",
|
|
312
312
|
array: true,
|
|
313
313
|
alias: "o",
|
|
314
|
-
description: "sd.config.ts
|
|
314
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
315
315
|
default: [] as string[],
|
|
316
316
|
},
|
|
317
317
|
}),
|
|
@@ -326,7 +326,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
326
326
|
)
|
|
327
327
|
.command(
|
|
328
328
|
"replace-deps",
|
|
329
|
-
"
|
|
329
|
+
"Replace node_modules packages with local sources via symlink according to replaceDeps config in sd.config.ts",
|
|
330
330
|
(cmd) =>
|
|
331
331
|
cmd
|
|
332
332
|
.version(false)
|
|
@@ -336,7 +336,7 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
336
336
|
type: "string",
|
|
337
337
|
array: true,
|
|
338
338
|
alias: "o",
|
|
339
|
-
description: "sd.config.ts
|
|
339
|
+
description: "Options to pass to sd.config.ts (e.g., -o key=value)",
|
|
340
340
|
default: [] as string[],
|
|
341
341
|
},
|
|
342
342
|
}),
|
|
@@ -346,12 +346,12 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
346
346
|
});
|
|
347
347
|
},
|
|
348
348
|
)
|
|
349
|
-
.demandCommand(1, "
|
|
349
|
+
.demandCommand(1, "Please specify a command.")
|
|
350
350
|
.strict();
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
//
|
|
354
|
-
//
|
|
353
|
+
// Parse only when executed directly as CLI
|
|
354
|
+
// Determine main module in ESM: normalize import.meta.url and process.argv[1] and compare
|
|
355
355
|
const cliEntryPath = process.argv.at(1);
|
|
356
356
|
if (
|
|
357
357
|
cliEntryPath != null &&
|
package/src/sd-cli.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* CLI Launcher
|
|
5
5
|
*
|
|
6
|
-
* .ts
|
|
7
|
-
* .js
|
|
6
|
+
* .ts execution (dev): apply CPU affinity then directly import sd-cli-entry
|
|
7
|
+
* .js execution (production): run replaceDeps then spawn sd-cli-entry in new process
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { execa } from "execa";
|
|
@@ -17,16 +17,16 @@ const __dirname = path.dirname(__filename);
|
|
|
17
17
|
const isDev = path.extname(__filename) === ".ts";
|
|
18
18
|
|
|
19
19
|
if (isDev) {
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// createCliParser
|
|
20
|
+
// Dev mode (.ts): apply affinity then run directly
|
|
21
|
+
// Main module detection fails with import only (process.argv[1] ≠ sd-cli-entry)
|
|
22
|
+
// so createCliParser must be called explicitly.
|
|
23
23
|
configureAffinityAndPriority(process.pid);
|
|
24
24
|
const { createCliParser } = await import("./sd-cli-entry.js");
|
|
25
25
|
await createCliParser(process.argv.slice(2)).parse();
|
|
26
26
|
} else {
|
|
27
|
-
//
|
|
27
|
+
// Production mode (.js): two-stage execution
|
|
28
28
|
|
|
29
|
-
// Phase 1: replaceDeps (inline —
|
|
29
|
+
// Phase 1: replaceDeps (inline — copy to installed version)
|
|
30
30
|
try {
|
|
31
31
|
const { loadSdConfig } = await import("./utils/sd-config.js");
|
|
32
32
|
const { setupReplaceDeps } = await import("./utils/replace-deps.js");
|
|
@@ -35,10 +35,10 @@ if (isDev) {
|
|
|
35
35
|
await setupReplaceDeps(process.cwd(), sdConfig.replaceDeps);
|
|
36
36
|
}
|
|
37
37
|
} catch {
|
|
38
|
-
// sd.config.ts
|
|
38
|
+
// Skip if sd.config.ts is missing or replaceDeps is not configured
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// Phase 2:
|
|
41
|
+
// Phase 2: Run actual CLI in new process (reset module cache)
|
|
42
42
|
const cliEntryFilePath = path.join(__dirname, "sd-cli-entry.js");
|
|
43
43
|
const subprocess = execa(
|
|
44
44
|
"node",
|
|
@@ -56,10 +56,10 @@ if (isDev) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* CPU affinity mask
|
|
59
|
+
* Calculate CPU affinity mask (exclude front cores)
|
|
60
60
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* Exclude 1 core per 4 CPUs, then set bits ON for remaining cores.
|
|
62
|
+
* Example: 8 cores → exclude 2 → 0xFC (cores 2~7)
|
|
63
63
|
*/
|
|
64
64
|
function calculateAffinityMask(cpuCount: number): string {
|
|
65
65
|
const exclude = cpuCount <= 1 ? 0 : Math.ceil(cpuCount / 4);
|
|
@@ -71,12 +71,12 @@ function calculateAffinityMask(cpuCount: number): string {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* Configure CPU affinity and priority (cross-platform)
|
|
75
75
|
*
|
|
76
76
|
* - Windows: PowerShell ProcessorAffinity + PriorityClass
|
|
77
77
|
* - Linux/WSL: taskset + renice
|
|
78
78
|
*
|
|
79
|
-
*
|
|
79
|
+
* Only print warning on failure; does not affect CLI operation.
|
|
80
80
|
*/
|
|
81
81
|
function configureAffinityAndPriority(pid: number): void {
|
|
82
82
|
const cpuCount = os.cpus().length;
|
|
@@ -96,6 +96,6 @@ function configureAffinityAndPriority(pid: number): void {
|
|
|
96
96
|
|
|
97
97
|
execa({ shell: true })`${command}`.catch((err: Error) => {
|
|
98
98
|
// eslint-disable-next-line no-console
|
|
99
|
-
console.warn("CPU affinity/priority
|
|
99
|
+
console.warn("Failed to configure CPU affinity/priority:", err.message);
|
|
100
100
|
});
|
|
101
101
|
}
|