From 0433aa487e22063b4815453b33790ce9683852e5 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 26 May 2022 12:28:23 +0800 Subject: [PATCH] chore: use fast-glob --- package.json | 8 +++----- pnpm-lock.yaml | 31 ------------------------------- scripts/copyClient.js | 4 ++-- scripts/copyShared.js | 4 ++-- src/node/config.ts | 6 +++--- 5 files changed, 10 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index 0ea4a6e0..c462bf97 100644 --- a/package.json +++ b/package.json @@ -52,9 +52,8 @@ "build-prepare": "rimraf dist && node scripts/copyShared", "build-client": "tsc -p src/client && node scripts/copyClient", "build-node": "rollup --config rollup.config.ts --configPlugin esbuild", - "lint": "run-s lint:js lint:ts", - "lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"", - "lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"", + "format": "prettier --write .", + "lint": "pnpm run format", "test": "vitest run __tests__ -c __tests__/vitest.config.js --global", "test:all": "run-s lint test", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", @@ -65,7 +64,7 @@ "docs-build": "run-s build docs-build-only", "docs-build-only": "node ./bin/vitepress build docs", "docs-serve": "node ./bin/vitepress serve docs", - "ci-docs": "run-s build docs-build" + "ci-docs": "run-s docs-build" }, "gitHooks": { "pre-commit": "lint-staged" @@ -120,7 +119,6 @@ "execa": "^6.1.0", "fast-glob": "^3.2.7", "fs-extra": "^10.0.0", - "globby": "^11.0.3", "gray-matter": "^4.0.3", "lint-staged": "^11.0.0", "lru-cache": "^6.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 199fbf8f..3d8745d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,7 +40,6 @@ importers: execa: ^6.1.0 fast-glob: ^3.2.7 fs-extra: ^10.0.0 - globby: ^11.0.3 gray-matter: ^4.0.3 lint-staged: ^11.0.0 lru-cache: ^6.0.0 @@ -112,7 +111,6 @@ importers: execa: 6.1.0 fast-glob: 3.2.7 fs-extra: 10.0.0 - globby: 11.0.4 gray-matter: 4.0.3 lint-staged: 11.1.2_supports-color@9.2.2 lru-cache: 6.0.0 @@ -905,11 +903,6 @@ packages: resolution: {integrity: sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=} dev: true - /array-union/2.1.0: - resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} - engines: {node: '>=8'} - dev: true - /arrify/1.0.1: resolution: {integrity: sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=} engines: {node: '>=0.10.0'} @@ -1458,13 +1451,6 @@ packages: resolution: {integrity: sha1-PvqHMj67hj5mls67AILUj/PW96E=} dev: true - /dir-glob/3.0.1: - resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} - engines: {node: '>=8'} - dependencies: - path-type: 4.0.0 - dev: true - /dot-prop/5.3.0: resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} engines: {node: '>=8'} @@ -2119,18 +2105,6 @@ packages: path-is-absolute: 1.0.1 dev: true - /globby/11.0.4: - resolution: {integrity: sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==} - engines: {node: '>=10'} - dependencies: - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.2.7 - ignore: 5.1.8 - merge2: 1.4.1 - slash: 3.0.0 - dev: true - /graceful-fs/4.2.8: resolution: {integrity: sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==} dev: true @@ -2224,11 +2198,6 @@ packages: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: true - /ignore/5.1.8: - resolution: {integrity: sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==} - engines: {node: '>= 4'} - dev: true - /import-fresh/3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} diff --git a/scripts/copyClient.js b/scripts/copyClient.js index b5860e56..44360e28 100644 --- a/scripts/copyClient.js +++ b/scripts/copyClient.js @@ -1,11 +1,11 @@ import { copy } from 'fs-extra' -import { sync } from 'globby' +import fg from 'fast-glob' function toDest(file) { return file.replace(/^src\//, 'dist/') } -sync('src/client/**').forEach((file) => { +fg.sync('src/client/**').forEach((file) => { if (/(\.ts|tsconfig\.json)$/.test(file)) return copy(file, toDest(file)) }) diff --git a/scripts/copyShared.js b/scripts/copyShared.js index 7b87b441..ed5f55d9 100644 --- a/scripts/copyShared.js +++ b/scripts/copyShared.js @@ -1,7 +1,7 @@ import { copy } from 'fs-extra' -import { sync } from 'globby' +import fg from 'fast-glob' -sync('src/shared/**/*.ts').map(async (file) => { +fg.sync('src/shared/**/*.ts').map(async (file) => { await copy(file, file.replace(/^src\/shared\//, 'src/node/')) await copy(file, file.replace(/^src\/shared\//, 'src/client/')) }) diff --git a/src/node/config.ts b/src/node/config.ts index 6786b27a..c9bf2a14 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -1,7 +1,7 @@ import path from 'path' import fs from 'fs-extra' import c from 'picocolors' -import globby from 'globby' +import fg from 'fast-glob' import { normalizePath, AliasOptions, @@ -124,14 +124,14 @@ export async function resolveConfig( ? userThemeDir : DEFAULT_THEME_PATH - // Important: globby/fast-glob doesn't guarantee order of the returned files. + // Important: fast-glob doesn't guarantee order of the returned files. // We must sort the pages so the input list to rollup is stable across // builds - otherwise different input order could result in different exports // order in shared chunks which in turns invalidates the hash of every chunk! // JavaScript built-in sort() is mandated to be stable as of ES2019 and // supported in Node 12+, which is required by Vite. const pages = ( - await globby(['**.md'], { + await fg(['**.md'], { cwd: srcDir, ignore: ['**/node_modules', ...(userConfig.srcExclude || [])] })