@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
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { err as errNs } from "@simplysm/core-common";
|
|
5
|
+
import type { BuildOutput } from "../engines/types";
|
|
6
|
+
import type { SerializedDiagnostic } from "./typecheck-serialization";
|
|
7
|
+
import { serializeDiagnostic } from "./typecheck-serialization";
|
|
8
|
+
import {
|
|
9
|
+
parseTsconfig,
|
|
10
|
+
getPackageSourceFiles,
|
|
11
|
+
} from "./tsconfig";
|
|
12
|
+
import {
|
|
13
|
+
NgtscProgram,
|
|
14
|
+
OptimizeFor,
|
|
15
|
+
type AngularLibraryHostExtensions,
|
|
16
|
+
} from "./angular-build";
|
|
17
|
+
import { createOutputPathRewriter } from "./output-path-rewriter";
|
|
18
|
+
import { compileScssString, compileScssFile } from "./scss-compiler";
|
|
19
|
+
|
|
20
|
+
//#region Types
|
|
21
|
+
|
|
22
|
+
export interface NgtscBuildInfo {
|
|
23
|
+
name: string;
|
|
24
|
+
cwd: string;
|
|
25
|
+
pkgDir: string;
|
|
26
|
+
output: BuildOutput;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface NgtscBuildResult {
|
|
30
|
+
js: { success: boolean; errors?: string[]; warnings?: string[] };
|
|
31
|
+
dts: { success: boolean; errors?: string[]; diagnostics: SerializedDiagnostic[] };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface NgtscCombinedBuildEvent {
|
|
35
|
+
js: { success: boolean; errors?: string[]; warnings?: string[] };
|
|
36
|
+
dts: { success: boolean; errors?: string[] };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
|
|
41
|
+
//#region CompilerOptions helpers
|
|
42
|
+
|
|
43
|
+
export function buildCompilerOptions(
|
|
44
|
+
baseOptions: ts.CompilerOptions,
|
|
45
|
+
pkgDir: string,
|
|
46
|
+
output: BuildOutput,
|
|
47
|
+
): ts.CompilerOptions {
|
|
48
|
+
const options: ts.CompilerOptions = {
|
|
49
|
+
...baseOptions,
|
|
50
|
+
sourceMap: false,
|
|
51
|
+
outDir: path.join(pkgDir, "dist"),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (output.js && output.dts) {
|
|
55
|
+
options.noEmit = false;
|
|
56
|
+
options.declaration = true;
|
|
57
|
+
options.declarationMap = true;
|
|
58
|
+
options.emitDeclarationOnly = false;
|
|
59
|
+
options.declarationDir = path.join(pkgDir, "dist");
|
|
60
|
+
} else if (output.js && !output.dts) {
|
|
61
|
+
options.noEmit = false;
|
|
62
|
+
options.declaration = false;
|
|
63
|
+
options.declarationMap = false;
|
|
64
|
+
options.emitDeclarationOnly = false;
|
|
65
|
+
} else if (!output.js && output.dts) {
|
|
66
|
+
options.noEmit = false;
|
|
67
|
+
options.declaration = true;
|
|
68
|
+
options.declarationMap = true;
|
|
69
|
+
options.emitDeclarationOnly = true;
|
|
70
|
+
options.declarationDir = path.join(pkgDir, "dist");
|
|
71
|
+
} else {
|
|
72
|
+
// both false — typecheck only
|
|
73
|
+
options.noEmit = true;
|
|
74
|
+
options.declaration = false;
|
|
75
|
+
options.declarationMap = false;
|
|
76
|
+
options.emitDeclarationOnly = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return options;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
|
|
84
|
+
//#region SCSS loadPaths helper
|
|
85
|
+
|
|
86
|
+
export function buildScssLoadPaths(info: NgtscBuildInfo): string[] {
|
|
87
|
+
return [
|
|
88
|
+
path.join(info.pkgDir, "scss"),
|
|
89
|
+
path.join(info.cwd, "node_modules"),
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
|
|
95
|
+
//#region NgtscProgram build core
|
|
96
|
+
|
|
97
|
+
interface NgtscProgramWithHostResult {
|
|
98
|
+
program: NgtscProgram;
|
|
99
|
+
host: ts.CompilerHost;
|
|
100
|
+
scssErrors: string[];
|
|
101
|
+
scssDependencies: Map<string, Set<string>>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function createNgtscProgramWithHost(
|
|
105
|
+
rootNames: string[],
|
|
106
|
+
compilerOptions: ts.CompilerOptions,
|
|
107
|
+
info: NgtscBuildInfo,
|
|
108
|
+
output: BuildOutput,
|
|
109
|
+
oldProgram?: NgtscProgram,
|
|
110
|
+
modifiedResourceFiles?: Set<string>,
|
|
111
|
+
): NgtscProgramWithHostResult {
|
|
112
|
+
const pkgDir = info.pkgDir;
|
|
113
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
114
|
+
const scssErrors: string[] = [];
|
|
115
|
+
const scssDependencies = new Map<string, Set<string>>();
|
|
116
|
+
|
|
117
|
+
const loadPaths = buildScssLoadPaths(info);
|
|
118
|
+
|
|
119
|
+
// AngularLibraryHostExtensions duck-typing
|
|
120
|
+
const hostExt = host as ts.CompilerHost & AngularLibraryHostExtensions;
|
|
121
|
+
hostExt.readResource = (fileName: string) => ts.sys.readFile(fileName) ?? "";
|
|
122
|
+
|
|
123
|
+
hostExt.transformResource = (data, context) => {
|
|
124
|
+
if (context.type !== "style") return Promise.resolve(null);
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
if (context.resourceFile != null && context.resourceFile.endsWith(".scss")) {
|
|
128
|
+
const result = compileScssFile(context.resourceFile, loadPaths);
|
|
129
|
+
trackDeps(scssDependencies, context.containingFile, result.dependencies);
|
|
130
|
+
return Promise.resolve({ content: result.css });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (context.resourceFile != null) {
|
|
134
|
+
// .css 등 비-SCSS 파일 -> null 반환 (readResource가 처리)
|
|
135
|
+
return Promise.resolve(null);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 인라인 스타일 -- SCSS로 시도, 순수 CSS면 그대로 통과
|
|
139
|
+
const result = compileScssString(data, context.containingFile, loadPaths);
|
|
140
|
+
trackDeps(scssDependencies, context.containingFile, result.dependencies);
|
|
141
|
+
return Promise.resolve({ content: result.css });
|
|
142
|
+
} catch (err) {
|
|
143
|
+
scssErrors.push(formatScssError(err, context.containingFile));
|
|
144
|
+
return Promise.resolve({ content: "/* SCSS compilation error */" });
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
if (modifiedResourceFiles != null) {
|
|
149
|
+
hostExt.getModifiedResourceFiles = () => modifiedResourceFiles;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Output path rewriting
|
|
153
|
+
if (output.js || output.dts) {
|
|
154
|
+
const rewritePath = createOutputPathRewriter(pkgDir);
|
|
155
|
+
const originalWriteFile = host.writeFile;
|
|
156
|
+
host.writeFile = (fileName, content, writeByteOrderMark, onError, sourceFiles, data) => {
|
|
157
|
+
const result = rewritePath(fileName, content);
|
|
158
|
+
if (result != null) {
|
|
159
|
+
originalWriteFile(result[0], result[1], writeByteOrderMark, onError, sourceFiles, data);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const program = new NgtscProgram(rootNames, compilerOptions, hostExt, oldProgram);
|
|
165
|
+
|
|
166
|
+
return { program, host, scssErrors, scssDependencies };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function trackDeps(
|
|
170
|
+
depsMap: Map<string, Set<string>>,
|
|
171
|
+
containingFile: string,
|
|
172
|
+
dependencies: string[],
|
|
173
|
+
): void {
|
|
174
|
+
let deps = depsMap.get(containingFile);
|
|
175
|
+
if (deps == null) {
|
|
176
|
+
deps = new Set<string>();
|
|
177
|
+
depsMap.set(containingFile, deps);
|
|
178
|
+
}
|
|
179
|
+
for (const dep of dependencies) {
|
|
180
|
+
deps.add(dep);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function formatScssError(err: unknown, containingFile: string): string {
|
|
185
|
+
const message = errNs.message(err);
|
|
186
|
+
return `SCSS error in ${containingFile}: ${message}`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
//#region Global SCSS
|
|
190
|
+
|
|
191
|
+
export function compileGlobalScss(
|
|
192
|
+
pkgDir: string,
|
|
193
|
+
loadPaths: string[],
|
|
194
|
+
): string[] {
|
|
195
|
+
const stylesPath = path.join(pkgDir, "scss", "styles.scss");
|
|
196
|
+
if (!fs.existsSync(stylesPath)) return [];
|
|
197
|
+
|
|
198
|
+
const errors: string[] = [];
|
|
199
|
+
try {
|
|
200
|
+
const result = compileScssFile(stylesPath, loadPaths);
|
|
201
|
+
const distDir = path.join(pkgDir, "dist");
|
|
202
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
203
|
+
fs.writeFileSync(path.join(distDir, "styles.css"), result.css, "utf-8");
|
|
204
|
+
} catch (err) {
|
|
205
|
+
errors.push(`Global SCSS error: ${errNs.message(err)}`);
|
|
206
|
+
}
|
|
207
|
+
return errors;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
|
|
212
|
+
function collectDiagnostics(
|
|
213
|
+
program: NgtscProgram,
|
|
214
|
+
tsProgram: ts.Program,
|
|
215
|
+
pkgSrcDir: string,
|
|
216
|
+
): { serialized: SerializedDiagnostic[]; errorCount: number; errors: string[] } {
|
|
217
|
+
const allDiagnostics: ts.Diagnostic[] = [
|
|
218
|
+
...tsProgram.getSyntacticDiagnostics(),
|
|
219
|
+
...tsProgram.getOptionsDiagnostics(),
|
|
220
|
+
...tsProgram.getGlobalDiagnostics(),
|
|
221
|
+
...tsProgram.getSemanticDiagnostics(),
|
|
222
|
+
];
|
|
223
|
+
|
|
224
|
+
// Angular-specific diagnostics
|
|
225
|
+
for (const sf of tsProgram.getSourceFiles()) {
|
|
226
|
+
const ngDiags = program.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
|
|
227
|
+
allDiagnostics.push(...ngDiags);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Filter diagnostics to package source files
|
|
231
|
+
const normalizedSrcDir = pkgSrcDir.replace(/\\/g, "/");
|
|
232
|
+
const filteredDiagnostics = allDiagnostics.filter(
|
|
233
|
+
(d) => d.file == null || d.file.fileName.includes(normalizedSrcDir),
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const serialized = filteredDiagnostics.map(serializeDiagnostic);
|
|
237
|
+
const errorCount = filteredDiagnostics.filter(
|
|
238
|
+
(d) => d.category === ts.DiagnosticCategory.Error,
|
|
239
|
+
).length;
|
|
240
|
+
|
|
241
|
+
const errors = filteredDiagnostics
|
|
242
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Error)
|
|
243
|
+
.map((d) => {
|
|
244
|
+
const message = ts.flattenDiagnosticMessageText(d.messageText, "\n");
|
|
245
|
+
if (d.file != null && d.start != null) {
|
|
246
|
+
const { line, character } = d.file.getLineAndCharacterOfPosition(d.start);
|
|
247
|
+
return `${d.file.fileName}:${line + 1}:${character + 1}: TS${d.code}: ${message}`;
|
|
248
|
+
}
|
|
249
|
+
return `TS${d.code}: ${message}`;
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
return { serialized, errorCount, errors };
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function emitFiles(
|
|
256
|
+
program: NgtscProgram,
|
|
257
|
+
tsProgram: ts.Program,
|
|
258
|
+
pkgSrcDir: string,
|
|
259
|
+
output: BuildOutput,
|
|
260
|
+
): void {
|
|
261
|
+
const { transformers } = program.compiler.prepareEmit();
|
|
262
|
+
const normalizedSrcDir = pkgSrcDir.replace(/\\/g, "/");
|
|
263
|
+
|
|
264
|
+
for (const sf of tsProgram.getSourceFiles()) {
|
|
265
|
+
if (program.compiler.ignoreForEmit.has(sf)) continue;
|
|
266
|
+
// Only emit files from this package's src directory
|
|
267
|
+
if (!sf.fileName.includes(normalizedSrcDir)) continue;
|
|
268
|
+
|
|
269
|
+
tsProgram.emit(sf, undefined, undefined, output.dts && !output.js, transformers);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Run a full NgtscProgram build (parse, analyze, diagnostics, emit)
|
|
275
|
+
*/
|
|
276
|
+
export async function runNgtscBuild(info: NgtscBuildInfo): Promise<NgtscBuildResult> {
|
|
277
|
+
try {
|
|
278
|
+
const parsedConfig = parseTsconfig(info.pkgDir);
|
|
279
|
+
const sourceFiles = getPackageSourceFiles(info.pkgDir, parsedConfig);
|
|
280
|
+
const compilerOptions = buildCompilerOptions(parsedConfig.options, info.pkgDir, info.output);
|
|
281
|
+
const pkgSrcDir = path.join(info.pkgDir, "src");
|
|
282
|
+
|
|
283
|
+
const { program, scssErrors } = createNgtscProgramWithHost(
|
|
284
|
+
sourceFiles,
|
|
285
|
+
compilerOptions,
|
|
286
|
+
info,
|
|
287
|
+
info.output,
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
// AOT analysis
|
|
291
|
+
await program.compiler.analyzeAsync();
|
|
292
|
+
|
|
293
|
+
// Collect diagnostics
|
|
294
|
+
const tsProgram = program.getTsProgram();
|
|
295
|
+
const { serialized, errorCount, errors } = collectDiagnostics(program, tsProgram, pkgSrcDir);
|
|
296
|
+
|
|
297
|
+
// Emit if needed
|
|
298
|
+
if (info.output.js || info.output.dts) {
|
|
299
|
+
emitFiles(program, tsProgram, pkgSrcDir, info.output);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Global SCSS compilation
|
|
303
|
+
const globalScssErrors = compileGlobalScss(info.pkgDir, buildScssLoadPaths(info));
|
|
304
|
+
|
|
305
|
+
const allErrors = [...errors, ...scssErrors, ...globalScssErrors];
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
js: {
|
|
309
|
+
success: true,
|
|
310
|
+
errors: undefined,
|
|
311
|
+
warnings: undefined,
|
|
312
|
+
},
|
|
313
|
+
dts: {
|
|
314
|
+
success: errorCount === 0 && scssErrors.length === 0 && globalScssErrors.length === 0,
|
|
315
|
+
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
316
|
+
diagnostics: serialized,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
} catch (err) {
|
|
320
|
+
const message = errNs.message(err);
|
|
321
|
+
return {
|
|
322
|
+
js: { success: false, errors: [message] },
|
|
323
|
+
dts: { success: false, errors: [message], diagnostics: [] },
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Run NgtscProgram incremental rebuild (for watch mode)
|
|
330
|
+
*/
|
|
331
|
+
export async function runNgtscRebuild(
|
|
332
|
+
info: NgtscBuildInfo,
|
|
333
|
+
oldProg?: NgtscProgram,
|
|
334
|
+
modifiedResourceFiles?: Set<string>,
|
|
335
|
+
): Promise<{
|
|
336
|
+
result: NgtscCombinedBuildEvent;
|
|
337
|
+
program: NgtscProgram;
|
|
338
|
+
scssDependencies: Map<string, Set<string>>;
|
|
339
|
+
}> {
|
|
340
|
+
const parsedConfig = parseTsconfig(info.pkgDir);
|
|
341
|
+
const sourceFiles = getPackageSourceFiles(info.pkgDir, parsedConfig);
|
|
342
|
+
const compilerOptions = buildCompilerOptions(parsedConfig.options, info.pkgDir, info.output);
|
|
343
|
+
const pkgSrcDir = path.join(info.pkgDir, "src");
|
|
344
|
+
|
|
345
|
+
const { program, scssErrors, scssDependencies } = createNgtscProgramWithHost(
|
|
346
|
+
sourceFiles,
|
|
347
|
+
compilerOptions,
|
|
348
|
+
info,
|
|
349
|
+
info.output,
|
|
350
|
+
oldProg,
|
|
351
|
+
modifiedResourceFiles,
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
await program.compiler.analyzeAsync();
|
|
355
|
+
|
|
356
|
+
const tsProgram = program.getTsProgram();
|
|
357
|
+
const { errorCount, errors } = collectDiagnostics(program, tsProgram, pkgSrcDir);
|
|
358
|
+
|
|
359
|
+
if (info.output.js || info.output.dts) {
|
|
360
|
+
emitFiles(program, tsProgram, pkgSrcDir, info.output);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Global SCSS compilation
|
|
364
|
+
const globalScssErrors = compileGlobalScss(info.pkgDir, buildScssLoadPaths(info));
|
|
365
|
+
|
|
366
|
+
const allErrors = [...errors, ...scssErrors, ...globalScssErrors];
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
result: {
|
|
370
|
+
js: { success: true },
|
|
371
|
+
dts: {
|
|
372
|
+
success: errorCount === 0 && scssErrors.length === 0 && globalScssErrors.length === 0,
|
|
373
|
+
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
program,
|
|
377
|
+
scssDependencies,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { pathx } from "@simplysm/core-node";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Add .js extension to extensionless relative import/export paths in ESM output.
|
|
6
|
+
*
|
|
7
|
+
* Matches: from "./foo", import("./bar"), from "../baz"
|
|
8
|
+
* Skips: bare specifiers ("lodash"), paths already ending with known extensions (.js, .json, .css, etc.)
|
|
9
|
+
*/
|
|
10
|
+
export function addJsExtensionToImports(text: string): string {
|
|
11
|
+
return text.replace(
|
|
12
|
+
/((?:from|import)\s*(?:\(\s*)?["'])(\.\.?\/[^"']*?)(["'](?:\s*\))?)/g,
|
|
13
|
+
(_match, prefix: string, importPath: string, suffix: string) => {
|
|
14
|
+
if (/\.(js|mjs|cjs|json|css|wasm|node)$/i.test(importPath)) return _match;
|
|
15
|
+
return `${prefix}${importPath}.js${suffix}`;
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Adjust sources path in .d.ts.map file to new location
|
|
22
|
+
*/
|
|
23
|
+
export function adjustMapSources(content: string, originalDir: string, newDir: string): string {
|
|
24
|
+
if (originalDir === newDir) return content;
|
|
25
|
+
try {
|
|
26
|
+
const map = JSON.parse(content) as { sources?: string[] };
|
|
27
|
+
if (Array.isArray(map.sources)) {
|
|
28
|
+
map.sources = map.sources.map((source) => {
|
|
29
|
+
const absoluteSource = path.resolve(originalDir, source);
|
|
30
|
+
return path.relative(newDir, absoluteSource);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return JSON.stringify(map);
|
|
34
|
+
} catch {
|
|
35
|
+
return content;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create path rewriter function for NgtscProgram output files (.js, .d.ts, .d.ts.map)
|
|
41
|
+
*
|
|
42
|
+
* TypeScript/NgtscProgram includes other package sources referenced via path alias (@simplysm/*)
|
|
43
|
+
* in rootDir calculation, so output is generated as nested structure dist/{pkgName}/src/...
|
|
44
|
+
* The returned function rewrites only this package's output to flat structure (dist/...)
|
|
45
|
+
* and ignores output from other packages.
|
|
46
|
+
*
|
|
47
|
+
* @returns (fileName, content) => [newPath, newContent] | null (null to skip writing)
|
|
48
|
+
*/
|
|
49
|
+
export function createOutputPathRewriter(
|
|
50
|
+
pkgDir: string,
|
|
51
|
+
): (fileName: string, content: string) => [string, string] | null {
|
|
52
|
+
const pkgName = path.basename(pkgDir);
|
|
53
|
+
const distDir = pathx.norm(path.join(pkgDir, "dist"));
|
|
54
|
+
const distPrefix = distDir + path.sep;
|
|
55
|
+
// Nested structure prefix for this package: dist/{pkgName}/src/
|
|
56
|
+
const ownNestedPrefix = pathx.norm(path.join(distDir, pkgName, "src")) + path.sep;
|
|
57
|
+
|
|
58
|
+
return (fileName, content) => {
|
|
59
|
+
fileName = pathx.norm(fileName);
|
|
60
|
+
|
|
61
|
+
if (!fileName.startsWith(distPrefix)) return null;
|
|
62
|
+
|
|
63
|
+
if (fileName.startsWith(ownNestedPrefix)) {
|
|
64
|
+
// Rewrite nested path to flat: dist/{pkgName}/src/... → dist/...
|
|
65
|
+
const flatPath = path.join(distDir, fileName.slice(ownNestedPrefix.length));
|
|
66
|
+
if (fileName.endsWith(".d.ts.map") || fileName.endsWith(".js.map")) {
|
|
67
|
+
content = adjustMapSources(content, path.dirname(fileName), path.dirname(flatPath));
|
|
68
|
+
}
|
|
69
|
+
return [flatPath, content];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Nested output from other packages (dist/{otherPkg}/src/...) → ignore
|
|
73
|
+
const relFromDist = fileName.slice(distPrefix.length);
|
|
74
|
+
const segments = relFromDist.split(path.sep);
|
|
75
|
+
if (segments.length >= 3 && segments[1] === "src") {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Already flat structure (package with no dependencies) → output as is
|
|
80
|
+
return [fileName, content];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { consola } from "consola";
|
|
4
|
+
import { SdError } from "@simplysm/core-common";
|
|
4
5
|
import type { SdPackageConfig } from "../sd-config.types";
|
|
5
6
|
|
|
6
7
|
const logger = consola.withTag("sd:cli:package-utils");
|
|
@@ -91,6 +92,25 @@ export function collectDeps(
|
|
|
91
92
|
return { workspaceDeps, replaceDeps };
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Validate that all target names exist in the sdConfig packages.
|
|
97
|
+
* Throws SdError if any unknown targets are found.
|
|
98
|
+
* Does nothing when targets is empty.
|
|
99
|
+
* @param targets - package name list to validate
|
|
100
|
+
* @param packages - sdConfig.packages object
|
|
101
|
+
*/
|
|
102
|
+
export function validateTargets(
|
|
103
|
+
targets: string[],
|
|
104
|
+
packages: Record<string, unknown>,
|
|
105
|
+
): void {
|
|
106
|
+
if (targets.length === 0) return;
|
|
107
|
+
const packageNames = Object.keys(packages);
|
|
108
|
+
const unknown = targets.filter((t) => !packageNames.includes(t));
|
|
109
|
+
if (unknown.length > 0) {
|
|
110
|
+
throw new SdError(`Unknown target: ${unknown.join(", ")}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
94
114
|
/**
|
|
95
115
|
* Filter packages config by targets (excluding scripts target)
|
|
96
116
|
* @param packages Package config map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as sass from "sass";
|
|
2
|
+
import { pathToFileURL } from "url";
|
|
3
|
+
|
|
4
|
+
//#region Types
|
|
5
|
+
|
|
6
|
+
export interface ScssCompileResult {
|
|
7
|
+
css: string;
|
|
8
|
+
/** 컴파일에 참여한 의존 파일 목록 (loadedUrls -> 절대 경로) */
|
|
9
|
+
dependencies: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
|
|
14
|
+
//#region Private helpers
|
|
15
|
+
|
|
16
|
+
function extractDependencies(loadedUrls: URL[]): string[] {
|
|
17
|
+
return loadedUrls
|
|
18
|
+
.filter((url) => url.protocol === "file:")
|
|
19
|
+
.map((url) => url.pathname.replace(/^\/([A-Za-z]:)/, "$1"));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
|
|
24
|
+
//#region Public API
|
|
25
|
+
|
|
26
|
+
/** 인라인 SCSS 문자열을 CSS로 컴파일한다 */
|
|
27
|
+
export function compileScssString(
|
|
28
|
+
source: string,
|
|
29
|
+
containingFile: string,
|
|
30
|
+
loadPaths: string[],
|
|
31
|
+
): ScssCompileResult {
|
|
32
|
+
const result = sass.compileString(source, {
|
|
33
|
+
url: pathToFileURL(containingFile),
|
|
34
|
+
loadPaths,
|
|
35
|
+
silenceDeprecations: ["color-functions", "global-builtin", "import", "legacy-js-api"],
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
css: result.css,
|
|
39
|
+
dependencies: extractDependencies(result.loadedUrls),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** 외부 SCSS 파일을 CSS로 컴파일한다 */
|
|
44
|
+
export function compileScssFile(
|
|
45
|
+
filePath: string,
|
|
46
|
+
loadPaths: string[],
|
|
47
|
+
): ScssCompileResult {
|
|
48
|
+
const result = sass.compile(filePath, {
|
|
49
|
+
loadPaths,
|
|
50
|
+
silenceDeprecations: ["color-functions", "global-builtin", "import", "legacy-js-api"],
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
css: result.css,
|
|
54
|
+
dependencies: extractDependencies(result.loadedUrls),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|