diff --git a/package-lock.json b/package-lock.json index 0b7337d..8ca31bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,19 @@ { "name": "twify", - "version": "0.4.2", + "version": "0.4.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "twify", - "version": "0.4.2", + "version": "0.4.3", "license": "MIT", "dependencies": { "chalk": "^5.0.1", - "commander": "^9.3.0", + "commander": "^10.0.0", "enquirer": "^2.3.6", - "fs-extra": "^10.1.0", + "fs-extra": "^11.1.0", + "glob": "^8.1.0", "gradient-string": "^2.0.1", "jscodeshift": "^0.14.0", "ora": "^6.1.0" @@ -22,6 +23,7 @@ }, "devDependencies": { "@types/fs-extra": "^9.0.13", + "@types/glob": "^8.0.1", "@types/gradient-string": "^1.1.2", "@types/jscodeshift": "^0.11.5", "@types/node": "^18.0.0", @@ -35,7 +37,7 @@ "microbundle": "^0.15.0", "prettier": "^2.6.2", "typescript": "^4.6.4", - "vitest": "^0.25.1" + "vitest": "^0.27.2" } }, "node_modules/@ampproject/remapping": { @@ -2455,6 +2457,26 @@ "rollup": "^2.30.0" } }, + "node_modules/@rollup/plugin-commonjs/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@rollup/plugin-json": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", @@ -2577,6 +2599,16 @@ "@types/node": "*" } }, + "node_modules/@types/glob": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.1.tgz", + "integrity": "sha512-8bVUjXZvJacUFkJXHdyZ9iH1Eaj5V7I8c4NdH5sQJsdXkqT4CA5Dhb4yb4VE/3asyx4L9ayZr1NIhTsWHczmMw==", + "dev": true, + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "node_modules/@types/gradient-string": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@types/gradient-string/-/gradient-string-1.1.2.tgz", @@ -2603,6 +2635,12 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true + }, "node_modules/@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -3000,18 +3038,6 @@ "url": "https://github.com/sponsors/antfu" } }, - "node_modules/@vitest/coverage-istanbul/node_modules/strip-literal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.0.tgz", - "integrity": "sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==", - "dev": true, - "dependencies": { - "acorn": "^8.8.1" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, "node_modules/@vitest/coverage-istanbul/node_modules/vitest": { "version": "0.26.2", "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.26.2.tgz", @@ -3481,6 +3507,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -3670,11 +3705,11 @@ "license": "MIT" }, "node_modules/commander": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", - "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz", + "integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==", "engines": { - "node": "^12.20.0 || >=14" + "node": ">=14" } }, "node_modules/commondir": { @@ -4768,17 +4803,16 @@ } }, "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "license": "MIT", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz", + "integrity": "sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==", "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" }, "engines": { - "node": ">=12" + "node": ">=14.14" } }, "node_modules/fs.realpath": { @@ -4907,20 +4941,18 @@ } }, "node_modules/glob": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.2.tgz", - "integrity": "sha512-NzDgHDiJwKYByLrL5lONmQFpK/2G78SMMfo+E9CuGlX4IkvfKDsiQSNPwAYxEy+e6p7ZQ3uslSLlwlJcqezBmQ==", - "license": "ISC", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": "*" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -4939,6 +4971,25 @@ "node": ">=10.13.0" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -6524,15 +6575,15 @@ } }, "node_modules/mlly": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.0.0.tgz", - "integrity": "sha512-QL108Hwt+u9bXdWgOI0dhzZfACovn5Aen4Xvc8Jasd9ouRH4NjnrXEiyP3nVvJo91zPlYjVRckta0Nt2zfoR6g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.1.0.tgz", + "integrity": "sha512-cwzBrBfwGC1gYJyfcy8TcZU1f+dbH/T+TuOhtYP2wLv/Fb51/uV7HJQfBPtEupZ2ORLRU1EKFS/QfS3eo9+kBQ==", "dev": true, "dependencies": { "acorn": "^8.8.1", "pathe": "^1.0.0", - "pkg-types": "^1.0.0", - "ufo": "^1.0.0" + "pkg-types": "^1.0.1", + "ufo": "^1.0.1" } }, "node_modules/mlly/node_modules/pathe": { @@ -6947,8 +6998,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "license": "MIT", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "engines": { "node": ">=0.10.0" } @@ -8031,6 +8081,26 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/rollup": { "version": "2.77.3", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.77.3.tgz", @@ -8241,6 +8311,20 @@ "node": ">=8" } }, + "node_modules/rollup-plugin-typescript2/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/rollup-plugin-typescript2/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -8489,6 +8573,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -8548,6 +8638,12 @@ "dev": true, "license": "MIT" }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -8683,12 +8779,12 @@ } }, "node_modules/strip-literal": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-0.4.2.tgz", - "integrity": "sha512-pv48ybn4iE1O9RLgCAN0iU4Xv7RlBTiit6DKmMiErbs9x1wH6vXBs45tWc0H5wUIF6TLTrKweqkmYF/iraQKNw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.0.tgz", + "integrity": "sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==", "dev": true, "dependencies": { - "acorn": "^8.8.0" + "acorn": "^8.8.1" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -8786,6 +8882,25 @@ "node": ">=6.0.0" } }, + "node_modules/temp/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/temp/node_modules/rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -8838,6 +8953,26 @@ "node": ">=8" } }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -9518,25 +9653,29 @@ } }, "node_modules/vitest": { - "version": "0.25.3", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.25.3.tgz", - "integrity": "sha512-/UzHfXIKsELZhL7OaM2xFlRF8HRZgAHtPctacvNK8H4vOcbJJAMEgbWNGSAK7Y9b1NBe5SeM7VTuz2RsTHFJJA==", + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.27.2.tgz", + "integrity": "sha512-y7tdsL2uaQy+KF18AlmNHZe29ukyFytlxrpSTwwmgLE2XHR/aPucJP9FLjWoqjgqFlXzRAjHlFJLU+HDyI/OsA==", "dev": true, "dependencies": { - "@types/chai": "^4.3.3", + "@types/chai": "^4.3.4", "@types/chai-subset": "^1.3.3", "@types/node": "*", - "acorn": "^8.8.0", + "acorn": "^8.8.1", "acorn-walk": "^8.2.0", - "chai": "^4.3.6", + "cac": "^6.7.14", + "chai": "^4.3.7", "debug": "^4.3.4", "local-pkg": "^0.4.2", + "picocolors": "^1.0.0", "source-map": "^0.6.1", - "strip-literal": "^0.4.2", + "strip-literal": "^1.0.0", "tinybench": "^2.3.1", "tinypool": "^0.3.0", "tinyspy": "^1.0.2", - "vite": "^3.0.0" + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.27.2", + "why-is-node-running": "^2.2.2" }, "bin": { "vitest": "vitest.mjs" @@ -9572,6 +9711,31 @@ } } }, + "node_modules/vitest/node_modules/vite-node": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.27.2.tgz", + "integrity": "sha512-IDwuVhslF10qCnWOGJui7/2KksAOBHi+UbVo6Pqt4f5lgn+kS2sVvYDsETRG5PSuslisGB5CFGvb9I6FQgymBQ==", + "dev": true, + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.1.0", + "pathe": "^0.2.0", + "picocolors": "^1.0.0", + "source-map": "^0.6.1", + "source-map-support": "^0.5.21", + "vite": "^3.0.0 || ^4.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": ">=v14.16.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -9613,6 +9777,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dev": true, + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -11176,6 +11356,22 @@ "is-reference": "^1.2.1", "magic-string": "^0.25.7", "resolve": "^1.17.0" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "@rollup/plugin-json": { @@ -11274,6 +11470,16 @@ "@types/node": "*" } }, + "@types/glob": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.1.tgz", + "integrity": "sha512-8bVUjXZvJacUFkJXHdyZ9iH1Eaj5V7I8c4NdH5sQJsdXkqT4CA5Dhb4yb4VE/3asyx4L9ayZr1NIhTsWHczmMw==", + "dev": true, + "requires": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "@types/gradient-string": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@types/gradient-string/-/gradient-string-1.1.2.tgz", @@ -11299,6 +11505,12 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true + }, "@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -11545,15 +11757,6 @@ "vitest": "0.26.2" }, "dependencies": { - "strip-literal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.0.tgz", - "integrity": "sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==", - "dev": true, - "requires": { - "acorn": "^8.8.1" - } - }, "vitest": { "version": "0.26.2", "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.26.2.tgz", @@ -11841,6 +12044,12 @@ "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true }, + "cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true + }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -11964,9 +12173,9 @@ "dev": true }, "commander": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", - "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==" + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz", + "integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==" }, "commondir": { "version": "1.0.1", @@ -12726,9 +12935,9 @@ "dev": true }, "fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz", + "integrity": "sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==", "requires": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", @@ -12817,16 +13026,33 @@ } }, "glob": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.2.tgz", - "integrity": "sha512-NzDgHDiJwKYByLrL5lONmQFpK/2G78SMMfo+E9CuGlX4IkvfKDsiQSNPwAYxEy+e6p7ZQ3uslSLlwlJcqezBmQ==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "glob-parent": { @@ -13904,15 +14130,15 @@ } }, "mlly": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.0.0.tgz", - "integrity": "sha512-QL108Hwt+u9bXdWgOI0dhzZfACovn5Aen4Xvc8Jasd9ouRH4NjnrXEiyP3nVvJo91zPlYjVRckta0Nt2zfoR6g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.1.0.tgz", + "integrity": "sha512-cwzBrBfwGC1gYJyfcy8TcZU1f+dbH/T+TuOhtYP2wLv/Fb51/uV7HJQfBPtEupZ2ORLRU1EKFS/QfS3eo9+kBQ==", "dev": true, "requires": { "acorn": "^8.8.1", "pathe": "^1.0.0", - "pkg-types": "^1.0.0", - "ufo": "^1.0.0" + "pkg-types": "^1.0.1", + "ufo": "^1.0.1" }, "dependencies": { "pathe": { @@ -14185,7 +14411,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" }, "path-key": { "version": "3.1.1", @@ -14838,6 +15064,22 @@ "dev": true, "requires": { "glob": "^7.1.3" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "rollup": { @@ -14990,6 +15232,17 @@ "path-exists": "^4.0.0" } }, + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -15163,6 +15416,12 @@ "object-inspect": "^1.9.0" } }, + "siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true + }, "signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -15206,6 +15465,12 @@ "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", "dev": true }, + "stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true + }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -15300,12 +15565,12 @@ "dev": true }, "strip-literal": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-0.4.2.tgz", - "integrity": "sha512-pv48ybn4iE1O9RLgCAN0iU4Xv7RlBTiit6DKmMiErbs9x1wH6vXBs45tWc0H5wUIF6TLTrKweqkmYF/iraQKNw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.0.tgz", + "integrity": "sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==", "dev": true, "requires": { - "acorn": "^8.8.0" + "acorn": "^8.8.1" } }, "style-inject": { @@ -15368,6 +15633,19 @@ "rimraf": "~2.6.2" }, "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -15407,6 +15685,22 @@ "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", "minimatch": "^3.0.4" + }, + "dependencies": { + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "text-table": { @@ -15786,25 +16080,47 @@ } }, "vitest": { - "version": "0.25.3", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.25.3.tgz", - "integrity": "sha512-/UzHfXIKsELZhL7OaM2xFlRF8HRZgAHtPctacvNK8H4vOcbJJAMEgbWNGSAK7Y9b1NBe5SeM7VTuz2RsTHFJJA==", + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.27.2.tgz", + "integrity": "sha512-y7tdsL2uaQy+KF18AlmNHZe29ukyFytlxrpSTwwmgLE2XHR/aPucJP9FLjWoqjgqFlXzRAjHlFJLU+HDyI/OsA==", "dev": true, "requires": { - "@types/chai": "^4.3.3", + "@types/chai": "^4.3.4", "@types/chai-subset": "^1.3.3", "@types/node": "*", - "acorn": "^8.8.0", + "acorn": "^8.8.1", "acorn-walk": "^8.2.0", - "chai": "^4.3.6", + "cac": "^6.7.14", + "chai": "^4.3.7", "debug": "^4.3.4", "local-pkg": "^0.4.2", + "picocolors": "^1.0.0", "source-map": "^0.6.1", - "strip-literal": "^0.4.2", + "strip-literal": "^1.0.0", "tinybench": "^2.3.1", "tinypool": "^0.3.0", "tinyspy": "^1.0.2", - "vite": "^3.0.0" + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.27.2", + "why-is-node-running": "^2.2.2" + }, + "dependencies": { + "vite-node": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.27.2.tgz", + "integrity": "sha512-IDwuVhslF10qCnWOGJui7/2KksAOBHi+UbVo6Pqt4f5lgn+kS2sVvYDsETRG5PSuslisGB5CFGvb9I6FQgymBQ==", + "dev": true, + "requires": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.1.0", + "pathe": "^0.2.0", + "picocolors": "^1.0.0", + "source-map": "^0.6.1", + "source-map-support": "^0.5.21", + "vite": "^3.0.0 || ^4.0.0" + } + } } }, "wcwidth": { @@ -15837,6 +16153,16 @@ "is-symbol": "^1.0.3" } }, + "why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dev": true, + "requires": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + } + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", diff --git a/package.json b/package.json index d231cce..7edcdbc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "twify", - "version": "0.4.2", + "version": "0.4.3", "description": "A Tool to Setup TailwindCSS in your Project with a Single Command", "bin": { "twify": "dist/main.js" @@ -37,15 +37,17 @@ "license": "MIT", "dependencies": { "chalk": "^5.0.1", - "commander": "^9.3.0", + "commander": "^10.0.0", "enquirer": "^2.3.6", - "fs-extra": "^10.1.0", + "fs-extra": "^11.1.0", + "glob": "^8.1.0", "gradient-string": "^2.0.1", "jscodeshift": "^0.14.0", "ora": "^6.1.0" }, "devDependencies": { "@types/fs-extra": "^9.0.13", + "@types/glob": "^8.0.1", "@types/gradient-string": "^1.1.2", "@types/jscodeshift": "^0.11.5", "@types/node": "^18.0.0", @@ -59,7 +61,7 @@ "microbundle": "^0.15.0", "prettier": "^2.6.2", "typescript": "^4.6.4", - "vitest": "^0.25.1" + "vitest": "^0.27.2" }, "prettier": { "singleQuote": true, diff --git a/src/content.ts b/src/content.ts index 8181c38..54b257c 100644 --- a/src/content.ts +++ b/src/content.ts @@ -23,9 +23,7 @@ export function addContentToCode(code: string, content: string[]): string { } export async function setupContent({ content }: Framework) { - console.log( - `\n${chalk.green('✔')} Configuring ${chalk.blue.bold(content)} content...` - ); + console.log(`\n${chalk.green('✔')} Configuring content paths...`); console.log(chalk.blue(`- ${content.join('\n- ')}`)); const [contentPath] = tailwindConfigFiles diff --git a/src/frameworks/nextjs.ts b/src/frameworks/nextjs.ts index 740a05a..2a2e286 100644 --- a/src/frameworks/nextjs.ts +++ b/src/frameworks/nextjs.ts @@ -1,9 +1,10 @@ import { Framework } from '../types'; +import { resolveCssLocation } from './steps/next'; const NextJS: Framework = { requiredDependencies: ['tailwindcss', 'postcss', 'autoprefixer'], initCommands: ['npx tailwindcss init -p'], - cssLocation: './styles/globals.css', + cssLocation: resolveCssLocation, content: [ './pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}', diff --git a/src/frameworks/steps/next.ts b/src/frameworks/steps/next.ts new file mode 100644 index 0000000..8e0d8b7 --- /dev/null +++ b/src/frameworks/steps/next.ts @@ -0,0 +1,12 @@ +import glob from 'glob'; +import util from 'util'; + +export async function resolveCssLocation() { + const [match] = await util.promisify(glob)('./**/globals.css'); + + if (!match) { + return './styles/globals.css'; + } + + return match; +} diff --git a/src/processor.ts b/src/processor.ts index 152d99c..8aae311 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -45,13 +45,15 @@ export async function handle(framework: Framework, options: InitOptions) { } // Write content to cssLocation + const cssTarget = + typeof cssLocation === 'string' ? cssLocation : await cssLocation(); console.log( - `\n${chalk.green('✔')} Setting up ${chalk.blue.bold(cssLocation)}...` + `\n${chalk.green('✔')} Setting up ${chalk.blue.bold(cssTarget)}...` ); - fs.ensureFileSync(cssLocation); - const exitingCss = fs.readFileSync(cssLocation, 'utf8'); + fs.ensureFileSync(cssTarget); + const exitingCss = fs.readFileSync(cssTarget, 'utf8'); const updatedCss = !options.keep ? CSS_STUB : `${exitingCss}\n\n${CSS_STUB}`; - fs.writeFileSync(cssLocation, updatedCss); + fs.writeFileSync(cssTarget, updatedCss); await setupContent(framework); diff --git a/src/types.ts b/src/types.ts index a92a9ff..b11f660 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,10 +12,12 @@ export interface Step { (): Promise; } +type CSSLocation = () => Promise; + export interface Framework { requiredDependencies: string[]; initCommands: string[]; - cssLocation: string; + cssLocation: string | CSSLocation; content: string[]; steps: Step[]; } diff --git a/tests/__snapshots__/drivers.spec.ts.snap b/tests/__snapshots__/drivers.spec.ts.snap index 1cbf220..0e9f747 100644 --- a/tests/__snapshots__/drivers.spec.ts.snap +++ b/tests/__snapshots__/drivers.spec.ts.snap @@ -8,7 +8,7 @@ exports[`Drivers > has a list of drivers 1`] = ` "./src/**/*.{js,ts,jsx,tsx}", "./app/**/*.{js,ts,jsx,tsx}", ], - "cssLocation": "./styles/globals.css", + "cssLocation": [Function], "initCommands": [ "npx tailwindcss init -p", ], diff --git a/tests/helpers.spec.ts b/tests/helpers.spec.ts index 4607cd9..430b893 100644 --- a/tests/helpers.spec.ts +++ b/tests/helpers.spec.ts @@ -7,7 +7,7 @@ import { runCommand, runCommandSpawn, } from '../src/helpers'; -import { EventEmitter } from 'stream'; +import stream from 'stream'; vi.mock('child_process'); @@ -106,7 +106,7 @@ describe('Helpers', () => { }); it('can run command with spawn', async () => { - const emitter = new EventEmitter(); + const emitter = new stream.EventEmitter(); // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.mocked(spawn).mockReturnValue(emitter as any); const resolve = runCommandSpawn('cmd'); diff --git a/tests/processor.spec.ts b/tests/processor.spec.ts index 01d7973..2e95581 100644 --- a/tests/processor.spec.ts +++ b/tests/processor.spec.ts @@ -92,7 +92,7 @@ describe('Processor', () => { content: ['content'], requiredDependencies: [], initCommands: [], - cssLocation: 'css', + cssLocation: () => Promise.resolve('css'), steps: [step], }; diff --git a/tests/steps/next.spec.ts b/tests/steps/next.spec.ts new file mode 100644 index 0000000..d227c83 --- /dev/null +++ b/tests/steps/next.spec.ts @@ -0,0 +1,32 @@ +import glob from 'glob'; +import { resolveCssLocation } from '../../src/frameworks/steps/next'; + +vi.mock('glob'); + +describe('Next JS CSS', () => { + afterEach(() => { + vi.clearAllMocks(); + }); + + afterAll(() => { + vi.resetAllMocks(); + }); + + it('can resolve css location', async () => { + vi.mocked(glob) + .mockImplementationOnce((_, cb) => { + console.log(typeof cb, cb); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return (cb as any)(null, ['foo']) as any; + }) + .mockImplementationOnce((_, cb) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return (cb as any)(null, []) as any; + }); + const first = await resolveCssLocation(); + const second = await resolveCssLocation(); + + expect(first).toStrictEqual('foo'); + expect(second).toStrictEqual('./styles/globals.css'); + }); +});