From f9752fe7af20a2993323f96b406ca31f22651af1 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 23 Aug 2024 20:33:47 +0100 Subject: [PATCH] chore: use `tinyexec` internally (#28684) --- package.json | 2 +- packages/ui-templates/package.json | 2 +- packages/ui-templates/test/templates.spec.ts | 12 ++- pnpm-lock.yaml | 108 ++----------------- scripts/_utils.ts | 4 +- test/bundle.test.ts | 6 +- test/prepare.ts | 4 +- 7 files changed, 27 insertions(+), 111 deletions(-) diff --git a/package.json b/package.json index 50ec05cd34..2b5982f465 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "eslint-plugin-no-only-tests": "3.3.0", "eslint-plugin-perfectionist": "3.2.0", "eslint-typegen": "0.3.1", - "execa": "9.3.1", "globby": "14.0.2", "h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e", "happy-dom": "15.0.0", @@ -94,6 +93,7 @@ "rimraf": "6.0.1", "semver": "7.6.3", "std-env": "3.7.0", + "tinyexec": "0.2.0", "typescript": "5.5.4", "ufo": "1.5.4", "vitest": "2.0.5", diff --git a/packages/ui-templates/package.json b/packages/ui-templates/package.json index ec5fe100e2..7ca56f6792 100644 --- a/packages/ui-templates/package.json +++ b/packages/ui-templates/package.json @@ -21,7 +21,6 @@ "@types/html-minifier": "4.0.5", "@unocss/reset": "0.62.2", "critters": "0.0.24", - "execa": "9.3.1", "globby": "14.0.2", "html-minifier": "4.0.0", "html-validate": "8.21.0", @@ -30,6 +29,7 @@ "pathe": "1.1.2", "prettier": "3.3.3", "scule": "1.3.0", + "tinyexec": "0.2.0", "unocss": "0.62.2", "vite": "5.4.2" } diff --git a/packages/ui-templates/test/templates.spec.ts b/packages/ui-templates/test/templates.spec.ts index a4234d18c4..33aa989914 100644 --- a/packages/ui-templates/test/templates.spec.ts +++ b/packages/ui-templates/test/templates.spec.ts @@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url' import { readFileSync } from 'node:fs' import { rm } from 'node:fs/promises' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { execaCommand } from 'execa' +import { exec } from 'tinyexec' import { format } from 'prettier' import { createJiti } from 'jiti' // @ts-expect-error types not valid for bundler resolution @@ -12,10 +12,12 @@ const distDir = fileURLToPath(new URL('../node_modules/.temp/dist/templates', im describe('template', () => { beforeAll(async () => { - await execaCommand('pnpm build', { - cwd: fileURLToPath(new URL('..', import.meta.url)), - env: { - OUTPUT_DIR: './node_modules/.temp/dist', + await exec('pnpm', ['build'], { + nodeOptions: { + cwd: fileURLToPath(new URL('..', import.meta.url)), + env: { + OUTPUT_DIR: './node_modules/.temp/dist', + }, }, }) }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e7c58e35e..768b922288 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -107,9 +107,6 @@ importers: eslint-typegen: specifier: 0.3.1 version: 0.3.1(eslint@9.9.0(jiti@2.0.0-beta.3)) - execa: - specifier: 9.3.1 - version: 9.3.1 globby: specifier: 14.0.2 version: 14.0.2 @@ -155,6 +152,9 @@ importers: std-env: specifier: 3.7.0 version: 3.7.0 + tinyexec: + specifier: 0.2.0 + version: 0.2.0 typescript: specifier: 5.5.4 version: 5.5.4 @@ -605,9 +605,6 @@ importers: critters: specifier: 0.0.24 version: 0.0.24 - execa: - specifier: 9.3.1 - version: 9.3.1 globby: specifier: 14.0.2 version: 14.0.2 @@ -632,6 +629,9 @@ importers: scule: specifier: 1.3.0 version: 1.3.0 + tinyexec: + specifier: 0.2.0 + version: 0.2.0 unocss: specifier: 0.62.2 version: 0.62.2(@unocss/webpack@0.62.2(rollup@4.21.0)(webpack@5.94.0(esbuild@0.23.1)))(postcss@8.4.41)(rollup@4.21.0)(vite@5.4.2(@types/node@20.16.1)(sass@1.69.4)(terser@5.27.0)) @@ -2305,9 +2305,6 @@ packages: '@rushstack/eslint-patch@1.10.4': resolution: {integrity: sha512-WJgX9nzTqknM393q1QJDJmoW28kUfEnybeTfVNcNAPnIx210RXm2DiXiHzfNPJNIUUb1tJnz/l4QGtJ30PgWmA==} - '@sec-ant/readable-stream@0.4.1': - resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} - '@shikijs/core@1.1.2': resolution: {integrity: sha512-ERVzNQz88ZkDqUpWeC57Kp+Kmx5RjqeDBR1M8AGWGom4yrkITiTfXCGmjchlDSw12MhDTuPYR4HVFW8uT61RaQ==} @@ -2343,10 +2340,6 @@ packages: resolution: {integrity: sha512-UTce8mUwUW0RikMb/eseJ7ys0BRkZVFB86orHzrfW12ZmFtym5zua8joZ4L7okH2dDFHkcFjqnZ5GocWBXOFtA==} engines: {node: '>=18'} - '@sindresorhus/merge-streams@4.0.0': - resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==} - engines: {node: '>=18'} - '@stylistic/eslint-plugin-js@2.6.4': resolution: {integrity: sha512-kx1hS3xTvzxZLdr/DCU/dLBE++vcP97sHeEFX2QXhk1Ipa4K1rzPOLw1HCbf4mU3s+7kHP5eYpDe+QteEOFLug==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -4108,10 +4101,6 @@ packages: resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} engines: {node: '>=16.17'} - execa@9.3.1: - resolution: {integrity: sha512-gdhefCCNy/8tpH/2+ajP9IQc14vXchNdd0weyzSJEFURhRMGncQ+zKFxwjAufIewPEJm9BPOaJnvg2UtlH2gPQ==} - engines: {node: ^18.19.0 || >=20.5.0} - extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -4156,10 +4145,6 @@ packages: resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==} engines: {node: '>=8'} - figures@6.1.0: - resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} - engines: {node: '>=18'} - file-entry-cache@8.0.0: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} @@ -4298,10 +4283,6 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} - get-stream@9.0.1: - resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} - engines: {node: '>=18'} - get-tsconfig@4.7.6: resolution: {integrity: sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA==} @@ -4549,10 +4530,6 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} - human-signals@8.0.0: - resolution: {integrity: sha512-/1/GPCpDUCCYwlERiYjxoczfP0zfvZMU/OWgQPMya9AbAE24vseigFdhAMObpc8Q4lc/kjutPfUddDYyAmejnA==} - engines: {node: '>=18.18.0'} - hyperdyperid@1.2.0: resolution: {integrity: sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A==} engines: {node: '>=10.18'} @@ -4771,10 +4748,6 @@ packages: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - is-stream@4.0.1: - resolution: {integrity: sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==} - engines: {node: '>=18'} - is-string@1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -4787,10 +4760,6 @@ packages: resolution: {integrity: sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==} engines: {node: '>= 0.4'} - is-unicode-supported@2.0.0: - resolution: {integrity: sha512-FRdAyx5lusK1iHG0TWpVtk9+1i+GjrzRffhDg4ovQ7mcidMQ6mj+MhKPmvh7Xwyv5gIS06ns49CA7Sqg7lC22Q==} - engines: {node: '>=18'} - is-weakmap@2.0.1: resolution: {integrity: sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==} @@ -5651,10 +5620,6 @@ packages: resolution: {integrity: sha512-rum1bPifK5SSar35Z6EKZuYPJx85pkNaFrxBK3mwdfSJ1/WKbYrjoW/zTPSjRRamfmVX1ACBIdFAO0VRErW/EA==} engines: {node: '>=18'} - parse-ms@4.0.0: - resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} - engines: {node: '>=18'} - parse-path@7.0.0: resolution: {integrity: sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==} @@ -6005,10 +5970,6 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - pretty-ms@9.0.0: - resolution: {integrity: sha512-E9e9HJ9R9NasGOgPaPE8VMeiPKAyWR5jcFpNnwIejslIhWqdqOrb2wShBsncMPUb+BcCd2OPYfh7p2W6oemTng==} - engines: {node: '>=18'} - pretty-time@1.1.0: resolution: {integrity: sha512-28iF6xPQrP8Oa6uxE6a1biz+lWeTOAPKggvjB8HAs6nVMKZwf5bG++632Dx614hIWgUPkgivRfG+a8uAXGTIbA==} engines: {node: '>=4'} @@ -6533,10 +6494,6 @@ packages: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} - strip-final-newline@4.0.0: - resolution: {integrity: sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==} - engines: {node: '>=18'} - strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -6660,6 +6617,9 @@ packages: tinybench@2.8.0: resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} + tinyexec@0.2.0: + resolution: {integrity: sha512-au8dwv4xKSDR+Fw52csDo3wcDztPdne2oM1o/7LFro4h6bdFmvyUAeAfX40pwDtzHgRFqz1XWaUqgKS2G83/ig==} + tinyglobby@0.2.2: resolution: {integrity: sha512-mZ2sDMaySvi1PkTp4lTo1In2zjU+cY8OvZsfwrDrx3YGRbXPX1/cbPwCR9zkm3O/Fz9Jo0F1HNgIQ1b8BepqyQ==} engines: {node: '>=12.0.0'} @@ -7416,10 +7376,6 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} - yoctocolors@2.0.0: - resolution: {integrity: sha512-esbDnt0Z1zI1KgvOZU90hJbL6BkoUbrP9yy7ArNZ6TmxBxydMJTYMf9FZjmwwcA8ZgEQzriQ3hwZ0NYXhlFo8Q==} - engines: {node: '>=18'} - zhead@2.2.4: resolution: {integrity: sha512-8F0OI5dpWIA5IGG5NHUg9staDwz/ZPxZtvGVf01j7vHqSyZ0raHY+78atOVxRqb73AotX22uV1pXt3gYSstGag==} @@ -8749,8 +8705,6 @@ snapshots: '@rushstack/eslint-patch@1.10.4': {} - '@sec-ant/readable-stream@0.4.1': {} - '@shikijs/core@1.1.2': {} '@shikijs/core@1.12.1': @@ -8801,8 +8755,6 @@ snapshots: '@sindresorhus/merge-streams@2.2.0': {} - '@sindresorhus/merge-streams@4.0.0': {} - '@stylistic/eslint-plugin-js@2.6.4(eslint@9.9.0(jiti@2.0.0-beta.3))': dependencies: '@types/eslint': 9.6.0 @@ -11036,21 +10988,6 @@ snapshots: signal-exit: 4.1.0 strip-final-newline: 3.0.0 - execa@9.3.1: - dependencies: - '@sindresorhus/merge-streams': 4.0.0 - cross-spawn: 7.0.3 - figures: 6.1.0 - get-stream: 9.0.1 - human-signals: 8.0.0 - is-plain-obj: 4.1.0 - is-stream: 4.0.1 - npm-run-path: 5.3.0 - pretty-ms: 9.0.0 - signal-exit: 4.1.0 - strip-final-newline: 4.0.0 - yoctocolors: 2.0.0 - extend@3.0.2: {} externality@1.0.2: @@ -11092,10 +11029,6 @@ snapshots: dependencies: escape-string-regexp: 1.0.5 - figures@6.1.0: - dependencies: - is-unicode-supported: 2.0.0 - file-entry-cache@8.0.0: dependencies: flat-cache: 4.0.1 @@ -11236,11 +11169,6 @@ snapshots: get-stream@8.0.1: {} - get-stream@9.0.1: - dependencies: - '@sec-ant/readable-stream': 0.4.1 - is-stream: 4.0.1 - get-tsconfig@4.7.6: dependencies: resolve-pkg-maps: 1.0.0 @@ -11550,8 +11478,6 @@ snapshots: human-signals@5.0.0: {} - human-signals@8.0.0: {} - hyperdyperid@1.2.0: {} iconv-lite@0.6.3: @@ -11752,8 +11678,6 @@ snapshots: is-stream@3.0.0: {} - is-stream@4.0.1: {} - is-string@1.0.7: dependencies: has-tostringtag: 1.0.2 @@ -11766,8 +11690,6 @@ snapshots: dependencies: which-typed-array: 1.1.14 - is-unicode-supported@2.0.0: {} - is-weakmap@2.0.1: {} is-weakset@2.0.2: @@ -13000,8 +12922,6 @@ snapshots: index-to-position: 0.1.2 type-fest: 4.20.1 - parse-ms@4.0.0: {} - parse-path@7.0.0: dependencies: protocols: 2.0.1 @@ -13308,10 +13228,6 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.2.0 - pretty-ms@9.0.0: - dependencies: - parse-ms: 4.0.0 - pretty-time@1.1.0: {} process-nextick-args@2.0.1: {} @@ -13954,8 +13870,6 @@ snapshots: strip-final-newline@3.0.0: {} - strip-final-newline@4.0.0: {} - strip-indent@3.0.0: dependencies: min-indent: 1.0.1 @@ -14083,6 +13997,8 @@ snapshots: tinybench@2.8.0: {} + tinyexec@0.2.0: {} + tinyglobby@0.2.2: dependencies: fdir: 6.2.0(picomatch@4.0.2) @@ -14989,8 +14905,6 @@ snapshots: yocto-queue@1.0.0: {} - yoctocolors@2.0.0: {} - zhead@2.2.4: {} zip-stream@6.0.1: diff --git a/scripts/_utils.ts b/scripts/_utils.ts index 9e7737f506..0ca3f1d673 100644 --- a/scripts/_utils.ts +++ b/scripts/_utils.ts @@ -3,7 +3,7 @@ import { promises as fsp } from 'node:fs' import { $fetch } from 'ofetch' import { resolve } from 'pathe' import { globby } from 'globby' -import { execaSync } from 'execa' +import { exec } from 'tinyexec' import { determineSemverChange, getGitDiff, loadChangelogConfig, parseCommits } from 'changelogen' export interface Dep { @@ -108,7 +108,7 @@ export async function determineBumpType () { export async function getLatestCommits () { const config = await loadChangelogConfig(process.cwd()) - const latestTag = execaSync('git', ['describe', '--tags', '--abbrev=0']).stdout + const { stdout: latestTag } = await exec('git', ['describe', '--tags', '--abbrev=0']) return parseCommits(await getGitDiff(latestTag), config) } diff --git a/test/bundle.test.ts b/test/bundle.test.ts index d61144460f..f5a67f98a7 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -1,7 +1,7 @@ import { fileURLToPath } from 'node:url' import fsp from 'node:fs/promises' import { beforeAll, describe, expect, it } from 'vitest' -import { execaCommand } from 'execa' +import { exec } from 'tinyexec' import { globby } from 'globby' import { join } from 'pathe' @@ -10,8 +10,8 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM beforeAll(async () => { await Promise.all([ - execaCommand(`pnpm nuxi build ${rootDir}`, { env: { EXTERNAL_VUE: 'false' } }), - execaCommand(`pnpm nuxi build ${rootDir}`, { env: { EXTERNAL_VUE: 'true' } }), + exec('pnpm', ['nuxi', 'build', rootDir], { nodeOptions: { env: { EXTERNAL_VUE: 'false' } } }), + exec('pnpm', ['nuxi', 'build', rootDir], { nodeOptions: { env: { EXTERNAL_VUE: 'true' } } }), ]) }, 120 * 1000) diff --git a/test/prepare.ts b/test/prepare.ts index e4442a18ac..31d6d72d49 100644 --- a/test/prepare.ts +++ b/test/prepare.ts @@ -3,7 +3,7 @@ import { rm } from 'node:fs/promises' import { globby } from 'globby' -import { execa } from 'execa' +import { exec } from 'tinyexec' async function initTesting () { const dirs = await globby('*', { @@ -20,7 +20,7 @@ async function initTesting () { ]) await Promise.all( - dirs.map(dir => execa('pnpm', ['nuxi', 'prepare'], { cwd: dir })), + dirs.map(dir => exec('pnpm', ['nuxi', 'prepare'], { nodeOptions: { cwd: dir } })), ) }