@d-es-ign/stryker-js-core 9.6.0
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/LICENSE +201 -0
- package/README.md +96 -0
- package/bin/stryker +2 -0
- package/bin/stryker.js +6 -0
- package/dist/src/checker/checker-child-process-proxy.d.ts +16 -0
- package/dist/src/checker/checker-child-process-proxy.d.ts.map +1 -0
- package/dist/src/checker/checker-child-process-proxy.js +22 -0
- package/dist/src/checker/checker-child-process-proxy.js.map +1 -0
- package/dist/src/checker/checker-facade.d.ts +9 -0
- package/dist/src/checker/checker-facade.d.ts.map +1 -0
- package/dist/src/checker/checker-facade.js +52 -0
- package/dist/src/checker/checker-facade.js.map +1 -0
- package/dist/src/checker/checker-factory.d.ts +10 -0
- package/dist/src/checker/checker-factory.d.ts.map +1 -0
- package/dist/src/checker/checker-factory.js +10 -0
- package/dist/src/checker/checker-factory.js.map +1 -0
- package/dist/src/checker/checker-resource.d.ts +8 -0
- package/dist/src/checker/checker-resource.d.ts.map +1 -0
- package/dist/src/checker/checker-resource.js +2 -0
- package/dist/src/checker/checker-resource.js.map +1 -0
- package/dist/src/checker/checker-retry-decorator.d.ts +12 -0
- package/dist/src/checker/checker-retry-decorator.d.ts.map +1 -0
- package/dist/src/checker/checker-retry-decorator.js +37 -0
- package/dist/src/checker/checker-retry-decorator.js.map +1 -0
- package/dist/src/checker/checker-worker.d.ts +14 -0
- package/dist/src/checker/checker-worker.d.ts.map +1 -0
- package/dist/src/checker/checker-worker.js +41 -0
- package/dist/src/checker/checker-worker.js.map +1 -0
- package/dist/src/checker/index.d.ts +4 -0
- package/dist/src/checker/index.d.ts.map +1 -0
- package/dist/src/checker/index.js +4 -0
- package/dist/src/checker/index.js.map +1 -0
- package/dist/src/child-proxy/child-process-crashed-error.d.ts +8 -0
- package/dist/src/child-proxy/child-process-crashed-error.d.ts.map +1 -0
- package/dist/src/child-proxy/child-process-crashed-error.js +16 -0
- package/dist/src/child-proxy/child-process-crashed-error.js.map +1 -0
- package/dist/src/child-proxy/child-process-proxy-worker.d.ts +32 -0
- package/dist/src/child-proxy/child-process-proxy-worker.d.ts.map +1 -0
- package/dist/src/child-proxy/child-process-proxy-worker.js +148 -0
- package/dist/src/child-proxy/child-process-proxy-worker.js.map +1 -0
- package/dist/src/child-proxy/child-process-proxy.d.ts +45 -0
- package/dist/src/child-proxy/child-process-proxy.d.ts.map +1 -0
- package/dist/src/child-proxy/child-process-proxy.js +232 -0
- package/dist/src/child-proxy/child-process-proxy.js.map +1 -0
- package/dist/src/child-proxy/id-generator.d.ts +5 -0
- package/dist/src/child-proxy/id-generator.d.ts.map +1 -0
- package/dist/src/child-proxy/id-generator.js +7 -0
- package/dist/src/child-proxy/id-generator.js.map +1 -0
- package/dist/src/child-proxy/message-protocol.d.ts +71 -0
- package/dist/src/child-proxy/message-protocol.d.ts.map +1 -0
- package/dist/src/child-proxy/message-protocol.js +34 -0
- package/dist/src/child-proxy/message-protocol.js.map +1 -0
- package/dist/src/child-proxy/out-of-memory-error.d.ts +5 -0
- package/dist/src/child-proxy/out-of-memory-error.d.ts.map +1 -0
- package/dist/src/child-proxy/out-of-memory-error.js +11 -0
- package/dist/src/child-proxy/out-of-memory-error.js.map +1 -0
- package/dist/src/concurrent/concurrency-token-provider.d.ts +20 -0
- package/dist/src/concurrent/concurrency-token-provider.d.ts.map +1 -0
- package/dist/src/concurrent/concurrency-token-provider.js +68 -0
- package/dist/src/concurrent/concurrency-token-provider.js.map +1 -0
- package/dist/src/concurrent/index.d.ts +4 -0
- package/dist/src/concurrent/index.d.ts.map +1 -0
- package/dist/src/concurrent/index.js +4 -0
- package/dist/src/concurrent/index.js.map +1 -0
- package/dist/src/concurrent/pool.d.ts +49 -0
- package/dist/src/concurrent/pool.d.ts.map +1 -0
- package/dist/src/concurrent/pool.js +137 -0
- package/dist/src/concurrent/pool.js.map +1 -0
- package/dist/src/concurrent/resource-decorator.d.ts +14 -0
- package/dist/src/concurrent/resource-decorator.d.ts.map +1 -0
- package/dist/src/concurrent/resource-decorator.js +24 -0
- package/dist/src/concurrent/resource-decorator.js.map +1 -0
- package/dist/src/config/config-file-formats.d.ts +6 -0
- package/dist/src/config/config-file-formats.d.ts.map +1 -0
- package/dist/src/config/config-file-formats.js +23 -0
- package/dist/src/config/config-file-formats.js.map +1 -0
- package/dist/src/config/config-reader.d.ts +23 -0
- package/dist/src/config/config-reader.d.ts.map +1 -0
- package/dist/src/config/config-reader.js +141 -0
- package/dist/src/config/config-reader.js.map +1 -0
- package/dist/src/config/file-matcher.d.ts +10 -0
- package/dist/src/config/file-matcher.d.ts.map +1 -0
- package/dist/src/config/file-matcher.js +31 -0
- package/dist/src/config/file-matcher.js.map +1 -0
- package/dist/src/config/index.d.ts +6 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +6 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/meta-schema-builder.d.ts +10 -0
- package/dist/src/config/meta-schema-builder.d.ts.map +1 -0
- package/dist/src/config/meta-schema-builder.js +30 -0
- package/dist/src/config/meta-schema-builder.js.map +1 -0
- package/dist/src/config/options-validator.d.ts +28 -0
- package/dist/src/config/options-validator.d.ts.map +1 -0
- package/dist/src/config/options-validator.js +213 -0
- package/dist/src/config/options-validator.js.map +1 -0
- package/dist/src/config/validation-errors.d.ts +7 -0
- package/dist/src/config/validation-errors.d.ts.map +1 -0
- package/dist/src/config/validation-errors.js +154 -0
- package/dist/src/config/validation-errors.js.map +1 -0
- package/dist/src/di/core-tokens.d.ts +40 -0
- package/dist/src/di/core-tokens.d.ts.map +1 -0
- package/dist/src/di/core-tokens.js +40 -0
- package/dist/src/di/core-tokens.js.map +1 -0
- package/dist/src/di/index.d.ts +4 -0
- package/dist/src/di/index.d.ts.map +1 -0
- package/dist/src/di/index.js +4 -0
- package/dist/src/di/index.js.map +1 -0
- package/dist/src/di/plugin-creator.d.ts +10 -0
- package/dist/src/di/plugin-creator.d.ts.map +1 -0
- package/dist/src/di/plugin-creator.js +51 -0
- package/dist/src/di/plugin-creator.js.map +1 -0
- package/dist/src/di/plugin-loader.d.ts +41 -0
- package/dist/src/di/plugin-loader.d.ts.map +1 -0
- package/dist/src/di/plugin-loader.js +153 -0
- package/dist/src/di/plugin-loader.js.map +1 -0
- package/dist/src/errors.d.ts +5 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +13 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/fs/file-system.d.ts +19 -0
- package/dist/src/fs/file-system.d.ts.map +1 -0
- package/dist/src/fs/file-system.js +52 -0
- package/dist/src/fs/file-system.js.map +1 -0
- package/dist/src/fs/index.d.ts +5 -0
- package/dist/src/fs/index.d.ts.map +1 -0
- package/dist/src/fs/index.js +5 -0
- package/dist/src/fs/index.js.map +1 -0
- package/dist/src/fs/project-file.d.ts +26 -0
- package/dist/src/fs/project-file.d.ts.map +1 -0
- package/dist/src/fs/project-file.js +87 -0
- package/dist/src/fs/project-file.js.map +1 -0
- package/dist/src/fs/project-reader.d.ts +51 -0
- package/dist/src/fs/project-reader.d.ts.map +1 -0
- package/dist/src/fs/project-reader.js +335 -0
- package/dist/src/fs/project-reader.js.map +1 -0
- package/dist/src/fs/project.d.ts +22 -0
- package/dist/src/fs/project.d.ts.map +1 -0
- package/dist/src/fs/project.js +65 -0
- package/dist/src/fs/project.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/initializer/custom-initializers/angular-initializer.d.ts +17 -0
- package/dist/src/initializer/custom-initializers/angular-initializer.d.ts.map +1 -0
- package/dist/src/initializer/custom-initializers/angular-initializer.js +74 -0
- package/dist/src/initializer/custom-initializers/angular-initializer.js.map +1 -0
- package/dist/src/initializer/custom-initializers/custom-initializer.d.ts +13 -0
- package/dist/src/initializer/custom-initializers/custom-initializer.d.ts.map +1 -0
- package/dist/src/initializer/custom-initializers/custom-initializer.js +2 -0
- package/dist/src/initializer/custom-initializers/custom-initializer.js.map +1 -0
- package/dist/src/initializer/custom-initializers/index.d.ts +14 -0
- package/dist/src/initializer/custom-initializers/index.d.ts.map +1 -0
- package/dist/src/initializer/custom-initializers/index.js +16 -0
- package/dist/src/initializer/custom-initializers/index.js.map +1 -0
- package/dist/src/initializer/custom-initializers/react-initializer.d.ts +12 -0
- package/dist/src/initializer/custom-initializers/react-initializer.d.ts.map +1 -0
- package/dist/src/initializer/custom-initializers/react-initializer.js +25 -0
- package/dist/src/initializer/custom-initializers/react-initializer.js.map +1 -0
- package/dist/src/initializer/custom-initializers/svelte-initializer.d.ts +6 -0
- package/dist/src/initializer/custom-initializers/svelte-initializer.d.ts.map +1 -0
- package/dist/src/initializer/custom-initializers/svelte-initializer.js +33 -0
- package/dist/src/initializer/custom-initializers/svelte-initializer.js.map +1 -0
- package/dist/src/initializer/custom-initializers/vue-js-initializer.d.ts +11 -0
- package/dist/src/initializer/custom-initializers/vue-js-initializer.d.ts.map +1 -0
- package/dist/src/initializer/custom-initializers/vue-js-initializer.js +20 -0
- package/dist/src/initializer/custom-initializers/vue-js-initializer.js.map +1 -0
- package/dist/src/initializer/gitignore-writer.d.ts +7 -0
- package/dist/src/initializer/gitignore-writer.d.ts.map +1 -0
- package/dist/src/initializer/gitignore-writer.js +28 -0
- package/dist/src/initializer/gitignore-writer.js.map +1 -0
- package/dist/src/initializer/index.d.ts +6 -0
- package/dist/src/initializer/index.d.ts.map +1 -0
- package/dist/src/initializer/index.js +29 -0
- package/dist/src/initializer/index.js.map +1 -0
- package/dist/src/initializer/initializer-tokens.d.ts +9 -0
- package/dist/src/initializer/initializer-tokens.d.ts.map +1 -0
- package/dist/src/initializer/initializer-tokens.js +9 -0
- package/dist/src/initializer/initializer-tokens.js.map +1 -0
- package/dist/src/initializer/inquire.d.ts +12 -0
- package/dist/src/initializer/inquire.d.ts.map +1 -0
- package/dist/src/initializer/inquire.js +12 -0
- package/dist/src/initializer/inquire.js.map +1 -0
- package/dist/src/initializer/npm-client.d.ts +22 -0
- package/dist/src/initializer/npm-client.d.ts.map +1 -0
- package/dist/src/initializer/npm-client.js +65 -0
- package/dist/src/initializer/npm-client.js.map +1 -0
- package/dist/src/initializer/npm-registry.d.ts +13 -0
- package/dist/src/initializer/npm-registry.d.ts.map +1 -0
- package/dist/src/initializer/npm-registry.js +36 -0
- package/dist/src/initializer/npm-registry.js.map +1 -0
- package/dist/src/initializer/package-info.d.ts +10 -0
- package/dist/src/initializer/package-info.d.ts.map +1 -0
- package/dist/src/initializer/package-info.js +2 -0
- package/dist/src/initializer/package-info.js.map +1 -0
- package/dist/src/initializer/prompt-option.d.ts +6 -0
- package/dist/src/initializer/prompt-option.d.ts.map +1 -0
- package/dist/src/initializer/prompt-option.js +2 -0
- package/dist/src/initializer/prompt-option.js.map +1 -0
- package/dist/src/initializer/stryker-config-writer.d.ts +27 -0
- package/dist/src/initializer/stryker-config-writer.d.ts.map +1 -0
- package/dist/src/initializer/stryker-config-writer.js +106 -0
- package/dist/src/initializer/stryker-config-writer.js.map +1 -0
- package/dist/src/initializer/stryker-initializer.d.ts +45 -0
- package/dist/src/initializer/stryker-initializer.d.ts.map +1 -0
- package/dist/src/initializer/stryker-initializer.js +184 -0
- package/dist/src/initializer/stryker-initializer.js.map +1 -0
- package/dist/src/initializer/stryker-inquirer.d.ts +15 -0
- package/dist/src/initializer/stryker-inquirer.d.ts.map +1 -0
- package/dist/src/initializer/stryker-inquirer.js +72 -0
- package/dist/src/initializer/stryker-inquirer.js.map +1 -0
- package/dist/src/logging/index.d.ts +6 -0
- package/dist/src/logging/index.d.ts.map +1 -0
- package/dist/src/logging/index.js +5 -0
- package/dist/src/logging/index.js.map +1 -0
- package/dist/src/logging/logger-impl.d.ts +19 -0
- package/dist/src/logging/logger-impl.d.ts.map +1 -0
- package/dist/src/logging/logger-impl.js +64 -0
- package/dist/src/logging/logger-impl.js.map +1 -0
- package/dist/src/logging/logging-backend.d.ts +22 -0
- package/dist/src/logging/logging-backend.d.ts.map +1 -0
- package/dist/src/logging/logging-backend.js +65 -0
- package/dist/src/logging/logging-backend.js.map +1 -0
- package/dist/src/logging/logging-client.d.ts +16 -0
- package/dist/src/logging/logging-client.d.ts.map +1 -0
- package/dist/src/logging/logging-client.js +44 -0
- package/dist/src/logging/logging-client.js.map +1 -0
- package/dist/src/logging/logging-event.d.ts +23 -0
- package/dist/src/logging/logging-event.d.ts.map +1 -0
- package/dist/src/logging/logging-event.js +63 -0
- package/dist/src/logging/logging-event.js.map +1 -0
- package/dist/src/logging/logging-server.d.ts +15 -0
- package/dist/src/logging/logging-server.d.ts.map +1 -0
- package/dist/src/logging/logging-server.js +43 -0
- package/dist/src/logging/logging-server.js.map +1 -0
- package/dist/src/logging/logging-sink.d.ts +7 -0
- package/dist/src/logging/logging-sink.d.ts.map +1 -0
- package/dist/src/logging/logging-sink.js +2 -0
- package/dist/src/logging/logging-sink.js.map +1 -0
- package/dist/src/logging/priority.d.ts +12 -0
- package/dist/src/logging/priority.d.ts.map +1 -0
- package/dist/src/logging/priority.js +13 -0
- package/dist/src/logging/priority.js.map +1 -0
- package/dist/src/logging/provide-logging.d.ts +30 -0
- package/dist/src/logging/provide-logging.d.ts.map +1 -0
- package/dist/src/logging/provide-logging.js +45 -0
- package/dist/src/logging/provide-logging.js.map +1 -0
- package/dist/src/mutants/diff-statistics-collector.d.ts +14 -0
- package/dist/src/mutants/diff-statistics-collector.d.ts.map +1 -0
- package/dist/src/mutants/diff-statistics-collector.js +40 -0
- package/dist/src/mutants/diff-statistics-collector.js.map +1 -0
- package/dist/src/mutants/incremental-differ.d.ts +39 -0
- package/dist/src/mutants/incremental-differ.d.ts.map +1 -0
- package/dist/src/mutants/incremental-differ.js +547 -0
- package/dist/src/mutants/incremental-differ.js.map +1 -0
- package/dist/src/mutants/index.d.ts +4 -0
- package/dist/src/mutants/index.d.ts.map +1 -0
- package/dist/src/mutants/index.js +4 -0
- package/dist/src/mutants/index.js.map +1 -0
- package/dist/src/mutants/mutant-test-planner.d.ts +36 -0
- package/dist/src/mutants/mutant-test-planner.d.ts.map +1 -0
- package/dist/src/mutants/mutant-test-planner.js +237 -0
- package/dist/src/mutants/mutant-test-planner.js.map +1 -0
- package/dist/src/mutants/test-coverage.d.ts +22 -0
- package/dist/src/mutants/test-coverage.d.ts.map +1 -0
- package/dist/src/mutants/test-coverage.js +87 -0
- package/dist/src/mutants/test-coverage.js.map +1 -0
- package/dist/src/process/1-prepare-executor.d.ts +22 -0
- package/dist/src/process/1-prepare-executor.d.ts.map +1 -0
- package/dist/src/process/1-prepare-executor.js +86 -0
- package/dist/src/process/1-prepare-executor.js.map +1 -0
- package/dist/src/process/2-mutant-instrumenter-executor.d.ts +39 -0
- package/dist/src/process/2-mutant-instrumenter-executor.d.ts.map +1 -0
- package/dist/src/process/2-mutant-instrumenter-executor.js +58 -0
- package/dist/src/process/2-mutant-instrumenter-executor.js.map +1 -0
- package/dist/src/process/3-dry-run-executor.d.ts +50 -0
- package/dist/src/process/3-dry-run-executor.d.ts.map +1 -0
- package/dist/src/process/3-dry-run-executor.js +164 -0
- package/dist/src/process/3-dry-run-executor.js.map +1 -0
- package/dist/src/process/4-mutation-test-executor.d.ts +56 -0
- package/dist/src/process/4-mutation-test-executor.d.ts.map +1 -0
- package/dist/src/process/4-mutation-test-executor.js +152 -0
- package/dist/src/process/4-mutation-test-executor.js.map +1 -0
- package/dist/src/process/index.d.ts +5 -0
- package/dist/src/process/index.d.ts.map +1 -0
- package/dist/src/process/index.js +5 -0
- package/dist/src/process/index.js.map +1 -0
- package/dist/src/reporters/broadcast-reporter.d.ts +25 -0
- package/dist/src/reporters/broadcast-reporter.d.ts.map +1 -0
- package/dist/src/reporters/broadcast-reporter.js +74 -0
- package/dist/src/reporters/broadcast-reporter.js.map +1 -0
- package/dist/src/reporters/ci/circle-provider.d.ts +11 -0
- package/dist/src/reporters/ci/circle-provider.d.ts.map +1 -0
- package/dist/src/reporters/ci/circle-provider.js +33 -0
- package/dist/src/reporters/ci/circle-provider.js.map +1 -0
- package/dist/src/reporters/ci/github-actions-provider.d.ts +9 -0
- package/dist/src/reporters/ci/github-actions-provider.d.ts.map +1 -0
- package/dist/src/reporters/ci/github-actions-provider.js +21 -0
- package/dist/src/reporters/ci/github-actions-provider.js.map +1 -0
- package/dist/src/reporters/ci/provider.d.ts +22 -0
- package/dist/src/reporters/ci/provider.d.ts.map +1 -0
- package/dist/src/reporters/ci/provider.js +24 -0
- package/dist/src/reporters/ci/provider.js.map +1 -0
- package/dist/src/reporters/ci/travis-provider.d.ts +9 -0
- package/dist/src/reporters/ci/travis-provider.d.ts.map +1 -0
- package/dist/src/reporters/ci/travis-provider.js +19 -0
- package/dist/src/reporters/ci/travis-provider.js.map +1 -0
- package/dist/src/reporters/clear-text-reporter.d.ts +23 -0
- package/dist/src/reporters/clear-text-reporter.d.ts.map +1 -0
- package/dist/src/reporters/clear-text-reporter.js +174 -0
- package/dist/src/reporters/clear-text-reporter.js.map +1 -0
- package/dist/src/reporters/clear-text-score-table.d.ts +22 -0
- package/dist/src/reporters/clear-text-score-table.d.ts.map +1 -0
- package/dist/src/reporters/clear-text-score-table.js +191 -0
- package/dist/src/reporters/clear-text-score-table.js.map +1 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter-client.d.ts +19 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter-client.d.ts.map +1 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter-client.js +54 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter-client.js.map +1 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter.d.ts +21 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter.d.ts.map +1 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter.js +62 -0
- package/dist/src/reporters/dashboard-reporter/dashboard-reporter.js.map +1 -0
- package/dist/src/reporters/dashboard-reporter/index.d.ts +7 -0
- package/dist/src/reporters/dashboard-reporter/index.d.ts.map +1 -0
- package/dist/src/reporters/dashboard-reporter/index.js +15 -0
- package/dist/src/reporters/dashboard-reporter/index.js.map +1 -0
- package/dist/src/reporters/dashboard-reporter/report.d.ts +6 -0
- package/dist/src/reporters/dashboard-reporter/report.d.ts.map +1 -0
- package/dist/src/reporters/dashboard-reporter/report.js +2 -0
- package/dist/src/reporters/dashboard-reporter/report.js.map +1 -0
- package/dist/src/reporters/dashboard-reporter/tokens.d.ts +6 -0
- package/dist/src/reporters/dashboard-reporter/tokens.d.ts.map +1 -0
- package/dist/src/reporters/dashboard-reporter/tokens.js +6 -0
- package/dist/src/reporters/dashboard-reporter/tokens.js.map +1 -0
- package/dist/src/reporters/dots-reporter.d.ts +7 -0
- package/dist/src/reporters/dots-reporter.d.ts.map +1 -0
- package/dist/src/reporters/dots-reporter.js +29 -0
- package/dist/src/reporters/dots-reporter.js.map +1 -0
- package/dist/src/reporters/event-recorder-reporter.d.ts +22 -0
- package/dist/src/reporters/event-recorder-reporter.d.ts.map +1 -0
- package/dist/src/reporters/event-recorder-reporter.js +53 -0
- package/dist/src/reporters/event-recorder-reporter.js.map +1 -0
- package/dist/src/reporters/html-reporter.d.ts +14 -0
- package/dist/src/reporters/html-reporter.d.ts.map +1 -0
- package/dist/src/reporters/html-reporter.js +65 -0
- package/dist/src/reporters/html-reporter.js.map +1 -0
- package/dist/src/reporters/index.d.ts +6 -0
- package/dist/src/reporters/index.d.ts.map +1 -0
- package/dist/src/reporters/index.js +24 -0
- package/dist/src/reporters/index.js.map +1 -0
- package/dist/src/reporters/json-reporter.d.ts +15 -0
- package/dist/src/reporters/json-reporter.d.ts.map +1 -0
- package/dist/src/reporters/json-reporter.js +29 -0
- package/dist/src/reporters/json-reporter.js.map +1 -0
- package/dist/src/reporters/mutation-test-report-helper.d.ts +40 -0
- package/dist/src/reporters/mutation-test-report-helper.d.ts.map +1 -0
- package/dist/src/reporters/mutation-test-report-helper.js +298 -0
- package/dist/src/reporters/mutation-test-report-helper.js.map +1 -0
- package/dist/src/reporters/mutation-timings-reporter.d.ts +14 -0
- package/dist/src/reporters/mutation-timings-reporter.d.ts.map +1 -0
- package/dist/src/reporters/mutation-timings-reporter.js +49 -0
- package/dist/src/reporters/mutation-timings-reporter.js.map +1 -0
- package/dist/src/reporters/progress-append-only-reporter.d.ts +10 -0
- package/dist/src/reporters/progress-append-only-reporter.d.ts.map +1 -0
- package/dist/src/reporters/progress-append-only-reporter.js +25 -0
- package/dist/src/reporters/progress-append-only-reporter.js.map +1 -0
- package/dist/src/reporters/progress-bar.d.ts +8 -0
- package/dist/src/reporters/progress-bar.d.ts.map +1 -0
- package/dist/src/reporters/progress-bar.js +6 -0
- package/dist/src/reporters/progress-bar.js.map +1 -0
- package/dist/src/reporters/progress-keeper.d.ts +27 -0
- package/dist/src/reporters/progress-keeper.d.ts.map +1 -0
- package/dist/src/reporters/progress-keeper.js +77 -0
- package/dist/src/reporters/progress-keeper.js.map +1 -0
- package/dist/src/reporters/progress-reporter.d.ts +11 -0
- package/dist/src/reporters/progress-reporter.d.ts.map +1 -0
- package/dist/src/reporters/progress-reporter.js +40 -0
- package/dist/src/reporters/progress-reporter.js.map +1 -0
- package/dist/src/reporters/reporter-util.d.ts +5 -0
- package/dist/src/reporters/reporter-util.d.ts.map +1 -0
- package/dist/src/reporters/reporter-util.js +19 -0
- package/dist/src/reporters/reporter-util.js.map +1 -0
- package/dist/src/reporters/strict-reporter.d.ts +3 -0
- package/dist/src/reporters/strict-reporter.d.ts.map +1 -0
- package/dist/src/reporters/strict-reporter.js +2 -0
- package/dist/src/reporters/strict-reporter.js.map +1 -0
- package/dist/src/sandbox/create-preprocessor.d.ts +7 -0
- package/dist/src/sandbox/create-preprocessor.d.ts.map +1 -0
- package/dist/src/sandbox/create-preprocessor.js +16 -0
- package/dist/src/sandbox/create-preprocessor.js.map +1 -0
- package/dist/src/sandbox/disable-type-checks-preprocessor.d.ts +18 -0
- package/dist/src/sandbox/disable-type-checks-preprocessor.d.ts.map +1 -0
- package/dist/src/sandbox/disable-type-checks-preprocessor.js +43 -0
- package/dist/src/sandbox/disable-type-checks-preprocessor.js.map +1 -0
- package/dist/src/sandbox/file-preprocessor.d.ts +10 -0
- package/dist/src/sandbox/file-preprocessor.d.ts.map +1 -0
- package/dist/src/sandbox/file-preprocessor.js +2 -0
- package/dist/src/sandbox/file-preprocessor.js.map +1 -0
- package/dist/src/sandbox/index.d.ts +4 -0
- package/dist/src/sandbox/index.d.ts.map +1 -0
- package/dist/src/sandbox/index.js +3 -0
- package/dist/src/sandbox/index.js.map +1 -0
- package/dist/src/sandbox/multi-preprocessor.d.ts +8 -0
- package/dist/src/sandbox/multi-preprocessor.d.ts.map +1 -0
- package/dist/src/sandbox/multi-preprocessor.js +12 -0
- package/dist/src/sandbox/multi-preprocessor.js.map +1 -0
- package/dist/src/sandbox/sandbox.d.ts +43 -0
- package/dist/src/sandbox/sandbox.d.ts.map +1 -0
- package/dist/src/sandbox/sandbox.js +134 -0
- package/dist/src/sandbox/sandbox.js.map +1 -0
- package/dist/src/sandbox/ts-config-preprocessor.d.ts +46 -0
- package/dist/src/sandbox/ts-config-preprocessor.d.ts.map +1 -0
- package/dist/src/sandbox/ts-config-preprocessor.js +112 -0
- package/dist/src/sandbox/ts-config-preprocessor.js.map +1 -0
- package/dist/src/stryker-cli.d.ts +15 -0
- package/dist/src/stryker-cli.d.ts.map +1 -0
- package/dist/src/stryker-cli.js +168 -0
- package/dist/src/stryker-cli.js.map +1 -0
- package/dist/src/stryker-package.d.ts +5 -0
- package/dist/src/stryker-package.d.ts.map +1 -0
- package/dist/src/stryker-package.js +7 -0
- package/dist/src/stryker-package.js.map +1 -0
- package/dist/src/stryker-server.d.ts +40 -0
- package/dist/src/stryker-server.d.ts.map +1 -0
- package/dist/src/stryker-server.js +234 -0
- package/dist/src/stryker-server.js.map +1 -0
- package/dist/src/stryker.d.ts +31 -0
- package/dist/src/stryker.d.ts.map +1 -0
- package/dist/src/stryker.js +86 -0
- package/dist/src/stryker.js.map +1 -0
- package/dist/src/test-runner/child-process-test-runner-proxy.d.ts +19 -0
- package/dist/src/test-runner/child-process-test-runner-proxy.d.ts.map +1 -0
- package/dist/src/test-runner/child-process-test-runner-proxy.js +45 -0
- package/dist/src/test-runner/child-process-test-runner-proxy.js.map +1 -0
- package/dist/src/test-runner/child-process-test-runner-worker.d.ts +14 -0
- package/dist/src/test-runner/child-process-test-runner-worker.d.ts.map +1 -0
- package/dist/src/test-runner/child-process-test-runner-worker.js +45 -0
- package/dist/src/test-runner/child-process-test-runner-worker.js.map +1 -0
- package/dist/src/test-runner/command-test-runner.d.ts +31 -0
- package/dist/src/test-runner/command-test-runner.d.ts.map +1 -0
- package/dist/src/test-runner/command-test-runner.js +144 -0
- package/dist/src/test-runner/command-test-runner.js.map +1 -0
- package/dist/src/test-runner/index.d.ts +11 -0
- package/dist/src/test-runner/index.d.ts.map +1 -0
- package/dist/src/test-runner/index.js +18 -0
- package/dist/src/test-runner/index.js.map +1 -0
- package/dist/src/test-runner/max-test-runner-reuse-decorator.d.ts +14 -0
- package/dist/src/test-runner/max-test-runner-reuse-decorator.d.ts.map +1 -0
- package/dist/src/test-runner/max-test-runner-reuse-decorator.js +25 -0
- package/dist/src/test-runner/max-test-runner-reuse-decorator.js.map +1 -0
- package/dist/src/test-runner/reload-environment-decorator.d.ts +11 -0
- package/dist/src/test-runner/reload-environment-decorator.d.ts.map +1 -0
- package/dist/src/test-runner/reload-environment-decorator.js +56 -0
- package/dist/src/test-runner/reload-environment-decorator.js.map +1 -0
- package/dist/src/test-runner/retry-rejected-decorator.d.ts +15 -0
- package/dist/src/test-runner/retry-rejected-decorator.d.ts.map +1 -0
- package/dist/src/test-runner/retry-rejected-decorator.js +59 -0
- package/dist/src/test-runner/retry-rejected-decorator.js.map +1 -0
- package/dist/src/test-runner/test-runner-decorator.d.ts +8 -0
- package/dist/src/test-runner/test-runner-decorator.d.ts.map +1 -0
- package/dist/src/test-runner/test-runner-decorator.js +13 -0
- package/dist/src/test-runner/test-runner-decorator.js.map +1 -0
- package/dist/src/test-runner/timeout-decorator.d.ts +15 -0
- package/dist/src/test-runner/timeout-decorator.d.ts.map +1 -0
- package/dist/src/test-runner/timeout-decorator.js +51 -0
- package/dist/src/test-runner/timeout-decorator.js.map +1 -0
- package/dist/src/unexpected-exit-handler.d.ts +13 -0
- package/dist/src/unexpected-exit-handler.d.ts.map +1 -0
- package/dist/src/unexpected-exit-handler.js +28 -0
- package/dist/src/unexpected-exit-handler.js.map +1 -0
- package/dist/src/utils/file-utils.d.ts +30 -0
- package/dist/src/utils/file-utils.d.ts.map +1 -0
- package/dist/src/utils/file-utils.js +101 -0
- package/dist/src/utils/file-utils.js.map +1 -0
- package/dist/src/utils/index.d.ts +7 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +7 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/json-rpc-event-deserializer.d.ts +5 -0
- package/dist/src/utils/json-rpc-event-deserializer.d.ts.map +1 -0
- package/dist/src/utils/json-rpc-event-deserializer.js +42 -0
- package/dist/src/utils/json-rpc-event-deserializer.js.map +1 -0
- package/dist/src/utils/object-utils.d.ts +37 -0
- package/dist/src/utils/object-utils.d.ts.map +1 -0
- package/dist/src/utils/object-utils.js +91 -0
- package/dist/src/utils/object-utils.js.map +1 -0
- package/dist/src/utils/string-builder.d.ts +9 -0
- package/dist/src/utils/string-builder.d.ts.map +1 -0
- package/dist/src/utils/string-builder.js +26 -0
- package/dist/src/utils/string-builder.js.map +1 -0
- package/dist/src/utils/string-utils.d.ts +12 -0
- package/dist/src/utils/string-utils.d.ts.map +1 -0
- package/dist/src/utils/string-utils.js +54 -0
- package/dist/src/utils/string-utils.js.map +1 -0
- package/dist/src/utils/temporary-directory.d.ts +18 -0
- package/dist/src/utils/temporary-directory.d.ts.map +1 -0
- package/dist/src/utils/temporary-directory.js +63 -0
- package/dist/src/utils/temporary-directory.js.map +1 -0
- package/dist/src/utils/timer.d.ts +14 -0
- package/dist/src/utils/timer.d.ts.map +1 -0
- package/dist/src/utils/timer.js +53 -0
- package/dist/src/utils/timer.js.map +1 -0
- package/package.json +106 -0
- package/schema/stryker-schema.json +855 -0
- package/src/checker/checker-child-process-proxy.ts +67 -0
- package/src/checker/checker-facade.ts +90 -0
- package/src/checker/checker-factory.ts +46 -0
- package/src/checker/checker-resource.ts +12 -0
- package/src/checker/checker-retry-decorator.ts +57 -0
- package/src/checker/checker-worker.ts +62 -0
- package/src/checker/index.ts +3 -0
- package/src/child-proxy/child-process-crashed-error.ts +16 -0
- package/src/child-proxy/child-process-proxy-worker.ts +203 -0
- package/src/child-proxy/child-process-proxy.ts +353 -0
- package/src/child-proxy/id-generator.ts +6 -0
- package/src/child-proxy/message-protocol.ts +87 -0
- package/src/child-proxy/out-of-memory-error.ts +11 -0
- package/src/concurrent/concurrency-token-provider.ts +106 -0
- package/src/concurrent/index.ts +3 -0
- package/src/concurrent/pool.ts +209 -0
- package/src/concurrent/resource-decorator.ts +28 -0
- package/src/config/config-file-formats.ts +31 -0
- package/src/config/config-reader.ts +193 -0
- package/src/config/file-matcher.ts +36 -0
- package/src/config/index.ts +5 -0
- package/src/config/meta-schema-builder.ts +50 -0
- package/src/config/options-validator.ts +317 -0
- package/src/config/validation-errors.ts +192 -0
- package/src/di/core-tokens.ts +39 -0
- package/src/di/index.ts +4 -0
- package/src/di/plugin-creator.ts +102 -0
- package/src/di/plugin-loader.ts +245 -0
- package/src/errors.ts +12 -0
- package/src/fs/file-system.ts +63 -0
- package/src/fs/index.ts +4 -0
- package/src/fs/project-file.ts +100 -0
- package/src/fs/project-reader.ts +493 -0
- package/src/fs/project.ts +98 -0
- package/src/index.ts +7 -0
- package/src/initializer/custom-initializers/angular-initializer.ts +95 -0
- package/src/initializer/custom-initializers/custom-initializer.ts +14 -0
- package/src/initializer/custom-initializers/index.ts +31 -0
- package/src/initializer/custom-initializers/react-initializer.ts +35 -0
- package/src/initializer/custom-initializers/svelte-initializer.ts +40 -0
- package/src/initializer/custom-initializers/vue-js-initializer.ts +30 -0
- package/src/initializer/gitignore-writer.ts +33 -0
- package/src/initializer/index.ts +35 -0
- package/src/initializer/initializer-tokens.ts +8 -0
- package/src/initializer/inquire.ts +17 -0
- package/src/initializer/npm-client.ts +103 -0
- package/src/initializer/npm-registry.ts +48 -0
- package/src/initializer/package-info.ts +10 -0
- package/src/initializer/prompt-option.ts +6 -0
- package/src/initializer/stryker-config-writer.ts +158 -0
- package/src/initializer/stryker-initializer.ts +278 -0
- package/src/initializer/stryker-inquirer.ts +101 -0
- package/src/logging/index.ts +5 -0
- package/src/logging/logger-impl.ts +81 -0
- package/src/logging/logging-backend.ts +90 -0
- package/src/logging/logging-client.ts +56 -0
- package/src/logging/logging-event.ts +94 -0
- package/src/logging/logging-server.ts +56 -0
- package/src/logging/logging-sink.ts +7 -0
- package/src/logging/priority.ts +15 -0
- package/src/logging/provide-logging.ts +70 -0
- package/src/mutants/diff-statistics-collector.ts +47 -0
- package/src/mutants/incremental-differ.ts +771 -0
- package/src/mutants/index.ts +3 -0
- package/src/mutants/mutant-test-planner.ts +357 -0
- package/src/mutants/test-coverage.ts +125 -0
- package/src/process/1-prepare-executor.ts +133 -0
- package/src/process/2-mutant-instrumenter-executor.ts +122 -0
- package/src/process/3-dry-run-executor.ts +262 -0
- package/src/process/4-mutation-test-executor.ts +272 -0
- package/src/process/index.ts +4 -0
- package/src/reporters/broadcast-reporter.ts +129 -0
- package/src/reporters/ci/circle-provider.ts +50 -0
- package/src/reporters/ci/github-actions-provider.ts +22 -0
- package/src/reporters/ci/provider.ts +42 -0
- package/src/reporters/ci/travis-provider.ts +24 -0
- package/src/reporters/clear-text-reporter.ts +245 -0
- package/src/reporters/clear-text-score-table.ts +305 -0
- package/src/reporters/dashboard-reporter/dashboard-reporter-client.ts +89 -0
- package/src/reporters/dashboard-reporter/dashboard-reporter.ts +97 -0
- package/src/reporters/dashboard-reporter/index.ts +30 -0
- package/src/reporters/dashboard-reporter/report.ts +6 -0
- package/src/reporters/dashboard-reporter/tokens.ts +5 -0
- package/src/reporters/dots-reporter.ts +33 -0
- package/src/reporters/event-recorder-reporter.ts +88 -0
- package/src/reporters/html-reporter.ts +87 -0
- package/src/reporters/index.ts +48 -0
- package/src/reporters/json-reporter.ts +45 -0
- package/src/reporters/mutation-test-report-helper.ts +425 -0
- package/src/reporters/mutation-timings-reporter.ts +78 -0
- package/src/reporters/progress-append-only-reporter.ts +36 -0
- package/src/reporters/progress-bar.ts +6 -0
- package/src/reporters/progress-keeper.ts +113 -0
- package/src/reporters/progress-reporter.ts +62 -0
- package/src/reporters/reporter-util.ts +20 -0
- package/src/reporters/strict-reporter.ts +3 -0
- package/src/sandbox/create-preprocessor.ts +27 -0
- package/src/sandbox/disable-type-checks-preprocessor.ts +70 -0
- package/src/sandbox/file-preprocessor.ts +10 -0
- package/src/sandbox/index.ts +3 -0
- package/src/sandbox/multi-preprocessor.ts +13 -0
- package/src/sandbox/sandbox.ts +198 -0
- package/src/sandbox/ts-config-preprocessor.ts +168 -0
- package/src/stryker-cli.ts +363 -0
- package/src/stryker-package.ts +19 -0
- package/src/stryker-server.ts +334 -0
- package/src/stryker.ts +126 -0
- package/src/test-runner/child-process-test-runner-proxy.ts +94 -0
- package/src/test-runner/child-process-test-runner-worker.ts +66 -0
- package/src/test-runner/command-test-runner.ts +190 -0
- package/src/test-runner/index.ts +74 -0
- package/src/test-runner/max-test-runner-reuse-decorator.ts +41 -0
- package/src/test-runner/reload-environment-decorator.ts +72 -0
- package/src/test-runner/retry-rejected-decorator.ts +79 -0
- package/src/test-runner/test-runner-decorator.ts +22 -0
- package/src/test-runner/timeout-decorator.ts +71 -0
- package/src/unexpected-exit-handler.ts +36 -0
- package/src/utils/file-utils.ts +113 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/json-rpc-event-deserializer.ts +48 -0
- package/src/utils/object-utils.ts +106 -0
- package/src/utils/string-builder.ts +30 -0
- package/src/utils/string-utils.ts +61 -0
- package/src/utils/temporary-directory.ts +83 -0
- package/src/utils/timer.ts +58 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import { Minimatch } from 'minimatch';
|
|
5
|
+
import ajvModule, { ValidateFunction } from 'ajv';
|
|
6
|
+
import { StrykerOptions, strykerCoreSchema } from '@stryker-mutator/api/core';
|
|
7
|
+
import { tokens, commonTokens } from '@stryker-mutator/api/plugin';
|
|
8
|
+
import {
|
|
9
|
+
noopLogger,
|
|
10
|
+
findUnserializables,
|
|
11
|
+
Immutable,
|
|
12
|
+
deepFreeze,
|
|
13
|
+
} from '@stryker-mutator/util';
|
|
14
|
+
import { Logger } from '@stryker-mutator/api/logging';
|
|
15
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
16
|
+
|
|
17
|
+
import { coreTokens } from '../di/index.js';
|
|
18
|
+
import { ConfigError } from '../errors.js';
|
|
19
|
+
import { objectUtils, optionsPath } from '../utils/index.js';
|
|
20
|
+
import { CommandTestRunner } from '../test-runner/command-test-runner.js';
|
|
21
|
+
import { IGNORE_PATTERN_CHARACTER, MUTATION_RANGE_REGEX } from '../fs/index.js';
|
|
22
|
+
|
|
23
|
+
import { describeErrors } from './validation-errors.js';
|
|
24
|
+
|
|
25
|
+
const Ajv = ajvModule.default;
|
|
26
|
+
|
|
27
|
+
const ajv = new Ajv({
|
|
28
|
+
useDefaults: true,
|
|
29
|
+
allErrors: true,
|
|
30
|
+
jsPropertySyntax: true,
|
|
31
|
+
verbose: true,
|
|
32
|
+
logger: false,
|
|
33
|
+
strict: false,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export class OptionsValidator {
|
|
37
|
+
private readonly validateFn: ValidateFunction;
|
|
38
|
+
|
|
39
|
+
public static readonly inject = tokens(
|
|
40
|
+
coreTokens.validationSchema,
|
|
41
|
+
commonTokens.logger,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
private readonly schema: JSONSchema7,
|
|
46
|
+
private readonly log: Logger,
|
|
47
|
+
) {
|
|
48
|
+
this.validateFn = ajv.compile(schema);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Validates the provided options, throwing an error if something is wrong.
|
|
53
|
+
* Optionally also warns about excess or unserializable options.
|
|
54
|
+
* @param options The stryker options to validate
|
|
55
|
+
* @param mark Wether or not to log warnings on unknown properties or unserializable properties
|
|
56
|
+
*/
|
|
57
|
+
public validate(
|
|
58
|
+
options: Record<string, unknown>,
|
|
59
|
+
mark = false,
|
|
60
|
+
): asserts options is StrykerOptions {
|
|
61
|
+
this.removeDeprecatedOptions(options);
|
|
62
|
+
this.schemaValidate(options);
|
|
63
|
+
this.customValidation(options);
|
|
64
|
+
if (mark) {
|
|
65
|
+
this.markOptions(options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private removeDeprecatedOptions(rawOptions: Record<string, unknown>) {
|
|
70
|
+
if (typeof rawOptions.mutator === 'string') {
|
|
71
|
+
this.log.warn(
|
|
72
|
+
'DEPRECATED. Use of "mutator" as string is no longer needed. You can remove it from your configuration. Stryker now supports mutating of JavaScript and friend files out of the box.',
|
|
73
|
+
);
|
|
74
|
+
delete rawOptions.mutator;
|
|
75
|
+
}
|
|
76
|
+
// @ts-expect-error mutator.name
|
|
77
|
+
if (typeof rawOptions.mutator === 'object' && rawOptions.mutator.name) {
|
|
78
|
+
this.log.warn(
|
|
79
|
+
'DEPRECATED. Use of "mutator.name" is no longer needed. You can remove "mutator.name" from your configuration. Stryker now supports mutating of JavaScript and friend files out of the box.',
|
|
80
|
+
);
|
|
81
|
+
// @ts-expect-error mutator.name
|
|
82
|
+
delete rawOptions.mutator.name;
|
|
83
|
+
}
|
|
84
|
+
if (Object.keys(rawOptions).includes('testFramework')) {
|
|
85
|
+
this.log.warn(
|
|
86
|
+
'DEPRECATED. Use of "testFramework" is no longer needed. You can remove it from your configuration. Your test runner plugin now handles its own test framework integration.',
|
|
87
|
+
);
|
|
88
|
+
delete rawOptions.testFramework;
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(rawOptions.transpilers)) {
|
|
91
|
+
const example = rawOptions.transpilers.includes('babel')
|
|
92
|
+
? 'babel src --out-dir lib'
|
|
93
|
+
: rawOptions.transpilers.includes('typescript')
|
|
94
|
+
? 'tsc -b'
|
|
95
|
+
: rawOptions.transpilers.includes('webpack')
|
|
96
|
+
? 'webpack --config webpack.config.js'
|
|
97
|
+
: 'npm run build';
|
|
98
|
+
this.log.warn(
|
|
99
|
+
`DEPRECATED. Support for "transpilers" is removed. You can now configure your own "${optionsPath('buildCommand')}". For example, ${example}.`,
|
|
100
|
+
);
|
|
101
|
+
delete rawOptions.transpilers;
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(rawOptions.files)) {
|
|
104
|
+
const ignorePatternsName = optionsPath('ignorePatterns');
|
|
105
|
+
const isString = (uncertain: unknown): uncertain is string =>
|
|
106
|
+
typeof uncertain === 'string';
|
|
107
|
+
const files = rawOptions.files.filter(isString);
|
|
108
|
+
const newIgnorePatterns: string[] = [
|
|
109
|
+
'**',
|
|
110
|
+
...files.map((filePattern) =>
|
|
111
|
+
filePattern.startsWith(IGNORE_PATTERN_CHARACTER)
|
|
112
|
+
? filePattern.substr(1)
|
|
113
|
+
: `${IGNORE_PATTERN_CHARACTER}${filePattern}`,
|
|
114
|
+
),
|
|
115
|
+
];
|
|
116
|
+
delete rawOptions.files;
|
|
117
|
+
this.log.warn(
|
|
118
|
+
`DEPRECATED. Use of "files" is deprecated, please use "${ignorePatternsName}" instead (or remove "files" altogether will probably work as well). For now, rewriting them as ${JSON.stringify(
|
|
119
|
+
newIgnorePatterns,
|
|
120
|
+
)}. See https://stryker-mutator.io/docs/stryker-js/configuration/#ignorepatterns-string`,
|
|
121
|
+
);
|
|
122
|
+
const existingIgnorePatterns = Array.isArray(
|
|
123
|
+
rawOptions[ignorePatternsName],
|
|
124
|
+
)
|
|
125
|
+
? (rawOptions[ignorePatternsName] as unknown[])
|
|
126
|
+
: [];
|
|
127
|
+
rawOptions[ignorePatternsName] = [
|
|
128
|
+
...newIgnorePatterns,
|
|
129
|
+
...existingIgnorePatterns,
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
// @ts-expect-error jest.enableBail
|
|
133
|
+
if (rawOptions.jest?.enableBail !== undefined) {
|
|
134
|
+
this.log.warn(
|
|
135
|
+
'DEPRECATED. Use of "jest.enableBail" is deprecated, please use "disableBail" instead. See https://stryker-mutator.io/docs/stryker-js/configuration#disablebail-boolean',
|
|
136
|
+
);
|
|
137
|
+
// @ts-expect-error jest.enableBail
|
|
138
|
+
rawOptions.disableBail = !rawOptions.jest?.enableBail;
|
|
139
|
+
// @ts-expect-error jest.enableBail
|
|
140
|
+
delete rawOptions.jest.enableBail;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// @ts-expect-error htmlReporter.baseDir
|
|
144
|
+
if (rawOptions.htmlReporter?.baseDir) {
|
|
145
|
+
this.log.warn(
|
|
146
|
+
`DEPRECATED. Use of "htmlReporter.baseDir" is deprecated, please use "${optionsPath(
|
|
147
|
+
'htmlReporter',
|
|
148
|
+
'fileName',
|
|
149
|
+
)}" instead. See https://stryker-mutator.io/docs/stryker-js/configuration/#reporters-string`,
|
|
150
|
+
);
|
|
151
|
+
// @ts-expect-error htmlReporter.baseDir
|
|
152
|
+
if (!rawOptions.htmlReporter.fileName) {
|
|
153
|
+
// @ts-expect-error htmlReporter.fileName
|
|
154
|
+
rawOptions.htmlReporter.fileName = path.join(
|
|
155
|
+
// @ts-expect-error htmlReporter.baseDir
|
|
156
|
+
String(rawOptions.htmlReporter.baseDir),
|
|
157
|
+
'index.html',
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
// @ts-expect-error htmlReporter.baseDir
|
|
161
|
+
delete rawOptions.htmlReporter.baseDir;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private customValidation(options: StrykerOptions) {
|
|
166
|
+
const additionalErrors: string[] = [];
|
|
167
|
+
if (options.thresholds.high < options.thresholds.low) {
|
|
168
|
+
additionalErrors.push(
|
|
169
|
+
'Config option "thresholds.high" should be higher than "thresholds.low".',
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
if (options.maxConcurrentTestRunners !== Number.MAX_SAFE_INTEGER) {
|
|
173
|
+
this.log.warn(
|
|
174
|
+
'DEPRECATED. Use of "maxConcurrentTestRunners" is deprecated. Please use "concurrency" instead.',
|
|
175
|
+
);
|
|
176
|
+
if (
|
|
177
|
+
!options.concurrency &&
|
|
178
|
+
options.maxConcurrentTestRunners < os.availableParallelism() - 1
|
|
179
|
+
) {
|
|
180
|
+
options.concurrency = options.maxConcurrentTestRunners;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (CommandTestRunner.is(options.testRunner)) {
|
|
184
|
+
if (options.testRunnerNodeArgs.length) {
|
|
185
|
+
this.log.warn(
|
|
186
|
+
'Using "testRunnerNodeArgs" together with the "command" test runner is not supported, these arguments will be ignored. You can add your custom arguments by setting the "commandRunner.command" option.',
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (options.ignoreStatic && options.coverageAnalysis !== 'perTest') {
|
|
191
|
+
additionalErrors.push(
|
|
192
|
+
`Config option "${optionsPath('ignoreStatic')}" is not supported with coverage analysis "${
|
|
193
|
+
options.coverageAnalysis
|
|
194
|
+
}". Either turn off "${optionsPath('ignoreStatic')}", or configure "${optionsPath('coverageAnalysis')}" to be "perTest".`,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
options.mutate.forEach((mutateString, index) => {
|
|
198
|
+
const match = MUTATION_RANGE_REGEX.exec(mutateString);
|
|
199
|
+
if (match) {
|
|
200
|
+
if (new Minimatch(mutateString).hasMagic()) {
|
|
201
|
+
additionalErrors.push(
|
|
202
|
+
`Config option "mutate[${index}]" is invalid. Cannot combine a glob expression with a mutation range in "${mutateString}".`,
|
|
203
|
+
);
|
|
204
|
+
} else {
|
|
205
|
+
const [
|
|
206
|
+
_,
|
|
207
|
+
_fileName,
|
|
208
|
+
mutationRange,
|
|
209
|
+
startLine,
|
|
210
|
+
_startColumn,
|
|
211
|
+
endLine,
|
|
212
|
+
_endColumn,
|
|
213
|
+
] = match;
|
|
214
|
+
const start = parseInt(startLine, 10);
|
|
215
|
+
const end = parseInt(endLine, 10);
|
|
216
|
+
if (start < 1) {
|
|
217
|
+
additionalErrors.push(
|
|
218
|
+
`Config option "mutate[${index}]" is invalid. Mutation range "${mutationRange}" is invalid, line ${start} does not exist (lines start at 1).`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
if (start > end) {
|
|
222
|
+
additionalErrors.push(
|
|
223
|
+
`Config option "mutate[${index}]" is invalid. Mutation range "${mutationRange}" is invalid. The "from" line number (${start}) should be less then the "to" line number (${end}).`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
additionalErrors.forEach((error) => this.log.error(error));
|
|
231
|
+
this.throwErrorIfNeeded(additionalErrors);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private schemaValidate(options: unknown): asserts options is StrykerOptions {
|
|
235
|
+
if (!this.validateFn(options)) {
|
|
236
|
+
const describedErrors = describeErrors(this.validateFn.errors!);
|
|
237
|
+
describedErrors.forEach((error) => this.log.error(error));
|
|
238
|
+
this.throwErrorIfNeeded(describedErrors);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private throwErrorIfNeeded(errors: string[]) {
|
|
243
|
+
if (errors.length > 0) {
|
|
244
|
+
throw new ConfigError(
|
|
245
|
+
errors.length === 1
|
|
246
|
+
? 'Please correct this configuration error and try again.'
|
|
247
|
+
: 'Please correct these configuration errors and try again.',
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private markOptions(options: StrykerOptions): void {
|
|
253
|
+
this.markExcessOptions(options);
|
|
254
|
+
this.markUnserializableOptions(options);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private markExcessOptions(options: StrykerOptions) {
|
|
258
|
+
const OPTIONS_ADDED_BY_STRYKER = ['set', 'configFile', '$schema'];
|
|
259
|
+
|
|
260
|
+
if (objectUtils.isWarningEnabled('unknownOptions', options.warnings)) {
|
|
261
|
+
const schemaKeys = Object.keys(this.schema.properties!);
|
|
262
|
+
const excessPropertyNames = Object.keys(options)
|
|
263
|
+
.filter((key) => !key.endsWith('_comment'))
|
|
264
|
+
.filter((key) => !OPTIONS_ADDED_BY_STRYKER.includes(key))
|
|
265
|
+
.filter((key) => !schemaKeys.includes(key));
|
|
266
|
+
|
|
267
|
+
if (excessPropertyNames.length) {
|
|
268
|
+
excessPropertyNames.forEach((excessPropertyName) => {
|
|
269
|
+
this.log.warn(
|
|
270
|
+
`Unknown stryker config option "${excessPropertyName}".`,
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
this.log.warn(`Possible causes:
|
|
275
|
+
* Is it a typo on your end?
|
|
276
|
+
* Did you only write this property as a comment? If so, please postfix it with "_comment".
|
|
277
|
+
* You might be missing a plugin that is supposed to use it. Stryker loaded plugins from: ${JSON.stringify(options.plugins)}
|
|
278
|
+
* The plugin that is using it did not contribute explicit validation.
|
|
279
|
+
(disable "${optionsPath('warnings', 'unknownOptions')}" to ignore this warning)`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private markUnserializableOptions(options: StrykerOptions) {
|
|
285
|
+
if (
|
|
286
|
+
objectUtils.isWarningEnabled('unserializableOptions', options.warnings)
|
|
287
|
+
) {
|
|
288
|
+
const unserializables = findUnserializables(options);
|
|
289
|
+
if (unserializables) {
|
|
290
|
+
unserializables.forEach((unserializable) =>
|
|
291
|
+
this.log.warn(
|
|
292
|
+
`Config option "${unserializable.path.join('.')}" is not (fully) serializable. ${
|
|
293
|
+
unserializable.reason
|
|
294
|
+
}. Any test runner or checker worker processes might not receive this value as intended.`,
|
|
295
|
+
),
|
|
296
|
+
);
|
|
297
|
+
this.log.warn(
|
|
298
|
+
`(disable ${optionsPath('warnings', 'unserializableOptions')} to ignore this warning)`,
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function createDefaultOptions(): StrykerOptions {
|
|
306
|
+
const options: Record<string, unknown> = {};
|
|
307
|
+
const validator: OptionsValidator = new OptionsValidator(
|
|
308
|
+
strykerCoreSchema,
|
|
309
|
+
noopLogger,
|
|
310
|
+
);
|
|
311
|
+
validator.validate(options);
|
|
312
|
+
return options;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export const defaultOptions: Immutable<StrykerOptions> = deepFreeze(
|
|
316
|
+
createDefaultOptions(),
|
|
317
|
+
);
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ErrorObject } from 'ajv';
|
|
2
|
+
|
|
3
|
+
import groupby from 'lodash.groupby';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Convert AJV errors to human readable messages
|
|
7
|
+
* @param allErrors The AJV errors to describe
|
|
8
|
+
*/
|
|
9
|
+
export function describeErrors(allErrors: ErrorObject[]): string[] {
|
|
10
|
+
const processedErrors = filterRelevantErrors(allErrors);
|
|
11
|
+
return processedErrors.map(describeError);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Filters the relevant AJV errors for error reporting.
|
|
16
|
+
* Removes meta schema errors, merges type errors for the same `dataPath` and removes type errors for which another error also exist.
|
|
17
|
+
* @param allErrors The raw source AJV errors
|
|
18
|
+
* @example
|
|
19
|
+
* This:
|
|
20
|
+
* ```
|
|
21
|
+
* [
|
|
22
|
+
* {
|
|
23
|
+
* keyword: 'type',
|
|
24
|
+
* dataPath: '.mutator',
|
|
25
|
+
* params: { type: 'string' },
|
|
26
|
+
* [...]
|
|
27
|
+
* },
|
|
28
|
+
* {
|
|
29
|
+
* keyword: 'required',
|
|
30
|
+
* dataPath: '.mutator',
|
|
31
|
+
* params: { missingProperty: 'name' },
|
|
32
|
+
* [...]
|
|
33
|
+
* },
|
|
34
|
+
* {
|
|
35
|
+
* keyword: 'oneOf',
|
|
36
|
+
* dataPath: '.mutator',
|
|
37
|
+
* params: { passingSchemas: null },
|
|
38
|
+
* [...]
|
|
39
|
+
* }
|
|
40
|
+
* ]
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Becomes:
|
|
44
|
+
* ```
|
|
45
|
+
* [
|
|
46
|
+
* {
|
|
47
|
+
* keyword: 'required',
|
|
48
|
+
* dataPath: '.mutator',
|
|
49
|
+
* params: { missingProperty: 'name' },
|
|
50
|
+
* [...]
|
|
51
|
+
* }
|
|
52
|
+
* ]
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function filterRelevantErrors(allErrors: ErrorObject[]): ErrorObject[] {
|
|
56
|
+
// These are the "meta schema" keywords. A Meta schema is a schema consisting of other schemas. See https://json-schema.org/understanding-json-schema/structuring.html
|
|
57
|
+
const META_SCHEMA_KEYWORDS = Object.freeze(['anyOf', 'allOf', 'oneOf']);
|
|
58
|
+
|
|
59
|
+
// Split the meta errors from what I call "single errors" (the real errors)
|
|
60
|
+
const [metaErrors, singleErrors] = split(allErrors, (error) =>
|
|
61
|
+
META_SCHEMA_KEYWORDS.includes(error.keyword),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Filter out the single errors we want to show
|
|
65
|
+
const nonShadowedSingleErrors = removeShadowingErrors(
|
|
66
|
+
singleErrors,
|
|
67
|
+
metaErrors,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// We're handling type errors differently, split them out
|
|
71
|
+
const [typeErrors, nonTypeErrors] = split(
|
|
72
|
+
nonShadowedSingleErrors,
|
|
73
|
+
(error) => error.keyword === 'type',
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// Filter out the type errors that already have other errors as well.
|
|
77
|
+
// For example when setting `logLevel: 4`, we don't want to see the error specifying that logLevel should be a string,
|
|
78
|
+
// if the other error already specified that it should be one of the enum values.
|
|
79
|
+
const nonShadowingTypeErrors = typeErrors.filter(
|
|
80
|
+
(typeError) =>
|
|
81
|
+
!nonTypeErrors.some(
|
|
82
|
+
(nonTypeError) => nonTypeError.instancePath === typeError.instancePath,
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
const typeErrorsMerged = mergeTypeErrorsByPath(nonShadowingTypeErrors);
|
|
86
|
+
return [...nonTypeErrors, ...typeErrorsMerged];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Remove the single errors that are pointing to the same data path.
|
|
91
|
+
* This can happen when using meta schemas.
|
|
92
|
+
* For example, the "mutator" Stryker option can be either a `string` or a `MutatorDescriptor`.
|
|
93
|
+
* A data object of `{ "foo": "bar" }` would result in 2 errors. One of a missing property "name" missing, and one that mutator itself should be a string.
|
|
94
|
+
* @param singleErrors The 'real' errors
|
|
95
|
+
* @param metaErrors The grouping errors
|
|
96
|
+
*/
|
|
97
|
+
function removeShadowingErrors(
|
|
98
|
+
singleErrors: ErrorObject[],
|
|
99
|
+
metaErrors: ErrorObject[],
|
|
100
|
+
): ErrorObject[] {
|
|
101
|
+
return singleErrors.filter((error) => {
|
|
102
|
+
if (
|
|
103
|
+
metaErrors.some((metaError) =>
|
|
104
|
+
error.instancePath.startsWith(metaError.instancePath),
|
|
105
|
+
)
|
|
106
|
+
) {
|
|
107
|
+
return !singleErrors.some(
|
|
108
|
+
(otherError) =>
|
|
109
|
+
otherError.instancePath.startsWith(error.instancePath) &&
|
|
110
|
+
otherError.instancePath.length > error.instancePath.length,
|
|
111
|
+
);
|
|
112
|
+
} else {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function split<T>(items: T[], splitFn: (item: T) => boolean): [T[], T[]] {
|
|
119
|
+
return [items.filter(splitFn), items.filter((error) => !splitFn(error))];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Merge type errors that have the same path into 1.
|
|
124
|
+
* @example
|
|
125
|
+
* The 'plugins' Stryker option can have 2 types, null or an array of strings.
|
|
126
|
+
* When setting `plugins: 'my-plugin'` we get 2 type errors, because it isn't an array AND it isn't `null`.
|
|
127
|
+
* @param typeErrors The type errors to merge by path
|
|
128
|
+
*/
|
|
129
|
+
function mergeTypeErrorsByPath(typeErrors: ErrorObject[]): ErrorObject[] {
|
|
130
|
+
const typeErrorsByPath = groupby(typeErrors, (error) => error.instancePath);
|
|
131
|
+
return Object.values(typeErrorsByPath).map(mergeTypeErrors);
|
|
132
|
+
|
|
133
|
+
function mergeTypeErrors(errors: ErrorObject[]): ErrorObject {
|
|
134
|
+
const params = {
|
|
135
|
+
type: errors.map((error) => error.params.type).join(','),
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
...errors[0],
|
|
139
|
+
params,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Converts the AJV error object to a human readable error.
|
|
146
|
+
* @param error The error to describe
|
|
147
|
+
*/
|
|
148
|
+
function describeError(error: ErrorObject): string {
|
|
149
|
+
const errorPrefix = `Config option "${error.instancePath.substr(1)}"`;
|
|
150
|
+
|
|
151
|
+
switch (error.keyword) {
|
|
152
|
+
case 'type': {
|
|
153
|
+
const expectedTypeDescription = error.params.type.split(',').join(' or ');
|
|
154
|
+
return `${errorPrefix} has the wrong type. It should be a ${expectedTypeDescription}, but was a ${jsonSchemaType(error.data)}.`;
|
|
155
|
+
}
|
|
156
|
+
case 'enum':
|
|
157
|
+
return `${errorPrefix} should be one of the allowed values (${new Intl.ListFormat('en', { type: 'disjunction' }).format((error.params.allowedValues as unknown[]).map(stringify))}), but was ${stringify(
|
|
158
|
+
error.data,
|
|
159
|
+
)}.`;
|
|
160
|
+
case 'minimum':
|
|
161
|
+
case 'maximum':
|
|
162
|
+
return `${errorPrefix} ${error.message}, was ${String(error.data)}.`;
|
|
163
|
+
default:
|
|
164
|
+
return `${errorPrefix} ${error.message!.replace(/'/g, '"')}`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Returns the JSON schema name of the type. JSON schema types are slightly different from actual JS types.
|
|
170
|
+
* @see https://json-schema.org/understanding-json-schema/reference/type.html
|
|
171
|
+
* @param value The value of which it's type should be known
|
|
172
|
+
*/
|
|
173
|
+
function jsonSchemaType(value: unknown): string {
|
|
174
|
+
if (value === null) {
|
|
175
|
+
return 'null';
|
|
176
|
+
}
|
|
177
|
+
if (value === undefined) {
|
|
178
|
+
return 'undefined';
|
|
179
|
+
}
|
|
180
|
+
if (Array.isArray(value)) {
|
|
181
|
+
return 'array';
|
|
182
|
+
}
|
|
183
|
+
return typeof value;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function stringify(value: unknown): string {
|
|
187
|
+
if (typeof value === 'number' && isNaN(value)) {
|
|
188
|
+
return 'NaN';
|
|
189
|
+
} else {
|
|
190
|
+
return JSON.stringify(value);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const checkerPool = 'checkerPool';
|
|
2
|
+
export const checkerFactory = 'checkerFactory';
|
|
3
|
+
export const checkerConcurrencyTokens = 'checkerConcurrencyTokens';
|
|
4
|
+
export const disableTypeChecksHelper = 'disableTypeChecksHelper';
|
|
5
|
+
export const execa = 'execa';
|
|
6
|
+
export const execaSync = 'execaSync';
|
|
7
|
+
export const dryRunResult = 'dryRunResult';
|
|
8
|
+
export const mutants = 'mutants';
|
|
9
|
+
export const mutantTestPlanner = 'mutantTestPlanner';
|
|
10
|
+
export const process = 'process';
|
|
11
|
+
export const pluginModulePaths = 'pluginModulePaths';
|
|
12
|
+
export const temporaryDirectory = 'temporaryDirectory';
|
|
13
|
+
export const unexpectedExitRegistry = 'unexpectedExitRegistry';
|
|
14
|
+
export const timer = 'timer';
|
|
15
|
+
export const timeOverheadMS = 'timeOverheadMS';
|
|
16
|
+
export const loggingServerAddress = 'loggingServerAddress';
|
|
17
|
+
export const loggerActiveLevel = 'loggerActiveLevel';
|
|
18
|
+
export const loggerConsoleOut = 'loggerConsoleOut';
|
|
19
|
+
export const loggingSink = 'loggingSink';
|
|
20
|
+
export const loggingServer = 'loggingServer';
|
|
21
|
+
export const mutationTestReportHelper = 'mutationTestReportHelper';
|
|
22
|
+
export const sandbox = 'sandbox';
|
|
23
|
+
export const concurrencyTokenProvider = 'concurrencyTokenProvider';
|
|
24
|
+
export const testRunnerFactory = 'testRunnerFactory';
|
|
25
|
+
export const testRunnerPool = 'testRunnerPool';
|
|
26
|
+
export const testRunnerConcurrencyTokens = 'testRunnerConcurrencyTokens';
|
|
27
|
+
export const reporter = 'reporter';
|
|
28
|
+
export const reporterOverride = 'reporterOverride';
|
|
29
|
+
export const pluginCreator = 'pluginCreator';
|
|
30
|
+
export const pluginsByKind = 'pluginsByKind';
|
|
31
|
+
export const validationSchema = 'validationSchema';
|
|
32
|
+
export const optionsValidator = 'optionsValidator';
|
|
33
|
+
export const requireFromCwd = 'requireFromCwd';
|
|
34
|
+
export const resolveFromCwd = 'resolveFromCwd';
|
|
35
|
+
export const fs = 'fs';
|
|
36
|
+
export const testCoverage = 'testCoverage';
|
|
37
|
+
export const incrementalDiffer = 'incrementalDiffer';
|
|
38
|
+
export const project = 'project';
|
|
39
|
+
export const workerIdGenerator = 'worker-id-generator';
|
package/src/di/index.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Plugins,
|
|
3
|
+
PluginInterfaces,
|
|
4
|
+
PluginContext,
|
|
5
|
+
Injector,
|
|
6
|
+
Plugin,
|
|
7
|
+
PluginKind,
|
|
8
|
+
ClassPlugin,
|
|
9
|
+
FactoryPlugin,
|
|
10
|
+
InjectionToken,
|
|
11
|
+
tokens,
|
|
12
|
+
commonTokens,
|
|
13
|
+
ValuePlugin,
|
|
14
|
+
} from '@stryker-mutator/api/plugin';
|
|
15
|
+
import { InjectableFunction, InjectableClass } from 'typed-inject';
|
|
16
|
+
|
|
17
|
+
import { coreTokens } from './index.js';
|
|
18
|
+
|
|
19
|
+
export class PluginCreator {
|
|
20
|
+
public static readonly inject = tokens(
|
|
21
|
+
coreTokens.pluginsByKind,
|
|
22
|
+
commonTokens.injector,
|
|
23
|
+
);
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly pluginsByKind: Map<PluginKind, Array<Plugin<PluginKind>>>,
|
|
26
|
+
private readonly injector: Injector<PluginContext>,
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
public create<TPlugin extends keyof Plugins>(
|
|
30
|
+
kind: TPlugin,
|
|
31
|
+
name: string,
|
|
32
|
+
): PluginInterfaces[TPlugin] {
|
|
33
|
+
const plugin = this.findPlugin(kind, name);
|
|
34
|
+
if (isFactoryPlugin(plugin)) {
|
|
35
|
+
return this.injector.injectFunction(
|
|
36
|
+
plugin.factory as InjectableFunction<
|
|
37
|
+
PluginContext,
|
|
38
|
+
PluginInterfaces[TPlugin],
|
|
39
|
+
Array<InjectionToken<PluginContext>>
|
|
40
|
+
>,
|
|
41
|
+
);
|
|
42
|
+
} else if (isClassPlugin(plugin)) {
|
|
43
|
+
return this.injector.injectClass(
|
|
44
|
+
plugin.injectableClass as InjectableClass<
|
|
45
|
+
PluginContext,
|
|
46
|
+
PluginInterfaces[TPlugin],
|
|
47
|
+
Array<InjectionToken<PluginContext>>
|
|
48
|
+
>,
|
|
49
|
+
);
|
|
50
|
+
} else if (isValuePlugin(plugin)) {
|
|
51
|
+
return plugin.value;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Plugin "${kind}:${name}" could not be created, missing "factory", "injectableClass" or "value" property.`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private findPlugin<T extends keyof Plugins>(
|
|
59
|
+
kind: T,
|
|
60
|
+
name: string,
|
|
61
|
+
): Plugins[T] {
|
|
62
|
+
const plugins = this.pluginsByKind.get(kind);
|
|
63
|
+
if (plugins) {
|
|
64
|
+
const pluginFound = plugins.find(
|
|
65
|
+
(plugin) => plugin.name.toLowerCase() === name.toLowerCase(),
|
|
66
|
+
);
|
|
67
|
+
if (pluginFound) {
|
|
68
|
+
return pluginFound as Plugins[T];
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Cannot find ${kind} plugin "${name}". Did you forget to install it? Loaded ${kind} plugins were: ${new Intl.ListFormat('en').format(plugins.map((p) => `"${p.name}"`))}`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Cannot find ${kind} plugin "${name}". In fact, no ${kind} plugins were loaded. Did you forget to install it?`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function isFactoryPlugin(
|
|
83
|
+
plugin: Plugin<PluginKind>,
|
|
84
|
+
): plugin is FactoryPlugin<PluginKind, Array<InjectionToken<PluginContext>>> {
|
|
85
|
+
return Boolean(
|
|
86
|
+
(plugin as FactoryPlugin<PluginKind, Array<InjectionToken<PluginContext>>>)
|
|
87
|
+
.factory,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function isClassPlugin(
|
|
91
|
+
plugin: Plugin<PluginKind>,
|
|
92
|
+
): plugin is ClassPlugin<PluginKind, Array<InjectionToken<PluginContext>>> {
|
|
93
|
+
return Boolean(
|
|
94
|
+
(plugin as ClassPlugin<PluginKind, Array<InjectionToken<PluginContext>>>)
|
|
95
|
+
.injectableClass,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function isValuePlugin(
|
|
99
|
+
plugin: Plugin<PluginKind>,
|
|
100
|
+
): plugin is ValuePlugin<PluginKind> {
|
|
101
|
+
return Boolean((plugin as ValuePlugin<PluginKind>).value);
|
|
102
|
+
}
|