refactor: Move Astro project to root directory
- Move all Astro files from dealplustech-astro/ to root - Archive Next.js code in _nextjs-backup/ - Update .gitignore for Astro project - Simplify project structure This completes the migration from Next.js to Astro. The Astro project is now at the root level.
This commit is contained in:
5
dealplustech-astro/node_modules/is-docker/cli.js
generated
vendored
5
dealplustech-astro/node_modules/is-docker/cli.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import process from 'node:process';
|
||||
import isDocker from './index.js';
|
||||
|
||||
process.exitCode = isDocker() ? 0 : 2;
|
||||
13
dealplustech-astro/node_modules/is-docker/index.d.ts
generated
vendored
13
dealplustech-astro/node_modules/is-docker/index.d.ts
generated
vendored
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
Check if the process is running inside a Docker container.
|
||||
|
||||
@example
|
||||
```
|
||||
import isDocker from 'is-docker';
|
||||
|
||||
if (isDocker()) {
|
||||
console.log('Running inside a Docker container');
|
||||
}
|
||||
```
|
||||
*/
|
||||
export default function isDocker(): boolean;
|
||||
29
dealplustech-astro/node_modules/is-docker/index.js
generated
vendored
29
dealplustech-astro/node_modules/is-docker/index.js
generated
vendored
@@ -1,29 +0,0 @@
|
||||
import fs from 'node:fs';
|
||||
|
||||
let isDockerCached;
|
||||
|
||||
function hasDockerEnv() {
|
||||
try {
|
||||
fs.statSync('/.dockerenv');
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasDockerCGroup() {
|
||||
try {
|
||||
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default function isDocker() {
|
||||
// TODO: Use `??=` when targeting Node.js 16.
|
||||
if (isDockerCached === undefined) {
|
||||
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
||||
}
|
||||
|
||||
return isDockerCached;
|
||||
}
|
||||
9
dealplustech-astro/node_modules/is-docker/license
generated
vendored
9
dealplustech-astro/node_modules/is-docker/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
44
dealplustech-astro/node_modules/is-docker/package.json
generated
vendored
44
dealplustech-astro/node_modules/is-docker/package.json
generated
vendored
@@ -1,44 +0,0 @@
|
||||
{
|
||||
"name": "is-docker",
|
||||
"version": "3.0.0",
|
||||
"description": "Check if the process is running inside a Docker container",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-docker",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"bin": "./cli.js",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"cli.js"
|
||||
],
|
||||
"keywords": [
|
||||
"detect",
|
||||
"docker",
|
||||
"dockerized",
|
||||
"container",
|
||||
"inside",
|
||||
"is",
|
||||
"env",
|
||||
"environment",
|
||||
"process"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"sinon": "^11.1.2",
|
||||
"tsd": "^0.17.0",
|
||||
"xo": "^0.44.0"
|
||||
}
|
||||
}
|
||||
27
dealplustech-astro/node_modules/is-docker/readme.md
generated
vendored
27
dealplustech-astro/node_modules/is-docker/readme.md
generated
vendored
@@ -1,27 +0,0 @@
|
||||
# is-docker
|
||||
|
||||
> Check if the process is running inside a Docker container
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install is-docker
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import isDocker from 'is-docker';
|
||||
|
||||
if (isDocker()) {
|
||||
console.log('Running inside a Docker container');
|
||||
}
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
```
|
||||
$ is-docker
|
||||
```
|
||||
|
||||
Exits with code 0 if inside a Docker container and 2 if not.
|
||||
23
dealplustech-astro/node_modules/is-inside-container/index.js
generated
vendored
23
dealplustech-astro/node_modules/is-inside-container/index.js
generated
vendored
@@ -1,23 +0,0 @@
|
||||
import fs from 'node:fs';
|
||||
import isDocker from 'is-docker';
|
||||
|
||||
let cachedResult;
|
||||
|
||||
// Podman detection
|
||||
const hasContainerEnv = () => {
|
||||
try {
|
||||
fs.statSync('/run/.containerenv');
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export default function isInsideContainer() {
|
||||
// TODO: Use `??=` when targeting Node.js 16.
|
||||
if (cachedResult === undefined) {
|
||||
cachedResult = hasContainerEnv() || isDocker();
|
||||
}
|
||||
|
||||
return cachedResult;
|
||||
}
|
||||
9
dealplustech-astro/node_modules/is-inside-container/license
generated
vendored
9
dealplustech-astro/node_modules/is-inside-container/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
35
dealplustech-astro/node_modules/is-plain-obj/index.d.ts
generated
vendored
35
dealplustech-astro/node_modules/is-plain-obj/index.d.ts
generated
vendored
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
Check if a value is a plain object.
|
||||
|
||||
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
||||
|
||||
@example
|
||||
```
|
||||
import isPlainObject from 'is-plain-obj';
|
||||
import {runInNewContext} from 'node:vm';
|
||||
|
||||
isPlainObject({foo: 'bar'});
|
||||
//=> true
|
||||
|
||||
isPlainObject(new Object());
|
||||
//=> true
|
||||
|
||||
isPlainObject(Object.create(null));
|
||||
//=> true
|
||||
|
||||
// This works across realms
|
||||
isPlainObject(runInNewContext('({})'));
|
||||
//=> true
|
||||
|
||||
isPlainObject([1, 2, 3]);
|
||||
//=> false
|
||||
|
||||
class Unicorn {}
|
||||
isPlainObject(new Unicorn());
|
||||
//=> false
|
||||
|
||||
isPlainObject(Math);
|
||||
//=> false
|
||||
```
|
||||
*/
|
||||
export default function isPlainObject<Value>(value: unknown): value is Record<PropertyKey, Value>;
|
||||
8
dealplustech-astro/node_modules/is-plain-obj/index.js
generated
vendored
8
dealplustech-astro/node_modules/is-plain-obj/index.js
generated
vendored
@@ -1,8 +0,0 @@
|
||||
export default function isPlainObject(value) {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
||||
}
|
||||
9
dealplustech-astro/node_modules/is-plain-obj/license
generated
vendored
9
dealplustech-astro/node_modules/is-plain-obj/license
generated
vendored
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
41
dealplustech-astro/node_modules/is-plain-obj/package.json
generated
vendored
41
dealplustech-astro/node_modules/is-plain-obj/package.json
generated
vendored
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"name": "is-plain-obj",
|
||||
"version": "4.1.0",
|
||||
"description": "Check if a value is a plain object",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-plain-obj",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"object",
|
||||
"is",
|
||||
"check",
|
||||
"test",
|
||||
"type",
|
||||
"plain",
|
||||
"vanilla",
|
||||
"pure",
|
||||
"simple"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.38.2"
|
||||
}
|
||||
}
|
||||
58
dealplustech-astro/node_modules/is-plain-obj/readme.md
generated
vendored
58
dealplustech-astro/node_modules/is-plain-obj/readme.md
generated
vendored
@@ -1,58 +0,0 @@
|
||||
# is-plain-obj
|
||||
|
||||
> Check if a value is a plain object
|
||||
|
||||
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install is-plain-obj
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import isPlainObject from 'is-plain-obj';
|
||||
import {runInNewContext} from 'node:vm';
|
||||
|
||||
isPlainObject({foo: 'bar'});
|
||||
//=> true
|
||||
|
||||
isPlainObject(new Object());
|
||||
//=> true
|
||||
|
||||
isPlainObject(Object.create(null));
|
||||
//=> true
|
||||
|
||||
// This works across realms
|
||||
isPlainObject(runInNewContext('({})'));
|
||||
//=> true
|
||||
|
||||
isPlainObject([1, 2, 3]);
|
||||
//=> false
|
||||
|
||||
class Unicorn {}
|
||||
isPlainObject(new Unicorn());
|
||||
//=> false
|
||||
|
||||
isPlainObject(Math);
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [is-obj](https://github.com/sindresorhus/is-obj) - Check if a value is an object
|
||||
- [is](https://github.com/sindresorhus/is) - Type check values
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-is-plain-obj?utm_source=npm-is-plain-obj&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
21
dealplustech-astro/node_modules/tinyglobby/LICENSE
generated
vendored
21
dealplustech-astro/node_modules/tinyglobby/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
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.
|
||||
25
dealplustech-astro/node_modules/tinyglobby/README.md
generated
vendored
25
dealplustech-astro/node_modules/tinyglobby/README.md
generated
vendored
@@ -1,25 +0,0 @@
|
||||
# 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' });
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Visit https://superchupu.dev/tinyglobby to read the full documentation.
|
||||
350
dealplustech-astro/node_modules/tinyglobby/dist/index.cjs
generated
vendored
350
dealplustech-astro/node_modules/tinyglobby/dist/index.cjs
generated
vendored
@@ -1,350 +0,0 @@
|
||||
//#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
|
||||
let fs = require("fs");
|
||||
fs = __toESM(fs);
|
||||
let path = require("path");
|
||||
path = __toESM(path);
|
||||
let url = require("url");
|
||||
url = __toESM(url);
|
||||
let fdir = require("fdir");
|
||||
fdir = __toESM(fdir);
|
||||
let picomatch = require("picomatch");
|
||||
picomatch = __toESM(picomatch);
|
||||
|
||||
//#region src/utils.ts
|
||||
const isReadonlyArray = Array.isArray;
|
||||
const isWin = process.platform === "win32";
|
||||
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
||||
function getPartialMatcher(patterns, options = {}) {
|
||||
const patternsCount = patterns.length;
|
||||
const patternsParts = Array(patternsCount);
|
||||
const matchers = Array(patternsCount);
|
||||
const globstarEnabled = !options.noglobstar;
|
||||
for (let i = 0; i < patternsCount; i++) {
|
||||
const parts = splitPattern(patterns[i]);
|
||||
patternsParts[i] = parts;
|
||||
const partsCount = parts.length;
|
||||
const partMatchers = Array(partsCount);
|
||||
for (let j = 0; j < partsCount; j++) partMatchers[j] = (0, picomatch.default)(parts[j], options);
|
||||
matchers[i] = partMatchers;
|
||||
}
|
||||
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 matcher = matchers[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 = matcher[j](inputParts[j]);
|
||||
if (!match) break;
|
||||
if (globstarEnabled && part === "**") return true;
|
||||
j++;
|
||||
}
|
||||
if (j === inputPatternCount) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/* node:coverage ignore next 2 */
|
||||
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
||||
const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
|
||||
function buildFormat(cwd, root, absolute) {
|
||||
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
||||
if (absolute) {
|
||||
const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
|
||||
return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
|
||||
}
|
||||
const prefix = root.slice(cwd.length + 1);
|
||||
if (prefix) return (p, isDir) => {
|
||||
if (p === ".") return prefix;
|
||||
const result = `${prefix}/${p}`;
|
||||
return isDir ? result.slice(0, -1) : result;
|
||||
};
|
||||
return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
|
||||
}
|
||||
if (absolute) return (p) => path.posix.relative(cwd, p) || ".";
|
||||
return (p) => path.posix.relative(cwd, `${root}/${p}`) || ".";
|
||||
}
|
||||
function buildRelative(cwd, root) {
|
||||
if (root.startsWith(`${cwd}/`)) {
|
||||
const prefix = root.slice(cwd.length + 1);
|
||||
return (p) => `${prefix}/${p}`;
|
||||
}
|
||||
return (p) => {
|
||||
const result = path.posix.relative(cwd, `${root}/${p}`);
|
||||
if (p.endsWith("/") && result !== "") return `${result}/`;
|
||||
return result || ".";
|
||||
};
|
||||
}
|
||||
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 ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
||||
function convertPosixPathToPattern(path$2) {
|
||||
return escapePosixPath(path$2);
|
||||
}
|
||||
function convertWin32PathToPattern(path$2) {
|
||||
return escapeWin32Path(path$2).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
||||
}
|
||||
/**
|
||||
* Converts a path to a pattern depending on the platform.
|
||||
* Identical to {@link escapePath} on POSIX systems.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
||||
*/
|
||||
/* node:coverage ignore next 3 */
|
||||
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, "\\$&");
|
||||
/**
|
||||
* Escapes a path's special characters depending on the platform.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
||||
*/
|
||||
/* node:coverage ignore next */
|
||||
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
||||
/**
|
||||
* Checks if a pattern has dynamic parts.
|
||||
*
|
||||
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/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 `..`.
|
||||
*
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
||||
*/
|
||||
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 ${(/* @__PURE__ */ 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.posix.join(cwd, ...newCommonPath) : cwd;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
|
||||
if (typeof patterns === "string") 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 formatPaths(paths, relative) {
|
||||
for (let i = paths.length - 1; i >= 0; i--) {
|
||||
const path$2 = paths[i];
|
||||
paths[i] = relative(path$2);
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
function normalizeCwd(cwd) {
|
||||
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
||||
if (cwd instanceof URL) return (0, url.fileURLToPath)(cwd).replace(BACKSLASHES, "/");
|
||||
return path.default.resolve(cwd).replace(BACKSLASHES, "/");
|
||||
}
|
||||
function getCrawler(patterns, inputOptions = {}) {
|
||||
const options = process.env.TINYGLOBBY_DEBUG ? {
|
||||
...inputOptions,
|
||||
debug: true
|
||||
} : inputOptions;
|
||||
const cwd = normalizeCwd(options.cwd);
|
||||
if (options.debug) log("globbing with:", {
|
||||
patterns,
|
||||
options,
|
||||
cwd
|
||||
});
|
||||
if (Array.isArray(patterns) && patterns.length === 0) return [{
|
||||
sync: () => [],
|
||||
withPromise: async () => []
|
||||
}, false];
|
||||
const props = {
|
||||
root: cwd,
|
||||
commonPath: null,
|
||||
depthOffset: 0
|
||||
};
|
||||
const processed = processPatterns({
|
||||
...options,
|
||||
patterns
|
||||
}, cwd, props);
|
||||
if (options.debug) log("internal processing patterns:", processed);
|
||||
const matchOptions = {
|
||||
dot: options.dot,
|
||||
nobrace: options.braceExpansion === false,
|
||||
nocase: options.caseSensitiveMatch === false,
|
||||
noextglob: options.extglob === false,
|
||||
noglobstar: options.globstar === false,
|
||||
posix: true
|
||||
};
|
||||
const matcher = (0, picomatch.default)(processed.match, {
|
||||
...matchOptions,
|
||||
ignore: processed.ignore
|
||||
});
|
||||
const ignore = (0, picomatch.default)(processed.ignore, matchOptions);
|
||||
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
||||
const format = buildFormat(cwd, props.root, options.absolute);
|
||||
const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
|
||||
const fdirOptions = {
|
||||
filters: [options.debug ? (p, isDirectory) => {
|
||||
const path$2 = format(p, isDirectory);
|
||||
const matches = matcher(path$2);
|
||||
if (matches) log(`matched ${path$2}`);
|
||||
return matches;
|
||||
} : (p, isDirectory) => matcher(format(p, isDirectory))],
|
||||
exclude: options.debug ? (_, p) => {
|
||||
const relativePath = formatExclude(p, true);
|
||||
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
if (skipped) log(`skipped ${p}`);
|
||||
else log(`crawling ${p}`);
|
||||
return skipped;
|
||||
} : (_, p) => {
|
||||
const relativePath = formatExclude(p, true);
|
||||
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
},
|
||||
fs: options.fs ? {
|
||||
readdir: options.fs.readdir || fs.default.readdir,
|
||||
readdirSync: options.fs.readdirSync || fs.default.readdirSync,
|
||||
realpath: options.fs.realpath || fs.default.realpath,
|
||||
realpathSync: options.fs.realpathSync || fs.default.realpathSync,
|
||||
stat: options.fs.stat || fs.default.stat,
|
||||
statSync: options.fs.statSync || fs.default.statSync
|
||||
} : void 0,
|
||||
pathSeparator: "/",
|
||||
relativePaths: true,
|
||||
resolveSymlinks: true,
|
||||
signal: options.signal
|
||||
};
|
||||
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 relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
|
||||
return [new fdir.fdir(fdirOptions).crawl(root), relative];
|
||||
}
|
||||
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 isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
||||
const opts = isModern ? options : patternsOrOptions;
|
||||
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
||||
const [crawler, relative] = getCrawler(patterns, opts);
|
||||
if (!relative) return crawler.withPromise();
|
||||
return formatPaths(await crawler.withPromise(), relative);
|
||||
}
|
||||
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 isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
||||
const opts = isModern ? options : patternsOrOptions;
|
||||
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
||||
const [crawler, relative] = getCrawler(patterns, opts);
|
||||
if (!relative) return crawler.sync();
|
||||
return formatPaths(crawler.sync(), relative);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.convertPathToPattern = convertPathToPattern;
|
||||
exports.escapePath = escapePath;
|
||||
exports.glob = glob;
|
||||
exports.globSync = globSync;
|
||||
exports.isDynamicPattern = isDynamicPattern;
|
||||
147
dealplustech-astro/node_modules/tinyglobby/dist/index.d.cts
generated
vendored
147
dealplustech-astro/node_modules/tinyglobby/dist/index.d.cts
generated
vendored
@@ -1,147 +0,0 @@
|
||||
import { FSLike } from "fdir";
|
||||
|
||||
//#region src/utils.d.ts
|
||||
|
||||
/**
|
||||
* Converts a path to a pattern depending on the platform.
|
||||
* Identical to {@link escapePath} on POSIX systems.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
||||
*/
|
||||
declare const convertPathToPattern: (path: string) => string;
|
||||
/**
|
||||
* Escapes a path's special characters depending on the platform.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
||||
*/
|
||||
declare const escapePath: (path: string) => string;
|
||||
/**
|
||||
* Checks if a pattern has dynamic parts.
|
||||
*
|
||||
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/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 `..`.
|
||||
*
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
||||
*/
|
||||
declare function isDynamicPattern(pattern: string, options?: {
|
||||
caseSensitiveMatch: boolean;
|
||||
}): boolean;
|
||||
//#endregion
|
||||
//#region src/index.d.ts
|
||||
interface GlobOptions {
|
||||
/**
|
||||
* Whether to return absolute paths. Disable to have relative paths.
|
||||
* @default false
|
||||
*/
|
||||
absolute?: boolean;
|
||||
/**
|
||||
* Enables support for brace expansion syntax, like `{a,b}` or `{1..9}`.
|
||||
* @default true
|
||||
*/
|
||||
braceExpansion?: boolean;
|
||||
/**
|
||||
* Whether to match in case-sensitive mode.
|
||||
* @default true
|
||||
*/
|
||||
caseSensitiveMatch?: boolean;
|
||||
/**
|
||||
* The working directory in which to search. Results will be returned relative to this directory, unless
|
||||
* {@link absolute} is set.
|
||||
*
|
||||
* It is important to avoid globbing outside this directory when possible, even with absolute paths enabled,
|
||||
* as doing so can harm performance due to having to recalculate relative paths.
|
||||
* @default process.cwd()
|
||||
*/
|
||||
cwd?: string | URL;
|
||||
/**
|
||||
* Logs useful debug information. Meant for development purposes. Logs can change at any time.
|
||||
* @default false
|
||||
*/
|
||||
debug?: boolean;
|
||||
/**
|
||||
* Maximum directory depth to crawl.
|
||||
* @default Infinity
|
||||
*/
|
||||
deep?: number;
|
||||
/**
|
||||
* Whether to return entries that start with a dot, like `.gitignore` or `.prettierrc`.
|
||||
* @default false
|
||||
*/
|
||||
dot?: boolean;
|
||||
/**
|
||||
* Whether to automatically expand directory patterns.
|
||||
*
|
||||
* Important to disable if migrating from [`fast-glob`](https://github.com/mrmlnc/fast-glob).
|
||||
* @default true
|
||||
*/
|
||||
expandDirectories?: boolean;
|
||||
/**
|
||||
* Enables support for extglobs, like `+(pattern)`.
|
||||
* @default true
|
||||
*/
|
||||
extglob?: boolean;
|
||||
/**
|
||||
* Whether to traverse and include symbolic links. Can slightly affect performance.
|
||||
* @default true
|
||||
*/
|
||||
followSymbolicLinks?: boolean;
|
||||
/**
|
||||
* An object that overrides `node:fs` functions.
|
||||
* @default import('node:fs')
|
||||
*/
|
||||
fs?: FileSystemAdapter;
|
||||
/**
|
||||
* Enables support for matching nested directories with globstars (`**`).
|
||||
* If `false`, `**` behaves exactly like `*`.
|
||||
* @default true
|
||||
*/
|
||||
globstar?: boolean;
|
||||
/**
|
||||
* Glob patterns to exclude from the results.
|
||||
* @default []
|
||||
*/
|
||||
ignore?: string | readonly string[];
|
||||
/**
|
||||
* Enable to only return directories.
|
||||
* If `true`, disables {@link onlyFiles}.
|
||||
* @default false
|
||||
*/
|
||||
onlyDirectories?: boolean;
|
||||
/**
|
||||
* Enable to only return files.
|
||||
* @default true
|
||||
*/
|
||||
onlyFiles?: boolean;
|
||||
/**
|
||||
* @deprecated Provide patterns as the first argument instead.
|
||||
*/
|
||||
patterns?: string | readonly string[];
|
||||
/**
|
||||
* An `AbortSignal` to abort crawling the file system.
|
||||
* @default undefined
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
type FileSystemAdapter = Partial<FSLike>;
|
||||
/**
|
||||
* Asynchronously match files following a glob pattern.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#glob}
|
||||
*/
|
||||
declare function glob(patterns: string | readonly string[], options?: Omit<GlobOptions, "patterns">): Promise<string[]>;
|
||||
/**
|
||||
* @deprecated Provide patterns as the first argument instead.
|
||||
*/
|
||||
declare function glob(options: GlobOptions): Promise<string[]>;
|
||||
/**
|
||||
* Synchronously match files following a glob pattern.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#globSync}
|
||||
*/
|
||||
declare function globSync(patterns: string | readonly string[], options?: Omit<GlobOptions, "patterns">): string[];
|
||||
/**
|
||||
* @deprecated Provide patterns as the first argument instead.
|
||||
*/
|
||||
declare function globSync(options: GlobOptions): string[];
|
||||
//#endregion
|
||||
export { FileSystemAdapter, GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
|
||||
147
dealplustech-astro/node_modules/tinyglobby/dist/index.d.mts
generated
vendored
147
dealplustech-astro/node_modules/tinyglobby/dist/index.d.mts
generated
vendored
@@ -1,147 +0,0 @@
|
||||
import { FSLike } from "fdir";
|
||||
|
||||
//#region src/utils.d.ts
|
||||
|
||||
/**
|
||||
* Converts a path to a pattern depending on the platform.
|
||||
* Identical to {@link escapePath} on POSIX systems.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
||||
*/
|
||||
declare const convertPathToPattern: (path: string) => string;
|
||||
/**
|
||||
* Escapes a path's special characters depending on the platform.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
||||
*/
|
||||
declare const escapePath: (path: string) => string;
|
||||
/**
|
||||
* Checks if a pattern has dynamic parts.
|
||||
*
|
||||
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/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 `..`.
|
||||
*
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
||||
*/
|
||||
declare function isDynamicPattern(pattern: string, options?: {
|
||||
caseSensitiveMatch: boolean;
|
||||
}): boolean;
|
||||
//#endregion
|
||||
//#region src/index.d.ts
|
||||
interface GlobOptions {
|
||||
/**
|
||||
* Whether to return absolute paths. Disable to have relative paths.
|
||||
* @default false
|
||||
*/
|
||||
absolute?: boolean;
|
||||
/**
|
||||
* Enables support for brace expansion syntax, like `{a,b}` or `{1..9}`.
|
||||
* @default true
|
||||
*/
|
||||
braceExpansion?: boolean;
|
||||
/**
|
||||
* Whether to match in case-sensitive mode.
|
||||
* @default true
|
||||
*/
|
||||
caseSensitiveMatch?: boolean;
|
||||
/**
|
||||
* The working directory in which to search. Results will be returned relative to this directory, unless
|
||||
* {@link absolute} is set.
|
||||
*
|
||||
* It is important to avoid globbing outside this directory when possible, even with absolute paths enabled,
|
||||
* as doing so can harm performance due to having to recalculate relative paths.
|
||||
* @default process.cwd()
|
||||
*/
|
||||
cwd?: string | URL;
|
||||
/**
|
||||
* Logs useful debug information. Meant for development purposes. Logs can change at any time.
|
||||
* @default false
|
||||
*/
|
||||
debug?: boolean;
|
||||
/**
|
||||
* Maximum directory depth to crawl.
|
||||
* @default Infinity
|
||||
*/
|
||||
deep?: number;
|
||||
/**
|
||||
* Whether to return entries that start with a dot, like `.gitignore` or `.prettierrc`.
|
||||
* @default false
|
||||
*/
|
||||
dot?: boolean;
|
||||
/**
|
||||
* Whether to automatically expand directory patterns.
|
||||
*
|
||||
* Important to disable if migrating from [`fast-glob`](https://github.com/mrmlnc/fast-glob).
|
||||
* @default true
|
||||
*/
|
||||
expandDirectories?: boolean;
|
||||
/**
|
||||
* Enables support for extglobs, like `+(pattern)`.
|
||||
* @default true
|
||||
*/
|
||||
extglob?: boolean;
|
||||
/**
|
||||
* Whether to traverse and include symbolic links. Can slightly affect performance.
|
||||
* @default true
|
||||
*/
|
||||
followSymbolicLinks?: boolean;
|
||||
/**
|
||||
* An object that overrides `node:fs` functions.
|
||||
* @default import('node:fs')
|
||||
*/
|
||||
fs?: FileSystemAdapter;
|
||||
/**
|
||||
* Enables support for matching nested directories with globstars (`**`).
|
||||
* If `false`, `**` behaves exactly like `*`.
|
||||
* @default true
|
||||
*/
|
||||
globstar?: boolean;
|
||||
/**
|
||||
* Glob patterns to exclude from the results.
|
||||
* @default []
|
||||
*/
|
||||
ignore?: string | readonly string[];
|
||||
/**
|
||||
* Enable to only return directories.
|
||||
* If `true`, disables {@link onlyFiles}.
|
||||
* @default false
|
||||
*/
|
||||
onlyDirectories?: boolean;
|
||||
/**
|
||||
* Enable to only return files.
|
||||
* @default true
|
||||
*/
|
||||
onlyFiles?: boolean;
|
||||
/**
|
||||
* @deprecated Provide patterns as the first argument instead.
|
||||
*/
|
||||
patterns?: string | readonly string[];
|
||||
/**
|
||||
* An `AbortSignal` to abort crawling the file system.
|
||||
* @default undefined
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
type FileSystemAdapter = Partial<FSLike>;
|
||||
/**
|
||||
* Asynchronously match files following a glob pattern.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#glob}
|
||||
*/
|
||||
declare function glob(patterns: string | readonly string[], options?: Omit<GlobOptions, "patterns">): Promise<string[]>;
|
||||
/**
|
||||
* @deprecated Provide patterns as the first argument instead.
|
||||
*/
|
||||
declare function glob(options: GlobOptions): Promise<string[]>;
|
||||
/**
|
||||
* Synchronously match files following a glob pattern.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#globSync}
|
||||
*/
|
||||
declare function globSync(patterns: string | readonly string[], options?: Omit<GlobOptions, "patterns">): string[];
|
||||
/**
|
||||
* @deprecated Provide patterns as the first argument instead.
|
||||
*/
|
||||
declare function globSync(options: GlobOptions): string[];
|
||||
//#endregion
|
||||
export { FileSystemAdapter, GlobOptions, convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
|
||||
318
dealplustech-astro/node_modules/tinyglobby/dist/index.mjs
generated
vendored
318
dealplustech-astro/node_modules/tinyglobby/dist/index.mjs
generated
vendored
@@ -1,318 +0,0 @@
|
||||
import nativeFs from "fs";
|
||||
import path, { posix } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { fdir } from "fdir";
|
||||
import picomatch from "picomatch";
|
||||
|
||||
//#region src/utils.ts
|
||||
const isReadonlyArray = Array.isArray;
|
||||
const isWin = process.platform === "win32";
|
||||
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
||||
function getPartialMatcher(patterns, options = {}) {
|
||||
const patternsCount = patterns.length;
|
||||
const patternsParts = Array(patternsCount);
|
||||
const matchers = Array(patternsCount);
|
||||
const globstarEnabled = !options.noglobstar;
|
||||
for (let i = 0; i < patternsCount; i++) {
|
||||
const parts = splitPattern(patterns[i]);
|
||||
patternsParts[i] = parts;
|
||||
const partsCount = parts.length;
|
||||
const partMatchers = Array(partsCount);
|
||||
for (let j = 0; j < partsCount; j++) partMatchers[j] = picomatch(parts[j], options);
|
||||
matchers[i] = partMatchers;
|
||||
}
|
||||
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 matcher = matchers[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 = matcher[j](inputParts[j]);
|
||||
if (!match) break;
|
||||
if (globstarEnabled && part === "**") return true;
|
||||
j++;
|
||||
}
|
||||
if (j === inputPatternCount) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
/* node:coverage ignore next 2 */
|
||||
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
||||
const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
|
||||
function buildFormat(cwd, root, absolute) {
|
||||
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
||||
if (absolute) {
|
||||
const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
|
||||
return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
|
||||
}
|
||||
const prefix = root.slice(cwd.length + 1);
|
||||
if (prefix) return (p, isDir) => {
|
||||
if (p === ".") return prefix;
|
||||
const result = `${prefix}/${p}`;
|
||||
return isDir ? result.slice(0, -1) : result;
|
||||
};
|
||||
return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
|
||||
}
|
||||
if (absolute) return (p) => posix.relative(cwd, p) || ".";
|
||||
return (p) => posix.relative(cwd, `${root}/${p}`) || ".";
|
||||
}
|
||||
function buildRelative(cwd, root) {
|
||||
if (root.startsWith(`${cwd}/`)) {
|
||||
const prefix = root.slice(cwd.length + 1);
|
||||
return (p) => `${prefix}/${p}`;
|
||||
}
|
||||
return (p) => {
|
||||
const result = posix.relative(cwd, `${root}/${p}`);
|
||||
if (p.endsWith("/") && result !== "") return `${result}/`;
|
||||
return result || ".";
|
||||
};
|
||||
}
|
||||
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 ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
||||
function convertPosixPathToPattern(path$1) {
|
||||
return escapePosixPath(path$1);
|
||||
}
|
||||
function convertWin32PathToPattern(path$1) {
|
||||
return escapeWin32Path(path$1).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
||||
}
|
||||
/**
|
||||
* Converts a path to a pattern depending on the platform.
|
||||
* Identical to {@link escapePath} on POSIX systems.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
|
||||
*/
|
||||
/* node:coverage ignore next 3 */
|
||||
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, "\\$&");
|
||||
/**
|
||||
* Escapes a path's special characters depending on the platform.
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
||||
*/
|
||||
/* node:coverage ignore next */
|
||||
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
||||
/**
|
||||
* Checks if a pattern has dynamic parts.
|
||||
*
|
||||
* Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/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 `..`.
|
||||
*
|
||||
* @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
|
||||
*/
|
||||
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 ${(/* @__PURE__ */ 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 ? posix.join(cwd, ...newCommonPath) : cwd;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
|
||||
if (typeof patterns === "string") 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 formatPaths(paths, relative) {
|
||||
for (let i = paths.length - 1; i >= 0; i--) {
|
||||
const path$1 = paths[i];
|
||||
paths[i] = relative(path$1);
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
function normalizeCwd(cwd) {
|
||||
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
||||
if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
|
||||
return path.resolve(cwd).replace(BACKSLASHES, "/");
|
||||
}
|
||||
function getCrawler(patterns, inputOptions = {}) {
|
||||
const options = process.env.TINYGLOBBY_DEBUG ? {
|
||||
...inputOptions,
|
||||
debug: true
|
||||
} : inputOptions;
|
||||
const cwd = normalizeCwd(options.cwd);
|
||||
if (options.debug) log("globbing with:", {
|
||||
patterns,
|
||||
options,
|
||||
cwd
|
||||
});
|
||||
if (Array.isArray(patterns) && patterns.length === 0) return [{
|
||||
sync: () => [],
|
||||
withPromise: async () => []
|
||||
}, false];
|
||||
const props = {
|
||||
root: cwd,
|
||||
commonPath: null,
|
||||
depthOffset: 0
|
||||
};
|
||||
const processed = processPatterns({
|
||||
...options,
|
||||
patterns
|
||||
}, cwd, props);
|
||||
if (options.debug) log("internal processing patterns:", processed);
|
||||
const matchOptions = {
|
||||
dot: options.dot,
|
||||
nobrace: options.braceExpansion === false,
|
||||
nocase: options.caseSensitiveMatch === false,
|
||||
noextglob: options.extglob === false,
|
||||
noglobstar: options.globstar === false,
|
||||
posix: true
|
||||
};
|
||||
const matcher = picomatch(processed.match, {
|
||||
...matchOptions,
|
||||
ignore: processed.ignore
|
||||
});
|
||||
const ignore = picomatch(processed.ignore, matchOptions);
|
||||
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
||||
const format = buildFormat(cwd, props.root, options.absolute);
|
||||
const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
|
||||
const fdirOptions = {
|
||||
filters: [options.debug ? (p, isDirectory) => {
|
||||
const path$1 = format(p, isDirectory);
|
||||
const matches = matcher(path$1);
|
||||
if (matches) log(`matched ${path$1}`);
|
||||
return matches;
|
||||
} : (p, isDirectory) => matcher(format(p, isDirectory))],
|
||||
exclude: options.debug ? (_, p) => {
|
||||
const relativePath = formatExclude(p, true);
|
||||
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
if (skipped) log(`skipped ${p}`);
|
||||
else log(`crawling ${p}`);
|
||||
return skipped;
|
||||
} : (_, p) => {
|
||||
const relativePath = formatExclude(p, true);
|
||||
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
||||
},
|
||||
fs: options.fs ? {
|
||||
readdir: options.fs.readdir || nativeFs.readdir,
|
||||
readdirSync: options.fs.readdirSync || nativeFs.readdirSync,
|
||||
realpath: options.fs.realpath || nativeFs.realpath,
|
||||
realpathSync: options.fs.realpathSync || nativeFs.realpathSync,
|
||||
stat: options.fs.stat || nativeFs.stat,
|
||||
statSync: options.fs.statSync || nativeFs.statSync
|
||||
} : void 0,
|
||||
pathSeparator: "/",
|
||||
relativePaths: true,
|
||||
resolveSymlinks: true,
|
||||
signal: options.signal
|
||||
};
|
||||
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 relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
|
||||
return [new fdir(fdirOptions).crawl(root), relative];
|
||||
}
|
||||
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 isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
||||
const opts = isModern ? options : patternsOrOptions;
|
||||
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
||||
const [crawler, relative] = getCrawler(patterns, opts);
|
||||
if (!relative) return crawler.withPromise();
|
||||
return formatPaths(await crawler.withPromise(), relative);
|
||||
}
|
||||
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 isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
|
||||
const opts = isModern ? options : patternsOrOptions;
|
||||
const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
|
||||
const [crawler, relative] = getCrawler(patterns, opts);
|
||||
if (!relative) return crawler.sync();
|
||||
return formatPaths(crawler.sync(), relative);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };
|
||||
73
dealplustech-astro/node_modules/tinyglobby/package.json
generated
vendored
73
dealplustech-astro/node_modules/tinyglobby/package.json
generated
vendored
@@ -1,73 +0,0 @@
|
||||
{
|
||||
"name": "tinyglobby",
|
||||
"version": "0.2.15",
|
||||
"description": "A fast and minimal alternative to globby and fast-glob",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.cts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"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://superchupu.dev/tinyglobby",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||
},
|
||||
"dependencies": {
|
||||
"fdir": "^6.5.0",
|
||||
"picomatch": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.2.3",
|
||||
"@types/node": "^24.3.1",
|
||||
"@types/picomatch": "^4.0.2",
|
||||
"fast-glob": "^3.3.3",
|
||||
"fs-fixture": "^2.8.1",
|
||||
"glob": "^11.0.3",
|
||||
"tinybench": "^5.0.1",
|
||||
"tsdown": "^0.14.2",
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"provenance": true
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/bench.ts",
|
||||
"bench:setup": "node benchmark/setup.ts",
|
||||
"build": "tsdown",
|
||||
"check": "biome check",
|
||||
"check:fix": "biome check --write --unsafe",
|
||||
"format": "biome format --write",
|
||||
"lint": "biome lint",
|
||||
"test": "node --test \"test/**/*.ts\"",
|
||||
"test:coverage": "node --test --experimental-test-coverage \"test/**/*.ts\"",
|
||||
"test:only": "node --test --test-only \"test/**/*.ts\"",
|
||||
"typecheck": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
21
dealplustech-astro/node_modules/vitefu/LICENSE
generated
vendored
21
dealplustech-astro/node_modules/vitefu/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Bjorn and Dominik
|
||||
|
||||
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.
|
||||
11
dealplustech-astro/node_modules/vitefu/README.md
generated
vendored
11
dealplustech-astro/node_modules/vitefu/README.md
generated
vendored
@@ -1,11 +0,0 @@
|
||||
# vitefu
|
||||
|
||||
Utilities for building frameworks with Vite.
|
||||
|
||||
## Usage
|
||||
|
||||
See [src/index.d.ts](./src/index.d.ts).
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
51
dealplustech-astro/node_modules/vitefu/package.json
generated
vendored
51
dealplustech-astro/node_modules/vitefu/package.json
generated
vendored
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"name": "vitefu",
|
||||
"description": "Utilities for building frameworks with Vite",
|
||||
"version": "1.1.2",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"types": "./src/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./src/index.js",
|
||||
"require": "./src/index.cjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/svitejs/vitefu.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/svitejs/vitefu/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"vite",
|
||||
"framework",
|
||||
"utilities"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "uvu tests \".*\\.test\\.js\""
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-beta.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.18.63",
|
||||
"@types/pnpapi": "^0.0.5",
|
||||
"uvu": "^0.5.6",
|
||||
"vite": "^3.2.11"
|
||||
},
|
||||
"workspaces": [
|
||||
"tests/deps/*",
|
||||
"tests/projects/*",
|
||||
"tests/projects/workspace/packages/*"
|
||||
]
|
||||
}
|
||||
18
dealplustech-astro/node_modules/vitefu/src/index.cjs
generated
vendored
18
dealplustech-astro/node_modules/vitefu/src/index.cjs
generated
vendored
@@ -1,18 +0,0 @@
|
||||
// CJS -> ESM proxy file
|
||||
// Reference: https://github.com/vitejs/vite/blob/9f268dad2e82c0f1276b1098c0a28f1cf245aa50/packages/vite/index.cjs
|
||||
|
||||
module.exports = require('./sync.cjs')
|
||||
|
||||
// redirect async functions to ESM
|
||||
const asyncFunctions = [
|
||||
'crawlFrameworkPkgs',
|
||||
'findDepPkgJsonPath',
|
||||
'findClosestPkgJsonPath',
|
||||
'pkgNeedsOptimization'
|
||||
]
|
||||
|
||||
for (const fn of asyncFunctions) {
|
||||
module.exports[fn] = function () {
|
||||
return import('./index.js').then((mod) => mod[fn].apply(this, arguments))
|
||||
}
|
||||
}
|
||||
59
dealplustech-astro/node_modules/vitefu/src/index.d.cts
generated
vendored
59
dealplustech-astro/node_modules/vitefu/src/index.d.cts
generated
vendored
@@ -1,59 +0,0 @@
|
||||
// CJS types like `index.d.ts` but dumbed down and doesn't import from `vite`. Thanks TypeScript.
|
||||
|
||||
export interface CrawlFrameworkPkgsOptions {
|
||||
root: string
|
||||
isBuild: boolean
|
||||
workspaceRoot?: string
|
||||
viteUserConfig?: any
|
||||
isFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
isFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
isSemiFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
isSemiFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
}
|
||||
|
||||
export interface CrawlFrameworkPkgsResult {
|
||||
optimizeDeps: {
|
||||
include: string[]
|
||||
exclude: string[]
|
||||
}
|
||||
ssr: {
|
||||
noExternal: string[]
|
||||
external: string[]
|
||||
}
|
||||
}
|
||||
|
||||
export declare function crawlFrameworkPkgs(
|
||||
options: CrawlFrameworkPkgsOptions
|
||||
): Promise<CrawlFrameworkPkgsResult>
|
||||
|
||||
export declare function findDepPkgJsonPath(
|
||||
dep: string,
|
||||
parent: string
|
||||
): Promise<string | undefined>
|
||||
|
||||
export declare function findClosestPkgJsonPath(
|
||||
dir: string,
|
||||
predicate?: (pkgJsonPath: string) => boolean | Promise<boolean>
|
||||
): Promise<string | undefined>
|
||||
|
||||
export declare function pkgNeedsOptimization(
|
||||
pkgJson: Record<string, any>,
|
||||
pkgJsonPath: string
|
||||
): Promise<boolean>
|
||||
|
||||
export declare function isDepExcluded(
|
||||
dep: string,
|
||||
optimizeDepsExclude: any
|
||||
): boolean
|
||||
|
||||
export declare function isDepIncluded(
|
||||
dep: string,
|
||||
optimizeDepsInclude: any
|
||||
): boolean
|
||||
|
||||
export declare function isDepNoExternaled(
|
||||
dep: string,
|
||||
ssrNoExternal: any
|
||||
): boolean
|
||||
|
||||
export declare function isDepExternaled(dep: string, ssrExternal: any): boolean
|
||||
187
dealplustech-astro/node_modules/vitefu/src/index.d.ts
generated
vendored
187
dealplustech-astro/node_modules/vitefu/src/index.d.ts
generated
vendored
@@ -1,187 +0,0 @@
|
||||
import type { DepOptimizationOptions, SSROptions, UserConfig } from 'vite'
|
||||
|
||||
export interface CrawlFrameworkPkgsOptions {
|
||||
/**
|
||||
* Path to the root of the project that contains the `package.json`
|
||||
*/
|
||||
root: string
|
||||
/**
|
||||
* Whether we're currently in a Vite build
|
||||
*/
|
||||
isBuild: boolean
|
||||
|
||||
/**
|
||||
* Path to workspace root of the project
|
||||
*
|
||||
* setting this enables crawling devDependencies of private packages inside the workspace
|
||||
* you can use `import {searchForWorkspaceRoot} from 'vite'` to find it.
|
||||
*/
|
||||
workspaceRoot?: string
|
||||
|
||||
/**
|
||||
* Optional. If a Vite user config is passed, the output Vite config will respect the
|
||||
* set `optimizeDeps` and `ssr` options so it doesn't override it
|
||||
*/
|
||||
viteUserConfig?: UserConfig
|
||||
/**
|
||||
* Whether this is a framework package by checking it's `package.json`.
|
||||
* A framework package is one that exports special files that can't be processed
|
||||
* by esbuild natively. For example, exporting `.framework` files.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return pkgJson.keywords?.includes('my-framework')
|
||||
* ```
|
||||
*/
|
||||
isFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
/**
|
||||
* Whether this is a framework package by checking it's name. This is
|
||||
* usually used as a fast path. Return `true` or `false` if you know 100%
|
||||
* if it's a framework package or not. Return `undefined` to fallback to
|
||||
* `isFrameworkPkgByJson`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return SPECIAL_PACKAGES.includes(pkgName) || undefined
|
||||
* ```
|
||||
*/
|
||||
isFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
/**
|
||||
* Whether this is a semi-framework package by checking it's `package.json`.
|
||||
* A semi-framework package is one that **doesn't** export special files but
|
||||
* consumes other APIs of the framework. For example, it only does
|
||||
* `import { debounce } from 'my-framework/utils'`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return Object.keys(pkgJson.dependencies || {}).includes('my-framework')
|
||||
* ```
|
||||
*/
|
||||
isSemiFrameworkPkgByJson?: (pkgJson: Record<string, any>) => boolean
|
||||
/**
|
||||
* Whether this is a semi-framework package by checking it's name. This is
|
||||
* usually used as a fast path. Return `true` or `false` if you know 100%
|
||||
* if it's a semi-framework package or not. Return `undefined` to fallback to
|
||||
* `isSemiFrameworkPkgByJson`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* return SPECIAL_SEMI_PACKAGES.includes(pkgName) || undefined
|
||||
* ```
|
||||
*/
|
||||
isSemiFrameworkPkgByName?: (pkgName: string) => boolean | undefined
|
||||
}
|
||||
|
||||
export interface CrawlFrameworkPkgsResult {
|
||||
optimizeDeps: {
|
||||
include: string[]
|
||||
exclude: string[]
|
||||
}
|
||||
ssr: {
|
||||
noExternal: string[]
|
||||
external: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Crawls for framework packages starting from `<root>/package.json` to build
|
||||
* out a partial Vite config. See the source code for details of how this is built.
|
||||
*/
|
||||
export declare function crawlFrameworkPkgs(
|
||||
options: CrawlFrameworkPkgsOptions
|
||||
): Promise<CrawlFrameworkPkgsResult>
|
||||
|
||||
/**
|
||||
* Find the `package.json` of a dep, starting from the parent, e.g. `process.cwd()`.
|
||||
* A simplified implementation of https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
||||
* (PACKAGE_RESOLVE) for `package.json` specifically.
|
||||
*/
|
||||
export declare function findDepPkgJsonPath(
|
||||
dep: string,
|
||||
parent: string,
|
||||
): Promise<string | undefined>
|
||||
|
||||
/**
|
||||
* Find the closest `package.json` path by walking `dir` upwards.
|
||||
*
|
||||
* Pass a function to `predicate` to check if the current `package.json` is the
|
||||
* one you're looking for. For example, finding `package.json` that has the
|
||||
* `name` field only. Throwing inside the `predicate` is safe and acts the same
|
||||
* as returning false.
|
||||
*/
|
||||
export declare function findClosestPkgJsonPath(
|
||||
dir: string,
|
||||
predicate?: (pkgJsonPath: string) => boolean | Promise<boolean>
|
||||
): Promise<string | undefined>
|
||||
|
||||
/**
|
||||
* Check if a package needs to be optimized by Vite, aka if it's CJS-only
|
||||
*/
|
||||
export declare function pkgNeedsOptimization(
|
||||
pkgJson: Record<string, any>,
|
||||
pkgJsonPath: string
|
||||
): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `optimizeDeps.exclude` config
|
||||
* @param dep Dependency to be included
|
||||
* @param optimizeDepsExclude Existing `optimizeDeps.exclude` config
|
||||
* @example
|
||||
* ```ts
|
||||
* optimizeDeps: {
|
||||
* include: includesToAdd.filter((dep) => !isDepExcluded(dep, existingExclude))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepExcluded(
|
||||
dep: string,
|
||||
optimizeDepsExclude: NonNullable<DepOptimizationOptions['exclude']>
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `optimizeDeps.include` config
|
||||
* @param dep Dependency to be excluded
|
||||
* @param optimizeDepsInclude Existing `optimizeDeps.include` config
|
||||
* @example
|
||||
* ```ts
|
||||
* optimizeDeps: {
|
||||
* exclude: excludesToAdd.filter((dep) => !isDepIncluded(dep, existingInclude))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepIncluded(
|
||||
dep: string,
|
||||
optimizeDepsInclude: NonNullable<DepOptimizationOptions['include']>
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `ssr.noExternal` config
|
||||
* @param dep Dependency to be excluded
|
||||
* @param ssrNoExternal Existing `ssr.noExternal` config
|
||||
* @example
|
||||
* ```ts
|
||||
* ssr: {
|
||||
* external: externalsToAdd.filter((dep) => !isDepNoExternal(dep, existingNoExternal))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepNoExternaled(
|
||||
dep: string,
|
||||
ssrNoExternal: NonNullable<SSROptions['noExternal']>
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Check if a dependency is part of an existing `ssr.external` config
|
||||
* @param dep Dependency to be noExternaled
|
||||
* @param ssrExternal Existing `ssr.external` config
|
||||
* @example
|
||||
* ```ts
|
||||
* ssr: {
|
||||
* noExternal: noExternalsToAdd.filter((dep) => !isDepExternal(dep, existingExternal))
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export declare function isDepExternaled(
|
||||
dep: string,
|
||||
ssrExternal: NonNullable<SSROptions['external']>
|
||||
): boolean
|
||||
315
dealplustech-astro/node_modules/vitefu/src/index.js
generated
vendored
315
dealplustech-astro/node_modules/vitefu/src/index.js
generated
vendored
@@ -1,315 +0,0 @@
|
||||
import fs from 'node:fs/promises'
|
||||
import fsSync from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import path from 'node:path'
|
||||
import {
|
||||
isDepIncluded,
|
||||
isDepExcluded,
|
||||
isDepNoExternaled,
|
||||
isDepExternaled
|
||||
} from './sync.cjs'
|
||||
|
||||
/** @type {import('pnpapi')} */
|
||||
let pnp
|
||||
|
||||
|
||||
/** @type {Array<{ name: string; reference: string; }>} */
|
||||
let pnpWorkspaceLocators;
|
||||
|
||||
if (process.versions.pnp) {
|
||||
try {
|
||||
pnp = createRequire(import.meta.url)('pnpapi')
|
||||
// returns a set of physical locators https://yarnpkg.com/advanced/pnpapi#getdependencytreeroots
|
||||
// @ts-expect-error unfortunately doesn't exist in the `@types` package
|
||||
pnpWorkspaceLocators = pnp.getDependencyTreeRoots()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
export { isDepIncluded, isDepExcluded, isDepNoExternaled, isDepExternaled }
|
||||
|
||||
/** @type {import('./index.d.ts').crawlFrameworkPkgs} */
|
||||
export async function crawlFrameworkPkgs(options) {
|
||||
const pkgJsonPath = await findClosestPkgJsonPath(options.root)
|
||||
if (!pkgJsonPath) {
|
||||
// don't throw as package.json is not required
|
||||
return {
|
||||
optimizeDeps: { include: [], exclude: [] },
|
||||
ssr: { noExternal: [], external: [] }
|
||||
}
|
||||
}
|
||||
const pkgJson = await readJson(pkgJsonPath).catch((e) => {
|
||||
throw new Error(`Unable to read ${pkgJsonPath}`, { cause: e })
|
||||
})
|
||||
|
||||
/** @type {string[]} */
|
||||
let optimizeDepsInclude = []
|
||||
/** @type {string[]} */
|
||||
let optimizeDepsExclude = []
|
||||
/** @type {string[]} */
|
||||
let ssrNoExternal = []
|
||||
/** @type {string[]} */
|
||||
let ssrExternal = []
|
||||
|
||||
await crawl(pkgJsonPath, pkgJson)
|
||||
|
||||
// respect vite user config
|
||||
if (options.viteUserConfig) {
|
||||
// remove includes that are explicitly excluded in optimizeDeps
|
||||
const _optimizeDepsExclude = options.viteUserConfig?.optimizeDeps?.exclude
|
||||
if (_optimizeDepsExclude) {
|
||||
optimizeDepsInclude = optimizeDepsInclude.filter(
|
||||
(dep) => !isDepExcluded(dep, _optimizeDepsExclude)
|
||||
)
|
||||
}
|
||||
// remove excludes that are explicitly included in optimizeDeps
|
||||
const _optimizeDepsInclude = options.viteUserConfig?.optimizeDeps?.include
|
||||
if (_optimizeDepsInclude) {
|
||||
optimizeDepsExclude = optimizeDepsExclude.filter(
|
||||
(dep) => !isDepIncluded(dep, _optimizeDepsInclude)
|
||||
)
|
||||
}
|
||||
// remove noExternals that are explicitly externalized
|
||||
const _ssrExternal = options.viteUserConfig?.ssr?.external
|
||||
if (_ssrExternal) {
|
||||
ssrNoExternal = ssrNoExternal.filter(
|
||||
(dep) => !isDepExternaled(dep, _ssrExternal)
|
||||
)
|
||||
}
|
||||
// remove externals that are explicitly noExternal
|
||||
const _ssrNoExternal = options.viteUserConfig?.ssr?.noExternal
|
||||
if (_ssrNoExternal) {
|
||||
ssrExternal = ssrExternal.filter(
|
||||
(dep) => !isDepNoExternaled(dep, _ssrNoExternal)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
optimizeDeps: {
|
||||
include: optimizeDepsInclude,
|
||||
exclude: optimizeDepsExclude
|
||||
},
|
||||
ssr: {
|
||||
noExternal: ssrNoExternal,
|
||||
external: ssrExternal
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* crawl the package.json dependencies for framework packages. rules:
|
||||
* 1. a framework package should be `optimizeDeps.exclude` and `ssr.noExternal`.
|
||||
* 2. the deps of the framework package should be `optimizeDeps.include` and `ssr.external`
|
||||
* unless the dep is also a framework package, in which case do no1 & no2 recursively.
|
||||
* 3. any non-framework packages that aren't imported by a framework package can be skipped entirely.
|
||||
* 4. a semi-framework package is like a framework package, except it isn't `optimizeDeps.exclude`,
|
||||
* but only applies `ssr.noExternal`.
|
||||
* @param {string} pkgJsonPath
|
||||
* @param {Record<string, any>} pkgJson
|
||||
* @param {string[]} [parentDepNames]
|
||||
*/
|
||||
async function crawl(pkgJsonPath, pkgJson, parentDepNames = []) {
|
||||
const isRoot = parentDepNames.length === 0
|
||||
const crawlDevDependencies = isRoot || isPrivateWorkspacePackage(pkgJsonPath,pkgJson,options.workspaceRoot)
|
||||
/** @type {string[]} */
|
||||
let deps = [
|
||||
...Object.keys(pkgJson.dependencies || {}),
|
||||
...((crawlDevDependencies) ? Object.keys(pkgJson.devDependencies || {}) : [])
|
||||
]
|
||||
|
||||
deps = deps.filter((dep) => {
|
||||
// skip circular deps
|
||||
if (parentDepNames.includes(dep)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const isFrameworkPkg = options.isFrameworkPkgByName?.(dep)
|
||||
const isSemiFrameworkPkg = options.isSemiFrameworkPkgByName?.(dep)
|
||||
if (isFrameworkPkg) {
|
||||
// framework packages should be excluded from optimization as esbuild can't handle them.
|
||||
// otherwise it'll cause https://github.com/vitejs/vite/issues/3910
|
||||
optimizeDepsExclude.push(dep)
|
||||
// framework packages should be noExternal so that they go through vite's transformation
|
||||
// pipeline, since nodejs can't support them.
|
||||
ssrNoExternal.push(dep)
|
||||
} else if (isSemiFrameworkPkg) {
|
||||
// semi-framework packages should do the same except for optimization exclude as they
|
||||
// aren't needed to work (they don't contain raw framework components)
|
||||
ssrNoExternal.push(dep)
|
||||
}
|
||||
|
||||
// only those that are explictly false can skip crawling since we don't need to do anything
|
||||
// special for them
|
||||
if (isFrameworkPkg === false || isSemiFrameworkPkg === false) {
|
||||
return false
|
||||
}
|
||||
// if `true`, we need to crawl the nested deps to deep include and ssr externalize them in dev.
|
||||
// if `undefined`, it's the same as "i don't know". we need to crawl and find the package.json
|
||||
// to find out.
|
||||
else {
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
const promises = deps.map(async (dep) => {
|
||||
const depPkgJsonPath = await _findDepPkgJsonPath(dep, pkgJsonPath, !!options.workspaceRoot)
|
||||
if (!depPkgJsonPath) return
|
||||
const depPkgJson = await readJson(depPkgJsonPath).catch(() => {})
|
||||
if (!depPkgJson) return
|
||||
|
||||
// fast path if this dep is already a framework dep based on the filter condition above
|
||||
const cachedIsFrameworkPkg = ssrNoExternal.includes(dep)
|
||||
if (cachedIsFrameworkPkg) {
|
||||
return crawl(depPkgJsonPath, depPkgJson, parentDepNames.concat(dep))
|
||||
}
|
||||
|
||||
// check if this dep is a framework dep, if so, track and crawl it
|
||||
const isFrameworkPkg = options.isFrameworkPkgByJson?.(depPkgJson)
|
||||
const isSemiFrameworkPkg = options.isSemiFrameworkPkgByJson?.(depPkgJson)
|
||||
if (isFrameworkPkg || isSemiFrameworkPkg) {
|
||||
// see explanation in filter condition above
|
||||
if (isFrameworkPkg) {
|
||||
optimizeDepsExclude.push(dep)
|
||||
ssrNoExternal.push(dep)
|
||||
} else if (isSemiFrameworkPkg) {
|
||||
ssrNoExternal.push(dep)
|
||||
}
|
||||
return crawl(depPkgJsonPath, depPkgJson, parentDepNames.concat(dep))
|
||||
}
|
||||
|
||||
// if we're crawling in a non-root state, the parent is 100% a framework package
|
||||
// because of the above if block. in this case, if it's dep of a non-framework
|
||||
// package, handle special cases for them.
|
||||
if (!isRoot) {
|
||||
// deep include it if it's a CJS package, so it becomes ESM and vite is happy.
|
||||
if (await pkgNeedsOptimization(depPkgJson, depPkgJsonPath)) {
|
||||
optimizeDepsInclude.push(parentDepNames.concat(dep).join(' > '))
|
||||
}
|
||||
// also externalize it in dev so it doesn't trip vite's SSR transformation.
|
||||
// we do in dev only as build cannot access deep external packages in strict
|
||||
// dependency installations, such as pnpm.
|
||||
if (!options.isBuild && !ssrExternal.includes(dep)) {
|
||||
ssrExternal.push(dep)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
}
|
||||
}
|
||||
/** @type {import('./index.d.ts').findDepPkgJsonPath} */
|
||||
export async function findDepPkgJsonPath(dep, parent) {
|
||||
return _findDepPkgJsonPath(dep, parent, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* internal implementation to avoid exposing the usePnpWorkspaceLocators flag
|
||||
*
|
||||
* @param {string} dep
|
||||
* @param {string} parent
|
||||
* @param {boolean} usePnpWorkspaceLocators
|
||||
* @returns {Promise<undefined|string>}
|
||||
* @private
|
||||
*/
|
||||
async function _findDepPkgJsonPath(dep, parent, usePnpWorkspaceLocators) {
|
||||
if (pnp) {
|
||||
if(usePnpWorkspaceLocators) {
|
||||
try {
|
||||
// if we're in a workspace and the dep is a workspace dep,
|
||||
// then we'll try to resolve to it's real location
|
||||
const locator = pnpWorkspaceLocators.find((root) => root.name === dep)
|
||||
if (locator) {
|
||||
const pkgPath = pnp.getPackageInformation(locator).packageLocation
|
||||
return path.resolve(pkgPath, 'package.json')
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
try {
|
||||
const depRoot = pnp.resolveToUnqualified(dep, parent)
|
||||
if (!depRoot) return undefined
|
||||
return path.join(depRoot, 'package.json')
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
let root = parent
|
||||
while (root) {
|
||||
const pkg = path.join(root, 'node_modules', dep, 'package.json')
|
||||
try {
|
||||
await fs.access(pkg)
|
||||
// use 'node:fs' version to match 'vite:resolve' and avoid realpath.native quirk
|
||||
// https://github.com/sveltejs/vite-plugin-svelte/issues/525#issuecomment-1355551264
|
||||
return fsSync.realpathSync(pkg)
|
||||
} catch {}
|
||||
const nextRoot = path.dirname(root)
|
||||
if (nextRoot === root) break
|
||||
root = nextRoot
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').findClosestPkgJsonPath} */
|
||||
export async function findClosestPkgJsonPath(dir, predicate = undefined) {
|
||||
if (dir.endsWith('package.json')) {
|
||||
dir = path.dirname(dir)
|
||||
}
|
||||
while (dir) {
|
||||
const pkg = path.join(dir, 'package.json')
|
||||
try {
|
||||
const stat = await fs.stat(pkg)
|
||||
if (stat.isFile() && (!predicate || (await predicate(pkg)))) {
|
||||
return pkg
|
||||
}
|
||||
} catch {}
|
||||
const nextDir = path.dirname(dir)
|
||||
if (nextDir === dir) break
|
||||
dir = nextDir
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').pkgNeedsOptimization} */
|
||||
export async function pkgNeedsOptimization(pkgJson, pkgJsonPath) {
|
||||
// only optimize if is cjs, using the below as heuristic
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/162
|
||||
if (pkgJson.module || pkgJson.exports) return false
|
||||
// if have main, ensure entry is js so vite can prebundle it
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/233
|
||||
if (pkgJson.main) {
|
||||
const entryExt = path.extname(pkgJson.main)
|
||||
return !entryExt || entryExt === '.js' || entryExt === '.cjs'
|
||||
}
|
||||
// check if has implicit index.js entrypoint to prebundle
|
||||
// see https://github.com/sveltejs/vite-plugin-svelte/issues/281
|
||||
// see https://github.com/solidjs/vite-plugin-solid/issues/70#issuecomment-1306488154
|
||||
try {
|
||||
await fs.access(path.join(path.dirname(pkgJsonPath), 'index.js'))
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} findDepPkgJsonPath
|
||||
* @returns {Promise<Record<string, any>>}
|
||||
*/
|
||||
async function readJson(findDepPkgJsonPath) {
|
||||
return JSON.parse(await fs.readFile(findDepPkgJsonPath, 'utf8'))
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} pkgJsonPath
|
||||
* @param {Record<string,any>} pkgJson
|
||||
* @param {string} [workspaceRoot]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isPrivateWorkspacePackage(pkgJsonPath,pkgJson,workspaceRoot = undefined) {
|
||||
return !!(
|
||||
workspaceRoot &&
|
||||
pkgJson.private &&
|
||||
!pkgJsonPath.match(/[/\\]node_modules[/\\]/) &&
|
||||
!path.relative(workspaceRoot,pkgJsonPath).startsWith('..')
|
||||
)
|
||||
}
|
||||
66
dealplustech-astro/node_modules/vitefu/src/sync.cjs
generated
vendored
66
dealplustech-astro/node_modules/vitefu/src/sync.cjs
generated
vendored
@@ -1,66 +0,0 @@
|
||||
// contains synchronous API only so it can be exported as CJS and ESM
|
||||
|
||||
/** @type {import('./index.d.ts').isDepIncluded} */
|
||||
function isDepIncluded(dep, optimizeDepsInclude) {
|
||||
return optimizeDepsInclude.some((id) => parseIncludeStr(id) === dep)
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').isDepExcluded} */
|
||||
function isDepExcluded(dep, optimizeDepsExclude) {
|
||||
dep = parseIncludeStr(dep)
|
||||
return optimizeDepsExclude.some(
|
||||
(id) => id === dep || dep.startsWith(`${id}/`)
|
||||
)
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').isDepNoExternaled} */
|
||||
function isDepNoExternaled(dep, ssrNoExternal) {
|
||||
if (ssrNoExternal === true) {
|
||||
return true
|
||||
} else {
|
||||
return isMatch(dep, ssrNoExternal)
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {import('./index.d.ts').isDepExternaled} */
|
||||
function isDepExternaled(dep, ssrExternal) {
|
||||
// If `ssrExternal` is `true`, it just means that all linked
|
||||
// dependencies should also be externalized by default. It doesn't
|
||||
// mean that a dependency is being explicitly externalized. So we
|
||||
// return `false` in this case.
|
||||
// @ts-expect-error can be true in Vite 6
|
||||
if (ssrExternal === true) {
|
||||
return false
|
||||
} else {
|
||||
return ssrExternal.includes(dep)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} raw could be "foo" or "foo > bar" etc
|
||||
*/
|
||||
function parseIncludeStr(raw) {
|
||||
const lastArrow = raw.lastIndexOf('>')
|
||||
return lastArrow === -1 ? raw : raw.slice(lastArrow + 1).trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} target
|
||||
* @param {string | RegExp | (string | RegExp)[]} pattern
|
||||
*/
|
||||
function isMatch(target, pattern) {
|
||||
if (Array.isArray(pattern)) {
|
||||
return pattern.some((p) => isMatch(target, p))
|
||||
} else if (typeof pattern === 'string') {
|
||||
return target === pattern
|
||||
} else if (pattern instanceof RegExp) {
|
||||
return pattern.test(target)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isDepIncluded,
|
||||
isDepExcluded,
|
||||
isDepNoExternaled,
|
||||
isDepExternaled
|
||||
}
|
||||
Reference in New Issue
Block a user