From 357def23b1ef3bcbdde34fef83094d2468e9d605 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Tue, 2 Apr 2024 00:15:48 -0500 Subject: [PATCH] feat(config): determined extension based on project dialect --- .eslintrc.yml | 8 ++ .remarkrc.json | 25 +++- README.md | 3 +- example.js | 5 +- package-lock.json | 136 +++++++----------- package.json | 1 + src/config-scaffolder.js | 13 ++ src/config-scaffolder.test.js | 32 +++++ src/scaffolder.js | 5 +- src/scaffolder.test.js | 19 ++- templates/{config.ts => config.js} | 0 test/integration/features/scaffolder.feature | 13 +- .../features/step_definitions/common-steps.js | 2 +- .../features/step_definitions/config-steps.js | 4 +- .../step_definitions/dialect-steps.js | 5 + vitest.config.js | 8 ++ vitest.config.ts | 7 - 17 files changed, 170 insertions(+), 116 deletions(-) create mode 100644 src/config-scaffolder.js create mode 100644 src/config-scaffolder.test.js rename templates/{config.ts => config.js} (100%) create mode 100644 test/integration/features/step_definitions/dialect-steps.js create mode 100644 vitest.config.js delete mode 100644 vitest.config.ts diff --git a/.eslintrc.yml b/.eslintrc.yml index e7d1153..da5c500 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,3 +4,11 @@ extends: - '@form8ion' - '@form8ion/cucumber' - '@form8ion/mocha' + +overrides: + - files: + - vitest.config.js + - templates/config.js + rules: + import/no-unresolved: off + no-console: off diff --git a/.remarkrc.json b/.remarkrc.json index 031522b..52accbb 100644 --- a/.remarkrc.json +++ b/.remarkrc.json @@ -1 +1,24 @@ -{"settings":{"listItemIndent":1,"emphasis":"_","strong":"_","bullet":"*","incrementListMarker":false},"plugins":["@form8ion/remark-lint-preset",["remark-toc",{"tight":true}],["remark-usage",{"heading":"example"}]]} \ No newline at end of file +{ + "settings": { + "listItemIndent": "one", + "emphasis": "_", + "strong": "_", + "bullet": "*", + "incrementListMarker": false + }, + "plugins": [ + "@form8ion/remark-lint-preset", + [ + "remark-toc", + { + "tight": true + } + ], + [ + "remark-usage", + { + "heading": "example" + } + ] + ] +} diff --git a/README.md b/README.md index ef64fa1..2af8917 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ $ npm install @form8ion/vitest --save-prod #### Import ```javascript +import {dialects} from '@form8ion/javascript-core'; import {scaffold} from '@form8ion/vitest'; ``` @@ -53,7 +54,7 @@ import {scaffold} from '@form8ion/vitest'; ```javascript (async () => { - await scaffold({projectRoot: process.cwd()}); + await scaffold({projectRoot: process.cwd(), dialect: dialects.ESM}); })(); ``` diff --git a/example.js b/example.js index 5040594..7785950 100644 --- a/example.js +++ b/example.js @@ -1,13 +1,14 @@ // #### Import // remark-usage-ignore-next import stubbedFs from 'mock-fs'; +import {dialects} from '@form8ion/javascript-core'; import {scaffold} from './lib/index.mjs'; // remark-usage-ignore-next -stubbedFs({templates: {'canary-test.js': '', 'config.ts': ''}}); +stubbedFs({templates: {'canary-test.js': '', 'config.js': ''}}); // #### Execute (async () => { - await scaffold({projectRoot: process.cwd()}); + await scaffold({projectRoot: process.cwd(), dialect: dialects.ESM}); })(); diff --git a/package-lock.json b/package-lock.json index 88fb46b..a0b8e7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0-semantically-released", "license": "MIT", "dependencies": { + "@form8ion/javascript-core": "^11.0.0", "filedirname": "^3.0.0", "make-dir": "^4.0.0" }, @@ -1652,7 +1653,6 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/@form8ion/core/-/core-4.2.1.tgz", "integrity": "sha512-Xf49rggOun4EL05kUYeAOWg0KS1ziPcGvp5YdiR/M2TUyA42DE6+jNRWElX1npOu2Qo7l6qONZCrO7DlNOBALg==", - "dev": true, "dependencies": { "@hapi/hoek": "^11.0.2", "@travi/cli-messages": "^1.0.5", @@ -1702,6 +1702,39 @@ "node": "^16.14 || >=18" } }, + "node_modules/@form8ion/execa-wrapper": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@form8ion/execa-wrapper/-/execa-wrapper-1.0.0.tgz", + "integrity": "sha512-GD4ShDFigPMtlrFN5wNqdUyhj7oxq77Zr+StSoH1zXLevDvGMnWXFH4setwcMlF7W+X0xvYugoqrqIjLcfOIEg==", + "dependencies": { + "execa": "^5.1.1" + } + }, + "node_modules/@form8ion/javascript-core": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@form8ion/javascript-core/-/javascript-core-11.0.0.tgz", + "integrity": "sha512-kZsouCrhKWKt+WYGqhPo3viEhIpPe8o3BBK1pwpcwnscOddGhPzuhpKubpyL7yD8V3/3ondOSCZkIYzxUB0Rew==", + "dependencies": { + "@form8ion/core": "^4.2.0", + "@form8ion/execa-wrapper": "^1.0.0-alpha.1", + "@form8ion/overridable-prompts": "^1.1.0", + "@hapi/hoek": "^11.0.0", + "@travi/cli-messages": "^1.0.4", + "deepmerge": "^4.2.2", + "semver": "^7.3.5" + }, + "engines": { + "node": "^18.17 || >=20.6.1" + } + }, + "node_modules/@form8ion/overridable-prompts": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@form8ion/overridable-prompts/-/overridable-prompts-1.2.0.tgz", + "integrity": "sha512-Db4+RAHc0dkvlAviADT6aOXQhDhjoduAkytQZZU5Z8LiwDQg5BBjENk9HwptX6PEYbLuHPHRhqQ30djduf9mqQ==", + "dependencies": { + "inquirer": "^8.0.0" + } + }, "node_modules/@form8ion/remark-lint-preset": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/@form8ion/remark-lint-preset/-/remark-lint-preset-6.0.2.tgz", @@ -1732,8 +1765,7 @@ "node_modules/@hapi/hoek": { "version": "11.0.4", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-11.0.4.tgz", - "integrity": "sha512-PnsP5d4q7289pS2T2EgGz147BFJ2Jpb4yrEdkpz2IhgEUzos1S7HTl7ezWh1yfYzYlj89KzLdCRkqsP6SIryeQ==", - "dev": true + "integrity": "sha512-PnsP5d4q7289pS2T2EgGz147BFJ2Jpb4yrEdkpz2IhgEUzos1S7HTl7ezWh1yfYzYlj89KzLdCRkqsP6SIryeQ==" }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", @@ -3309,7 +3341,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@travi/cli-messages/-/cli-messages-1.1.1.tgz", "integrity": "sha512-R3PRqMPUbgzV+yuhP0bH39Y3K8HnzA2Bp+iDJS8OYXTujfhHCG9FGuC7sVq1vCeUfjVbw0L9MpOb3w50lqqddw==", - "dev": true, "dependencies": { "chalk": "^4.0.0", "log-symbols": "4.1.0" @@ -3936,7 +3967,6 @@ "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", - "dev": true, "dependencies": { "type-fest": "^0.21.3" }, @@ -3951,7 +3981,6 @@ "version": "0.21.3", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", - "dev": true, "engines": { "node": ">=10" }, @@ -3972,7 +4001,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -4163,8 +4191,7 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/array-buffer-byte-length": { "version": "1.0.1", @@ -4613,7 +4640,6 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, "funding": [ { "type": "github", @@ -4685,7 +4711,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "dev": true, "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", @@ -4812,7 +4837,6 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, "funding": [ { "type": "github", @@ -5128,7 +5152,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -5144,7 +5167,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -5181,8 +5203,7 @@ "node_modules/chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" }, "node_modules/chdir-promise": { "version": "0.6.2", @@ -5328,7 +5349,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "dev": true, "dependencies": { "restore-cursor": "^3.1.0" }, @@ -5340,7 +5360,6 @@ "version": "2.9.2", "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", - "dev": true, "engines": { "node": ">=6" }, @@ -5388,7 +5407,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", - "dev": true, "engines": { "node": ">= 10" } @@ -5411,7 +5429,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", - "dev": true, "engines": { "node": ">=0.8" } @@ -5459,7 +5476,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "dependencies": { "color-name": "~1.1.4" }, @@ -5470,8 +5486,7 @@ "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/color-support": { "version": "1.1.3", @@ -5823,7 +5838,6 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -6174,7 +6188,6 @@ "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -6183,7 +6196,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", - "dev": true, "dependencies": { "clone": "^1.0.2" }, @@ -6399,8 +6411,7 @@ "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/encoding": { "version": "0.1.13", @@ -7127,7 +7138,6 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", @@ -7201,7 +7211,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "dev": true, "dependencies": { "chardet": "^0.7.0", "iconv-lite": "^0.4.24", @@ -7215,7 +7224,6 @@ "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, "dependencies": { "os-tmpdir": "~1.0.2" }, @@ -7298,7 +7306,6 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", - "dev": true, "dependencies": { "escape-string-regexp": "^1.0.5" }, @@ -7313,7 +7320,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, "engines": { "node": ">=0.8.0" } @@ -8556,7 +8562,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true, "engines": { "node": ">=10" }, @@ -9289,7 +9294,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, "engines": { "node": ">=8" } @@ -9448,7 +9452,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true, "engines": { "node": ">=10.17.0" } @@ -9481,7 +9484,6 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -9493,7 +9495,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, "funding": [ { "type": "github", @@ -9655,8 +9656,7 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/ini": { "version": "2.0.0", @@ -9671,7 +9671,6 @@ "version": "8.2.5", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.5.tgz", "integrity": "sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ==", - "dev": true, "dependencies": { "ansi-escapes": "^4.2.1", "chalk": "^4.1.1", @@ -9921,7 +9920,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, "engines": { "node": ">=8" } @@ -9968,7 +9966,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", - "dev": true, "engines": { "node": ">=8" } @@ -10122,7 +10119,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, "engines": { "node": ">=8" }, @@ -10197,7 +10193,6 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, "engines": { "node": ">=10" }, @@ -10247,8 +10242,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/istanbul-lib-coverage": { "version": "3.2.2", @@ -11119,7 +11113,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, "dependencies": { "argparse": "^2.0.1" }, @@ -11515,8 +11508,7 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/lodash.camelcase": { "version": "4.3.0", @@ -11594,7 +11586,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" @@ -13053,8 +13044,7 @@ "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, "node_modules/merge2": { "version": "1.4.1", @@ -13651,7 +13641,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, "engines": { "node": ">=6" } @@ -14042,8 +14031,7 @@ "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", - "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", - "dev": true + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, "node_modules/mz": { "version": "2.7.0", @@ -14529,7 +14517,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, "dependencies": { "path-key": "^3.0.0" }, @@ -14682,7 +14669,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, "dependencies": { "mimic-fn": "^2.1.0" }, @@ -14730,7 +14716,6 @@ "version": "5.4.1", "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", - "dev": true, "dependencies": { "bl": "^4.1.0", "chalk": "^4.1.0", @@ -14753,7 +14738,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -14979,7 +14963,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "engines": { "node": ">=8" } @@ -15902,7 +15885,6 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -18410,7 +18392,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "dev": true, "dependencies": { "onetime": "^5.1.0", "signal-exit": "^3.0.2" @@ -18565,7 +18546,6 @@ "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true, "engines": { "node": ">=0.12.0" } @@ -18597,7 +18577,6 @@ "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", - "dev": true, "dependencies": { "tslib": "^2.1.0" } @@ -18636,7 +18615,6 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, "funding": [ { "type": "github", @@ -18678,8 +18656,7 @@ "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/sax": { "version": "1.3.0", @@ -18786,7 +18763,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -18798,7 +18774,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "engines": { "node": ">=8" } @@ -18839,8 +18814,7 @@ "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, "node_modules/sigstore": { "version": "1.9.0", @@ -19069,7 +19043,6 @@ "version": "6.9.0", "resolved": "https://registry.npmjs.org/spdx-license-list/-/spdx-license-list-6.9.0.tgz", "integrity": "sha512-L2jl5vc2j6jxWcNCvcVj/BW9A8yGIG02Dw+IUw0ZxDM70f7Ylf5Hq39appV1BI9yxyWQRpq2TQ1qaXvf+yjkqA==", - "dev": true, "engines": { "node": ">=8" }, @@ -19161,7 +19134,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -19193,7 +19165,6 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -19271,7 +19242,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -19305,7 +19275,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, "engines": { "node": ">=8" } @@ -19323,7 +19292,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true, "engines": { "node": ">=6" } @@ -19560,8 +19528,7 @@ "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", - "dev": true + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, "node_modules/through2": { "version": "4.0.2", @@ -19731,8 +19698,7 @@ "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", - "dev": true + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/tuf-js": { "version": "1.1.7", @@ -20549,8 +20515,7 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/uuid": { "version": "9.0.1", @@ -21288,7 +21253,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", - "dev": true, "dependencies": { "defaults": "^1.0.3" } @@ -21303,7 +21267,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -21408,7 +21371,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", diff --git a/package.json b/package.json index ac81606..f3e0751 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "provenance": true }, "dependencies": { + "@form8ion/javascript-core": "^11.0.0", "filedirname": "^3.0.0", "make-dir": "^4.0.0" }, diff --git a/src/config-scaffolder.js b/src/config-scaffolder.js new file mode 100644 index 0000000..a050c29 --- /dev/null +++ b/src/config-scaffolder.js @@ -0,0 +1,13 @@ +import {promises as fs} from 'node:fs'; +import path from 'node:path'; +import filedirname from 'filedirname'; +import {dialects} from '@form8ion/javascript-core'; + +const [, __dirname] = filedirname(); + +export default async function ({projectRoot, dialect}) { + await fs.copyFile( + path.resolve(__dirname, '..', 'templates', 'config.js'), + `${projectRoot}/vitest.config.${dialects.TYPESCRIPT === dialect ? 'ts' : 'js'}` + ); +} diff --git a/src/config-scaffolder.test.js b/src/config-scaffolder.test.js new file mode 100644 index 0000000..2c02325 --- /dev/null +++ b/src/config-scaffolder.test.js @@ -0,0 +1,32 @@ +import {promises as fs} from 'node:fs'; +import path from 'node:path'; +import {dialects} from '@form8ion/javascript-core'; + +import any from '@travi/any'; +import {describe, vi, expect, it} from 'vitest'; + +import scaffoldConfig from './config-scaffolder.js'; + +vi.mock('node:fs'); + +describe('config scaffolder', () => { + const projectRoot = any.string(); + + it('should create the config file for a typescript project', async () => { + await scaffoldConfig({projectRoot, dialect: dialects.TYPESCRIPT}); + + expect(fs.copyFile).toBeCalledWith( + path.resolve(__dirname, '..', 'templates', 'config.js'), + `${projectRoot}/vitest.config.ts` + ); + }); + + it('should create the config file for an ESM project', async () => { + await scaffoldConfig({projectRoot, dialect: dialects.ESM}); + + expect(fs.copyFile).toBeCalledWith( + path.resolve(__dirname, '..', 'templates', 'config.js'), + `${projectRoot}/vitest.config.js` + ); + }); +}); diff --git a/src/scaffolder.js b/src/scaffolder.js index c1b1dd7..d51465a 100644 --- a/src/scaffolder.js +++ b/src/scaffolder.js @@ -3,15 +3,16 @@ import {promises as fs} from 'node:fs'; import filedirname from 'filedirname'; import makeDir from '../thirdparty-wrappers/make-dir.js'; +import scaffoldConfig from './config-scaffolder.js'; const [, __dirname] = filedirname(); -export default async function ({projectRoot}) { +export default async function ({projectRoot, dialect}) { const createdSrcDirectory = await makeDir(`${projectRoot}/src`); await Promise.all([ fs.copyFile(path.resolve(__dirname, '..', 'templates', 'canary-test.js'), `${createdSrcDirectory}/canary.test.js`), - fs.copyFile(path.resolve(__dirname, '..', 'templates', 'config.ts'), `${projectRoot}/vitest.config.ts`) + scaffoldConfig({projectRoot, dialect}) ]); return { diff --git a/src/scaffolder.test.js b/src/scaffolder.test.js index 176f3ae..0beec10 100644 --- a/src/scaffolder.test.js +++ b/src/scaffolder.test.js @@ -1,13 +1,16 @@ import path from 'path'; -import {promises as fs} from 'fs'; +import {promises as fs} from 'node:fs'; -import {describe, it, assert, expect, vi, beforeEach, afterEach} from 'vitest'; +import {assert, beforeEach, describe, expect, it, vi} from 'vitest'; import any from '@travi/any'; import {when} from 'jest-when'; import * as makeDir from '../thirdparty-wrappers/make-dir.js'; +import scaffoldConfig from './config-scaffolder.js'; import scaffold from './scaffolder.js'; +vi.mock('./config-scaffolder.js'); + describe('scaffolder', () => { const projectRoot = any.string(); const pathToCreatedSrcDirectory = any.string(); @@ -19,21 +22,15 @@ describe('scaffolder', () => { fs.copyFile.mockImplementation(() => Promise.resolve()); }); - afterEach(() => { - vi.clearAllMocks(); - }); - it('that core details are defined', async () => { - const {devDependencies, scripts, testFilenamePattern} = await scaffold({projectRoot}); + const dialect = any.word(); + const {devDependencies, scripts, testFilenamePattern} = await scaffold({projectRoot, dialect}); expect(fs.copyFile).toBeCalledWith( path.resolve(__dirname, '..', 'templates', 'canary-test.js'), `${pathToCreatedSrcDirectory}/canary.test.js` ); - expect(fs.copyFile).toBeCalledWith( - path.resolve(__dirname, '..', 'templates', 'config.ts'), - `${projectRoot}/vitest.config.ts` - ); + expect(scaffoldConfig).toBeCalledWith({projectRoot, dialect}); assert.deepEqual(scripts, {'test:unit:base': 'DEBUG=any vitest run'}); assert.deepEqual(devDependencies, ['vitest', 'jest-when']); diff --git a/templates/config.ts b/templates/config.js similarity index 100% rename from templates/config.ts rename to templates/config.js diff --git a/test/integration/features/scaffolder.feature b/test/integration/features/scaffolder.feature index c6a609a..e06c932 100644 --- a/test/integration/features/scaffolder.feature +++ b/test/integration/features/scaffolder.feature @@ -1,8 +1,17 @@ Feature: Scaffolder - Scenario: Scaffold + Scenario: Scaffold a TypeScript project + Given the project dialect is "typescript" When the project is scaffolded Then scripts are defined And dependencies are listed And a canary test file exists - And vitest is configured + And vitest is configured using a "ts" extension + + Scenario: Scaffold an ESM project + Given the project dialect is "esm" + When the project is scaffolded + Then scripts are defined + And dependencies are listed + And a canary test file exists + And vitest is configured using a "js" extension diff --git a/test/integration/features/step_definitions/common-steps.js b/test/integration/features/step_definitions/common-steps.js index 85ac99a..d62bf04 100644 --- a/test/integration/features/step_definitions/common-steps.js +++ b/test/integration/features/step_definitions/common-steps.js @@ -22,5 +22,5 @@ When('the project is scaffolded', async function () { templates: stubbedTemplates }); - this.result = await scaffold({projectRoot: process.cwd()}); + this.result = await scaffold({projectRoot: process.cwd(), dialect: this.dialect}); }); diff --git a/test/integration/features/step_definitions/config-steps.js b/test/integration/features/step_definitions/config-steps.js index 974f5d5..de8e3c3 100644 --- a/test/integration/features/step_definitions/config-steps.js +++ b/test/integration/features/step_definitions/config-steps.js @@ -3,8 +3,8 @@ import {promises as fs} from 'node:fs'; import {Then} from '@cucumber/cucumber'; import {assert} from 'chai'; -Then('vitest is configured', async function () { - const vitestConfig = await fs.readFile(`${process.cwd()}/vitest.config.ts`, 'utf-8'); +Then('vitest is configured using a {string} extension', async function (extension) { + const vitestConfig = await fs.readFile(`${process.cwd()}/vitest.config.${extension}`, 'utf-8'); assert.equal( vitestConfig, diff --git a/test/integration/features/step_definitions/dialect-steps.js b/test/integration/features/step_definitions/dialect-steps.js new file mode 100644 index 0000000..cfced91 --- /dev/null +++ b/test/integration/features/step_definitions/dialect-steps.js @@ -0,0 +1,5 @@ +import {Given} from '@cucumber/cucumber'; + +Given('the project dialect is {string}', async function (dialect) { + this.dialect = dialect; +}); diff --git a/vitest.config.js b/vitest.config.js new file mode 100644 index 0000000..e01f859 --- /dev/null +++ b/vitest.config.js @@ -0,0 +1,8 @@ +import {defineConfig} from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + restoreMocks: true + } +}); diff --git a/vitest.config.ts b/vitest.config.ts deleted file mode 100644 index d7c175f..0000000 --- a/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import {defineConfig} from 'vitest/config' - -export default defineConfig({ - test: { - globals: true, - }, -})