full site update
This commit is contained in:
21
node_modules/tinyglobby/LICENSE
generated
vendored
Normal file
21
node_modules/tinyglobby/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Madeline Gurriarán
|
||||
|
||||
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.
|
72
node_modules/tinyglobby/README.md
generated
vendored
Normal file
72
node_modules/tinyglobby/README.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# tinyglobby
|
||||
|
||||
[](https://npmjs.com/package/tinyglobby)
|
||||
[](https://npmjs.com/package/tinyglobby)
|
||||
|
||||
A fast and minimal alternative to globby and fast-glob, meant to behave the same way.
|
||||
|
||||
Both globby and fast-glob present some behavior no other globbing lib has,
|
||||
which makes it hard to manually replace with something smaller and better.
|
||||
|
||||
This library uses only two subdependencies, compared to `globby`'s [23](https://npmgraph.js.org/?q=globby@14.1.0)
|
||||
and `fast-glob`'s [17](https://npmgraph.js.org/?q=fast-glob@3.3.3).
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { glob, globSync } from 'tinyglobby';
|
||||
|
||||
await glob(['files/*.ts', '!**/*.d.ts'], { cwd: 'src' });
|
||||
globSync(['src/**/*.ts'], { ignore: ['**/*.d.ts'] });
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
- `glob(patterns: string | string[], options: GlobOptions): Promise<string[]>`: Returns a promise with an array of matches.
|
||||
- `globSync(patterns: string | string[], options: GlobOptions): string[]`: Returns an array of matches.
|
||||
- `convertPathToPattern(path: string): string`: Converts a path to a pattern depending on the platform.
|
||||
- `escapePath(path: string): string`: Escapes a path's special characters depending on the platform.
|
||||
- `isDynamicPattern(pattern: string, options?: GlobOptions): boolean`: Checks if a pattern is dynamic.
|
||||
|
||||
## Options
|
||||
|
||||
- `patterns`: An array of glob patterns to search for. Defaults to `['**/*']`.
|
||||
- `ignore`: An array of glob patterns to ignore.
|
||||
- `cwd`: The current working directory in which to search. Defaults to `process.cwd()`.
|
||||
- `absolute`: Whether to return absolute paths. Defaults to `false`.
|
||||
- `dot`: Whether to allow entries starting with a dot. Defaults to `false`.
|
||||
- `deep`: Maximum depth of a directory. Defaults to `Infinity`.
|
||||
- `followSymbolicLinks`: Whether to traverse and include symbolic links. Defaults to `true`.
|
||||
- `caseSensitiveMatch`: Whether to match in case-sensitive mode. Defaults to `true`.
|
||||
- `expandDirectories`: Whether to expand directories. Disable to best match `fast-glob`. Defaults to `true`.
|
||||
- `onlyDirectories`: Enable to only return directories. Disables `onlyFiles` if set. Defaults to `false`.
|
||||
- `onlyFiles`: Enable to only return files. Defaults to `true`.
|
||||
- `debug`: Enable debug logs. Useful for development purposes.
|
||||
|
||||
## Used by
|
||||
|
||||
`tinyglobby` is downloaded many times by projects all around the world. Here's a partial list of notable projects that use it:
|
||||
|
||||
<!-- should be sorted by weekly download count -->
|
||||
- [`vite`](https://github.com/vitejs/vite)
|
||||
- [`pnpm`](https://github.com/pnpm/pnpm)
|
||||
- [`node-gyp`](https://github.com/nodejs/node-gyp)
|
||||
- [`eslint-import-resolver-typescript`](https://github.com/import-js/eslint-import-resolver-typescript)
|
||||
- [`vitest`](https://github.com/vitest-dev/vitest)
|
||||
- [`copy-webpack-plugin`](https://github.com/webpack-contrib/copy-webpack-plugin)
|
||||
- [`storybook`](https://github.com/storybookjs/storybook)
|
||||
- [`ts-morph`](https://github.com/dsherret/ts-morph)
|
||||
- [`nx`](https://github.com/nrwl/nx)
|
||||
- [`sort-package-json`](https://github.com/keithamus/sort-package-json)
|
||||
- [`unimport`](https://github.com/unjs/unimport)
|
||||
- [`tsup`](https://github.com/egoist/tsup)
|
||||
- [`lerna`](https://github.com/lerna/lerna)
|
||||
- [`cspell`](https://github.com/streetsidesoftware/cspell)
|
||||
- [`nuxt`](https://github.com/nuxt/nuxt)
|
||||
- [`postcss-mixins`](https://github.com/postcss/postcss-mixins)
|
||||
- [`astro`](https://github.com/withastro/astro)
|
||||
- [`unocss`](https://github.com/unocss/unocss)
|
||||
- [`vitepress`](https://github.com/vuejs/vitepress)
|
||||
- [`pkg-pr-new`](https://github.com/stackblitz-labs/pkg.pr.new)
|
||||
- Your own project? [Open an issue](https://github.com/SuperchupuDev/tinyglobby/issues)
|
||||
if you feel like this list is incomplete.
|
46
node_modules/tinyglobby/dist/index.d.mts
generated
vendored
Normal file
46
node_modules/tinyglobby/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
//#region src/utils.d.ts
|
||||
|
||||
declare const convertPathToPattern: (path: string) => string;
|
||||
declare const escapePath: (path: string) => string;
|
||||
// #endregion
|
||||
// #region isDynamicPattern
|
||||
/*
|
||||
Has a few minor differences with `fast-glob` for better accuracy:
|
||||
|
||||
Doesn't necessarily return false on patterns that include `\\`.
|
||||
|
||||
Returns true if the pattern includes parentheses,
|
||||
regardless of them representing one single pattern or not.
|
||||
|
||||
Returns true for unfinished glob extensions i.e. `(h`, `+(h`.
|
||||
|
||||
Returns true for unfinished brace expansions as long as they include `,` or `..`.
|
||||
*/
|
||||
declare function isDynamicPattern(pattern: string, options?: {
|
||||
caseSensitiveMatch: boolean;
|
||||
}): boolean; //#endregion
|
||||
//#region src/index.d.ts
|
||||
|
||||
// #endregion
|
||||
// #region log
|
||||
interface GlobOptions {
|
||||
absolute?: boolean;
|
||||
cwd?: string;
|
||||
patterns?: string | string[];
|
||||
ignore?: string | string[];
|
||||
dot?: boolean;
|
||||
deep?: number;
|
||||
followSymbolicLinks?: boolean;
|
||||
caseSensitiveMatch?: boolean;
|
||||
expandDirectories?: boolean;
|
||||
onlyDirectories?: boolean;
|
||||
onlyFiles?: boolean;
|
||||
debug?: boolean;
|
||||
}
|
||||
declare function glob(patterns: string | string[], options?: Omit<GlobOptions, "patterns">): Promise<string[]>;
|
||||
declare function glob(options: GlobOptions): Promise<string[]>;
|
||||
declare function globSync(patterns: string | string[], options?: Omit<GlobOptions, "patterns">): string[];
|
||||
declare function globSync(options: GlobOptions): string[];
|
||||
|
||||
//#endregion
|
||||
export { GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
|
46
node_modules/tinyglobby/dist/index.d.ts
generated
vendored
Normal file
46
node_modules/tinyglobby/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
//#region src/utils.d.ts
|
||||
|
||||
declare const convertPathToPattern: (path: string) => string;
|
||||
declare const escapePath: (path: string) => string;
|
||||
// #endregion
|
||||
// #region isDynamicPattern
|
||||
/*
|
||||
Has a few minor differences with `fast-glob` for better accuracy:
|
||||
|
||||
Doesn't necessarily return false on patterns that include `\\`.
|
||||
|
||||
Returns true if the pattern includes parentheses,
|
||||
regardless of them representing one single pattern or not.
|
||||
|
||||
Returns true for unfinished glob extensions i.e. `(h`, `+(h`.
|
||||
|
||||
Returns true for unfinished brace expansions as long as they include `,` or `..`.
|
||||
*/
|
||||
declare function isDynamicPattern(pattern: string, options?: {
|
||||
caseSensitiveMatch: boolean;
|
||||
}): boolean; //#endregion
|
||||
//#region src/index.d.ts
|
||||
|
||||
// #endregion
|
||||
// #region log
|
||||
interface GlobOptions {
|
||||
absolute?: boolean;
|
||||
cwd?: string;
|
||||
patterns?: string | string[];
|
||||
ignore?: string | string[];
|
||||
dot?: boolean;
|
||||
deep?: number;
|
||||
followSymbolicLinks?: boolean;
|
||||
caseSensitiveMatch?: boolean;
|
||||
expandDirectories?: boolean;
|
||||
onlyDirectories?: boolean;
|
||||
onlyFiles?: boolean;
|
||||
debug?: boolean;
|
||||
}
|
||||
declare function glob(patterns: string | string[], options?: Omit<GlobOptions, "patterns">): Promise<string[]>;
|
||||
declare function glob(options: GlobOptions): Promise<string[]>;
|
||||
declare function globSync(patterns: string | string[], options?: Omit<GlobOptions, "patterns">): string[];
|
||||
declare function globSync(options: GlobOptions): string[];
|
||||
|
||||
//#endregion
|
||||
export { GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
|
267
node_modules/tinyglobby/dist/index.js
generated
vendored
Normal file
267
node_modules/tinyglobby/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
//#region rolldown:runtime
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
||||
key = keys[i];
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
||||
get: ((k) => from[k]).bind(null, key),
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
||||
});
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
||||
value: mod,
|
||||
enumerable: true
|
||||
}) : target, mod));
|
||||
|
||||
//#endregion
|
||||
const path = __toESM(require("path"));
|
||||
const fdir = __toESM(require("fdir"));
|
||||
const picomatch = __toESM(require("picomatch"));
|
||||
|
||||
//#region src/utils.ts
|
||||
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
||||
function getPartialMatcher(patterns, options) {
|
||||
const patternsCount = patterns.length;
|
||||
const patternsParts = Array(patternsCount);
|
||||
const regexes = Array(patternsCount);
|
||||
for (let i = 0; i < patternsCount; i++) {
|
||||
const parts = splitPattern(patterns[i]);
|
||||
patternsParts[i] = parts;
|
||||
const partsCount = parts.length;
|
||||
const partRegexes = Array(partsCount);
|
||||
for (let j = 0; j < partsCount; j++) partRegexes[j] = picomatch.default.makeRe(parts[j], options);
|
||||
regexes[i] = partRegexes;
|
||||
}
|
||||
return (input) => {
|
||||
const inputParts = input.split("/");
|
||||
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
||||
for (let i = 0; i < patterns.length; i++) {
|
||||
const patternParts = patternsParts[i];
|
||||
const regex = regexes[i];
|
||||
const inputPatternCount = inputParts.length;
|
||||
const minParts = Math.min(inputPatternCount, patternParts.length);
|
||||
let j = 0;
|
||||
while (j < minParts) {
|
||||
const part = patternParts[j];
|
||||
if (part.includes("/")) return true;
|
||||
const match = regex[j].test(inputParts[j]);
|
||||
if (!match) break;
|
||||
if (part === "**") return true;
|
||||
j++;
|
||||
}
|
||||
if (j === inputPatternCount) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
const splitPatternOptions = { parts: true };
|
||||
function splitPattern(path$2) {
|
||||
var _result$parts;
|
||||
const result = picomatch.default.scan(path$2, splitPatternOptions);
|
||||
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$2];
|
||||
}
|
||||
const isWin = process.platform === "win32";
|
||||
const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
||||
function convertPosixPathToPattern(path$2) {
|
||||
return escapePosixPath(path$2);
|
||||
}
|
||||
function convertWin32PathToPattern(path$2) {
|
||||
return escapeWin32Path(path$2).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
||||
}
|
||||
const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
|
||||
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
||||
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
||||
const escapePosixPath = (path$2) => path$2.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
||||
const escapeWin32Path = (path$2) => path$2.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
||||
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
||||
function isDynamicPattern(pattern, options) {
|
||||
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
|
||||
const scan = picomatch.default.scan(pattern);
|
||||
return scan.isGlob || scan.negated;
|
||||
}
|
||||
function log(...tasks) {
|
||||
console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`, ...tasks);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/index.ts
|
||||
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
||||
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
||||
const BACKSLASHES = /\\/g;
|
||||
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
||||
let result = pattern;
|
||||
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
||||
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
||||
const escapedCwd = escapePath(cwd);
|
||||
if (path.default.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = path.posix.relative(escapedCwd, result);
|
||||
else result = path.posix.normalize(result);
|
||||
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
||||
const parts = splitPattern(result);
|
||||
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
||||
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
||||
let i = 0;
|
||||
const cwdParts = escapedCwd.split("/");
|
||||
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
||||
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
||||
i++;
|
||||
}
|
||||
const potentialRoot = path.posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
||||
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
||||
props.root = potentialRoot;
|
||||
props.depthOffset = -n + i;
|
||||
}
|
||||
}
|
||||
if (!isIgnore && props.depthOffset >= 0) {
|
||||
var _props$commonPath;
|
||||
(_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
|
||||
const newCommonPath = [];
|
||||
const length = Math.min(props.commonPath.length, parts.length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
const part = parts[i];
|
||||
if (part === "**" && !parts[i + 1]) {
|
||||
newCommonPath.pop();
|
||||
break;
|
||||
}
|
||||
if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
|
||||
newCommonPath.push(part);
|
||||
}
|
||||
props.depthOffset = newCommonPath.length;
|
||||
props.commonPath = newCommonPath;
|
||||
props.root = newCommonPath.length > 0 ? path.default.posix.join(cwd, ...newCommonPath) : cwd;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, props) {
|
||||
if (typeof patterns === "string") patterns = [patterns];
|
||||
else if (!patterns) patterns = ["**/*"];
|
||||
if (typeof ignore === "string") ignore = [ignore];
|
||||
const matchPatterns = [];
|
||||
const ignorePatterns = [];
|
||||
for (const pattern of ignore) {
|
||||
if (!pattern) continue;
|
||||
if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
|
||||
}
|
||||
for (const pattern of patterns) {
|
||||
if (!pattern) continue;
|
||||
if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
|
||||
else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
|
||||
}
|
||||
return {
|
||||
match: matchPatterns,
|
||||
ignore: ignorePatterns
|
||||
};
|
||||
}
|
||||
function getRelativePath(path$2, cwd, root) {
|
||||
return path.posix.relative(cwd, `${root}/${path$2}`) || ".";
|
||||
}
|
||||
function processPath(path$2, cwd, root, isDirectory, absolute) {
|
||||
const relativePath = absolute ? path$2.slice(root === "/" ? 1 : root.length + 1) || "." : path$2;
|
||||
if (root === cwd) return isDirectory && relativePath !== "." ? relativePath.slice(0, -1) : relativePath;
|
||||
return getRelativePath(relativePath, cwd, root);
|
||||
}
|
||||
function formatPaths(paths, cwd, root) {
|
||||
for (let i = paths.length - 1; i >= 0; i--) {
|
||||
const path$2 = paths[i];
|
||||
paths[i] = getRelativePath(path$2, cwd, root) + (!path$2 || path$2.endsWith("/") ? "/" : "");
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
function crawl(options, cwd, sync) {
|
||||
if (process.env.TINYGLOBBY_DEBUG) options.debug = true;
|
||||
if (options.debug) log("globbing with options:", options, "cwd:", cwd);
|
||||
if (Array.isArray(options.patterns) && options.patterns.length === 0) return sync ? [] : Promise.resolve([]);
|
||||
const props = {
|
||||
root: cwd,
|
||||
commonPath: null,
|
||||
depthOffset: 0
|
||||
};
|
||||
const processed = processPatterns(options, cwd, props);
|
||||
const nocase = options.caseSensitiveMatch === false;
|
||||
if (options.debug) log("internal processing patterns:", processed);
|
||||
const matcher = (0, picomatch.default)(processed.match, {
|
||||
dot: options.dot,
|
||||
nocase,
|
||||
ignore: processed.ignore
|
||||
});
|
||||
const ignore = (0, picomatch.default)(processed.ignore, {
|
||||
dot: options.dot,
|
||||
nocase
|
||||
});
|
||||
const partialMatcher = getPartialMatcher(processed.match, {
|
||||
dot: options.dot,
|
||||
nocase
|
||||
});
|
||||
const fdirOptions = {
|
||||
filters: [options.debug ? (p, isDirectory) => {
|
||||
const path$2 = processPath(p, cwd, props.root, isDirectory, options.absolute);
|
||||
const matches = matcher(path$2);
|
||||
if (matches) log(`matched ${path$2}`);
|
||||
return matches;
|
||||
} : (p, isDirectory) => matcher(processPath(p, cwd, props.root, isDirectory, options.absolute))],
|
||||
exclude: options.debug ? (_, p) => {
|
||||
const relativePath = processPath(p, cwd, props.root, true, true);
|
||||
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
if (skipped) log(`skipped ${p}`);
|
||||
else log(`crawling ${p}`);
|
||||
return skipped;
|
||||
} : (_, p) => {
|
||||
const relativePath = processPath(p, cwd, props.root, true, true);
|
||||
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
},
|
||||
pathSeparator: "/",
|
||||
relativePaths: true,
|
||||
resolveSymlinks: true
|
||||
};
|
||||
if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
||||
if (options.absolute) {
|
||||
fdirOptions.relativePaths = false;
|
||||
fdirOptions.resolvePaths = true;
|
||||
fdirOptions.includeBasePath = true;
|
||||
}
|
||||
if (options.followSymbolicLinks === false) {
|
||||
fdirOptions.resolveSymlinks = false;
|
||||
fdirOptions.excludeSymlinks = true;
|
||||
}
|
||||
if (options.onlyDirectories) {
|
||||
fdirOptions.excludeFiles = true;
|
||||
fdirOptions.includeDirs = true;
|
||||
} else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
|
||||
props.root = props.root.replace(BACKSLASHES, "");
|
||||
const root = props.root;
|
||||
if (options.debug) log("internal properties:", props);
|
||||
const api = new fdir.fdir(fdirOptions).crawl(root);
|
||||
if (cwd === root || options.absolute) return sync ? api.sync() : api.withPromise();
|
||||
return sync ? formatPaths(api.sync(), cwd, root) : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
|
||||
}
|
||||
async function glob(patternsOrOptions, options) {
|
||||
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
||||
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
||||
...options,
|
||||
patterns: patternsOrOptions
|
||||
} : patternsOrOptions;
|
||||
const cwd = opts.cwd ? path.default.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
||||
return crawl(opts, cwd, false);
|
||||
}
|
||||
function globSync(patternsOrOptions, options) {
|
||||
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
||||
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
||||
...options,
|
||||
patterns: patternsOrOptions
|
||||
} : patternsOrOptions;
|
||||
const cwd = opts.cwd ? path.default.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
||||
return crawl(opts, cwd, true);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.convertPathToPattern = convertPathToPattern;
|
||||
exports.escapePath = escapePath;
|
||||
exports.glob = glob;
|
||||
exports.globSync = globSync;
|
||||
exports.isDynamicPattern = isDynamicPattern;
|
240
node_modules/tinyglobby/dist/index.mjs
generated
vendored
Normal file
240
node_modules/tinyglobby/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
import path, { posix } from "path";
|
||||
import { fdir } from "fdir";
|
||||
import picomatch from "picomatch";
|
||||
|
||||
//#region src/utils.ts
|
||||
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
||||
function getPartialMatcher(patterns, options) {
|
||||
const patternsCount = patterns.length;
|
||||
const patternsParts = Array(patternsCount);
|
||||
const regexes = Array(patternsCount);
|
||||
for (let i = 0; i < patternsCount; i++) {
|
||||
const parts = splitPattern(patterns[i]);
|
||||
patternsParts[i] = parts;
|
||||
const partsCount = parts.length;
|
||||
const partRegexes = Array(partsCount);
|
||||
for (let j = 0; j < partsCount; j++) partRegexes[j] = picomatch.makeRe(parts[j], options);
|
||||
regexes[i] = partRegexes;
|
||||
}
|
||||
return (input) => {
|
||||
const inputParts = input.split("/");
|
||||
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
||||
for (let i = 0; i < patterns.length; i++) {
|
||||
const patternParts = patternsParts[i];
|
||||
const regex = regexes[i];
|
||||
const inputPatternCount = inputParts.length;
|
||||
const minParts = Math.min(inputPatternCount, patternParts.length);
|
||||
let j = 0;
|
||||
while (j < minParts) {
|
||||
const part = patternParts[j];
|
||||
if (part.includes("/")) return true;
|
||||
const match = regex[j].test(inputParts[j]);
|
||||
if (!match) break;
|
||||
if (part === "**") return true;
|
||||
j++;
|
||||
}
|
||||
if (j === inputPatternCount) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
const splitPatternOptions = { parts: true };
|
||||
function splitPattern(path$1) {
|
||||
var _result$parts;
|
||||
const result = picomatch.scan(path$1, splitPatternOptions);
|
||||
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
|
||||
}
|
||||
const isWin = process.platform === "win32";
|
||||
const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
||||
function convertPosixPathToPattern(path$1) {
|
||||
return escapePosixPath(path$1);
|
||||
}
|
||||
function convertWin32PathToPattern(path$1) {
|
||||
return escapeWin32Path(path$1).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
||||
}
|
||||
const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
|
||||
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
||||
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
||||
const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
||||
const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
||||
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
||||
function isDynamicPattern(pattern, options) {
|
||||
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
|
||||
const scan = picomatch.scan(pattern);
|
||||
return scan.isGlob || scan.negated;
|
||||
}
|
||||
function log(...tasks) {
|
||||
console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`, ...tasks);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/index.ts
|
||||
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
||||
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
||||
const BACKSLASHES = /\\/g;
|
||||
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
||||
let result = pattern;
|
||||
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
||||
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
||||
const escapedCwd = escapePath(cwd);
|
||||
if (path.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
|
||||
else result = posix.normalize(result);
|
||||
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
||||
const parts = splitPattern(result);
|
||||
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
||||
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
||||
let i = 0;
|
||||
const cwdParts = escapedCwd.split("/");
|
||||
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
||||
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
||||
i++;
|
||||
}
|
||||
const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
||||
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
||||
props.root = potentialRoot;
|
||||
props.depthOffset = -n + i;
|
||||
}
|
||||
}
|
||||
if (!isIgnore && props.depthOffset >= 0) {
|
||||
var _props$commonPath;
|
||||
(_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
|
||||
const newCommonPath = [];
|
||||
const length = Math.min(props.commonPath.length, parts.length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
const part = parts[i];
|
||||
if (part === "**" && !parts[i + 1]) {
|
||||
newCommonPath.pop();
|
||||
break;
|
||||
}
|
||||
if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
|
||||
newCommonPath.push(part);
|
||||
}
|
||||
props.depthOffset = newCommonPath.length;
|
||||
props.commonPath = newCommonPath;
|
||||
props.root = newCommonPath.length > 0 ? path.posix.join(cwd, ...newCommonPath) : cwd;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, props) {
|
||||
if (typeof patterns === "string") patterns = [patterns];
|
||||
else if (!patterns) patterns = ["**/*"];
|
||||
if (typeof ignore === "string") ignore = [ignore];
|
||||
const matchPatterns = [];
|
||||
const ignorePatterns = [];
|
||||
for (const pattern of ignore) {
|
||||
if (!pattern) continue;
|
||||
if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
|
||||
}
|
||||
for (const pattern of patterns) {
|
||||
if (!pattern) continue;
|
||||
if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
|
||||
else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
|
||||
}
|
||||
return {
|
||||
match: matchPatterns,
|
||||
ignore: ignorePatterns
|
||||
};
|
||||
}
|
||||
function getRelativePath(path$1, cwd, root) {
|
||||
return posix.relative(cwd, `${root}/${path$1}`) || ".";
|
||||
}
|
||||
function processPath(path$1, cwd, root, isDirectory, absolute) {
|
||||
const relativePath = absolute ? path$1.slice(root === "/" ? 1 : root.length + 1) || "." : path$1;
|
||||
if (root === cwd) return isDirectory && relativePath !== "." ? relativePath.slice(0, -1) : relativePath;
|
||||
return getRelativePath(relativePath, cwd, root);
|
||||
}
|
||||
function formatPaths(paths, cwd, root) {
|
||||
for (let i = paths.length - 1; i >= 0; i--) {
|
||||
const path$1 = paths[i];
|
||||
paths[i] = getRelativePath(path$1, cwd, root) + (!path$1 || path$1.endsWith("/") ? "/" : "");
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
function crawl(options, cwd, sync) {
|
||||
if (process.env.TINYGLOBBY_DEBUG) options.debug = true;
|
||||
if (options.debug) log("globbing with options:", options, "cwd:", cwd);
|
||||
if (Array.isArray(options.patterns) && options.patterns.length === 0) return sync ? [] : Promise.resolve([]);
|
||||
const props = {
|
||||
root: cwd,
|
||||
commonPath: null,
|
||||
depthOffset: 0
|
||||
};
|
||||
const processed = processPatterns(options, cwd, props);
|
||||
const nocase = options.caseSensitiveMatch === false;
|
||||
if (options.debug) log("internal processing patterns:", processed);
|
||||
const matcher = picomatch(processed.match, {
|
||||
dot: options.dot,
|
||||
nocase,
|
||||
ignore: processed.ignore
|
||||
});
|
||||
const ignore = picomatch(processed.ignore, {
|
||||
dot: options.dot,
|
||||
nocase
|
||||
});
|
||||
const partialMatcher = getPartialMatcher(processed.match, {
|
||||
dot: options.dot,
|
||||
nocase
|
||||
});
|
||||
const fdirOptions = {
|
||||
filters: [options.debug ? (p, isDirectory) => {
|
||||
const path$1 = processPath(p, cwd, props.root, isDirectory, options.absolute);
|
||||
const matches = matcher(path$1);
|
||||
if (matches) log(`matched ${path$1}`);
|
||||
return matches;
|
||||
} : (p, isDirectory) => matcher(processPath(p, cwd, props.root, isDirectory, options.absolute))],
|
||||
exclude: options.debug ? (_, p) => {
|
||||
const relativePath = processPath(p, cwd, props.root, true, true);
|
||||
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
if (skipped) log(`skipped ${p}`);
|
||||
else log(`crawling ${p}`);
|
||||
return skipped;
|
||||
} : (_, p) => {
|
||||
const relativePath = processPath(p, cwd, props.root, true, true);
|
||||
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
},
|
||||
pathSeparator: "/",
|
||||
relativePaths: true,
|
||||
resolveSymlinks: true
|
||||
};
|
||||
if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
||||
if (options.absolute) {
|
||||
fdirOptions.relativePaths = false;
|
||||
fdirOptions.resolvePaths = true;
|
||||
fdirOptions.includeBasePath = true;
|
||||
}
|
||||
if (options.followSymbolicLinks === false) {
|
||||
fdirOptions.resolveSymlinks = false;
|
||||
fdirOptions.excludeSymlinks = true;
|
||||
}
|
||||
if (options.onlyDirectories) {
|
||||
fdirOptions.excludeFiles = true;
|
||||
fdirOptions.includeDirs = true;
|
||||
} else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
|
||||
props.root = props.root.replace(BACKSLASHES, "");
|
||||
const root = props.root;
|
||||
if (options.debug) log("internal properties:", props);
|
||||
const api = new fdir(fdirOptions).crawl(root);
|
||||
if (cwd === root || options.absolute) return sync ? api.sync() : api.withPromise();
|
||||
return sync ? formatPaths(api.sync(), cwd, root) : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
|
||||
}
|
||||
async function glob(patternsOrOptions, options) {
|
||||
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
||||
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
||||
...options,
|
||||
patterns: patternsOrOptions
|
||||
} : patternsOrOptions;
|
||||
const cwd = opts.cwd ? path.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
||||
return crawl(opts, cwd, false);
|
||||
}
|
||||
function globSync(patternsOrOptions, options) {
|
||||
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
||||
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
||||
...options,
|
||||
patterns: patternsOrOptions
|
||||
} : patternsOrOptions;
|
||||
const cwd = opts.cwd ? path.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
||||
return crawl(opts, cwd, true);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
|
65
node_modules/tinyglobby/package.json
generated
vendored
Normal file
65
node_modules/tinyglobby/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "tinyglobby",
|
||||
"version": "0.2.14",
|
||||
"description": "A fast and minimal alternative to globby and fast-glob",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"author": "Superchupu",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"glob",
|
||||
"patterns",
|
||||
"fast",
|
||||
"implementation"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/SuperchupuDev/tinyglobby.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/SuperchupuDev/tinyglobby/issues"
|
||||
},
|
||||
"homepage": "https://github.com/SuperchupuDev/tinyglobby#readme",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||
},
|
||||
"dependencies": {
|
||||
"fdir": "^6.4.4",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@types/node": "^22.15.21",
|
||||
"@types/picomatch": "^4.0.0",
|
||||
"fs-fixture": "^2.7.1",
|
||||
"tsdown": "^0.12.3",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"check": "biome check",
|
||||
"format": "biome format --write",
|
||||
"lint": "biome lint",
|
||||
"lint:fix": "biome lint --fix --unsafe",
|
||||
"test": "node --experimental-transform-types --test",
|
||||
"test:coverage": "node --experimental-transform-types --test --experimental-test-coverage",
|
||||
"test:only": "node --experimental-transform-types --test --test-only",
|
||||
"typecheck": "tsc --noEmit"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user