@simplysm/sd-cli 13.0.100 → 14.0.1
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/commands/build.js +29 -19
- package/dist/commands/build.js.map +1 -6
- package/dist/commands/check.d.ts +1 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +130 -115
- package/dist/commands/check.js.map +1 -6
- package/dist/commands/dev.d.ts +6 -7
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +24 -14
- package/dist/commands/dev.js.map +1 -6
- package/dist/commands/lint.d.ts +1 -1
- package/dist/commands/lint.js +158 -116
- package/dist/commands/lint.js.map +1 -6
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +637 -510
- package/dist/commands/publish.js.map +1 -6
- package/dist/commands/replace-deps.js +12 -12
- package/dist/commands/replace-deps.js.map +1 -6
- package/dist/commands/typecheck.d.ts +5 -30
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +144 -207
- package/dist/commands/typecheck.js.map +1 -6
- package/dist/commands/watch.d.ts +6 -4
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +25 -16
- package/dist/commands/watch.js.map +1 -6
- package/dist/engines/NgtscEngine.d.ts +47 -0
- package/dist/engines/NgtscEngine.d.ts.map +1 -0
- package/dist/engines/NgtscEngine.js +151 -0
- package/dist/engines/NgtscEngine.js.map +1 -0
- package/dist/engines/ServerEsbuildEngine.d.ts +47 -0
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -0
- package/dist/engines/ServerEsbuildEngine.js +159 -0
- package/dist/engines/ServerEsbuildEngine.js.map +1 -0
- package/dist/engines/TscEngine.d.ts +47 -0
- package/dist/engines/TscEngine.d.ts.map +1 -0
- package/dist/engines/TscEngine.js +153 -0
- package/dist/engines/TscEngine.js.map +1 -0
- package/dist/engines/ViteEngine.d.ts +49 -0
- package/dist/engines/ViteEngine.d.ts.map +1 -0
- package/dist/engines/ViteEngine.js +161 -0
- package/dist/engines/ViteEngine.js.map +1 -0
- package/dist/engines/index.d.ts +26 -0
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/engines/index.js +30 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/engines/types.d.ts +77 -0
- package/dist/engines/types.d.ts.map +1 -0
- package/dist/engines/types.js +2 -0
- package/dist/engines/types.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -6
- package/dist/infra/ResultCollector.d.ts +1 -1
- package/dist/infra/ResultCollector.d.ts.map +1 -1
- package/dist/infra/ResultCollector.js +30 -27
- package/dist/infra/ResultCollector.js.map +1 -6
- package/dist/infra/SignalHandler.js +45 -42
- package/dist/infra/SignalHandler.js.map +1 -6
- package/dist/infra/WorkerManager.js +56 -53
- package/dist/infra/WorkerManager.js.map +1 -6
- package/dist/orchestrators/BuildOrchestrator.d.ts +33 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +314 -309
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -6
- package/dist/orchestrators/DevWatchOrchestrator.d.ts +60 -0
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +1 -0
- package/dist/orchestrators/DevWatchOrchestrator.js +465 -0
- package/dist/orchestrators/DevWatchOrchestrator.js.map +1 -0
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +190 -266
- package/dist/sd-cli-entry.js.map +1 -6
- package/dist/sd-cli.js +77 -49
- package/dist/sd-cli.js.map +1 -6
- package/dist/sd-config.types.d.ts +2 -0
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/sd-config.types.js +2 -1
- package/dist/sd-config.types.js.map +1 -6
- package/dist/utils/angular-build.d.ts +77 -0
- package/dist/utils/angular-build.d.ts.map +1 -0
- package/dist/utils/angular-build.js +84 -0
- package/dist/utils/angular-build.js.map +1 -0
- package/dist/utils/build-env.js +9 -9
- package/dist/utils/build-env.js.map +1 -6
- package/dist/utils/concurrency.d.ts +15 -0
- package/dist/utils/concurrency.d.ts.map +1 -0
- package/dist/utils/concurrency.js +38 -0
- package/dist/utils/concurrency.js.map +1 -0
- package/dist/utils/copy-public.js +104 -87
- package/dist/utils/copy-public.js.map +1 -6
- package/dist/utils/copy-src.js +49 -35
- package/dist/utils/copy-src.js.map +1 -6
- package/dist/utils/esbuild-config.d.ts +0 -29
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +151 -218
- package/dist/utils/esbuild-config.js.map +1 -6
- package/dist/utils/ngtsc-build-core.d.ts +49 -0
- package/dist/utils/ngtsc-build-core.d.ts.map +1 -0
- package/dist/utils/ngtsc-build-core.js +250 -0
- package/dist/utils/ngtsc-build-core.js.map +1 -0
- package/dist/utils/output-path-rewriter.d.ts +23 -0
- package/dist/utils/output-path-rewriter.d.ts.map +1 -0
- package/dist/utils/output-path-rewriter.js +74 -0
- package/dist/utils/output-path-rewriter.js.map +1 -0
- package/dist/utils/output-utils.js +55 -40
- package/dist/utils/output-utils.js.map +1 -6
- package/dist/utils/package-utils.d.ts +8 -0
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +103 -73
- package/dist/utils/package-utils.js.map +1 -6
- package/dist/utils/rebuild-manager.js +41 -44
- package/dist/utils/rebuild-manager.js.map +1 -6
- package/dist/utils/replace-deps.js +283 -184
- package/dist/utils/replace-deps.js.map +1 -6
- package/dist/utils/scss-compiler.d.ts +10 -0
- package/dist/utils/scss-compiler.d.ts.map +1 -0
- package/dist/utils/scss-compiler.js +36 -0
- package/dist/utils/scss-compiler.js.map +1 -0
- package/dist/utils/sd-config.js +29 -19
- package/dist/utils/sd-config.js.map +1 -6
- package/dist/utils/tsc-build.d.ts +36 -0
- package/dist/utils/tsc-build.d.ts.map +1 -0
- package/dist/utils/tsc-build.js +130 -0
- package/dist/utils/tsc-build.js.map +1 -0
- package/dist/utils/tsconfig.d.ts +7 -26
- package/dist/utils/tsconfig.d.ts.map +1 -1
- package/dist/utils/tsconfig.js +39 -64
- package/dist/utils/tsconfig.js.map +1 -6
- package/dist/utils/typecheck-non-package.d.ts +18 -0
- package/dist/utils/typecheck-non-package.d.ts.map +1 -0
- package/dist/utils/typecheck-non-package.js +64 -0
- package/dist/utils/typecheck-non-package.js.map +1 -0
- package/dist/utils/typecheck-serialization.js +58 -40
- package/dist/utils/typecheck-serialization.js.map +1 -6
- package/dist/utils/worker-events.js +48 -40
- package/dist/utils/worker-events.js.map +1 -6
- package/dist/utils/worker-utils.js +48 -28
- package/dist/utils/worker-utils.js.map +1 -6
- package/dist/vitest-plugin.d.ts +9 -0
- package/dist/vitest-plugin.d.ts.map +1 -0
- package/dist/vitest-plugin.js +85 -0
- package/dist/vitest-plugin.js.map +1 -0
- package/dist/workers/library-build.worker.d.ts +54 -0
- package/dist/workers/library-build.worker.d.ts.map +1 -0
- package/dist/workers/library-build.worker.js +97 -0
- package/dist/workers/library-build.worker.js.map +1 -0
- package/dist/workers/lint.worker.js +9 -6
- package/dist/workers/lint.worker.js.map +1 -6
- package/dist/workers/ngtsc-build.worker.d.ts +23 -0
- package/dist/workers/ngtsc-build.worker.d.ts.map +1 -0
- package/dist/workers/ngtsc-build.worker.js +98 -0
- package/dist/workers/ngtsc-build.worker.js.map +1 -0
- package/dist/workers/{server.worker.d.ts → server-build.worker.d.ts} +39 -29
- package/dist/workers/server-build.worker.d.ts.map +1 -0
- package/dist/workers/server-build.worker.js +399 -0
- package/dist/workers/server-build.worker.js.map +1 -0
- package/dist/workers/server-runtime.worker.d.ts +3 -2
- package/dist/workers/server-runtime.worker.d.ts.map +1 -1
- package/dist/workers/server-runtime.worker.js +100 -95
- package/dist/workers/server-runtime.worker.js.map +1 -6
- package/dist/workers/vite-build.worker.d.ts +56 -0
- package/dist/workers/vite-build.worker.d.ts.map +1 -0
- package/dist/workers/vite-build.worker.js +167 -0
- package/dist/workers/vite-build.worker.js.map +1 -0
- package/package.json +10 -16
- package/src/commands/check.ts +21 -3
- package/src/commands/dev.ts +10 -8
- package/src/commands/lint.ts +1 -1
- package/src/commands/publish.ts +4 -0
- package/src/commands/typecheck.ts +89 -256
- package/src/commands/watch.ts +9 -8
- package/src/engines/NgtscEngine.ts +190 -0
- package/src/engines/ServerEsbuildEngine.ts +195 -0
- package/src/engines/TscEngine.ts +189 -0
- package/src/engines/ViteEngine.ts +203 -0
- package/src/engines/index.ts +49 -0
- package/src/engines/types.ts +79 -0
- package/src/index.ts +0 -3
- package/src/infra/ResultCollector.ts +1 -1
- package/src/orchestrators/BuildOrchestrator.ts +87 -157
- package/src/orchestrators/DevWatchOrchestrator.ts +573 -0
- package/src/sd-cli-entry.ts +13 -116
- package/src/sd-config.types.ts +2 -0
- package/src/utils/angular-build.ts +157 -0
- package/src/utils/concurrency.ts +43 -0
- package/src/utils/esbuild-config.ts +1 -122
- package/src/utils/ngtsc-build-core.ts +379 -0
- package/src/utils/output-path-rewriter.ts +82 -0
- package/src/utils/package-utils.ts +20 -0
- package/src/utils/scss-compiler.ts +58 -0
- package/src/utils/tsc-build.ts +175 -0
- package/src/utils/tsconfig.ts +27 -95
- package/src/utils/typecheck-non-package.ts +87 -0
- package/src/vitest-plugin.ts +118 -0
- package/src/workers/library-build.worker.ts +153 -0
- package/src/workers/ngtsc-build.worker.ts +146 -0
- package/src/workers/server-build.worker.ts +565 -0
- package/src/workers/server-runtime.worker.ts +17 -26
- package/src/workers/vite-build.worker.ts +252 -0
- package/tests/commands/check.spec.ts +276 -0
- package/tests/commands/dev.spec.ts +53 -0
- package/tests/commands/lint.spec.ts +243 -0
- package/tests/commands/publish.spec.ts +1159 -0
- package/tests/commands/typecheck.spec.ts +294 -0
- package/tests/commands/watch.spec.ts +53 -0
- package/tests/engines/engine-selection.spec.ts +247 -0
- package/tests/engines/ngtsc-engine.spec.ts +274 -0
- package/tests/engines/server-esbuild-engine.spec.ts +256 -0
- package/tests/engines/tsc-engine.spec.ts +213 -0
- package/tests/engines/vite-engine.spec.ts +358 -0
- package/tests/infra/result-collector.spec.ts +46 -0
- package/tests/infra/signal-handler.spec.ts +32 -0
- package/tests/infra/worker-manager.spec.ts +63 -0
- package/tests/orchestrators/build-orchestrator.spec.ts +772 -0
- package/tests/orchestrators/dev-watch-orchestrator.spec.ts +1173 -0
- package/tests/sd-cli-entry.spec.ts +49 -0
- package/tests/utils/angular-build.spec.ts +251 -0
- package/tests/utils/build-env.spec.ts +33 -0
- package/tests/utils/concurrency.spec.ts +65 -0
- package/tests/utils/copy-src.spec.ts +144 -0
- package/tests/utils/esbuild-config.spec.ts +186 -0
- package/tests/utils/external-modules.spec.ts +161 -0
- package/tests/utils/ngtsc-scss-refactor.spec.ts +66 -0
- package/tests/utils/output-path-rewriter.spec.ts +165 -0
- package/tests/utils/output-utils.spec.ts +104 -0
- package/tests/utils/package-utils.spec.ts +52 -0
- package/tests/utils/rebuild-manager.spec.ts +30 -27
- package/tests/utils/replace-deps.spec.ts +69 -0
- package/tests/utils/scss-compiler.spec.ts +131 -0
- package/tests/utils/sd-config.spec.ts +77 -0
- package/tests/utils/tsc-build.spec.ts +358 -0
- package/tests/utils/tsconfig-angular.spec.ts +71 -0
- package/tests/utils/typecheck-non-package.spec.ts +120 -0
- package/tests/utils/worker-events.spec.ts +155 -0
- package/tests/utils/worker-utils.spec.ts +43 -0
- package/tests/vitest-plugin-cwd.spec.ts +68 -0
- package/tests/vitest-plugin.spec.ts +103 -0
- package/tests/workers/library-build-worker.spec.ts +258 -0
- package/tests/workers/ngtsc-build-worker.spec.ts +187 -0
- package/tests/workers/server-build-worker.spec.ts +566 -0
- package/tests/workers/server-runtime-worker.spec.ts +251 -0
- package/README.md +0 -295
- package/dist/builders/BaseBuilder.d.ts +0 -88
- package/dist/builders/BaseBuilder.d.ts.map +0 -1
- package/dist/builders/BaseBuilder.js +0 -142
- package/dist/builders/BaseBuilder.js.map +0 -6
- package/dist/builders/DtsBuilder.d.ts +0 -22
- package/dist/builders/DtsBuilder.d.ts.map +0 -1
- package/dist/builders/DtsBuilder.js +0 -72
- package/dist/builders/DtsBuilder.js.map +0 -6
- package/dist/builders/LibraryBuilder.d.ts +0 -22
- package/dist/builders/LibraryBuilder.d.ts.map +0 -1
- package/dist/builders/LibraryBuilder.js +0 -85
- package/dist/builders/LibraryBuilder.js.map +0 -6
- package/dist/builders/types.d.ts +0 -55
- package/dist/builders/types.d.ts.map +0 -1
- package/dist/builders/types.js +0 -1
- package/dist/builders/types.js.map +0 -6
- package/dist/capacitor/capacitor.d.ts +0 -151
- package/dist/capacitor/capacitor.d.ts.map +0 -1
- package/dist/capacitor/capacitor.js +0 -694
- package/dist/capacitor/capacitor.js.map +0 -6
- package/dist/commands/device.d.ts +0 -22
- package/dist/commands/device.d.ts.map +0 -1
- package/dist/commands/device.js +0 -98
- package/dist/commands/device.js.map +0 -6
- package/dist/commands/init.d.ts +0 -14
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -72
- package/dist/commands/init.js.map +0 -6
- package/dist/electron/electron.d.ts +0 -84
- package/dist/electron/electron.d.ts.map +0 -1
- package/dist/electron/electron.js +0 -263
- package/dist/electron/electron.js.map +0 -6
- package/dist/orchestrators/DevOrchestrator.d.ts +0 -83
- package/dist/orchestrators/DevOrchestrator.d.ts.map +0 -1
- package/dist/orchestrators/DevOrchestrator.js +0 -540
- package/dist/orchestrators/DevOrchestrator.js.map +0 -6
- package/dist/orchestrators/WatchOrchestrator.d.ts +0 -57
- package/dist/orchestrators/WatchOrchestrator.d.ts.map +0 -1
- package/dist/orchestrators/WatchOrchestrator.js +0 -199
- package/dist/orchestrators/WatchOrchestrator.js.map +0 -6
- package/dist/utils/tailwind-config-deps.d.ts +0 -8
- package/dist/utils/tailwind-config-deps.d.ts.map +0 -1
- package/dist/utils/tailwind-config-deps.js +0 -82
- package/dist/utils/tailwind-config-deps.js.map +0 -6
- package/dist/utils/template.d.ts +0 -14
- package/dist/utils/template.d.ts.map +0 -1
- package/dist/utils/template.js +0 -33
- package/dist/utils/template.js.map +0 -6
- package/dist/utils/vite-config.d.ts +0 -35
- package/dist/utils/vite-config.d.ts.map +0 -1
- package/dist/utils/vite-config.js +0 -259
- package/dist/utils/vite-config.js.map +0 -6
- package/dist/workers/client.worker.d.ts +0 -83
- package/dist/workers/client.worker.d.ts.map +0 -1
- package/dist/workers/client.worker.js +0 -111
- package/dist/workers/client.worker.js.map +0 -6
- package/dist/workers/dts.worker.d.ts +0 -75
- package/dist/workers/dts.worker.d.ts.map +0 -1
- package/dist/workers/dts.worker.js +0 -270
- package/dist/workers/dts.worker.js.map +0 -6
- package/dist/workers/library.worker.d.ts +0 -75
- package/dist/workers/library.worker.d.ts.map +0 -1
- package/dist/workers/library.worker.js +0 -166
- package/dist/workers/library.worker.js.map +0 -6
- package/dist/workers/server.worker.d.ts.map +0 -1
- package/dist/workers/server.worker.js +0 -482
- package/dist/workers/server.worker.js.map +0 -6
- package/src/builders/BaseBuilder.ts +0 -218
- package/src/builders/DtsBuilder.ts +0 -92
- package/src/builders/LibraryBuilder.ts +0 -110
- package/src/builders/types.ts +0 -60
- package/src/capacitor/capacitor.ts +0 -931
- package/src/commands/device.ts +0 -140
- package/src/commands/init.ts +0 -113
- package/src/electron/electron.ts +0 -362
- package/src/orchestrators/DevOrchestrator.ts +0 -744
- package/src/orchestrators/WatchOrchestrator.ts +0 -277
- package/src/utils/tailwind-config-deps.ts +0 -98
- package/src/utils/template.ts +0 -56
- package/src/utils/vite-config.ts +0 -390
- package/src/workers/client.worker.ts +0 -250
- package/src/workers/dts.worker.ts +0 -453
- package/src/workers/library.worker.ts +0 -316
- package/src/workers/server.worker.ts +0 -734
- package/templates/init/.gitignore.hbs +0 -34
- package/templates/init/.npmrc.hbs +0 -1
- package/templates/init/.prettierignore +0 -1
- package/templates/init/.prettierrc.yaml +0 -12
- package/templates/init/eslint.config.ts +0 -15
- package/templates/init/mise.toml +0 -3
- package/templates/init/package.json.hbs +0 -32
- package/templates/init/packages/client-admin/index.html.hbs +0 -144
- package/templates/init/packages/client-admin/package.json.hbs +0 -27
- package/templates/init/packages/client-admin/public/assets/logo-landscape.png +0 -0
- package/templates/init/packages/client-admin/public/assets/logo.png +0 -0
- package/templates/init/packages/client-admin/public/favicon.ico +0 -0
- package/templates/init/packages/client-admin/src/App.tsx +0 -42
- package/templates/init/packages/client-admin/src/dev/DevDialog.tsx +0 -34
- package/templates/init/packages/client-admin/src/events/AuthChangeEvent.ts +0 -3
- package/templates/init/packages/client-admin/src/main.css +0 -4
- package/templates/init/packages/client-admin/src/main.tsx.hbs +0 -146
- package/templates/init/packages/client-admin/src/providers/AppServiceProvider.tsx.hbs +0 -103
- package/templates/init/packages/client-admin/src/providers/AppStructureProvider.tsx +0 -84
- package/templates/init/packages/client-admin/src/providers/AuthProvider.tsx.hbs +0 -96
- package/templates/init/packages/client-admin/src/providers/configureSharedData.ts.hbs +0 -67
- package/templates/init/packages/client-admin/src/views/auth/LoginView.tsx +0 -132
- package/templates/init/packages/client-admin/src/views/home/HomeView.tsx +0 -108
- package/templates/init/packages/client-admin/src/views/home/base/employee/EmployeeDetail.tsx.hbs +0 -243
- package/templates/init/packages/client-admin/src/views/home/base/employee/EmployeeSheet.tsx.hbs +0 -271
- package/templates/init/packages/client-admin/src/views/home/base/role-permission/RoleDetail.tsx.hbs +0 -146
- package/templates/init/packages/client-admin/src/views/home/base/role-permission/RolePermissionDetail.tsx.hbs +0 -121
- package/templates/init/packages/client-admin/src/views/home/base/role-permission/RolePermissionView.tsx +0 -52
- package/templates/init/packages/client-admin/src/views/home/base/role-permission/RoleSheet.tsx.hbs +0 -125
- package/templates/init/packages/client-admin/src/views/home/main/MainView.tsx.hbs +0 -13
- package/templates/init/packages/client-admin/src/views/home/my-info/MyInfoDetail.tsx.hbs +0 -241
- package/templates/init/packages/client-admin/src/views/home/system/system-log/SystemLogSheet.tsx.hbs +0 -169
- package/templates/init/packages/client-admin/src/views/not-found/NotFoundView.tsx +0 -15
- package/templates/init/packages/client-admin/tailwind.config.ts +0 -10
- package/templates/init/packages/db-main/package.json.hbs +0 -13
- package/templates/init/packages/db-main/src/MainDbContext.ts +0 -22
- package/templates/init/packages/db-main/src/dataLogExt.ts +0 -127
- package/templates/init/packages/db-main/src/index.ts +0 -14
- package/templates/init/packages/db-main/src/tables/base/Employee.ts +0 -24
- package/templates/init/packages/db-main/src/tables/base/EmployeeConfig.ts +0 -13
- package/templates/init/packages/db-main/src/tables/base/Role.ts +0 -9
- package/templates/init/packages/db-main/src/tables/base/RolePermission.ts +0 -13
- package/templates/init/packages/db-main/src/tables/system/_DataLog.ts +0 -19
- package/templates/init/packages/db-main/src/tables/system/_Log.ts +0 -16
- package/templates/init/packages/server/package.json.hbs +0 -20
- package/templates/init/packages/server/public-dev/dev//354/264/210/352/270/260/355/231/224.xlsx +0 -0
- package/templates/init/packages/server/src/index.ts +0 -4
- package/templates/init/packages/server/src/main.ts.hbs +0 -34
- package/templates/init/packages/server/src/services/AuthService.ts.hbs +0 -171
- package/templates/init/packages/server/src/services/DevService.ts.hbs +0 -94
- package/templates/init/packages/server/src/services/EmployeeService.ts.hbs +0 -122
- package/templates/init/packages/server/src/services/RoleService.ts.hbs +0 -59
- package/templates/init/pnpm-workspace.yaml +0 -15
- package/templates/init/sd.config.ts.hbs +0 -48
- package/templates/init/tsconfig.json.hbs +0 -39
- package/templates/init/vitest.config.ts +0 -36
- package/tests/capacitor-exclude.spec.ts +0 -78
- package/tests/capacitor.spec.ts +0 -49
- package/tests/copy-src.spec.ts +0 -50
- package/tests/electron-exclude.spec.ts +0 -61
- package/tests/get-compiler-options-for-package.spec.ts +0 -80
- package/tests/get-package-source-files.spec.ts +0 -139
- package/tests/get-types-from-package-json.spec.ts +0 -92
- package/tests/infra/ResultCollector.spec.ts +0 -30
- package/tests/infra/SignalHandler.spec.ts +0 -38
- package/tests/infra/WorkerManager.spec.ts +0 -63
- package/tests/load-ignore-patterns.spec.ts +0 -163
- package/tests/load-sd-config.spec.ts +0 -100
- package/tests/package-utils.spec.ts +0 -188
- package/tests/parse-root-tsconfig.spec.ts +0 -89
- package/tests/publish-config-narrowing.spec.ts +0 -20
- package/tests/replace-deps.spec.ts +0 -308
- package/tests/run-lint.spec.ts +0 -366
- package/tests/run-typecheck.spec.ts +0 -544
- package/tests/run-watch.spec.ts +0 -76
- package/tests/sd-cli.spec.ts +0 -265
- package/tests/sd-public-dev-plugin-mime.spec.ts +0 -19
- package/tests/tailwind-config-deps.spec.ts +0 -30
- package/tests/template.spec.ts +0 -70
- package/tests/vite-config-exclude.spec.ts +0 -35
- package/tests/vite-config-outdir.spec.ts +0 -38
- package/tests/write-changed-output-files.spec.ts +0 -97
package/src/commands/publish.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { env, json } 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 { validateTargets } from "../utils/package-utils";
|
|
10
11
|
import { execa } from "execa";
|
|
11
12
|
import { runBuild } from "./build";
|
|
12
13
|
import { parseWorkspaceGlobs } from "../utils/replace-deps";
|
|
@@ -491,6 +492,9 @@ export async function runPublish(options: PublishOptions): Promise<void> {
|
|
|
491
492
|
return;
|
|
492
493
|
}
|
|
493
494
|
|
|
495
|
+
// Validate targets
|
|
496
|
+
validateTargets(targets, sdConfig.packages);
|
|
497
|
+
|
|
494
498
|
// Load package.json
|
|
495
499
|
const projPkgPath = path.resolve(cwd, "package.json");
|
|
496
500
|
const projPkg = await fsx.readJson<PackageJson>(projPkgPath);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import { pathx, Worker, type WorkerProxy } from "@simplysm/core-node";
|
|
5
3
|
import { err as errNs } from "@simplysm/core-common";
|
|
6
4
|
import { consola } from "consola";
|
|
7
5
|
import type { SdConfig } from "../sd-config.types";
|
|
8
|
-
import { parseRootTsconfig, type TypecheckEnv } from "../utils/tsconfig";
|
|
9
6
|
import { loadSdConfig } from "../utils/sd-config";
|
|
10
7
|
import { deserializeDiagnostic } from "../utils/typecheck-serialization";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
8
|
+
import { createBuildEngine } from "../engines/index";
|
|
9
|
+
import { typecheckNonPackageFiles } from "../utils/typecheck-non-package";
|
|
10
|
+
import { runWithConcurrency, getMaxConcurrency } from "../utils/concurrency";
|
|
11
|
+
import type { EngineResult } from "../engines/types";
|
|
13
12
|
|
|
14
13
|
//#region Types
|
|
15
14
|
|
|
@@ -33,138 +32,23 @@ export interface TypecheckResult {
|
|
|
33
32
|
formattedOutput: string;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
// Package information (for classifying files under packages/*)
|
|
37
|
-
interface PackageInfo {
|
|
38
|
-
name: string;
|
|
39
|
-
dir: string;
|
|
40
|
-
envs: TypecheckEnv[]; // neutral is ["node", "browser"], others are single environment
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Typecheck task information (internal use)
|
|
44
|
-
interface TypecheckTask {
|
|
45
|
-
/** Task display name (e.g., "package: core-common [node]") */
|
|
46
|
-
displayName: string;
|
|
47
|
-
/** Information to pass to dts.worker */
|
|
48
|
-
buildInfo: DtsBuildInfo;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
35
|
//#endregion
|
|
52
36
|
|
|
53
37
|
//#region Utilities
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
const PATH_PATTERNS = {
|
|
57
|
-
/** packages/{pkg}/... */
|
|
58
|
-
PACKAGE: /^packages\/([^/]+)\//,
|
|
59
|
-
} as const;
|
|
39
|
+
const PACKAGE_PATH_PATTERN = /^packages\/([^/]+)/;
|
|
60
40
|
|
|
61
41
|
/**
|
|
62
|
-
*
|
|
63
|
-
* -
|
|
64
|
-
* - neutral: both node + browser
|
|
65
|
-
* - client: treated as browser
|
|
66
|
-
* @param target package build target
|
|
67
|
-
* @returns list of typecheck environments
|
|
42
|
+
* Extract package names from target paths.
|
|
43
|
+
* "packages/core-common" → "core-common"
|
|
68
44
|
*/
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Extract package information from file paths.
|
|
78
|
-
* Excludes packages with scripts target.
|
|
79
|
-
* @internal exported for testing
|
|
80
|
-
*/
|
|
81
|
-
export function extractPackages(
|
|
82
|
-
fileNames: string[],
|
|
83
|
-
cwd: string,
|
|
84
|
-
config: SdConfig,
|
|
85
|
-
): Map<string, PackageInfo> {
|
|
86
|
-
const packages = new Map<string, PackageInfo>();
|
|
87
|
-
|
|
88
|
-
for (const fileName of fileNames) {
|
|
89
|
-
const relativePath = pathx.posix(path.relative(cwd, fileName));
|
|
90
|
-
|
|
91
|
-
// packages/{pkg}/...
|
|
92
|
-
const packageMatch = relativePath.match(PATH_PATTERNS.PACKAGE);
|
|
93
|
-
if (packageMatch) {
|
|
94
|
-
const pkgName = packageMatch[1];
|
|
95
|
-
// Exclude packages with scripts target
|
|
96
|
-
if (config.packages[pkgName]?.target === "scripts") continue;
|
|
97
|
-
|
|
98
|
-
if (!packages.has(pkgName)) {
|
|
99
|
-
packages.set(pkgName, {
|
|
100
|
-
name: pkgName,
|
|
101
|
-
dir: path.resolve(cwd, "packages", pkgName),
|
|
102
|
-
envs: toTypecheckEnvs(config.packages[pkgName]?.target),
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
45
|
+
function extractTargetPackageNames(targets: string[]): Set<string> {
|
|
46
|
+
const names = new Set<string>();
|
|
47
|
+
for (const target of targets) {
|
|
48
|
+
const match = target.match(PACKAGE_PATH_PATTERN);
|
|
49
|
+
if (match) names.add(match[1]);
|
|
106
50
|
}
|
|
107
|
-
|
|
108
|
-
return packages;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Check if there are files not under packages/ in the tsconfig file list.
|
|
113
|
-
*/
|
|
114
|
-
function hasNonPackageFiles(fileNames: string[], cwd: string): boolean {
|
|
115
|
-
return fileNames.some((f) => {
|
|
116
|
-
const relativePath = pathx.posix(path.relative(cwd, f));
|
|
117
|
-
if (!relativePath.startsWith("packages/")) return true;
|
|
118
|
-
// Also treat files directly under package root (config files) as non-package
|
|
119
|
-
return relativePath.split("/").length === 3;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Create typecheck task list from package information.
|
|
125
|
-
* Neutral packages are split into node/browser environments and checked separately.
|
|
126
|
-
* @param packages package information map
|
|
127
|
-
* @param cwd current working directory
|
|
128
|
-
* @param includeNonPackage add "other" task if non-package files exist
|
|
129
|
-
* @returns array of typecheck task information
|
|
130
|
-
*/
|
|
131
|
-
function createTypecheckTasks(
|
|
132
|
-
packages: Map<string, PackageInfo>,
|
|
133
|
-
cwd: string,
|
|
134
|
-
includeNonPackage: boolean,
|
|
135
|
-
): TypecheckTask[] {
|
|
136
|
-
const tasks: TypecheckTask[] = [];
|
|
137
|
-
|
|
138
|
-
// packages/* - create separate task per env
|
|
139
|
-
for (const info of packages.values()) {
|
|
140
|
-
for (const env of info.envs) {
|
|
141
|
-
const envSuffix = info.envs.length > 1 ? ` [${env}]` : "";
|
|
142
|
-
tasks.push({
|
|
143
|
-
displayName: `package: ${info.name}${envSuffix}`,
|
|
144
|
-
buildInfo: {
|
|
145
|
-
name: info.name,
|
|
146
|
-
cwd,
|
|
147
|
-
pkgDir: info.dir,
|
|
148
|
-
env,
|
|
149
|
-
emit: false, // Only typecheck (no dts generation)
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// non-package files (tests/, root *.ts, etc.)
|
|
156
|
-
if (includeNonPackage) {
|
|
157
|
-
tasks.push({
|
|
158
|
-
displayName: "other",
|
|
159
|
-
buildInfo: {
|
|
160
|
-
name: "root",
|
|
161
|
-
cwd,
|
|
162
|
-
emit: false,
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return tasks;
|
|
51
|
+
return names;
|
|
168
52
|
}
|
|
169
53
|
|
|
170
54
|
//#endregion
|
|
@@ -172,14 +56,12 @@ function createTypecheckTasks(
|
|
|
172
56
|
//#region Main
|
|
173
57
|
|
|
174
58
|
/**
|
|
175
|
-
* Execute TypeScript typecheck
|
|
59
|
+
* Execute TypeScript typecheck using BuildEngine.
|
|
176
60
|
*
|
|
177
|
-
*
|
|
178
|
-
* -
|
|
179
|
-
* -
|
|
180
|
-
* -
|
|
181
|
-
* - Show progress using consola logging
|
|
182
|
-
* - Return results only, no stdout output or exitCode setting
|
|
61
|
+
* For each package in sd.config.ts:
|
|
62
|
+
* - Library/Server packages → BuildEngine.run({js:false, dts:false})
|
|
63
|
+
* - Scripts/Client packages → excluded
|
|
64
|
+
* Non-package files → typecheckNonPackageFiles utility
|
|
183
65
|
*
|
|
184
66
|
* @param options - typecheck execution options
|
|
185
67
|
* @returns typecheck result (success status, error/warning counts, formatted output string)
|
|
@@ -197,51 +79,38 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
197
79
|
getNewLine: () => ts.sys.newLine,
|
|
198
80
|
};
|
|
199
81
|
|
|
200
|
-
// Load and parse tsconfig.json
|
|
201
|
-
let parsedConfig: ts.ParsedCommandLine;
|
|
202
|
-
try {
|
|
203
|
-
parsedConfig = parseRootTsconfig(cwd);
|
|
204
|
-
} catch (err) {
|
|
205
|
-
logger.error(errNs.message(err));
|
|
206
|
-
return { success: false, errorCount: 1, warningCount: 0, formattedOutput: "" };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
82
|
// Load sd.config.ts
|
|
210
83
|
let sdConfig: SdConfig;
|
|
211
84
|
try {
|
|
212
85
|
sdConfig = await loadSdConfig({ cwd, dev: false, options: options.options });
|
|
213
86
|
logger.debug("sd.config.ts loaded");
|
|
214
|
-
} catch
|
|
215
|
-
// Use defaults if sd.config.ts is missing or load fails
|
|
87
|
+
} catch {
|
|
216
88
|
sdConfig = { packages: {} };
|
|
217
|
-
logger.debug("sd.config.ts load failed, using defaults"
|
|
89
|
+
logger.debug("sd.config.ts load failed, using defaults");
|
|
218
90
|
}
|
|
219
91
|
|
|
220
|
-
//
|
|
221
|
-
const
|
|
92
|
+
// Determine target package names from path-based targets
|
|
93
|
+
const targetNames = extractTargetPackageNames(targets);
|
|
222
94
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
formattedOutput: "✔ No files to typecheck.\n",
|
|
230
|
-
};
|
|
231
|
-
}
|
|
95
|
+
// Collect packages to typecheck (exclude scripts and client)
|
|
96
|
+
const typecheckPackages: Array<{ name: string; dir: string; config: any }> = [];
|
|
97
|
+
for (const [name, config] of Object.entries(sdConfig.packages)) {
|
|
98
|
+
if (config == null) continue;
|
|
99
|
+
if (config.target === "scripts" || config.target === "client") continue;
|
|
100
|
+
if (targetNames.size > 0 && !targetNames.has(name)) continue;
|
|
232
101
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
102
|
+
typecheckPackages.push({
|
|
103
|
+
name,
|
|
104
|
+
dir: path.join(cwd, "packages", name),
|
|
105
|
+
config,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
239
108
|
|
|
240
|
-
//
|
|
241
|
-
const
|
|
242
|
-
const tasks = createTypecheckTasks(packages, cwd, nonPackage);
|
|
109
|
+
// Non-package typecheck: run when no targets or when targets include non-package paths
|
|
110
|
+
const includeNonPackage = targets.length === 0 || targets.some((t) => !t.startsWith("packages/"));
|
|
243
111
|
|
|
244
|
-
if (
|
|
112
|
+
if (typecheckPackages.length === 0 && !includeNonPackage) {
|
|
113
|
+
logger.info("no typecheck targets");
|
|
245
114
|
return {
|
|
246
115
|
success: true,
|
|
247
116
|
errorCount: 0,
|
|
@@ -250,89 +119,71 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
250
119
|
};
|
|
251
120
|
}
|
|
252
121
|
|
|
253
|
-
//
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
122
|
+
// Create BuildEngine tasks with concurrency limit
|
|
123
|
+
const allDiagnostics: ts.Diagnostic[] = [];
|
|
124
|
+
let totalErrorCount = 0;
|
|
125
|
+
let totalWarningCount = 0;
|
|
126
|
+
const fileCache = new Map<string, string>();
|
|
127
|
+
|
|
128
|
+
if (typecheckPackages.length > 0) {
|
|
129
|
+
const tasks = typecheckPackages.map((pkg) => async (): Promise<EngineResult> => {
|
|
130
|
+
const engine = createBuildEngine(
|
|
131
|
+
{ name: pkg.name, dir: pkg.dir, config: pkg.config },
|
|
132
|
+
{ cwd },
|
|
133
|
+
);
|
|
134
|
+
try {
|
|
135
|
+
logger.debug(`[${pkg.name}] typecheck started`);
|
|
136
|
+
const result = await engine.run({ js: false, dts: false });
|
|
137
|
+
logger.debug(`[${pkg.name}] typecheck ${result.dts.success ? "completed" : "failed"}`);
|
|
138
|
+
return result;
|
|
139
|
+
} finally {
|
|
140
|
+
await engine.stop();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
269
143
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
144
|
+
const concurrency = getMaxConcurrency();
|
|
145
|
+
logger.start(`Running typecheck... (${tasks.length} packages, concurrency: ${concurrency})`);
|
|
146
|
+
const results = await runWithConcurrency(tasks, concurrency);
|
|
147
|
+
logger.success("Typecheck execution completed");
|
|
274
148
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
});
|
|
288
|
-
allResults.push({
|
|
289
|
-
displayName: task.displayName,
|
|
290
|
-
result: {
|
|
291
|
-
success: false,
|
|
292
|
-
errors: [errNs.message(err)],
|
|
293
|
-
diagnostics: [],
|
|
294
|
-
errorCount: 1,
|
|
295
|
-
warningCount: 0,
|
|
296
|
-
},
|
|
297
|
-
});
|
|
149
|
+
// Aggregate engine results
|
|
150
|
+
for (const settled of results) {
|
|
151
|
+
if (settled.status === "fulfilled") {
|
|
152
|
+
const engineResult = settled.value;
|
|
153
|
+
const dtsDiags = engineResult.dts.diagnostics.map((d) => deserializeDiagnostic(d, fileCache));
|
|
154
|
+
allDiagnostics.push(...dtsDiags);
|
|
155
|
+
// Count errors/warnings from deserialized diagnostics
|
|
156
|
+
// Use numeric category values (ts.DiagnosticCategory: Error=1, Warning=0)
|
|
157
|
+
totalErrorCount += dtsDiags.filter((d) => d.category === 1).length;
|
|
158
|
+
totalWarningCount += dtsDiags.filter((d) => d.category === 0).length;
|
|
159
|
+
if (!engineResult.dts.success && dtsDiags.length === 0) {
|
|
160
|
+
totalErrorCount += engineResult.dts.errors.length || 1;
|
|
298
161
|
}
|
|
162
|
+
} else {
|
|
163
|
+
totalErrorCount += 1;
|
|
164
|
+
logger.error("Engine task failed", { error: errNs.message(settled.reason) });
|
|
299
165
|
}
|
|
300
166
|
}
|
|
301
|
-
|
|
302
|
-
logger.start(`Running typecheck... (${tasks.length} targets, concurrency: ${concurrency})`);
|
|
303
|
-
await Promise.all(workers.map((worker) => runNextTask(worker)));
|
|
304
|
-
logger.success("Typecheck execution completed");
|
|
305
|
-
} finally {
|
|
306
|
-
await Promise.all(workers.map((w) => w.terminate()));
|
|
307
167
|
}
|
|
308
168
|
|
|
309
|
-
//
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
for (const serialized of result.diagnostics) {
|
|
318
|
-
allDiagnostics.push(deserializeDiagnostic(serialized, fileCache));
|
|
319
|
-
}
|
|
169
|
+
// Non-package typecheck
|
|
170
|
+
if (includeNonPackage) {
|
|
171
|
+
logger.debug("Running non-package typecheck");
|
|
172
|
+
const nonPkgResult = typecheckNonPackageFiles(cwd);
|
|
173
|
+
totalErrorCount += nonPkgResult.errorCount;
|
|
174
|
+
totalWarningCount += nonPkgResult.warningCount;
|
|
175
|
+
const nonPkgDiags = nonPkgResult.diagnostics.map((d) => deserializeDiagnostic(d, fileCache));
|
|
176
|
+
allDiagnostics.push(...nonPkgDiags);
|
|
320
177
|
}
|
|
321
178
|
|
|
179
|
+
// Log summary
|
|
322
180
|
if (totalErrorCount > 0) {
|
|
323
|
-
logger.error("typecheck errors occurred", {
|
|
324
|
-
errorCount: totalErrorCount,
|
|
325
|
-
warningCount: totalWarningCount,
|
|
326
|
-
});
|
|
327
|
-
} else if (totalWarningCount > 0) {
|
|
328
|
-
logger.info("typecheck complete (warnings present)", {
|
|
329
|
-
errorCount: totalErrorCount,
|
|
330
|
-
warningCount: totalWarningCount,
|
|
331
|
-
});
|
|
181
|
+
logger.error("typecheck errors occurred", { errorCount: totalErrorCount, warningCount: totalWarningCount });
|
|
332
182
|
} else {
|
|
333
183
|
logger.info("typecheck complete", { errorCount: totalErrorCount, warningCount: totalWarningCount });
|
|
334
184
|
}
|
|
335
185
|
|
|
186
|
+
// Format diagnostics output
|
|
336
187
|
let formattedOutput = "";
|
|
337
188
|
if (allDiagnostics.length > 0) {
|
|
338
189
|
const uniqueDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
|
|
@@ -347,22 +198,4 @@ export async function executeTypecheck(options: TypecheckOptions): Promise<Typec
|
|
|
347
198
|
};
|
|
348
199
|
}
|
|
349
200
|
|
|
350
|
-
/**
|
|
351
|
-
* Run TypeScript typecheck.
|
|
352
|
-
*
|
|
353
|
-
* Calls `executeTypecheck()`, outputs results to stdout, and sets `process.exitCode` if errors occur.
|
|
354
|
-
*
|
|
355
|
-
* @param options - typecheck execution options
|
|
356
|
-
* @returns resolves when complete. If errors are found, sets `process.exitCode` to 1 and resolves (does not throw)
|
|
357
|
-
*/
|
|
358
|
-
export async function runTypecheck(options: TypecheckOptions): Promise<void> {
|
|
359
|
-
const result = await executeTypecheck(options);
|
|
360
|
-
if (result.formattedOutput) {
|
|
361
|
-
process.stdout.write(result.formattedOutput);
|
|
362
|
-
}
|
|
363
|
-
if (!result.success) {
|
|
364
|
-
process.exitCode = 1;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
201
|
//#endregion
|
package/src/commands/watch.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
// packages/cli/src/commands/watch.ts
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
} from "../orchestrators/
|
|
2
|
+
DevWatchOrchestrator,
|
|
3
|
+
type DevWatchOrchestratorOptions,
|
|
4
|
+
} from "../orchestrators/DevWatchOrchestrator";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
* Build
|
|
7
|
+
* Build all packages in watch mode.
|
|
9
8
|
*
|
|
10
9
|
* - Load `sd.config.ts` to check build target info per package (required)
|
|
11
10
|
* - `node`/`browser`/`neutral` target: build in esbuild watch mode + generate .d.ts
|
|
11
|
+
* - `server` target: build in esbuild watch mode (no runtime)
|
|
12
|
+
* - `scripts` target with watch config: run hook on file changes
|
|
12
13
|
* - Auto rebuild on file changes
|
|
13
14
|
* - Terminate with SIGINT/SIGTERM signals
|
|
14
15
|
*
|
|
15
|
-
* @param options - watch execution options
|
|
16
|
+
* @param options - watch execution options (targets, options)
|
|
16
17
|
* @returns resolves on termination signal
|
|
17
18
|
*/
|
|
18
|
-
export async function runWatch(options:
|
|
19
|
-
const orchestrator = new
|
|
19
|
+
export async function runWatch(options: Omit<DevWatchOrchestratorOptions, "mode">): Promise<void> {
|
|
20
|
+
const orchestrator = new DevWatchOrchestrator({ mode: "watch", ...options });
|
|
20
21
|
|
|
21
22
|
try {
|
|
22
23
|
await orchestrator.initialize();
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Worker, type WorkerProxy } from "@simplysm/core-node";
|
|
2
|
+
import { consola } from "consola";
|
|
3
|
+
import type * as NgtscBuildWorkerModule from "../workers/ngtsc-build.worker";
|
|
4
|
+
import type { BuildResult, ResultCollector } from "../infra/ResultCollector";
|
|
5
|
+
import type { RebuildManager } from "../utils/rebuild-manager";
|
|
6
|
+
import type { BuildEngine, BuildOutput, BuildPackageInfo, EngineResult } from "./types";
|
|
7
|
+
|
|
8
|
+
const logger = consola.withTag("sd:cli:engine:ngtsc");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* NgtscEngine options
|
|
12
|
+
*/
|
|
13
|
+
export interface NgtscEngineOptions {
|
|
14
|
+
cwd: string;
|
|
15
|
+
pkg: BuildPackageInfo;
|
|
16
|
+
/** ResultCollector for watch mode rebuild reporting */
|
|
17
|
+
resultCollector?: ResultCollector;
|
|
18
|
+
/** RebuildManager for watch mode batch coordination */
|
|
19
|
+
rebuildManager?: RebuildManager;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* NgtscProgram-based build engine for Angular Library packages
|
|
24
|
+
*
|
|
25
|
+
* Wraps a single ngtsc-build.worker that uses NgtscProgram for AOT compilation.
|
|
26
|
+
* Angular packages are detected by the presence of angularCompilerOptions in tsconfig.json.
|
|
27
|
+
*/
|
|
28
|
+
export class NgtscEngine implements BuildEngine {
|
|
29
|
+
private readonly _cwd: string;
|
|
30
|
+
private readonly _pkg: BuildPackageInfo;
|
|
31
|
+
private readonly _resultCollector: ResultCollector | undefined;
|
|
32
|
+
private readonly _rebuildManager: RebuildManager | undefined;
|
|
33
|
+
|
|
34
|
+
private _worker: WorkerProxy<typeof NgtscBuildWorkerModule> | undefined;
|
|
35
|
+
private _isWatchMode = false;
|
|
36
|
+
|
|
37
|
+
constructor(options: NgtscEngineOptions) {
|
|
38
|
+
this._cwd = options.cwd;
|
|
39
|
+
this._pkg = options.pkg;
|
|
40
|
+
this._resultCollector = options.resultCollector;
|
|
41
|
+
this._rebuildManager = options.rebuildManager;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* One-time build (production)
|
|
46
|
+
*/
|
|
47
|
+
async run(output: BuildOutput): Promise<EngineResult> {
|
|
48
|
+
this._createWorker();
|
|
49
|
+
|
|
50
|
+
const result = await this._worker!.build({
|
|
51
|
+
name: this._pkg.name,
|
|
52
|
+
cwd: this._cwd,
|
|
53
|
+
pkgDir: this._pkg.dir,
|
|
54
|
+
output,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
success: result.js.success && result.dts.success,
|
|
59
|
+
js: {
|
|
60
|
+
success: result.js.success,
|
|
61
|
+
errors: result.js.errors ?? [],
|
|
62
|
+
warnings: result.js.warnings ?? [],
|
|
63
|
+
},
|
|
64
|
+
dts: {
|
|
65
|
+
success: result.dts.success,
|
|
66
|
+
errors: result.dts.errors ?? [],
|
|
67
|
+
warnings: [],
|
|
68
|
+
diagnostics: result.dts.diagnostics,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Start watch mode
|
|
75
|
+
* Promise resolves when initial build completes.
|
|
76
|
+
*/
|
|
77
|
+
async startWatch(output: BuildOutput): Promise<void> {
|
|
78
|
+
this._isWatchMode = true;
|
|
79
|
+
this._createWorker();
|
|
80
|
+
|
|
81
|
+
return new Promise<void>((resolve) => {
|
|
82
|
+
let isInitialBuild = true;
|
|
83
|
+
const workerKey = `${this._pkg.name}:build`;
|
|
84
|
+
|
|
85
|
+
this._worker!.on("buildStart", () => {
|
|
86
|
+
if (!isInitialBuild && this._rebuildManager != null) {
|
|
87
|
+
this._rebuildManager.registerBuild(
|
|
88
|
+
workerKey,
|
|
89
|
+
`${this._pkg.name} (${this._pkg.config.target})`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
this._worker!.on("build", (data) => {
|
|
95
|
+
const event = data;
|
|
96
|
+
|
|
97
|
+
if (event.js.warnings != null && event.js.warnings.length > 0) {
|
|
98
|
+
logger.warn(`${this._pkg.name}: ${event.js.warnings.join(", ")}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Report JS result
|
|
102
|
+
const buildResult: BuildResult = {
|
|
103
|
+
name: this._pkg.name,
|
|
104
|
+
target: this._pkg.config.target,
|
|
105
|
+
type: "build",
|
|
106
|
+
status: event.js.success ? "success" : "error",
|
|
107
|
+
message: event.js.errors?.join("\n"),
|
|
108
|
+
};
|
|
109
|
+
this._resultCollector?.add(buildResult);
|
|
110
|
+
|
|
111
|
+
// Report DTS result
|
|
112
|
+
const dtsResult: BuildResult = {
|
|
113
|
+
name: this._pkg.name,
|
|
114
|
+
target: this._pkg.config.target,
|
|
115
|
+
type: "dts",
|
|
116
|
+
status: event.dts.success ? "success" : "error",
|
|
117
|
+
message: event.dts.errors?.join("\n"),
|
|
118
|
+
};
|
|
119
|
+
this._resultCollector?.add(dtsResult);
|
|
120
|
+
|
|
121
|
+
if (isInitialBuild) {
|
|
122
|
+
isInitialBuild = false;
|
|
123
|
+
resolve();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
this._worker!.on("error", (data) => {
|
|
128
|
+
const event = data as { message: string };
|
|
129
|
+
const result: BuildResult = {
|
|
130
|
+
name: this._pkg.name,
|
|
131
|
+
target: this._pkg.config.target,
|
|
132
|
+
type: "build",
|
|
133
|
+
status: "error",
|
|
134
|
+
message: event.message,
|
|
135
|
+
};
|
|
136
|
+
this._resultCollector?.add(result);
|
|
137
|
+
|
|
138
|
+
if (isInitialBuild) {
|
|
139
|
+
isInitialBuild = false;
|
|
140
|
+
resolve();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
this._worker!
|
|
145
|
+
.startWatch({
|
|
146
|
+
name: this._pkg.name,
|
|
147
|
+
cwd: this._cwd,
|
|
148
|
+
pkgDir: this._pkg.dir,
|
|
149
|
+
output,
|
|
150
|
+
})
|
|
151
|
+
.catch(() => {
|
|
152
|
+
if (isInitialBuild) {
|
|
153
|
+
isInitialBuild = false;
|
|
154
|
+
resolve();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Stop engine and clean up resources
|
|
162
|
+
*/
|
|
163
|
+
async stop(): Promise<void> {
|
|
164
|
+
const shutdownTimeout = 3000;
|
|
165
|
+
|
|
166
|
+
if (this._isWatchMode && this._worker != null) {
|
|
167
|
+
try {
|
|
168
|
+
await Promise.race([
|
|
169
|
+
this._worker.stopWatch(),
|
|
170
|
+
new Promise<void>((resolve) => setTimeout(resolve, shutdownTimeout)),
|
|
171
|
+
]);
|
|
172
|
+
} catch {
|
|
173
|
+
// Continue even if stopWatch fails
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (this._worker != null) {
|
|
178
|
+
await this._worker.terminate();
|
|
179
|
+
this._worker = undefined;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Create worker instance
|
|
185
|
+
*/
|
|
186
|
+
private _createWorker(): void {
|
|
187
|
+
const workerPath = import.meta.resolve("../workers/ngtsc-build.worker");
|
|
188
|
+
this._worker = Worker.create<typeof NgtscBuildWorkerModule>(workerPath);
|
|
189
|
+
}
|
|
190
|
+
}
|