@simplysm/sd-cli 14.0.11 → 14.0.13
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 +58 -253
- package/dist/angular/client-transform-stylesheet.js +1 -1
- package/dist/angular/client-transform-stylesheet.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +4 -2
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +73 -36
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/angular/vite-postcss-inline-plugin.d.ts +1 -1
- package/dist/angular/vite-postcss-inline-plugin.js +1 -1
- package/dist/capacitor/capacitor.d.ts +20 -2
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +155 -28
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/build.d.ts +3 -10
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +3 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -9
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -9
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/device.d.ts +3 -3
- package/dist/commands/device.js +5 -5
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/publish.d.ts +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +24 -26
- 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/typecheck.d.ts +4 -3
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +5 -11
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +9 -9
- package/dist/commands/watch.js +9 -9
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +42 -3
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts +1 -1
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +3 -1
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts +7 -7
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +3 -3
- package/dist/engines/ServerEsbuildEngine.d.ts +7 -7
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
- package/dist/engines/ServerEsbuildEngine.js +3 -3
- package/dist/engines/TscEngine.d.ts +7 -7
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +3 -3
- package/dist/engines/ViteEngine.d.ts +7 -1
- package/dist/engines/ViteEngine.d.ts.map +1 -1
- package/dist/engines/ViteEngine.js +13 -12
- package/dist/engines/ViteEngine.js.map +1 -1
- package/dist/engines/index.d.ts +9 -5
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +7 -5
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/types.d.ts +20 -20
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/infra/ResultCollector.d.ts +9 -9
- package/dist/infra/ResultCollector.js +8 -8
- package/dist/infra/SignalHandler.d.ts +7 -7
- package/dist/infra/SignalHandler.js +7 -7
- package/dist/infra/WorkerManager.d.ts +14 -14
- package/dist/infra/WorkerManager.js +14 -14
- package/dist/orchestrators/BuildOrchestrator.d.ts +25 -25
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +34 -30
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.d.ts +7 -7
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.js +34 -34
- package/dist/orchestrators/DevWatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +2 -2
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +15 -8
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.d.ts +3 -3
- package/dist/sd-cli.js +16 -16
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +105 -105
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/angular-compiler.js +5 -5
- package/dist/utils/angular-compiler.js.map +1 -1
- package/dist/utils/build-env.d.ts +1 -1
- package/dist/utils/build-env.js +1 -1
- package/dist/utils/concurrency.d.ts +7 -7
- package/dist/utils/concurrency.js +7 -7
- package/dist/utils/copy-public.d.ts +9 -9
- package/dist/utils/copy-public.js +17 -17
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/copy-src.d.ts +9 -9
- package/dist/utils/copy-src.js +11 -11
- package/dist/utils/copy-src.js.map +1 -1
- package/dist/utils/engine-stop.d.ts +8 -9
- package/dist/utils/engine-stop.d.ts.map +1 -1
- package/dist/utils/engine-stop.js +9 -10
- package/dist/utils/engine-stop.js.map +1 -1
- package/dist/utils/esbuild-config.d.ts +23 -23
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +25 -25
- package/dist/utils/esbuild-config.js.map +1 -1
- package/dist/utils/lint-with-program.d.ts +15 -15
- package/dist/utils/lint-with-program.d.ts.map +1 -1
- package/dist/utils/lint-with-program.js +29 -29
- package/dist/utils/lint-with-program.js.map +1 -1
- package/dist/utils/ngtsc-build-core.d.ts +8 -8
- package/dist/utils/ngtsc-build-core.d.ts.map +1 -1
- package/dist/utils/ngtsc-build-core.js +14 -14
- package/dist/utils/ngtsc-build-core.js.map +1 -1
- package/dist/utils/output-path-rewriter.d.ts +14 -14
- package/dist/utils/output-path-rewriter.js +18 -18
- package/dist/utils/output-path-rewriter.js.map +1 -1
- package/dist/utils/output-utils.d.ts +6 -6
- package/dist/utils/output-utils.js +11 -11
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/utils/package-utils.d.ts +21 -21
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +56 -45
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/replace-deps.d.ts +25 -25
- package/dist/utils/replace-deps.d.ts.map +1 -1
- package/dist/utils/replace-deps.js +84 -65
- 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/tsc-build.d.ts +13 -13
- package/dist/utils/tsc-build.d.ts.map +1 -1
- package/dist/utils/tsc-build.js +9 -9
- package/dist/utils/tsc-build.js.map +1 -1
- package/dist/utils/tsconfig.d.ts +11 -9
- package/dist/utils/tsconfig.d.ts.map +1 -1
- package/dist/utils/tsconfig.js +11 -9
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-non-package.d.ts +5 -6
- package/dist/utils/typecheck-non-package.d.ts.map +1 -1
- package/dist/utils/typecheck-non-package.js +7 -8
- package/dist/utils/typecheck-non-package.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts +8 -8
- package/dist/utils/typecheck-serialization.d.ts.map +1 -1
- package/dist/utils/typecheck-serialization.js +12 -16
- package/dist/utils/typecheck-serialization.js.map +1 -1
- package/dist/utils/vite-config.d.ts +12 -5
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +95 -41
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/vite-scope-watch-plugin.d.ts.map +1 -1
- package/dist/utils/vite-scope-watch-plugin.js +1 -1
- package/dist/utils/vite-scope-watch-plugin.js.map +1 -1
- package/dist/utils/worker-events.d.ts +12 -12
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-events.js +10 -10
- package/dist/utils/worker-events.js.map +1 -1
- package/dist/utils/worker-utils.d.ts +12 -13
- package/dist/utils/worker-utils.d.ts.map +1 -1
- package/dist/utils/worker-utils.js +12 -13
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +5 -7
- package/dist/vitest-plugin.js.map +1 -1
- package/dist/workers/client.worker.d.ts +8 -2
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +215 -6
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +1 -1
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +7 -7
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +2 -2
- package/dist/workers/lint.worker.js +2 -2
- package/dist/workers/ngtsc-build.worker.js +30 -30
- package/dist/workers/ngtsc-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts +17 -17
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +46 -46
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-runtime.worker.d.ts +7 -7
- package/dist/workers/server-runtime.worker.d.ts.map +1 -1
- package/dist/workers/server-runtime.worker.js +17 -17
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/docs/config.md +340 -0
- package/docs/publish-configuration-types.md +87 -0
- package/docs/pwa-configuration-types.md +55 -0
- package/docs/vitest-plugin.md +47 -0
- package/package.json +9 -7
- package/src/angular/client-transform-stylesheet.ts +1 -1
- package/src/angular/vite-angular-plugin.ts +89 -39
- package/src/angular/vite-postcss-inline-plugin.ts +1 -1
- package/src/capacitor/capacitor.ts +185 -38
- package/src/commands/build.ts +3 -10
- package/src/commands/check.ts +3 -3
- package/src/commands/dev.ts +3 -9
- package/src/commands/device.ts +5 -5
- package/src/commands/publish.ts +30 -26
- package/src/commands/replace-deps.ts +3 -3
- package/src/commands/typecheck.ts +7 -13
- package/src/commands/watch.ts +9 -9
- package/src/electron/electron.ts +49 -4
- package/src/engines/BaseEngine.ts +4 -1
- package/src/engines/NgtscEngine.ts +7 -7
- package/src/engines/ServerEsbuildEngine.ts +7 -7
- package/src/engines/TscEngine.ts +7 -7
- package/src/engines/ViteEngine.ts +18 -13
- package/src/engines/index.ts +11 -5
- package/src/engines/types.ts +20 -20
- 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 +42 -38
- package/src/orchestrators/DevWatchOrchestrator.ts +36 -36
- package/src/sd-cli-entry.ts +15 -8
- package/src/sd-cli.ts +16 -16
- package/src/sd-config.types.ts +107 -107
- package/src/utils/angular-compiler.ts +5 -5
- package/src/utils/build-env.ts +1 -1
- package/src/utils/concurrency.ts +7 -7
- package/src/utils/copy-public.ts +17 -17
- package/src/utils/copy-src.ts +11 -11
- package/src/utils/engine-stop.ts +9 -10
- package/src/utils/esbuild-config.ts +29 -29
- package/src/utils/lint-with-program.ts +34 -34
- package/src/utils/ngtsc-build-core.ts +17 -17
- package/src/utils/output-path-rewriter.ts +18 -18
- package/src/utils/output-utils.ts +11 -11
- package/src/utils/package-utils.ts +57 -45
- package/src/utils/replace-deps.ts +92 -67
- package/src/utils/sd-config.ts +3 -3
- package/src/utils/tsc-build.ts +18 -18
- package/src/utils/tsconfig.ts +11 -9
- package/src/utils/typecheck-non-package.ts +7 -8
- package/src/utils/typecheck-serialization.ts +13 -15
- package/src/utils/vite-config.ts +108 -46
- package/src/utils/vite-scope-watch-plugin.ts +6 -1
- package/src/utils/worker-events.ts +16 -16
- package/src/utils/worker-utils.ts +12 -13
- package/src/vitest-plugin.ts +5 -8
- package/src/workers/client.worker.ts +246 -7
- package/src/workers/library-build.worker.ts +8 -8
- package/src/workers/lint.worker.ts +2 -2
- package/src/workers/ngtsc-build.worker.ts +31 -31
- package/src/workers/server-build.worker.ts +60 -60
- package/src/workers/server-runtime.worker.ts +22 -22
- package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +1 -0
- package/tests/angular/vite-angular-plugin-hmr.spec.ts +78 -0
- package/tests/angular/vite-angular-plugin.spec.ts +67 -0
- package/tests/capacitor/capacitor-build.spec.ts +93 -11
- package/tests/capacitor/capacitor-icon.spec.ts +7 -5
- package/tests/capacitor/capacitor-init.spec.ts +124 -10
- package/tests/capacitor/capacitor-run.spec.ts +14 -17
- package/tests/capacitor/capacitor-workspace.spec.ts +5 -3
- package/tests/commands/check.spec.ts +2 -2
- package/tests/commands/publish.spec.ts +2 -2
- package/tests/commands/typecheck.spec.ts +8 -0
- package/tests/electron/electron.spec.ts +12 -10
- package/tests/engines/base-engine.spec.ts +37 -0
- package/tests/engines/vite-engine.spec.ts +115 -3
- package/tests/utils/vite-config.spec.ts +162 -90
- package/tests/workers/client-worker.spec.ts +690 -0
- package/tests/workers/server-build-worker.spec.ts +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 빌드 결과 상태
|
|
3
3
|
*/
|
|
4
4
|
export interface BuildResult {
|
|
5
5
|
name: string;
|
|
@@ -11,17 +11,17 @@ export interface BuildResult {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* 빌드 결과를 수집·관리하는 클래스
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* 여러 Builder의 빌드 결과를 중앙에서 관리하며,
|
|
17
|
+
* 상태별 필터링 및 출력 기능을 제공한다.
|
|
18
18
|
*/
|
|
19
19
|
export class ResultCollector {
|
|
20
20
|
private readonly _results = new Map<string, BuildResult>();
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param result
|
|
23
|
+
* 결과를 추가한다
|
|
24
|
+
* @param result 빌드 결과
|
|
25
25
|
*/
|
|
26
26
|
add(result: BuildResult): void {
|
|
27
27
|
const key = `${result.name}:${result.type}`;
|
|
@@ -29,15 +29,15 @@ export class ResultCollector {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param key
|
|
32
|
+
* 키로 결과를 조회한다
|
|
33
|
+
* @param key 결과 키 (예: "core-common:build")
|
|
34
34
|
*/
|
|
35
35
|
get(key: string): BuildResult | undefined {
|
|
36
36
|
return this._results.get(key);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* 내부 Map을 반환한다 (외부 접근용)
|
|
41
41
|
*/
|
|
42
42
|
toMap(): Map<string, BuildResult> {
|
|
43
43
|
return this._results;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 프로세스 종료 시그널을 처리하는 클래스
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* SIGINT(Ctrl+C) 및 SIGTERM 시그널을 감지하고,
|
|
5
|
+
* 종료까지 대기하는 Promise를 제공한다.
|
|
6
6
|
*/
|
|
7
7
|
export class SignalHandler {
|
|
8
8
|
private _terminateResolver: (() => void) | null = null;
|
|
@@ -26,22 +26,22 @@ export class SignalHandler {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* 종료 시그널이 수신될 때까지 대기한다
|
|
30
30
|
*/
|
|
31
31
|
waitForTermination(): Promise<void> {
|
|
32
32
|
return this._terminatePromise;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 종료 여부를 확인한다
|
|
37
37
|
*/
|
|
38
38
|
isTerminated(): boolean {
|
|
39
39
|
return this._terminated;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
* (
|
|
43
|
+
* 프로그래밍 방식으로 종료를 요청한다
|
|
44
|
+
* (테스트나 외부에서 종료를 트리거할 때 사용)
|
|
45
45
|
*/
|
|
46
46
|
requestTermination(): void {
|
|
47
47
|
if (!this._terminated) {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Worker, type WorkerProxy, type WorkerModule } from "@simplysm/core-node";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Worker 생명주기를 관리하는 클래스
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Worker 생성, 조회, 종료를 중앙에서 관리하여
|
|
7
|
+
* 리소스 누수를 방지하고 일관된 Worker 관리를 제공한다.
|
|
8
8
|
*/
|
|
9
9
|
export class WorkerManager {
|
|
10
10
|
private readonly _workers = new Map<string, WorkerProxy<WorkerModule>>();
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param id Worker
|
|
15
|
-
* @param workerPath Worker
|
|
16
|
-
* @returns
|
|
13
|
+
* 새 Worker를 생성한다
|
|
14
|
+
* @param id Worker 식별자 (예: "core-common:build")
|
|
15
|
+
* @param workerPath Worker 파일 경로
|
|
16
|
+
* @returns 생성된 WorkerProxy
|
|
17
17
|
*/
|
|
18
18
|
create<TModule extends WorkerModule>(id: string, workerPath: string): WorkerProxy<TModule> {
|
|
19
19
|
const worker = Worker.create<TModule>(workerPath);
|
|
@@ -22,16 +22,16 @@ export class WorkerManager {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param id Worker
|
|
25
|
+
* ID로 Worker를 조회한다
|
|
26
|
+
* @param id Worker 식별자
|
|
27
27
|
*/
|
|
28
28
|
get<TModule extends WorkerModule>(id: string): WorkerProxy<TModule> | undefined {
|
|
29
29
|
return this._workers.get(id) as WorkerProxy<TModule> | undefined;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @param id Worker
|
|
33
|
+
* 특정 Worker를 종료하고 제거한다
|
|
34
|
+
* @param id Worker 식별자
|
|
35
35
|
*/
|
|
36
36
|
async terminate(id: string): Promise<void> {
|
|
37
37
|
const worker = this._workers.get(id);
|
|
@@ -42,7 +42,7 @@ export class WorkerManager {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 모든 Worker를 종료한다
|
|
46
46
|
*/
|
|
47
47
|
async terminateAll(): Promise<void> {
|
|
48
48
|
await Promise.all([...this._workers.values()].map((w) => w.terminate()));
|
|
@@ -50,14 +50,14 @@ export class WorkerManager {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* 관리 중인 Worker 수
|
|
54
54
|
*/
|
|
55
55
|
get size(): number {
|
|
56
56
|
return this._workers.size;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* 모든 Worker ID 목록
|
|
61
61
|
*/
|
|
62
62
|
get ids(): string[] {
|
|
63
63
|
return [...this._workers.keys()];
|
|
@@ -21,17 +21,17 @@ import { Electron } from "../electron/electron";
|
|
|
21
21
|
//#region Types
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* BuildOrchestrator 옵션
|
|
25
25
|
*/
|
|
26
26
|
export interface BuildOrchestratorOptions {
|
|
27
|
-
/**
|
|
27
|
+
/** 빌드 대상 패키지 필터 (빈 배열이면 전체) */
|
|
28
28
|
targets: string[];
|
|
29
|
-
/**
|
|
29
|
+
/** sd.config.ts에 전달할 추가 옵션 */
|
|
30
30
|
options: string[];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 빌드 결과
|
|
35
35
|
*/
|
|
36
36
|
interface BuildStepResult {
|
|
37
37
|
name: string;
|
|
@@ -44,14 +44,14 @@ interface BuildStepResult {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* 패키지 분류 결과
|
|
48
48
|
*/
|
|
49
49
|
interface ClassifiedPackages {
|
|
50
|
-
/** node/browser/neutral
|
|
50
|
+
/** node/browser/neutral 대상 (JS + DTS) */
|
|
51
51
|
buildPackages: Array<{ name: string; config: SdBuildPackageConfig }>;
|
|
52
|
-
/** server
|
|
52
|
+
/** server 대상 (JS 빌드, DTS 없음) */
|
|
53
53
|
serverPackages: Array<{ name: string; config: SdServerPackageConfig }>;
|
|
54
|
-
/** client
|
|
54
|
+
/** client 대상 (Vite 프로덕션 빌드, DTS 없음) */
|
|
55
55
|
clientPackages: Array<{ name: string; config: SdClientPackageConfig }>;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -60,11 +60,11 @@ interface ClassifiedPackages {
|
|
|
60
60
|
//#region Utilities
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
* - node/browser/neutral: buildPackages (JS +
|
|
65
|
-
* - server: serverPackages (JS
|
|
66
|
-
* - client: clientPackages (Vite
|
|
67
|
-
* - scripts:
|
|
63
|
+
* 패키지를 target별로 분류
|
|
64
|
+
* - node/browser/neutral: buildPackages (JS + DTS)
|
|
65
|
+
* - server: serverPackages (JS 빌드, DTS 없음)
|
|
66
|
+
* - client: clientPackages (Vite 프로덕션 빌드, DTS 없음)
|
|
67
|
+
* - scripts: 제외
|
|
68
68
|
*/
|
|
69
69
|
export function classifyPackages(
|
|
70
70
|
packages: Record<
|
|
@@ -97,7 +97,7 @@ export function classifyPackages(
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* dist 폴더 삭제
|
|
101
101
|
*/
|
|
102
102
|
async function cleanDistFolders(cwd: string, packageNames: string[]): Promise<void> {
|
|
103
103
|
await Promise.all(packageNames.map((name) => fsx.rm(pathx.posixResolve(cwd, "packages", name, "dist"))));
|
|
@@ -108,14 +108,14 @@ async function cleanDistFolders(cwd: string, packageNames: string[]): Promise<vo
|
|
|
108
108
|
//#region BuildOrchestrator
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* 프로덕션 빌드를 조율하는 Orchestrator
|
|
112
112
|
*
|
|
113
|
-
*
|
|
114
|
-
* -
|
|
115
|
-
* -
|
|
116
|
-
* -
|
|
117
|
-
* -
|
|
118
|
-
* -
|
|
113
|
+
* sd.config.ts 기반으로 패키지를 분류하고 빌드를 실행한다.
|
|
114
|
+
* - dist 폴더 정리 (클린 빌드)
|
|
115
|
+
* - lint + 빌드 동시 실행
|
|
116
|
+
* - 라이브러리 패키지: TscEngine/NgtscEngine으로 JS + DTS 빌드
|
|
117
|
+
* - 서버 패키지: BuildEngine으로 JS 빌드
|
|
118
|
+
* - 클라이언트 패키지: ViteEngine으로 Vite 프로덕션 빌드
|
|
119
119
|
*/
|
|
120
120
|
export class BuildOrchestrator {
|
|
121
121
|
private readonly _cwd: string;
|
|
@@ -183,12 +183,12 @@ export class BuildOrchestrator {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
*
|
|
187
|
-
* -
|
|
188
|
-
* -
|
|
189
|
-
* -
|
|
186
|
+
* 빌드 실행
|
|
187
|
+
* - 클린
|
|
188
|
+
* - lint + 빌드 (동시 실행)
|
|
189
|
+
* - 결과 출력
|
|
190
190
|
*
|
|
191
|
-
* @returns
|
|
191
|
+
* @returns 에러 발생 여부 (true: 에러 있음)
|
|
192
192
|
*/
|
|
193
193
|
async start(): Promise<boolean> {
|
|
194
194
|
if (this._allPackageNames.length === 0) {
|
|
@@ -198,15 +198,15 @@ export class BuildOrchestrator {
|
|
|
198
198
|
const classified = this._classified!;
|
|
199
199
|
const baseEnv = this._baseEnv!;
|
|
200
200
|
|
|
201
|
-
//
|
|
201
|
+
// 결과 수집
|
|
202
202
|
const results: BuildStepResult[] = [];
|
|
203
|
-
//
|
|
203
|
+
// 에러 추적 (콜백에서 변경 추적을 위해 객체로 래핑)
|
|
204
204
|
const state = { hasError: false };
|
|
205
205
|
|
|
206
|
-
//
|
|
206
|
+
// 파일 캐시 (진단 출력용)
|
|
207
207
|
const fileCache = new Map<string, string>();
|
|
208
208
|
|
|
209
|
-
// formatHost (
|
|
209
|
+
// formatHost (진단 출력용)
|
|
210
210
|
const formatHost: ts.FormatDiagnosticsHost = {
|
|
211
211
|
getCanonicalFileName: (f) => f,
|
|
212
212
|
getCurrentDirectory: () => this._cwd,
|
|
@@ -221,10 +221,10 @@ export class BuildOrchestrator {
|
|
|
221
221
|
// Phase 2: 빌드
|
|
222
222
|
const concurrency = getMaxConcurrency();
|
|
223
223
|
|
|
224
|
-
//
|
|
224
|
+
// 빌드 태스크 목록 생성
|
|
225
225
|
const buildTasks: Array<() => Promise<void>> = [];
|
|
226
226
|
|
|
227
|
-
//
|
|
227
|
+
// 라이브러리 패키지: BuildEngine으로 JS + DTS 빌드
|
|
228
228
|
for (const { name, config } of classified.buildPackages) {
|
|
229
229
|
const pkgDir = pathx.posixResolve(this._cwd, "packages", name);
|
|
230
230
|
|
|
@@ -276,7 +276,7 @@ export class BuildOrchestrator {
|
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
//
|
|
279
|
+
// 서버 패키지: BuildEngine으로 JS 빌드 + 타입체크
|
|
280
280
|
for (const { name, config } of classified.serverPackages) {
|
|
281
281
|
const pkgDir = pathx.posixResolve(this._cwd, "packages", name);
|
|
282
282
|
|
|
@@ -322,15 +322,19 @@ export class BuildOrchestrator {
|
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
//
|
|
325
|
+
// 클라이언트 패키지: ViteEngine으로 Vite 프로덕션 빌드 (DTS 없음)
|
|
326
326
|
for (const { name, config } of classified.clientPackages) {
|
|
327
327
|
const pkgDir = pathx.posixResolve(this._cwd, "packages", name);
|
|
328
328
|
|
|
329
329
|
buildTasks.push(async () => {
|
|
330
330
|
this._logger.debug(`[${name}] (client) 빌드 시작`);
|
|
331
|
+
const isNativeBuild = config.capacitor != null || config.electron != null;
|
|
332
|
+
const outDir = config.capacitor != null
|
|
333
|
+
? pathx.posixResolve(pkgDir, ".capacitor/www")
|
|
334
|
+
: undefined;
|
|
331
335
|
const engine = createBuildEngine(
|
|
332
336
|
{ name, dir: pkgDir, config: { ...config, env: { ...baseEnv, ...config.env } } },
|
|
333
|
-
{ cwd: this._cwd },
|
|
337
|
+
{ cwd: this._cwd, outDir, base: isNativeBuild ? "" : undefined },
|
|
334
338
|
);
|
|
335
339
|
|
|
336
340
|
try {
|
|
@@ -471,11 +475,11 @@ export class BuildOrchestrator {
|
|
|
471
475
|
}
|
|
472
476
|
|
|
473
477
|
/**
|
|
474
|
-
*
|
|
478
|
+
* Orchestrator 종료 (현재 정리할 리소스 없음)
|
|
475
479
|
*/
|
|
476
480
|
async shutdown(): Promise<void> {
|
|
477
|
-
//
|
|
478
|
-
//
|
|
481
|
+
// 프로덕션 빌드는 일회성 작업이므로 종료 시 정리할 리소스가 없음
|
|
482
|
+
// Worker는 각 빌드 태스크 내에서 terminate()로 정리됨
|
|
479
483
|
await Promise.resolve();
|
|
480
484
|
}
|
|
481
485
|
}
|
|
@@ -25,12 +25,12 @@ import type * as ServerRuntimeWorkerModule from "../workers/server-runtime.worke
|
|
|
25
25
|
import type { ServerReadyEventData, ErrorEventData } from "../utils/worker-events";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Orchestrator
|
|
28
|
+
* Orchestrator 모드
|
|
29
29
|
*/
|
|
30
30
|
export type OrchestratorMode = "watch" | "dev";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* DevWatchOrchestrator
|
|
33
|
+
* DevWatchOrchestrator 옵션
|
|
34
34
|
*/
|
|
35
35
|
export interface DevWatchOrchestratorOptions {
|
|
36
36
|
mode: OrchestratorMode;
|
|
@@ -39,26 +39,26 @@ export interface DevWatchOrchestratorOptions {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* watch/dev 모드 통합 Orchestrator
|
|
43
43
|
*
|
|
44
|
-
* - watch:
|
|
45
|
-
* - dev:
|
|
44
|
+
* - watch: 라이브러리(JS+DTS) + Scripts(watch hook) + copySrc + replaceDeps
|
|
45
|
+
* - dev: 서버(JS+런타임) + 클라이언트 준비(skip) + replaceDeps
|
|
46
46
|
*/
|
|
47
47
|
export class DevWatchOrchestrator {
|
|
48
48
|
private readonly _cwd: string;
|
|
49
49
|
private readonly _options: DevWatchOrchestratorOptions;
|
|
50
50
|
private readonly _logger;
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// 인프라
|
|
53
53
|
private _resultCollector!: ResultCollector;
|
|
54
54
|
private _signalHandler!: SignalHandler;
|
|
55
55
|
private _rebuildManager!: RebuildManager;
|
|
56
56
|
|
|
57
|
-
//
|
|
57
|
+
// 엔진
|
|
58
58
|
private readonly _libraryEngines: BuildEngine[] = [];
|
|
59
59
|
private readonly _serverEngines = new Map<string, BuildEngine>();
|
|
60
60
|
|
|
61
|
-
//
|
|
61
|
+
// 패키지 정보
|
|
62
62
|
private _libraryPackages: BuildPackageInfo[] = [];
|
|
63
63
|
private _serverPackages: Array<{ name: string; dir: string; config: SdServerPackageConfig }> = [];
|
|
64
64
|
private _watchHookPackages: Array<{ name: string; dir: string; config: SdScriptsPackageConfig | SdBuildPackageConfig }> = [];
|
|
@@ -66,13 +66,13 @@ export class DevWatchOrchestrator {
|
|
|
66
66
|
private readonly _clientEngines = new Map<string, BuildEngine>();
|
|
67
67
|
private _serverClientsMap = new Map<string, string[]>();
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// dev 모드: 런타임 워커
|
|
70
70
|
private _baseEnv: { VER: string; DEV: string } | undefined;
|
|
71
71
|
private readonly _serverRuntimeWorkers = new Map<string, WorkerProxy<typeof ServerRuntimeWorkerModule>>();
|
|
72
72
|
private _printServersTimer: ReturnType<typeof setTimeout> | undefined;
|
|
73
73
|
private _serverRestartTimer: ReturnType<typeof setTimeout> | undefined;
|
|
74
74
|
|
|
75
|
-
//
|
|
75
|
+
// 워처
|
|
76
76
|
private _copySrcWatchers: FsWatcher[] = [];
|
|
77
77
|
private readonly _watchHookWatchers: FsWatcher[] = [];
|
|
78
78
|
private readonly _watchHookChildren = new Map<string, ChildProcess>();
|
|
@@ -106,30 +106,30 @@ export class DevWatchOrchestrator {
|
|
|
106
106
|
throw err;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
//
|
|
109
|
+
// config 패키지에서 pathMap 빌드 (tests 패키지는 watch/dev에서 제외)
|
|
110
110
|
this._pathMap = buildPathMapFromConfig(sdConfig.packages);
|
|
111
111
|
|
|
112
|
-
//
|
|
112
|
+
// 대상 유효성 검사
|
|
113
113
|
validateTargets(this._options.targets, sdConfig.packages);
|
|
114
114
|
|
|
115
|
-
//
|
|
115
|
+
// 엔진 생성을 위해 replaceDeps 저장
|
|
116
116
|
this._replaceDeps = sdConfig.replaceDeps;
|
|
117
117
|
|
|
118
|
-
//
|
|
118
|
+
// replaceDeps 설정이 있으면 watch 시작
|
|
119
119
|
if (sdConfig.replaceDeps != null) {
|
|
120
120
|
this._replaceDepWatcher = await watchReplaceDeps(this._cwd, sdConfig.replaceDeps);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
//
|
|
123
|
+
// dev 모드용 VER, DEV 환경변수 준비
|
|
124
124
|
if (this._options.mode === "dev") {
|
|
125
125
|
const version = await getVersion(this._cwd);
|
|
126
126
|
this._baseEnv = { VER: version, DEV: "true" };
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
//
|
|
129
|
+
// 대상으로 필터링
|
|
130
130
|
const allPackages = filterPackagesByTargets(sdConfig.packages, this._options.targets);
|
|
131
131
|
|
|
132
|
-
//
|
|
132
|
+
// 모드에 따라 패키지 분류
|
|
133
133
|
if (this._options.mode === "watch") {
|
|
134
134
|
const classified = classifyWatchPackages(allPackages, this._cwd, this._pathMap);
|
|
135
135
|
this._libraryPackages = classified.libraryPackages;
|
|
@@ -141,7 +141,7 @@ export class DevWatchOrchestrator {
|
|
|
141
141
|
this._serverClientsMap = classified.serverClientsMap;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
//
|
|
144
|
+
// 처리할 패키지가 있는지 확인
|
|
145
145
|
const totalPackages = this._libraryPackages.length + this._serverPackages.length + this._watchHookPackages.length + this._clientPackages.length;
|
|
146
146
|
if (totalPackages === 0) {
|
|
147
147
|
const modeLabel = this._options.mode === "watch" ? "워치" : "개발";
|
|
@@ -151,12 +151,12 @@ export class DevWatchOrchestrator {
|
|
|
151
151
|
|
|
152
152
|
this._hasPackages = true;
|
|
153
153
|
|
|
154
|
-
//
|
|
154
|
+
// 인프라 초기화
|
|
155
155
|
this._signalHandler = new SignalHandler();
|
|
156
156
|
this._resultCollector = new ResultCollector();
|
|
157
157
|
this._rebuildManager = new RebuildManager(this._logger);
|
|
158
158
|
|
|
159
|
-
//
|
|
159
|
+
// 배치 완료 핸들러
|
|
160
160
|
if (this._options.mode === "watch") {
|
|
161
161
|
this._rebuildManager.on("batchComplete", (_completedKeys) => {
|
|
162
162
|
printErrors(this._resultCollector.toMap());
|
|
@@ -167,7 +167,7 @@ export class DevWatchOrchestrator {
|
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
//
|
|
170
|
+
// 라이브러리 패키지용 BuildEngine 생성 (watch 모드 전용)
|
|
171
171
|
for (const pkg of this._libraryPackages) {
|
|
172
172
|
const engine = createBuildEngine(pkg, {
|
|
173
173
|
cwd: this._cwd,
|
|
@@ -178,7 +178,7 @@ export class DevWatchOrchestrator {
|
|
|
178
178
|
this._libraryEngines.push(engine);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
//
|
|
181
|
+
// 서버 패키지용 BuildEngine 생성
|
|
182
182
|
for (const { name, dir, config } of this._serverPackages) {
|
|
183
183
|
const engineConfig = this._options.mode === "dev"
|
|
184
184
|
? { ...config, env: { ...this._baseEnv, ...config.env } }
|
|
@@ -196,7 +196,7 @@ export class DevWatchOrchestrator {
|
|
|
196
196
|
this._serverEngines.set(name, engine);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
//
|
|
199
|
+
// 클라이언트 패키지용 BuildEngine 생성 (dev 모드 전용)
|
|
200
200
|
const resolvedReplaceDeps = this._replaceDepWatcher?.entries.map((e) => ({
|
|
201
201
|
packageName: e.targetName,
|
|
202
202
|
sourcePath: e.resolvedSourcePath,
|
|
@@ -249,16 +249,16 @@ export class DevWatchOrchestrator {
|
|
|
249
249
|
|
|
250
250
|
const shutdownTasks: Array<Promise<void>> = [];
|
|
251
251
|
|
|
252
|
-
//
|
|
252
|
+
// 모든 엔진 중지
|
|
253
253
|
shutdownTasks.push(...this._libraryEngines.map((e) => e.stop()));
|
|
254
254
|
shutdownTasks.push(...[...this._serverEngines.values()].map((e) => e.stop()));
|
|
255
255
|
shutdownTasks.push(...[...this._clientEngines.values()].map((e) => e.stop()));
|
|
256
256
|
|
|
257
|
-
//
|
|
257
|
+
// 워처 종료 (watch 모드)
|
|
258
258
|
shutdownTasks.push(...this._copySrcWatchers.map((w) => w.close()));
|
|
259
259
|
shutdownTasks.push(...this._watchHookWatchers.map((w) => w.close()));
|
|
260
260
|
|
|
261
|
-
//
|
|
261
|
+
// hook 자식 프로세스 종료
|
|
262
262
|
for (const child of this._watchHookChildren.values()) {
|
|
263
263
|
if (child.exitCode == null) {
|
|
264
264
|
child.kill();
|
|
@@ -266,7 +266,7 @@ export class DevWatchOrchestrator {
|
|
|
266
266
|
}
|
|
267
267
|
this._watchHookChildren.clear();
|
|
268
268
|
|
|
269
|
-
//
|
|
269
|
+
// 런타임 워커 종료 (dev 모드)
|
|
270
270
|
shutdownTasks.push(...[...this._serverRuntimeWorkers.values()].map((w) => w.terminate()));
|
|
271
271
|
|
|
272
272
|
await Promise.all(shutdownTasks);
|
|
@@ -277,7 +277,7 @@ export class DevWatchOrchestrator {
|
|
|
277
277
|
process.stdout.write("✔ 종료 완료\n");
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
// ---
|
|
280
|
+
// --- watch 모드 ---
|
|
281
281
|
|
|
282
282
|
private async _startWatchMode(): Promise<void> {
|
|
283
283
|
this._logger.debug("watch 모드 시작");
|
|
@@ -346,7 +346,7 @@ export class DevWatchOrchestrator {
|
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
// ---
|
|
349
|
+
// --- dev 모드 ---
|
|
350
350
|
|
|
351
351
|
private async _startDevMode(): Promise<void> {
|
|
352
352
|
// Start client and server engines in parallel
|
|
@@ -380,7 +380,7 @@ export class DevWatchOrchestrator {
|
|
|
380
380
|
}
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
-
//
|
|
383
|
+
// 독립 클라이언트 결과를 ResultCollector에 등록
|
|
384
384
|
for (const { name } of this._clientPackages) {
|
|
385
385
|
const isServerConnected = [...this._serverClientsMap.values()].some(
|
|
386
386
|
(clients) => clients.includes(name),
|
|
@@ -399,7 +399,7 @@ export class DevWatchOrchestrator {
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
//
|
|
402
|
+
// 클라이언트 패키지의 Capacitor 초기화 (디바이스 실행은 'device' 명령어가 담당)
|
|
403
403
|
for (const { name, config } of this._clientPackages) {
|
|
404
404
|
const port = this._getClientPort(name);
|
|
405
405
|
if (port == null) continue;
|
|
@@ -474,13 +474,13 @@ export class DevWatchOrchestrator {
|
|
|
474
474
|
}, 300);
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
-
/**
|
|
477
|
+
/** 클라이언트 엔진에서 포트 가져오기 (ViteEngine.port에 대한 duck-typing) */
|
|
478
478
|
private _getClientPort(name: string): number | undefined {
|
|
479
479
|
const engine = this._clientEngines.get(name) as { port?: number } | undefined;
|
|
480
480
|
return engine?.port;
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
-
/**
|
|
483
|
+
/** 서버에 연결된 클라이언트들의 포트 수집 */
|
|
484
484
|
private _collectClientPorts(serverName: string): Record<string, number> {
|
|
485
485
|
const clientPorts: Record<string, number> = {};
|
|
486
486
|
const connectedClients = this._serverClientsMap.get(serverName) ?? [];
|
|
@@ -501,19 +501,19 @@ export class DevWatchOrchestrator {
|
|
|
501
501
|
): Promise<void> {
|
|
502
502
|
this._logger.debug(`[${serverName}] 서버 런타임 시작: ${mainJsPath}`);
|
|
503
503
|
|
|
504
|
-
//
|
|
504
|
+
// 기존 런타임 종료
|
|
505
505
|
const existingRuntime = this._serverRuntimeWorkers.get(serverName);
|
|
506
506
|
if (existingRuntime != null) {
|
|
507
507
|
this._logger.info(`[${serverName}] 서버 재시작 중...`);
|
|
508
508
|
await existingRuntime.terminate();
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
//
|
|
511
|
+
// 새 런타임 워커 생성 및 시작
|
|
512
512
|
const runtimeWorkerPath = import.meta.resolve("../workers/server-runtime.worker");
|
|
513
513
|
const runtimeWorker = Worker.create<typeof ServerRuntimeWorkerModule>(runtimeWorkerPath);
|
|
514
514
|
this._serverRuntimeWorkers.set(serverName, runtimeWorker);
|
|
515
515
|
|
|
516
|
-
//
|
|
516
|
+
// 런타임 이벤트 핸들러
|
|
517
517
|
runtimeWorker.on("serverReady", (readyData) => {
|
|
518
518
|
const readyEvent = readyData as ServerReadyEventData;
|
|
519
519
|
this._resultCollector.add({
|
package/src/sd-cli-entry.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// 사이드 이펙트: Map/Array prototype 확장 (getOrCreate 등)
|
|
5
5
|
import "@simplysm/core-common";
|
|
6
6
|
import yargs, { type Argv } from "yargs";
|
|
7
7
|
import { hideBin } from "yargs/helpers";
|
|
@@ -34,7 +34,7 @@ async function collectYargsHelp(argv: string[]): Promise<string> {
|
|
|
34
34
|
try {
|
|
35
35
|
await createCliParser(argv).exitProcess(false).parse();
|
|
36
36
|
} catch {
|
|
37
|
-
// yargs
|
|
37
|
+
// yargs가 help 출력 후 throw할 수 있음
|
|
38
38
|
} finally {
|
|
39
39
|
|
|
40
40
|
console.log = orig;
|
|
@@ -43,11 +43,11 @@ async function collectYargsHelp(argv: string[]): Promise<string> {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @internal
|
|
46
|
+
* CLI 파서 생성
|
|
47
|
+
* @internal 테스트용으로 export
|
|
48
48
|
*/
|
|
49
49
|
export function createCliParser(argv: string[]): Argv {
|
|
50
|
-
//
|
|
50
|
+
// 최상위 --help/-h (서브커맨드 없이): 모든 명령어의 종합 도움말 표시
|
|
51
51
|
const hasHelp = argv.includes("--help") || argv.includes("-h");
|
|
52
52
|
const hasCommand = COMMAND_NAMES.some((cmd) => argv.includes(cmd));
|
|
53
53
|
if (hasHelp && !hasCommand) {
|
|
@@ -313,11 +313,18 @@ export function createCliParser(argv: string[]): Argv {
|
|
|
313
313
|
},
|
|
314
314
|
)
|
|
315
315
|
.demandCommand(1, "Please specify a command.")
|
|
316
|
-
.strict()
|
|
316
|
+
.strict()
|
|
317
|
+
.fail((msg, err) => {
|
|
318
|
+
if (msg) {
|
|
319
|
+
consola.error(msg);
|
|
320
|
+
process.exit(1);
|
|
321
|
+
}
|
|
322
|
+
throw err;
|
|
323
|
+
});
|
|
317
324
|
}
|
|
318
325
|
|
|
319
|
-
//
|
|
320
|
-
//
|
|
326
|
+
// CLI로 직접 실행될 때만 파싱
|
|
327
|
+
// ESM에서 메인 모듈 판별: import.meta.url과 process.argv[1]을 정규화하여 비교
|
|
321
328
|
const cliEntryPath = process.argv.at(1);
|
|
322
329
|
if (
|
|
323
330
|
cliEntryPath != null &&
|