@simplysm/sd-cli 13.0.99 → 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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { pathx } from "@simplysm/core-node";
|
|
4
|
+
import { err as errNs } from "@simplysm/core-common";
|
|
5
|
+
import {
|
|
6
|
+
parseTsconfig,
|
|
7
|
+
getPackageSourceFiles,
|
|
8
|
+
getPackageFiles,
|
|
9
|
+
} from "./tsconfig";
|
|
10
|
+
import { serializeDiagnostic, type SerializedDiagnostic } from "./typecheck-serialization";
|
|
11
|
+
import { createOutputPathRewriter, addJsExtensionToImports } from "./output-path-rewriter";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for package-mode tsc build
|
|
15
|
+
*/
|
|
16
|
+
export interface TscPackageBuildOptions {
|
|
17
|
+
pkgDir: string;
|
|
18
|
+
cwd: string;
|
|
19
|
+
/** Output control flags: which files to emit */
|
|
20
|
+
output: { js: boolean; dts: boolean };
|
|
21
|
+
/** Pre-parsed tsconfig. If provided, skips parseTsconfig() call. */
|
|
22
|
+
parsedConfig?: ts.ParsedCommandLine;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Result of package-mode tsc build
|
|
27
|
+
*/
|
|
28
|
+
export interface TscPackageBuildResult {
|
|
29
|
+
success: boolean;
|
|
30
|
+
errors?: string[];
|
|
31
|
+
diagnostics: SerializedDiagnostic[];
|
|
32
|
+
errorCount: number;
|
|
33
|
+
warningCount: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Run TypeScript incremental build for a package.
|
|
38
|
+
*
|
|
39
|
+
* - output.js || output.dts: emit mode (src files only, generates output files)
|
|
40
|
+
* - neither: typecheck only (src + test files, no output)
|
|
41
|
+
*
|
|
42
|
+
* Uses tsBuildInfoFile for incremental compilation across runs.
|
|
43
|
+
*/
|
|
44
|
+
export function runTscPackageBuild(options: TscPackageBuildOptions): TscPackageBuildResult {
|
|
45
|
+
try {
|
|
46
|
+
const { pkgDir, output } = options;
|
|
47
|
+
const needsEmit = output.js || output.dts;
|
|
48
|
+
|
|
49
|
+
const parsedConfig = options.parsedConfig ?? parseTsconfig(pkgDir);
|
|
50
|
+
const baseOptions = parsedConfig.options;
|
|
51
|
+
|
|
52
|
+
let rootFiles: string[];
|
|
53
|
+
let diagnosticFilter: (d: ts.Diagnostic) => boolean;
|
|
54
|
+
|
|
55
|
+
if (needsEmit) {
|
|
56
|
+
rootFiles = getPackageSourceFiles(pkgDir, parsedConfig);
|
|
57
|
+
const pkgSrcDir = path.join(pkgDir, "src");
|
|
58
|
+
diagnosticFilter = (d) => d.file == null || pathx.isChildPath(d.file.fileName, pkgSrcDir);
|
|
59
|
+
} else {
|
|
60
|
+
rootFiles = getPackageFiles(pkgDir, parsedConfig);
|
|
61
|
+
diagnosticFilter = (d) => d.file == null || pathx.isChildPath(d.file.fileName, pkgDir);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const tsBuildInfoFile = path.join(
|
|
65
|
+
pkgDir,
|
|
66
|
+
".cache",
|
|
67
|
+
needsEmit ? "build.tsbuildinfo" : "typecheck.tsbuildinfo",
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const compilerOptions: ts.CompilerOptions = {
|
|
71
|
+
...baseOptions,
|
|
72
|
+
sourceMap: output.js,
|
|
73
|
+
incremental: true,
|
|
74
|
+
tsBuildInfoFile,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (output.js && output.dts) {
|
|
78
|
+
compilerOptions.noEmit = false;
|
|
79
|
+
compilerOptions.emitDeclarationOnly = false;
|
|
80
|
+
compilerOptions.declaration = true;
|
|
81
|
+
compilerOptions.declarationMap = true;
|
|
82
|
+
compilerOptions.outDir = path.join(pkgDir, "dist");
|
|
83
|
+
compilerOptions.declarationDir = path.join(pkgDir, "dist");
|
|
84
|
+
} else if (output.js) {
|
|
85
|
+
compilerOptions.noEmit = false;
|
|
86
|
+
compilerOptions.emitDeclarationOnly = false;
|
|
87
|
+
compilerOptions.declaration = false;
|
|
88
|
+
compilerOptions.declarationMap = false;
|
|
89
|
+
compilerOptions.outDir = path.join(pkgDir, "dist");
|
|
90
|
+
} else if (output.dts) {
|
|
91
|
+
compilerOptions.noEmit = false;
|
|
92
|
+
compilerOptions.emitDeclarationOnly = true;
|
|
93
|
+
compilerOptions.declaration = true;
|
|
94
|
+
compilerOptions.declarationMap = true;
|
|
95
|
+
compilerOptions.outDir = path.join(pkgDir, "dist");
|
|
96
|
+
compilerOptions.declarationDir = path.join(pkgDir, "dist");
|
|
97
|
+
} else {
|
|
98
|
+
compilerOptions.noEmit = true;
|
|
99
|
+
compilerOptions.emitDeclarationOnly = false;
|
|
100
|
+
compilerOptions.declaration = false;
|
|
101
|
+
compilerOptions.declarationMap = false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const host = ts.createIncrementalCompilerHost(compilerOptions);
|
|
105
|
+
|
|
106
|
+
if (needsEmit) {
|
|
107
|
+
const rewritePath = createOutputPathRewriter(pkgDir);
|
|
108
|
+
const originalWriteFile = host.writeFile;
|
|
109
|
+
host.writeFile = (fileName, content, writeByteOrderMark, onError, sourceFiles, data) => {
|
|
110
|
+
const result = rewritePath(fileName, content);
|
|
111
|
+
if (result != null) {
|
|
112
|
+
let [newPath, newContent] = result;
|
|
113
|
+
if (newPath.endsWith(".js")) {
|
|
114
|
+
newContent = addJsExtensionToImports(newContent);
|
|
115
|
+
}
|
|
116
|
+
originalWriteFile(newPath, newContent, writeByteOrderMark, onError, sourceFiles, data);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const program = ts.createIncrementalProgram({
|
|
122
|
+
rootNames: rootFiles,
|
|
123
|
+
options: compilerOptions,
|
|
124
|
+
host,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const emitResult = program.emit();
|
|
128
|
+
|
|
129
|
+
const allDiagnostics = [
|
|
130
|
+
...program.getConfigFileParsingDiagnostics(),
|
|
131
|
+
...program.getSyntacticDiagnostics(),
|
|
132
|
+
...program.getOptionsDiagnostics(),
|
|
133
|
+
...program.getGlobalDiagnostics(),
|
|
134
|
+
...program.getSemanticDiagnostics(),
|
|
135
|
+
...emitResult.diagnostics,
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
const filteredDiagnostics = allDiagnostics.filter(diagnosticFilter);
|
|
139
|
+
|
|
140
|
+
const serializedDiagnostics = filteredDiagnostics.map(serializeDiagnostic);
|
|
141
|
+
const errorCount = filteredDiagnostics.filter(
|
|
142
|
+
(d) => d.category === ts.DiagnosticCategory.Error,
|
|
143
|
+
).length;
|
|
144
|
+
const warningCount = filteredDiagnostics.filter(
|
|
145
|
+
(d) => d.category === ts.DiagnosticCategory.Warning,
|
|
146
|
+
).length;
|
|
147
|
+
|
|
148
|
+
const errors = filteredDiagnostics
|
|
149
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Error)
|
|
150
|
+
.map((d) => {
|
|
151
|
+
const message = ts.flattenDiagnosticMessageText(d.messageText, "\n");
|
|
152
|
+
if (d.file != null && d.start != null) {
|
|
153
|
+
const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
|
|
154
|
+
return `${d.file.fileName}:${line + 1}:${character + 1}: TS${d.code}: ${message}`;
|
|
155
|
+
}
|
|
156
|
+
return `TS${d.code}: ${message}`;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
success: errorCount === 0,
|
|
161
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
162
|
+
diagnostics: serializedDiagnostics,
|
|
163
|
+
errorCount,
|
|
164
|
+
warningCount,
|
|
165
|
+
};
|
|
166
|
+
} catch (err) {
|
|
167
|
+
return {
|
|
168
|
+
success: false,
|
|
169
|
+
errors: [errNs.message(err)],
|
|
170
|
+
diagnostics: [],
|
|
171
|
+
errorCount: 1,
|
|
172
|
+
warningCount: 0,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
package/src/utils/tsconfig.ts
CHANGED
|
@@ -1,123 +1,55 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
1
|
import path from "path";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* DOM-related lib patterns - libs that include browser APIs
|
|
8
|
-
* Used when filtering libs that should be excluded from node environment (lib.dom.d.ts, lib.webworker.d.ts, etc)
|
|
9
|
-
*/
|
|
10
|
-
const DOM_LIB_PATTERNS = ["dom", "webworker"] as const;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Read @types/* devDependencies from package.json and return types list
|
|
14
|
-
*/
|
|
15
|
-
export async function getTypesFromPackageJson(packageDir: string): Promise<string[]> {
|
|
16
|
-
const packageJsonPath = path.join(packageDir, "package.json");
|
|
17
|
-
if (!(await fsx.exists(packageJsonPath))) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const packageJson = await fsx.readJson<{ devDependencies?: Record<string, string> }>(
|
|
22
|
-
packageJsonPath,
|
|
23
|
-
);
|
|
24
|
-
const devDeps = packageJson.devDependencies ?? {};
|
|
25
|
-
|
|
26
|
-
return Object.keys(devDeps)
|
|
27
|
-
.filter((dep) => dep.startsWith("@types/"))
|
|
28
|
-
.map((dep) => dep.replace("@types/", ""));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Type check environment
|
|
33
|
-
* - node: remove DOM lib + add node types
|
|
34
|
-
* - browser: remove node types
|
|
35
|
-
*/
|
|
36
|
-
export type TypecheckEnv = "node" | "browser";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { pathx } from "@simplysm/core-node";
|
|
37
4
|
|
|
38
5
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param baseOptions - Compiler options from root tsconfig
|
|
42
|
-
* @param env - Type check environment (node: remove DOM lib + add node types, browser: remove node types)
|
|
43
|
-
* @param packageDir - Package directory path
|
|
44
|
-
*
|
|
45
|
-
* @remarks
|
|
46
|
-
* The types option ignores baseOptions.types and is newly constructed per package.
|
|
47
|
-
* This is because the global types in root tsconfig may not fit the package environment.
|
|
48
|
-
* (e.g., prevent node types from being included in browser packages)
|
|
6
|
+
* Check if tsconfig.json in the given directory has angularCompilerOptions.
|
|
7
|
+
* Uses ts.readConfigFile to read raw JSON (before parsing/extension).
|
|
49
8
|
*/
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const options = { ...baseOptions };
|
|
56
|
-
const packageTypes = await getTypesFromPackageJson(packageDir);
|
|
57
|
-
|
|
58
|
-
// pnpm environment: search both package-specific node_modules/@types and root node_modules/@types
|
|
59
|
-
options.typeRoots = [
|
|
60
|
-
path.join(packageDir, "node_modules", "@types"),
|
|
61
|
-
path.join(process.cwd(), "node_modules", "@types"),
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
switch (env) {
|
|
65
|
-
case "node":
|
|
66
|
-
options.lib = options.lib?.filter(
|
|
67
|
-
(lib) => !DOM_LIB_PATTERNS.some((pattern) => lib.toLowerCase().includes(pattern)),
|
|
68
|
-
);
|
|
69
|
-
options.types = [...new Set([...packageTypes, "node"])];
|
|
70
|
-
break;
|
|
71
|
-
case "browser":
|
|
72
|
-
options.types = packageTypes.filter((t) => t !== "node");
|
|
73
|
-
break;
|
|
9
|
+
export function hasAngularCompilerOptions(pkgDir: string): boolean {
|
|
10
|
+
const tsconfigPath = path.join(pkgDir, "tsconfig.json");
|
|
11
|
+
const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
12
|
+
if (configFile.error != null) {
|
|
13
|
+
return false;
|
|
74
14
|
}
|
|
75
|
-
|
|
76
|
-
return options;
|
|
15
|
+
return configFile.config?.angularCompilerOptions != null;
|
|
77
16
|
}
|
|
78
17
|
|
|
79
18
|
/**
|
|
80
|
-
* Parse
|
|
81
|
-
* @throws If unable to read or parse tsconfig.json
|
|
19
|
+
* Parse tsconfig.json from the given directory.
|
|
82
20
|
*/
|
|
83
|
-
export function
|
|
84
|
-
const tsconfigPath = path.join(
|
|
21
|
+
export function parseTsconfig(dir: string): ts.ParsedCommandLine {
|
|
22
|
+
const tsconfigPath = path.join(dir, "tsconfig.json");
|
|
85
23
|
const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
86
|
-
|
|
87
24
|
if (configFile.error) {
|
|
88
|
-
|
|
89
|
-
throw new SdError(`Failed to read tsconfig.json: ${message}`);
|
|
25
|
+
throw new Error(ts.flattenDiagnosticMessageText(configFile.error.messageText, "\n"));
|
|
90
26
|
}
|
|
91
|
-
|
|
92
|
-
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, cwd);
|
|
93
|
-
|
|
27
|
+
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, dir);
|
|
94
28
|
if (parsed.errors.length > 0) {
|
|
95
|
-
|
|
96
|
-
|
|
29
|
+
throw new Error(
|
|
30
|
+
parsed.errors.map((e) => ts.flattenDiagnosticMessageText(e.messageText, "\n")).join("\n"),
|
|
31
|
+
);
|
|
97
32
|
}
|
|
98
|
-
|
|
99
33
|
return parsed;
|
|
100
34
|
}
|
|
101
35
|
|
|
102
36
|
/**
|
|
103
|
-
* Get
|
|
37
|
+
* Get source files (under src/) from a package, filtered by the parsed tsconfig.
|
|
104
38
|
*/
|
|
105
39
|
export function getPackageSourceFiles(
|
|
106
40
|
pkgDir: string,
|
|
107
41
|
parsedConfig: ts.ParsedCommandLine,
|
|
108
42
|
): string[] {
|
|
109
|
-
const
|
|
110
|
-
return parsedConfig.fileNames.filter((f) => pathx.isChildPath(f,
|
|
43
|
+
const srcDir = path.join(pkgDir, "src");
|
|
44
|
+
return parsedConfig.fileNames.filter((f) => pathx.isChildPath(f, srcDir));
|
|
111
45
|
}
|
|
112
46
|
|
|
113
47
|
/**
|
|
114
|
-
* Get
|
|
48
|
+
* Get all files (src + tests) from a package, filtered by the parsed tsconfig.
|
|
115
49
|
*/
|
|
116
|
-
export function getPackageFiles(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return path.dirname(relative) !== ".";
|
|
122
|
-
});
|
|
50
|
+
export function getPackageFiles(
|
|
51
|
+
pkgDir: string,
|
|
52
|
+
parsedConfig: ts.ParsedCommandLine,
|
|
53
|
+
): string[] {
|
|
54
|
+
return parsedConfig.fileNames.filter((f) => pathx.isChildPath(f, pkgDir));
|
|
123
55
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { parseTsconfig } from "./tsconfig";
|
|
4
|
+
import { serializeDiagnostic, type SerializedDiagnostic } from "./typecheck-serialization";
|
|
5
|
+
|
|
6
|
+
export interface NonPackageTypecheckResult {
|
|
7
|
+
success: boolean;
|
|
8
|
+
errorCount: number;
|
|
9
|
+
warningCount: number;
|
|
10
|
+
diagnostics: SerializedDiagnostic[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Typecheck non-package files (root-level configs + package root configs).
|
|
15
|
+
* Extracted from dts.worker.ts non-package mode.
|
|
16
|
+
*
|
|
17
|
+
* Non-package files include:
|
|
18
|
+
* - Root-level files (vitest.config.ts, etc.) — not under packages/
|
|
19
|
+
* - Package root config files (packages/{pkg}/vitest.config.ts) — depth 2 under packages/
|
|
20
|
+
* Excludes package source files (packages/{pkg}/src/...)
|
|
21
|
+
*/
|
|
22
|
+
export function typecheckNonPackageFiles(cwd: string): NonPackageTypecheckResult {
|
|
23
|
+
const parsedConfig = parseTsconfig(cwd);
|
|
24
|
+
const packagesDir = path.join(cwd, "packages");
|
|
25
|
+
|
|
26
|
+
const isNonPackageFile = (fileName: string): boolean => {
|
|
27
|
+
const normalized = path.resolve(fileName);
|
|
28
|
+
const normalizedPkgDir = path.resolve(packagesDir);
|
|
29
|
+
|
|
30
|
+
// Files outside packages/ directory
|
|
31
|
+
if (!normalized.startsWith(normalizedPkgDir + path.sep)) return true;
|
|
32
|
+
|
|
33
|
+
// Files directly in package root (e.g., packages/{pkg}/file.ts — depth 2)
|
|
34
|
+
const relative = path.relative(normalizedPkgDir, normalized);
|
|
35
|
+
return relative.split(path.sep).length === 2;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const rootFiles = parsedConfig.fileNames.filter(isNonPackageFile);
|
|
39
|
+
|
|
40
|
+
const tsBuildInfoFile = path.join(cwd, ".cache", "typecheck-root.tsbuildinfo");
|
|
41
|
+
const options: ts.CompilerOptions = {
|
|
42
|
+
...parsedConfig.options,
|
|
43
|
+
sourceMap: false,
|
|
44
|
+
incremental: true,
|
|
45
|
+
tsBuildInfoFile,
|
|
46
|
+
noEmit: true,
|
|
47
|
+
emitDeclarationOnly: false,
|
|
48
|
+
declaration: false,
|
|
49
|
+
declarationMap: false,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const host = ts.createIncrementalCompilerHost(options);
|
|
53
|
+
const program = ts.createIncrementalProgram({
|
|
54
|
+
rootNames: rootFiles,
|
|
55
|
+
options,
|
|
56
|
+
host,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
program.emit();
|
|
60
|
+
|
|
61
|
+
const allDiagnostics = [
|
|
62
|
+
...program.getConfigFileParsingDiagnostics(),
|
|
63
|
+
...program.getSyntacticDiagnostics(),
|
|
64
|
+
...program.getOptionsDiagnostics(),
|
|
65
|
+
...program.getGlobalDiagnostics(),
|
|
66
|
+
...program.getSemanticDiagnostics(),
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const filteredDiagnostics = allDiagnostics.filter(
|
|
70
|
+
(d) => d.file == null || isNonPackageFile(d.file.fileName),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const serializedDiagnostics = filteredDiagnostics.map(serializeDiagnostic);
|
|
74
|
+
const errorCount = filteredDiagnostics.filter(
|
|
75
|
+
(d) => d.category === ts.DiagnosticCategory.Error,
|
|
76
|
+
).length;
|
|
77
|
+
const warningCount = filteredDiagnostics.filter(
|
|
78
|
+
(d) => d.category === ts.DiagnosticCategory.Warning,
|
|
79
|
+
).length;
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
success: errorCount === 0,
|
|
83
|
+
errorCount,
|
|
84
|
+
warningCount,
|
|
85
|
+
diagnostics: serializedDiagnostics,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { NgtscProgram, type AngularLibraryHostExtensions } from "./utils/angular-build";
|
|
5
|
+
import { compileScssString, compileScssFile } from "./utils/scss-compiler";
|
|
6
|
+
|
|
7
|
+
export interface AngularVitestPluginOptions {
|
|
8
|
+
/** Angular 패키지의 tsconfig.json 절대 경로 */
|
|
9
|
+
tsconfig: string;
|
|
10
|
+
/** monorepo 워크스페이스 루트 경로. 미지정 시 tsconfig 기준 상위 2단계를 사용한다 */
|
|
11
|
+
cwd?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function angularVitestPlugin(options: AngularVitestPluginOptions): Plugin {
|
|
15
|
+
const compiledFiles = new Map<string, { js: string; map?: string }>();
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
name: "angular-vitest",
|
|
19
|
+
enforce: "pre",
|
|
20
|
+
|
|
21
|
+
async buildStart() {
|
|
22
|
+
const configFile = ts.readConfigFile(options.tsconfig, ts.sys.readFile);
|
|
23
|
+
const parsedConfig = ts.parseJsonConfigFileContent(
|
|
24
|
+
configFile.config,
|
|
25
|
+
ts.sys,
|
|
26
|
+
ts.sys.resolvePath(options.tsconfig + "/.."),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// src/ 파일만 필터 (테스트 제외)
|
|
30
|
+
const sourceFiles = parsedConfig.fileNames.filter((f) => f.includes("/src/"));
|
|
31
|
+
|
|
32
|
+
const compilerOptions: ts.CompilerOptions = {
|
|
33
|
+
...parsedConfig.options,
|
|
34
|
+
noEmit: false,
|
|
35
|
+
declaration: false,
|
|
36
|
+
declarationMap: false,
|
|
37
|
+
sourceMap: false,
|
|
38
|
+
inlineSourceMap: true,
|
|
39
|
+
inlineSources: true,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
43
|
+
|
|
44
|
+
// AngularLibraryHostExtensions duck-typing
|
|
45
|
+
const hostExt = host as ts.CompilerHost & AngularLibraryHostExtensions;
|
|
46
|
+
hostExt.readResource = (fileName: string) => ts.sys.readFile(fileName) ?? "";
|
|
47
|
+
|
|
48
|
+
const pkgDir = ts.sys.resolvePath(options.tsconfig + "/..");
|
|
49
|
+
const cwd = options.cwd ?? ts.sys.resolvePath(pkgDir + "/../..");
|
|
50
|
+
const loadPaths = [
|
|
51
|
+
path.join(pkgDir, "scss"),
|
|
52
|
+
path.join(cwd, "node_modules"),
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
hostExt.transformResource = (data, context) => {
|
|
56
|
+
if (context.type !== "style") return Promise.resolve(null);
|
|
57
|
+
|
|
58
|
+
if (context.resourceFile != null && context.resourceFile.endsWith(".scss")) {
|
|
59
|
+
const result = compileScssFile(context.resourceFile, loadPaths);
|
|
60
|
+
return Promise.resolve({ content: result.css });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (context.resourceFile != null) {
|
|
64
|
+
// .css 등 비-SCSS 파일 -> null 반환 (readResource가 처리)
|
|
65
|
+
return Promise.resolve(null);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 인라인 스타일 -- SCSS로 시도, 순수 CSS면 그대로 통과
|
|
69
|
+
const result = compileScssString(data, context.containingFile, loadPaths);
|
|
70
|
+
return Promise.resolve({ content: result.css });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// writeFile 인터셉트 — 메모리에 수집 (inline sourcemap이므로 .js만 수집)
|
|
74
|
+
let currentSourcePath = "";
|
|
75
|
+
host.writeFile = (fileName: string, data: string) => {
|
|
76
|
+
if (fileName.endsWith(".js")) {
|
|
77
|
+
compiledFiles.set(currentSourcePath, { js: data });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// NgtscProgram 생성 + AOT 컴파일
|
|
82
|
+
const program = new NgtscProgram(
|
|
83
|
+
sourceFiles,
|
|
84
|
+
compilerOptions,
|
|
85
|
+
hostExt,
|
|
86
|
+
);
|
|
87
|
+
await program.compiler.analyzeAsync();
|
|
88
|
+
const { transformers } = program.compiler.prepareEmit();
|
|
89
|
+
const tsProgram = program.getTsProgram();
|
|
90
|
+
|
|
91
|
+
// per-file emit
|
|
92
|
+
for (const filePath of sourceFiles) {
|
|
93
|
+
const sf = tsProgram.getSourceFile(filePath);
|
|
94
|
+
if (sf == null) continue;
|
|
95
|
+
|
|
96
|
+
currentSourcePath = normalizePath(filePath);
|
|
97
|
+
tsProgram.emit(sf, host.writeFile, undefined, false, transformers);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
transform(_code: string, id: string) {
|
|
102
|
+
if (!id.endsWith(".ts") || id.includes("node_modules")) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const compiled = compiledFiles.get(normalizePath(id));
|
|
107
|
+
if (compiled == null) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return { code: compiled.js, map: compiled.map };
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function normalizePath(p: string): string {
|
|
117
|
+
return p.replace(/\\/g, "/");
|
|
118
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { createWorker, FsWatcher } from "@simplysm/core-node";
|
|
3
|
+
import { err as errNs } from "@simplysm/core-common";
|
|
4
|
+
import { consola } from "consola";
|
|
5
|
+
import type { SdBuildPackageConfig } from "../sd-config.types";
|
|
6
|
+
import type { BuildOutput } from "../engines/types";
|
|
7
|
+
import type { SerializedDiagnostic } from "../utils/typecheck-serialization";
|
|
8
|
+
import { runTscPackageBuild } from "../utils/tsc-build";
|
|
9
|
+
import { collectDeps } from "../utils/package-utils";
|
|
10
|
+
import { registerCleanupHandlers, createOnceGuard, applyDebugLevel } from "../utils/worker-utils";
|
|
11
|
+
|
|
12
|
+
applyDebugLevel();
|
|
13
|
+
|
|
14
|
+
//#region Types
|
|
15
|
+
|
|
16
|
+
export interface LibraryBuildInfo {
|
|
17
|
+
name: string;
|
|
18
|
+
config: SdBuildPackageConfig;
|
|
19
|
+
cwd: string;
|
|
20
|
+
pkgDir: string;
|
|
21
|
+
output: BuildOutput;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface LibraryBuildResult {
|
|
25
|
+
js: { success: boolean; errors?: string[]; warnings?: string[] };
|
|
26
|
+
dts: { success: boolean; errors?: string[]; diagnostics: SerializedDiagnostic[] };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CombinedBuildEvent {
|
|
30
|
+
js: { success: boolean; errors?: string[]; warnings?: string[] };
|
|
31
|
+
dts: { success: boolean; errors?: string[] };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface LibraryBuildWorkerEvents extends Record<string, unknown> {
|
|
35
|
+
buildStart: Record<string, never>;
|
|
36
|
+
build: CombinedBuildEvent;
|
|
37
|
+
error: { message: string };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
|
|
42
|
+
//#region Resource Management
|
|
43
|
+
|
|
44
|
+
const logger = consola.withTag("sd:cli:library-build:worker");
|
|
45
|
+
|
|
46
|
+
let fsWatcher: FsWatcher | undefined;
|
|
47
|
+
|
|
48
|
+
async function cleanup(): Promise<void> {
|
|
49
|
+
const watcherToClose = fsWatcher;
|
|
50
|
+
fsWatcher = undefined;
|
|
51
|
+
await watcherToClose?.close();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
registerCleanupHandlers(cleanup, logger);
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
|
|
58
|
+
//#region build (one-time build)
|
|
59
|
+
|
|
60
|
+
function build(info: LibraryBuildInfo): LibraryBuildResult {
|
|
61
|
+
const tscResult = runTscPackageBuild({
|
|
62
|
+
pkgDir: info.pkgDir,
|
|
63
|
+
cwd: info.cwd,
|
|
64
|
+
output: info.output,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
js: {
|
|
69
|
+
success: tscResult.success,
|
|
70
|
+
errors: tscResult.errors,
|
|
71
|
+
warnings: undefined,
|
|
72
|
+
},
|
|
73
|
+
dts: {
|
|
74
|
+
success: tscResult.success,
|
|
75
|
+
errors: tscResult.errors,
|
|
76
|
+
diagnostics: tscResult.diagnostics,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
|
|
83
|
+
//#region startWatch (watch mode)
|
|
84
|
+
|
|
85
|
+
const guardStartWatch = createOnceGuard("startWatch");
|
|
86
|
+
|
|
87
|
+
// Mutable state for watch mode
|
|
88
|
+
let watchInfo: LibraryBuildInfo | undefined;
|
|
89
|
+
|
|
90
|
+
function rebuildAll(): CombinedBuildEvent {
|
|
91
|
+
const info = watchInfo!;
|
|
92
|
+
|
|
93
|
+
const tscResult = runTscPackageBuild({
|
|
94
|
+
pkgDir: info.pkgDir,
|
|
95
|
+
cwd: info.cwd,
|
|
96
|
+
output: info.output,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
js: { success: tscResult.success, errors: tscResult.errors },
|
|
101
|
+
dts: { success: tscResult.success, errors: tscResult.errors },
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function startWatch(info: LibraryBuildInfo): Promise<void> {
|
|
106
|
+
guardStartWatch();
|
|
107
|
+
watchInfo = info;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
// Initial build
|
|
111
|
+
const initialResult = rebuildAll();
|
|
112
|
+
sender.send("build", initialResult);
|
|
113
|
+
|
|
114
|
+
// Collect workspace dependency paths
|
|
115
|
+
const { workspaceDeps } = collectDeps(info.pkgDir, info.cwd);
|
|
116
|
+
|
|
117
|
+
// Start FsWatcher — own src/ + workspace deps' src/
|
|
118
|
+
const watchPaths = [
|
|
119
|
+
path.join(info.pkgDir, "src", "**", "*.{ts,tsx}"),
|
|
120
|
+
...workspaceDeps.map((d) => path.join(info.cwd, "packages", d, "src", "**", "*.{ts,tsx}")),
|
|
121
|
+
];
|
|
122
|
+
fsWatcher = await FsWatcher.watch(watchPaths);
|
|
123
|
+
|
|
124
|
+
fsWatcher.onChange({ delay: 300 }, () => {
|
|
125
|
+
try {
|
|
126
|
+
sender.send("buildStart", {});
|
|
127
|
+
const result = rebuildAll();
|
|
128
|
+
sender.send("build", result);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
sender.send("error", { message: errNs.message(err) });
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
} catch (err) {
|
|
134
|
+
sender.send("error", { message: errNs.message(err) });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function stopWatch(): Promise<void> {
|
|
139
|
+
await cleanup();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
|
|
144
|
+
const sender = createWorker<
|
|
145
|
+
{ build: typeof build; startWatch: typeof startWatch; stopWatch: typeof stopWatch },
|
|
146
|
+
LibraryBuildWorkerEvents
|
|
147
|
+
>({
|
|
148
|
+
build,
|
|
149
|
+
startWatch,
|
|
150
|
+
stopWatch,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export default sender;
|