@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
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
parseWorkspaceGlobs,
|
|
4
|
-
resolveReplaceDepEntries,
|
|
5
|
-
setupReplaceDeps,
|
|
6
|
-
watchReplaceDeps,
|
|
7
|
-
} from "../src/utils/replace-deps";
|
|
8
|
-
import fs from "fs";
|
|
9
|
-
import path from "path";
|
|
10
|
-
import os from "os";
|
|
11
|
-
|
|
12
|
-
describe("resolveReplaceDepEntries", () => {
|
|
13
|
-
test("captures glob * pattern and substitutes it in source path", () => {
|
|
14
|
-
const result = resolveReplaceDepEntries({ "@simplysm/*": "../simplysm/packages/*" }, [
|
|
15
|
-
"@simplysm/solid",
|
|
16
|
-
"@simplysm/core-common",
|
|
17
|
-
]);
|
|
18
|
-
expect(result).toEqual([
|
|
19
|
-
{ targetName: "@simplysm/solid", sourcePath: "../simplysm/packages/solid" },
|
|
20
|
-
{ targetName: "@simplysm/core-common", sourcePath: "../simplysm/packages/core-common" },
|
|
21
|
-
]);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("matches exact package names without *", () => {
|
|
25
|
-
const result = resolveReplaceDepEntries({ "@other/lib": "../other-project/lib" }, [
|
|
26
|
-
"@other/lib",
|
|
27
|
-
"@other/unused",
|
|
28
|
-
]);
|
|
29
|
-
expect(result).toEqual([{ targetName: "@other/lib", sourcePath: "../other-project/lib" }]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("non-matching packages are not included in results", () => {
|
|
33
|
-
const result = resolveReplaceDepEntries({ "@simplysm/*": "../simplysm/packages/*" }, [
|
|
34
|
-
"@other/lib",
|
|
35
|
-
]);
|
|
36
|
-
expect(result).toEqual([]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("processes multiple replaceDeps entries", () => {
|
|
40
|
-
const result = resolveReplaceDepEntries(
|
|
41
|
-
{
|
|
42
|
-
"@simplysm/*": "../simplysm/packages/*",
|
|
43
|
-
"@other/lib": "../other/lib",
|
|
44
|
-
},
|
|
45
|
-
["@simplysm/solid", "@other/lib"],
|
|
46
|
-
);
|
|
47
|
-
expect(result).toEqual([
|
|
48
|
-
{ targetName: "@simplysm/solid", sourcePath: "../simplysm/packages/solid" },
|
|
49
|
-
{ targetName: "@other/lib", sourcePath: "../other/lib" },
|
|
50
|
-
]);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("parseWorkspaceGlobs", () => {
|
|
55
|
-
test("parses packages glob array", () => {
|
|
56
|
-
const yaml = `packages:\n - "packages/*"\n - "tools/*"`;
|
|
57
|
-
expect(parseWorkspaceGlobs(yaml)).toEqual(["packages/*", "tools/*"]);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("parses glob without quotes", () => {
|
|
61
|
-
const yaml = `packages:\n - packages/*\n - tools/*`;
|
|
62
|
-
expect(parseWorkspaceGlobs(yaml)).toEqual(["packages/*", "tools/*"]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("returns empty array for empty content", () => {
|
|
66
|
-
expect(parseWorkspaceGlobs("")).toEqual([]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("returns empty array if packages section is missing", () => {
|
|
70
|
-
const yaml = `# some comment\nsomething: value`;
|
|
71
|
-
expect(parseWorkspaceGlobs(yaml)).toEqual([]);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("setupReplaceDeps", () => {
|
|
76
|
-
let tmpDir: string;
|
|
77
|
-
|
|
78
|
-
beforeEach(async () => {
|
|
79
|
-
// Create test project structure in temporary directory
|
|
80
|
-
tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "sd-replace-deps-"));
|
|
81
|
-
|
|
82
|
-
// Source package (simplysm/packages/solid)
|
|
83
|
-
const sourceDir = path.join(tmpDir, "simplysm", "packages", "solid");
|
|
84
|
-
await fs.promises.mkdir(sourceDir, { recursive: true });
|
|
85
|
-
await fs.promises.writeFile(path.join(sourceDir, "index.js"), "export default 1;");
|
|
86
|
-
await fs.promises.writeFile(path.join(sourceDir, "README.md"), "readme");
|
|
87
|
-
|
|
88
|
-
// Create items to be excluded
|
|
89
|
-
await fs.promises.mkdir(path.join(sourceDir, "node_modules"), { recursive: true });
|
|
90
|
-
await fs.promises.writeFile(path.join(sourceDir, "node_modules", "dep.js"), "dep");
|
|
91
|
-
await fs.promises.writeFile(path.join(sourceDir, "package.json"), '{"name":"solid"}');
|
|
92
|
-
await fs.promises.mkdir(path.join(sourceDir, ".cache"), { recursive: true });
|
|
93
|
-
await fs.promises.writeFile(path.join(sourceDir, ".cache", "file.txt"), "cache");
|
|
94
|
-
await fs.promises.mkdir(path.join(sourceDir, "tests"), { recursive: true });
|
|
95
|
-
await fs.promises.writeFile(path.join(sourceDir, "tests", "test.spec.ts"), "test");
|
|
96
|
-
|
|
97
|
-
// Target project (app/node_modules/@simplysm/solid)
|
|
98
|
-
// pnpm style: app/node_modules/@simplysm/solid → symlink to .pnpm store
|
|
99
|
-
const appRoot = path.join(tmpDir, "app");
|
|
100
|
-
|
|
101
|
-
// .pnpm store directory (where actual contents are)
|
|
102
|
-
const pnpmStoreTarget = path.join(
|
|
103
|
-
appRoot,
|
|
104
|
-
"node_modules",
|
|
105
|
-
".pnpm",
|
|
106
|
-
"@simplysm+solid@1.0.0",
|
|
107
|
-
"node_modules",
|
|
108
|
-
"@simplysm",
|
|
109
|
-
"solid",
|
|
110
|
-
);
|
|
111
|
-
await fs.promises.mkdir(pnpmStoreTarget, { recursive: true });
|
|
112
|
-
await fs.promises.writeFile(path.join(pnpmStoreTarget, "index.js"), "old");
|
|
113
|
-
|
|
114
|
-
// node_modules/@simplysm/solid → symlink to .pnpm store
|
|
115
|
-
const nodeModulesSymlink = path.join(appRoot, "node_modules", "@simplysm", "solid");
|
|
116
|
-
await fs.promises.mkdir(path.dirname(nodeModulesSymlink), { recursive: true });
|
|
117
|
-
const relativeToStore = path.relative(path.dirname(nodeModulesSymlink), pnpmStoreTarget);
|
|
118
|
-
await fs.promises.symlink(relativeToStore, nodeModulesSymlink, "dir");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
afterEach(async () => {
|
|
122
|
-
await fs.promises.rm(tmpDir, { recursive: true, force: true });
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("replaces package in node_modules by copying from source directory", async () => {
|
|
126
|
-
const appRoot = path.join(tmpDir, "app");
|
|
127
|
-
|
|
128
|
-
await setupReplaceDeps(appRoot, {
|
|
129
|
-
"@simplysm/*": "../simplysm/packages/*",
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const targetPath = path.join(appRoot, "node_modules", "@simplysm", "solid");
|
|
133
|
-
|
|
134
|
-
// Symlink is preserved
|
|
135
|
-
const stat = await fs.promises.lstat(targetPath);
|
|
136
|
-
expect(stat.isSymbolicLink()).toBe(true);
|
|
137
|
-
|
|
138
|
-
// Verify source files are copied to symlink's actual path (.pnpm store)
|
|
139
|
-
const realPath = await fs.promises.realpath(targetPath);
|
|
140
|
-
const indexContent = await fs.promises.readFile(path.join(realPath, "index.js"), "utf-8");
|
|
141
|
-
expect(indexContent).toBe("export default 1;");
|
|
142
|
-
|
|
143
|
-
const readmeContent = await fs.promises.readFile(path.join(targetPath, "README.md"), "utf-8");
|
|
144
|
-
expect(readmeContent).toBe("readme");
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test("excludes node_modules, package.json, .cache, and tests when copying", async () => {
|
|
148
|
-
const appRoot = path.join(tmpDir, "app");
|
|
149
|
-
|
|
150
|
-
await setupReplaceDeps(appRoot, {
|
|
151
|
-
"@simplysm/*": "../simplysm/packages/*",
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const targetPath = path.join(appRoot, "node_modules", "@simplysm", "solid");
|
|
155
|
-
|
|
156
|
-
// Files to be copied
|
|
157
|
-
expect(fs.existsSync(path.join(targetPath, "index.js"))).toBe(true);
|
|
158
|
-
expect(fs.existsSync(path.join(targetPath, "README.md"))).toBe(true);
|
|
159
|
-
|
|
160
|
-
// Items to be excluded
|
|
161
|
-
expect(fs.existsSync(path.join(targetPath, "node_modules"))).toBe(false);
|
|
162
|
-
expect(fs.existsSync(path.join(targetPath, "package.json"))).toBe(false);
|
|
163
|
-
expect(fs.existsSync(path.join(targetPath, ".cache"))).toBe(false);
|
|
164
|
-
expect(fs.existsSync(path.join(targetPath, "tests"))).toBe(false);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test("skips package if source path does not exist", async () => {
|
|
168
|
-
const appRoot = path.join(tmpDir, "app");
|
|
169
|
-
|
|
170
|
-
// Create .pnpm store for no-exist package
|
|
171
|
-
const pnpmStoreNoExist = path.join(
|
|
172
|
-
appRoot,
|
|
173
|
-
"node_modules",
|
|
174
|
-
".pnpm",
|
|
175
|
-
"@simplysm+no-exist@1.0.0",
|
|
176
|
-
"node_modules",
|
|
177
|
-
"@simplysm",
|
|
178
|
-
"no-exist",
|
|
179
|
-
);
|
|
180
|
-
await fs.promises.mkdir(pnpmStoreNoExist, { recursive: true });
|
|
181
|
-
await fs.promises.writeFile(path.join(pnpmStoreNoExist, "index.js"), "no-exist-old");
|
|
182
|
-
|
|
183
|
-
// node_modules/@simplysm/no-exist → symlink to .pnpm store
|
|
184
|
-
const noExistSymlink = path.join(appRoot, "node_modules", "@simplysm", "no-exist");
|
|
185
|
-
await fs.promises.mkdir(path.dirname(noExistSymlink), { recursive: true });
|
|
186
|
-
const relativeToStore = path.relative(path.dirname(noExistSymlink), pnpmStoreNoExist);
|
|
187
|
-
await fs.promises.symlink(relativeToStore, noExistSymlink, "dir");
|
|
188
|
-
|
|
189
|
-
// Should complete without error
|
|
190
|
-
await setupReplaceDeps(appRoot, {
|
|
191
|
-
"@simplysm/*": "../simplysm/packages/*",
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// solid symlink is preserved, no-exist symlink remains unchanged
|
|
195
|
-
const solidPath = path.join(appRoot, "node_modules", "@simplysm", "solid");
|
|
196
|
-
const solidStat = await fs.promises.lstat(solidPath);
|
|
197
|
-
expect(solidStat.isSymbolicLink()).toBe(true);
|
|
198
|
-
|
|
199
|
-
const noExistStat = await fs.promises.lstat(noExistSymlink);
|
|
200
|
-
expect(noExistStat.isSymbolicLink()).toBe(true);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test("processes node_modules in workspace packages", async () => {
|
|
204
|
-
const appRoot = path.join(tmpDir, "app");
|
|
205
|
-
|
|
206
|
-
// Create workspace package structure (.pnpm store style)
|
|
207
|
-
const pkgPnpmStore = path.join(
|
|
208
|
-
appRoot,
|
|
209
|
-
"packages",
|
|
210
|
-
"client",
|
|
211
|
-
"node_modules",
|
|
212
|
-
".pnpm",
|
|
213
|
-
"@simplysm+solid@1.0.0",
|
|
214
|
-
"node_modules",
|
|
215
|
-
"@simplysm",
|
|
216
|
-
"solid",
|
|
217
|
-
);
|
|
218
|
-
await fs.promises.mkdir(pkgPnpmStore, { recursive: true });
|
|
219
|
-
await fs.promises.writeFile(path.join(pkgPnpmStore, "index.js"), "old");
|
|
220
|
-
|
|
221
|
-
// node_modules/@simplysm/solid → symlink to .pnpm store
|
|
222
|
-
const pkgNodeModulesSymlink = path.join(
|
|
223
|
-
appRoot,
|
|
224
|
-
"packages",
|
|
225
|
-
"client",
|
|
226
|
-
"node_modules",
|
|
227
|
-
"@simplysm",
|
|
228
|
-
"solid",
|
|
229
|
-
);
|
|
230
|
-
await fs.promises.mkdir(path.dirname(pkgNodeModulesSymlink), { recursive: true });
|
|
231
|
-
const relativeToStore = path.relative(path.dirname(pkgNodeModulesSymlink), pkgPnpmStore);
|
|
232
|
-
await fs.promises.symlink(relativeToStore, pkgNodeModulesSymlink, "dir");
|
|
233
|
-
|
|
234
|
-
// Create pnpm-workspace.yaml
|
|
235
|
-
await fs.promises.writeFile(
|
|
236
|
-
path.join(appRoot, "pnpm-workspace.yaml"),
|
|
237
|
-
"packages:\n - packages/*\n",
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
await setupReplaceDeps(appRoot, {
|
|
241
|
-
"@simplysm/*": "../simplysm/packages/*",
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// Workspace package's node_modules symlink is also preserved
|
|
245
|
-
const stat = await fs.promises.lstat(pkgNodeModulesSymlink);
|
|
246
|
-
expect(stat.isSymbolicLink()).toBe(true);
|
|
247
|
-
|
|
248
|
-
// Verify source files are copied to symlink's actual path
|
|
249
|
-
const realPath = await fs.promises.realpath(pkgNodeModulesSymlink);
|
|
250
|
-
const indexContent = await fs.promises.readFile(path.join(realPath, "index.js"), "utf-8");
|
|
251
|
-
expect(indexContent).toBe("export default 1;");
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
describe("watchReplaceDeps", () => {
|
|
256
|
-
let tmpDir: string;
|
|
257
|
-
|
|
258
|
-
beforeEach(async () => {
|
|
259
|
-
tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "sd-watch-replace-"));
|
|
260
|
-
|
|
261
|
-
// Source package (simplysm/packages/solid)
|
|
262
|
-
const sourceDir = path.join(tmpDir, "simplysm", "packages", "solid");
|
|
263
|
-
await fs.promises.mkdir(sourceDir, { recursive: true });
|
|
264
|
-
await fs.promises.writeFile(path.join(sourceDir, "index.js"), "export default 1;");
|
|
265
|
-
|
|
266
|
-
// Target project (.pnpm store style)
|
|
267
|
-
const appRoot = path.join(tmpDir, "app");
|
|
268
|
-
const pnpmStoreTarget = path.join(
|
|
269
|
-
appRoot,
|
|
270
|
-
"node_modules",
|
|
271
|
-
".pnpm",
|
|
272
|
-
"@simplysm+solid@1.0.0",
|
|
273
|
-
"node_modules",
|
|
274
|
-
"@simplysm",
|
|
275
|
-
"solid",
|
|
276
|
-
);
|
|
277
|
-
await fs.promises.mkdir(pnpmStoreTarget, { recursive: true });
|
|
278
|
-
await fs.promises.writeFile(path.join(pnpmStoreTarget, "index.js"), "old");
|
|
279
|
-
|
|
280
|
-
const nodeModulesSymlink = path.join(appRoot, "node_modules", "@simplysm", "solid");
|
|
281
|
-
await fs.promises.mkdir(path.dirname(nodeModulesSymlink), { recursive: true });
|
|
282
|
-
const relativeToStore = path.relative(path.dirname(nodeModulesSymlink), pnpmStoreTarget);
|
|
283
|
-
await fs.promises.symlink(relativeToStore, nodeModulesSymlink, "dir");
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
afterEach(async () => {
|
|
287
|
-
await fs.promises.rm(tmpDir, { recursive: true, force: true });
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
test("copies source files to target when modified after watch starts", async () => {
|
|
291
|
-
const appRoot = path.join(tmpDir, "app");
|
|
292
|
-
const sourceDir = path.join(tmpDir, "simplysm", "packages", "solid");
|
|
293
|
-
const targetPath = path.join(appRoot, "node_modules", "@simplysm", "solid");
|
|
294
|
-
|
|
295
|
-
const { dispose } = await watchReplaceDeps(appRoot, {
|
|
296
|
-
"@simplysm/*": "../simplysm/packages/*",
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
// Modify source file
|
|
300
|
-
await fs.promises.writeFile(path.join(sourceDir, "index.js"), "export default 2;");
|
|
301
|
-
await new Promise((resolve) => setTimeout(resolve, 500)); // 300ms delay + buffer
|
|
302
|
-
|
|
303
|
-
const indexContent = await fs.promises.readFile(path.join(targetPath, "index.js"), "utf-8");
|
|
304
|
-
expect(indexContent).toBe("export default 2;");
|
|
305
|
-
|
|
306
|
-
dispose();
|
|
307
|
-
});
|
|
308
|
-
});
|
package/tests/run-lint.spec.ts
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
// State management hoisted via vi.hoisted
|
|
5
|
-
const { mockState, mockJitiImportFn } = vi.hoisted(() => ({
|
|
6
|
-
mockState: {
|
|
7
|
-
lintResults: [] as Array<{ errorCount: number; warningCount: number }>,
|
|
8
|
-
lintedFiles: [] as string[],
|
|
9
|
-
outputFixesCalled: false,
|
|
10
|
-
},
|
|
11
|
-
mockJitiImportFn: vi.fn(),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
// Mock external dependencies
|
|
15
|
-
|
|
16
|
-
vi.mock("eslint", () => {
|
|
17
|
-
class MockESLint {
|
|
18
|
-
lintFiles(files: string[]) {
|
|
19
|
-
mockState.lintedFiles = files;
|
|
20
|
-
return Promise.resolve(mockState.lintResults);
|
|
21
|
-
}
|
|
22
|
-
loadFormatter() {
|
|
23
|
-
return Promise.resolve({
|
|
24
|
-
format: () => Promise.resolve(""),
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
static outputFixes(_results: unknown) {
|
|
28
|
-
mockState.outputFixesCalled = true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return { ESLint: MockESLint };
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
vi.mock("@simplysm/core-node", () => {
|
|
36
|
-
const posix = (p: string) => p.replace(/\\/g, "/");
|
|
37
|
-
const isChildPath = (child: string, parent: string) => {
|
|
38
|
-
if (child === parent) return false;
|
|
39
|
-
const parentWithSlash = parent.endsWith("/") ? parent : parent + "/";
|
|
40
|
-
return child.startsWith(parentWithSlash);
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
fsx: {
|
|
44
|
-
exists: vi.fn(),
|
|
45
|
-
glob: vi.fn(),
|
|
46
|
-
},
|
|
47
|
-
pathx: {
|
|
48
|
-
posix: vi.fn(posix),
|
|
49
|
-
isChildPath: vi.fn(isChildPath),
|
|
50
|
-
filterByTargets: vi.fn((files: string[], targets: string[], cwd: string) => {
|
|
51
|
-
if (targets.length === 0) return files;
|
|
52
|
-
return files.filter((file) => {
|
|
53
|
-
const relativePath = posix(file.replace(cwd + "/", ""));
|
|
54
|
-
return targets.some(
|
|
55
|
-
(target) => relativePath === target || isChildPath(relativePath, target),
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
}),
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
vi.mock("jiti", () => ({
|
|
64
|
-
createJiti: vi.fn(() => ({
|
|
65
|
-
import: (configPath: string) => mockJitiImportFn(configPath),
|
|
66
|
-
})),
|
|
67
|
-
}));
|
|
68
|
-
|
|
69
|
-
vi.mock("consola", () => {
|
|
70
|
-
const mockLogger = {
|
|
71
|
-
debug: vi.fn(),
|
|
72
|
-
info: vi.fn(),
|
|
73
|
-
error: vi.fn(),
|
|
74
|
-
warn: vi.fn(),
|
|
75
|
-
start: vi.fn(),
|
|
76
|
-
success: vi.fn(),
|
|
77
|
-
fail: vi.fn(),
|
|
78
|
-
withTag: vi.fn(() => mockLogger),
|
|
79
|
-
level: 3, // info level
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
consola: mockLogger,
|
|
83
|
-
default: mockLogger,
|
|
84
|
-
LogLevels: { debug: 4, info: 3, warn: 2, error: 1 },
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
import { fsx } from "@simplysm/core-node";
|
|
89
|
-
import { runLint, executeLint } from "../src/commands/lint";
|
|
90
|
-
|
|
91
|
-
describe("runLint", () => {
|
|
92
|
-
let originalExitCode: typeof process.exitCode;
|
|
93
|
-
let originalCwd: () => string;
|
|
94
|
-
|
|
95
|
-
beforeEach(() => {
|
|
96
|
-
vi.clearAllMocks();
|
|
97
|
-
originalExitCode = process.exitCode;
|
|
98
|
-
originalCwd = process.cwd;
|
|
99
|
-
process.cwd = vi.fn().mockReturnValue("/project");
|
|
100
|
-
|
|
101
|
-
// Reset state
|
|
102
|
-
mockState.lintResults = [];
|
|
103
|
-
mockState.lintedFiles = [];
|
|
104
|
-
mockState.outputFixesCalled = false;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
afterEach(() => {
|
|
108
|
-
vi.restoreAllMocks();
|
|
109
|
-
process.exitCode = originalExitCode;
|
|
110
|
-
process.cwd = originalCwd;
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("sets exitCode to 1 when lint errors occur", async () => {
|
|
114
|
-
const cwd = "/project";
|
|
115
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
116
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
mockJitiImportFn.mockResolvedValue({
|
|
120
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/src/index.ts"]);
|
|
124
|
-
|
|
125
|
-
mockState.lintResults = [{ errorCount: 2, warningCount: 0 }];
|
|
126
|
-
|
|
127
|
-
await runLint({ targets: [], fix: false, timing: false });
|
|
128
|
-
|
|
129
|
-
expect(process.exitCode).toBe(1);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("does not set exitCode when no lint errors", async () => {
|
|
133
|
-
const cwd = "/project";
|
|
134
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
135
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
mockJitiImportFn.mockResolvedValue({
|
|
139
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/src/index.ts"]);
|
|
143
|
-
|
|
144
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
145
|
-
|
|
146
|
-
await runLint({ targets: [], fix: false, timing: false });
|
|
147
|
-
|
|
148
|
-
expect(process.exitCode).toBeUndefined();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("filters files using targets option", async () => {
|
|
152
|
-
const cwd = "/project";
|
|
153
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
154
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
mockJitiImportFn.mockResolvedValue({
|
|
158
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
vi.mocked(fsx.glob).mockResolvedValue([
|
|
162
|
-
"/project/packages/core-common/src/index.ts",
|
|
163
|
-
"/project/packages/core-node/src/index.ts",
|
|
164
|
-
"/project/packages/cli/src/index.ts",
|
|
165
|
-
]);
|
|
166
|
-
|
|
167
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
168
|
-
|
|
169
|
-
await runLint({
|
|
170
|
-
targets: ["packages/core-common"],
|
|
171
|
-
fix: false,
|
|
172
|
-
timing: false,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
expect(mockState.lintedFiles).toHaveLength(1);
|
|
176
|
-
expect(mockState.lintedFiles[0]).toContain("core-common");
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("filters files from all paths when multiple targets specified", async () => {
|
|
180
|
-
const cwd = "/project";
|
|
181
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
182
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
mockJitiImportFn.mockResolvedValue({
|
|
186
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
vi.mocked(fsx.glob).mockResolvedValue([
|
|
190
|
-
"/project/packages/core-common/src/index.ts",
|
|
191
|
-
"/project/packages/core-node/src/index.ts",
|
|
192
|
-
"/project/packages/cli/src/index.ts",
|
|
193
|
-
"/project/tests/orm/src/test.spec.ts",
|
|
194
|
-
]);
|
|
195
|
-
|
|
196
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
197
|
-
|
|
198
|
-
await runLint({
|
|
199
|
-
targets: ["packages/core-common", "packages/cli"],
|
|
200
|
-
fix: false,
|
|
201
|
-
timing: false,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
expect(mockState.lintedFiles).toHaveLength(2);
|
|
205
|
-
expect(mockState.lintedFiles.some((f) => f.includes("core-common"))).toBe(true);
|
|
206
|
-
expect(mockState.lintedFiles.some((f) => f.includes("cli"))).toBe(true);
|
|
207
|
-
expect(mockState.lintedFiles.some((f) => f.includes("core-node"))).toBe(false);
|
|
208
|
-
expect(mockState.lintedFiles.some((f) => f.includes("tests/orm"))).toBe(false);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("calls ESLint.outputFixes when fix option is enabled", async () => {
|
|
212
|
-
const cwd = "/project";
|
|
213
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
214
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
mockJitiImportFn.mockResolvedValue({
|
|
218
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/src/index.ts"]);
|
|
222
|
-
|
|
223
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
224
|
-
|
|
225
|
-
await runLint({ targets: [], fix: true, timing: false });
|
|
226
|
-
|
|
227
|
-
expect(mockState.outputFixesCalled).toBe(true);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("exits early when no files to lint", async () => {
|
|
231
|
-
const cwd = "/project";
|
|
232
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
233
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
mockJitiImportFn.mockResolvedValue({
|
|
237
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
vi.mocked(fsx.glob).mockResolvedValue([]);
|
|
241
|
-
|
|
242
|
-
await runLint({ targets: [], fix: false, timing: false });
|
|
243
|
-
|
|
244
|
-
// ESLint is not called, so lintedFiles stays empty
|
|
245
|
-
expect(mockState.lintedFiles).toHaveLength(0);
|
|
246
|
-
expect(process.exitCode).toBeUndefined();
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("throws error when ESLint config file is not found", async () => {
|
|
250
|
-
// When all config files are missing
|
|
251
|
-
vi.mocked(fsx.exists).mockResolvedValue(false);
|
|
252
|
-
|
|
253
|
-
await expect(runLint({ targets: [], fix: false, timing: false })).rejects.toThrow(
|
|
254
|
-
"Cannot find ESLint config file",
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
// Since error is thrown, exitCode must be set by caller (not set inside runLint)
|
|
258
|
-
// ESLint is not called
|
|
259
|
-
expect(mockState.lintedFiles).toHaveLength(0);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it("sets TIMING environment variable when timing option is enabled", async () => {
|
|
263
|
-
const cwd = "/project";
|
|
264
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
265
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
mockJitiImportFn.mockResolvedValue({
|
|
269
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/src/index.ts"]);
|
|
273
|
-
|
|
274
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
275
|
-
|
|
276
|
-
const originalTiming = process.env["TIMING"];
|
|
277
|
-
delete process.env["TIMING"];
|
|
278
|
-
|
|
279
|
-
await runLint({ targets: [], fix: false, timing: true });
|
|
280
|
-
|
|
281
|
-
// Verify TIMING is set (set inside the function)
|
|
282
|
-
expect(process.env["TIMING"]).toBe("1");
|
|
283
|
-
|
|
284
|
-
// cleanup
|
|
285
|
-
if (originalTiming !== undefined) {
|
|
286
|
-
process.env["TIMING"] = originalTiming;
|
|
287
|
-
} else {
|
|
288
|
-
delete process.env["TIMING"];
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("uses eslint.config.mts when eslint.config.ts is not found", async () => {
|
|
293
|
-
const cwd = "/project";
|
|
294
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
295
|
-
// eslint.config.ts does not exist, only eslint.config.mts
|
|
296
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.mts"));
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
mockJitiImportFn.mockResolvedValue({
|
|
300
|
-
default: [{ ignores: ["dist/**"] }],
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/src/index.ts"]);
|
|
304
|
-
|
|
305
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
306
|
-
|
|
307
|
-
await runLint({ targets: [], fix: false, timing: false });
|
|
308
|
-
|
|
309
|
-
// Verify that mts file was loaded
|
|
310
|
-
expect(mockJitiImportFn).toHaveBeenCalledWith(expect.stringContaining("eslint.config.mts"));
|
|
311
|
-
expect(process.exitCode).toBeUndefined();
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
describe("executeLint", () => {
|
|
317
|
-
let originalCwd: () => string;
|
|
318
|
-
|
|
319
|
-
beforeEach(() => {
|
|
320
|
-
vi.clearAllMocks();
|
|
321
|
-
originalCwd = process.cwd;
|
|
322
|
-
process.cwd = vi.fn().mockReturnValue("/project");
|
|
323
|
-
|
|
324
|
-
// Reset state
|
|
325
|
-
mockState.lintResults = [];
|
|
326
|
-
mockState.lintedFiles = [];
|
|
327
|
-
mockState.outputFixesCalled = false;
|
|
328
|
-
|
|
329
|
-
// Default ESLint config mock
|
|
330
|
-
const cwd = "/project";
|
|
331
|
-
vi.mocked(fsx.exists).mockImplementation((filePath: string) => {
|
|
332
|
-
return Promise.resolve(filePath === path.join(cwd, "eslint.config.ts"));
|
|
333
|
-
});
|
|
334
|
-
mockJitiImportFn.mockResolvedValue({
|
|
335
|
-
default: [{ ignores: ["node_modules/**"] }],
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
afterEach(() => {
|
|
340
|
-
vi.restoreAllMocks();
|
|
341
|
-
process.cwd = originalCwd;
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
it("returns success result when no errors", async () => {
|
|
345
|
-
mockState.lintResults = [{ errorCount: 0, warningCount: 0 }];
|
|
346
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/packages/core-common/src/index.ts"]);
|
|
347
|
-
|
|
348
|
-
const result = await executeLint({ targets: [], fix: false, timing: false });
|
|
349
|
-
|
|
350
|
-
expect(result.success).toBe(true);
|
|
351
|
-
expect(result.errorCount).toBe(0);
|
|
352
|
-
expect(result.warningCount).toBe(0);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it("returns failure result when errors exist", async () => {
|
|
356
|
-
mockState.lintResults = [{ errorCount: 2, warningCount: 1 }];
|
|
357
|
-
vi.mocked(fsx.glob).mockResolvedValue(["/project/packages/core-common/src/index.ts"]);
|
|
358
|
-
|
|
359
|
-
const result = await executeLint({ targets: [], fix: false, timing: false });
|
|
360
|
-
|
|
361
|
-
expect(result.success).toBe(false);
|
|
362
|
-
expect(result.errorCount).toBe(2);
|
|
363
|
-
expect(result.warningCount).toBe(1);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
});
|