@simplysm/sd-cli 13.0.28 → 13.0.30
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 +30 -28
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +55 -10
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/add-client.d.ts.map +1 -1
- package/dist/commands/add-client.js +5 -1
- package/dist/commands/add-client.js.map +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +3 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/device.d.ts.map +1 -1
- package/dist/commands/device.js +9 -3
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +17 -4
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +16 -4
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +3 -1
- package/dist/commands/watch.js.map +1 -1
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +8 -2
- package/dist/electron/electron.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +24 -7
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.js +4 -1
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +6 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/utils/config-editor.d.ts.map +1 -1
- package/dist/utils/config-editor.js +3 -1
- package/dist/utils/config-editor.js.map +1 -1
- package/dist/utils/copy-public.d.ts.map +1 -1
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +6 -2
- package/dist/utils/esbuild-config.js.map +1 -1
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/utils/package-utils.d.ts +4 -3
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +10 -2
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/rebuild-manager.d.ts.map +1 -1
- package/dist/utils/rebuild-manager.js.map +1 -1
- package/dist/utils/replace-deps.d.ts.map +1 -1
- package/dist/utils/replace-deps.js +3 -1
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts.map +1 -1
- package/dist/utils/sd-config.js.map +1 -1
- package/dist/utils/spawn.d.ts.map +1 -1
- package/dist/utils/spawn.js +4 -2
- package/dist/utils/spawn.js.map +1 -1
- package/dist/utils/template.d.ts.map +1 -1
- package/dist/utils/template.js +6 -1
- package/dist/utils/template.js.map +1 -1
- package/dist/utils/tsconfig.d.ts.map +1 -1
- package/dist/utils/tsconfig.js +3 -1
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts.map +1 -1
- package/dist/utils/typecheck-serialization.js +2 -1
- package/dist/utils/typecheck-serialization.js.map +1 -1
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +24 -17
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-events.js.map +1 -1
- package/dist/utils/worker-utils.d.ts.map +1 -1
- 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 +10 -2
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/dts.worker.d.ts.map +1 -1
- package/dist/workers/dts.worker.js +14 -4
- 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 +17 -3
- 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 +3 -1
- 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 +20 -4
- package/dist/workers/server.worker.js.map +1 -1
- package/package.json +5 -5
- package/src/capacitor/capacitor.ts +78 -18
- package/src/commands/add-client.ts +5 -1
- package/src/commands/build.ts +4 -1
- package/src/commands/device.ts +9 -3
- package/src/commands/init.ts +3 -1
- package/src/commands/lint.ts +22 -5
- package/src/commands/publish.ts +22 -6
- package/src/commands/typecheck.ts +5 -1
- package/src/commands/watch.ts +4 -1
- package/src/electron/electron.ts +14 -3
- package/src/orchestrators/BuildOrchestrator.ts +15 -4
- package/src/orchestrators/DevOrchestrator.ts +42 -12
- package/src/orchestrators/WatchOrchestrator.ts +5 -1
- package/src/sd-cli-entry.ts +4 -1
- package/src/sd-cli.ts +6 -1
- package/src/utils/config-editor.ts +15 -5
- package/src/utils/copy-public.ts +4 -1
- package/src/utils/esbuild-config.ts +18 -4
- package/src/utils/output-utils.ts +4 -1
- package/src/utils/package-utils.ts +16 -4
- package/src/utils/rebuild-manager.ts +4 -1
- package/src/utils/replace-deps.ts +7 -2
- package/src/utils/sd-config.ts +5 -1
- package/src/utils/spawn.ts +3 -1
- package/src/utils/template.ts +6 -1
- package/src/utils/tsconfig.ts +7 -2
- package/src/utils/typecheck-serialization.ts +6 -2
- package/src/utils/vite-config.ts +36 -20
- package/src/utils/worker-events.ts +4 -1
- package/src/utils/worker-utils.ts +4 -1
- package/src/workers/client.worker.ts +12 -3
- package/src/workers/dts.worker.ts +24 -7
- package/src/workers/library.worker.ts +17 -3
- package/src/workers/server-runtime.worker.ts +3 -1
- package/src/workers/server.worker.ts +23 -5
- 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/src/utils/tsconfig.ts
CHANGED
|
@@ -18,7 +18,9 @@ export async function getTypesFromPackageJson(packageDir: string): Promise<strin
|
|
|
18
18
|
return [];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const packageJson = await fsReadJson<{ devDependencies?: Record<string, string> }>(
|
|
21
|
+
const packageJson = await fsReadJson<{ devDependencies?: Record<string, string> }>(
|
|
22
|
+
packageJsonPath,
|
|
23
|
+
);
|
|
22
24
|
const devDeps = packageJson.devDependencies ?? {};
|
|
23
25
|
|
|
24
26
|
return Object.keys(devDeps)
|
|
@@ -104,7 +106,10 @@ export function parseRootTsconfig(cwd: string): ts.ParsedCommandLine {
|
|
|
104
106
|
/**
|
|
105
107
|
* 패키지의 소스 파일 목록 가져오기 (tsconfig 기반)
|
|
106
108
|
*/
|
|
107
|
-
export function getPackageSourceFiles(
|
|
109
|
+
export function getPackageSourceFiles(
|
|
110
|
+
pkgDir: string,
|
|
111
|
+
parsedConfig: ts.ParsedCommandLine,
|
|
112
|
+
): string[] {
|
|
108
113
|
// 경로 구분자까지 포함하여 비교 (packages/core와 packages/core-common 구분)
|
|
109
114
|
const pkgSrcPrefix = path.join(pkgDir, "src") + path.sep;
|
|
110
115
|
return parsedConfig.fileNames.filter((f) => f.startsWith(pkgSrcPrefix));
|
|
@@ -43,7 +43,8 @@ export function serializeDiagnostic(diagnostic: ts.Diagnostic): SerializedDiagno
|
|
|
43
43
|
function getScriptKind(fileName: string): ts.ScriptKind {
|
|
44
44
|
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
45
45
|
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
46
|
-
if (fileName.endsWith(".js") || fileName.endsWith(".mjs") || fileName.endsWith(".cjs"))
|
|
46
|
+
if (fileName.endsWith(".js") || fileName.endsWith(".mjs") || fileName.endsWith(".cjs"))
|
|
47
|
+
return ts.ScriptKind.JS;
|
|
47
48
|
return ts.ScriptKind.TS;
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -54,7 +55,10 @@ function getScriptKind(fileName: string): ts.ScriptKind {
|
|
|
54
55
|
* @param fileCache 파일 내용 캐시 (동일 파일 중복 읽기 방지)
|
|
55
56
|
* @returns 복원된 ts.Diagnostic 객체
|
|
56
57
|
*/
|
|
57
|
-
export function deserializeDiagnostic(
|
|
58
|
+
export function deserializeDiagnostic(
|
|
59
|
+
serialized: SerializedDiagnostic,
|
|
60
|
+
fileCache: Map<string, string>,
|
|
61
|
+
): ts.Diagnostic {
|
|
58
62
|
let file: ts.SourceFile | undefined;
|
|
59
63
|
if (serialized.file != null) {
|
|
60
64
|
const fileName = serialized.file.fileName;
|
package/src/utils/vite-config.ts
CHANGED
|
@@ -17,23 +17,14 @@ import { FsWatcher } from "@simplysm/core-node";
|
|
|
17
17
|
* preset 등으로 참조하는 scope 패키지의 config 변경을 감지하지 못한다.
|
|
18
18
|
* 이 플러그인이 해당 파일들을 watch하고, 변경 시 Tailwind 캐시를 무효화한다.
|
|
19
19
|
*/
|
|
20
|
-
function sdTailwindConfigDepsPlugin(pkgDir: string): Plugin {
|
|
20
|
+
function sdTailwindConfigDepsPlugin(pkgDir: string, scopes: string[]): Plugin {
|
|
21
21
|
return {
|
|
22
22
|
name: "sd-tailwind-config-deps",
|
|
23
23
|
configureServer(server) {
|
|
24
24
|
const configPath = path.join(pkgDir, "tailwind.config.ts");
|
|
25
25
|
if (!fs.existsSync(configPath)) return;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
const pkgJsonPath = path.join(pkgDir, "package.json");
|
|
29
|
-
const pkgName = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")).name as string;
|
|
30
|
-
const pkgScope = pkgName.match(/^(@[^/]+)\//)?.[1];
|
|
31
|
-
const scopes = new Set(["@simplysm"]);
|
|
32
|
-
if (pkgScope != null) {
|
|
33
|
-
scopes.add(pkgScope);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const allDeps = getTailwindConfigDeps(configPath, [...scopes]);
|
|
27
|
+
const allDeps = getTailwindConfigDeps(configPath, scopes);
|
|
37
28
|
const configAbsolute = path.resolve(configPath);
|
|
38
29
|
const externalDeps = allDeps.filter((d) => d !== configAbsolute);
|
|
39
30
|
if (externalDeps.length === 0) return;
|
|
@@ -170,7 +161,8 @@ function sdScopeWatchPlugin(pkgDir: string, scopes: string[], onScopeRebuild?: (
|
|
|
170
161
|
// 같은 scope 내 패키지는 이미 excluded이므로 제외
|
|
171
162
|
if (scopes.some((s) => dep.startsWith(`${s}/`))) continue;
|
|
172
163
|
// SolidJS 관련 패키지는 solid 플러그인 transform이 필요하므로 pre-bundling 불가
|
|
173
|
-
if (dep === "solid-js" || dep.startsWith("@solidjs/") || dep.startsWith("solid-"))
|
|
164
|
+
if (dep === "solid-js" || dep.startsWith("@solidjs/") || dep.startsWith("solid-"))
|
|
165
|
+
continue;
|
|
174
166
|
// PostCSS/빌드 도구는 브라우저 pre-bundling 대상 아님
|
|
175
167
|
if (dep === "tailwindcss") continue;
|
|
176
168
|
|
|
@@ -185,7 +177,13 @@ function sdScopeWatchPlugin(pkgDir: string, scopes: string[], onScopeRebuild?: (
|
|
|
185
177
|
|
|
186
178
|
// workspace 패키지는 realpath가 소스 디렉토리로 해석되어 .pnpm 구조가 아님
|
|
187
179
|
// symlink 경로의 node_modules에서 fallback 시도
|
|
188
|
-
const depPkgJsonFallback = path.join(
|
|
180
|
+
const depPkgJsonFallback = path.join(
|
|
181
|
+
scopeDir,
|
|
182
|
+
name,
|
|
183
|
+
"node_modules",
|
|
184
|
+
dep,
|
|
185
|
+
"package.json",
|
|
186
|
+
);
|
|
189
187
|
if (isSubpathOnlyPackage(depPkgJsonFallback)) {
|
|
190
188
|
continue;
|
|
191
189
|
}
|
|
@@ -200,32 +198,47 @@ function sdScopeWatchPlugin(pkgDir: string, scopes: string[], onScopeRebuild?: (
|
|
|
200
198
|
|
|
201
199
|
return {
|
|
202
200
|
optimizeDeps: {
|
|
201
|
+
force: true,
|
|
203
202
|
exclude: excluded,
|
|
204
203
|
include: [...new Set(nestedDepsToInclude)],
|
|
205
204
|
},
|
|
206
205
|
};
|
|
207
206
|
},
|
|
208
207
|
async configureServer(server) {
|
|
209
|
-
const
|
|
208
|
+
const watchPaths: string[] = [];
|
|
210
209
|
|
|
211
210
|
for (const scope of scopes) {
|
|
212
211
|
const scopeDir = path.join(pkgDir, "node_modules", scope);
|
|
213
212
|
if (!fs.existsSync(scopeDir)) continue;
|
|
214
213
|
|
|
215
214
|
for (const pkgName of fs.readdirSync(scopeDir)) {
|
|
216
|
-
const
|
|
215
|
+
const pkgRoot = path.join(scopeDir, pkgName);
|
|
216
|
+
|
|
217
|
+
// dist 디렉토리 watch (JS/TS 빌드 결과물)
|
|
218
|
+
const distDir = path.join(pkgRoot, "dist");
|
|
217
219
|
if (fs.existsSync(distDir)) {
|
|
218
|
-
|
|
220
|
+
watchPaths.push(distDir);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 패키지 루트의 CSS/config 파일 watch (tailwind.css, tailwind.config.ts 등)
|
|
224
|
+
for (const file of fs.readdirSync(pkgRoot)) {
|
|
225
|
+
if (
|
|
226
|
+
file.endsWith(".css") ||
|
|
227
|
+
file === "tailwind.config.ts" ||
|
|
228
|
+
file === "tailwind.config.js"
|
|
229
|
+
) {
|
|
230
|
+
watchPaths.push(path.join(pkgRoot, file));
|
|
231
|
+
}
|
|
219
232
|
}
|
|
220
233
|
}
|
|
221
234
|
}
|
|
222
235
|
|
|
223
|
-
if (
|
|
236
|
+
if (watchPaths.length === 0) return;
|
|
224
237
|
|
|
225
238
|
// Vite의 기본 watcher는 **/node_modules/**를 ignore하고
|
|
226
239
|
// server.watcher.add()로는 이 패턴을 override할 수 없다.
|
|
227
240
|
// 별도의 FsWatcher로 scope 패키지의 dist 디렉토리를 감시한다.
|
|
228
|
-
const scopeWatcher = await FsWatcher.watch(
|
|
241
|
+
const scopeWatcher = await FsWatcher.watch(watchPaths);
|
|
229
242
|
scopeWatcher.onChange({ delay: 300 }, (changeInfos) => {
|
|
230
243
|
for (const { path: changedPath } of changeInfos) {
|
|
231
244
|
// pnpm symlink → real path 변환 (Vite module graph은 real path 사용)
|
|
@@ -275,7 +288,8 @@ export interface ViteConfigOptions {
|
|
|
275
288
|
* - dev 모드: dev server (define으로 env 치환, server 설정)
|
|
276
289
|
*/
|
|
277
290
|
export function createViteConfig(options: ViteConfigOptions): ViteUserConfig {
|
|
278
|
-
const { pkgDir, name, tsconfigPath, compilerOptions, env, mode, serverPort, watchScopes } =
|
|
291
|
+
const { pkgDir, name, tsconfigPath, compilerOptions, env, mode, serverPort, watchScopes } =
|
|
292
|
+
options;
|
|
279
293
|
|
|
280
294
|
// Read package.json to extract app name for PWA manifest
|
|
281
295
|
const pkgJsonPath = path.join(pkgDir, "package.json");
|
|
@@ -308,7 +322,9 @@ export function createViteConfig(options: ViteConfigOptions): ViteUserConfig {
|
|
|
308
322
|
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
|
|
309
323
|
},
|
|
310
324
|
}),
|
|
311
|
-
|
|
325
|
+
...(watchScopes != null && watchScopes.length > 0
|
|
326
|
+
? [sdTailwindConfigDepsPlugin(pkgDir, watchScopes)]
|
|
327
|
+
: []),
|
|
312
328
|
...(watchScopes != null && watchScopes.length > 0
|
|
313
329
|
? [sdScopeWatchPlugin(pkgDir, watchScopes, options.onScopeRebuild)]
|
|
314
330
|
: []),
|
|
@@ -62,7 +62,10 @@ export interface WorkerEventHandlerOptions {
|
|
|
62
62
|
* @param rebuildManager 리빌드 매니저
|
|
63
63
|
* @returns completeTask 함수 (결과를 저장하고 빌드 완료를 알림)
|
|
64
64
|
*/
|
|
65
|
-
export function registerWorkerEventHandlers<
|
|
65
|
+
export function registerWorkerEventHandlers<
|
|
66
|
+
TEvents extends Record<string, any[]>,
|
|
67
|
+
T extends BaseWorkerInfo<TEvents>,
|
|
68
|
+
>(
|
|
66
69
|
workerInfo: T,
|
|
67
70
|
opts: WorkerEventHandlerOptions,
|
|
68
71
|
results: Map<string, PackageResult>,
|
|
@@ -10,7 +10,10 @@ import type { ConsolaInstance } from "consola";
|
|
|
10
10
|
* @param cleanup - Async cleanup function to execute on shutdown
|
|
11
11
|
* @param logger - Consola logger instance for error logging
|
|
12
12
|
*/
|
|
13
|
-
export function registerCleanupHandlers(
|
|
13
|
+
export function registerCleanupHandlers(
|
|
14
|
+
cleanup: () => Promise<void>,
|
|
15
|
+
logger: ConsolaInstance,
|
|
16
|
+
): void {
|
|
14
17
|
const handleSignal = () => {
|
|
15
18
|
cleanup()
|
|
16
19
|
.catch((err) => {
|
|
@@ -115,7 +115,11 @@ async function build(info: ClientBuildInfo): Promise<ClientBuildResult> {
|
|
|
115
115
|
const tsconfigPath = path.join(info.cwd, "tsconfig.json");
|
|
116
116
|
|
|
117
117
|
// browser 타겟용 compilerOptions 생성
|
|
118
|
-
const compilerOptions = await getCompilerOptionsForPackage(
|
|
118
|
+
const compilerOptions = await getCompilerOptionsForPackage(
|
|
119
|
+
parsedConfig.options,
|
|
120
|
+
"browser",
|
|
121
|
+
info.pkgDir,
|
|
122
|
+
);
|
|
119
123
|
|
|
120
124
|
// Vite 설정 생성 및 빌드
|
|
121
125
|
const viteConfig = createViteConfig({
|
|
@@ -162,7 +166,11 @@ async function startWatch(info: ClientWatchInfo): Promise<void> {
|
|
|
162
166
|
const tsconfigPath = path.join(info.cwd, "tsconfig.json");
|
|
163
167
|
|
|
164
168
|
// browser 타겟용 compilerOptions 생성
|
|
165
|
-
const compilerOptions = await getCompilerOptionsForPackage(
|
|
169
|
+
const compilerOptions = await getCompilerOptionsForPackage(
|
|
170
|
+
parsedConfig.options,
|
|
171
|
+
"browser",
|
|
172
|
+
info.pkgDir,
|
|
173
|
+
);
|
|
166
174
|
|
|
167
175
|
// server가 0이면 자동 포트 할당 (서버 연결 클라이언트)
|
|
168
176
|
// server가 숫자면 해당 포트로 고정 (standalone 클라이언트)
|
|
@@ -192,7 +200,8 @@ async function startWatch(info: ClientWatchInfo): Promise<void> {
|
|
|
192
200
|
|
|
193
201
|
// 실제 할당된 포트 반환 (config.server.port는 설정값이므로 httpServer에서 실제 포트를 가져옴)
|
|
194
202
|
const address = viteServer.httpServer?.address();
|
|
195
|
-
const actualPort =
|
|
203
|
+
const actualPort =
|
|
204
|
+
typeof address === "object" && address != null ? address.port : viteServer.config.server.port;
|
|
196
205
|
|
|
197
206
|
sender.send("serverReady", { port: actualPort });
|
|
198
207
|
} catch (err) {
|
|
@@ -78,7 +78,9 @@ export interface DtsWorkerEvents extends Record<string, unknown> {
|
|
|
78
78
|
const logger = consola.withTag("sd:cli:dts:worker");
|
|
79
79
|
|
|
80
80
|
/** tsc watch program (정리 대상) */
|
|
81
|
-
let tscWatchProgram:
|
|
81
|
+
let tscWatchProgram:
|
|
82
|
+
| ts.WatchOfFilesAndCompilerOptions<ts.EmitAndSemanticDiagnosticsBuilderProgram>
|
|
83
|
+
| undefined;
|
|
82
84
|
|
|
83
85
|
/**
|
|
84
86
|
* 리소스 정리
|
|
@@ -141,7 +143,9 @@ function adjustDtsMapSources(content: string, originalDir: string, newDir: strin
|
|
|
141
143
|
*
|
|
142
144
|
* @returns (fileName, content) => [newPath, newContent] | null (null이면 쓰기 무시)
|
|
143
145
|
*/
|
|
144
|
-
function createDtsPathRewriter(
|
|
146
|
+
function createDtsPathRewriter(
|
|
147
|
+
pkgDir: string,
|
|
148
|
+
): (fileName: string, content: string) => [string, string] | null {
|
|
145
149
|
const pkgName = path.basename(pkgDir);
|
|
146
150
|
const distDir = path.join(pkgDir, "dist");
|
|
147
151
|
const distPrefix = distDir + path.sep;
|
|
@@ -276,8 +280,12 @@ async function buildDts(info: DtsBuildInfo): Promise<DtsBuildResult> {
|
|
|
276
280
|
const filteredDiagnostics = allDiagnostics.filter(diagnosticFilter);
|
|
277
281
|
|
|
278
282
|
const serializedDiagnostics = filteredDiagnostics.map(serializeDiagnostic);
|
|
279
|
-
const errorCount = filteredDiagnostics.filter(
|
|
280
|
-
|
|
283
|
+
const errorCount = filteredDiagnostics.filter(
|
|
284
|
+
(d) => d.category === ts.DiagnosticCategory.Error,
|
|
285
|
+
).length;
|
|
286
|
+
const warningCount = filteredDiagnostics.filter(
|
|
287
|
+
(d) => d.category === ts.DiagnosticCategory.Warning,
|
|
288
|
+
).length;
|
|
281
289
|
|
|
282
290
|
// 에러 메시지 문자열 배열 (하위 호환용)
|
|
283
291
|
const errors = filteredDiagnostics
|
|
@@ -330,7 +338,11 @@ async function startDtsWatch(info: DtsWatchInfo): Promise<void> {
|
|
|
330
338
|
try {
|
|
331
339
|
const parsedConfig = parseRootTsconfig(info.cwd);
|
|
332
340
|
const rootFiles = getPackageSourceFiles(info.pkgDir, parsedConfig);
|
|
333
|
-
const baseOptions = await getCompilerOptionsForPackage(
|
|
341
|
+
const baseOptions = await getCompilerOptionsForPackage(
|
|
342
|
+
parsedConfig.options,
|
|
343
|
+
info.env,
|
|
344
|
+
info.pkgDir,
|
|
345
|
+
);
|
|
334
346
|
|
|
335
347
|
// 해당 패키지 경로 (필터링용)
|
|
336
348
|
const pkgSrcPrefix = path.join(info.pkgDir, "src") + path.sep;
|
|
@@ -362,7 +374,9 @@ async function startDtsWatch(info: DtsWatchInfo): Promise<void> {
|
|
|
362
374
|
|
|
363
375
|
// 파일 위치 정보가 있으면 포함 (절대경로:라인:컬럼 형식 - IDE 링크 지원)
|
|
364
376
|
if (diagnostic.file != null && diagnostic.start != null) {
|
|
365
|
-
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(
|
|
377
|
+
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(
|
|
378
|
+
diagnostic.start,
|
|
379
|
+
);
|
|
366
380
|
collectedErrors.push(
|
|
367
381
|
`${diagnostic.file.fileName}:${line + 1}:${character + 1}: TS${diagnostic.code}: ${message}`,
|
|
368
382
|
);
|
|
@@ -424,7 +438,10 @@ async function startDtsWatch(info: DtsWatchInfo): Promise<void> {
|
|
|
424
438
|
}
|
|
425
439
|
}
|
|
426
440
|
|
|
427
|
-
const sender = createWorker<
|
|
441
|
+
const sender = createWorker<
|
|
442
|
+
{ startDtsWatch: typeof startDtsWatch; buildDts: typeof buildDts },
|
|
443
|
+
DtsWorkerEvents
|
|
444
|
+
>({
|
|
428
445
|
startDtsWatch,
|
|
429
446
|
buildDts,
|
|
430
447
|
});
|
|
@@ -3,7 +3,11 @@ import esbuild from "esbuild";
|
|
|
3
3
|
import { createWorker, FsWatcher } from "@simplysm/core-node";
|
|
4
4
|
import { consola } from "consola";
|
|
5
5
|
import type { SdBuildPackageConfig } from "../sd-config.types";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
parseRootTsconfig,
|
|
8
|
+
getPackageSourceFiles,
|
|
9
|
+
getCompilerOptionsForPackage,
|
|
10
|
+
} from "../utils/tsconfig";
|
|
7
11
|
import {
|
|
8
12
|
createLibraryEsbuildOptions,
|
|
9
13
|
getTypecheckEnvFromTarget,
|
|
@@ -114,7 +118,11 @@ async function build(info: LibraryBuildInfo): Promise<LibraryBuildResult> {
|
|
|
114
118
|
|
|
115
119
|
// 타겟별 compilerOptions 생성
|
|
116
120
|
const env = getTypecheckEnvFromTarget(info.config.target);
|
|
117
|
-
const compilerOptions = await getCompilerOptionsForPackage(
|
|
121
|
+
const compilerOptions = await getCompilerOptionsForPackage(
|
|
122
|
+
parsedConfig.options,
|
|
123
|
+
env,
|
|
124
|
+
info.pkgDir,
|
|
125
|
+
);
|
|
118
126
|
|
|
119
127
|
// esbuild 일회성 빌드
|
|
120
128
|
const esbuildOptions = createLibraryEsbuildOptions({
|
|
@@ -237,7 +245,13 @@ async function startWatch(info: LibraryWatchInfo): Promise<void> {
|
|
|
237
245
|
});
|
|
238
246
|
|
|
239
247
|
// 초기 esbuild context 생성 및 빌드
|
|
240
|
-
esbuildContext = await createAndBuildContext(
|
|
248
|
+
esbuildContext = await createAndBuildContext(
|
|
249
|
+
info.pkgDir,
|
|
250
|
+
info.cwd,
|
|
251
|
+
info.config,
|
|
252
|
+
true,
|
|
253
|
+
resolveFirstBuild,
|
|
254
|
+
);
|
|
241
255
|
|
|
242
256
|
// 첫 번째 빌드 완료 대기
|
|
243
257
|
await firstBuildPromise;
|
|
@@ -96,7 +96,9 @@ async function findAvailablePort(startPort: number, maxRetries = 20): Promise<nu
|
|
|
96
96
|
return port;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
throw new Error(
|
|
99
|
+
throw new Error(
|
|
100
|
+
`포트 ${startPort}부터 ${startPort + maxRetries - 1}까지 사용 가능한 포트가 없습니다.`,
|
|
101
|
+
);
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
/**
|
|
@@ -5,7 +5,11 @@ import esbuild from "esbuild";
|
|
|
5
5
|
import { createWorker } from "@simplysm/core-node";
|
|
6
6
|
import type { FsWatcher } from "@simplysm/core-node";
|
|
7
7
|
import { consola } from "consola";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
parseRootTsconfig,
|
|
10
|
+
getPackageSourceFiles,
|
|
11
|
+
getCompilerOptionsForPackage,
|
|
12
|
+
} from "../utils/tsconfig";
|
|
9
13
|
import {
|
|
10
14
|
createServerEsbuildOptions,
|
|
11
15
|
collectUninstalledOptionalPeerDeps,
|
|
@@ -229,7 +233,11 @@ function generateProductionFiles(info: ServerBuildInfo, externals: string[]): vo
|
|
|
229
233
|
logger.debug("GEN pm2.config.cjs...");
|
|
230
234
|
|
|
231
235
|
const pm2Name = info.pm2.name ?? pkgJson.name.replace(/@/g, "").replace(/[/\\]/g, "-");
|
|
232
|
-
const ignoreWatch = JSON.stringify([
|
|
236
|
+
const ignoreWatch = JSON.stringify([
|
|
237
|
+
"node_modules",
|
|
238
|
+
"www",
|
|
239
|
+
...(info.pm2.ignoreWatchPaths ?? []),
|
|
240
|
+
]);
|
|
233
241
|
const envObj: Record<string, string> = {
|
|
234
242
|
NODE_ENV: "production",
|
|
235
243
|
TZ: "Asia/Seoul",
|
|
@@ -238,7 +246,9 @@ function generateProductionFiles(info: ServerBuildInfo, externals: string[]): vo
|
|
|
238
246
|
const envStr = JSON.stringify(envObj, undefined, 4);
|
|
239
247
|
|
|
240
248
|
const interpreterLine =
|
|
241
|
-
info.packageManager === "volta"
|
|
249
|
+
info.packageManager === "volta"
|
|
250
|
+
? ""
|
|
251
|
+
: ` interpreter: cp.execSync("mise which node").toString().trim(),\n`;
|
|
242
252
|
|
|
243
253
|
const pm2Config = [
|
|
244
254
|
`const cp = require("child_process");`,
|
|
@@ -284,7 +294,11 @@ async function build(info: ServerBuildInfo): Promise<ServerBuildResult> {
|
|
|
284
294
|
const entryPoints = getPackageSourceFiles(info.pkgDir, parsedConfig);
|
|
285
295
|
|
|
286
296
|
// 서버는 node 환경
|
|
287
|
-
const compilerOptions = await getCompilerOptionsForPackage(
|
|
297
|
+
const compilerOptions = await getCompilerOptionsForPackage(
|
|
298
|
+
parsedConfig.options,
|
|
299
|
+
"node",
|
|
300
|
+
info.pkgDir,
|
|
301
|
+
);
|
|
288
302
|
|
|
289
303
|
// 모든 external 수집 (optional peer deps + native modules + manual)
|
|
290
304
|
const external = collectAllExternals(info.pkgDir, info.externals);
|
|
@@ -347,7 +361,11 @@ async function startWatch(info: ServerWatchInfo): Promise<void> {
|
|
|
347
361
|
const entryPoints = getPackageSourceFiles(info.pkgDir, parsedConfig);
|
|
348
362
|
|
|
349
363
|
// 서버는 node 환경
|
|
350
|
-
const compilerOptions = await getCompilerOptionsForPackage(
|
|
364
|
+
const compilerOptions = await getCompilerOptionsForPackage(
|
|
365
|
+
parsedConfig.options,
|
|
366
|
+
"node",
|
|
367
|
+
info.pkgDir,
|
|
368
|
+
);
|
|
351
369
|
|
|
352
370
|
const mainJsPath = path.join(info.pkgDir, "dist", "main.js");
|
|
353
371
|
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"vitest": "vitest"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@simplysm/sd-cli": "~13.0.
|
|
19
|
-
"@simplysm/claude": "~13.0.
|
|
20
|
-
"@simplysm/lint": "~13.0.
|
|
18
|
+
"@simplysm/sd-cli": "~13.0.30",
|
|
19
|
+
"@simplysm/claude": "~13.0.30",
|
|
20
|
+
"@simplysm/lint": "~13.0.30",
|
|
21
21
|
"@types/node": "^20.19.33",
|
|
22
22
|
"eslint": "^9.39.2",
|
|
23
23
|
"prettier": "^3.8.1",
|