@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
package/tests/sd-cli.spec.ts
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { consola, LogLevels } from "consola";
|
|
3
|
-
|
|
4
|
-
// Mock runLint, runTypecheck, runWatch, runCheck
|
|
5
|
-
vi.mock("../src/commands/lint", () => ({
|
|
6
|
-
runLint: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
vi.mock("../src/commands/typecheck", () => ({
|
|
10
|
-
runTypecheck: vi.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
vi.mock("../src/commands/check", () => ({
|
|
14
|
-
runCheck: vi.fn(),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
vi.mock("../src/commands/watch", () => ({
|
|
18
|
-
runWatch: vi.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
vi.mock("../src/commands/build", () => ({
|
|
22
|
-
runBuild: vi.fn(),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
vi.mock("../src/commands/publish", () => ({
|
|
26
|
-
runPublish: vi.fn(),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
import { createCliParser } from "../src/sd-cli-entry";
|
|
30
|
-
import { runLint } from "../src/commands/lint";
|
|
31
|
-
import { runTypecheck } from "../src/commands/typecheck";
|
|
32
|
-
import { runCheck } from "../src/commands/check";
|
|
33
|
-
import { runWatch } from "../src/commands/watch";
|
|
34
|
-
import { runBuild } from "../src/commands/build";
|
|
35
|
-
import { runPublish } from "../src/commands/publish";
|
|
36
|
-
|
|
37
|
-
describe("sd-cli", () => {
|
|
38
|
-
let originalConsolaLevel: number;
|
|
39
|
-
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
vi.clearAllMocks();
|
|
42
|
-
vi.mocked(runLint).mockResolvedValue(undefined);
|
|
43
|
-
vi.mocked(runTypecheck).mockResolvedValue(undefined);
|
|
44
|
-
vi.mocked(runCheck).mockResolvedValue(undefined);
|
|
45
|
-
vi.mocked(runWatch).mockResolvedValue(undefined);
|
|
46
|
-
vi.mocked(runBuild).mockResolvedValue(undefined);
|
|
47
|
-
vi.mocked(runPublish).mockResolvedValue(undefined);
|
|
48
|
-
originalConsolaLevel = consola.level;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
afterEach(() => {
|
|
52
|
-
vi.restoreAllMocks();
|
|
53
|
-
consola.level = originalConsolaLevel;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("lint command", () => {
|
|
57
|
-
it("calls runLint with correct options", async () => {
|
|
58
|
-
await createCliParser(["lint", "packages/core-common", "--fix"]).parse();
|
|
59
|
-
|
|
60
|
-
expect(runLint).toHaveBeenCalledWith({
|
|
61
|
-
targets: ["packages/core-common"],
|
|
62
|
-
fix: true,
|
|
63
|
-
timing: false,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("passes --timing option correctly", async () => {
|
|
68
|
-
await createCliParser(["lint", "--timing"]).parse();
|
|
69
|
-
|
|
70
|
-
expect(runLint).toHaveBeenCalledWith({
|
|
71
|
-
targets: [],
|
|
72
|
-
fix: false,
|
|
73
|
-
timing: true,
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe("typecheck command", () => {
|
|
80
|
-
it("calls runTypecheck with correct options", async () => {
|
|
81
|
-
await createCliParser(["typecheck", "packages/cli"]).parse();
|
|
82
|
-
|
|
83
|
-
expect(runTypecheck).toHaveBeenCalledWith({
|
|
84
|
-
targets: ["packages/cli"],
|
|
85
|
-
options: [],
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("passes multiple targets to typecheck command", async () => {
|
|
90
|
-
await createCliParser(["typecheck", "packages/core-common", "packages/core-node"]).parse();
|
|
91
|
-
|
|
92
|
-
expect(runTypecheck).toHaveBeenCalledWith({
|
|
93
|
-
targets: ["packages/core-common", "packages/core-node"],
|
|
94
|
-
options: [],
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("passes --options option correctly", async () => {
|
|
99
|
-
await createCliParser(["typecheck", "-o", "dev", "-o", "test"]).parse();
|
|
100
|
-
|
|
101
|
-
expect(runTypecheck).toHaveBeenCalledWith({
|
|
102
|
-
targets: [],
|
|
103
|
-
options: ["dev", "test"],
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe("check command", () => {
|
|
109
|
-
it("calls runCheck with correct options", async () => {
|
|
110
|
-
await createCliParser(["check", "packages/core-common", "--type", "typecheck,lint"]).parse();
|
|
111
|
-
|
|
112
|
-
expect(runCheck).toHaveBeenCalledWith({
|
|
113
|
-
targets: ["packages/core-common"],
|
|
114
|
-
types: ["typecheck", "lint"],
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("specifies single type using --type option", async () => {
|
|
119
|
-
await createCliParser(["check", "--type", "test"]).parse();
|
|
120
|
-
|
|
121
|
-
expect(runCheck).toHaveBeenCalledWith({
|
|
122
|
-
targets: [],
|
|
123
|
-
types: ["test"],
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe("watch command", () => {
|
|
129
|
-
it("calls runWatch with correct options", async () => {
|
|
130
|
-
await createCliParser(["watch", "solid"]).parse();
|
|
131
|
-
|
|
132
|
-
expect(runWatch).toHaveBeenCalledWith({
|
|
133
|
-
targets: ["solid"],
|
|
134
|
-
options: [],
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe("build command", () => {
|
|
141
|
-
it("calls runBuild with correct options", async () => {
|
|
142
|
-
await createCliParser(["build", "solid", "core-common"]).parse();
|
|
143
|
-
|
|
144
|
-
expect(runBuild).toHaveBeenCalledWith({
|
|
145
|
-
targets: ["solid", "core-common"],
|
|
146
|
-
options: [],
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
describe("publish command", () => {
|
|
153
|
-
it("calls runPublish with correct options", async () => {
|
|
154
|
-
await createCliParser(["publish", "solid", "core-common"]).parse();
|
|
155
|
-
|
|
156
|
-
expect(runPublish).toHaveBeenCalledWith({
|
|
157
|
-
targets: ["solid", "core-common"],
|
|
158
|
-
noBuild: false,
|
|
159
|
-
dryRun: false,
|
|
160
|
-
options: [],
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("passes --no-build option correctly", async () => {
|
|
165
|
-
await createCliParser(["publish", "--no-build"]).parse();
|
|
166
|
-
|
|
167
|
-
expect(runPublish).toHaveBeenCalledWith({
|
|
168
|
-
targets: [],
|
|
169
|
-
noBuild: true,
|
|
170
|
-
dryRun: false,
|
|
171
|
-
options: [],
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("passes --options option correctly", async () => {
|
|
176
|
-
await createCliParser(["publish", "-o", "prod", "-o", "test"]).parse();
|
|
177
|
-
|
|
178
|
-
expect(runPublish).toHaveBeenCalledWith({
|
|
179
|
-
targets: [],
|
|
180
|
-
noBuild: false,
|
|
181
|
-
dryRun: false,
|
|
182
|
-
options: ["prod", "test"],
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("passes all options together", async () => {
|
|
187
|
-
await createCliParser(["publish", "solid", "--no-build", "-o", "prod"]).parse();
|
|
188
|
-
|
|
189
|
-
expect(runPublish).toHaveBeenCalledWith({
|
|
190
|
-
targets: ["solid"],
|
|
191
|
-
noBuild: true,
|
|
192
|
-
dryRun: false,
|
|
193
|
-
options: ["prod"],
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it("passes --dry-run option correctly", async () => {
|
|
198
|
-
await createCliParser(["publish", "--dry-run"]).parse();
|
|
199
|
-
|
|
200
|
-
expect(runPublish).toHaveBeenCalledWith({
|
|
201
|
-
targets: [],
|
|
202
|
-
noBuild: false,
|
|
203
|
-
dryRun: true,
|
|
204
|
-
options: [],
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
describe("global --debug option", () => {
|
|
211
|
-
it("sets consola.level to debug with --debug option", async () => {
|
|
212
|
-
await createCliParser(["--debug", "lint"]).parse();
|
|
213
|
-
|
|
214
|
-
expect(consola.level).toBe(LogLevels.debug);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
describe("--help shows all commands", () => {
|
|
220
|
-
it("shows help for all commands", async () => {
|
|
221
|
-
const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
222
|
-
|
|
223
|
-
await createCliParser(["--help"]).parse();
|
|
224
|
-
|
|
225
|
-
const output = logSpy.mock.calls.map((c) => c.join(" ")).join("\n");
|
|
226
|
-
|
|
227
|
-
// All command names are included in the output
|
|
228
|
-
for (const cmd of ["lint", "typecheck", "check", "watch", "dev", "build", "device", "init", "publish", "replace-deps"]) {
|
|
229
|
-
expect(output).toContain(cmd);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Each command's unique options are included in the output
|
|
233
|
-
expect(output).toContain("--fix");
|
|
234
|
-
expect(output).toContain("--timing");
|
|
235
|
-
expect(output).toContain("--no-build");
|
|
236
|
-
expect(output).toContain("--dry-run");
|
|
237
|
-
|
|
238
|
-
logSpy.mockRestore();
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe("error handling", () => {
|
|
243
|
-
it("throws error on unknown command", async () => {
|
|
244
|
-
let errorMessage: string | undefined;
|
|
245
|
-
const parser = createCliParser(["unknown"]).fail((msg) => {
|
|
246
|
-
errorMessage = msg;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
await parser.parse();
|
|
250
|
-
|
|
251
|
-
expect(errorMessage).toMatch(/Unknown argument|알 수 없는 인수/);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("throws error when no command specified", async () => {
|
|
255
|
-
let errorMessage: string | undefined;
|
|
256
|
-
const parser = createCliParser([]).fail((msg) => {
|
|
257
|
-
errorMessage = msg;
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
await parser.parse();
|
|
261
|
-
|
|
262
|
-
expect(errorMessage).toMatch(/Please specify a command/);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getMimeType } from "../src/utils/vite-config";
|
|
3
|
-
|
|
4
|
-
describe("getMimeType", () => {
|
|
5
|
-
it("returns correct MIME for common web types", () => {
|
|
6
|
-
expect(getMimeType(".html")).toBe("text/html");
|
|
7
|
-
expect(getMimeType(".css")).toBe("text/css");
|
|
8
|
-
expect(getMimeType(".js")).toBe("text/javascript");
|
|
9
|
-
expect(getMimeType(".json")).toBe("application/json");
|
|
10
|
-
expect(getMimeType(".png")).toBe("image/png");
|
|
11
|
-
expect(getMimeType(".svg")).toBe("image/svg+xml");
|
|
12
|
-
expect(getMimeType(".woff2")).toBe("font/woff2");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("returns application/octet-stream for unknown extensions", () => {
|
|
16
|
-
expect(getMimeType(".xyz")).toBe("application/octet-stream");
|
|
17
|
-
expect(getMimeType("")).toBe("application/octet-stream");
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { getTailwindConfigDeps } from "../src/utils/tailwind-config-deps";
|
|
4
|
-
|
|
5
|
-
const packagesDir = path.resolve(import.meta.dirname, "../..");
|
|
6
|
-
|
|
7
|
-
describe("getTailwindConfigDeps", () => {
|
|
8
|
-
it("includes solid tailwind config in dependencies of solid-demo tailwind config", () => {
|
|
9
|
-
const configPath = path.join(packagesDir, "solid-demo/tailwind.config.ts");
|
|
10
|
-
const deps = getTailwindConfigDeps(configPath, ["@simplysm"]);
|
|
11
|
-
|
|
12
|
-
const solidConfig = path.join(packagesDir, "solid/tailwind.config.ts");
|
|
13
|
-
expect(deps).toContain(solidConfig);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("includes the config itself in dependencies", () => {
|
|
17
|
-
const configPath = path.join(packagesDir, "solid-demo/tailwind.config.ts");
|
|
18
|
-
const deps = getTailwindConfigDeps(configPath, ["@simplysm"]);
|
|
19
|
-
|
|
20
|
-
expect(deps).toContain(path.resolve(configPath));
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("excludes packages outside @simplysm/ (like tailwindcss/colors)", () => {
|
|
24
|
-
const configPath = path.join(packagesDir, "solid/tailwind.config.ts");
|
|
25
|
-
const deps = getTailwindConfigDeps(configPath, ["@simplysm"]);
|
|
26
|
-
|
|
27
|
-
// solid/tailwind.config.ts imports tailwindcss/colors but does not track it
|
|
28
|
-
expect(deps).toHaveLength(1); // only itself
|
|
29
|
-
});
|
|
30
|
-
});
|
package/tests/template.spec.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import { renderTemplateDir } from "../src/utils/template";
|
|
6
|
-
|
|
7
|
-
describe("renderTemplateDir", () => {
|
|
8
|
-
let tmpDir: string;
|
|
9
|
-
let srcDir: string;
|
|
10
|
-
let destDir: string;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "sd-template-test-"));
|
|
14
|
-
srcDir = path.join(tmpDir, "src");
|
|
15
|
-
destDir = path.join(tmpDir, "dest");
|
|
16
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("renders .hbs files with context and removes .hbs extension", async () => {
|
|
24
|
-
fs.writeFileSync(path.join(srcDir, "hello.txt.hbs"), "Hello, {{name}}!");
|
|
25
|
-
await renderTemplateDir(srcDir, destDir, { name: "World" });
|
|
26
|
-
expect(fs.readFileSync(path.join(destDir, "hello.txt"), "utf-8")).toBe("Hello, World!");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("copies non-.hbs files as-is (binary safe)", async () => {
|
|
30
|
-
const binaryData = Uint8Array.from([0x00, 0x01, 0xff, 0xfe]);
|
|
31
|
-
fs.writeFileSync(path.join(srcDir, "icon.bin"), binaryData);
|
|
32
|
-
await renderTemplateDir(srcDir, destDir, {});
|
|
33
|
-
const copied = fs.readFileSync(path.join(destDir, "icon.bin"));
|
|
34
|
-
expect(new Uint8Array(copied)).toEqual(binaryData);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("replaces directory name placeholders", async () => {
|
|
38
|
-
const subDir = path.join(srcDir, "__CLIENT__");
|
|
39
|
-
fs.mkdirSync(subDir, { recursive: true });
|
|
40
|
-
fs.writeFileSync(path.join(subDir, "file.txt.hbs"), "pkg: {{clientName}}");
|
|
41
|
-
await renderTemplateDir(
|
|
42
|
-
srcDir,
|
|
43
|
-
destDir,
|
|
44
|
-
{ clientName: "client-admin" },
|
|
45
|
-
{ __CLIENT__: "client-admin" },
|
|
46
|
-
);
|
|
47
|
-
expect(fs.readFileSync(path.join(destDir, "client-admin", "file.txt"), "utf-8")).toBe(
|
|
48
|
-
"pkg: client-admin",
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("skips file when .hbs renders to empty/whitespace", async () => {
|
|
53
|
-
fs.writeFileSync(path.join(srcDir, "optional.ts.hbs"), "{{#if enabled}}content{{/if}}");
|
|
54
|
-
await renderTemplateDir(srcDir, destDir, { enabled: false });
|
|
55
|
-
expect(fs.existsSync(path.join(destDir, "optional.ts"))).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("handles nested directories", async () => {
|
|
59
|
-
fs.mkdirSync(path.join(srcDir, "a", "b"), { recursive: true });
|
|
60
|
-
fs.writeFileSync(path.join(srcDir, "a", "b", "deep.txt.hbs"), "{{value}}");
|
|
61
|
-
await renderTemplateDir(srcDir, destDir, { value: "nested" });
|
|
62
|
-
expect(fs.readFileSync(path.join(destDir, "a", "b", "deep.txt"), "utf-8")).toBe("nested");
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("preserves Handlebars {{#if}} conditional blocks", async () => {
|
|
66
|
-
fs.writeFileSync(path.join(srcDir, "test.txt.hbs"), "start\n{{#if flag}}included\n{{/if}}end");
|
|
67
|
-
await renderTemplateDir(srcDir, destDir, { flag: true });
|
|
68
|
-
expect(fs.readFileSync(path.join(destDir, "test.txt"), "utf-8")).toBe("start\nincluded\nend");
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createViteConfig } from "../src/utils/vite-config";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
describe("createViteConfig exclude option", () => {
|
|
6
|
-
const baseOptions = {
|
|
7
|
-
pkgDir: path.resolve(__dirname, ".."),
|
|
8
|
-
name: "test-app",
|
|
9
|
-
tsconfigPath: path.resolve(__dirname, "../../..", "tsconfig.json"),
|
|
10
|
-
compilerOptions: {},
|
|
11
|
-
mode: "build" as const,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
it("should set optimizeDeps.exclude when exclude option is provided", () => {
|
|
15
|
-
const config = createViteConfig({ ...baseOptions, exclude: ["jeep-sqlite"] });
|
|
16
|
-
|
|
17
|
-
expect(config.optimizeDeps?.exclude).toContain("jeep-sqlite");
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should not set optimizeDeps.exclude when exclude option is not provided", () => {
|
|
21
|
-
const config = createViteConfig(baseOptions);
|
|
22
|
-
|
|
23
|
-
expect(config.optimizeDeps?.exclude).toBeUndefined();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should handle multiple exclude packages", () => {
|
|
27
|
-
const config = createViteConfig({
|
|
28
|
-
...baseOptions,
|
|
29
|
-
exclude: ["jeep-sqlite", "electron"],
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
expect(config.optimizeDeps?.exclude).toContain("jeep-sqlite");
|
|
33
|
-
expect(config.optimizeDeps?.exclude).toContain("electron");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createViteConfig } from "../src/utils/vite-config";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
describe("createViteConfig capacitor overrides", () => {
|
|
6
|
-
const baseOptions = {
|
|
7
|
-
pkgDir: path.resolve(__dirname, ".."),
|
|
8
|
-
name: "test-app",
|
|
9
|
-
tsconfigPath: path.resolve(__dirname, "../../..", "tsconfig.json"),
|
|
10
|
-
compilerOptions: {},
|
|
11
|
-
mode: "build" as const,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
it("should set build.outDir when outDir option is provided", () => {
|
|
15
|
-
const outDir = path.join(baseOptions.pkgDir, ".capacitor", "www");
|
|
16
|
-
const config = createViteConfig({ ...baseOptions, outDir });
|
|
17
|
-
|
|
18
|
-
expect(config.build?.outDir).toBe(outDir);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should not set build.outDir when outDir option is not provided", () => {
|
|
22
|
-
const config = createViteConfig(baseOptions);
|
|
23
|
-
|
|
24
|
-
expect(config.build?.outDir).toBeUndefined();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should override base when base option is provided", () => {
|
|
28
|
-
const config = createViteConfig({ ...baseOptions, base: "./" });
|
|
29
|
-
|
|
30
|
-
expect(config.base).toBe("./");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should use /{name}/ as base when base option is not provided", () => {
|
|
34
|
-
const config = createViteConfig(baseOptions);
|
|
35
|
-
|
|
36
|
-
expect(config.base).toBe("/test-app/");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import fs from "fs/promises";
|
|
5
|
-
import type esbuild from "esbuild";
|
|
6
|
-
import { writeChangedOutputFiles } from "../src/utils/esbuild-config";
|
|
7
|
-
|
|
8
|
-
function makeOutputFile(filePath: string, text: string): esbuild.OutputFile {
|
|
9
|
-
const contents = new TextEncoder().encode(text);
|
|
10
|
-
return { path: filePath, contents, text, hash: "" };
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe("writeChangedOutputFiles", () => {
|
|
14
|
-
let tmpDir: string;
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "esbuild-write-"));
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
afterEach(async () => {
|
|
21
|
-
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("writes new files that don't exist on disk", async () => {
|
|
25
|
-
const outFile = makeOutputFile(path.join(tmpDir, "index.js"), "const x = 1;\n");
|
|
26
|
-
await writeChangedOutputFiles([outFile]);
|
|
27
|
-
|
|
28
|
-
const result = await fs.readFile(path.join(tmpDir, "index.js"), "utf-8");
|
|
29
|
-
expect(result).toBe("const x = 1;\n");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("skips writing when content is identical", async () => {
|
|
33
|
-
const filePath = path.join(tmpDir, "index.js");
|
|
34
|
-
await fs.writeFile(filePath, "const x = 1;\n");
|
|
35
|
-
const statBefore = await fs.stat(filePath);
|
|
36
|
-
|
|
37
|
-
// Small delay to ensure mtime would differ if file were rewritten
|
|
38
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
39
|
-
|
|
40
|
-
const outFile = makeOutputFile(filePath, "const x = 1;\n");
|
|
41
|
-
await writeChangedOutputFiles([outFile]);
|
|
42
|
-
|
|
43
|
-
const statAfter = await fs.stat(filePath);
|
|
44
|
-
expect(statAfter.mtimeMs).toBe(statBefore.mtimeMs);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("writes when content differs", async () => {
|
|
48
|
-
const filePath = path.join(tmpDir, "index.js");
|
|
49
|
-
await fs.writeFile(filePath, "const x = 1;\n");
|
|
50
|
-
|
|
51
|
-
const outFile = makeOutputFile(filePath, "const x = 2;\n");
|
|
52
|
-
await writeChangedOutputFiles([outFile]);
|
|
53
|
-
|
|
54
|
-
const result = await fs.readFile(filePath, "utf-8");
|
|
55
|
-
expect(result).toBe("const x = 2;\n");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("adds .js extension to relative imports in .js files", async () => {
|
|
59
|
-
const filePath = path.join(tmpDir, "index.js");
|
|
60
|
-
const outFile = makeOutputFile(filePath, 'import { foo } from "./utils";\nexport { foo };\n');
|
|
61
|
-
await writeChangedOutputFiles([outFile]);
|
|
62
|
-
|
|
63
|
-
const result = await fs.readFile(filePath, "utf-8");
|
|
64
|
-
expect(result).toBe('import { foo } from "./utils.js";\nexport { foo };\n');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("does not add .js extension to imports that already have known extensions", async () => {
|
|
68
|
-
const filePath = path.join(tmpDir, "index.js");
|
|
69
|
-
const outFile = makeOutputFile(
|
|
70
|
-
filePath,
|
|
71
|
-
'import "./styles.css";\nimport data from "./data.json";\n',
|
|
72
|
-
);
|
|
73
|
-
await writeChangedOutputFiles([outFile]);
|
|
74
|
-
|
|
75
|
-
const result = await fs.readFile(filePath, "utf-8");
|
|
76
|
-
expect(result).toBe('import "./styles.css";\nimport data from "./data.json";\n');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("does not rewrite imports in .js.map files", async () => {
|
|
80
|
-
const filePath = path.join(tmpDir, "index.js.map");
|
|
81
|
-
const content = '{"sources":["./utils"]}';
|
|
82
|
-
const outFile = makeOutputFile(filePath, content);
|
|
83
|
-
await writeChangedOutputFiles([outFile]);
|
|
84
|
-
|
|
85
|
-
const result = await fs.readFile(filePath, "utf-8");
|
|
86
|
-
expect(result).toBe(content);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("creates parent directories if needed", async () => {
|
|
90
|
-
const filePath = path.join(tmpDir, "sub", "deep", "index.js");
|
|
91
|
-
const outFile = makeOutputFile(filePath, "export {};\n");
|
|
92
|
-
await writeChangedOutputFiles([outFile]);
|
|
93
|
-
|
|
94
|
-
const result = await fs.readFile(filePath, "utf-8");
|
|
95
|
-
expect(result).toBe("export {};\n");
|
|
96
|
-
});
|
|
97
|
-
});
|