@simplysm/sd-cli 14.0.29 → 14.0.32
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/{utils → angular}/angular-build-pipeline.d.ts +0 -2
- package/dist/angular/angular-build-pipeline.d.ts.map +1 -0
- package/dist/{utils → angular}/angular-build-pipeline.js +3 -6
- package/dist/angular/angular-build-pipeline.js.map +1 -0
- package/dist/{utils → angular}/angular-build.d.ts +1 -1
- package/dist/angular/angular-build.d.ts.map +1 -0
- package/dist/{utils → angular}/angular-build.js +1 -1
- package/dist/angular/angular-build.js.map +1 -0
- package/dist/{utils → angular}/angular-compiler.d.ts +0 -3
- package/dist/angular/angular-compiler.d.ts.map +1 -0
- package/dist/{utils → angular}/angular-compiler.js +1 -45
- package/dist/angular/angular-compiler.js.map +1 -0
- package/dist/angular/client-transform-stylesheet.js +1 -1
- package/dist/angular/client-transform-stylesheet.js.map +1 -1
- package/dist/{utils → angular}/ngtsc-build-core.d.ts +3 -3
- package/dist/angular/ngtsc-build-core.d.ts.map +1 -0
- package/dist/angular/ngtsc-build-core.js.map +1 -0
- package/dist/angular/scss-compiler.d.ts.map +1 -0
- package/dist/angular/scss-compiler.js.map +1 -0
- package/dist/angular/vite-angular-plugin.d.ts +2 -10
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +20 -286
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/capacitor/capacitor-build.d.ts +14 -0
- package/dist/capacitor/capacitor-build.d.ts.map +1 -0
- package/dist/capacitor/capacitor-build.js +105 -0
- package/dist/capacitor/capacitor-build.js.map +1 -0
- package/dist/capacitor/capacitor-config-writer.d.ts +11 -0
- package/dist/capacitor/capacitor-config-writer.d.ts.map +1 -0
- package/dist/capacitor/capacitor-config-writer.js +54 -0
- package/dist/capacitor/capacitor-config-writer.js.map +1 -0
- package/dist/capacitor/capacitor-icon.d.ts +5 -0
- package/dist/capacitor/capacitor-icon.d.ts.map +1 -0
- package/dist/capacitor/capacitor-icon.js +58 -0
- package/dist/capacitor/capacitor-icon.js.map +1 -0
- package/dist/capacitor/capacitor-npm-config.d.ts +11 -0
- package/dist/capacitor/capacitor-npm-config.d.ts.map +1 -0
- package/dist/capacitor/capacitor-npm-config.js +145 -0
- package/dist/capacitor/capacitor-npm-config.js.map +1 -0
- package/dist/capacitor/capacitor.d.ts +0 -45
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +15 -354
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.js +2 -2
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -3
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -3
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/lint.d.ts +1 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +1 -1
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish/deployment-phase.d.ts +12 -0
- package/dist/commands/publish/deployment-phase.d.ts.map +1 -0
- package/dist/commands/publish/deployment-phase.js +94 -0
- package/dist/commands/publish/deployment-phase.js.map +1 -0
- package/dist/commands/publish/env-utils.d.ts +10 -0
- package/dist/commands/publish/env-utils.d.ts.map +1 -0
- package/dist/commands/publish/env-utils.js +41 -0
- package/dist/commands/publish/env-utils.js.map +1 -0
- package/dist/commands/publish/git-phase.d.ts +12 -0
- package/dist/commands/publish/git-phase.d.ts.map +1 -0
- package/dist/commands/publish/git-phase.js +79 -0
- package/dist/commands/publish/git-phase.js.map +1 -0
- package/dist/commands/{publish.d.ts → publish/index.d.ts} +1 -1
- package/dist/commands/publish/index.d.ts.map +1 -0
- package/dist/commands/publish/index.js +211 -0
- package/dist/commands/publish/index.js.map +1 -0
- package/dist/commands/publish/local-publisher.d.ts +6 -0
- package/dist/commands/publish/local-publisher.d.ts.map +1 -0
- package/dist/commands/publish/local-publisher.js +16 -0
- package/dist/commands/publish/local-publisher.js.map +1 -0
- package/dist/commands/publish/npm-publisher.d.ts +6 -0
- package/dist/commands/publish/npm-publisher.d.ts.map +1 -0
- package/dist/commands/publish/npm-publisher.js +21 -0
- package/dist/commands/publish/npm-publisher.js.map +1 -0
- package/dist/commands/publish/post-publish-phase.d.ts +8 -0
- package/dist/commands/publish/post-publish-phase.d.ts.map +1 -0
- package/dist/commands/publish/post-publish-phase.js +34 -0
- package/dist/commands/publish/post-publish-phase.js.map +1 -0
- package/dist/commands/publish/storage-publisher.d.ts +18 -0
- package/dist/commands/publish/storage-publisher.d.ts.map +1 -0
- package/dist/commands/publish/storage-publisher.js +173 -0
- package/dist/commands/publish/storage-publisher.js.map +1 -0
- package/dist/commands/publish/version-upgrade.d.ts +28 -0
- package/dist/commands/publish/version-upgrade.d.ts.map +1 -0
- package/dist/commands/publish/version-upgrade.js +96 -0
- package/dist/commands/publish/version-upgrade.js.map +1 -0
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/commands/watch.d.ts +3 -4
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +3 -4
- package/dist/commands/watch.js.map +1 -1
- package/dist/deps/replace-deps/collect-deps.d.ts +6 -0
- package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -0
- package/dist/deps/replace-deps/collect-deps.js +71 -0
- package/dist/deps/replace-deps/collect-deps.js.map +1 -0
- package/dist/{utils/replace-deps.d.ts → deps/replace-deps/replace-deps-resolve.d.ts} +7 -24
- package/dist/deps/replace-deps/replace-deps-resolve.d.ts.map +1 -0
- package/dist/{utils/replace-deps.js → deps/replace-deps/replace-deps-resolve.js} +4 -152
- package/dist/deps/replace-deps/replace-deps-resolve.js.map +1 -0
- package/dist/deps/replace-deps/replace-deps.d.ts +36 -0
- package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -0
- package/dist/deps/replace-deps/replace-deps.js +155 -0
- package/dist/deps/replace-deps/replace-deps.js.map +1 -0
- package/dist/{utils → deps/server-externals}/server-production-files.d.ts +1 -1
- package/dist/deps/server-externals/server-production-files.d.ts.map +1 -0
- package/dist/{utils → deps/server-externals}/server-production-files.js +1 -1
- package/dist/deps/server-externals/server-production-files.js.map +1 -0
- package/dist/dev-server/dev-http-server.d.ts +23 -0
- package/dist/dev-server/dev-http-server.d.ts.map +1 -0
- package/dist/dev-server/dev-http-server.js +116 -0
- package/dist/dev-server/dev-http-server.js.map +1 -0
- package/dist/dev-server/hmr-client-script.d.ts +13 -0
- package/dist/dev-server/hmr-client-script.d.ts.map +1 -0
- package/dist/dev-server/hmr-client-script.js +73 -0
- package/dist/dev-server/hmr-client-script.js.map +1 -0
- package/dist/dev-server/hmr-service.d.ts +23 -0
- package/dist/dev-server/hmr-service.d.ts.map +1 -0
- package/dist/dev-server/hmr-service.js +139 -0
- package/dist/dev-server/hmr-service.js.map +1 -0
- package/dist/electron/electron.d.ts +5 -0
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +17 -24
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts +18 -4
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +45 -66
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/{ViteEngine.d.ts → EsbuildClientEngine.d.ts} +11 -18
- package/dist/engines/EsbuildClientEngine.d.ts.map +1 -0
- package/dist/engines/{ViteEngine.js → EsbuildClientEngine.js} +28 -55
- package/dist/engines/EsbuildClientEngine.js.map +1 -0
- package/dist/engines/NgtscEngine.d.ts +2 -2
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +1 -9
- package/dist/engines/NgtscEngine.js.map +1 -1
- package/dist/engines/ServerEsbuildEngine.d.ts +2 -2
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
- package/dist/engines/ServerEsbuildEngine.js +1 -9
- package/dist/engines/ServerEsbuildEngine.js.map +1 -1
- package/dist/engines/TscEngine.d.ts +2 -2
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +1 -9
- package/dist/engines/TscEngine.js.map +1 -1
- package/dist/engines/index.d.ts +15 -5
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +21 -5
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/types.d.ts +3 -3
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/esbuild/esbuild-client-config.d.ts +38 -0
- package/dist/esbuild/esbuild-client-config.d.ts.map +1 -0
- package/dist/esbuild/esbuild-client-config.js +171 -0
- package/dist/esbuild/esbuild-client-config.js.map +1 -0
- package/dist/esbuild/esbuild-config.d.ts.map +1 -0
- package/dist/{utils → esbuild}/esbuild-config.js +1 -0
- package/dist/esbuild/esbuild-config.js.map +1 -0
- package/dist/esbuild/esbuild-index-html.d.ts +39 -0
- package/dist/esbuild/esbuild-index-html.d.ts.map +1 -0
- package/dist/esbuild/esbuild-index-html.js +68 -0
- package/dist/esbuild/esbuild-index-html.js.map +1 -0
- package/dist/esbuild/esbuild-pwa.d.ts +21 -0
- package/dist/esbuild/esbuild-pwa.d.ts.map +1 -0
- package/dist/esbuild/esbuild-pwa.js +105 -0
- package/dist/esbuild/esbuild-pwa.js.map +1 -0
- package/dist/esbuild/esbuild-scss-plugin.d.ts +6 -0
- package/dist/esbuild/esbuild-scss-plugin.d.ts.map +1 -0
- package/dist/esbuild/esbuild-scss-plugin.js +41 -0
- package/dist/esbuild/esbuild-scss-plugin.js.map +1 -0
- package/dist/lint/lint-core.d.ts.map +1 -0
- package/dist/lint/lint-core.js.map +1 -0
- package/dist/lint/lint-utils.d.ts.map +1 -0
- package/dist/lint/lint-utils.js.map +1 -0
- package/dist/lint/lint-with-program.d.ts.map +1 -0
- package/dist/lint/lint-with-program.js.map +1 -0
- package/dist/orchestrators/BaseOrchestrator.d.ts +44 -0
- package/dist/orchestrators/BaseOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/BaseOrchestrator.js +92 -0
- package/dist/orchestrators/BaseOrchestrator.js.map +1 -0
- package/dist/orchestrators/BuildOrchestrator.d.ts +45 -3
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +170 -143
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.d.ts +39 -0
- package/dist/orchestrators/DevOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/DevOrchestrator.js +249 -0
- package/dist/orchestrators/DevOrchestrator.js.map +1 -0
- package/dist/orchestrators/ServerRuntimeManager.d.ts +22 -0
- package/dist/orchestrators/ServerRuntimeManager.d.ts.map +1 -0
- package/dist/orchestrators/ServerRuntimeManager.js +66 -0
- package/dist/orchestrators/ServerRuntimeManager.js.map +1 -0
- package/dist/orchestrators/TypecheckOrchestrator.d.ts +17 -2
- package/dist/orchestrators/TypecheckOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/TypecheckOrchestrator.js +122 -108
- package/dist/orchestrators/TypecheckOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.d.ts +33 -0
- package/dist/orchestrators/WatchOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/WatchOrchestrator.js +158 -0
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -0
- package/dist/orchestrators/types.d.ts +17 -0
- package/dist/orchestrators/types.d.ts.map +1 -0
- package/dist/orchestrators/types.js +2 -0
- package/dist/orchestrators/types.js.map +1 -0
- package/dist/runtime/ResultCollector.d.ts.map +1 -0
- package/dist/runtime/ResultCollector.js.map +1 -0
- package/dist/runtime/SignalHandler.d.ts.map +1 -0
- package/dist/runtime/SignalHandler.js.map +1 -0
- package/dist/{utils → runtime}/engine-stop.d.ts +1 -1
- package/dist/runtime/engine-stop.d.ts.map +1 -0
- package/dist/{utils → runtime}/engine-stop.js +1 -1
- package/dist/runtime/engine-stop.js.map +1 -0
- package/dist/runtime/engine-watch-events.d.ts +43 -0
- package/dist/runtime/engine-watch-events.d.ts.map +1 -0
- package/dist/runtime/engine-watch-events.js +72 -0
- package/dist/runtime/engine-watch-events.js.map +1 -0
- package/dist/{utils → runtime}/rebuild-manager.d.ts +1 -0
- package/dist/runtime/rebuild-manager.d.ts.map +1 -0
- package/dist/{utils → runtime}/rebuild-manager.js +8 -1
- package/dist/runtime/rebuild-manager.js.map +1 -0
- package/dist/runtime/worker-events.d.ts +22 -0
- package/dist/runtime/worker-events.d.ts.map +1 -0
- package/dist/runtime/worker-events.js +2 -0
- package/dist/runtime/worker-events.js.map +1 -0
- package/dist/runtime/worker-utils.d.ts.map +1 -0
- package/dist/runtime/worker-utils.js.map +1 -0
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +61 -54
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +1 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +6 -15
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/typecheck/typecheck-non-package.d.ts.map +1 -0
- package/dist/{utils → typecheck}/typecheck-non-package.js +1 -1
- package/dist/typecheck/typecheck-non-package.js.map +1 -0
- package/dist/typecheck/typecheck-serialization.d.ts.map +1 -0
- package/dist/typecheck/typecheck-serialization.js.map +1 -0
- package/dist/utils/diagnostic-utils.d.ts +5 -0
- package/dist/utils/diagnostic-utils.d.ts.map +1 -1
- package/dist/utils/diagnostic-utils.js +15 -0
- package/dist/utils/diagnostic-utils.js.map +1 -1
- package/dist/utils/orchestrator-utils.d.ts +1 -5
- package/dist/utils/orchestrator-utils.d.ts.map +1 -1
- package/dist/utils/orchestrator-utils.js +2 -5
- package/dist/utils/orchestrator-utils.js.map +1 -1
- package/dist/utils/output-utils.d.ts +1 -1
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/package-classify.d.ts +54 -0
- package/dist/utils/package-classify.d.ts.map +1 -0
- package/dist/utils/package-classify.js +134 -0
- package/dist/utils/package-classify.js.map +1 -0
- package/dist/utils/package-utils.d.ts +1 -58
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +0 -193
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/tsc-build.d.ts +1 -1
- package/dist/utils/tsc-build.d.ts.map +1 -1
- package/dist/utils/tsc-build.js +1 -1
- package/dist/utils/tsc-build.js.map +1 -1
- package/dist/workers/build-change-filter.d.ts +8 -0
- package/dist/workers/build-change-filter.d.ts.map +1 -0
- package/dist/workers/build-change-filter.js +16 -0
- package/dist/workers/build-change-filter.js.map +1 -0
- package/dist/workers/build-watch-paths.d.ts +20 -0
- package/dist/workers/build-watch-paths.d.ts.map +1 -0
- package/dist/workers/build-watch-paths.js +29 -0
- package/dist/workers/build-watch-paths.js.map +1 -0
- package/dist/workers/client.worker.d.ts +11 -18
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +218 -289
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +2 -2
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +13 -24
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +1 -1
- package/dist/workers/lint.worker.d.ts.map +1 -1
- package/dist/workers/lint.worker.js +1 -1
- package/dist/workers/lint.worker.js.map +1 -1
- package/dist/workers/ngtsc-build.worker.d.ts +1 -1
- package/dist/workers/ngtsc-build.worker.d.ts.map +1 -1
- package/dist/workers/ngtsc-build.worker.js +19 -35
- package/dist/workers/ngtsc-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts +2 -2
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +36 -137
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-esbuild-context.d.ts +47 -0
- package/dist/workers/server-esbuild-context.d.ts.map +1 -0
- package/dist/workers/server-esbuild-context.js +92 -0
- package/dist/workers/server-esbuild-context.js.map +1 -0
- 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-watch-manager.d.ts +44 -0
- package/dist/workers/server-watch-manager.d.ts.map +1 -0
- package/dist/workers/server-watch-manager.js +87 -0
- package/dist/workers/server-watch-manager.js.map +1 -0
- package/dist/workers/shared-worker-lifecycle.d.ts +14 -0
- package/dist/workers/shared-worker-lifecycle.d.ts.map +1 -0
- package/dist/workers/shared-worker-lifecycle.js +17 -0
- package/dist/workers/shared-worker-lifecycle.js.map +1 -0
- package/package.json +9 -9
- package/src/{utils → angular}/angular-build-pipeline.ts +3 -8
- package/src/{utils → angular}/angular-build.ts +1 -1
- package/src/{utils → angular}/angular-compiler.ts +1 -64
- package/src/angular/client-transform-stylesheet.ts +1 -1
- package/src/{utils → angular}/ngtsc-build-core.ts +3 -3
- package/src/angular/vite-angular-plugin.ts +22 -355
- package/src/capacitor/capacitor-build.ts +142 -0
- package/src/capacitor/capacitor-config-writer.ts +66 -0
- package/src/capacitor/capacitor-icon.ts +75 -0
- package/src/capacitor/capacitor-npm-config.ts +192 -0
- package/src/capacitor/capacitor.ts +32 -441
- package/src/commands/check.ts +2 -2
- package/src/commands/dev.ts +6 -6
- package/src/commands/lint.ts +1 -1
- package/src/commands/publish/deployment-phase.ts +125 -0
- package/src/commands/publish/env-utils.ts +44 -0
- package/src/commands/publish/git-phase.ts +99 -0
- package/src/commands/publish/index.ts +266 -0
- package/src/commands/publish/local-publisher.ts +23 -0
- package/src/commands/publish/npm-publisher.ts +30 -0
- package/src/commands/publish/post-publish-phase.ts +43 -0
- package/src/commands/publish/storage-publisher.ts +208 -0
- package/src/commands/publish/version-upgrade.ts +132 -0
- package/src/commands/replace-deps.ts +1 -1
- package/src/commands/watch.ts +6 -7
- package/src/deps/replace-deps/collect-deps.ts +92 -0
- package/src/{utils/replace-deps.ts → deps/replace-deps/replace-deps-resolve.ts} +4 -188
- package/src/deps/replace-deps/replace-deps.ts +193 -0
- package/src/{utils → deps/server-externals}/server-production-files.ts +2 -2
- package/src/dev-server/dev-http-server.ts +149 -0
- package/src/dev-server/hmr-client-script.ts +74 -0
- package/src/dev-server/hmr-service.ts +178 -0
- package/src/electron/electron.ts +21 -28
- package/src/engines/BaseEngine.ts +64 -83
- package/src/engines/{ViteEngine.ts → EsbuildClientEngine.ts} +33 -72
- package/src/engines/NgtscEngine.ts +3 -11
- package/src/engines/ServerEsbuildEngine.ts +3 -11
- package/src/engines/TscEngine.ts +3 -11
- package/src/engines/index.ts +29 -9
- package/src/engines/types.ts +3 -3
- package/src/esbuild/esbuild-client-config.ts +230 -0
- package/src/{utils → esbuild}/esbuild-config.ts +1 -0
- package/src/esbuild/esbuild-index-html.ts +119 -0
- package/src/esbuild/esbuild-pwa.ts +139 -0
- package/src/esbuild/esbuild-scss-plugin.ts +48 -0
- package/src/orchestrators/BaseOrchestrator.ts +118 -0
- package/src/orchestrators/BuildOrchestrator.ts +234 -171
- package/src/orchestrators/DevOrchestrator.ts +315 -0
- package/src/orchestrators/ServerRuntimeManager.ts +85 -0
- package/src/orchestrators/TypecheckOrchestrator.ts +166 -117
- package/src/orchestrators/WatchOrchestrator.ts +203 -0
- package/src/orchestrators/types.ts +18 -0
- package/src/{utils → runtime}/engine-stop.ts +1 -1
- package/src/runtime/engine-watch-events.ts +121 -0
- package/src/{utils → runtime}/rebuild-manager.ts +8 -1
- package/src/runtime/worker-events.ts +25 -0
- package/src/sd-cli-entry.ts +69 -54
- package/src/sd-cli.ts +1 -1
- package/src/sd-config.types.ts +6 -16
- package/src/{utils → typecheck}/typecheck-non-package.ts +1 -1
- package/src/utils/diagnostic-utils.ts +15 -0
- package/src/utils/orchestrator-utils.ts +2 -6
- package/src/utils/output-utils.ts +1 -1
- package/src/utils/package-classify.ts +182 -0
- package/src/utils/package-utils.ts +0 -257
- package/src/utils/tsc-build.ts +1 -1
- package/src/workers/build-change-filter.ts +27 -0
- package/src/workers/build-watch-paths.ts +54 -0
- package/src/workers/client.worker.ts +258 -328
- package/src/workers/library-build.worker.ts +15 -34
- package/src/workers/lint.worker.ts +1 -1
- package/src/workers/ngtsc-build.worker.ts +19 -46
- package/src/workers/server-build.worker.ts +38 -168
- package/src/workers/server-esbuild-context.ts +122 -0
- package/src/workers/server-runtime.worker.ts +4 -1
- package/src/workers/server-watch-manager.ts +124 -0
- package/src/workers/shared-worker-lifecycle.ts +24 -0
- package/tests/angular/angular-build-pipeline.spec.ts +2 -2
- package/tests/angular/angular-compiler-aot.acc.spec.ts +68 -0
- package/tests/angular/angular-compiler-aot.spec.ts +80 -0
- package/tests/angular/angular-compiler-hmr-removal.verify.md +16 -0
- package/tests/angular/vite-angular-plugin-legacy-watch.spec.ts +0 -17
- package/tests/angular/vite-angular-plugin-vitest.spec.ts +1 -6
- package/tests/angular/vite-angular-plugin-vitest.verify.md +20 -0
- package/tests/angular/vite-angular-plugin.spec.ts +4 -178
- package/tests/capacitor/capacitor-android.spec.ts +1 -0
- package/tests/capacitor/capacitor-build.spec.ts +1 -0
- package/tests/capacitor/capacitor-config-writer.acc.spec.ts +108 -0
- package/tests/capacitor/capacitor-config-writer.spec.ts +95 -0
- package/tests/capacitor/capacitor-icon.spec.ts +1 -0
- package/tests/capacitor/capacitor-init.spec.ts +1 -0
- package/tests/capacitor/capacitor-npm-config.acc.spec.ts +236 -0
- package/tests/capacitor/capacitor-npm-config.spec.ts +132 -0
- package/tests/capacitor/capacitor-run.spec.ts +1 -0
- package/tests/capacitor/capacitor-workspace.spec.ts +1 -0
- package/tests/commands/check.spec.ts +2 -2
- package/tests/commands/deployment-phase.acc.spec.ts +142 -0
- package/tests/commands/git-phase.acc.spec.ts +158 -0
- package/tests/commands/lint.spec.ts +1 -1
- package/tests/commands/post-publish-phase.acc.spec.ts +82 -0
- package/tests/commands/publish-npm-local-split.verify.md +9 -0
- package/tests/commands/publish-responsibility-split.verify.md +13 -0
- package/tests/commands/publish-storage-split.verify.md +8 -0
- package/tests/commands/publish.spec.ts +1 -1
- package/tests/commands/typecheck.spec.ts +18 -18
- package/tests/deps/deps-directory-separation.verify.md +15 -0
- package/tests/engines/base-engine.spec.ts +65 -6
- package/tests/engines/engine-adapter-isolation.spec.ts +11 -18
- package/tests/engines/engine-selection.spec.ts +38 -5
- package/tests/engines/engine-typecheck-selection.acc.spec.ts +85 -0
- package/tests/engines/engine-typecheck-selection.verify.md +8 -0
- package/tests/engines/esbuild-client-engine.acc.spec.ts +161 -0
- package/tests/engines/esbuild-client-engine.spec.ts +320 -0
- package/tests/engines/esbuild-client-engine.verify.md +15 -0
- package/tests/engines/normalize-result.verify.md +9 -0
- package/tests/engines/vite-dependency-cleanup.verify.md +24 -0
- package/tests/orchestrators/build-orchestrator.spec.ts +3 -3
- package/tests/orchestrators/dev-orchestrator.spec.ts +799 -0
- package/tests/orchestrators/orchestrator-baseenv.verify.md +10 -0
- package/tests/orchestrators/orchestrator-diagnostic-formatting.verify.md +10 -0
- package/tests/orchestrators/orchestrator-initializemode-signature.verify.md +9 -0
- package/tests/orchestrators/typecheck-orchestrator.spec.ts +11 -11
- package/tests/orchestrators/watch-orchestrator.spec.ts +511 -0
- package/tests/{infra → runtime}/result-collector.spec.ts +1 -1
- package/tests/{infra → runtime}/signal-handler.spec.ts +1 -1
- package/tests/sd-cli-entry.spec.ts +9 -0
- package/tests/utils/angular-build.spec.ts +15 -20
- package/tests/utils/angular-compiler-emit.spec.ts +2 -2
- package/tests/utils/angular-compiler.spec.ts +2 -2
- package/tests/utils/angular-source-file-cache.spec.ts +2 -2
- package/tests/utils/concurrency.spec.ts +2 -10
- package/tests/utils/dev-http-server.acc.spec.ts +206 -0
- package/tests/utils/dev-http-server.spec.ts +181 -0
- package/tests/utils/dev-http-server.verify.md +8 -0
- package/tests/utils/diagnostic-utils.spec.ts +42 -1
- package/tests/utils/engine-stop.spec.ts +1 -1
- package/tests/utils/engine-watch-events.acc.spec.ts +217 -0
- package/tests/utils/engine-watch-events.spec.ts +141 -0
- package/tests/utils/engine-watch-events.verify.md +17 -0
- package/tests/utils/esbuild-client-config.acc.spec.ts +443 -0
- package/tests/utils/esbuild-client-config.spec.ts +590 -0
- package/tests/utils/esbuild-client-config.verify.md +26 -0
- package/tests/utils/esbuild-config.spec.ts +11 -1
- package/tests/utils/esbuild-index-html.acc.spec.ts +166 -0
- package/tests/utils/esbuild-index-html.spec.ts +194 -0
- package/tests/utils/esbuild-index-html.verify.md +10 -0
- package/tests/utils/esbuild-pwa.acc.spec.ts +203 -0
- package/tests/utils/esbuild-pwa.spec.ts +189 -0
- package/tests/utils/esbuild-pwa.verify.md +9 -0
- package/tests/utils/esbuild-scss-plugin.acc.spec.ts +111 -0
- package/tests/utils/esbuild-scss-plugin.spec.ts +150 -0
- package/tests/utils/esbuild-scss-plugin.verify.md +8 -0
- package/tests/utils/external-modules.spec.ts +1 -1
- package/tests/utils/hmr-client-script.acc.spec.ts +128 -0
- package/tests/utils/hmr-client-script.spec.ts +44 -0
- package/tests/utils/hmr-service-dispatcher.acc.spec.ts +217 -0
- package/tests/utils/hmr-service-dispatcher.spec.ts +143 -0
- package/tests/utils/hmr-service.acc.spec.ts +139 -0
- package/tests/utils/hmr-service.spec.ts +131 -0
- package/tests/utils/hmr-service.verify.md +17 -0
- package/tests/utils/lint-core.spec.ts +2 -1
- package/tests/utils/lint-utils.spec.ts +1 -1
- package/tests/utils/lint-with-program.spec.ts +1 -1
- package/tests/utils/ngtsc-build-core-write-emit.spec.ts +19 -19
- package/tests/utils/ngtsc-build-core.spec.ts +4 -4
- package/tests/utils/orchestrator-utils.spec.ts +2 -2
- package/tests/utils/output-utils.spec.ts +1 -1
- package/tests/utils/package-utils.spec.ts +1 -1
- package/tests/utils/rebuild-manager.spec.ts +20 -7
- package/tests/utils/replace-deps-split.verify.md +15 -0
- package/tests/utils/replace-deps-watch.acc.spec.ts +131 -0
- package/tests/utils/replace-deps-watch.spec.ts +91 -0
- package/tests/utils/replace-deps-watch.verify.md +9 -0
- package/tests/utils/replace-deps.spec.ts +1 -1
- package/tests/utils/scss-compiler.spec.ts +1 -1
- package/tests/utils/tsc-build.spec.ts +1 -1
- package/tests/utils/typecheck-non-package.spec.ts +2 -2
- package/tests/utils/worker-utils.spec.ts +2 -1
- package/tests/workers/build-change-filter.acc.spec.ts +78 -0
- package/tests/workers/build-change-filter.spec.ts +39 -0
- package/tests/workers/build-watch-paths-library.verify.md +10 -0
- package/tests/workers/build-watch-paths-ngtsc-server.verify.md +12 -0
- package/tests/workers/build-watch-paths.acc.spec.ts +101 -0
- package/tests/workers/build-watch-paths.spec.ts +121 -0
- package/tests/workers/client-worker-browser-support.verify.md +7 -0
- package/tests/workers/client-worker-onend-sync.verify.md +7 -0
- package/tests/workers/client-worker.acc.spec.ts +185 -0
- package/tests/workers/client-worker.spec.ts +91 -178
- package/tests/workers/library-build-lint.spec.ts +3 -3
- package/tests/workers/library-build-worker.spec.ts +10 -11
- package/tests/workers/ngtsc-build-lint.spec.ts +4 -4
- package/tests/workers/ngtsc-build-worker.spec.ts +2 -2
- package/tests/workers/server-build-lint.spec.ts +4 -4
- package/tests/workers/server-build-worker.spec.ts +14 -15
- package/tests/workers/server-esbuild-context-integration.verify.md +10 -0
- package/tests/workers/server-esbuild-context.acc.spec.ts +98 -0
- package/tests/workers/server-esbuild-context.spec.ts +198 -0
- package/tests/workers/server-runtime-worker.spec.ts +4 -3
- package/tests/workers/server-watch-manager.acc.spec.ts +162 -0
- package/tests/workers/server-watch-manager.spec.ts +199 -0
- package/tests/workers/shared-worker-lifecycle.acc.spec.ts +27 -0
- package/tests/workers/shared-worker-lifecycle.spec.ts +47 -0
- package/dist/angular/vite-postcss-inline-plugin.d.ts +0 -18
- package/dist/angular/vite-postcss-inline-plugin.d.ts.map +0 -1
- package/dist/angular/vite-postcss-inline-plugin.js +0 -108
- package/dist/angular/vite-postcss-inline-plugin.js.map +0 -1
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/publish.js +0 -689
- package/dist/commands/publish.js.map +0 -1
- package/dist/engines/ViteEngine.d.ts.map +0 -1
- package/dist/engines/ViteEngine.js.map +0 -1
- package/dist/infra/ResultCollector.d.ts.map +0 -1
- package/dist/infra/ResultCollector.js.map +0 -1
- package/dist/infra/SignalHandler.d.ts.map +0 -1
- package/dist/infra/SignalHandler.js.map +0 -1
- package/dist/orchestrators/DevWatchOrchestrator.d.ts +0 -63
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +0 -1
- package/dist/orchestrators/DevWatchOrchestrator.js +0 -478
- package/dist/orchestrators/DevWatchOrchestrator.js.map +0 -1
- package/dist/utils/angular-build-pipeline.d.ts.map +0 -1
- package/dist/utils/angular-build-pipeline.js.map +0 -1
- package/dist/utils/angular-build.d.ts.map +0 -1
- package/dist/utils/angular-build.js.map +0 -1
- package/dist/utils/angular-compiler.d.ts.map +0 -1
- package/dist/utils/angular-compiler.js.map +0 -1
- package/dist/utils/engine-stop.d.ts.map +0 -1
- package/dist/utils/engine-stop.js.map +0 -1
- package/dist/utils/esbuild-config.d.ts.map +0 -1
- package/dist/utils/esbuild-config.js.map +0 -1
- package/dist/utils/hmr-candidates.d.ts +0 -15
- package/dist/utils/hmr-candidates.d.ts.map +0 -1
- package/dist/utils/hmr-candidates.js +0 -234
- package/dist/utils/hmr-candidates.js.map +0 -1
- package/dist/utils/lint-core.d.ts.map +0 -1
- package/dist/utils/lint-core.js.map +0 -1
- package/dist/utils/lint-utils.d.ts.map +0 -1
- package/dist/utils/lint-utils.js.map +0 -1
- package/dist/utils/lint-with-program.d.ts.map +0 -1
- package/dist/utils/lint-with-program.js.map +0 -1
- package/dist/utils/ngtsc-build-core.d.ts.map +0 -1
- package/dist/utils/ngtsc-build-core.js.map +0 -1
- package/dist/utils/rebuild-manager.d.ts.map +0 -1
- package/dist/utils/rebuild-manager.js.map +0 -1
- package/dist/utils/replace-deps.d.ts.map +0 -1
- package/dist/utils/replace-deps.js.map +0 -1
- package/dist/utils/scss-compiler.d.ts.map +0 -1
- package/dist/utils/scss-compiler.js.map +0 -1
- package/dist/utils/server-production-files.d.ts.map +0 -1
- package/dist/utils/server-production-files.js.map +0 -1
- package/dist/utils/typecheck-non-package.d.ts.map +0 -1
- package/dist/utils/typecheck-non-package.js.map +0 -1
- package/dist/utils/typecheck-serialization.d.ts.map +0 -1
- package/dist/utils/typecheck-serialization.js.map +0 -1
- package/dist/utils/vite-config.d.ts +0 -50
- package/dist/utils/vite-config.d.ts.map +0 -1
- package/dist/utils/vite-config.js +0 -242
- package/dist/utils/vite-config.js.map +0 -1
- package/dist/utils/vite-pwa-plugin.d.ts +0 -9
- package/dist/utils/vite-pwa-plugin.d.ts.map +0 -1
- package/dist/utils/vite-pwa-plugin.js +0 -139
- package/dist/utils/vite-pwa-plugin.js.map +0 -1
- package/dist/utils/vite-scope-watch-plugin.d.ts +0 -24
- package/dist/utils/vite-scope-watch-plugin.d.ts.map +0 -1
- package/dist/utils/vite-scope-watch-plugin.js +0 -51
- package/dist/utils/vite-scope-watch-plugin.js.map +0 -1
- package/dist/utils/worker-events.d.ts +0 -66
- package/dist/utils/worker-events.d.ts.map +0 -1
- package/dist/utils/worker-events.js +0 -55
- package/dist/utils/worker-events.js.map +0 -1
- package/dist/utils/worker-utils.d.ts.map +0 -1
- package/dist/utils/worker-utils.js.map +0 -1
- package/src/angular/vite-postcss-inline-plugin.ts +0 -139
- package/src/commands/publish.ts +0 -850
- package/src/orchestrators/DevWatchOrchestrator.ts +0 -594
- package/src/utils/hmr-candidates.ts +0 -327
- package/src/utils/vite-config.ts +0 -318
- package/src/utils/vite-pwa-plugin.ts +0 -168
- package/src/utils/vite-scope-watch-plugin.ts +0 -77
- package/src/utils/worker-events.ts +0 -128
- package/tests/angular/angular-compiler-hmr.spec.ts +0 -152
- package/tests/angular/hmr-candidates.spec.ts +0 -158
- package/tests/angular/linker-disk-cache.spec.ts +0 -171
- package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +0 -333
- package/tests/angular/vite-angular-plugin-hmr.spec.ts +0 -320
- package/tests/angular/vite-angular-plugin-scss-hmr.spec.ts +0 -95
- package/tests/angular/vite-postcss-inline-plugin.spec.ts +0 -60
- package/tests/engines/vite-engine.spec.ts +0 -409
- package/tests/orchestrators/dev-watch-orchestrator.spec.ts +0 -1542
- package/tests/utils/vite-config.spec.ts +0 -780
- package/tests/utils/vite-pwa-plugin.spec.ts +0 -401
- package/tests/utils/vite-scope-watch-plugin.spec.ts +0 -218
- package/tests/utils/worker-events.spec.ts +0 -147
- package/tests/workers/client-worker-legacy.spec.ts +0 -659
- /package/dist/{utils → angular}/ngtsc-build-core.js +0 -0
- /package/dist/{utils → angular}/scss-compiler.d.ts +0 -0
- /package/dist/{utils → angular}/scss-compiler.js +0 -0
- /package/dist/{utils → esbuild}/esbuild-config.d.ts +0 -0
- /package/dist/{utils → lint}/lint-core.d.ts +0 -0
- /package/dist/{utils → lint}/lint-core.js +0 -0
- /package/dist/{utils → lint}/lint-utils.d.ts +0 -0
- /package/dist/{utils → lint}/lint-utils.js +0 -0
- /package/dist/{utils → lint}/lint-with-program.d.ts +0 -0
- /package/dist/{utils → lint}/lint-with-program.js +0 -0
- /package/dist/{infra → runtime}/ResultCollector.d.ts +0 -0
- /package/dist/{infra → runtime}/ResultCollector.js +0 -0
- /package/dist/{infra → runtime}/SignalHandler.d.ts +0 -0
- /package/dist/{infra → runtime}/SignalHandler.js +0 -0
- /package/dist/{utils → runtime}/worker-utils.d.ts +0 -0
- /package/dist/{utils → runtime}/worker-utils.js +0 -0
- /package/dist/{utils → typecheck}/typecheck-non-package.d.ts +0 -0
- /package/dist/{utils → typecheck}/typecheck-serialization.d.ts +0 -0
- /package/dist/{utils → typecheck}/typecheck-serialization.js +0 -0
- /package/src/{utils → angular}/scss-compiler.ts +0 -0
- /package/src/{utils → lint}/lint-core.ts +0 -0
- /package/src/{utils → lint}/lint-utils.ts +0 -0
- /package/src/{utils → lint}/lint-with-program.ts +0 -0
- /package/src/{infra → runtime}/ResultCollector.ts +0 -0
- /package/src/{infra → runtime}/SignalHandler.ts +0 -0
- /package/src/{utils → runtime}/worker-utils.ts +0 -0
- /package/src/{utils → typecheck}/typecheck-serialization.ts +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import esbuild from "esbuild";
|
|
4
|
+
import browserslistToEsbuild from "browserslist-to-esbuild";
|
|
5
|
+
import {
|
|
6
|
+
createCompilerPlugin,
|
|
7
|
+
SourceFileCache,
|
|
8
|
+
type CompilerPluginOptions,
|
|
9
|
+
type BundleStylesheetOptions,
|
|
10
|
+
} from "@angular/build/private";
|
|
11
|
+
import { createScssPlugin } from "./esbuild-scss-plugin";
|
|
12
|
+
|
|
13
|
+
export interface CreateClientEsbuildOptions {
|
|
14
|
+
/** 패키지 디렉토리 경로 */
|
|
15
|
+
pkgDir: string;
|
|
16
|
+
/** 모노레포 루트 (workspaceRoot) */
|
|
17
|
+
cwd: string;
|
|
18
|
+
/** 빌드 모드 */
|
|
19
|
+
mode: "dev" | "build";
|
|
20
|
+
/** tsconfig 경로 (기본: pkgDir/tsconfig.json) */
|
|
21
|
+
tsconfig?: string;
|
|
22
|
+
/** 빌드 시 치환할 환경변수 */
|
|
23
|
+
env?: Record<string, string>;
|
|
24
|
+
/** 추가 esbuild 플러그인 (Feature 1.1b에서 사용) */
|
|
25
|
+
plugins?: esbuild.Plugin[];
|
|
26
|
+
/** HMR용 templateUpdates Map (Feature 2.2에서 사용) */
|
|
27
|
+
templateUpdates?: Map<string, string>;
|
|
28
|
+
/** watch 모드 빌드 완료 콜백 */
|
|
29
|
+
onEnd?: (result: esbuild.BuildResult) => void | Promise<void>;
|
|
30
|
+
/** PostCSS 플러그인 ([name, options] 튜플 배열) */
|
|
31
|
+
postcssPlugins?: [string, (object | string)?][];
|
|
32
|
+
/** PostCSS 설정 기준 경로 */
|
|
33
|
+
postcssConfigPath?: string;
|
|
34
|
+
/** 빌드 출력 경로 (기본: pkgDir/dist) */
|
|
35
|
+
outdir?: string;
|
|
36
|
+
/** browserslist 쿼리. 미설정 시 "es2022" 기본값 */
|
|
37
|
+
browserslist?: string | string[];
|
|
38
|
+
/** polyfills 경로 (pkgDir 기준 상대경로, 예: ["src/polyfills.ts"]). entryPoints에 추가됨 */
|
|
39
|
+
polyfills?: string[];
|
|
40
|
+
/** 레거시 모듈 지원 (코드 분할 비활성화 + import.meta 치환 + 잔여 import() 제거) */
|
|
41
|
+
legacyModule?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ClientEsbuildResult {
|
|
45
|
+
context: esbuild.BuildContext;
|
|
46
|
+
sourceFileCache: InstanceType<typeof SourceFileCache>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function createClientEsbuildContext(
|
|
50
|
+
options: CreateClientEsbuildOptions,
|
|
51
|
+
): Promise<ClientEsbuildResult> {
|
|
52
|
+
const isDev = options.mode === "dev";
|
|
53
|
+
|
|
54
|
+
// browserslist → esbuild target 변환
|
|
55
|
+
let esbuildTarget: string[] = ["es2022"];
|
|
56
|
+
if (options.browserslist != null) {
|
|
57
|
+
const queries = Array.isArray(options.browserslist)
|
|
58
|
+
? options.browserslist
|
|
59
|
+
: [options.browserslist];
|
|
60
|
+
esbuildTarget = browserslistToEsbuild(queries);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// SourceFileCache 생성 (LMDB 디스크 캐시)
|
|
64
|
+
const cachePath = path.join(options.pkgDir, ".angular", "cache");
|
|
65
|
+
const sourceFileCache = new SourceFileCache(cachePath);
|
|
66
|
+
|
|
67
|
+
// CompilerPluginOptions
|
|
68
|
+
const pluginOptions: CompilerPluginOptions & { browserOnlyBuild?: boolean } = {
|
|
69
|
+
tsconfig: options.tsconfig ?? path.join(options.pkgDir, "tsconfig.json"),
|
|
70
|
+
sourcemap: isDev,
|
|
71
|
+
advancedOptimizations: !isDev,
|
|
72
|
+
thirdPartySourcemaps: isDev,
|
|
73
|
+
incremental: true,
|
|
74
|
+
sourceFileCache,
|
|
75
|
+
loadResultCache: sourceFileCache.loadResultCache,
|
|
76
|
+
templateUpdates: options.templateUpdates,
|
|
77
|
+
browserOnlyBuild: true,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// BundleStylesheetOptions
|
|
81
|
+
const styleOptions: BundleStylesheetOptions & { inlineStyleLanguage: string } = {
|
|
82
|
+
workspaceRoot: options.cwd,
|
|
83
|
+
optimization: !isDev,
|
|
84
|
+
inlineFonts: false,
|
|
85
|
+
sourcemap: isDev ? "linked" : false,
|
|
86
|
+
outputNames: { bundles: "[name]", media: "media/[name]" },
|
|
87
|
+
includePaths: [],
|
|
88
|
+
target: esbuildTarget,
|
|
89
|
+
cacheOptions: {
|
|
90
|
+
enabled: true,
|
|
91
|
+
path: cachePath,
|
|
92
|
+
basePath: cachePath,
|
|
93
|
+
},
|
|
94
|
+
postcssConfiguration:
|
|
95
|
+
options.postcssPlugins != null
|
|
96
|
+
? {
|
|
97
|
+
config: { plugins: options.postcssPlugins },
|
|
98
|
+
configPath: options.postcssConfigPath ?? options.pkgDir,
|
|
99
|
+
}
|
|
100
|
+
: undefined,
|
|
101
|
+
inlineStyleLanguage: "scss",
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const angularPlugin = createCompilerPlugin(pluginOptions, styleOptions);
|
|
105
|
+
|
|
106
|
+
// SCSS side-effect import 처리 플러그인
|
|
107
|
+
const scssPlugin = createScssPlugin({
|
|
108
|
+
loadPaths: [
|
|
109
|
+
path.join(options.pkgDir, "scss"),
|
|
110
|
+
path.join(options.cwd, "node_modules"),
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// define 주입
|
|
115
|
+
const define: Record<string, string> = {};
|
|
116
|
+
|
|
117
|
+
// Angular 플래그
|
|
118
|
+
if (!isDev) {
|
|
119
|
+
define["ngDevMode"] = "false";
|
|
120
|
+
}
|
|
121
|
+
define["ngJitMode"] = "false";
|
|
122
|
+
if (isDev && options.templateUpdates != null && options.legacyModule !== true) {
|
|
123
|
+
define["ngHmrMode"] = "true";
|
|
124
|
+
} else if (!isDev) {
|
|
125
|
+
define["ngHmrMode"] = "false";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 커스텀 env
|
|
129
|
+
if (options.env != null) {
|
|
130
|
+
for (const [key, value] of Object.entries(options.env)) {
|
|
131
|
+
define[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// import.meta.hot 폴리필 banner (Angular HMR 런타임용)
|
|
136
|
+
// Angular의 compileHmrInitializer가 import.meta.hot.on('angular:component-update', ...)을 사용.
|
|
137
|
+
// Vite 없이 동작하도록 import.meta.hot을 폴리필하고, globalThis.__hmr_dispatch로 외부 트리거 제공.
|
|
138
|
+
const hmrBanner =
|
|
139
|
+
options.templateUpdates != null && options.legacyModule !== true
|
|
140
|
+
? [
|
|
141
|
+
'if(typeof ngHmrMode!=="undefined"&&ngHmrMode){(function(){',
|
|
142
|
+
"var _l={};",
|
|
143
|
+
"import.meta.hot={on:function(e,c){if(!_l[e])_l[e]=[];_l[e].push(c);},off:function(e,c){var a=_l[e];if(a){var i=a.indexOf(c);if(i!==-1)a.splice(i,1);}}};",
|
|
144
|
+
"globalThis.__hmr_dispatch=function(e,d){var a=_l[e];if(a)for(var i=0;i<a.length;i++)a[i](d);};",
|
|
145
|
+
"})()}",
|
|
146
|
+
].join("")
|
|
147
|
+
: undefined;
|
|
148
|
+
|
|
149
|
+
// esbuild context 생성
|
|
150
|
+
const context = await esbuild.context({
|
|
151
|
+
entryPoints: [
|
|
152
|
+
path.join(options.pkgDir, "src", "main.ts"),
|
|
153
|
+
...(options.polyfills != null
|
|
154
|
+
? options.polyfills.map((p) => path.join(options.pkgDir, p))
|
|
155
|
+
: []),
|
|
156
|
+
],
|
|
157
|
+
target: esbuildTarget,
|
|
158
|
+
entryNames: isDev ? "[name]" : "[name]-[hash]",
|
|
159
|
+
chunkNames: isDev ? "[name]" : "[name]-[hash]",
|
|
160
|
+
assetNames: isDev ? "[name]" : "[name]-[hash]",
|
|
161
|
+
bundle: true,
|
|
162
|
+
splitting: options.legacyModule !== true,
|
|
163
|
+
format: "esm",
|
|
164
|
+
platform: "browser",
|
|
165
|
+
outdir: options.outdir ?? path.join(options.pkgDir, "dist"),
|
|
166
|
+
metafile: true,
|
|
167
|
+
write: true,
|
|
168
|
+
sourcemap: isDev ? "linked" : false,
|
|
169
|
+
logLevel: "silent",
|
|
170
|
+
tsconfig: options.tsconfig ?? path.join(options.pkgDir, "tsconfig.json"),
|
|
171
|
+
define,
|
|
172
|
+
banner: hmrBanner != null ? { js: hmrBanner } : undefined,
|
|
173
|
+
...(options.legacyModule === true ? { supported: { "import-meta": false } } : {}),
|
|
174
|
+
plugins: [
|
|
175
|
+
...(options.templateUpdates != null
|
|
176
|
+
? [
|
|
177
|
+
{
|
|
178
|
+
name: "sd-hmr-reset",
|
|
179
|
+
setup(build: esbuild.PluginBuild) {
|
|
180
|
+
build.onStart(() => {
|
|
181
|
+
options.templateUpdates!.clear();
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
]
|
|
186
|
+
: []),
|
|
187
|
+
angularPlugin,
|
|
188
|
+
scssPlugin,
|
|
189
|
+
...(options.plugins ?? []),
|
|
190
|
+
...(options.legacyModule === true
|
|
191
|
+
? [
|
|
192
|
+
{
|
|
193
|
+
name: "sd-legacy-strip-dynamic-import",
|
|
194
|
+
setup(build: esbuild.PluginBuild) {
|
|
195
|
+
build.onEnd(async (result) => {
|
|
196
|
+
if (result.metafile == null) return;
|
|
197
|
+
const jsFiles = Object.keys(result.metafile.outputs).filter((f) =>
|
|
198
|
+
f.endsWith(".js"),
|
|
199
|
+
);
|
|
200
|
+
for (const file of jsFiles) {
|
|
201
|
+
const code = await fs.promises.readFile(file, "utf-8");
|
|
202
|
+
if (!code.includes("import(")) continue;
|
|
203
|
+
const replaced = code.replace(
|
|
204
|
+
/\bimport\s*\(/g,
|
|
205
|
+
'(function(){return Promise.reject(new Error("Dynamic import not supported"))})(',
|
|
206
|
+
);
|
|
207
|
+
await fs.promises.writeFile(file, replaced);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
: []),
|
|
214
|
+
...(options.onEnd != null
|
|
215
|
+
? [
|
|
216
|
+
{
|
|
217
|
+
name: "sd-on-end",
|
|
218
|
+
setup(build: esbuild.PluginBuild) {
|
|
219
|
+
build.onEnd((result) => {
|
|
220
|
+
return options.onEnd!(result);
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
]
|
|
225
|
+
: []),
|
|
226
|
+
],
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return { context, sourceFileCache };
|
|
230
|
+
}
|
|
@@ -85,6 +85,7 @@ export function createServerEsbuildOptions(options: ServerEsbuildOptions): esbui
|
|
|
85
85
|
outdir: path.join(options.pkgDir, "dist"),
|
|
86
86
|
format: "esm",
|
|
87
87
|
minify: options.dev !== true,
|
|
88
|
+
sourcemap: options.dev === true ? "linked" : undefined,
|
|
88
89
|
platform: "node",
|
|
89
90
|
target: "node20",
|
|
90
91
|
bundle: true,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type esbuild from "esbuild";
|
|
2
|
+
import {
|
|
3
|
+
IndexHtmlGenerator,
|
|
4
|
+
type IndexHtmlTransform,
|
|
5
|
+
} from "@angular/build/private";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
/** metafile.outputs에서 추출된 파일 정보 (IndexHtmlGenerator.FileInfo 호환) */
|
|
9
|
+
export interface FileInfo {
|
|
10
|
+
file: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
extension: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface GenerateIndexHtmlOptions {
|
|
16
|
+
/** src/index.html 경로 */
|
|
17
|
+
indexPath: string;
|
|
18
|
+
/** esbuild 빌드 결과 metafile */
|
|
19
|
+
metafile: esbuild.Metafile;
|
|
20
|
+
/** 출력 디렉토리 (dist/) */
|
|
21
|
+
outdir: string;
|
|
22
|
+
/** <base href> (기본: "/") */
|
|
23
|
+
baseHref?: string;
|
|
24
|
+
/** 빌드 모드 */
|
|
25
|
+
mode: "dev" | "build";
|
|
26
|
+
/** entryPoints의 이름 목록 (main, polyfills 등) */
|
|
27
|
+
entryNames: string[];
|
|
28
|
+
/** HTML 후처리 훅 (HMR 스크립트 주입용) */
|
|
29
|
+
postTransform?: IndexHtmlTransform;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface GenerateIndexHtmlResult {
|
|
33
|
+
content: string;
|
|
34
|
+
warnings: string[];
|
|
35
|
+
errors: string[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* esbuild metafile.outputs에서 JS/CSS 파일을 추출하여 FileInfo[] 로 변환한다.
|
|
40
|
+
*/
|
|
41
|
+
export function extractFilesFromMetafile(
|
|
42
|
+
metafile: esbuild.Metafile,
|
|
43
|
+
outdir: string,
|
|
44
|
+
): FileInfo[] {
|
|
45
|
+
const files: FileInfo[] = [];
|
|
46
|
+
const normalizedOutdir = outdir.replace(/\\/g, "/");
|
|
47
|
+
|
|
48
|
+
// cssBundle → entry name 매핑 (JS entry의 cssBundle로 CSS에 name 전파)
|
|
49
|
+
const cssBundleToName = new Map<string, string>();
|
|
50
|
+
for (const output of Object.values(metafile.outputs)) {
|
|
51
|
+
if (output.entryPoint != null && output.cssBundle != null) {
|
|
52
|
+
const name = path.basename(output.entryPoint, path.extname(output.entryPoint));
|
|
53
|
+
cssBundleToName.set(output.cssBundle.replace(/\\/g, "/"), name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const [outputPath, output] of Object.entries(metafile.outputs)) {
|
|
58
|
+
const normalizedPath = outputPath.replace(/\\/g, "/");
|
|
59
|
+
const ext = path.extname(normalizedPath);
|
|
60
|
+
|
|
61
|
+
if (ext !== ".js" && ext !== ".css") {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const relativePath = normalizedPath.startsWith(normalizedOutdir)
|
|
66
|
+
? normalizedPath.slice(normalizedOutdir.length).replace(/^\//, "")
|
|
67
|
+
: path.relative(normalizedOutdir, normalizedPath).replace(/\\/g, "/");
|
|
68
|
+
|
|
69
|
+
const fileInfo: FileInfo = {
|
|
70
|
+
file: relativePath,
|
|
71
|
+
extension: ext,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (output.entryPoint != null) {
|
|
75
|
+
fileInfo.name = path.basename(output.entryPoint, path.extname(output.entryPoint));
|
|
76
|
+
} else if (ext === ".css") {
|
|
77
|
+
const cssName = cssBundleToName.get(normalizedPath);
|
|
78
|
+
if (cssName != null) {
|
|
79
|
+
fileInfo.name = cssName;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
files.push(fileInfo);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return files;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* esbuild 빌드 결과를 기반으로 index.html을 생성한다.
|
|
91
|
+
* IndexHtmlGenerator(@angular/build/private)를 활용하여 script/link 태그를 자동 주입한다.
|
|
92
|
+
*/
|
|
93
|
+
export async function generateIndexHtml(
|
|
94
|
+
options: GenerateIndexHtmlOptions,
|
|
95
|
+
): Promise<GenerateIndexHtmlResult> {
|
|
96
|
+
const files = extractFilesFromMetafile(options.metafile, options.outdir);
|
|
97
|
+
|
|
98
|
+
const entrypoints: [string, boolean][] = options.entryNames.map((name) => [name, true]);
|
|
99
|
+
|
|
100
|
+
const generator = new IndexHtmlGenerator({
|
|
101
|
+
indexPath: options.indexPath,
|
|
102
|
+
entrypoints,
|
|
103
|
+
sri: options.mode === "build",
|
|
104
|
+
postTransform: options.postTransform,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const result = await generator.process({
|
|
108
|
+
lang: undefined,
|
|
109
|
+
baseHref: options.baseHref,
|
|
110
|
+
outputPath: options.outdir,
|
|
111
|
+
files,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
content: result.csrContent,
|
|
116
|
+
warnings: result.warnings,
|
|
117
|
+
errors: result.errors,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { IndexHtmlTransform } from "@angular/build/private";
|
|
2
|
+
import type { SdPwaConfig } from "../sd-config.types.js";
|
|
3
|
+
import { augmentAppWithServiceWorker } from "@angular/build/private";
|
|
4
|
+
import { generatePwaIcons } from "../utils/generate-pwa-icons.js";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
export interface ApplyPwaOptions {
|
|
9
|
+
/** 패키지 디렉토리 경로 */
|
|
10
|
+
pkgDir: string;
|
|
11
|
+
/** 패키지 표시명 */
|
|
12
|
+
pkgName: string;
|
|
13
|
+
/** 모노레포 루트 (workspaceRoot) */
|
|
14
|
+
cwd: string;
|
|
15
|
+
/** 빌드 출력 디렉토리 (dist/) */
|
|
16
|
+
outdir: string;
|
|
17
|
+
/** base href (기본: "/") */
|
|
18
|
+
baseHref: string;
|
|
19
|
+
/** 빌드 모드 */
|
|
20
|
+
mode: "dev" | "build";
|
|
21
|
+
/** PWA 설정. false이면 비활성화 */
|
|
22
|
+
pwa?: false | SdPwaConfig;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function createPwaHtmlTransform(): IndexHtmlTransform {
|
|
26
|
+
return (content: string) => {
|
|
27
|
+
const manifestLink = '<link rel="manifest" href="manifest.webmanifest">';
|
|
28
|
+
const registrationScript = `<script>${generateRegistrationScript()}</script>`;
|
|
29
|
+
|
|
30
|
+
content = content.replace("</head>", `${manifestLink}\n</head>`);
|
|
31
|
+
content = content.replace("</body>", `${registrationScript}\n</body>`);
|
|
32
|
+
|
|
33
|
+
return Promise.resolve(content);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function applyPwa(options: ApplyPwaOptions): Promise<void> {
|
|
38
|
+
if (options.mode !== "build") return;
|
|
39
|
+
if (options.pwa === false) return;
|
|
40
|
+
|
|
41
|
+
const pwaConfig = options.pwa ?? {};
|
|
42
|
+
|
|
43
|
+
// 1. Icons
|
|
44
|
+
let iconsField: Record<string, unknown> = {};
|
|
45
|
+
if (pwaConfig.manifest?.icons != null) {
|
|
46
|
+
iconsField = { icons: pwaConfig.manifest.icons };
|
|
47
|
+
} else {
|
|
48
|
+
const generated = await generatePwaIcons(options.pkgDir);
|
|
49
|
+
if (generated.length > 0) {
|
|
50
|
+
// Copy generated icons from public/icons/ to dist/icons/
|
|
51
|
+
const srcIconsDir = path.join(options.pkgDir, "public", "icons");
|
|
52
|
+
const dstIconsDir = path.join(options.outdir, "icons");
|
|
53
|
+
fs.mkdirSync(dstIconsDir, { recursive: true });
|
|
54
|
+
for (const icon of generated) {
|
|
55
|
+
const srcPath = path.join(srcIconsDir, path.basename(icon.src));
|
|
56
|
+
const dstPath = path.join(dstIconsDir, path.basename(icon.src));
|
|
57
|
+
fs.copyFileSync(srcPath, dstPath);
|
|
58
|
+
}
|
|
59
|
+
iconsField = { icons: generated };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 2. Manifest
|
|
64
|
+
const manifest = {
|
|
65
|
+
name: pwaConfig.manifest?.name ?? options.pkgName,
|
|
66
|
+
short_name: pwaConfig.manifest?.short_name ?? options.pkgName,
|
|
67
|
+
display: pwaConfig.manifest?.display ?? "standalone",
|
|
68
|
+
theme_color: pwaConfig.manifest?.theme_color ?? "#ffffff",
|
|
69
|
+
background_color: pwaConfig.manifest?.background_color ?? "#ffffff",
|
|
70
|
+
start_url: ".",
|
|
71
|
+
scope: ".",
|
|
72
|
+
...iconsField,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
fs.writeFileSync(
|
|
76
|
+
path.join(options.outdir, "manifest.webmanifest"),
|
|
77
|
+
JSON.stringify(manifest, null, 2),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// 3. Ensure ngsw-config.json exists
|
|
81
|
+
const ngswConfigPath = path.join(options.pkgDir, "ngsw-config.json");
|
|
82
|
+
if (!fs.existsSync(ngswConfigPath)) {
|
|
83
|
+
const defaultConfig = {
|
|
84
|
+
$schema: "./node_modules/@angular/service-worker/config/schema.json",
|
|
85
|
+
index: "/index.html",
|
|
86
|
+
assetGroups: [
|
|
87
|
+
{
|
|
88
|
+
name: "app",
|
|
89
|
+
installMode: "prefetch",
|
|
90
|
+
resources: {
|
|
91
|
+
files: ["/*.html", "/*.css", "/*.js"],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "assets",
|
|
96
|
+
installMode: "lazy",
|
|
97
|
+
updateMode: "prefetch",
|
|
98
|
+
resources: {
|
|
99
|
+
files: ["/**/*.{png,jpg,svg,ico,woff2,webmanifest}"],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
fs.writeFileSync(ngswConfigPath, JSON.stringify(defaultConfig, null, 2) + "\n");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 4. augmentAppWithServiceWorker
|
|
108
|
+
await augmentAppWithServiceWorker(
|
|
109
|
+
options.pkgDir,
|
|
110
|
+
options.cwd,
|
|
111
|
+
options.outdir,
|
|
112
|
+
options.baseHref,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function generateRegistrationScript(): string {
|
|
117
|
+
return `(function(){
|
|
118
|
+
if(!("serviceWorker" in navigator))return;
|
|
119
|
+
navigator.serviceWorker.register("ngsw-worker.js").then(function(reg){
|
|
120
|
+
if(reg.waiting){d(reg.waiting);return}
|
|
121
|
+
reg.addEventListener("updatefound",function(){
|
|
122
|
+
var w=reg.installing;
|
|
123
|
+
if(!w)return;
|
|
124
|
+
w.addEventListener("statechange",function(){
|
|
125
|
+
if(w.state==="installed"&&navigator.serviceWorker.controller)d(w);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
var r=false;
|
|
130
|
+
navigator.serviceWorker.addEventListener("controllerchange",function(){
|
|
131
|
+
if(!r){r=true;window.location.reload()}
|
|
132
|
+
});
|
|
133
|
+
function d(w){
|
|
134
|
+
window.dispatchEvent(new CustomEvent("sd-pwa-update-ready",{
|
|
135
|
+
detail:{update:function(){w.postMessage({type:"SKIP_WAITING"})}}
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
})();`;
|
|
139
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type esbuild from "esbuild";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { compileScssFileAsync } from "../angular/scss-compiler";
|
|
4
|
+
|
|
5
|
+
export interface CreateScssPluginOptions {
|
|
6
|
+
loadPaths: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function createScssPlugin(options: CreateScssPluginOptions): esbuild.Plugin {
|
|
10
|
+
return {
|
|
11
|
+
name: "sd-scss",
|
|
12
|
+
setup(build) {
|
|
13
|
+
build.onLoad({ filter: /\.scss$/ }, async (args) => {
|
|
14
|
+
try {
|
|
15
|
+
const result = await compileScssFileAsync(args.path, options.loadPaths);
|
|
16
|
+
return {
|
|
17
|
+
contents: result.css,
|
|
18
|
+
loader: "css" as const,
|
|
19
|
+
watchFiles: result.dependencies,
|
|
20
|
+
};
|
|
21
|
+
} catch (e: unknown) {
|
|
22
|
+
// sass.Exception은 span 프로퍼티로 위치 정보를 제공한다
|
|
23
|
+
const sassSpan = (e as any)?.span;
|
|
24
|
+
const location: esbuild.PartialMessage["location"] =
|
|
25
|
+
sassSpan != null
|
|
26
|
+
? {
|
|
27
|
+
file:
|
|
28
|
+
sassSpan.url != null
|
|
29
|
+
? fileURLToPath(sassSpan.url)
|
|
30
|
+
: args.path,
|
|
31
|
+
line: sassSpan.start.line + 1, // sass: 0-based → esbuild: 1-based
|
|
32
|
+
column: sassSpan.start.column,
|
|
33
|
+
}
|
|
34
|
+
: undefined;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
errors: [
|
|
38
|
+
{
|
|
39
|
+
text: (e as any)?.sassMessage ?? (e instanceof Error ? e.message : String(e)),
|
|
40
|
+
location,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { consola, type ConsolaInstance } from "consola";
|
|
2
|
+
import type { SdConfig } from "../sd-config.types";
|
|
3
|
+
import { loadSdConfig } from "../utils/sd-config";
|
|
4
|
+
import { getVersion } from "../utils/build-env";
|
|
5
|
+
import { buildPathMapFromConfig, validateTargets } from "../utils/package-utils";
|
|
6
|
+
import { watchReplaceDeps, type WatchReplaceDepResult } from "../deps/replace-deps/replace-deps";
|
|
7
|
+
import { RebuildManager } from "../runtime/rebuild-manager";
|
|
8
|
+
import { ResultCollector } from "../runtime/ResultCollector";
|
|
9
|
+
import { SignalHandler } from "../runtime/SignalHandler";
|
|
10
|
+
/**
|
|
11
|
+
* Orchestrator 공통 기반 클래스
|
|
12
|
+
*
|
|
13
|
+
* sd.config.ts 로드, pathMap 구축, 대상 검증, replaceDeps 감시,
|
|
14
|
+
* 런타임(SignalHandler, ResultCollector, RebuildManager) 초기화를 수행한다.
|
|
15
|
+
*
|
|
16
|
+
* 서브클래스(WatchOrchestrator, DevOrchestrator)가 OrchestratorLifecycle을 implements한다.
|
|
17
|
+
* BaseOrchestrator.initialize()는 params를 받으므로 인터페이스와 직접 호환되지 않으며,
|
|
18
|
+
* 서브클래스가 parameterless override를 제공한다.
|
|
19
|
+
*/
|
|
20
|
+
export abstract class BaseOrchestrator {
|
|
21
|
+
protected readonly _cwd: string;
|
|
22
|
+
protected readonly _logger: ConsolaInstance;
|
|
23
|
+
|
|
24
|
+
// 런타임
|
|
25
|
+
protected _resultCollector!: ResultCollector;
|
|
26
|
+
protected _signalHandler!: SignalHandler;
|
|
27
|
+
protected _rebuildManager!: RebuildManager;
|
|
28
|
+
|
|
29
|
+
// 공통 상태
|
|
30
|
+
protected _pathMap = new Map<string, string>();
|
|
31
|
+
protected _baseEnv!: { VER: string; DEV: string };
|
|
32
|
+
protected _replaceDeps: Record<string, string> | undefined;
|
|
33
|
+
protected _replaceDepWatcher: WatchReplaceDepResult | undefined;
|
|
34
|
+
protected _hasPackages = false;
|
|
35
|
+
|
|
36
|
+
constructor(logTag: string) {
|
|
37
|
+
this._cwd = process.cwd();
|
|
38
|
+
this._logger = consola.withTag(logTag);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async initialize(params: {
|
|
42
|
+
targets: string[];
|
|
43
|
+
options: string[];
|
|
44
|
+
dev: boolean;
|
|
45
|
+
}): Promise<void> {
|
|
46
|
+
this._logger.debug(`시작`, { targets: params.targets });
|
|
47
|
+
|
|
48
|
+
// 1. sd.config.ts 로드
|
|
49
|
+
let sdConfig: SdConfig;
|
|
50
|
+
try {
|
|
51
|
+
sdConfig = await loadSdConfig({
|
|
52
|
+
cwd: this._cwd,
|
|
53
|
+
dev: params.dev,
|
|
54
|
+
opt: params.options,
|
|
55
|
+
});
|
|
56
|
+
this._logger.debug("sd.config.ts 로드 완료");
|
|
57
|
+
} catch (err) {
|
|
58
|
+
this._logger.error(`sd.config.ts 로드 실패: ${err instanceof Error ? err.message : err}`);
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 2. pathMap 구축
|
|
64
|
+
this._pathMap = buildPathMapFromConfig(sdConfig.packages);
|
|
65
|
+
|
|
66
|
+
// 3. 대상 유효성 검사
|
|
67
|
+
validateTargets(params.targets, sdConfig.packages);
|
|
68
|
+
|
|
69
|
+
// 4. 환경변수 준비 (VER, DEV)
|
|
70
|
+
const version = await getVersion(this._cwd);
|
|
71
|
+
this._baseEnv = { VER: version, DEV: params.dev ? "true" : "false" };
|
|
72
|
+
|
|
73
|
+
// 5. replaceDeps 저장 + watch 시작
|
|
74
|
+
this._replaceDeps = sdConfig.replaceDeps;
|
|
75
|
+
if (sdConfig.replaceDeps != null) {
|
|
76
|
+
this._replaceDepWatcher = await watchReplaceDeps(this._cwd, sdConfig.replaceDeps);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 6. 서브클래스 초기화 (패키지 분류, 엔진 생성 등)
|
|
80
|
+
await this._initializeMode(sdConfig, params.targets);
|
|
81
|
+
|
|
82
|
+
// 7. 패키지 유무 확인 후 런타임 초기화
|
|
83
|
+
if (!this._hasPackages) return;
|
|
84
|
+
this._signalHandler = new SignalHandler();
|
|
85
|
+
this._resultCollector = new ResultCollector();
|
|
86
|
+
this._rebuildManager = new RebuildManager(this._logger);
|
|
87
|
+
|
|
88
|
+
// 8. 런타임 의존 초기화 (엔진 생성 등)
|
|
89
|
+
await this._initializeEngines(sdConfig);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
abstract start(): Promise<void>;
|
|
93
|
+
|
|
94
|
+
async awaitTermination(): Promise<void> {
|
|
95
|
+
if (!this._hasPackages) return;
|
|
96
|
+
await this._signalHandler.waitForTermination();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async shutdown(): Promise<void> {
|
|
100
|
+
// replaceDepWatcher는 항상 정리 (initialize 부분 실패 대응)
|
|
101
|
+
this._replaceDepWatcher?.dispose();
|
|
102
|
+
this._replaceDepWatcher = undefined;
|
|
103
|
+
|
|
104
|
+
if (!this._hasPackages) return;
|
|
105
|
+
process.stdout.write("⏳ 종료 중...\n");
|
|
106
|
+
await this._shutdownMode();
|
|
107
|
+
process.stdout.write("✔ 종료 완료\n");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected abstract _initializeMode(
|
|
111
|
+
config: SdConfig,
|
|
112
|
+
targets: string[],
|
|
113
|
+
): Promise<void> | void;
|
|
114
|
+
|
|
115
|
+
protected abstract _initializeEngines(config: SdConfig): Promise<void> | void;
|
|
116
|
+
|
|
117
|
+
protected abstract _shutdownMode(): Promise<void>;
|
|
118
|
+
}
|