@simplysm/sd-cli 13.0.66 → 13.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builders/BaseBuilder.d.ts.map +1 -1
- package/dist/builders/BaseBuilder.js +2 -7
- package/dist/builders/BaseBuilder.js.map +1 -1
- package/dist/builders/DtsBuilder.d.ts.map +1 -1
- package/dist/builders/DtsBuilder.js +4 -3
- package/dist/builders/DtsBuilder.js.map +1 -1
- package/dist/builders/LibraryBuilder.d.ts.map +1 -1
- package/dist/builders/LibraryBuilder.js +2 -1
- package/dist/builders/LibraryBuilder.js.map +1 -1
- package/dist/capacitor/capacitor.js +2 -2
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/add-client.js +2 -2
- package/dist/commands/add-server.js +2 -2
- package/dist/commands/build.d.ts +2 -10
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +1 -5
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +26 -37
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +2 -9
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +1 -5
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.js +5 -5
- package/dist/commands/publish.js +16 -16
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/typecheck.d.ts +0 -1
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +5 -5
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +2 -8
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +1 -5
- package/dist/commands/watch.js.map +1 -1
- package/dist/electron/electron.js +2 -2
- package/dist/electron/electron.js.map +1 -1
- package/dist/infra/ResultCollector.d.ts +0 -21
- package/dist/infra/ResultCollector.d.ts.map +1 -1
- package/dist/infra/ResultCollector.js +0 -31
- package/dist/infra/ResultCollector.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts +0 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +10 -19
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +12 -0
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +178 -167
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.js +14 -14
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +8 -13
- package/dist/sd-cli.js.map +1 -1
- package/dist/utils/output-utils.d.ts +4 -7
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/output-utils.js +13 -5
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/utils/package-utils.d.ts +0 -11
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/replace-deps.d.ts.map +1 -1
- package/dist/utils/replace-deps.js +21 -48
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts +2 -6
- package/dist/utils/sd-config.d.ts.map +1 -1
- package/dist/utils/sd-config.js.map +1 -1
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +7 -1
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/worker-events.d.ts +5 -5
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-events.js +14 -17
- package/dist/utils/worker-events.js.map +1 -1
- package/dist/utils/worker-utils.d.ts +7 -0
- package/dist/utils/worker-utils.d.ts.map +1 -1
- package/dist/utils/worker-utils.js +10 -0
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +11 -9
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/dts.worker.d.ts +4 -4
- package/dist/workers/dts.worker.d.ts.map +1 -1
- package/dist/workers/dts.worker.js +10 -11
- package/dist/workers/dts.worker.js.map +1 -1
- package/dist/workers/library.worker.d.ts.map +1 -1
- package/dist/workers/library.worker.js +7 -9
- package/dist/workers/library.worker.js.map +1 -1
- package/dist/workers/server-runtime.worker.d.ts.map +1 -1
- package/dist/workers/server-runtime.worker.js +4 -3
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/dist/workers/server.worker.d.ts.map +1 -1
- package/dist/workers/server.worker.js +10 -13
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +5 -4
- package/src/builders/BaseBuilder.ts +2 -7
- package/src/builders/DtsBuilder.ts +4 -3
- package/src/builders/LibraryBuilder.ts +2 -1
- package/src/capacitor/capacitor.ts +2 -2
- package/src/commands/add-client.ts +2 -2
- package/src/commands/add-server.ts +2 -2
- package/src/commands/build.ts +2 -17
- package/src/commands/check.ts +31 -44
- package/src/commands/dev.ts +2 -16
- package/src/commands/init.ts +5 -5
- package/src/commands/publish.ts +16 -16
- package/src/commands/typecheck.ts +5 -5
- package/src/commands/watch.ts +2 -15
- package/src/electron/electron.ts +2 -2
- package/src/infra/ResultCollector.ts +0 -36
- package/src/orchestrators/BuildOrchestrator.ts +12 -21
- package/src/orchestrators/DevOrchestrator.ts +221 -201
- package/src/sd-cli-entry.ts +14 -14
- package/src/sd-cli.ts +9 -14
- package/src/utils/output-utils.ts +15 -11
- package/src/utils/package-utils.ts +0 -12
- package/src/utils/replace-deps.ts +61 -88
- package/src/utils/sd-config.ts +2 -6
- package/src/utils/vite-config.ts +9 -1
- package/src/utils/worker-events.ts +22 -25
- package/src/utils/worker-utils.ts +16 -0
- package/src/workers/client.worker.ts +12 -11
- package/src/workers/dts.worker.ts +13 -15
- package/src/workers/library.worker.ts +7 -10
- package/src/workers/server-runtime.worker.ts +4 -3
- package/src/workers/server.worker.ts +10 -14
- 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/dist/utils/spawn.d.ts +0 -26
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js +0 -50
- package/dist/utils/spawn.js.map +0 -6
- package/src/utils/spawn.ts +0 -80
package/src/commands/check.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } from "execa";
|
|
2
2
|
import { Worker, type WorkerProxy } from "@simplysm/core-node";
|
|
3
|
+
import { errorMessage } from "@simplysm/core-common";
|
|
3
4
|
import { executeTypecheck, type TypecheckResult } from "./typecheck";
|
|
4
5
|
import type { LintResult } from "./lint";
|
|
5
6
|
import type * as LintWorkerModule from "../workers/lint.worker";
|
|
@@ -26,49 +27,35 @@ interface CheckResult {
|
|
|
26
27
|
|
|
27
28
|
//#region Utilities
|
|
28
29
|
|
|
29
|
-
function spawnVitest(targets: string[]): Promise<CheckResult> {
|
|
30
|
-
|
|
30
|
+
async function spawnVitest(targets: string[]): Promise<CheckResult> {
|
|
31
|
+
try {
|
|
31
32
|
const args = ["vitest", ...targets, "--run"];
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
formattedOutput: code === 0 ? "" : output,
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
child.on("error", (err) => {
|
|
63
|
-
resolve({
|
|
64
|
-
name: "TEST",
|
|
65
|
-
success: false,
|
|
66
|
-
errorCount: 1,
|
|
67
|
-
warningCount: 0,
|
|
68
|
-
formattedOutput: err.message,
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
33
|
+
const result = await execa("pnpm", args, { cwd: process.cwd(), reject: false });
|
|
34
|
+
const output = result.stdout + result.stderr;
|
|
35
|
+
const code = result.exitCode;
|
|
36
|
+
|
|
37
|
+
const failMatch =
|
|
38
|
+
output.match(/(\d+)\s+tests?\s+failed/i) ??
|
|
39
|
+
output.match(/Tests\s+(\d+)\s+failed/i) ??
|
|
40
|
+
output.match(/(\d+)\s+fail/i);
|
|
41
|
+
const failCount = failMatch ? Number(failMatch[1]) : 0;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
name: "TEST",
|
|
45
|
+
success: code === 0,
|
|
46
|
+
errorCount: failCount,
|
|
47
|
+
warningCount: 0,
|
|
48
|
+
formattedOutput: code === 0 ? "" : output,
|
|
49
|
+
};
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return {
|
|
52
|
+
name: "TEST",
|
|
53
|
+
success: false,
|
|
54
|
+
errorCount: 1,
|
|
55
|
+
warningCount: 0,
|
|
56
|
+
formattedOutput: errorMessage(err),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
72
59
|
}
|
|
73
60
|
|
|
74
61
|
function formatSection(result: CheckResult): string {
|
|
@@ -154,7 +141,7 @@ export async function runCheck(options: CheckOptions): Promise<void> {
|
|
|
154
141
|
success: false,
|
|
155
142
|
errorCount: 1,
|
|
156
143
|
warningCount: 0,
|
|
157
|
-
formattedOutput:
|
|
144
|
+
formattedOutput: errorMessage(r.reason),
|
|
158
145
|
};
|
|
159
146
|
});
|
|
160
147
|
|
package/src/commands/dev.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { DevOrchestrator, type DevOrchestratorOptions } from "../orchestrators/DevOrchestrator";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Dev 명령 옵션 (하위 호환성)
|
|
5
|
-
*/
|
|
6
|
-
export interface DevOptions {
|
|
7
|
-
/** dev할 패키지 필터 (빈 배열이면 모든 패키지) */
|
|
8
|
-
targets: string[];
|
|
9
|
-
options: string[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
3
|
/**
|
|
13
4
|
* Client 및 Server 패키지를 개발 모드로 실행한다.
|
|
14
5
|
*
|
|
@@ -22,13 +13,8 @@ export interface DevOptions {
|
|
|
22
13
|
* @param options - dev 실행 옵션
|
|
23
14
|
* @returns 종료 시그널 수신 시 resolve
|
|
24
15
|
*/
|
|
25
|
-
export async function runDev(options:
|
|
26
|
-
const
|
|
27
|
-
targets: options.targets,
|
|
28
|
-
options: options.options,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const orchestrator = new DevOrchestrator(orchestratorOptions);
|
|
16
|
+
export async function runDev(options: DevOrchestratorOptions): Promise<void> {
|
|
17
|
+
const orchestrator = new DevOrchestrator(options);
|
|
32
18
|
|
|
33
19
|
try {
|
|
34
20
|
await orchestrator.initialize();
|
package/src/commands/init.ts
CHANGED
|
@@ -2,7 +2,7 @@ import path from "path";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { consola } from "consola";
|
|
4
4
|
import { renderTemplateDir } from "../utils/template";
|
|
5
|
-
import {
|
|
5
|
+
import { execa } from "execa";
|
|
6
6
|
import { findPackageRoot } from "../utils/package-utils";
|
|
7
7
|
|
|
8
8
|
//#region Types
|
|
@@ -69,14 +69,14 @@ export async function runInit(_options: InitOptions): Promise<void> {
|
|
|
69
69
|
|
|
70
70
|
// 4. pnpm install
|
|
71
71
|
logger.info("pnpm install 실행 중...");
|
|
72
|
-
await
|
|
72
|
+
await execa("pnpm", ["install"], { cwd });
|
|
73
73
|
logger.success("pnpm install 완료");
|
|
74
74
|
|
|
75
75
|
// 5. git 초기화
|
|
76
76
|
logger.info("git 저장소 초기화 중...");
|
|
77
|
-
await
|
|
78
|
-
await
|
|
79
|
-
await
|
|
77
|
+
await execa("git", ["init"], { cwd });
|
|
78
|
+
await execa("git", ["add", "."], { cwd });
|
|
79
|
+
await execa("git", ["commit", "-m", "init"], { cwd });
|
|
80
80
|
logger.success("git 저장소 초기화 완료");
|
|
81
81
|
|
|
82
82
|
// 6. 완료 메시지
|
package/src/commands/publish.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { env, jsonStringify } from "@simplysm/core-common";
|
|
|
7
7
|
import "@simplysm/core-common";
|
|
8
8
|
import type { SdConfig, SdPublishConfig } from "../sd-config.types";
|
|
9
9
|
import { loadSdConfig } from "../utils/sd-config";
|
|
10
|
-
import {
|
|
10
|
+
import { execa } from "execa";
|
|
11
11
|
import { runBuild } from "./build";
|
|
12
12
|
import { parseWorkspaceGlobs } from "../utils/replace-deps";
|
|
13
13
|
import os from "os";
|
|
@@ -352,7 +352,7 @@ async function publishPackage(
|
|
|
352
352
|
logger.debug(`[${pkgName}] pnpm ${args.join(" ")}`);
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
await
|
|
355
|
+
await execa("pnpm", args, { cwd: pkgPath });
|
|
356
356
|
} else if (publishConfig.type === "local-directory") {
|
|
357
357
|
// 로컬 디렉토리 복사
|
|
358
358
|
const targetPath = replaceEnvVariables(publishConfig.path, version, projectPath);
|
|
@@ -558,7 +558,7 @@ export async function runPublish(options: PublishOptions): Promise<void> {
|
|
|
558
558
|
if (publishPackages.some((p) => p.config === "npm")) {
|
|
559
559
|
logger.debug("npm 인증 확인...");
|
|
560
560
|
try {
|
|
561
|
-
const whoami = await
|
|
561
|
+
const { stdout: whoami } = await execa("npm", ["whoami"]);
|
|
562
562
|
if (whoami.trim() === "") {
|
|
563
563
|
throw new Error("npm 로그인 정보가 없습니다.");
|
|
564
564
|
}
|
|
@@ -588,13 +588,13 @@ export async function runPublish(options: PublishOptions): Promise<void> {
|
|
|
588
588
|
if (!noBuild && hasGit) {
|
|
589
589
|
logger.debug("Git 커밋 여부 확인...");
|
|
590
590
|
try {
|
|
591
|
-
const diff = await
|
|
592
|
-
const stagedDiff = await
|
|
591
|
+
const { stdout: diff } = await execa("git", ["diff", "--name-only"]);
|
|
592
|
+
const { stdout: stagedDiff } = await execa("git", ["diff", "--cached", "--name-only"]);
|
|
593
593
|
|
|
594
594
|
if (diff.trim() !== "" || stagedDiff.trim() !== "") {
|
|
595
595
|
logger.info("커밋되지 않은 변경사항 감지. claude 자동 커밋 시도...");
|
|
596
596
|
try {
|
|
597
|
-
await
|
|
597
|
+
await execa("claude", [
|
|
598
598
|
"-p",
|
|
599
599
|
"/sd-commit all",
|
|
600
600
|
"--dangerously-skip-permissions",
|
|
@@ -609,8 +609,8 @@ export async function runPublish(options: PublishOptions): Promise<void> {
|
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
// 커밋 후 재확인
|
|
612
|
-
const recheckDiff = await
|
|
613
|
-
const recheckStaged = await
|
|
612
|
+
const { stdout: recheckDiff } = await execa("git", ["diff", "--name-only"]);
|
|
613
|
+
const { stdout: recheckStaged } = await execa("git", ["diff", "--cached", "--name-only"]);
|
|
614
614
|
if (recheckDiff.trim() !== "" || recheckStaged.trim() !== "") {
|
|
615
615
|
throw new Error(
|
|
616
616
|
"자동 커밋 후에도 미커밋 변경사항이 남아있습니다.\n" + recheckDiff + recheckStaged,
|
|
@@ -687,18 +687,18 @@ export async function runPublish(options: PublishOptions): Promise<void> {
|
|
|
687
687
|
logger.info(`[DRY-RUN] git commit -m "v${version}"`);
|
|
688
688
|
logger.info(`[DRY-RUN] git tag -a v${version} -m "v${version}"`);
|
|
689
689
|
logger.info("[DRY-RUN] git push --dry-run");
|
|
690
|
-
await
|
|
690
|
+
await execa("git", ["push", "--dry-run"]);
|
|
691
691
|
logger.info("[DRY-RUN] git push --tags --dry-run");
|
|
692
|
-
await
|
|
692
|
+
await execa("git", ["push", "--tags", "--dry-run"]);
|
|
693
693
|
logger.info("[DRY-RUN] Git 작업 시뮬레이션 완료");
|
|
694
694
|
} else {
|
|
695
695
|
logger.debug("Git 커밋/태그/푸시...");
|
|
696
696
|
try {
|
|
697
|
-
await
|
|
698
|
-
await
|
|
699
|
-
await
|
|
700
|
-
await
|
|
701
|
-
await
|
|
697
|
+
await execa("git", ["add", ..._changedFiles]);
|
|
698
|
+
await execa("git", ["commit", "-m", `v${version}`]);
|
|
699
|
+
await execa("git", ["tag", "-a", `v${version}`, "-m", `v${version}`]);
|
|
700
|
+
await execa("git", ["push"]);
|
|
701
|
+
await execa("git", ["push", "--tags"]);
|
|
702
702
|
logger.debug("Git 작업 완료");
|
|
703
703
|
} catch (err) {
|
|
704
704
|
logger.error(
|
|
@@ -812,7 +812,7 @@ export async function runPublish(options: PublishOptions): Promise<void> {
|
|
|
812
812
|
logger.info(`[DRY-RUN] 실행 예정: ${cmd} ${args.join(" ")}`);
|
|
813
813
|
} else {
|
|
814
814
|
logger.debug(`실행: ${cmd} ${args.join(" ")}`);
|
|
815
|
-
await
|
|
815
|
+
await execa(cmd, args, { cwd });
|
|
816
816
|
}
|
|
817
817
|
} catch (err) {
|
|
818
818
|
// postPublish 실패 시 경고만 출력 (배포 롤백 불가)
|
|
@@ -2,7 +2,7 @@ import ts from "typescript";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import os from "os";
|
|
4
4
|
import { pathPosix, pathFilterByTargets, Worker, type WorkerProxy } from "@simplysm/core-node";
|
|
5
|
-
import "@simplysm/core-common";
|
|
5
|
+
import { errorMessage } from "@simplysm/core-common";
|
|
6
6
|
import { consola } from "consola";
|
|
7
7
|
import type { SdConfig } from "../sd-config.types";
|
|
8
8
|
import { parseRootTsconfig, type TypecheckEnv } from "../utils/tsconfig";
|
|
@@ -202,7 +202,7 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
202
202
|
try {
|
|
203
203
|
parsedConfig = parseRootTsconfig(cwd);
|
|
204
204
|
} catch (err) {
|
|
205
|
-
logger.error(
|
|
205
|
+
logger.error(errorMessage(err));
|
|
206
206
|
return { success: false, errorCount: 1, warningCount: 0, formattedOutput: "" };
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -274,7 +274,7 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
274
274
|
|
|
275
275
|
logger.debug(`[${task.displayName}] 타입체크 시작`);
|
|
276
276
|
try {
|
|
277
|
-
const result = await worker.
|
|
277
|
+
const result = await worker.build(task.buildInfo);
|
|
278
278
|
allResults.push({ displayName: task.displayName, result });
|
|
279
279
|
if (result.success) {
|
|
280
280
|
logger.debug(`[${task.displayName}] 타입체크 완료`);
|
|
@@ -283,13 +283,13 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
283
283
|
}
|
|
284
284
|
} catch (err) {
|
|
285
285
|
logger.error(`Worker 오류: ${task.displayName}`, {
|
|
286
|
-
error:
|
|
286
|
+
error: errorMessage(err),
|
|
287
287
|
});
|
|
288
288
|
allResults.push({
|
|
289
289
|
displayName: task.displayName,
|
|
290
290
|
result: {
|
|
291
291
|
success: false,
|
|
292
|
-
errors: [
|
|
292
|
+
errors: [errorMessage(err)],
|
|
293
293
|
diagnostics: [],
|
|
294
294
|
errorCount: 1,
|
|
295
295
|
warningCount: 0,
|
package/src/commands/watch.ts
CHANGED
|
@@ -4,14 +4,6 @@ import {
|
|
|
4
4
|
type WatchOrchestratorOptions,
|
|
5
5
|
} from "../orchestrators/WatchOrchestrator";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Watch 명령 옵션 (하위 호환성)
|
|
9
|
-
*/
|
|
10
|
-
export interface WatchOptions {
|
|
11
|
-
targets: string[];
|
|
12
|
-
options: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
/**
|
|
16
8
|
* Library 패키지를 watch 모드로 빌드한다.
|
|
17
9
|
*
|
|
@@ -23,13 +15,8 @@ export interface WatchOptions {
|
|
|
23
15
|
* @param options - watch 실행 옵션
|
|
24
16
|
* @returns 종료 시그널 수신 시 resolve
|
|
25
17
|
*/
|
|
26
|
-
export async function runWatch(options:
|
|
27
|
-
const
|
|
28
|
-
targets: options.targets,
|
|
29
|
-
options: options.options,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const orchestrator = new WatchOrchestrator(orchestratorOptions);
|
|
18
|
+
export async function runWatch(options: WatchOrchestratorOptions): Promise<void> {
|
|
19
|
+
const orchestrator = new WatchOrchestrator(options);
|
|
33
20
|
|
|
34
21
|
try {
|
|
35
22
|
await orchestrator.initialize();
|
package/src/electron/electron.ts
CHANGED
|
@@ -5,7 +5,7 @@ import module from "module";
|
|
|
5
5
|
import { fsExists, fsMkdir, fsCopy, fsReaddir, fsReadJson, fsWriteJson } from "@simplysm/core-node";
|
|
6
6
|
import { consola } from "consola";
|
|
7
7
|
import type { SdElectronConfig } from "../sd-config.types";
|
|
8
|
-
import {
|
|
8
|
+
import { execa } from "execa";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* package.json 타입
|
|
@@ -68,7 +68,7 @@ export class Electron {
|
|
|
68
68
|
env?: Record<string, string>,
|
|
69
69
|
): Promise<string> {
|
|
70
70
|
Electron._logger.debug(`실행 명령: ${cmd} ${args.join(" ")}`);
|
|
71
|
-
const result = await
|
|
71
|
+
const { stdout: result } = await execa(cmd, args, { cwd, env: { ...process.env, ...env } });
|
|
72
72
|
Electron._logger.debug(`실행 결과: ${result}`);
|
|
73
73
|
return result;
|
|
74
74
|
}
|
|
@@ -36,42 +36,6 @@ export class ResultCollector {
|
|
|
36
36
|
return this._results.get(key);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
* 모든 결과 조회
|
|
41
|
-
*/
|
|
42
|
-
getAll(): BuildResult[] {
|
|
43
|
-
return [...this._results.values()];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 에러 상태인 결과만 조회
|
|
48
|
-
*/
|
|
49
|
-
getErrors(): BuildResult[] {
|
|
50
|
-
return this.getAll().filter((r) => r.status === "error");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 서버 상태인 결과만 조회
|
|
55
|
-
*/
|
|
56
|
-
getServers(): BuildResult[] {
|
|
57
|
-
return this.getAll().filter((r) => r.type === "server" && r.status === "running");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 특정 타입의 결과만 조회
|
|
62
|
-
* @param type 결과 타입
|
|
63
|
-
*/
|
|
64
|
-
getByType(type: BuildResult["type"]): BuildResult[] {
|
|
65
|
-
return this.getAll().filter((r) => r.type === type);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 결과 초기화
|
|
70
|
-
*/
|
|
71
|
-
clear(): void {
|
|
72
|
-
this._results.clear();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
39
|
/**
|
|
76
40
|
* 내부 Map 반환 (하위 호환성)
|
|
77
41
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { Worker, type WorkerProxy, fsRm } from "@simplysm/core-node";
|
|
4
|
-
import "@simplysm/core-common";
|
|
4
|
+
import { errorMessage } from "@simplysm/core-common";
|
|
5
5
|
import { consola } from "consola";
|
|
6
6
|
import type {
|
|
7
7
|
SdConfig,
|
|
@@ -22,6 +22,7 @@ import type * as DtsWorkerModule from "../workers/dts.worker";
|
|
|
22
22
|
import { Capacitor } from "../capacitor/capacitor";
|
|
23
23
|
import { Electron } from "../electron/electron";
|
|
24
24
|
import { copySrcFiles } from "../utils/copy-src";
|
|
25
|
+
import { formatBuildMessages } from "../utils/output-utils";
|
|
25
26
|
|
|
26
27
|
//#region Types
|
|
27
28
|
|
|
@@ -38,7 +39,7 @@ export interface BuildOrchestratorOptions {
|
|
|
38
39
|
/**
|
|
39
40
|
* 빌드 결과
|
|
40
41
|
*/
|
|
41
|
-
interface
|
|
42
|
+
interface BuildStepResult {
|
|
42
43
|
name: string;
|
|
43
44
|
target: string;
|
|
44
45
|
type: "js" | "dts" | "vite" | "capacitor" | "electron";
|
|
@@ -206,7 +207,7 @@ export class BuildOrchestrator {
|
|
|
206
207
|
const baseEnv = this._baseEnv!;
|
|
207
208
|
|
|
208
209
|
// 결과 수집
|
|
209
|
-
const results:
|
|
210
|
+
const results: BuildStepResult[] = [];
|
|
210
211
|
// 에러 추적 (객체로 래핑하여 콜백 내 수정 추적 가능하게 함)
|
|
211
212
|
const state = { hasError: false };
|
|
212
213
|
|
|
@@ -263,7 +264,7 @@ export class BuildOrchestrator {
|
|
|
263
264
|
// JS 빌드
|
|
264
265
|
libraryWorker.build({ name, config, cwd: this._cwd, pkgDir }),
|
|
265
266
|
// DTS 생성
|
|
266
|
-
dtsWorker.
|
|
267
|
+
dtsWorker.build({ name, cwd: this._cwd, pkgDir, env, emit: true }),
|
|
267
268
|
]);
|
|
268
269
|
|
|
269
270
|
// JS 빌드 결과 처리
|
|
@@ -321,7 +322,7 @@ export class BuildOrchestrator {
|
|
|
321
322
|
// Vite production 빌드
|
|
322
323
|
clientWorker.build({ name, config: clientConfig, cwd: this._cwd, pkgDir }),
|
|
323
324
|
// typecheck (dts 없이)
|
|
324
|
-
dtsWorker.
|
|
325
|
+
dtsWorker.build({
|
|
325
326
|
name,
|
|
326
327
|
cwd: this._cwd,
|
|
327
328
|
pkgDir,
|
|
@@ -374,7 +375,7 @@ export class BuildOrchestrator {
|
|
|
374
375
|
target: "client",
|
|
375
376
|
type: "capacitor",
|
|
376
377
|
success: false,
|
|
377
|
-
errors: [
|
|
378
|
+
errors: [errorMessage(err)],
|
|
378
379
|
});
|
|
379
380
|
state.hasError = true;
|
|
380
381
|
}
|
|
@@ -399,7 +400,7 @@ export class BuildOrchestrator {
|
|
|
399
400
|
target: "client",
|
|
400
401
|
type: "electron",
|
|
401
402
|
success: false,
|
|
402
|
-
errors: [
|
|
403
|
+
errors: [errorMessage(err)],
|
|
403
404
|
});
|
|
404
405
|
state.hasError = true;
|
|
405
406
|
}
|
|
@@ -465,26 +466,16 @@ export class BuildOrchestrator {
|
|
|
465
466
|
|
|
466
467
|
// warnings 출력
|
|
467
468
|
if (result.warnings != null) {
|
|
468
|
-
|
|
469
|
-
for (const warning of result.warnings) {
|
|
470
|
-
for (const line of warning.split("\n")) {
|
|
471
|
-
warnLines.push(` → ${line}`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
this._logger.warn(warnLines.join("\n"));
|
|
469
|
+
this._logger.warn(formatBuildMessages(result.name, typeLabel, result.warnings));
|
|
475
470
|
}
|
|
476
471
|
|
|
477
472
|
// errors 출력
|
|
478
473
|
if (!result.success) {
|
|
479
|
-
const errorLines: string[] = [`${result.name} (${typeLabel})`];
|
|
480
474
|
if (result.errors != null) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
}
|
|
475
|
+
this._logger.error(formatBuildMessages(result.name, typeLabel, result.errors));
|
|
476
|
+
} else {
|
|
477
|
+
this._logger.error(`${result.name} (${typeLabel})`);
|
|
486
478
|
}
|
|
487
|
-
this._logger.error(errorLines.join("\n"));
|
|
488
479
|
}
|
|
489
480
|
if (result.diagnostics != null) {
|
|
490
481
|
allDiagnostics.push(...result.diagnostics);
|