@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,190 @@
|
|
|
1
|
+
import { exec } from 'child_process';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
StrykerOptions,
|
|
6
|
+
CommandRunnerOptions,
|
|
7
|
+
INSTRUMENTER_CONSTANTS,
|
|
8
|
+
} from '@stryker-mutator/api/core';
|
|
9
|
+
import {
|
|
10
|
+
TestRunner,
|
|
11
|
+
TestStatus,
|
|
12
|
+
MutantRunOptions,
|
|
13
|
+
DryRunResult,
|
|
14
|
+
MutantRunResult,
|
|
15
|
+
DryRunStatus,
|
|
16
|
+
ErrorDryRunResult,
|
|
17
|
+
CompleteDryRunResult,
|
|
18
|
+
toMutantRunResult,
|
|
19
|
+
TestRunnerCapabilities,
|
|
20
|
+
DryRunOptions,
|
|
21
|
+
} from '@stryker-mutator/api/test-runner';
|
|
22
|
+
import { errorToString, testFilesProvided } from '@stryker-mutator/util';
|
|
23
|
+
|
|
24
|
+
import { objectUtils } from '../utils/object-utils.js';
|
|
25
|
+
import { Timer } from '../utils/timer.js';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A test runner that uses a (bash or cmd) command to execute the tests.
|
|
29
|
+
* Does not know hom many tests are executed or any code coverage results,
|
|
30
|
+
* instead, it mimics a simple test result based on the exit code.
|
|
31
|
+
* The command can be configured, but defaults to `npm test`.
|
|
32
|
+
*/
|
|
33
|
+
export class CommandTestRunner implements TestRunner {
|
|
34
|
+
/**
|
|
35
|
+
* "command"
|
|
36
|
+
*/
|
|
37
|
+
public static readonly runnerName = CommandTestRunner.name
|
|
38
|
+
.replace('TestRunner', '')
|
|
39
|
+
.toLowerCase();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Determines whether a given name is "command" (ignore case)
|
|
43
|
+
* @param name Maybe "command", maybe not
|
|
44
|
+
*/
|
|
45
|
+
public static is(name: string): name is 'command' {
|
|
46
|
+
return this.runnerName === name.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private readonly settings: CommandRunnerOptions;
|
|
50
|
+
private readonly testFilesProvided: boolean;
|
|
51
|
+
|
|
52
|
+
private timeoutHandler: (() => Promise<void>) | undefined;
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
private readonly workingDir: string,
|
|
56
|
+
options: StrykerOptions,
|
|
57
|
+
) {
|
|
58
|
+
this.settings = options.commandRunner;
|
|
59
|
+
this.testFilesProvided = testFilesProvided(options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public capabilities(): TestRunnerCapabilities {
|
|
63
|
+
// Can reload, because each call is a new process.
|
|
64
|
+
return { reloadEnvironment: true };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public async init(): Promise<void> {
|
|
68
|
+
if (this.testFilesProvided) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`The ${CommandTestRunner.runnerName} test runner does not support the --testFiles option.`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return Promise.resolve();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public async dryRun(_options: DryRunOptions): Promise<DryRunResult> {
|
|
77
|
+
return this.run({});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public async mutantRun({
|
|
81
|
+
activeMutant,
|
|
82
|
+
}: Pick<MutantRunOptions, 'activeMutant'>): Promise<MutantRunResult> {
|
|
83
|
+
const result = await this.run({ activeMutantId: activeMutant.id });
|
|
84
|
+
return toMutantRunResult(result);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private run({
|
|
88
|
+
activeMutantId,
|
|
89
|
+
}: {
|
|
90
|
+
activeMutantId?: string;
|
|
91
|
+
}): Promise<DryRunResult> {
|
|
92
|
+
const timerInstance = new Timer();
|
|
93
|
+
return new Promise((res, rej) => {
|
|
94
|
+
const output: Array<Buffer | string> = [];
|
|
95
|
+
const env =
|
|
96
|
+
activeMutantId === undefined
|
|
97
|
+
? process.env
|
|
98
|
+
: {
|
|
99
|
+
...process.env,
|
|
100
|
+
[INSTRUMENTER_CONSTANTS.ACTIVE_MUTANT_ENV_VARIABLE]:
|
|
101
|
+
activeMutantId,
|
|
102
|
+
};
|
|
103
|
+
const childProcess = exec(this.settings.command, {
|
|
104
|
+
cwd: this.workingDir,
|
|
105
|
+
env,
|
|
106
|
+
});
|
|
107
|
+
childProcess.on('error', (error) => {
|
|
108
|
+
objectUtils
|
|
109
|
+
.kill(childProcess.pid)
|
|
110
|
+
.then(() => handleResolve(errorResult(error)))
|
|
111
|
+
|
|
112
|
+
.catch(rej);
|
|
113
|
+
});
|
|
114
|
+
childProcess.on('exit', (code) => {
|
|
115
|
+
const result = completeResult(code, timerInstance);
|
|
116
|
+
handleResolve(result);
|
|
117
|
+
});
|
|
118
|
+
childProcess.stdout!.on('data', (chunk) => {
|
|
119
|
+
output.push(chunk as Buffer);
|
|
120
|
+
});
|
|
121
|
+
childProcess.stderr!.on('data', (chunk) => {
|
|
122
|
+
output.push(chunk as Buffer);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this.timeoutHandler = async () => {
|
|
126
|
+
handleResolve({ status: DryRunStatus.Timeout });
|
|
127
|
+
await objectUtils.kill(childProcess.pid);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const handleResolve = (runResult: DryRunResult) => {
|
|
131
|
+
removeAllListeners();
|
|
132
|
+
this.timeoutHandler = undefined;
|
|
133
|
+
res(runResult);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
function removeAllListeners() {
|
|
137
|
+
childProcess.stderr!.removeAllListeners();
|
|
138
|
+
childProcess.stdout!.removeAllListeners();
|
|
139
|
+
childProcess.removeAllListeners();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function errorResult(error: Error): ErrorDryRunResult {
|
|
143
|
+
return {
|
|
144
|
+
errorMessage: errorToString(error),
|
|
145
|
+
status: DryRunStatus.Error,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function completeResult(
|
|
150
|
+
exitCode: number | null,
|
|
151
|
+
timer: Timer,
|
|
152
|
+
): CompleteDryRunResult {
|
|
153
|
+
const duration = timer.elapsedMs();
|
|
154
|
+
if (exitCode === 0) {
|
|
155
|
+
return {
|
|
156
|
+
status: DryRunStatus.Complete,
|
|
157
|
+
tests: [
|
|
158
|
+
{
|
|
159
|
+
id: 'all',
|
|
160
|
+
name: 'All tests',
|
|
161
|
+
status: TestStatus.Success,
|
|
162
|
+
timeSpentMs: duration,
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
} else {
|
|
167
|
+
return {
|
|
168
|
+
status: DryRunStatus.Complete,
|
|
169
|
+
tests: [
|
|
170
|
+
{
|
|
171
|
+
id: 'all',
|
|
172
|
+
failureMessage: output
|
|
173
|
+
.map((buf) => buf.toString())
|
|
174
|
+
.join(os.EOL),
|
|
175
|
+
name: 'All tests',
|
|
176
|
+
status: TestStatus.Failed,
|
|
177
|
+
timeSpentMs: duration,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
public async dispose(): Promise<void> {
|
|
186
|
+
if (this.timeoutHandler) {
|
|
187
|
+
await this.timeoutHandler();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { TestRunner } from '@stryker-mutator/api/test-runner';
|
|
2
|
+
import { FileDescriptions, StrykerOptions } from '@stryker-mutator/api/core';
|
|
3
|
+
import { tokens, commonTokens } from '@stryker-mutator/api/plugin';
|
|
4
|
+
import { LoggerFactoryMethod } from '@stryker-mutator/api/logging';
|
|
5
|
+
|
|
6
|
+
import { LoggingServerAddress } from '../logging/index.js';
|
|
7
|
+
import { coreTokens } from '../di/index.js';
|
|
8
|
+
import { Sandbox } from '../sandbox/sandbox.js';
|
|
9
|
+
|
|
10
|
+
import { IdGenerator } from '../child-proxy/id-generator.js';
|
|
11
|
+
|
|
12
|
+
import { RetryRejectedDecorator } from './retry-rejected-decorator.js';
|
|
13
|
+
import { TimeoutDecorator } from './timeout-decorator.js';
|
|
14
|
+
import { ChildProcessTestRunnerProxy } from './child-process-test-runner-proxy.js';
|
|
15
|
+
import { CommandTestRunner } from './command-test-runner.js';
|
|
16
|
+
import { MaxTestRunnerReuseDecorator } from './max-test-runner-reuse-decorator.js';
|
|
17
|
+
import { ReloadEnvironmentDecorator } from './reload-environment-decorator.js';
|
|
18
|
+
|
|
19
|
+
createTestRunnerFactory.inject = tokens(
|
|
20
|
+
commonTokens.options,
|
|
21
|
+
commonTokens.fileDescriptions,
|
|
22
|
+
coreTokens.sandbox,
|
|
23
|
+
coreTokens.loggingServerAddress,
|
|
24
|
+
commonTokens.getLogger,
|
|
25
|
+
coreTokens.pluginModulePaths,
|
|
26
|
+
coreTokens.workerIdGenerator,
|
|
27
|
+
);
|
|
28
|
+
export function createTestRunnerFactory(
|
|
29
|
+
options: StrykerOptions,
|
|
30
|
+
fileDescriptions: FileDescriptions,
|
|
31
|
+
sandbox: Pick<Sandbox, 'workingDirectory'>,
|
|
32
|
+
loggingServerAddress: LoggingServerAddress,
|
|
33
|
+
getLogger: LoggerFactoryMethod,
|
|
34
|
+
pluginModulePaths: readonly string[],
|
|
35
|
+
idGenerator: IdGenerator,
|
|
36
|
+
): () => TestRunner {
|
|
37
|
+
if (CommandTestRunner.is(options.testRunner)) {
|
|
38
|
+
return () =>
|
|
39
|
+
new RetryRejectedDecorator(
|
|
40
|
+
getLogger(RetryRejectedDecorator.name),
|
|
41
|
+
() =>
|
|
42
|
+
new TimeoutDecorator(
|
|
43
|
+
getLogger(TimeoutDecorator.name),
|
|
44
|
+
() => new CommandTestRunner(sandbox.workingDirectory, options),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
} else {
|
|
48
|
+
return () =>
|
|
49
|
+
new RetryRejectedDecorator(
|
|
50
|
+
getLogger(RetryRejectedDecorator.name),
|
|
51
|
+
() =>
|
|
52
|
+
new ReloadEnvironmentDecorator(
|
|
53
|
+
() =>
|
|
54
|
+
new MaxTestRunnerReuseDecorator(
|
|
55
|
+
() =>
|
|
56
|
+
new TimeoutDecorator(
|
|
57
|
+
getLogger(TimeoutDecorator.name),
|
|
58
|
+
() =>
|
|
59
|
+
new ChildProcessTestRunnerProxy(
|
|
60
|
+
options,
|
|
61
|
+
fileDescriptions,
|
|
62
|
+
sandbox.workingDirectory,
|
|
63
|
+
loggingServerAddress,
|
|
64
|
+
pluginModulePaths,
|
|
65
|
+
getLogger,
|
|
66
|
+
idGenerator,
|
|
67
|
+
),
|
|
68
|
+
),
|
|
69
|
+
options,
|
|
70
|
+
),
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MutantRunOptions,
|
|
3
|
+
MutantRunResult,
|
|
4
|
+
TestRunner,
|
|
5
|
+
} from '@stryker-mutator/api/test-runner';
|
|
6
|
+
|
|
7
|
+
import { StrykerOptions } from '@stryker-mutator/api/core';
|
|
8
|
+
|
|
9
|
+
import { TestRunnerDecorator } from './test-runner-decorator.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a test runner and implements the retry functionality.
|
|
13
|
+
*/
|
|
14
|
+
export class MaxTestRunnerReuseDecorator extends TestRunnerDecorator {
|
|
15
|
+
public runs = 0;
|
|
16
|
+
private readonly restartAfter;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
testRunnerProducer: () => TestRunner,
|
|
20
|
+
options: Pick<StrykerOptions, 'maxTestRunnerReuse'>,
|
|
21
|
+
) {
|
|
22
|
+
super(testRunnerProducer);
|
|
23
|
+
|
|
24
|
+
this.restartAfter = options.maxTestRunnerReuse || 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async mutantRun(options: MutantRunOptions): Promise<MutantRunResult> {
|
|
28
|
+
this.runs++;
|
|
29
|
+
if (this.restartAfter > 0 && this.runs > this.restartAfter) {
|
|
30
|
+
await this.recover();
|
|
31
|
+
this.runs = 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return super.mutantRun(options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public dispose(): Promise<any> {
|
|
38
|
+
this.runs = 0;
|
|
39
|
+
return super.dispose();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DryRunOptions,
|
|
3
|
+
DryRunResult,
|
|
4
|
+
MutantRunOptions,
|
|
5
|
+
MutantRunResult,
|
|
6
|
+
TestRunnerCapabilities,
|
|
7
|
+
} from '@stryker-mutator/api/test-runner';
|
|
8
|
+
|
|
9
|
+
import { TestRunnerDecorator } from './test-runner-decorator.js';
|
|
10
|
+
|
|
11
|
+
enum TestEnvironmentState {
|
|
12
|
+
Pristine,
|
|
13
|
+
Loaded,
|
|
14
|
+
LoadedStaticMutant,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class ReloadEnvironmentDecorator extends TestRunnerDecorator {
|
|
18
|
+
private _capabilities?: TestRunnerCapabilities;
|
|
19
|
+
private testEnvironment = TestEnvironmentState.Pristine;
|
|
20
|
+
|
|
21
|
+
public override async capabilities(): Promise<TestRunnerCapabilities> {
|
|
22
|
+
if (!this._capabilities) {
|
|
23
|
+
this._capabilities = await super.capabilities();
|
|
24
|
+
}
|
|
25
|
+
return this._capabilities;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public override async dryRun(options: DryRunOptions): Promise<DryRunResult> {
|
|
29
|
+
this.testEnvironment = TestEnvironmentState.Loaded;
|
|
30
|
+
return super.dryRun(options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public override async mutantRun(
|
|
34
|
+
options: MutantRunOptions,
|
|
35
|
+
): Promise<MutantRunResult> {
|
|
36
|
+
let newState: TestEnvironmentState;
|
|
37
|
+
if (options.reloadEnvironment) {
|
|
38
|
+
newState = TestEnvironmentState.LoadedStaticMutant;
|
|
39
|
+
|
|
40
|
+
// If env is still pristine (first run), no reload is actually needed
|
|
41
|
+
options.reloadEnvironment =
|
|
42
|
+
this.testEnvironment !== TestEnvironmentState.Pristine;
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
options.reloadEnvironment &&
|
|
46
|
+
!(await this.testRunnerIsCapableOfReload())
|
|
47
|
+
) {
|
|
48
|
+
await this.recover();
|
|
49
|
+
options.reloadEnvironment = false;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
// Reload might still be needed actually, since a static mutant could be loaded
|
|
53
|
+
newState = TestEnvironmentState.Loaded;
|
|
54
|
+
if (this.testEnvironment === TestEnvironmentState.LoadedStaticMutant) {
|
|
55
|
+
// Test env needs reloading
|
|
56
|
+
if (await this.testRunnerIsCapableOfReload()) {
|
|
57
|
+
options.reloadEnvironment = true;
|
|
58
|
+
} else {
|
|
59
|
+
// loaded a static mutant in previous run, need to reload first
|
|
60
|
+
await this.recover();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const result = await super.mutantRun(options);
|
|
65
|
+
this.testEnvironment = newState;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private async testRunnerIsCapableOfReload() {
|
|
70
|
+
return (await this.capabilities()).reloadEnvironment;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DryRunStatus,
|
|
3
|
+
DryRunResult,
|
|
4
|
+
DryRunOptions,
|
|
5
|
+
MutantRunResult,
|
|
6
|
+
MutantRunOptions,
|
|
7
|
+
MutantRunStatus,
|
|
8
|
+
TestRunner,
|
|
9
|
+
} from '@stryker-mutator/api/test-runner';
|
|
10
|
+
import { errorToString } from '@stryker-mutator/util';
|
|
11
|
+
|
|
12
|
+
import { OutOfMemoryError } from '../child-proxy/out-of-memory-error.js';
|
|
13
|
+
|
|
14
|
+
import { TestRunnerDecorator } from './test-runner-decorator.js';
|
|
15
|
+
import { Logger } from '@stryker-mutator/api/logging';
|
|
16
|
+
|
|
17
|
+
const ERROR_MESSAGE =
|
|
18
|
+
'Test runner crashed. Tried twice to restart it without any luck. Last time the error message was: ';
|
|
19
|
+
export const MAX_RETRIES = 2;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Implements the retry functionality whenever an internal test runner rejects a promise.
|
|
23
|
+
*/
|
|
24
|
+
export class RetryRejectedDecorator extends TestRunnerDecorator {
|
|
25
|
+
constructor(
|
|
26
|
+
readonly log: Logger,
|
|
27
|
+
producer: () => TestRunner,
|
|
28
|
+
) {
|
|
29
|
+
super(producer);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async dryRun(options: DryRunOptions): Promise<DryRunResult> {
|
|
33
|
+
const result = await this.run(() => super.dryRun(options));
|
|
34
|
+
if (typeof result === 'string') {
|
|
35
|
+
return {
|
|
36
|
+
status: DryRunStatus.Error,
|
|
37
|
+
errorMessage: result,
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public async mutantRun(options: MutantRunOptions): Promise<MutantRunResult> {
|
|
45
|
+
const result = await this.run(() => super.mutantRun(options));
|
|
46
|
+
if (typeof result === 'string') {
|
|
47
|
+
return {
|
|
48
|
+
status: MutantRunStatus.Error,
|
|
49
|
+
errorMessage: result,
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private async run<T extends DryRunResult | MutantRunResult>(
|
|
57
|
+
actRun: () => Promise<T>,
|
|
58
|
+
attemptsLeft = MAX_RETRIES,
|
|
59
|
+
lastError?: unknown,
|
|
60
|
+
): Promise<T | string> {
|
|
61
|
+
if (attemptsLeft > 0) {
|
|
62
|
+
try {
|
|
63
|
+
return await actRun();
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error instanceof OutOfMemoryError) {
|
|
66
|
+
this.log.info(
|
|
67
|
+
"Test runner process [%s] ran out of memory. You probably have a memory leak in your tests. Don't worry, Stryker will restart the process, but you might want to investigate this later, because this decreases performance.",
|
|
68
|
+
error.pid,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
await this.recover();
|
|
72
|
+
return this.run(actRun, attemptsLeft - 1, error);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
await this.recover();
|
|
76
|
+
return `${ERROR_MESSAGE}${errorToString(lastError)}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TestRunner,
|
|
3
|
+
DryRunOptions,
|
|
4
|
+
MutantRunOptions,
|
|
5
|
+
MutantRunResult,
|
|
6
|
+
DryRunResult,
|
|
7
|
+
TestRunnerCapabilities,
|
|
8
|
+
} from '@stryker-mutator/api/test-runner';
|
|
9
|
+
|
|
10
|
+
import { ResourceDecorator } from '../concurrent/index.js';
|
|
11
|
+
|
|
12
|
+
export class TestRunnerDecorator extends ResourceDecorator<TestRunner> {
|
|
13
|
+
public async capabilities(): Promise<TestRunnerCapabilities> {
|
|
14
|
+
return this.innerResource.capabilities();
|
|
15
|
+
}
|
|
16
|
+
public dryRun(options: DryRunOptions): Promise<DryRunResult> {
|
|
17
|
+
return this.innerResource.dryRun(options);
|
|
18
|
+
}
|
|
19
|
+
public mutantRun(options: MutantRunOptions): Promise<MutantRunResult> {
|
|
20
|
+
return this.innerResource.mutantRun(options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DryRunStatus,
|
|
3
|
+
DryRunResult,
|
|
4
|
+
DryRunOptions,
|
|
5
|
+
MutantRunOptions,
|
|
6
|
+
MutantRunResult,
|
|
7
|
+
MutantRunStatus,
|
|
8
|
+
TestRunner,
|
|
9
|
+
} from '@stryker-mutator/api/test-runner';
|
|
10
|
+
import { ExpirableTask } from '@stryker-mutator/util';
|
|
11
|
+
|
|
12
|
+
import { TestRunnerDecorator } from './test-runner-decorator.js';
|
|
13
|
+
import { Logger } from '@stryker-mutator/api/logging';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a test runner and implements the timeout functionality.
|
|
17
|
+
*/
|
|
18
|
+
export class TimeoutDecorator extends TestRunnerDecorator {
|
|
19
|
+
constructor(
|
|
20
|
+
private readonly log: Logger,
|
|
21
|
+
producer: () => TestRunner,
|
|
22
|
+
) {
|
|
23
|
+
super(producer);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async dryRun(options: DryRunOptions): Promise<DryRunResult> {
|
|
27
|
+
const result = await this.run(options, () => super.dryRun(options));
|
|
28
|
+
if (result === ExpirableTask.TimeoutExpired) {
|
|
29
|
+
return {
|
|
30
|
+
status: DryRunStatus.Timeout,
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async mutantRun(options: MutantRunOptions): Promise<MutantRunResult> {
|
|
38
|
+
const result = await this.run(options, () => super.mutantRun(options));
|
|
39
|
+
if (result === ExpirableTask.TimeoutExpired) {
|
|
40
|
+
return {
|
|
41
|
+
status: MutantRunStatus.Timeout,
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private async run<TResult>(
|
|
49
|
+
options: { timeout: number },
|
|
50
|
+
actRun: () => Promise<TResult>,
|
|
51
|
+
): Promise<TResult | typeof ExpirableTask.TimeoutExpired> {
|
|
52
|
+
this.log.debug(
|
|
53
|
+
'Starting timeout timer (%s ms) for a test run',
|
|
54
|
+
options.timeout,
|
|
55
|
+
);
|
|
56
|
+
const result = await ExpirableTask.timeout(actRun(), options.timeout);
|
|
57
|
+
if (result === ExpirableTask.TimeoutExpired) {
|
|
58
|
+
await this.handleTimeout();
|
|
59
|
+
return result;
|
|
60
|
+
} else {
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async handleTimeout(): Promise<void> {
|
|
66
|
+
this.log.debug(
|
|
67
|
+
'Timeout expired, restarting the process and reporting timeout',
|
|
68
|
+
);
|
|
69
|
+
await this.recover();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Disposable } from '@stryker-mutator/api/plugin';
|
|
2
|
+
|
|
3
|
+
import { coreTokens } from './di/index.js';
|
|
4
|
+
|
|
5
|
+
export type ExitHandler = () => void;
|
|
6
|
+
|
|
7
|
+
const signals = Object.freeze(['SIGABRT', 'SIGINT', 'SIGHUP', 'SIGTERM']);
|
|
8
|
+
export class UnexpectedExitHandler implements Disposable {
|
|
9
|
+
private readonly unexpectedExitHandlers: ExitHandler[] = [];
|
|
10
|
+
|
|
11
|
+
public static readonly inject = [coreTokens.process] as const;
|
|
12
|
+
constructor(
|
|
13
|
+
private readonly process: Pick<NodeJS.Process, 'exit' | 'off' | 'on'>,
|
|
14
|
+
) {
|
|
15
|
+
process.on('exit', this.handleExit);
|
|
16
|
+
signals.forEach((signal) => process.on(signal, this.processSignal));
|
|
17
|
+
}
|
|
18
|
+
private readonly processSignal = (_signal: string, signalNumber: number) => {
|
|
19
|
+
// Just call 'exit' with correct exitCode.
|
|
20
|
+
// See https://nodejs.org/api/process.html#process_signal_events, we should exit with 128 + signal number
|
|
21
|
+
this.process.exit(128 + signalNumber);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
private readonly handleExit = () => {
|
|
25
|
+
this.unexpectedExitHandlers.forEach((handler) => handler());
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
public registerHandler(handler: ExitHandler): void {
|
|
29
|
+
this.unexpectedExitHandlers.push(handler);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public dispose(): void {
|
|
33
|
+
this.process.off('exit', this.handleExit);
|
|
34
|
+
signals.forEach((signal) => this.process.off(signal, this.processSignal));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
import { isErrnoException } from '@stryker-mutator/util';
|
|
5
|
+
|
|
6
|
+
export const fileUtils = {
|
|
7
|
+
/**
|
|
8
|
+
* Cleans the dir by creating it.
|
|
9
|
+
*/
|
|
10
|
+
async cleanDir(dirName: string): Promise<string | undefined> {
|
|
11
|
+
try {
|
|
12
|
+
await fs.promises.lstat(dirName);
|
|
13
|
+
await fs.promises.rm(dirName, { recursive: true, force: true });
|
|
14
|
+
return fs.promises.mkdir(dirName, { recursive: true });
|
|
15
|
+
} catch {
|
|
16
|
+
return fs.promises.mkdir(dirName, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async exists(fileName: string): Promise<boolean> {
|
|
21
|
+
try {
|
|
22
|
+
await fs.promises.access(fileName);
|
|
23
|
+
return true;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
if (isErrnoException(err) && err.code === 'ENOENT') {
|
|
26
|
+
return false;
|
|
27
|
+
} else {
|
|
28
|
+
// Oops, didn't mean to catch this one ⚾
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Wrapper around the 'import' expression (for testability)
|
|
36
|
+
*/
|
|
37
|
+
importModule(moduleName: string): Promise<unknown> {
|
|
38
|
+
return import(moduleName);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Recursively walks the from directory and copy the content to the target directory synchronously
|
|
43
|
+
* @param from The source directory to move from
|
|
44
|
+
* @param to The target directory to move to
|
|
45
|
+
*/
|
|
46
|
+
moveDirectoryRecursiveSync(from: string, to: string): void {
|
|
47
|
+
if (!fs.existsSync(from)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!fs.existsSync(to)) {
|
|
51
|
+
fs.mkdirSync(to);
|
|
52
|
+
}
|
|
53
|
+
const files = fs.readdirSync(from);
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
const fromFileName = path.join(from, file);
|
|
56
|
+
const toFileName = path.join(to, file);
|
|
57
|
+
const stats = fs.lstatSync(fromFileName);
|
|
58
|
+
if (stats.isFile()) {
|
|
59
|
+
fs.renameSync(fromFileName, toFileName);
|
|
60
|
+
} else {
|
|
61
|
+
this.moveDirectoryRecursiveSync(fromFileName, toFileName);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
fs.rmdirSync(from);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a symlink at `from` that points to `to`
|
|
69
|
+
* @param to The thing you want to point to
|
|
70
|
+
* @param from The thing you want to point from
|
|
71
|
+
*/
|
|
72
|
+
async symlinkJunction(to: string, from: string): Promise<void> {
|
|
73
|
+
await fs.promises.mkdir(path.dirname(from), { recursive: true });
|
|
74
|
+
return fs.promises.symlink(to, from, 'junction');
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Looks for the node_modules folder from basePath up to root.
|
|
79
|
+
* returns the first occurrence of the node_modules, or null of none could be found.
|
|
80
|
+
* @param basePath starting point
|
|
81
|
+
*/
|
|
82
|
+
async findNodeModulesList(
|
|
83
|
+
basePath: string,
|
|
84
|
+
tempDirName?: string,
|
|
85
|
+
): Promise<string[]> {
|
|
86
|
+
const nodeModulesList: string[] = [];
|
|
87
|
+
const dirBfsQueue: string[] = ['.'];
|
|
88
|
+
|
|
89
|
+
let dir: string | undefined;
|
|
90
|
+
while ((dir = dirBfsQueue.pop())) {
|
|
91
|
+
if (path.basename(dir) === tempDirName) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (path.basename(dir) === 'node_modules') {
|
|
96
|
+
nodeModulesList.push(dir);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const parentDir = dir;
|
|
101
|
+
const filesWithType = await fs.promises.readdir(
|
|
102
|
+
path.join(basePath, dir),
|
|
103
|
+
{ withFileTypes: true },
|
|
104
|
+
);
|
|
105
|
+
const dirs = filesWithType
|
|
106
|
+
.filter((file) => file.isDirectory())
|
|
107
|
+
.map((childDir) => path.join(parentDir, childDir.name));
|
|
108
|
+
dirBfsQueue.push(...dirs);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return nodeModulesList;
|
|
112
|
+
},
|
|
113
|
+
};
|