From 73bbaea02860197a5d6df12d8b2dac0131fab9c2 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sun, 30 Aug 2026 15:22:14 +0800 Subject: [PATCH] chore: replace `lodash.template` with eta (#5411) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- THIRD-PARTY-NOTICES.md | 97 ++++++------------------------------------ package.json | 7 ++- pnpm-lock.yaml | 82 +++++++++++------------------------ src/node/init/init.ts | 10 ++++- 4 files changed, 51 insertions(+), 145 deletions(-) diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index 04c61fd6..b5d9863b 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -546,6 +546,20 @@ Repository: https://github.com/jquery/esprima > (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## eta + +License: MIT +By: Ben Gubler +Repository: https://github.com/bgub/eta + +> Copyright 2025 Ben Gubler +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ## extend-shallow License: MIT @@ -904,89 +918,6 @@ Repository: https://github.com/markdown-it/linkify-it > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > OTHER DEALINGS IN THE SOFTWARE. -## lodash._reinterpolate - -License: MIT -By: John-David Dalton (http://allyoucanleet.com/), Benjamin Tan (https://d10.github.io/), Blaine Bublitz (http://www.iceddev.com/), Kit Cambridge (http://kitcambridge.be/), Mathias Bynens (https://mathiasbynens.be/) -Repository: https://github.com/lodash/lodash - -> Copyright 2012-2015 The Dojo Foundation -> Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, -> DocumentCloud and Investigative Reporters & Editors -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> "Software"), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -## lodash.template, lodash.templatesettings - -License: MIT -By: John-David Dalton , Mathias Bynens -Repository: https://github.com/lodash/lodash - -> Copyright OpenJS Foundation and other contributors -> -> Based on Underscore.js, copyright Jeremy Ashkenas, -> DocumentCloud and Investigative Reporters & Editors -> -> This software consists of voluntary contributions made by many -> individuals. For exact contribution history, see the revision history -> available at https://github.com/lodash/lodash -> -> The following license applies to all parts of this software except as -> documented below: -> -> ==== -> -> Permission is hereby granted, free of charge, to any person obtaining -> a copy of this software and associated documentation files (the -> "Software"), to deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, merge, publish, -> distribute, sublicense, and/or sell copies of the Software, and to -> permit persons to whom the Software is furnished to do so, subject to -> the following conditions: -> -> The above copyright notice and this permission notice shall be -> included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -> -> ==== -> -> Copyright and related rights for sample code are waived via CC0. Sample -> code is defined as all source code displayed within the prose of the -> documentation. -> -> CC0: http://creativecommons.org/publicdomain/zero/1.0/ -> -> ==== -> -> Files located in the node_modules and vendor directories are externally -> maintained libraries used by this software which have their own -> licenses; we recommend you read them, as their terms may differ from the -> terms above. - ## lru-cache License: BlueOak-1.0.0 diff --git a/package.json b/package.json index 5796ee71..0942027e 100644 --- a/package.json +++ b/package.json @@ -112,6 +112,7 @@ "vue": "^3.5.41" }, "devDependencies": { + "@arethetypeswrong/cli": "^0.18.5", "@clack/prompts": "^1.7.0", "@iconify/utils": "^3.1.4", "@mdit-vue/plugin-component": "^3.0.2", @@ -127,11 +128,9 @@ "@mdit/plugin-emoji": "^1.1.1", "@mdit/plugin-footnote": "^1.0.2", "@mdit/plugin-tasklist": "^1.0.2", - "@arethetypeswrong/cli": "^0.18.5", "@polka/compression": "^1.0.0-next.28", "@rolldown/pluginutils": "^1.0.1", "@types/cross-spawn": "^6.0.6", - "@types/lodash.template": "^4.5.3", "@types/mark.js": "^8.11.12", "@types/minimist": "^1.2.5", "@types/node": "^26.2.0", @@ -142,11 +141,11 @@ "conventional-changelog": "^8.1.1", "conventional-changelog-angular": "^9.2.1", "cross-spawn": "^7.0.6", + "eta": "^4.6.0", "get-port": "^7.2.0", "gray-matter": "^4.0.3", "image-size": "^2.0.2", "lint-staged": "^17.3.0", - "lodash.template": "^4.18.1", "lru-cache": "^11.5.2", "markdown-it": "^14.3.0", "markdown-it-async": "^2.2.0", @@ -192,5 +191,5 @@ "optional": true } }, - "packageManager": "pnpm@11.21.0" + "packageManager": "pnpm@11.24.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec90881c..a714130a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,7 +34,7 @@ importers: version: 14.1.2 '@vitejs/plugin-vue': specifier: ^6.0.8 - version: 6.0.8(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0))(vue@3.5.41(typescript@6.0.3)) + version: 6.0.8(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0))(vue@3.5.41(typescript@6.0.3)) '@vue/devtools-api': specifier: ^8.2.1 version: 8.2.1 @@ -61,7 +61,7 @@ importers: version: 4.4.3 vite: specifier: ^8.2.1 - version: 8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) + version: 8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) vue: specifier: ^3.5.41 version: 3.5.41(typescript@6.0.3) @@ -123,9 +123,6 @@ importers: '@types/cross-spawn': specifier: ^6.0.6 version: 6.0.6 - '@types/lodash.template': - specifier: ^4.5.3 - version: 4.5.3 '@types/mark.js': specifier: ^8.11.12 version: 8.11.12 @@ -156,6 +153,9 @@ importers: cross-spawn: specifier: ^7.0.6 version: 7.0.6 + eta: + specifier: ^4.6.0 + version: 4.6.0 get-port: specifier: ^7.2.0 version: 7.2.0 @@ -168,9 +168,6 @@ importers: lint-staged: specifier: ^17.3.0 version: 17.3.0 - lodash.template: - specifier: ^4.18.1 - version: 4.18.1 lru-cache: specifier: ^11.5.2 version: 11.5.2 @@ -257,7 +254,7 @@ importers: version: 6.0.3 vitest: specifier: ^4.1.10 - version: 4.1.10(@types/node@26.2.0)(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)) + version: 4.1.10(@types/node@26.2.0)(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)) vue-sfc-transformer: specifier: ^0.2.5 version: 0.2.5(patch_hash=06dbce7d98fac77faf5e66a94aa6e04f34c0cc7ec0910ec10848e5f2e08b8b68)(@volar/typescript@2.4.28(typescript@6.0.3))(@vue/compiler-core@3.5.41)(@vue/language-core@3.3.11)(rolldown@1.2.5)(typescript@6.0.3)(vue@3.5.41(typescript@6.0.3)) @@ -308,7 +305,7 @@ importers: version: link:.. vitepress-plugin-group-icons: specifier: ^1.7.6 - version: 1.7.6(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)) + version: 1.7.6(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)) vitepress-plugin-llms: specifier: ^1.13.4 version: 1.13.4(supports-color@7.2.0) @@ -763,12 +760,6 @@ packages: '@types/linkify-it@5.0.0': resolution: {integrity: sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==} - '@types/lodash.template@4.5.3': - resolution: {integrity: sha512-Mo0UYKLu1oXgkV9TVoXZLlXXjyIXlW7ZQRxi/4gQJmzJr63dmicE8gG0OkPjYTKBrBic852q0JzqrtNUWLBIyA==} - - '@types/lodash@4.17.25': - resolution: {integrity: sha512-+K1NIO8I+F9/wNulfVvu23QYd0Pe9/OCqRrim4NoYIf1VoEDL90Ve4ClzpyqBLc7NpGGWRvYNCKZ1BE/Jpf8dQ==} - '@types/mark.js@8.11.12': resolution: {integrity: sha512-244ZnaIBpz4c6xutliAnYVZp6xJlmC569jZqnR3ElO1Y01ooYASSVQEqpd2x0A2UfrgVMs5V9/9tUAdZaDMytQ==} @@ -1469,6 +1460,10 @@ packages: estree-walker@3.0.3: resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + eta@4.6.0: + resolution: {integrity: sha512-lW6is4T1NFOYnmqGZIfvixqj7A7sSvScF+DN8EK6K58xI5MZ5UvYe0GjopxOXQtZvUn4eDdVuZ8XSoYWTMEKwA==} + engines: {node: '>=20'} + expect-type@1.4.0: resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} engines: {node: '>=12.0.0'} @@ -1813,16 +1808,6 @@ packages: engines: {node: '>=22.22.1'} hasBin: true - lodash._reinterpolate@3.0.0: - resolution: {integrity: sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA==} - - lodash.template@4.18.1: - resolution: {integrity: sha512-5urZrLnV/VD6zHK5KsVtZgt7H19v51mIzoS0aBNH8yp3I8tbswrEjOABOPY8m8uB7NuibubLrMX+Y0PXsU9X+w==} - deprecated: This package is deprecated. Use https://socket.dev/npm/package/eta instead. - - lodash.templatesettings@4.2.0: - resolution: {integrity: sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==} - lodash@4.18.1: resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==} @@ -2606,13 +2591,13 @@ packages: vfile@6.0.3: resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} - vite@8.2.1: - resolution: {integrity: sha512-EU/eS7BH3XROHh2YnBefjM6DBKA6ZeMZEYQbj7NLWg5wHYlhB8B/Mayd5XsgWq+NFYccDOTemRpdETWR6Ka/lw==} + vite@8.2.2: + resolution: {integrity: sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: '@types/node': ^20.19.0 || >=22.12.0 - '@vitejs/devtools': ^0.4.0 + '@vitejs/devtools': ^0.4.0 || ^0.5.0 esbuild: '*' jiti: '>=1.21.0' less: ^4.0.0 @@ -3244,12 +3229,6 @@ snapshots: '@types/linkify-it@5.0.0': {} - '@types/lodash.template@4.5.3': - dependencies: - '@types/lodash': 4.17.25 - - '@types/lodash@4.17.25': {} - '@types/mark.js@8.11.12': dependencies: '@types/jquery': 4.0.1 @@ -3291,10 +3270,10 @@ snapshots: '@ungap/structured-clone@1.3.3': {} - '@vitejs/plugin-vue@6.0.8(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0))(vue@3.5.41(typescript@6.0.3))': + '@vitejs/plugin-vue@6.0.8(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0))(vue@3.5.41(typescript@6.0.3))': dependencies: '@rolldown/pluginutils': 1.0.1 - vite: 8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) + vite: 8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) vue: 3.5.41(typescript@6.0.3) '@vitest/expect@4.1.10': @@ -3306,13 +3285,13 @@ snapshots: chai: 6.2.2 tinyrainbow: 3.1.1 - '@vitest/mocker@4.1.10(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0))': + '@vitest/mocker@4.1.10(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0))': dependencies: '@vitest/spy': 4.1.10 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: - vite: 8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) + vite: 8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) '@vitest/pretty-format@4.1.10': dependencies: @@ -3862,6 +3841,8 @@ snapshots: dependencies: '@types/estree': 1.0.9 + eta@4.6.0: {} + expect-type@1.4.0: {} extend-shallow@2.0.1: @@ -4180,17 +4161,6 @@ snapshots: optionalDependencies: yaml: 2.9.0 - lodash._reinterpolate@3.0.0: {} - - lodash.template@4.18.1: - dependencies: - lodash._reinterpolate: 3.0.0 - lodash.templatesettings: 4.2.0 - - lodash.templatesettings@4.2.0: - dependencies: - lodash._reinterpolate: 3.0.0 - lodash@4.18.1: {} log-symbols@7.0.1: @@ -5069,7 +5039,7 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0): + vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.5 @@ -5082,13 +5052,13 @@ snapshots: jiti: 1.21.7 yaml: 2.9.0 - vitepress-plugin-group-icons@1.7.6(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)): + vitepress-plugin-group-icons@1.7.6(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)): dependencies: '@iconify-json/logos': 1.2.12 '@iconify-json/vscode-icons': 1.2.70 '@iconify/utils': 3.1.4 optionalDependencies: - vite: 8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) + vite: 8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) vitepress-plugin-llms@1.13.4(supports-color@7.2.0): dependencies: @@ -5109,10 +5079,10 @@ snapshots: transitivePeerDependencies: - supports-color - vitest@4.1.10(@types/node@26.2.0)(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)): + vitest@4.1.10(@types/node@26.2.0)(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)): dependencies: '@vitest/expect': 4.1.10 - '@vitest/mocker': 4.1.10(vite@8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)) + '@vitest/mocker': 4.1.10(vite@8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0)) '@vitest/pretty-format': 4.1.10 '@vitest/runner': 4.1.10 '@vitest/snapshot': 4.1.10 @@ -5129,7 +5099,7 @@ snapshots: tinyexec: 1.3.0 tinyglobby: 0.2.17 tinyrainbow: 3.1.1 - vite: 8.2.1(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) + vite: 8.2.2(@types/node@26.2.0)(jiti@1.21.7)(yaml@2.9.0) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 26.2.0 diff --git a/src/node/init/init.ts b/src/node/init/init.ts index dadce3fe..b481a62e 100644 --- a/src/node/init/init.ts +++ b/src/node/init/init.ts @@ -12,7 +12,7 @@ import { select, text } from '@clack/prompts' -import template from 'lodash.template' +import { Eta } from 'eta' import c from 'picocolors' import { slash } from '../shared' @@ -190,6 +190,12 @@ export async function scaffold({ const useMjs = userPkg.type !== 'module' + const eta = new Eta({ + useWith: true, + autoEscape: false, + autoTrim: false + }) + const renderFile = async (file: string) => { const filePath = path.resolve(templateDir, file) let targetPath = path.resolve(resolvedRoot, file) @@ -205,7 +211,7 @@ export async function scaffold({ } const content = await readFile(filePath) - const compiled = template(content)(data) + const compiled = eta.renderString(content, data) await mkdir(path.dirname(targetPath), { recursive: true }) await writeFile(targetPath, compiled)