diff --git a/docs/getting-started.md b/docs/getting-started.md index 3bd8bc72c6..e3614e0cfa 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -19,34 +19,15 @@ cd my-project ## 2 Install -The easiest way to get started with Stryker is by installing the stryker-cli globally. -It is a small package which forwards commands to your local Stryker instance. +The easiest way to get started with Stryker is by using the `npm init stryker` command. ```bash -npm install -g stryker-cli +npm init stryker ``` -Optionally, you could also install Stryker directly yourself. +This command will first install Stryker and then run the Stryker initializer. During the initialization, you'll be asked a series of questions to help set up Stryker for your project. -```bash -npm install --save-dev @stryker-mutator/core -``` - -If you choose to not install the stryker-cli, use `npx stryker` (after installing `@stryker-mutator/core` locally) instead of `stryker` for the rest of the quickstart. - ---- - -## 3 Configure - -Run this command to configure Stryker. - -```bash -stryker init -``` - -If you're asked to install Stryker, choose **Yes**. Follow the questionnaire. - -Please let us know if your option is missing here [by opening an issue](https://github.com/stryker-mutator/stryker-js/issues/new). +If you're asked to install Stryker, choose **Yes**. After the init is done, inspect the `stryker.config.mjs` file. @@ -54,18 +35,18 @@ For more information on what these options mean, take a look at [the Configurati --- -## 4 Let's kill some mutants +## 3 Let's kill some mutants Run Stryker to mutation test your project ```bash -stryker run +npx stryker run ``` -Have troubles running Stryker? Try running with trace logging. +Have troubles running Stryker? Try running with trace logging. You can also take a look at our [troubleshooting guide](./troubleshooting.md). ```bash -stryker run --logLevel trace +npx stryker run --logLevel trace ``` You can also have a look at [the Configuration docs page](./configuration.md) for more information about the configuration. diff --git a/package-lock.json b/package-lock.json index a14e1e9207..7167ad272e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1099,6 +1099,15 @@ "regexp-match-indices": "1.0.2" } }, + "node_modules/@cucumber/cucumber/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@cucumber/cucumber/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -1179,6 +1188,18 @@ "node": ">=14" } }, + "node_modules/@cucumber/cucumber/node_modules/has-ansi": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-4.0.1.tgz", + "integrity": "sha512-Qr4RtTm30xvEdqUXbSBVWDu+PrTokJOwe/FU+VdfJPk+MXAPoeOzKpRyrDTnZIJwAkQ4oBLTU53nu0HrkF/Z2A==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@cucumber/cucumber/node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -6998,9 +7019,9 @@ } }, "node_modules/angular-html-parser": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/angular-html-parser/-/angular-html-parser-5.2.0.tgz", - "integrity": "sha512-8S/8g5iMcuGhRmBUJ+xuXm9hdjqIcaky2z52RA7tSyz9tWN0mgiP/JR9+kx/SiS1REJpTXnEKpMCMEeVVIeo3A==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/angular-html-parser/-/angular-html-parser-5.0.2.tgz", + "integrity": "sha512-fov2PwgZDgDsvZXPRa0+lbJyakOZOlFb5eiACR2i6RSn9ad5A+84/SwVfj/dUCbUAHH1ta2uvaoAKEijG93Sfg==", "dependencies": { "tslib": "^2.6.2" }, @@ -7702,18 +7723,6 @@ "node": ">=0.8.0" } }, - "node_modules/babel-code-frame/node_modules/has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/babel-code-frame/node_modules/js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -9558,6 +9567,10 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, + "node_modules/create-stryker": { + "resolved": "packages/create-stryker", + "link": true + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -10138,9 +10151,9 @@ "integrity": "sha512-EmFMarXeqJp9cUKu/QEciEApn0S/xRcpZWuAm32U7NgoZCimjsilKXHRO9saeEW55eHZagIDg6XTUOv32w9pjg==" }, "node_modules/emittery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-1.0.1.tgz", - "integrity": "sha512-2ID6FdrMD9KDLldGesP6317G78K7km/kMcwItRtVFva7I/cSEOIaLpewaUb+YLXVwdAp3Ctfxh/V5zIl1sj7dQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-1.0.2.tgz", + "integrity": "sha512-PqHdP6JJrxiSXQzCAzII77dVsfyGWu+7V0ghqkaCej2shF1cnIPeFE9kKZcVTqvBjrRMDVOdNXKEYcjxkznS1g==", "dev": true, "engines": { "node": ">=14.16" @@ -12673,24 +12686,24 @@ } }, "node_modules/has-ansi": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-4.0.1.tgz", - "integrity": "sha512-Qr4RtTm30xvEdqUXbSBVWDu+PrTokJOwe/FU+VdfJPk+MXAPoeOzKpRyrDTnZIJwAkQ4oBLTU53nu0HrkF/Z2A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", "dev": true, "dependencies": { - "ansi-regex": "^4.1.0" + "ansi-regex": "^2.0.0" }, "engines": { - "node": ">=8" + "node": ">=0.10.0" } }, "node_modules/has-ansi/node_modules/ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { - "node": ">=6" + "node": ">=0.10.0" } }, "node_modules/has-bigints": { @@ -25912,9 +25925,9 @@ } }, "node_modules/weapon-regex": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/weapon-regex/-/weapon-regex-1.3.0.tgz", - "integrity": "sha512-0bvJynFMAedPFDRPPEDXAS4ZvlsRligfvpPPpB7Efgnf6xKw8/O6qHfdYLa0fFuOaHTQuX1sXeRX/DsqRmu7bA==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/weapon-regex/-/weapon-regex-1.1.1.tgz", + "integrity": "sha512-b0RmqduiSUKyKFamrpU+UK78Jm65/6CgKq1zoWFaS9PM7vwNK4RWrjmX1jREs3pLmG7botsgMLVOltxDR7RGRw==" }, "node_modules/webidl-conversions": { "version": "3.0.1", @@ -26604,6 +26617,150 @@ "node": ">= 8" } }, + "packages/create-stryker": { + "version": "8.0.0", + "license": "Apache-2.0", + "dependencies": { + "@stryker-mutator/core": "~8.0.0" + }, + "bin": { + "create-stryker": "dist/src/index.js" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "packages/create-stryker/node_modules/@stryker-mutator/api": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@stryker-mutator/api/-/api-8.0.0.tgz", + "integrity": "sha512-4R8yieczpgOrOBQYq1d1aRJLcgenltpMH9ugtIYPPVmENFUo+mWm9HmaahLe+TVHnJSb4OZ4lvI7dVIhoBaiSQ==", + "dependencies": { + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", + "tslib": "~2.6.0", + "typed-inject": "~4.0.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "packages/create-stryker/node_modules/@stryker-mutator/core": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@stryker-mutator/core/-/core-8.0.0.tgz", + "integrity": "sha512-dyPs60wtLS9vgghgL5a49k/7KOovOnavXzm5SIBBsBJuxoO+5rvGXRohZaqSoZdb0yWIvp+LFdu6qWcdlJPkoQ==", + "dependencies": { + "@stryker-mutator/api": "8.0.0", + "@stryker-mutator/instrumenter": "8.0.0", + "@stryker-mutator/util": "8.0.0", + "ajv": "~8.12.0", + "chalk": "~5.3.0", + "commander": "~11.1.0", + "diff-match-patch": "1.0.5", + "emoji-regex": "~10.3.0", + "execa": "~8.0.0", + "file-url": "~4.0.0", + "get-port": "~7.0.0", + "glob": "~10.3.0", + "inquirer": "~9.2.0", + "lodash.groupby": "~4.6.0", + "log4js": "~6.9.0", + "minimatch": "~9.0.1", + "mutation-testing-elements": "3.0.1", + "mutation-testing-metrics": "3.0.0", + "mutation-testing-report-schema": "3.0.0", + "npm-run-path": "~5.1.0", + "progress": "~2.0.0", + "rxjs": "~7.8.0", + "semver": "^7.3.5", + "source-map": "~0.7.3", + "tree-kill": "~1.2.2", + "tslib": "2.6.2", + "typed-inject": "~4.0.0", + "typed-rest-client": "~1.8.0" + }, + "bin": { + "stryker": "bin/stryker.js" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "packages/create-stryker/node_modules/@stryker-mutator/instrumenter": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@stryker-mutator/instrumenter/-/instrumenter-8.0.0.tgz", + "integrity": "sha512-kS3BdpqDuJeRBDBw2eP68rhUrgtlT5EGERNOwCwUGpfTtUan7y2zX9ZGEblOtMI5yTtyBArFZMtwhPGi+waJ/Q==", + "dependencies": { + "@babel/core": "~7.23.0", + "@babel/generator": "~7.23.0", + "@babel/parser": "~7.23.0", + "@babel/plugin-proposal-decorators": "~7.23.0", + "@babel/preset-typescript": "~7.23.0", + "@stryker-mutator/api": "8.0.0", + "@stryker-mutator/util": "8.0.0", + "angular-html-parser": "~5.0.0", + "semver": "~7.5.4", + "weapon-regex": "~1.1.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "packages/create-stryker/node_modules/@stryker-mutator/util": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@stryker-mutator/util/-/util-8.0.0.tgz", + "integrity": "sha512-geb2JvbYXDs6vOjGV9514PK+L6NiYFQIYhkpKvzfZQWYijNYnLhxXKz/X264a9StTYbGb/ZBADOkzsVde/5zig==" + }, + "packages/create-stryker/node_modules/mutation-testing-elements": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mutation-testing-elements/-/mutation-testing-elements-3.0.1.tgz", + "integrity": "sha512-hsBKkabjD2sjyR2vhdEFPDxZfYLw71geIWjEh4rcZSSQAtyWRfjGf6UbdMjleuyw1ZZTgGt6CImtwRY7s3lrVg==" + }, + "packages/create-stryker/node_modules/mutation-testing-metrics": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mutation-testing-metrics/-/mutation-testing-metrics-3.0.0.tgz", + "integrity": "sha512-WslGuCdpqT+6SpeIahMhLrJl5+YbutlOCFKxuULIkAkaHfsWBK8UCq6euE7PiDEx+R1pYZo//kqRbFIOFmdQug==", + "dependencies": { + "mutation-testing-report-schema": "3.0.0" + } + }, + "packages/create-stryker/node_modules/mutation-testing-report-schema": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mutation-testing-report-schema/-/mutation-testing-report-schema-3.0.0.tgz", + "integrity": "sha512-70+ZPYoyedruSGiEcXQnFiTtIusBYlsL/2EMwfR+/HOqBGxBpmI798spqc86ZVYXPVCL5mt2rWjE1dTQwcjpmQ==" + }, + "packages/create-stryker/node_modules/npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/create-stryker/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/create-stryker/node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "engines": { + "node": ">= 8" + } + }, "packages/cucumber-runner": { "name": "@stryker-mutator/cucumber-runner", "version": "8.1.0", @@ -26671,6 +26828,22 @@ "node": ">=18.0.0" } }, + "packages/instrumenter/node_modules/angular-html-parser": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/angular-html-parser/-/angular-html-parser-5.2.0.tgz", + "integrity": "sha512-8S/8g5iMcuGhRmBUJ+xuXm9hdjqIcaky2z52RA7tSyz9tWN0mgiP/JR9+kx/SiS1REJpTXnEKpMCMEeVVIeo3A==", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">= 14" + } + }, + "packages/instrumenter/node_modules/weapon-regex": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/weapon-regex/-/weapon-regex-1.3.0.tgz", + "integrity": "sha512-0bvJynFMAedPFDRPPEDXAS4ZvlsRligfvpPPpB7Efgnf6xKw8/O6qHfdYLa0fFuOaHTQuX1sXeRX/DsqRmu7bA==" + }, "packages/jasmine-runner": { "name": "@stryker-mutator/jasmine-runner", "version": "8.1.0", diff --git a/packages/create-stryker/README.md b/packages/create-stryker/README.md new file mode 100644 index 0000000000..f1f23f7ce3 --- /dev/null +++ b/packages/create-stryker/README.md @@ -0,0 +1,7 @@ +[![Slack Chat](https://img.shields.io/badge/slack-chat-brightgreen.svg?logo=slack)](https://join.slack.com/t/stryker-mutator/shared_invite/enQtOTUyMTYyNTg1NDQ0LTU4ODNmZDlmN2I3MmEyMTVhYjZlYmJkOThlNTY3NTM1M2QxYmM5YTM3ODQxYmJjY2YyYzllM2RkMmM1NjNjZjM) + +![Stryker](https://github.com/stryker-mutator/stryker-js/raw/master/stryker-80x80.png) + +# Create Stryker + +An initialer for StrykerJS! Run it with: `npm init stryker`. See [getting started](../../docs/getting-started.md) for more information. \ No newline at end of file diff --git a/packages/create-stryker/package.json b/packages/create-stryker/package.json new file mode 100644 index 0000000000..9ab0ec22da --- /dev/null +++ b/packages/create-stryker/package.json @@ -0,0 +1,42 @@ +{ + "name": "create-stryker", + "version": "8.0.0", + "description": "Initializer for StrykerJS", + "type": "module", + "files": [ + "dist/src/index.js" + ], + "scripts": { + "start": "tsc -b && node ./dist/src/index.js", + "build": "tsc -b" + }, + "repository": { + "type": "git", + "url": "https://github.com/stryker-mutator/stryker-js.git", + "directory": "packages/create-stryker" + }, + "engines": { + "node": ">=18.0.0" + }, + "keywords": [ + "mutation testing", + "mutation", + "testing", + "js", + "stryker", + "initialize" + ], + "author": "Lex Krooswijk ", + "contributors": [ + "Nico Jansen " + ], + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/stryker-mutator/stryker-js/issues" + }, + "homepage": "https://stryker-mutator.io/", + "bin": "dist/src/index.js", + "dependencies": { + "@stryker-mutator/core": "~8.1.0" + } +} diff --git a/packages/create-stryker/src/index.ts b/packages/create-stryker/src/index.ts new file mode 100644 index 0000000000..0f857208cf --- /dev/null +++ b/packages/create-stryker/src/index.ts @@ -0,0 +1,4 @@ +#!/usr/bin/env node +import { StrykerCli } from '@stryker-mutator/core'; + +new StrykerCli(['', '', 'init']).run(); diff --git a/packages/create-stryker/tsconfig.json b/packages/create-stryker/tsconfig.json new file mode 100644 index 0000000000..9ed3712bb2 --- /dev/null +++ b/packages/create-stryker/tsconfig.json @@ -0,0 +1,8 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.src.json" + } + ] +} diff --git a/packages/create-stryker/tsconfig.src.json b/packages/create-stryker/tsconfig.src.json new file mode 100644 index 0000000000..3040453b3c --- /dev/null +++ b/packages/create-stryker/tsconfig.src.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.settings.json", + "compilerOptions": { + "outDir": "dist/src", + "rootDir": "src" + }, + "include": ["src"], + "references": [] +} diff --git a/tsconfig.json b/tsconfig.json index 26794bc22d..c8c12225c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ { "path": "packages/api" }, { "path": "packages/util" }, { "path": "packages/core" }, + { "path": "packages/create-stryker" }, { "path": "packages/instrumenter" }, { "path": "packages/jasmine-runner" }, { "path": "packages/jest-runner" }, diff --git a/workspace.code-workspace b/workspace.code-workspace index 49b78998db..e40a5297c7 100644 --- a/workspace.code-workspace +++ b/workspace.code-workspace @@ -4,6 +4,9 @@ "name": "core", "path": "packages/core" }, + { + "path": "packages/create-stryker" + }, { "name": "instrumenter", "path": "packages/instrumenter"