mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
Replace globby/fast-glob/tiny-glob with tinyglobby (#13299)
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com> Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com>
This commit is contained in:
parent
baf0c405dd
commit
2e1321e9d5
25 changed files with 784 additions and 860 deletions
8
.changeset/happy-tomatoes-kick.md
Normal file
8
.changeset/happy-tomatoes-kick.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
'@astrojs/cloudflare': patch
|
||||||
|
'@astrojs/netlify': patch
|
||||||
|
'@astrojs/vercel': patch
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Uses `tinyglobby` for globbing files
|
4
.github/scripts/announce.mjs
vendored
4
.github/scripts/announce.mjs
vendored
|
@ -1,6 +1,6 @@
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { globby as glob } from 'globby';
|
import { glob } from 'tinyglobby';
|
||||||
import { setOutput } from './utils.mjs';
|
import { setOutput } from './utils.mjs';
|
||||||
|
|
||||||
const { GITHUB_REF = 'main' } = process.env;
|
const { GITHUB_REF = 'main' } = process.env;
|
||||||
|
@ -85,6 +85,8 @@ async function generatePackageMap() {
|
||||||
const packageRoot = new URL('../../packages/', import.meta.url);
|
const packageRoot = new URL('../../packages/', import.meta.url);
|
||||||
const packages = await glob(['*/package.json', '*/*/package.json'], {
|
const packages = await glob(['*/package.json', '*/*/package.json'], {
|
||||||
cwd: fileURLToPath(packageRoot),
|
cwd: fileURLToPath(packageRoot),
|
||||||
|
expandDirectories: false,
|
||||||
|
ignore: ['**/node_modules/**'],
|
||||||
});
|
});
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
packages.map(async (pkg) => {
|
packages.map(async (pkg) => {
|
||||||
|
|
|
@ -62,11 +62,11 @@
|
||||||
"esbuild": "^0.24.2",
|
"esbuild": "^0.24.2",
|
||||||
"eslint": "^9.19.0",
|
"eslint": "^9.19.0",
|
||||||
"eslint-plugin-regexp": "^2.7.0",
|
"eslint-plugin-regexp": "^2.7.0",
|
||||||
"globby": "^14.0.2",
|
|
||||||
"only-allow": "^1.2.1",
|
"only-allow": "^1.2.1",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"prettier-plugin-astro": "^0.14.1",
|
"prettier-plugin-astro": "^0.14.1",
|
||||||
"publint": "^0.3.2",
|
"publint": "^0.3.2",
|
||||||
|
"tinyglobby": "^0.2.12",
|
||||||
"turbo": "^2.4.0",
|
"turbo": "^2.4.0",
|
||||||
"typescript": "~5.7.3",
|
"typescript": "~5.7.3",
|
||||||
"typescript-eslint": "^8.23.0"
|
"typescript-eslint": "^8.23.0"
|
||||||
|
|
|
@ -143,7 +143,6 @@
|
||||||
"es-module-lexer": "^1.6.0",
|
"es-module-lexer": "^1.6.0",
|
||||||
"esbuild": "^0.24.2",
|
"esbuild": "^0.24.2",
|
||||||
"estree-walker": "^3.0.3",
|
"estree-walker": "^3.0.3",
|
||||||
"fast-glob": "^3.3.3",
|
|
||||||
"flattie": "^1.1.1",
|
"flattie": "^1.1.1",
|
||||||
"github-slugger": "^2.0.0",
|
"github-slugger": "^2.0.0",
|
||||||
"html-escaper": "3.0.3",
|
"html-escaper": "3.0.3",
|
||||||
|
@ -152,17 +151,18 @@
|
||||||
"kleur": "^4.1.5",
|
"kleur": "^4.1.5",
|
||||||
"magic-string": "^0.30.17",
|
"magic-string": "^0.30.17",
|
||||||
"magicast": "^0.3.5",
|
"magicast": "^0.3.5",
|
||||||
"micromatch": "^4.0.8",
|
|
||||||
"mrmime": "^2.0.0",
|
"mrmime": "^2.0.0",
|
||||||
"neotraverse": "^0.6.18",
|
"neotraverse": "^0.6.18",
|
||||||
"p-limit": "^6.2.0",
|
"p-limit": "^6.2.0",
|
||||||
"p-queue": "^8.1.0",
|
"p-queue": "^8.1.0",
|
||||||
|
"picomatch": "^4.0.2",
|
||||||
"preferred-pm": "^4.1.1",
|
"preferred-pm": "^4.1.1",
|
||||||
"prompts": "^2.4.2",
|
"prompts": "^2.4.2",
|
||||||
"rehype": "^13.0.2",
|
"rehype": "^13.0.2",
|
||||||
"semver": "^7.7.1",
|
"semver": "^7.7.1",
|
||||||
"shiki": "^1.29.2",
|
"shiki": "^1.29.2",
|
||||||
"tinyexec": "^0.3.2",
|
"tinyexec": "^0.3.2",
|
||||||
|
"tinyglobby": "^0.2.12",
|
||||||
"tsconfck": "^3.1.4",
|
"tsconfck": "^3.1.4",
|
||||||
"ultrahtml": "^1.5.3",
|
"ultrahtml": "^1.5.3",
|
||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
|
@ -194,7 +194,7 @@
|
||||||
"@types/html-escaper": "3.0.4",
|
"@types/html-escaper": "3.0.4",
|
||||||
"@types/http-cache-semantics": "^4.0.4",
|
"@types/http-cache-semantics": "^4.0.4",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/micromatch": "^4.0.9",
|
"@types/picomatch": "^3.0.2",
|
||||||
"@types/prompts": "^2.4.9",
|
"@types/prompts": "^2.4.9",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
"@types/yargs-parser": "^21.0.3",
|
"@types/yargs-parser": "^21.0.3",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { promises as fs, existsSync } from 'node:fs';
|
import { promises as fs, existsSync } from 'node:fs';
|
||||||
import { relative } from 'node:path';
|
import { relative } from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import fastGlob from 'fast-glob';
|
|
||||||
import { bold, green } from 'kleur/colors';
|
import { bold, green } from 'kleur/colors';
|
||||||
import micromatch from 'micromatch';
|
|
||||||
import pLimit from 'p-limit';
|
import pLimit from 'p-limit';
|
||||||
|
import picomatch from 'picomatch';
|
||||||
|
import { glob as tinyglobby } from 'tinyglobby';
|
||||||
import type { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';
|
import type { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';
|
||||||
import type { RenderedContent } from '../data-store.js';
|
import type { RenderedContent } from '../data-store.js';
|
||||||
import { getContentEntryIdAndSlug, posixRelative } from '../utils.js';
|
import { getContentEntryIdAndSlug, posixRelative } from '../utils.js';
|
||||||
|
@ -236,8 +236,9 @@ export function glob(globOptions: GlobOptions): Loader {
|
||||||
logger.warn(`The base directory "${fileURLToPath(baseDir)}" does not exist.`);
|
logger.warn(`The base directory "${fileURLToPath(baseDir)}" does not exist.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = await fastGlob(globOptions.pattern, {
|
const files = await tinyglobby(globOptions.pattern, {
|
||||||
cwd: fileURLToPath(baseDir),
|
cwd: fileURLToPath(baseDir),
|
||||||
|
expandDirectories: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (exists && files.length === 0) {
|
if (exists && files.length === 0) {
|
||||||
|
@ -321,7 +322,7 @@ export function glob(globOptions: GlobOptions): Loader {
|
||||||
watcher.add(filePath);
|
watcher.add(filePath);
|
||||||
|
|
||||||
const matchesGlob = (entry: string) =>
|
const matchesGlob = (entry: string) =>
|
||||||
!entry.startsWith('../') && micromatch.isMatch(entry, globOptions.pattern);
|
!entry.startsWith('../') && picomatch.isMatch(entry, globOptions.pattern);
|
||||||
|
|
||||||
const basePath = fileURLToPath(baseDir);
|
const basePath = fileURLToPath(baseDir);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type fsMod from 'node:fs';
|
import type fsMod from 'node:fs';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import glob from 'fast-glob';
|
|
||||||
import { bold, cyan } from 'kleur/colors';
|
import { bold, cyan } from 'kleur/colors';
|
||||||
|
import { glob } from 'tinyglobby';
|
||||||
import { type ViteDevServer, normalizePath } from 'vite';
|
import { type ViteDevServer, normalizePath } from 'vite';
|
||||||
import { type ZodSchema, z } from 'zod';
|
import { type ZodSchema, z } from 'zod';
|
||||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||||
|
@ -94,21 +94,16 @@ export async function createContentTypesGenerator({
|
||||||
}
|
}
|
||||||
const globResult = await glob('**', {
|
const globResult = await glob('**', {
|
||||||
cwd: fileURLToPath(contentPaths.contentDir),
|
cwd: fileURLToPath(contentPaths.contentDir),
|
||||||
fs: {
|
absolute: true,
|
||||||
readdir: fs.readdir.bind(fs),
|
|
||||||
readdirSync: fs.readdirSync.bind(fs),
|
|
||||||
},
|
|
||||||
onlyFiles: false,
|
|
||||||
objectMode: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const entry of globResult) {
|
for (const fullPath of globResult) {
|
||||||
const fullPath = path.join(fileURLToPath(contentPaths.contentDir), entry.path);
|
|
||||||
const entryURL = pathToFileURL(fullPath);
|
const entryURL = pathToFileURL(fullPath);
|
||||||
if (entryURL.href.startsWith(contentPaths.config.url.href)) continue;
|
if (entryURL.href.startsWith(contentPaths.config.url.href)) continue;
|
||||||
if (entry.dirent.isFile()) {
|
const stat = fs.statSync(fullPath);
|
||||||
|
if (stat.isFile()) {
|
||||||
events.push({ name: 'add', entry: entryURL });
|
events.push({ name: 'add', entry: entryURL });
|
||||||
} else if (entry.dirent.isDirectory()) {
|
} else if (stat.isDirectory()) {
|
||||||
events.push({ name: 'addDir', entry: entryURL });
|
events.push({ name: 'addDir', entry: entryURL });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ import nodeFs from 'node:fs';
|
||||||
import { extname } from 'node:path';
|
import { extname } from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import { dataToEsm } from '@rollup/pluginutils';
|
import { dataToEsm } from '@rollup/pluginutils';
|
||||||
import glob from 'fast-glob';
|
|
||||||
import pLimit from 'p-limit';
|
import pLimit from 'p-limit';
|
||||||
|
import { glob } from 'tinyglobby';
|
||||||
import type { Plugin, ViteDevServer } from 'vite';
|
import type { Plugin, ViteDevServer } from 'vite';
|
||||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
||||||
import { rootRelativePath } from '../core/viteUtils.js';
|
import { rootRelativePath } from '../core/viteUtils.js';
|
||||||
|
@ -280,7 +280,7 @@ export async function generateLookupMap({
|
||||||
{
|
{
|
||||||
absolute: true,
|
absolute: true,
|
||||||
cwd: fileURLToPath(root),
|
cwd: fileURLToPath(root),
|
||||||
fs,
|
expandDirectories: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import glob from 'fast-glob';
|
|
||||||
import type { OutputChunk } from 'rollup';
|
import type { OutputChunk } from 'rollup';
|
||||||
|
import { glob } from 'tinyglobby';
|
||||||
import type { Plugin as VitePlugin } from 'vite';
|
import type { Plugin as VitePlugin } from 'vite';
|
||||||
import { getAssetsPrefix } from '../../../assets/utils/getAssetsPrefix.js';
|
import { getAssetsPrefix } from '../../../assets/utils/getAssetsPrefix.js';
|
||||||
import { normalizeTheLocale } from '../../../i18n/index.js';
|
import { normalizeTheLocale } from '../../../i18n/index.js';
|
||||||
|
|
|
@ -2,8 +2,8 @@ import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import { teardown } from '@astrojs/compiler';
|
import { teardown } from '@astrojs/compiler';
|
||||||
import glob from 'fast-glob';
|
|
||||||
import { bgGreen, black, green } from 'kleur/colors';
|
import { bgGreen, black, green } from 'kleur/colors';
|
||||||
|
import { glob } from 'tinyglobby';
|
||||||
import * as vite from 'vite';
|
import * as vite from 'vite';
|
||||||
import { type BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
import { type BuildInternals, createBuildInternals } from '../../core/build/internal.js';
|
||||||
import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js';
|
import { emptyDir, removeEmptyDirs } from '../../core/fs/index.js';
|
||||||
|
@ -247,8 +247,8 @@ async function clientBuild(
|
||||||
// Nothing to do if there is no client-side JS.
|
// Nothing to do if there is no client-side JS.
|
||||||
if (!input.size) {
|
if (!input.size) {
|
||||||
// If SSR, copy public over
|
// If SSR, copy public over
|
||||||
if (ssr) {
|
if (ssr && fs.existsSync(settings.config.publicDir)) {
|
||||||
await copyFiles(settings.config.publicDir, out, true);
|
await fs.promises.cp(settings.config.publicDir, out, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -384,31 +384,12 @@ async function cleanServerOutput(
|
||||||
.map((fileName) => fs.promises.rm(new URL(fileName, out))),
|
.map((fileName) => fs.promises.rm(new URL(fileName, out))),
|
||||||
);
|
);
|
||||||
// Copy assets before cleaning directory if outside root
|
// Copy assets before cleaning directory if outside root
|
||||||
await copyFiles(out, opts.settings.config.outDir, true);
|
await fs.promises.cp(out, opts.settings.config.outDir, { recursive: true, force: true });
|
||||||
await fs.promises.rm(out, { recursive: true });
|
await fs.promises.rm(out, { recursive: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function copyFiles(fromFolder: URL, toFolder: URL, includeDotfiles = false) {
|
|
||||||
const files = await glob('**/*', {
|
|
||||||
cwd: fileURLToPath(fromFolder),
|
|
||||||
dot: includeDotfiles,
|
|
||||||
});
|
|
||||||
if (files.length === 0) return;
|
|
||||||
return await Promise.all(
|
|
||||||
files.map(async function copyFile(filename) {
|
|
||||||
const from = new URL(filename, fromFolder);
|
|
||||||
const to = new URL(filename, toFolder);
|
|
||||||
const lastFolder = new URL('./', to);
|
|
||||||
return fs.promises.mkdir(lastFolder, { recursive: true }).then(async function fsCopyFile() {
|
|
||||||
const p = await fs.promises.copyFile(from, to, fs.constants.COPYFILE_FICLONE);
|
|
||||||
return p;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ssrMoveAssets(opts: StaticBuildOptions) {
|
async function ssrMoveAssets(opts: StaticBuildOptions) {
|
||||||
opts.logger.info('build', 'Rearranging server assets...');
|
opts.logger.info('build', 'Rearranging server assets...');
|
||||||
const serverRoot =
|
const serverRoot =
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import nodeFs from 'node:fs';
|
import nodeFs from 'node:fs';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import glob from 'fast-glob';
|
import { convertPathToPattern } from 'tinyglobby';
|
||||||
import * as vite from 'vite';
|
import * as vite from 'vite';
|
||||||
import { crawlFrameworkPkgs } from 'vitefu';
|
import { crawlFrameworkPkgs } from 'vitefu';
|
||||||
import { vitePluginActions, vitePluginUserActions } from '../actions/plugins.js';
|
import { vitePluginActions, vitePluginUserActions } from '../actions/plugins.js';
|
||||||
|
@ -124,7 +124,7 @@ export async function createVite(
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const srcDirPattern = glob.convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
const srcDirPattern = convertPathToPattern(fileURLToPath(settings.config.srcDir));
|
||||||
const envLoader = createEnvLoader(mode, settings.config);
|
const envLoader = createEnvLoader(mode, settings.config);
|
||||||
|
|
||||||
// Start with the Vite configuration that Astro core needs
|
// Start with the Vite configuration that Astro core needs
|
||||||
|
|
|
@ -4,7 +4,7 @@ import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { stripVTControlCharacters } from 'node:util';
|
import { stripVTControlCharacters } from 'node:util';
|
||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
import fastGlob from 'fast-glob';
|
import { glob } from 'tinyglobby';
|
||||||
import { Agent } from 'undici';
|
import { Agent } from 'undici';
|
||||||
import { check } from '../dist/cli/check/index.js';
|
import { check } from '../dist/cli/check/index.js';
|
||||||
import { globalContentLayer } from '../dist/content/content-layer.js';
|
import { globalContentLayer } from '../dist/content/content-layer.js';
|
||||||
|
@ -252,8 +252,9 @@ export async function loadFixture(inlineConfig) {
|
||||||
),
|
),
|
||||||
readdir: (fp) => fs.promises.readdir(new URL(fp.replace(/^\//, ''), config.outDir)),
|
readdir: (fp) => fs.promises.readdir(new URL(fp.replace(/^\//, ''), config.outDir)),
|
||||||
glob: (p) =>
|
glob: (p) =>
|
||||||
fastGlob(p, {
|
glob(p, {
|
||||||
cwd: fileURLToPath(config.outDir),
|
cwd: fileURLToPath(config.outDir),
|
||||||
|
expandDirectories: false,
|
||||||
}),
|
}),
|
||||||
clean: async () => {
|
clean: async () => {
|
||||||
await fs.promises.rm(config.outDir, {
|
await fs.promises.rm(config.outDir, {
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
"estree-walker": "^3.0.3",
|
"estree-walker": "^3.0.3",
|
||||||
"magic-string": "^0.30.17",
|
"magic-string": "^0.30.17",
|
||||||
"miniflare": "^3.20241230.1",
|
"miniflare": "^3.20241230.1",
|
||||||
"tiny-glob": "^0.2.9",
|
"tinyglobby": "^0.2.12",
|
||||||
"vite": "^6.0.7",
|
"vite": "^6.0.7",
|
||||||
"wrangler": "^3.101.0"
|
"wrangler": "^3.101.0"
|
||||||
},
|
},
|
||||||
|
@ -52,7 +52,6 @@
|
||||||
"astro-scripts": "workspace:*",
|
"astro-scripts": "workspace:*",
|
||||||
"cheerio": "1.0.0",
|
"cheerio": "1.0.0",
|
||||||
"execa": "^8.0.1",
|
"execa": "^8.0.1",
|
||||||
"fast-glob": "^3.3.3",
|
|
||||||
"rollup": "^4.30.1",
|
"rollup": "^4.30.1",
|
||||||
"strip-ansi": "^7.1.0"
|
"strip-ansi": "^7.1.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
removeLeadingForwardSlash,
|
removeLeadingForwardSlash,
|
||||||
removeTrailingForwardSlash,
|
removeTrailingForwardSlash,
|
||||||
} from '@astrojs/internal-helpers/path';
|
} from '@astrojs/internal-helpers/path';
|
||||||
import glob from 'tiny-glob';
|
import { glob } from 'tinyglobby';
|
||||||
|
|
||||||
// Copied from https://github.com/withastro/astro/blob/3776ecf0aa9e08a992d3ae76e90682fd04093721/packages/astro/src/core/routing/manifest/create.ts#L45-L70
|
// Copied from https://github.com/withastro/astro/blob/3776ecf0aa9e08a992d3ae76e90682fd04093721/packages/astro/src/core/routing/manifest/create.ts#L45-L70
|
||||||
// We're not sure how to improve this regex yet
|
// We're not sure how to improve this regex yet
|
||||||
|
@ -205,9 +205,8 @@ export async function createRoutesFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existsSync(fileURLToPath(_config.publicDir))) {
|
if (existsSync(fileURLToPath(_config.publicDir))) {
|
||||||
const staticFiles = await glob(`${fileURLToPath(_config.publicDir)}/**/*`, {
|
const staticFiles = await glob(`**/*`, {
|
||||||
cwd: fileURLToPath(_config.publicDir),
|
cwd: fileURLToPath(_config.publicDir),
|
||||||
filesOnly: true,
|
|
||||||
dot: true,
|
dot: true,
|
||||||
});
|
});
|
||||||
for (const staticFile of staticFiles) {
|
for (const staticFile of staticFiles) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as assert from 'node:assert/strict';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { describe, it } from 'node:test';
|
import { describe, it } from 'node:test';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import glob from 'tiny-glob';
|
import { glob } from 'tinyglobby';
|
||||||
import { astroCli } from './_test-utils.js';
|
import { astroCli } from './_test-utils.js';
|
||||||
|
|
||||||
const root = new URL('./fixtures/external-image-service/', import.meta.url);
|
const root = new URL('./fixtures/external-image-service/', import.meta.url);
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
"@netlify/functions": "^2.8.0",
|
"@netlify/functions": "^2.8.0",
|
||||||
"@vercel/nft": "^0.29.0",
|
"@vercel/nft": "^0.29.0",
|
||||||
"esbuild": "^0.24.0",
|
"esbuild": "^0.24.0",
|
||||||
|
"tinyglobby": "^0.2.12",
|
||||||
"vite": "^6.0.7"
|
"vite": "^6.0.7"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
@ -56,7 +57,6 @@
|
||||||
"cheerio": "1.0.0",
|
"cheerio": "1.0.0",
|
||||||
"devalue": "^5.1.1",
|
"devalue": "^5.1.1",
|
||||||
"execa": "^8.0.1",
|
"execa": "^8.0.1",
|
||||||
"fast-glob": "^3.3.3",
|
|
||||||
"strip-ansi": "^7.1.0",
|
"strip-ansi": "^7.1.0",
|
||||||
"typescript": "^5.7.3"
|
"typescript": "^5.7.3"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
||||||
IntegrationResolvedRoute,
|
IntegrationResolvedRoute,
|
||||||
} from 'astro';
|
} from 'astro';
|
||||||
import { build } from 'esbuild';
|
import { build } from 'esbuild';
|
||||||
import glob from 'fast-glob';
|
import { glob, globSync } from 'tinyglobby';
|
||||||
import { copyDependenciesToFunction } from './lib/nft.js';
|
import { copyDependenciesToFunction } from './lib/nft.js';
|
||||||
import type { Args } from './ssr-function.js';
|
import type { Args } from './ssr-function.js';
|
||||||
|
|
||||||
|
@ -283,6 +283,7 @@ export default function netlifyIntegration(
|
||||||
cwd: fileURLToPath(rootDir),
|
cwd: fileURLToPath(rootDir),
|
||||||
absolute: true,
|
absolute: true,
|
||||||
ignore: exclude,
|
ignore: exclude,
|
||||||
|
expandDirectories: false,
|
||||||
});
|
});
|
||||||
return files.map((file) => pathToFileURL(file));
|
return files.map((file) => pathToFileURL(file));
|
||||||
}
|
}
|
||||||
|
@ -306,7 +307,7 @@ export default function netlifyIntegration(
|
||||||
if (_config.vite.assetsInclude) {
|
if (_config.vite.assetsInclude) {
|
||||||
const mergeGlobbedIncludes = (globPattern: unknown) => {
|
const mergeGlobbedIncludes = (globPattern: unknown) => {
|
||||||
if (typeof globPattern === 'string') {
|
if (typeof globPattern === 'string') {
|
||||||
const entries = glob.sync(globPattern).map((p) => pathToFileURL(p));
|
const entries = globSync(globPattern).map((p) => pathToFileURL(p));
|
||||||
extraFilesToInclude.push(...entries);
|
extraFilesToInclude.push(...entries);
|
||||||
} else if (Array.isArray(globPattern)) {
|
} else if (Array.isArray(globPattern)) {
|
||||||
for (const pattern of globPattern) {
|
for (const pattern of globPattern) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { existsSync } from 'node:fs';
|
||||||
import { after, before, describe, it } from 'node:test';
|
import { after, before, describe, it } from 'node:test';
|
||||||
import netlify from '@astrojs/netlify';
|
import netlify from '@astrojs/netlify';
|
||||||
import * as cheerio from 'cheerio';
|
import * as cheerio from 'cheerio';
|
||||||
import glob from 'fast-glob';
|
import { globSync } from 'tinyglobby';
|
||||||
import { loadFixture } from '../../../../astro/test/test-utils.js';
|
import { loadFixture } from '../../../../astro/test/test-utils.js';
|
||||||
|
|
||||||
describe(
|
describe(
|
||||||
|
@ -32,7 +32,7 @@ describe(
|
||||||
|
|
||||||
it('Emits vite assets files', async () => {
|
it('Emits vite assets files', async () => {
|
||||||
for (const pattern of expectedAssetsInclude) {
|
for (const pattern of expectedAssetsInclude) {
|
||||||
const files = glob.sync(pattern);
|
const files = globSync(pattern);
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
existsSync(new URL(file, expectedCwd)),
|
existsSync(new URL(file, expectedCwd)),
|
||||||
|
@ -158,7 +158,7 @@ describe(
|
||||||
|
|
||||||
it('Does not include files when excluded', async () => {
|
it('Does not include files when excluded', async () => {
|
||||||
for (const pattern of includeFiles) {
|
for (const pattern of includeFiles) {
|
||||||
const files = glob.sync(pattern, { ignore: excludedTxt });
|
const files = globSync(pattern, { ignore: excludedTxt });
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
existsSync(new URL(file, expectedCwd)),
|
existsSync(new URL(file, expectedCwd)),
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
"@vercel/nft": "^0.29.0",
|
"@vercel/nft": "^0.29.0",
|
||||||
"@vercel/routing-utils": "^5.0.4",
|
"@vercel/routing-utils": "^5.0.4",
|
||||||
"esbuild": "^0.24.0",
|
"esbuild": "^0.24.0",
|
||||||
"fast-glob": "^3.3.3"
|
"tinyglobby": "^0.2.12"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"astro": "^5.0.0"
|
"astro": "^5.0.0"
|
||||||
|
|
|
@ -12,7 +12,7 @@ import type {
|
||||||
IntegrationResolvedRoute,
|
IntegrationResolvedRoute,
|
||||||
} from 'astro';
|
} from 'astro';
|
||||||
import { AstroError } from 'astro/errors';
|
import { AstroError } from 'astro/errors';
|
||||||
import glob from 'fast-glob';
|
import { globSync } from 'tinyglobby';
|
||||||
import {
|
import {
|
||||||
type DevImageService,
|
type DevImageService,
|
||||||
type VercelImageConfig,
|
type VercelImageConfig,
|
||||||
|
@ -353,7 +353,7 @@ export default function vercelAdapter({
|
||||||
if (_config.vite.assetsInclude) {
|
if (_config.vite.assetsInclude) {
|
||||||
const mergeGlobbedIncludes = (globPattern: unknown) => {
|
const mergeGlobbedIncludes = (globPattern: unknown) => {
|
||||||
if (typeof globPattern === 'string') {
|
if (typeof globPattern === 'string') {
|
||||||
const entries = glob.sync(globPattern).map((p) => pathToFileURL(p));
|
const entries = globSync(globPattern).map((p) => pathToFileURL(p));
|
||||||
extraFilesToInclude.push(...entries);
|
extraFilesToInclude.push(...entries);
|
||||||
} else if (Array.isArray(globPattern)) {
|
} else if (Array.isArray(globPattern)) {
|
||||||
for (const pattern of globPattern) {
|
for (const pattern of globPattern) {
|
||||||
|
|
1504
pnpm-lock.yaml
generated
1504
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import glob from 'fast-glob';
|
|
||||||
import { dim, green, red, yellow } from 'kleur/colors';
|
import { dim, green, red, yellow } from 'kleur/colors';
|
||||||
|
import { glob } from 'tinyglobby';
|
||||||
import prebuild from './prebuild.js';
|
import prebuild from './prebuild.js';
|
||||||
|
|
||||||
/** @type {import('esbuild').BuildOptions} */
|
/** @type {import('esbuild').BuildOptions} */
|
||||||
|
@ -38,10 +38,13 @@ export default async function build(...args) {
|
||||||
const prebuilds = getPrebuilds(isDev, args);
|
const prebuilds = getPrebuilds(isDev, args);
|
||||||
const patterns = args
|
const patterns = args
|
||||||
.filter((f) => !!f) // remove empty args
|
.filter((f) => !!f) // remove empty args
|
||||||
|
.filter((f) => !f.startsWith('--')) // remove flags
|
||||||
.map((f) => f.replace(/^'/, '').replace(/'$/, '')); // Needed for Windows: glob strings contain surrounding string chars??? remove these
|
.map((f) => f.replace(/^'/, '').replace(/'$/, '')); // Needed for Windows: glob strings contain surrounding string chars??? remove these
|
||||||
let entryPoints = [].concat(
|
let entryPoints = [].concat(
|
||||||
...(await Promise.all(
|
...(await Promise.all(
|
||||||
patterns.map((pattern) => glob(pattern, { filesOnly: true, absolute: true })),
|
patterns.map((pattern) =>
|
||||||
|
glob(pattern, { filesOnly: true, expandDirectories: false, absolute: true }),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -115,7 +118,12 @@ export default async function build(...args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clean(outdir) {
|
async function clean(outdir) {
|
||||||
const files = await glob([`${outdir}/**`, `!${outdir}/**/*.d.ts`], { filesOnly: true });
|
const files = await glob('**', {
|
||||||
|
cwd: outdir,
|
||||||
|
filesOnly: true,
|
||||||
|
ignore: ['**/*.d.ts'],
|
||||||
|
absolute: true,
|
||||||
|
});
|
||||||
await Promise.all(files.map((file) => fs.rm(file, { force: true })));
|
await Promise.all(files.map((file) => fs.rm(file, { force: true })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import glob from 'fast-glob';
|
|
||||||
import { red } from 'kleur/colors';
|
import { red } from 'kleur/colors';
|
||||||
|
import { glob } from 'tinyglobby';
|
||||||
|
|
||||||
function escapeTemplateLiterals(str) {
|
function escapeTemplateLiterals(str) {
|
||||||
return str.replace(/\`/g, '\\`').replace(/\$\{/g, '\\${');
|
return str.replace(/\`/g, '\\`').replace(/\$\{/g, '\\${');
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { run } from 'node:test';
|
||||||
import { spec } from 'node:test/reporters';
|
import { spec } from 'node:test/reporters';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
import { parseArgs } from 'node:util';
|
import { parseArgs } from 'node:util';
|
||||||
import glob from 'fast-glob';
|
import { glob } from 'tinyglobby';
|
||||||
|
|
||||||
const isCI = !!process.env.CI;
|
const isCI = !!process.env.CI;
|
||||||
const defaultTimeout = isCI ? 1400000 : 600000;
|
const defaultTimeout = isCI ? 1400000 : 600000;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { globby as glob } from 'globby';
|
import { glob } from 'tinyglobby';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file updates the dependencies' versions in `examples/*` to match the workspace packages' versions.
|
This file updates the dependencies' versions in `examples/*` to match the workspace packages' versions.
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.24.2",
|
"esbuild": "^0.24.2",
|
||||||
"esbuild-plugin-copy": "^2.1.1",
|
|
||||||
"fast-glob": "^3.3.3",
|
|
||||||
"kleur": "^4.1.5",
|
"kleur": "^4.1.5",
|
||||||
"p-limit": "^6.2.0",
|
"p-limit": "^6.2.0",
|
||||||
"tinyexec": "^0.3.2",
|
"tinyexec": "^0.3.2",
|
||||||
|
"tinyglobby": "^0.2.12",
|
||||||
"tsconfck": "^3.1.4"
|
"tsconfck": "^3.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue