@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,49 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("sd-cli-entry COMMAND_NAMES", () => {
|
|
4
|
+
it("does not include device command", async () => {
|
|
5
|
+
// Import the module to check COMMAND_NAMES indirectly via createCliParser
|
|
6
|
+
const { createCliParser } = await import("../src/sd-cli-entry");
|
|
7
|
+
|
|
8
|
+
// device command should not be registered — parsing "device" should fail
|
|
9
|
+
let errorThrown = false;
|
|
10
|
+
const origExit = process.exit;
|
|
11
|
+
const origError = console.error;
|
|
12
|
+
const origLog = console.log;
|
|
13
|
+
|
|
14
|
+
// Suppress yargs output during test
|
|
15
|
+
console.error = () => {};
|
|
16
|
+
console.log = () => {};
|
|
17
|
+
process.exit = (() => {
|
|
18
|
+
errorThrown = true;
|
|
19
|
+
}) as never;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
await createCliParser(["device"]).exitProcess(false).fail(() => {
|
|
23
|
+
errorThrown = true;
|
|
24
|
+
}).parse();
|
|
25
|
+
} catch {
|
|
26
|
+
errorThrown = true;
|
|
27
|
+
} finally {
|
|
28
|
+
process.exit = origExit;
|
|
29
|
+
console.error = origError;
|
|
30
|
+
console.log = origLog;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
expect(errorThrown).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("includes expected commands", async () => {
|
|
37
|
+
const { createCliParser } = await import("../src/sd-cli-entry");
|
|
38
|
+
|
|
39
|
+
// These commands should be registered without throwing
|
|
40
|
+
const expectedCommands = ["lint", "typecheck", "check", "watch", "dev", "build", "init", "publish", "replace-deps"];
|
|
41
|
+
|
|
42
|
+
for (const cmd of expectedCommands) {
|
|
43
|
+
// Verify command exists by checking help doesn't throw for "unknown command"
|
|
44
|
+
const parser = createCliParser([cmd, "--help"]).exitProcess(false);
|
|
45
|
+
// Just verify it can be created without error
|
|
46
|
+
expect(parser).toBeDefined();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeAll } from "vitest";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
buildApplicationInternal,
|
|
6
|
+
createAngularBuilderContext,
|
|
7
|
+
ResultKind,
|
|
8
|
+
} from "../../src/utils/angular-build";
|
|
9
|
+
|
|
10
|
+
describe("Angular Build Adapter - Slice 1", () => {
|
|
11
|
+
// Rule: 어댑터는 @angular/build/private 임포트를 단일 모듈에 격리한다
|
|
12
|
+
it("exports buildApplicationInternal from adapter module", () => {
|
|
13
|
+
expect(typeof buildApplicationInternal).toBe("function");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("exports ResultKind enum from adapter module", () => {
|
|
17
|
+
expect(ResultKind.Failure).toBeDefined();
|
|
18
|
+
expect(ResultKind.Full).toBeDefined();
|
|
19
|
+
expect(ResultKind.Incremental).toBeDefined();
|
|
20
|
+
expect(ResultKind.ComponentUpdate).toBeDefined();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Rule: 어댑터는 BuilderContext를 내부적으로 생성한다
|
|
24
|
+
describe("createAngularBuilderContext", () => {
|
|
25
|
+
const baseOptions = {
|
|
26
|
+
workspaceRoot: "/test/workspace",
|
|
27
|
+
projectName: "test-app",
|
|
28
|
+
projectRoot: "packages/test-app",
|
|
29
|
+
buildOptions: { tsConfig: "./tsconfig.json", aot: true },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
it("creates context with workspaceRoot", () => {
|
|
33
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
34
|
+
expect(ctx.workspaceRoot).toBe("/test/workspace");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("creates context with target containing project name", () => {
|
|
38
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
39
|
+
expect(ctx.target.project).toBe("test-app");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("creates context with logger that has info/warn/error methods", () => {
|
|
43
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
44
|
+
expect(typeof ctx.logger.info).toBe("function");
|
|
45
|
+
expect(typeof ctx.logger.warn).toBe("function");
|
|
46
|
+
expect(typeof ctx.logger.error).toBe("function");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("getProjectMetadata returns root and sourceRoot", async () => {
|
|
50
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
51
|
+
const metadata = await ctx.getProjectMetadata("test-app");
|
|
52
|
+
expect(metadata).toEqual(
|
|
53
|
+
expect.objectContaining({
|
|
54
|
+
root: "packages/test-app",
|
|
55
|
+
sourceRoot: "src",
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("getProjectMetadata uses custom sourceRoot when provided", async () => {
|
|
61
|
+
const ctx = createAngularBuilderContext({
|
|
62
|
+
...baseOptions,
|
|
63
|
+
sourceRoot: "lib",
|
|
64
|
+
});
|
|
65
|
+
const metadata = await ctx.getProjectMetadata("test-app");
|
|
66
|
+
expect(metadata).toEqual(
|
|
67
|
+
expect.objectContaining({
|
|
68
|
+
root: "packages/test-app",
|
|
69
|
+
sourceRoot: "lib",
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("addTeardown registers cleanup callback and disposeTeardowns executes them", async () => {
|
|
75
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
76
|
+
const teardownFn1 = vi.fn();
|
|
77
|
+
const teardownFn2 = vi.fn();
|
|
78
|
+
ctx.addTeardown(teardownFn1);
|
|
79
|
+
ctx.addTeardown(teardownFn2);
|
|
80
|
+
|
|
81
|
+
expect(teardownFn1).not.toHaveBeenCalled();
|
|
82
|
+
expect(teardownFn2).not.toHaveBeenCalled();
|
|
83
|
+
|
|
84
|
+
await ctx.disposeTeardowns();
|
|
85
|
+
|
|
86
|
+
expect(teardownFn1).toHaveBeenCalledOnce();
|
|
87
|
+
expect(teardownFn2).toHaveBeenCalledOnce();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("passes signal to context when provided", () => {
|
|
91
|
+
const controller = new AbortController();
|
|
92
|
+
const ctx = createAngularBuilderContext({
|
|
93
|
+
...baseOptions,
|
|
94
|
+
signal: controller.signal as AbortSignal,
|
|
95
|
+
}) as { signal?: AbortSignal };
|
|
96
|
+
expect(ctx.signal).toBe(controller.signal);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Rule: 어댑터는 AOT 전용이다
|
|
101
|
+
it("exports checkPort utility from adapter module", async () => {
|
|
102
|
+
const { checkPort } = await import("../../src/utils/angular-build");
|
|
103
|
+
expect(typeof checkPort).toBe("function");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("exports emitFilesToDisk utility from adapter module", async () => {
|
|
107
|
+
const { emitFilesToDisk } = await import("../../src/utils/angular-build");
|
|
108
|
+
expect(typeof emitFilesToDisk).toBe("function");
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe("Angular Build Adapter - Library Compilation API", () => {
|
|
113
|
+
// Rule: 어댑터는 Library 빌드에 필요한 Angular 컴파일러 API를 노출한다
|
|
114
|
+
|
|
115
|
+
it("exports NgtscProgram from adapter module", async () => {
|
|
116
|
+
const { NgtscProgram } = await import("../../src/utils/angular-build");
|
|
117
|
+
expect(typeof NgtscProgram).toBe("function");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("exports OptimizeFor enum from adapter module", async () => {
|
|
121
|
+
const { OptimizeFor } = await import("../../src/utils/angular-build");
|
|
122
|
+
expect(OptimizeFor.WholeProgram).toBeDefined();
|
|
123
|
+
expect(OptimizeFor.SingleFile).toBeDefined();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("NgtscProgram accepts ts.CompilerHost augmented with AngularLibraryHostExtensions", async () => {
|
|
127
|
+
const mod = await import("../../src/utils/angular-build");
|
|
128
|
+
// AngularLibraryHostExtensions는 타입 전용이므로 런타임 값은 없다.
|
|
129
|
+
// NgtscProgram이 export되어 있으면 소비자가 타입을 조합하여 host를 만들 수 있다.
|
|
130
|
+
expect(typeof mod.NgtscProgram).toBe("function");
|
|
131
|
+
// 타입 검증: AngularLibraryHostExtensions가 export되는지는 TypeScript 컴파일로 확인
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe("Angular Build Adapter - Slice 2", () => {
|
|
136
|
+
// Rule: 어댑터는 Dev Server API를 제공한다
|
|
137
|
+
it("exports serveWithVite from adapter module", async () => {
|
|
138
|
+
const { serveWithVite } = await import("../../src/utils/angular-build");
|
|
139
|
+
expect(typeof serveWithVite).toBe("function");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("exports normalizeDevServerOptions from adapter module", async () => {
|
|
143
|
+
const { normalizeDevServerOptions } = await import("../../src/utils/angular-build");
|
|
144
|
+
expect(typeof normalizeDevServerOptions).toBe("function");
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Rule: 어댑터는 IndexHtmlGenerator를 제공한다
|
|
148
|
+
it("exports IndexHtmlGenerator from adapter module", async () => {
|
|
149
|
+
const { IndexHtmlGenerator } = await import("../../src/utils/angular-build");
|
|
150
|
+
expect(typeof IndexHtmlGenerator).toBe("function");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// BuilderContext dev server 필드 테스트
|
|
154
|
+
describe("createAngularBuilderContext - dev server fields", () => {
|
|
155
|
+
const baseOptions = {
|
|
156
|
+
workspaceRoot: "/test/workspace",
|
|
157
|
+
projectName: "test-app",
|
|
158
|
+
projectRoot: "packages/test-app",
|
|
159
|
+
buildOptions: { tsConfig: "./tsconfig.json", aot: true, browser: "./src/main.ts" },
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
it("getTargetOptions returns provided buildOptions", async () => {
|
|
163
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
164
|
+
const opts = await ctx.getTargetOptions({ project: "test-app", target: "build" });
|
|
165
|
+
expect(opts).toEqual(baseOptions.buildOptions);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("getBuilderNameForTarget returns @angular/build:application", async () => {
|
|
169
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
170
|
+
const name = await ctx.getBuilderNameForTarget({ project: "test-app", target: "build" });
|
|
171
|
+
expect(name).toBe("@angular/build:application");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("validateOptions returns options as passthrough", async () => {
|
|
175
|
+
const ctx = createAngularBuilderContext(baseOptions);
|
|
176
|
+
const input = { tsConfig: "./tsconfig.json", aot: true };
|
|
177
|
+
const result = await ctx.validateOptions(input, "@angular/build:application");
|
|
178
|
+
expect(result).toEqual(input);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe("Angular Build Adapter - Isolation & Scope", () => {
|
|
184
|
+
const sdCliSrcDir = path.resolve(import.meta.dirname, "../../src");
|
|
185
|
+
const adapterFileName = "angular-build.ts";
|
|
186
|
+
let srcFiles: string[];
|
|
187
|
+
|
|
188
|
+
beforeAll(() => {
|
|
189
|
+
const collectFiles = (dir: string): string[] => {
|
|
190
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
191
|
+
return entries.flatMap((e) =>
|
|
192
|
+
e.isDirectory()
|
|
193
|
+
? collectFiles(path.join(dir, e.name))
|
|
194
|
+
: e.name.endsWith(".ts")
|
|
195
|
+
? [path.join(dir, e.name)]
|
|
196
|
+
: [],
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
srcFiles = collectFiles(sdCliSrcDir).filter(
|
|
200
|
+
(f) => !f.endsWith(adapterFileName),
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Rule: 모든 Angular private/internal API 접근은 어댑터 모듈을 통해서만 한다
|
|
205
|
+
it("no src file outside adapter imports @angular/build/private", () => {
|
|
206
|
+
for (const file of srcFiles) {
|
|
207
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
208
|
+
expect(
|
|
209
|
+
content.includes("@angular/build/private"),
|
|
210
|
+
`${path.relative(sdCliSrcDir, file)} imports @angular/build/private directly`,
|
|
211
|
+
).toBe(false);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("no src file outside adapter imports @angular/compiler-cli", () => {
|
|
216
|
+
for (const file of srcFiles) {
|
|
217
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
218
|
+
expect(
|
|
219
|
+
content.includes("@angular/compiler-cli"),
|
|
220
|
+
`${path.relative(sdCliSrcDir, file)} imports @angular/compiler-cli directly`,
|
|
221
|
+
).toBe(false);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// Rule: @angular/compiler-cli는 sd-cli의 직접 의존성이다
|
|
226
|
+
it("package.json includes @angular/compiler-cli in dependencies", () => {
|
|
227
|
+
const pkgJson = JSON.parse(
|
|
228
|
+
fs.readFileSync(
|
|
229
|
+
path.resolve(import.meta.dirname, "../../package.json"),
|
|
230
|
+
"utf-8",
|
|
231
|
+
),
|
|
232
|
+
);
|
|
233
|
+
expect(pkgJson.dependencies["@angular/compiler-cli"]).toBeDefined();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Rule: 래핑 범위는 현재 필요한 API만 포함한다
|
|
237
|
+
it("adapter does not export browserslist/PostCSS APIs", async () => {
|
|
238
|
+
const mod = await import("../../src/utils/angular-build");
|
|
239
|
+
const exports = Object.keys(mod);
|
|
240
|
+
expect(exports).not.toContain("transformSupportedBrowsersToTargets");
|
|
241
|
+
expect(exports).not.toContain("getSupportedBrowsers");
|
|
242
|
+
expect(exports).not.toContain("loadPostcssConfiguration");
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("adapter does not export ServiceWorker/i18n APIs", async () => {
|
|
246
|
+
const mod = await import("../../src/utils/angular-build");
|
|
247
|
+
const exports = Object.keys(mod);
|
|
248
|
+
expect(exports).not.toContain("augmentAppWithServiceWorker");
|
|
249
|
+
expect(exports).not.toContain("createI18nOptions");
|
|
250
|
+
});
|
|
251
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
+
import { getVersion } from "../../src/utils/build-env";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import fs from "fs/promises";
|
|
5
|
+
import os from "os";
|
|
6
|
+
|
|
7
|
+
describe("getVersion", () => {
|
|
8
|
+
const tmpDirs: string[] = [];
|
|
9
|
+
|
|
10
|
+
async function createTmpDir(pkgJson: Record<string, unknown>): Promise<string> {
|
|
11
|
+
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "sd-cli-test-"));
|
|
12
|
+
tmpDirs.push(dir);
|
|
13
|
+
await fs.writeFile(path.join(dir, "package.json"), JSON.stringify(pkgJson));
|
|
14
|
+
return dir;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
afterEach(async () => {
|
|
18
|
+
for (const dir of tmpDirs) {
|
|
19
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
20
|
+
}
|
|
21
|
+
tmpDirs.length = 0;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("returns version from package.json", async () => {
|
|
25
|
+
const dir = await createTmpDir({ version: "14.0.0" });
|
|
26
|
+
expect(await getVersion(dir)).toBe("14.0.0");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns '0.0.0' when version field is missing", async () => {
|
|
30
|
+
const dir = await createTmpDir({ name: "test-pkg" });
|
|
31
|
+
expect(await getVersion(dir)).toBe("0.0.0");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("runWithConcurrency", () => {
|
|
4
|
+
it("limits concurrent task execution to specified concurrency", async () => {
|
|
5
|
+
const { runWithConcurrency } = await import("../../src/utils/concurrency");
|
|
6
|
+
|
|
7
|
+
let activeTasks = 0;
|
|
8
|
+
let maxActiveTasks = 0;
|
|
9
|
+
|
|
10
|
+
const tasks = Array.from({ length: 10 }, () => async () => {
|
|
11
|
+
activeTasks++;
|
|
12
|
+
maxActiveTasks = Math.max(maxActiveTasks, activeTasks);
|
|
13
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
14
|
+
activeTasks--;
|
|
15
|
+
return "done";
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const results = await runWithConcurrency(tasks, 3);
|
|
19
|
+
|
|
20
|
+
expect(maxActiveTasks).toBeLessThanOrEqual(3);
|
|
21
|
+
expect(results).toHaveLength(10);
|
|
22
|
+
expect(results.every((r) => r.status === "fulfilled")).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns all results in order even when individual tasks fail", async () => {
|
|
26
|
+
const { runWithConcurrency } = await import("../../src/utils/concurrency");
|
|
27
|
+
|
|
28
|
+
const tasks = [
|
|
29
|
+
() => Promise.resolve("a"),
|
|
30
|
+
() => { throw new Error("fail"); },
|
|
31
|
+
() => Promise.resolve("c"),
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const results = await runWithConcurrency(tasks, 2);
|
|
35
|
+
|
|
36
|
+
expect(results).toHaveLength(3);
|
|
37
|
+
expect(results[0]).toEqual({ status: "fulfilled", value: "a" });
|
|
38
|
+
expect(results[1].status).toBe("rejected");
|
|
39
|
+
expect(results[2]).toEqual({ status: "fulfilled", value: "c" });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("handles empty task list", async () => {
|
|
43
|
+
const { runWithConcurrency } = await import("../../src/utils/concurrency");
|
|
44
|
+
|
|
45
|
+
const results = await runWithConcurrency([], 3);
|
|
46
|
+
expect(results).toHaveLength(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("works when concurrency exceeds task count", async () => {
|
|
50
|
+
const { runWithConcurrency } = await import("../../src/utils/concurrency");
|
|
51
|
+
|
|
52
|
+
const tasks = [() => Promise.resolve(1), () => Promise.resolve(2)];
|
|
53
|
+
const results = await runWithConcurrency(tasks, 10);
|
|
54
|
+
|
|
55
|
+
expect(results).toHaveLength(2);
|
|
56
|
+
expect(results.every((r) => r.status === "fulfilled")).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("getMaxConcurrency", () => {
|
|
61
|
+
it("returns at least 1", async () => {
|
|
62
|
+
const { getMaxConcurrency } = await import("../../src/utils/concurrency");
|
|
63
|
+
expect(getMaxConcurrency()).toBeGreaterThanOrEqual(1);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
const mockOnChange = vi.fn();
|
|
5
|
+
const mockWatcherClose = vi.fn();
|
|
6
|
+
|
|
7
|
+
vi.mock("@simplysm/core-node", () => ({
|
|
8
|
+
fsx: {
|
|
9
|
+
glob: vi.fn(),
|
|
10
|
+
mkdir: vi.fn(),
|
|
11
|
+
copy: vi.fn(),
|
|
12
|
+
rm: vi.fn(),
|
|
13
|
+
},
|
|
14
|
+
FsWatcher: {
|
|
15
|
+
watch: vi.fn(() => Promise.resolve({
|
|
16
|
+
onChange: mockOnChange,
|
|
17
|
+
close: mockWatcherClose,
|
|
18
|
+
})),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const { fsx, FsWatcher } = await import("@simplysm/core-node");
|
|
23
|
+
const { copySrcFiles, watchCopySrcFiles } = await import("../../src/utils/copy-src");
|
|
24
|
+
|
|
25
|
+
const pkgDir = path.resolve("/workspace/packages/my-pkg");
|
|
26
|
+
const srcDir = path.join(pkgDir, "src");
|
|
27
|
+
const distDir = path.join(pkgDir, "dist");
|
|
28
|
+
|
|
29
|
+
describe("copySrcFiles", () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.mocked(fsx.glob).mockReset();
|
|
32
|
+
vi.mocked(fsx.mkdir).mockReset();
|
|
33
|
+
vi.mocked(fsx.copy).mockReset();
|
|
34
|
+
vi.mocked(fsx.mkdir).mockResolvedValue(undefined as any);
|
|
35
|
+
vi.mocked(fsx.copy).mockResolvedValue(undefined as any);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("copies files matching glob patterns preserving relative paths", async () => {
|
|
39
|
+
vi.mocked(fsx.glob).mockResolvedValue([
|
|
40
|
+
path.join(srcDir, "styles", "app.css"),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
await copySrcFiles(pkgDir, ["**/*.css"]);
|
|
44
|
+
|
|
45
|
+
expect(fsx.glob).toHaveBeenCalledWith("**/*.css", { cwd: srcDir, absolute: true });
|
|
46
|
+
expect(fsx.mkdir).toHaveBeenCalledWith(path.join(distDir, "styles"));
|
|
47
|
+
expect(fsx.copy).toHaveBeenCalledWith(
|
|
48
|
+
path.join(srcDir, "styles", "app.css"),
|
|
49
|
+
path.join(distDir, "styles", "app.css"),
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("handles multiple patterns", async () => {
|
|
54
|
+
vi.mocked(fsx.glob)
|
|
55
|
+
.mockResolvedValueOnce([path.join(srcDir, "a.css")])
|
|
56
|
+
.mockResolvedValueOnce([path.join(srcDir, "b.json")]);
|
|
57
|
+
|
|
58
|
+
await copySrcFiles(pkgDir, ["**/*.css", "**/*.json"]);
|
|
59
|
+
|
|
60
|
+
expect(fsx.glob).toHaveBeenCalledTimes(2);
|
|
61
|
+
expect(fsx.copy).toHaveBeenCalledTimes(2);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("does nothing when no files match", async () => {
|
|
65
|
+
vi.mocked(fsx.glob).mockResolvedValue([]);
|
|
66
|
+
|
|
67
|
+
await copySrcFiles(pkgDir, ["**/*.css"]);
|
|
68
|
+
|
|
69
|
+
expect(fsx.copy).not.toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("watchCopySrcFiles", () => {
|
|
74
|
+
beforeEach(() => {
|
|
75
|
+
vi.mocked(fsx.glob).mockReset();
|
|
76
|
+
vi.mocked(fsx.mkdir).mockReset();
|
|
77
|
+
vi.mocked(fsx.copy).mockReset();
|
|
78
|
+
vi.mocked(fsx.rm).mockReset();
|
|
79
|
+
mockOnChange.mockReset();
|
|
80
|
+
vi.mocked(fsx.glob).mockResolvedValue([]);
|
|
81
|
+
vi.mocked(fsx.mkdir).mockResolvedValue(undefined as any);
|
|
82
|
+
vi.mocked(fsx.copy).mockResolvedValue(undefined as any);
|
|
83
|
+
vi.mocked(fsx.rm).mockResolvedValue(undefined as any);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("performs initial copy then starts watch", async () => {
|
|
87
|
+
const watcher = await watchCopySrcFiles(pkgDir, ["**/*.css"]);
|
|
88
|
+
|
|
89
|
+
expect(fsx.glob).toHaveBeenCalledWith("**/*.css", { cwd: srcDir, absolute: true });
|
|
90
|
+
expect(FsWatcher.watch).toHaveBeenCalledWith([path.join(srcDir, "**/*.css")]);
|
|
91
|
+
expect(mockOnChange).toHaveBeenCalledWith({ delay: 300 }, expect.any(Function));
|
|
92
|
+
expect(watcher).toBeDefined();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("copies file on add/change event", async () => {
|
|
96
|
+
await watchCopySrcFiles(pkgDir, ["**/*.css"]);
|
|
97
|
+
|
|
98
|
+
// Get the onChange callback
|
|
99
|
+
const onChangeCallback = mockOnChange.mock.calls[0][1] as (
|
|
100
|
+
changes: Array<{ event: string; path: string }>,
|
|
101
|
+
) => Promise<void>;
|
|
102
|
+
|
|
103
|
+
await onChangeCallback([
|
|
104
|
+
{ event: "change", path: path.join(srcDir, "styles", "app.css") },
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
expect(fsx.mkdir).toHaveBeenCalledWith(path.join(distDir, "styles"));
|
|
108
|
+
expect(fsx.copy).toHaveBeenCalledWith(
|
|
109
|
+
path.join(srcDir, "styles", "app.css"),
|
|
110
|
+
path.join(distDir, "styles", "app.css"),
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("deletes dist file on unlink event", async () => {
|
|
115
|
+
await watchCopySrcFiles(pkgDir, ["**/*.css"]);
|
|
116
|
+
|
|
117
|
+
const onChangeCallback = mockOnChange.mock.calls[0][1] as (
|
|
118
|
+
changes: Array<{ event: string; path: string }>,
|
|
119
|
+
) => Promise<void>;
|
|
120
|
+
|
|
121
|
+
await onChangeCallback([
|
|
122
|
+
{ event: "unlink", path: path.join(srcDir, "styles", "old.css") },
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
expect(fsx.rm).toHaveBeenCalledWith(path.join(distDir, "styles", "old.css"));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("handles add event same as change event", async () => {
|
|
129
|
+
await watchCopySrcFiles(pkgDir, ["**/*.css"]);
|
|
130
|
+
|
|
131
|
+
const onChangeCallback = mockOnChange.mock.calls[0][1] as (
|
|
132
|
+
changes: Array<{ event: string; path: string }>,
|
|
133
|
+
) => Promise<void>;
|
|
134
|
+
|
|
135
|
+
await onChangeCallback([
|
|
136
|
+
{ event: "add", path: path.join(srcDir, "new.css") },
|
|
137
|
+
]);
|
|
138
|
+
|
|
139
|
+
expect(fsx.copy).toHaveBeenCalledWith(
|
|
140
|
+
path.join(srcDir, "new.css"),
|
|
141
|
+
path.join(distDir, "new.css"),
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
});
|