@simplysm/sd-cli 14.0.41 → 14.0.43
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/angular/angular-compiler.d.ts +0 -35
- package/dist/angular/angular-compiler.d.ts.map +1 -1
- package/dist/angular/angular-compiler.js +0 -374
- package/dist/angular/angular-compiler.js.map +1 -1
- package/dist/angular/hmr-candidates.d.ts +13 -0
- package/dist/angular/hmr-candidates.d.ts.map +1 -0
- package/dist/angular/hmr-candidates.js +230 -0
- package/dist/angular/hmr-candidates.js.map +1 -0
- package/dist/angular/ngtsc-build-core.d.ts +29 -34
- package/dist/angular/ngtsc-build-core.d.ts.map +1 -1
- package/dist/angular/ngtsc-build-core.js +90 -51
- package/dist/angular/ngtsc-build-core.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +1 -1
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +63 -56
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/angular/web-worker-transformer.d.ts +9 -0
- package/dist/angular/web-worker-transformer.d.ts.map +1 -0
- package/dist/angular/web-worker-transformer.js +73 -0
- package/dist/angular/web-worker-transformer.js.map +1 -0
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +6 -4
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +15 -65
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/publish/deployment-phase.d.ts.map +1 -1
- package/dist/commands/publish/deployment-phase.js +13 -5
- package/dist/commands/publish/deployment-phase.js.map +1 -1
- package/dist/commands/publish/npm-publisher.js +1 -1
- package/dist/commands/publish/npm-publisher.js.map +1 -1
- package/dist/commands/publish/publish-command.js +1 -1
- package/dist/commands/publish/publish-command.js.map +1 -1
- package/dist/commands/publish/version-upgrade.js +1 -1
- package/dist/commands/publish/version-upgrade.js.map +1 -1
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +2 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -1
- package/dist/deps/replace-deps/collect-deps.js +5 -2
- package/dist/deps/replace-deps/collect-deps.js.map +1 -1
- package/dist/deps/replace-deps/replace-deps.d.ts +21 -3
- package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -1
- package/dist/deps/replace-deps/replace-deps.js +107 -62
- package/dist/deps/replace-deps/replace-deps.js.map +1 -1
- package/dist/electron/electron.js +7 -7
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +2 -5
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/EsbuildClientEngine.d.ts.map +1 -1
- package/dist/engines/EsbuildClientEngine.js +16 -9
- package/dist/engines/EsbuildClientEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts +4 -4
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +5 -5
- package/dist/engines/NgtscEngine.js.map +1 -1
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +0 -2
- package/dist/engines/TscEngine.js.map +1 -1
- package/dist/engines/types.d.ts +2 -0
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts +36 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts.map +1 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.js +464 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.js.map +1 -0
- package/dist/esbuild/esbuild-client-config.d.ts +8 -2
- package/dist/esbuild/esbuild-client-config.d.ts.map +1 -1
- package/dist/esbuild/esbuild-client-config.js +48 -33
- package/dist/esbuild/esbuild-client-config.js.map +1 -1
- package/dist/esbuild/esbuild-tsc-plugin.d.ts +4 -1
- package/dist/esbuild/esbuild-tsc-plugin.d.ts.map +1 -1
- package/dist/esbuild/esbuild-tsc-plugin.js +27 -23
- package/dist/esbuild/esbuild-tsc-plugin.js.map +1 -1
- package/dist/esbuild/file-reference-tracker.d.ts +24 -0
- package/dist/esbuild/file-reference-tracker.d.ts.map +1 -0
- package/dist/esbuild/file-reference-tracker.js +57 -0
- package/dist/esbuild/file-reference-tracker.js.map +1 -0
- package/dist/esbuild/lmdb-cache-store.d.ts +18 -0
- package/dist/esbuild/lmdb-cache-store.d.ts.map +1 -0
- package/dist/esbuild/lmdb-cache-store.js +41 -0
- package/dist/esbuild/lmdb-cache-store.js.map +1 -0
- package/dist/esbuild/load-result-cache.d.ts +17 -0
- package/dist/esbuild/load-result-cache.d.ts.map +1 -0
- package/dist/esbuild/load-result-cache.js +61 -0
- package/dist/esbuild/load-result-cache.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lint/lint-core.js +7 -7
- package/dist/lint/lint-core.js.map +1 -1
- package/dist/orchestrators/BaseOrchestrator.js +2 -2
- package/dist/orchestrators/BaseOrchestrator.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +5 -19
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +5 -5
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.js +6 -6
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/runtime/ResultCollector.d.ts +1 -0
- package/dist/runtime/ResultCollector.d.ts.map +1 -1
- package/dist/runtime/ResultCollector.js.map +1 -1
- package/dist/runtime/engine-watch-events.d.ts.map +1 -1
- package/dist/runtime/engine-watch-events.js +3 -0
- package/dist/runtime/engine-watch-events.js.map +1 -1
- package/dist/runtime/rebuild-manager.js +1 -1
- package/dist/runtime/rebuild-manager.js.map +1 -1
- package/dist/runtime/worker-utils.js +1 -1
- package/dist/runtime/worker-utils.js.map +1 -1
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +4 -3
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +3 -3
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-compiler/SdTsCompiler.d.ts +39 -0
- package/dist/ts-compiler/SdTsCompiler.d.ts.map +1 -0
- package/dist/ts-compiler/SdTsCompiler.js +593 -0
- package/dist/ts-compiler/SdTsCompiler.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-options.d.ts +40 -0
- package/dist/ts-compiler/sd-ts-compiler-options.d.ts.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-options.js +2 -0
- package/dist/ts-compiler/sd-ts-compiler-options.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-result.d.ts +34 -0
- package/dist/ts-compiler/sd-ts-compiler-result.d.ts.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-result.js +2 -0
- package/dist/ts-compiler/sd-ts-compiler-result.js.map +1 -0
- package/dist/utils/copy-public.d.ts +6 -4
- package/dist/utils/copy-public.d.ts.map +1 -1
- package/dist/utils/copy-public.js +9 -7
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/diagnostic-utils.d.ts +2 -3
- package/dist/utils/diagnostic-utils.d.ts.map +1 -1
- package/dist/utils/diagnostic-utils.js +8 -9
- package/dist/utils/diagnostic-utils.js.map +1 -1
- package/dist/utils/output-utils.d.ts +8 -2
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/output-utils.js +32 -8
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +1 -1
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +136 -110
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +0 -2
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +147 -70
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +30 -57
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-esbuild-context.d.ts +7 -0
- package/dist/workers/server-esbuild-context.d.ts.map +1 -1
- package/dist/workers/server-esbuild-context.js +11 -2
- package/dist/workers/server-esbuild-context.js.map +1 -1
- package/package.json +7 -6
- package/src/angular/angular-compiler.ts +0 -502
- package/src/angular/hmr-candidates.ts +295 -0
- package/src/angular/ngtsc-build-core.ts +125 -92
- package/src/angular/vite-angular-plugin.ts +71 -65
- package/src/angular/web-worker-transformer.ts +117 -0
- package/src/capacitor/capacitor.ts +6 -4
- package/src/commands/check.ts +17 -76
- package/src/commands/publish/deployment-phase.ts +11 -7
- package/src/commands/publish/npm-publisher.ts +1 -1
- package/src/commands/publish/publish-command.ts +1 -1
- package/src/commands/publish/version-upgrade.ts +1 -1
- package/src/commands/replace-deps.ts +3 -1
- package/src/deps/replace-deps/collect-deps.ts +4 -2
- package/src/deps/replace-deps/replace-deps.ts +114 -66
- package/src/electron/electron.ts +7 -7
- package/src/engines/BaseEngine.ts +2 -6
- package/src/engines/EsbuildClientEngine.ts +16 -10
- package/src/engines/NgtscEngine.ts +7 -7
- package/src/engines/TscEngine.ts +0 -2
- package/src/engines/types.ts +2 -0
- package/src/esbuild/esbuild-angular-compiler-plugin.ts +647 -0
- package/src/esbuild/esbuild-client-config.ts +57 -41
- package/src/esbuild/esbuild-tsc-plugin.ts +33 -23
- package/src/esbuild/file-reference-tracker.ts +61 -0
- package/src/esbuild/lmdb-cache-store.ts +46 -0
- package/src/esbuild/load-result-cache.ts +85 -0
- package/src/index.ts +5 -0
- package/src/lint/lint-core.ts +7 -7
- package/src/orchestrators/BaseOrchestrator.ts +2 -2
- package/src/orchestrators/BuildOrchestrator.ts +5 -24
- package/src/orchestrators/DevOrchestrator.ts +5 -5
- package/src/orchestrators/WatchOrchestrator.ts +6 -6
- package/src/runtime/ResultCollector.ts +1 -0
- package/src/runtime/engine-watch-events.ts +3 -0
- package/src/runtime/rebuild-manager.ts +1 -1
- package/src/runtime/worker-utils.ts +1 -1
- package/src/sd-cli-entry.ts +5 -3
- package/src/sd-cli.ts +4 -4
- package/src/ts-compiler/SdTsCompiler.ts +815 -0
- package/src/ts-compiler/sd-ts-compiler-options.ts +46 -0
- package/src/ts-compiler/sd-ts-compiler-result.ts +34 -0
- package/src/utils/copy-public.ts +9 -6
- package/src/utils/diagnostic-utils.ts +8 -9
- package/src/utils/output-utils.ts +38 -8
- package/src/workers/client.worker.ts +160 -126
- package/src/workers/library-build.worker.ts +187 -75
- package/src/workers/server-build.worker.ts +31 -61
- package/src/workers/server-esbuild-context.ts +14 -2
- package/tests/angular/fixtures/packages/basic-app/dist/styles.css +3 -0
- package/tests/angular/fixtures/packages/basic-app/scss/styles.scss +5 -0
- package/tests/angular/vite-angular-plugin-sdtscompiler.verify.md +13 -0
- package/tests/angular/web-worker-transformer.spec.ts +154 -0
- package/tests/capacitor/capacitor-build.spec.ts +1 -1
- package/tests/capacitor/capacitor-icon.spec.ts +1 -1
- package/tests/capacitor/capacitor-init.spec.ts +1 -1
- package/tests/commands/check.spec.ts +90 -104
- package/tests/commands/publish.spec.ts +12 -4
- package/tests/commands/slice3-severity-cleanup.verify.md +12 -0
- package/tests/deps/replace-deps/collect-deps.acc.spec.ts +62 -0
- package/tests/deps/replace-deps/collect-deps.spec.ts +49 -0
- package/tests/deps/replace-deps/replace-deps-filter.spec.ts +103 -0
- package/tests/deps/replace-deps/replace-deps-setup.acc.spec.ts +156 -0
- package/tests/electron/electron.spec.ts +4 -1
- package/tests/engines/engine-adapter-isolation.spec.ts +5 -6
- package/tests/engines/engine-duplicate-output-removal.verify.md +10 -0
- package/tests/engines/esbuild-client-engine.acc.spec.ts +79 -0
- package/tests/engines/esbuild-client-engine.spec.ts +73 -3
- package/tests/esbuild/esbuild-angular-compiler-plugin-hmr.verify.md +23 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-onload.verify.md +21 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-onstart-extraction.verify.md +16 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-sdtscompiler.verify.md +15 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-stylesheet.verify.md +31 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-worker.verify.md +31 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin.spec.ts +397 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin.verify.md +21 -0
- package/tests/esbuild/esbuild-tsc-plugin-imports.verify.md +13 -0
- package/tests/esbuild/esbuild-tsc-plugin.acc.spec.ts +56 -111
- package/tests/esbuild/esbuild-tsc-plugin.spec.ts +116 -52
- package/tests/esbuild/file-reference-tracker.spec.ts +99 -0
- package/tests/esbuild/lmdb-cache-store.spec.ts +58 -0
- package/tests/esbuild/load-result-cache.acc.spec.ts +55 -0
- package/tests/esbuild/load-result-cache.spec.ts +133 -0
- package/tests/orchestrators/build-orchestrator.spec.ts +4 -3
- package/tests/orchestrators/dev-orchestrator.spec.ts +5 -5
- package/tests/orchestrators/slice1-stdout-to-consola.verify.md +10 -0
- package/tests/orchestrators/typecheck-orchestrator.spec.ts +1 -1
- package/tests/orchestrators/watch-orchestrator.spec.ts +7 -7
- package/tests/runtime/result-collector.spec.ts +64 -0
- package/tests/sd-cli-entry.spec.ts +3 -4
- package/tests/sd-cli-log-tag.verify.md +11 -0
- package/tests/ts-compiler/SdTsCompiler-affected-files.verify.md +8 -0
- package/tests/ts-compiler/SdTsCompiler-diagnostics.verify.md +12 -0
- package/tests/ts-compiler/SdTsCompiler-emit.verify.md +9 -0
- package/tests/ts-compiler/SdTsCompiler.acc.spec.ts +603 -0
- package/tests/ts-compiler/SdTsCompiler.spec.ts +265 -0
- package/tests/ts-compiler/SdTsCompiler.verify.md +41 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-browser.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-node.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.d.ts +2 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.d.ts.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.js +4 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.js.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.d.ts +2 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.d.ts.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.js +4 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.js.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/src/index.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/src/util.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/tests/sample.test-file.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/tsconfig.json +12 -0
- package/tests/ts-compiler/scss-lint-integration.verify.md +14 -0
- package/tests/utils/angular-build.spec.ts +1 -1
- package/tests/utils/copy-public-outdir.verify.md +8 -0
- package/tests/utils/copy-public.acc.spec.ts +52 -0
- package/tests/utils/copy-public.spec.ts +56 -0
- package/tests/utils/diagnostic-utils.spec.ts +24 -15
- package/tests/utils/engine-watch-events.acc.spec.ts +59 -0
- package/tests/utils/engine-watch-events.spec.ts +58 -0
- package/tests/utils/esbuild-client-config-integration.verify.md +9 -0
- package/tests/utils/esbuild-client-config.acc.spec.ts +45 -61
- package/tests/utils/esbuild-client-config.spec.ts +70 -52
- package/tests/utils/ngtsc-build-core-write-emit.spec.ts +12 -12
- package/tests/utils/ngtsc-build-core.spec.ts +1 -44
- package/tests/utils/output-utils.spec.ts +133 -13
- package/tests/utils/replace-deps-watch.acc.spec.ts +7 -1
- package/tests/utils/replace-deps-watch.spec.ts +57 -1
- package/tests/utils/worker-utils.spec.ts +8 -2
- package/tests/workers/client-worker-initial-build-error.verify.md +2 -3
- package/tests/workers/client-worker-initial-build-warnings.verify.md +7 -0
- package/tests/workers/client-worker-refactor.verify.md +22 -0
- package/tests/workers/client-worker-ts-cache-invalidation.verify.md +12 -0
- package/tests/workers/client-worker.acc.spec.ts +6 -3
- package/tests/workers/library-build-lint.spec.ts +40 -45
- package/tests/workers/library-build-worker.spec.ts +294 -40
- package/tests/workers/server-build-lint.spec.ts +59 -45
- package/tests/workers/server-build-worker.spec.ts +63 -24
- package/tests/workers/server-esbuild-context.acc.spec.ts +2 -0
- package/tests/workers/server-esbuild-context.spec.ts +2 -0
- package/tests/workers/server-runtime-worker.spec.ts +1 -1
- package/tests/workers/shared-worker-lifecycle.acc.spec.ts +1 -1
- package/dist/angular/angular-build-pipeline.d.ts +0 -97
- package/dist/angular/angular-build-pipeline.d.ts.map +0 -1
- package/dist/angular/angular-build-pipeline.js +0 -285
- package/dist/angular/angular-build-pipeline.js.map +0 -1
- package/dist/utils/tsc-build.d.ts +0 -51
- package/dist/utils/tsc-build.d.ts.map +0 -1
- package/dist/utils/tsc-build.js +0 -156
- package/dist/utils/tsc-build.js.map +0 -1
- package/dist/workers/ngtsc-build.worker.d.ts +0 -23
- package/dist/workers/ngtsc-build.worker.d.ts.map +0 -1
- package/dist/workers/ngtsc-build.worker.js +0 -267
- package/dist/workers/ngtsc-build.worker.js.map +0 -1
- package/src/angular/angular-build-pipeline.ts +0 -406
- package/src/utils/tsc-build.ts +0 -226
- package/src/workers/ngtsc-build.worker.ts +0 -351
- package/tests/angular/angular-build-pipeline.spec.ts +0 -247
- package/tests/angular/angular-compiler-aot.acc.spec.ts +0 -68
- package/tests/angular/angular-compiler-aot.spec.ts +0 -80
- package/tests/utils/angular-compiler-emit.spec.ts +0 -666
- package/tests/utils/angular-compiler.spec.ts +0 -707
- package/tests/utils/tsc-build.spec.ts +0 -527
- package/tests/workers/ngtsc-build-lint.spec.ts +0 -141
- package/tests/workers/ngtsc-build-worker.spec.ts +0 -199
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import * as tscBuild from "../../src/utils/tsc-build";
|
|
4
3
|
import * as collectDepsModule from "../../src/deps/replace-deps/collect-deps";
|
|
5
4
|
|
|
6
5
|
//#region Mocks
|
|
@@ -12,6 +11,35 @@ let mockSend: ReturnType<typeof vi.fn>;
|
|
|
12
11
|
const mockOnChange = vi.fn();
|
|
13
12
|
const mockWatcherClose = vi.fn();
|
|
14
13
|
|
|
14
|
+
// SdTsCompiler mock
|
|
15
|
+
const { mockCompileAsync, MockSdTsCompiler, mockSideEffectScssRegistry } = vi.hoisted(() => {
|
|
16
|
+
const compileAsync = vi.fn();
|
|
17
|
+
const sideEffectScssRegistry = new Map();
|
|
18
|
+
const Compiler = vi.fn().mockImplementation(function (this: any) {
|
|
19
|
+
this.compileAsync = compileAsync;
|
|
20
|
+
this.sideEffectScssRegistry = sideEffectScssRegistry;
|
|
21
|
+
});
|
|
22
|
+
return { mockCompileAsync: compileAsync, MockSdTsCompiler: Compiler, mockSideEffectScssRegistry: sideEffectScssRegistry };
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
vi.mock("../../src/ts-compiler/SdTsCompiler", () => ({
|
|
26
|
+
SdTsCompiler: MockSdTsCompiler,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
// ngtsc-build-core mock (writeEmitResults + compileSideEffectScss)
|
|
30
|
+
const { mockWriteEmitResults, mockCompileSideEffectScss } = vi.hoisted(() => {
|
|
31
|
+
return { mockWriteEmitResults: vi.fn(), mockCompileSideEffectScss: vi.fn() };
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
vi.mock("../../src/angular/ngtsc-build-core", async (importOriginal) => {
|
|
35
|
+
const original = await importOriginal<typeof import("../../src/angular/ngtsc-build-core")>();
|
|
36
|
+
return {
|
|
37
|
+
...original,
|
|
38
|
+
writeEmitResults: mockWriteEmitResults,
|
|
39
|
+
compileSideEffectScss: mockCompileSideEffectScss,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
15
43
|
vi.mock("@simplysm/core-node", () => ({
|
|
16
44
|
createWorker: vi.fn((fns: Record<string, Function>) => {
|
|
17
45
|
workerFns = fns as any;
|
|
@@ -39,18 +67,6 @@ vi.mock("../../src/workers/shared-worker-lifecycle", () => ({
|
|
|
39
67
|
})),
|
|
40
68
|
}));
|
|
41
69
|
|
|
42
|
-
// tsc build spy
|
|
43
|
-
const mockRunTscPackageBuild = vi.spyOn(tscBuild, "runTscPackageBuild").mockReturnValue({
|
|
44
|
-
success: true,
|
|
45
|
-
errors: undefined,
|
|
46
|
-
diagnostics: [],
|
|
47
|
-
errorCount: 0,
|
|
48
|
-
warningCount: 0,
|
|
49
|
-
program: {
|
|
50
|
-
getSourceFiles: () => [{ fileName: "/pkg/src/index.ts" }],
|
|
51
|
-
},
|
|
52
|
-
} as any);
|
|
53
|
-
|
|
54
70
|
// collect-deps spy
|
|
55
71
|
const mockCollectDeps = vi.spyOn(collectDepsModule, "collectDeps").mockReturnValue({
|
|
56
72
|
workspaceDeps: [],
|
|
@@ -59,27 +75,33 @@ const mockCollectDeps = vi.spyOn(collectDepsModule, "collectDeps").mockReturnVal
|
|
|
59
75
|
|
|
60
76
|
//#endregion
|
|
61
77
|
|
|
78
|
+
const defaultCompileResult = {
|
|
79
|
+
program: { getSourceFiles: () => [{ fileName: "/pkg/src/index.ts" }] },
|
|
80
|
+
builderProgram: {},
|
|
81
|
+
isForAngular: false,
|
|
82
|
+
affectedFiles: new Set<string>(),
|
|
83
|
+
diagnostics: [] as any[],
|
|
84
|
+
errorCount: 0,
|
|
85
|
+
warningCount: 0,
|
|
86
|
+
errors: undefined as string[] | undefined,
|
|
87
|
+
emitResults: undefined,
|
|
88
|
+
lint: undefined,
|
|
89
|
+
scssErrors: [] as string[],
|
|
90
|
+
scssDependencies: new Map<string, Set<string>>(),
|
|
91
|
+
};
|
|
92
|
+
|
|
62
93
|
// Import triggers createWorker, capturing the functions
|
|
63
94
|
await import("../../src/workers/library-build.worker");
|
|
64
95
|
|
|
65
96
|
beforeEach(() => {
|
|
66
97
|
vi.clearAllMocks();
|
|
67
|
-
|
|
68
|
-
success: true,
|
|
69
|
-
errors: undefined,
|
|
70
|
-
diagnostics: [],
|
|
71
|
-
errorCount: 0,
|
|
72
|
-
warningCount: 0,
|
|
73
|
-
program: {
|
|
74
|
-
getSourceFiles: () => [{ fileName: "/pkg/src/index.ts" }],
|
|
75
|
-
},
|
|
76
|
-
} as any);
|
|
98
|
+
mockCompileAsync.mockResolvedValue({ ...defaultCompileResult });
|
|
77
99
|
mockCollectDeps.mockReturnValue({ workspaceDeps: [], replaceDeps: [] });
|
|
100
|
+
mockSideEffectScssRegistry.clear();
|
|
78
101
|
});
|
|
79
102
|
|
|
80
103
|
const buildInfo = {
|
|
81
104
|
name: "test-pkg",
|
|
82
|
-
config: { target: "node" as const },
|
|
83
105
|
cwd: "/",
|
|
84
106
|
pkgDir: "/pkg",
|
|
85
107
|
output: { js: true, dts: true },
|
|
@@ -109,16 +131,13 @@ describe("library-build.worker build()", () => {
|
|
|
109
131
|
|
|
110
132
|
// Unit: tsc failure reflects in build result
|
|
111
133
|
it("reports failure in build when tsc fails", async () => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
errors: ["TS2345: type error"],
|
|
115
|
-
diagnostics: [{ code: 2345, category: 1 }],
|
|
134
|
+
mockCompileAsync.mockResolvedValueOnce({
|
|
135
|
+
...defaultCompileResult,
|
|
116
136
|
errorCount: 1,
|
|
117
137
|
warningCount: 0,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} as any);
|
|
138
|
+
errors: ["TS2345: type error"],
|
|
139
|
+
diagnostics: [{ code: 2345, category: 1 }],
|
|
140
|
+
});
|
|
122
141
|
|
|
123
142
|
const result = await workerFns["build"]({ ...buildInfo, output: { js: true, dts: true } });
|
|
124
143
|
|
|
@@ -129,6 +148,117 @@ describe("library-build.worker build()", () => {
|
|
|
129
148
|
|
|
130
149
|
});
|
|
131
150
|
|
|
151
|
+
const angularBuildInfo = {
|
|
152
|
+
name: "test-angular-lib",
|
|
153
|
+
cwd: "/workspace",
|
|
154
|
+
pkgDir: "/workspace/packages/test-angular-lib",
|
|
155
|
+
output: { js: true, dts: true, globalScss: true },
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const angularCompileResult = {
|
|
159
|
+
...defaultCompileResult,
|
|
160
|
+
program: { getSourceFiles: () => [{ fileName: "/workspace/packages/test-angular-lib/src/index.ts" }] },
|
|
161
|
+
isForAngular: true,
|
|
162
|
+
emitResults: [
|
|
163
|
+
{ filename: "/workspace/packages/test-angular-lib/dist/index.js", contents: "export {};", sourceFileName: "/workspace/packages/test-angular-lib/src/index.ts" },
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
describe("library-build.worker build() — Angular", () => {
|
|
168
|
+
// Acceptance: Angular one-shot build — writeEmitResults 호출
|
|
169
|
+
it("calls writeEmitResults with emitResults filtered to src/", async () => {
|
|
170
|
+
mockCompileAsync.mockResolvedValueOnce({
|
|
171
|
+
...angularCompileResult,
|
|
172
|
+
emitResults: [
|
|
173
|
+
{ filename: "dist/src-file.js", contents: "a", sourceFileName: "/workspace/packages/test-angular-lib/src/src-file.ts" },
|
|
174
|
+
{ filename: "dist/ext.js", contents: "b", sourceFileName: "/workspace/packages/test-angular-lib/node_modules/ext.ts" },
|
|
175
|
+
],
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
await workerFns["build"](angularBuildInfo);
|
|
179
|
+
|
|
180
|
+
expect(mockWriteEmitResults).toHaveBeenCalledTimes(1);
|
|
181
|
+
const emitArg = mockWriteEmitResults.mock.calls[0][0] as any[];
|
|
182
|
+
// src/ 하위만 필터됨
|
|
183
|
+
expect(emitArg).toHaveLength(1);
|
|
184
|
+
expect(emitArg[0].sourceFileName).toContain("src/src-file.ts");
|
|
185
|
+
// pkgDir 전달
|
|
186
|
+
expect(mockWriteEmitResults.mock.calls[0][1]).toBe(angularBuildInfo.pkgDir);
|
|
187
|
+
// Angular build 모드에서 scss 옵션 전달
|
|
188
|
+
expect(mockWriteEmitResults.mock.calls[0][2]).toEqual({
|
|
189
|
+
loadPaths: [
|
|
190
|
+
path.join(angularBuildInfo.pkgDir, "scss"),
|
|
191
|
+
path.join(angularBuildInfo.cwd, "node_modules"),
|
|
192
|
+
],
|
|
193
|
+
scssErrors: [],
|
|
194
|
+
scssDependencies: expect.any(Map),
|
|
195
|
+
registry: expect.any(Map),
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Acceptance: Angular build with SCSS errors
|
|
200
|
+
it("returns success=false when scssErrors exist", async () => {
|
|
201
|
+
mockCompileAsync.mockResolvedValueOnce({
|
|
202
|
+
...angularCompileResult,
|
|
203
|
+
scssErrors: ["SCSS error in styles.scss: variable not found"],
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const result = await workerFns["build"](angularBuildInfo);
|
|
207
|
+
|
|
208
|
+
expect(result.build.success).toBe(false);
|
|
209
|
+
expect(result.build.errors).toContain("SCSS error in styles.scss: variable not found");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Unit: ts errors + scss errors 병합
|
|
213
|
+
it("merges both ts errors and scss errors into build.errors", async () => {
|
|
214
|
+
mockCompileAsync.mockResolvedValueOnce({
|
|
215
|
+
...angularCompileResult,
|
|
216
|
+
errorCount: 1,
|
|
217
|
+
errors: ["TS2345: type error"],
|
|
218
|
+
scssErrors: ["SCSS error"],
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const result = await workerFns["build"](angularBuildInfo);
|
|
222
|
+
|
|
223
|
+
expect(result.build.success).toBe(false);
|
|
224
|
+
expect(result.build.errors).toEqual(["TS2345: type error", "SCSS error"]);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// Acceptance: Angular build 예외 처리
|
|
228
|
+
it("catches exceptions and returns error result", async () => {
|
|
229
|
+
mockCompileAsync.mockRejectedValueOnce(new Error("Fatal crash"));
|
|
230
|
+
|
|
231
|
+
const result = await workerFns["build"](angularBuildInfo);
|
|
232
|
+
|
|
233
|
+
expect(result.build.success).toBe(false);
|
|
234
|
+
expect(result.build.errors).toContain("Fatal crash");
|
|
235
|
+
expect(result.build.diagnostics).toEqual([]);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Unit: emitResults가 undefined이면 writeEmitResults 미호출
|
|
239
|
+
it("skips writeEmitResults when emitResults is undefined", async () => {
|
|
240
|
+
mockCompileAsync.mockResolvedValueOnce({
|
|
241
|
+
...angularCompileResult,
|
|
242
|
+
emitResults: undefined,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
await workerFns["build"](angularBuildInfo);
|
|
246
|
+
|
|
247
|
+
expect(mockWriteEmitResults).not.toHaveBeenCalled();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Unit: globalScss 옵션이 SdTsCompiler에 전달됨
|
|
251
|
+
it("passes globalScss to SdTsCompiler", async () => {
|
|
252
|
+
mockCompileAsync.mockResolvedValueOnce({ ...angularCompileResult });
|
|
253
|
+
|
|
254
|
+
await workerFns["build"](angularBuildInfo);
|
|
255
|
+
|
|
256
|
+
expect(MockSdTsCompiler).toHaveBeenCalledWith(expect.objectContaining({
|
|
257
|
+
globalScss: true,
|
|
258
|
+
}));
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
132
262
|
describe("library-build.worker startWatch()", () => {
|
|
133
263
|
// Acceptance: Initial build completes before returning
|
|
134
264
|
it("completes initial build and sends build event", async () => {
|
|
@@ -172,7 +302,7 @@ describe("library-build.worker startWatch()", () => {
|
|
|
172
302
|
it("sends error event on rebuild exception", async () => {
|
|
173
303
|
await workerFns["startWatch"]({ ...buildInfo, output: { js: true, dts: true } });
|
|
174
304
|
|
|
175
|
-
|
|
305
|
+
mockCompileAsync.mockRejectedValueOnce(new Error("tsc crash"));
|
|
176
306
|
const onChangeCallback = mockOnChange.mock.calls[0][1];
|
|
177
307
|
mockSend.mockClear();
|
|
178
308
|
|
|
@@ -219,14 +349,10 @@ describe("library-build.worker startWatch() dependency filter", () => {
|
|
|
219
349
|
});
|
|
220
350
|
|
|
221
351
|
const buildInfoWithProgram = () => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
errors: undefined,
|
|
225
|
-
diagnostics: [],
|
|
226
|
-
errorCount: 0,
|
|
227
|
-
warningCount: 0,
|
|
352
|
+
mockCompileAsync.mockResolvedValue({
|
|
353
|
+
...defaultCompileResult,
|
|
228
354
|
program: createMockProgram(["/pkg/src/index.ts", "/pkg/src/utils.ts"]),
|
|
229
|
-
}
|
|
355
|
+
});
|
|
230
356
|
};
|
|
231
357
|
|
|
232
358
|
// Acceptance: Skip rebuild when changed file is not in program
|
|
@@ -296,6 +422,134 @@ describe("library-build.worker startWatch() dependency filter", () => {
|
|
|
296
422
|
});
|
|
297
423
|
});
|
|
298
424
|
|
|
425
|
+
describe("library-build.worker startWatch() — Angular", () => {
|
|
426
|
+
const angularWatchInfo = {
|
|
427
|
+
...angularBuildInfo,
|
|
428
|
+
replaceDeps: undefined as Record<string, string> | undefined,
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
const angularWatchCompileResult = {
|
|
432
|
+
...angularCompileResult,
|
|
433
|
+
program: {
|
|
434
|
+
getSourceFiles: () => [
|
|
435
|
+
{ fileName: "/workspace/packages/test-angular-lib/src/index.ts" },
|
|
436
|
+
{ fileName: "/workspace/packages/test-angular-lib/src/comp.ts" },
|
|
437
|
+
],
|
|
438
|
+
},
|
|
439
|
+
scssDependencies: new Map<string, ReadonlySet<string>>(),
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// Acceptance: Angular 초기 빌드 with SCSS globs
|
|
443
|
+
it("starts FsWatcher with scss globs when globalScss is true", async () => {
|
|
444
|
+
mockCompileAsync.mockResolvedValue({ ...angularWatchCompileResult });
|
|
445
|
+
|
|
446
|
+
await workerFns["startWatch"](angularWatchInfo);
|
|
447
|
+
|
|
448
|
+
const { FsWatcher } = await import("@simplysm/core-node");
|
|
449
|
+
const watchPaths = vi.mocked(FsWatcher.watch).mock.calls[0][0];
|
|
450
|
+
// src/**/*.{ts,scss,css} + scss/**/*.{scss,css}
|
|
451
|
+
expect(watchPaths.length).toBeGreaterThanOrEqual(2);
|
|
452
|
+
expect(watchPaths.some((p: string) => p.includes("*.{ts,scss,css}"))).toBe(true);
|
|
453
|
+
expect(watchPaths.some((p: string) => p.includes("*.{scss,css}"))).toBe(true);
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// Acceptance: Angular 초기 빌드 — writeEmitResults with scss option
|
|
457
|
+
it("calls writeEmitResults with scss option in initial watch build", async () => {
|
|
458
|
+
mockCompileAsync.mockResolvedValue({ ...angularWatchCompileResult });
|
|
459
|
+
|
|
460
|
+
await workerFns["startWatch"](angularWatchInfo);
|
|
461
|
+
|
|
462
|
+
expect(mockWriteEmitResults).toHaveBeenCalledWith(
|
|
463
|
+
expect.any(Array),
|
|
464
|
+
angularWatchInfo.pkgDir,
|
|
465
|
+
expect.objectContaining({
|
|
466
|
+
loadPaths: expect.any(Array),
|
|
467
|
+
scssErrors: expect.any(Array),
|
|
468
|
+
scssDependencies: expect.any(Map),
|
|
469
|
+
registry: mockSideEffectScssRegistry,
|
|
470
|
+
}),
|
|
471
|
+
);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
// Acceptance: globalScss가 SdTsCompiler에 전달됨
|
|
475
|
+
it("passes globalScss to SdTsCompiler in watch mode", async () => {
|
|
476
|
+
mockCompileAsync.mockResolvedValue({ ...angularWatchCompileResult });
|
|
477
|
+
|
|
478
|
+
await workerFns["startWatch"](angularWatchInfo);
|
|
479
|
+
|
|
480
|
+
expect(MockSdTsCompiler).toHaveBeenCalledWith(expect.objectContaining({
|
|
481
|
+
globalScss: true,
|
|
482
|
+
}));
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// Acceptance: SCSS 의존성 역방향 탐색
|
|
486
|
+
it("adds SCSS-dependent files to modifiedFiles via combinedScssDeps", async () => {
|
|
487
|
+
const scssDeps = new Map<string, ReadonlySet<string>>();
|
|
488
|
+
scssDeps.set(
|
|
489
|
+
"/workspace/packages/test-angular-lib/src/comp.ts",
|
|
490
|
+
new Set(["/workspace/packages/test-angular-lib/scss/shared.scss"]),
|
|
491
|
+
);
|
|
492
|
+
mockCompileAsync.mockResolvedValue({
|
|
493
|
+
...angularWatchCompileResult,
|
|
494
|
+
scssDependencies: scssDeps,
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
await workerFns["startWatch"](angularWatchInfo);
|
|
498
|
+
|
|
499
|
+
const onChangeCallback = mockOnChange.mock.calls[0][1];
|
|
500
|
+
mockSend.mockClear();
|
|
501
|
+
|
|
502
|
+
// shared.scss 변경 → comp.ts도 modifiedFiles에 추가
|
|
503
|
+
await onChangeCallback([
|
|
504
|
+
{ event: "change", path: "/workspace/packages/test-angular-lib/scss/shared.scss" },
|
|
505
|
+
]);
|
|
506
|
+
|
|
507
|
+
expect(mockSend).toHaveBeenCalledWith("buildStart", {});
|
|
508
|
+
const compileCall = mockCompileAsync.mock.calls[mockCompileAsync.mock.calls.length - 1];
|
|
509
|
+
const modifiedFiles = compileCall[0] as Set<string>;
|
|
510
|
+
expect(modifiedFiles.has("/workspace/packages/test-angular-lib/scss/shared.scss")).toBe(true);
|
|
511
|
+
expect(modifiedFiles.has("/workspace/packages/test-angular-lib/src/comp.ts")).toBe(true);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// Acceptance: SCSS 변경 시 compileSideEffectScss 호출
|
|
515
|
+
it("calls compileSideEffectScss when scss files change", async () => {
|
|
516
|
+
mockCompileAsync.mockResolvedValue({ ...angularWatchCompileResult });
|
|
517
|
+
|
|
518
|
+
await workerFns["startWatch"](angularWatchInfo);
|
|
519
|
+
|
|
520
|
+
const onChangeCallback = mockOnChange.mock.calls[0][1];
|
|
521
|
+
mockCompileSideEffectScss.mockClear();
|
|
522
|
+
|
|
523
|
+
await onChangeCallback([
|
|
524
|
+
{ event: "change", path: "/workspace/packages/test-angular-lib/src/styles.scss" },
|
|
525
|
+
{ event: "change", path: "/workspace/packages/test-angular-lib/src/index.ts" },
|
|
526
|
+
]);
|
|
527
|
+
|
|
528
|
+
expect(mockCompileSideEffectScss).toHaveBeenCalledWith(
|
|
529
|
+
mockSideEffectScssRegistry,
|
|
530
|
+
expect.any(Array),
|
|
531
|
+
expect.any(Array),
|
|
532
|
+
expect.any(Map),
|
|
533
|
+
);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// Unit: SCSS 미변경 시 compileSideEffectScss 미호출
|
|
537
|
+
it("does not call compileSideEffectScss when no scss changes", async () => {
|
|
538
|
+
mockCompileAsync.mockResolvedValue({ ...angularWatchCompileResult });
|
|
539
|
+
|
|
540
|
+
await workerFns["startWatch"](angularWatchInfo);
|
|
541
|
+
|
|
542
|
+
const onChangeCallback = mockOnChange.mock.calls[0][1];
|
|
543
|
+
mockCompileSideEffectScss.mockClear();
|
|
544
|
+
|
|
545
|
+
await onChangeCallback([
|
|
546
|
+
{ event: "change", path: "/workspace/packages/test-angular-lib/src/index.ts" },
|
|
547
|
+
]);
|
|
548
|
+
|
|
549
|
+
expect(mockCompileSideEffectScss).not.toHaveBeenCalled();
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
|
|
299
553
|
describe("library-build.worker stopWatch()", () => {
|
|
300
554
|
it("cleans up FsWatcher", async () => {
|
|
301
555
|
await workerFns["startWatch"]({ ...buildInfo, output: { js: true, dts: true } });
|
|
@@ -2,34 +2,35 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
2
2
|
|
|
3
3
|
// --- Mocks ---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
success: true,
|
|
8
|
-
errorCount: 0,
|
|
9
|
-
warningCount: 0,
|
|
10
|
-
formattedOutput: "",
|
|
11
|
-
});
|
|
12
|
-
const RunnerCls = vi.fn().mockImplementation(function () {
|
|
13
|
-
return { lint: lintFn };
|
|
14
|
-
});
|
|
15
|
-
return { mockLintFn: lintFn, MockLintWithProgramRunner: RunnerCls };
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
vi.mock("../../src/lint/lint-with-program", () => ({
|
|
19
|
-
LintWithProgramRunner: MockLintWithProgramRunner,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const mockTscResult = {
|
|
5
|
+
// SdTsCompiler mock (js=false path) — lint result is part of compileAsync result
|
|
6
|
+
const mockLintResult = {
|
|
23
7
|
success: true,
|
|
24
|
-
errors: undefined,
|
|
25
|
-
diagnostics: [],
|
|
26
8
|
errorCount: 0,
|
|
27
9
|
warningCount: 0,
|
|
28
|
-
|
|
10
|
+
formattedOutput: "",
|
|
29
11
|
};
|
|
30
12
|
|
|
31
|
-
vi.
|
|
32
|
-
|
|
13
|
+
const mockCompileAsync = vi.fn(() => Promise.resolve({
|
|
14
|
+
program: { getSourceFiles: () => [] },
|
|
15
|
+
builderProgram: {},
|
|
16
|
+
isForAngular: false,
|
|
17
|
+
affectedFiles: undefined,
|
|
18
|
+
diagnostics: [],
|
|
19
|
+
errorCount: 0,
|
|
20
|
+
warningCount: 0,
|
|
21
|
+
errors: undefined as string[] | undefined,
|
|
22
|
+
emitResults: undefined,
|
|
23
|
+
lint: undefined as typeof mockLintResult | undefined,
|
|
24
|
+
scssErrors: [],
|
|
25
|
+
scssDependencies: new Map(),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const MockSdTsCompiler = vi.fn().mockImplementation(function () {
|
|
29
|
+
return { compileAsync: mockCompileAsync };
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
vi.mock("../../src/ts-compiler/SdTsCompiler", () => ({
|
|
33
|
+
SdTsCompiler: MockSdTsCompiler,
|
|
33
34
|
}));
|
|
34
35
|
|
|
35
36
|
// tsc plugin mock (build() js=true path)
|
|
@@ -39,6 +40,7 @@ const mockTscPlugin = {
|
|
|
39
40
|
getAffectedFiles: vi.fn(),
|
|
40
41
|
getDiagnostics: vi.fn((): unknown[] => []),
|
|
41
42
|
getErrors: vi.fn((): string[] | undefined => undefined),
|
|
43
|
+
getLintResult: vi.fn((): typeof mockLintResult | undefined => undefined),
|
|
42
44
|
resetBuilderProgram: vi.fn(),
|
|
43
45
|
};
|
|
44
46
|
|
|
@@ -114,25 +116,48 @@ await import("../../src/workers/server-build.worker");
|
|
|
114
116
|
|
|
115
117
|
beforeEach(() => {
|
|
116
118
|
vi.clearAllMocks();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
mockCompileAsync.mockResolvedValue({
|
|
120
|
+
program: { getSourceFiles: () => [] },
|
|
121
|
+
builderProgram: {},
|
|
122
|
+
isForAngular: false,
|
|
123
|
+
affectedFiles: undefined,
|
|
124
|
+
diagnostics: [],
|
|
119
125
|
errorCount: 0,
|
|
120
126
|
warningCount: 0,
|
|
121
|
-
|
|
127
|
+
errors: undefined,
|
|
128
|
+
emitResults: undefined,
|
|
129
|
+
lint: undefined,
|
|
130
|
+
scssErrors: [],
|
|
131
|
+
scssDependencies: new Map(),
|
|
122
132
|
});
|
|
123
|
-
mockTscResult.program = { getSourceFiles: () => [] } as any;
|
|
124
133
|
|
|
125
134
|
// Reset tsc plugin mock
|
|
126
135
|
mockTscPlugin.getProgram.mockReset();
|
|
127
136
|
mockTscPlugin.getAffectedFiles.mockReset();
|
|
128
137
|
mockTscPlugin.getDiagnostics.mockReset().mockReturnValue([]);
|
|
129
138
|
mockTscPlugin.getErrors.mockReset().mockReturnValue(undefined);
|
|
139
|
+
mockTscPlugin.getLintResult.mockReset().mockReturnValue(undefined);
|
|
130
140
|
mockTscPlugin.resetBuilderProgram.mockReset();
|
|
131
141
|
});
|
|
132
142
|
|
|
133
143
|
describe("server-build.worker lint integration (Slice 3)", () => {
|
|
134
|
-
describe("Scenario:
|
|
135
|
-
it("returns lint result
|
|
144
|
+
describe("Scenario: js=false lint via SdTsCompiler", () => {
|
|
145
|
+
it("returns lint result from SdTsCompiler when lint is enabled", async () => {
|
|
146
|
+
mockCompileAsync.mockResolvedValueOnce({
|
|
147
|
+
program: { getSourceFiles: () => [] },
|
|
148
|
+
builderProgram: {},
|
|
149
|
+
isForAngular: false,
|
|
150
|
+
affectedFiles: undefined,
|
|
151
|
+
diagnostics: [],
|
|
152
|
+
errorCount: 0,
|
|
153
|
+
warningCount: 0,
|
|
154
|
+
errors: undefined,
|
|
155
|
+
emitResults: undefined,
|
|
156
|
+
lint: mockLintResult,
|
|
157
|
+
scssErrors: [],
|
|
158
|
+
scssDependencies: new Map(),
|
|
159
|
+
});
|
|
160
|
+
|
|
136
161
|
const result = await workerMethods["build"]({
|
|
137
162
|
name: "my-server",
|
|
138
163
|
cwd: "/workspace",
|
|
@@ -141,19 +166,13 @@ describe("server-build.worker lint integration (Slice 3)", () => {
|
|
|
141
166
|
});
|
|
142
167
|
|
|
143
168
|
expect(result).toHaveProperty("lint");
|
|
144
|
-
expect(result.lint).toEqual(
|
|
145
|
-
success: true,
|
|
146
|
-
errorCount: 0,
|
|
147
|
-
warningCount: 0,
|
|
148
|
-
formattedOutput: "",
|
|
149
|
-
});
|
|
169
|
+
expect(result.lint).toEqual(mockLintResult);
|
|
150
170
|
});
|
|
151
171
|
});
|
|
152
172
|
|
|
153
|
-
describe("Scenario:
|
|
154
|
-
it("returns lint result
|
|
155
|
-
|
|
156
|
-
mockTscPlugin.getProgram.mockReturnValue(fakeProgram);
|
|
173
|
+
describe("Scenario: js=true lint via tscPlugin.getLintResult()", () => {
|
|
174
|
+
it("returns lint result from tsc plugin when js=true and lint enabled", async () => {
|
|
175
|
+
mockTscPlugin.getLintResult.mockReturnValue(mockLintResult);
|
|
157
176
|
|
|
158
177
|
const result = await workerMethods["build"]({
|
|
159
178
|
name: "my-server",
|
|
@@ -163,12 +182,7 @@ describe("server-build.worker lint integration (Slice 3)", () => {
|
|
|
163
182
|
});
|
|
164
183
|
|
|
165
184
|
expect(result).toHaveProperty("lint");
|
|
166
|
-
expect(result.lint).toEqual(
|
|
167
|
-
success: true,
|
|
168
|
-
errorCount: 0,
|
|
169
|
-
warningCount: 0,
|
|
170
|
-
formattedOutput: "",
|
|
171
|
-
});
|
|
185
|
+
expect(result.lint).toEqual(mockLintResult);
|
|
172
186
|
});
|
|
173
187
|
});
|
|
174
188
|
|