chore: use fast-glob

pull/666/head
Anthony Fu 3 years ago
parent f054432483
commit 0433aa487e

@ -52,9 +52,8 @@
"build-prepare": "rimraf dist && node scripts/copyShared", "build-prepare": "rimraf dist && node scripts/copyShared",
"build-client": "tsc -p src/client && node scripts/copyClient", "build-client": "tsc -p src/client && node scripts/copyClient",
"build-node": "rollup --config rollup.config.ts --configPlugin esbuild", "build-node": "rollup --config rollup.config.ts --configPlugin esbuild",
"lint": "run-s lint:js lint:ts", "format": "prettier --write .",
"lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"", "lint": "pnpm run format",
"lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"",
"test": "vitest run __tests__ -c __tests__/vitest.config.js --global", "test": "vitest run __tests__ -c __tests__/vitest.config.js --global",
"test:all": "run-s lint test", "test:all": "run-s lint test",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
@ -65,7 +64,7 @@
"docs-build": "run-s build docs-build-only", "docs-build": "run-s build docs-build-only",
"docs-build-only": "node ./bin/vitepress build docs", "docs-build-only": "node ./bin/vitepress build docs",
"docs-serve": "node ./bin/vitepress serve docs", "docs-serve": "node ./bin/vitepress serve docs",
"ci-docs": "run-s build docs-build" "ci-docs": "run-s docs-build"
}, },
"gitHooks": { "gitHooks": {
"pre-commit": "lint-staged" "pre-commit": "lint-staged"
@ -120,7 +119,6 @@
"execa": "^6.1.0", "execa": "^6.1.0",
"fast-glob": "^3.2.7", "fast-glob": "^3.2.7",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"globby": "^11.0.3",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"lint-staged": "^11.0.0", "lint-staged": "^11.0.0",
"lru-cache": "^6.0.0", "lru-cache": "^6.0.0",

@ -40,7 +40,6 @@ importers:
execa: ^6.1.0 execa: ^6.1.0
fast-glob: ^3.2.7 fast-glob: ^3.2.7
fs-extra: ^10.0.0 fs-extra: ^10.0.0
globby: ^11.0.3
gray-matter: ^4.0.3 gray-matter: ^4.0.3
lint-staged: ^11.0.0 lint-staged: ^11.0.0
lru-cache: ^6.0.0 lru-cache: ^6.0.0
@ -112,7 +111,6 @@ importers:
execa: 6.1.0 execa: 6.1.0
fast-glob: 3.2.7 fast-glob: 3.2.7
fs-extra: 10.0.0 fs-extra: 10.0.0
globby: 11.0.4
gray-matter: 4.0.3 gray-matter: 4.0.3
lint-staged: 11.1.2_supports-color@9.2.2 lint-staged: 11.1.2_supports-color@9.2.2
lru-cache: 6.0.0 lru-cache: 6.0.0
@ -905,11 +903,6 @@ packages:
resolution: {integrity: sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=} resolution: {integrity: sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=}
dev: true dev: true
/array-union/2.1.0:
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
dev: true
/arrify/1.0.1: /arrify/1.0.1:
resolution: {integrity: sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=} resolution: {integrity: sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -1458,13 +1451,6 @@ packages:
resolution: {integrity: sha1-PvqHMj67hj5mls67AILUj/PW96E=} resolution: {integrity: sha1-PvqHMj67hj5mls67AILUj/PW96E=}
dev: true 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: /dot-prop/5.3.0:
resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -2119,18 +2105,6 @@ packages:
path-is-absolute: 1.0.1 path-is-absolute: 1.0.1
dev: true 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: /graceful-fs/4.2.8:
resolution: {integrity: sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==} resolution: {integrity: sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==}
dev: true dev: true
@ -2224,11 +2198,6 @@ packages:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
dev: true dev: true
/ignore/5.1.8:
resolution: {integrity: sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==}
engines: {node: '>= 4'}
dev: true
/import-fresh/3.3.0: /import-fresh/3.3.0:
resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==}
engines: {node: '>=6'} engines: {node: '>=6'}

@ -1,11 +1,11 @@
import { copy } from 'fs-extra' import { copy } from 'fs-extra'
import { sync } from 'globby' import fg from 'fast-glob'
function toDest(file) { function toDest(file) {
return file.replace(/^src\//, 'dist/') return file.replace(/^src\//, 'dist/')
} }
sync('src/client/**').forEach((file) => { fg.sync('src/client/**').forEach((file) => {
if (/(\.ts|tsconfig\.json)$/.test(file)) return if (/(\.ts|tsconfig\.json)$/.test(file)) return
copy(file, toDest(file)) copy(file, toDest(file))
}) })

@ -1,7 +1,7 @@
import { copy } from 'fs-extra' 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/node/'))
await copy(file, file.replace(/^src\/shared\//, 'src/client/')) await copy(file, file.replace(/^src\/shared\//, 'src/client/'))
}) })

@ -1,7 +1,7 @@
import path from 'path' import path from 'path'
import fs from 'fs-extra' import fs from 'fs-extra'
import c from 'picocolors' import c from 'picocolors'
import globby from 'globby' import fg from 'fast-glob'
import { import {
normalizePath, normalizePath,
AliasOptions, AliasOptions,
@ -124,14 +124,14 @@ export async function resolveConfig(
? userThemeDir ? userThemeDir
: DEFAULT_THEME_PATH : 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 // We must sort the pages so the input list to rollup is stable across
// builds - otherwise different input order could result in different exports // builds - otherwise different input order could result in different exports
// order in shared chunks which in turns invalidates the hash of every chunk! // 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 // JavaScript built-in sort() is mandated to be stable as of ES2019 and
// supported in Node 12+, which is required by Vite. // supported in Node 12+, which is required by Vite.
const pages = ( const pages = (
await globby(['**.md'], { await fg(['**.md'], {
cwd: srcDir, cwd: srcDir,
ignore: ['**/node_modules', ...(userConfig.srcExclude || [])] ignore: ['**/node_modules', ...(userConfig.srcExclude || [])]
}) })

Loading…
Cancel
Save