@powerlines/plugin-env 0.16.67 → 0.16.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +0 -2
- package/dist/_virtual/_rolldown/runtime.mjs +2 -31
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +37 -27
- package/dist/components/docs.mjs +37 -27
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +404 -314
- package/dist/components/env-builtin.mjs +404 -314
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/create-reflection-resource.mjs.map +1 -1
- package/dist/helpers/docs-helper.mjs.map +1 -1
- package/dist/helpers/load.cjs +4 -4
- package/dist/helpers/load.mjs +2 -2
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/source-file-env.mjs.map +1 -1
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types/runtime.mjs.map +1 -1
- package/package.json +20 -35
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs +0 -346
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs +0 -347
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.cjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.cjs +0 -10
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.cjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.cjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.cjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.cjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.cjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.cjs +0 -13
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs +0 -14
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.cjs +0 -285
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs +0 -283
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.cjs +0 -71
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs +0 -69
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs.map +0 -1
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1008
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.cjs +0 -23
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +0 -14
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +0 -2695
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -2683
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs +0 -4457
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs +0 -4455
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.cjs +0 -29
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs +0 -30
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -181
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -177
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -22
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3967
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3963
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.cjs +0 -11766
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs +0 -11762
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -25
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs +0 -21
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.cjs +0 -20
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.cjs +0 -178
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs +0 -176
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.cjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.cjs +0 -3
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs +0 -3
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -145
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -139
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map +0 -1
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -128
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -127
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +0 -138
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +0 -137
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.cjs +0 -629
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs +0 -628
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs.map +0 -1
package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
3
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
4
|
-
function normalizeWindowsPath(input = "") {
|
|
5
|
-
if (!input) return input;
|
|
6
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
7
|
-
}
|
|
8
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
9
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
10
|
-
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
11
|
-
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
12
|
-
const normalize = function(path) {
|
|
13
|
-
if (path.length === 0) return ".";
|
|
14
|
-
path = normalizeWindowsPath(path);
|
|
15
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
16
|
-
const isPathAbsolute = isAbsolute(path);
|
|
17
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
18
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
19
|
-
if (path.length === 0) {
|
|
20
|
-
if (isPathAbsolute) return "/";
|
|
21
|
-
return trailingSeparator ? "./" : ".";
|
|
22
|
-
}
|
|
23
|
-
if (trailingSeparator) path += "/";
|
|
24
|
-
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
25
|
-
if (isUNCPath) {
|
|
26
|
-
if (!isPathAbsolute) return `//./${path}`;
|
|
27
|
-
return `//${path}`;
|
|
28
|
-
}
|
|
29
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
30
|
-
};
|
|
31
|
-
const join = function(...segments) {
|
|
32
|
-
let path = "";
|
|
33
|
-
for (const seg of segments) {
|
|
34
|
-
if (!seg) continue;
|
|
35
|
-
if (path.length > 0) {
|
|
36
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
37
|
-
const segLeading = seg[0] === "/";
|
|
38
|
-
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
39
|
-
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
40
|
-
} else path += seg;
|
|
41
|
-
}
|
|
42
|
-
return normalize(path);
|
|
43
|
-
};
|
|
44
|
-
function cwd() {
|
|
45
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
46
|
-
return "/";
|
|
47
|
-
}
|
|
48
|
-
const resolve = function(...arguments_) {
|
|
49
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
50
|
-
let resolvedPath = "";
|
|
51
|
-
let resolvedAbsolute = false;
|
|
52
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
53
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
54
|
-
if (!path || path.length === 0) continue;
|
|
55
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
56
|
-
resolvedAbsolute = isAbsolute(path);
|
|
57
|
-
}
|
|
58
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
59
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
60
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
61
|
-
};
|
|
62
|
-
function normalizeString(path, allowAboveRoot) {
|
|
63
|
-
let res = "";
|
|
64
|
-
let lastSegmentLength = 0;
|
|
65
|
-
let lastSlash = -1;
|
|
66
|
-
let dots = 0;
|
|
67
|
-
let char = null;
|
|
68
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
69
|
-
if (index < path.length) char = path[index];
|
|
70
|
-
else if (char === "/") break;
|
|
71
|
-
else char = "/";
|
|
72
|
-
if (char === "/") {
|
|
73
|
-
if (lastSlash === index - 1 || dots === 1);
|
|
74
|
-
else if (dots === 2) {
|
|
75
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
76
|
-
if (res.length > 2) {
|
|
77
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
78
|
-
if (lastSlashIndex === -1) {
|
|
79
|
-
res = "";
|
|
80
|
-
lastSegmentLength = 0;
|
|
81
|
-
} else {
|
|
82
|
-
res = res.slice(0, lastSlashIndex);
|
|
83
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
84
|
-
}
|
|
85
|
-
lastSlash = index;
|
|
86
|
-
dots = 0;
|
|
87
|
-
continue;
|
|
88
|
-
} else if (res.length > 0) {
|
|
89
|
-
res = "";
|
|
90
|
-
lastSegmentLength = 0;
|
|
91
|
-
lastSlash = index;
|
|
92
|
-
dots = 0;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (allowAboveRoot) {
|
|
97
|
-
res += res.length > 0 ? "/.." : "..";
|
|
98
|
-
lastSegmentLength = 2;
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
102
|
-
else res = path.slice(lastSlash + 1, index);
|
|
103
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
104
|
-
}
|
|
105
|
-
lastSlash = index;
|
|
106
|
-
dots = 0;
|
|
107
|
-
} else if (char === "." && dots !== -1) ++dots;
|
|
108
|
-
else dots = -1;
|
|
109
|
-
}
|
|
110
|
-
return res;
|
|
111
|
-
}
|
|
112
|
-
const isAbsolute = function(p) {
|
|
113
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
114
|
-
};
|
|
115
|
-
const extname = function(p) {
|
|
116
|
-
if (p === "..") return "";
|
|
117
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
118
|
-
return match && match[1] || "";
|
|
119
|
-
};
|
|
120
|
-
const dirname = function(p) {
|
|
121
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
122
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
123
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
124
|
-
};
|
|
125
|
-
const basename = function(p, extension) {
|
|
126
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
127
|
-
let lastSegment = "";
|
|
128
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
129
|
-
const val = segments[i];
|
|
130
|
-
if (val) {
|
|
131
|
-
lastSegment = val;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
exports.basename = basename;
|
|
140
|
-
exports.dirname = dirname;
|
|
141
|
-
exports.extname = extname;
|
|
142
|
-
exports.isAbsolute = isAbsolute;
|
|
143
|
-
exports.join = join;
|
|
144
|
-
exports.normalize = normalize;
|
|
145
|
-
exports.resolve = resolve;
|
package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
2
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3
|
-
function normalizeWindowsPath(input = "") {
|
|
4
|
-
if (!input) return input;
|
|
5
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6
|
-
}
|
|
7
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
8
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
9
|
-
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
10
|
-
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
11
|
-
const normalize = function(path) {
|
|
12
|
-
if (path.length === 0) return ".";
|
|
13
|
-
path = normalizeWindowsPath(path);
|
|
14
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
15
|
-
const isPathAbsolute = isAbsolute(path);
|
|
16
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
17
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
18
|
-
if (path.length === 0) {
|
|
19
|
-
if (isPathAbsolute) return "/";
|
|
20
|
-
return trailingSeparator ? "./" : ".";
|
|
21
|
-
}
|
|
22
|
-
if (trailingSeparator) path += "/";
|
|
23
|
-
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
24
|
-
if (isUNCPath) {
|
|
25
|
-
if (!isPathAbsolute) return `//./${path}`;
|
|
26
|
-
return `//${path}`;
|
|
27
|
-
}
|
|
28
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
29
|
-
};
|
|
30
|
-
const join = function(...segments) {
|
|
31
|
-
let path = "";
|
|
32
|
-
for (const seg of segments) {
|
|
33
|
-
if (!seg) continue;
|
|
34
|
-
if (path.length > 0) {
|
|
35
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
36
|
-
const segLeading = seg[0] === "/";
|
|
37
|
-
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
38
|
-
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
39
|
-
} else path += seg;
|
|
40
|
-
}
|
|
41
|
-
return normalize(path);
|
|
42
|
-
};
|
|
43
|
-
function cwd() {
|
|
44
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
45
|
-
return "/";
|
|
46
|
-
}
|
|
47
|
-
const resolve = function(...arguments_) {
|
|
48
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
49
|
-
let resolvedPath = "";
|
|
50
|
-
let resolvedAbsolute = false;
|
|
51
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
52
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
53
|
-
if (!path || path.length === 0) continue;
|
|
54
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
55
|
-
resolvedAbsolute = isAbsolute(path);
|
|
56
|
-
}
|
|
57
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
58
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
59
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
60
|
-
};
|
|
61
|
-
function normalizeString(path, allowAboveRoot) {
|
|
62
|
-
let res = "";
|
|
63
|
-
let lastSegmentLength = 0;
|
|
64
|
-
let lastSlash = -1;
|
|
65
|
-
let dots = 0;
|
|
66
|
-
let char = null;
|
|
67
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
68
|
-
if (index < path.length) char = path[index];
|
|
69
|
-
else if (char === "/") break;
|
|
70
|
-
else char = "/";
|
|
71
|
-
if (char === "/") {
|
|
72
|
-
if (lastSlash === index - 1 || dots === 1);
|
|
73
|
-
else if (dots === 2) {
|
|
74
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
75
|
-
if (res.length > 2) {
|
|
76
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
77
|
-
if (lastSlashIndex === -1) {
|
|
78
|
-
res = "";
|
|
79
|
-
lastSegmentLength = 0;
|
|
80
|
-
} else {
|
|
81
|
-
res = res.slice(0, lastSlashIndex);
|
|
82
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
83
|
-
}
|
|
84
|
-
lastSlash = index;
|
|
85
|
-
dots = 0;
|
|
86
|
-
continue;
|
|
87
|
-
} else if (res.length > 0) {
|
|
88
|
-
res = "";
|
|
89
|
-
lastSegmentLength = 0;
|
|
90
|
-
lastSlash = index;
|
|
91
|
-
dots = 0;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (allowAboveRoot) {
|
|
96
|
-
res += res.length > 0 ? "/.." : "..";
|
|
97
|
-
lastSegmentLength = 2;
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
101
|
-
else res = path.slice(lastSlash + 1, index);
|
|
102
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
103
|
-
}
|
|
104
|
-
lastSlash = index;
|
|
105
|
-
dots = 0;
|
|
106
|
-
} else if (char === "." && dots !== -1) ++dots;
|
|
107
|
-
else dots = -1;
|
|
108
|
-
}
|
|
109
|
-
return res;
|
|
110
|
-
}
|
|
111
|
-
const isAbsolute = function(p) {
|
|
112
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
113
|
-
};
|
|
114
|
-
const extname = function(p) {
|
|
115
|
-
if (p === "..") return "";
|
|
116
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
117
|
-
return match && match[1] || "";
|
|
118
|
-
};
|
|
119
|
-
const dirname = function(p) {
|
|
120
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
121
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
122
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
123
|
-
};
|
|
124
|
-
const basename = function(p, extension) {
|
|
125
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
126
|
-
let lastSegment = "";
|
|
127
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
128
|
-
const val = segments[i];
|
|
129
|
-
if (val) {
|
|
130
|
-
lastSegment = val;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
//#endregion
|
|
138
|
-
export { basename, dirname, extname, isAbsolute, join, normalize, resolve };
|
|
139
|
-
//# sourceMappingURL=pathe.M-eThtNZ.mjs.map
|
package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathe.M-eThtNZ.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs"],"sourcesContent":["let _lazyMatch = () => { var __lib__=(()=>{var m=Object.defineProperty,V=Object.getOwnPropertyDescriptor,G=Object.getOwnPropertyNames,T=Object.prototype.hasOwnProperty,q=(r,e)=>{for(var n in e)m(r,n,{get:e[n],enumerable:true});},H=(r,e,n,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let t of G(e))!T.call(r,t)&&t!==n&&m(r,t,{get:()=>e[t],enumerable:!(a=V(e,t))||a.enumerable});return r},J=r=>H(m({},\"__esModule\",{value:true}),r),w={};q(w,{default:()=>re});var A=r=>Array.isArray(r),d=r=>typeof r==\"function\",Q=r=>r.length===0,W=r=>typeof r==\"number\",K=r=>typeof r==\"object\"&&r!==null,X=r=>r instanceof RegExp,b=r=>typeof r==\"string\",h=r=>r===void 0,Y=r=>{const e=new Map;return n=>{const a=e.get(n);if(a)return a;const t=r(n);return e.set(n,t),t}},rr=(r,e,n={})=>{const a={cache:{},input:r,index:0,indexMax:0,options:n,output:[]};if(v(e)(a)&&a.index===r.length)return a.output;throw new Error(`Failed to parse at index ${a.indexMax}`)},i=(r,e)=>A(r)?er(r,e):b(r)?ar(r,e):nr(r,e),er=(r,e)=>{const n={};for(const a of r){if(a.length!==1)throw new Error(`Invalid character: \"${a}\"`);const t=a.charCodeAt(0);n[t]=true;}return a=>{const t=a.index,o=a.input;for(;a.index<o.length&&o.charCodeAt(a.index)in n;)a.index+=1;const u=a.index;if(u>t){if(!h(e)&&!a.options.silent){const s=a.input.slice(t,u),c=d(e)?e(s,o,String(t)):e;h(c)||a.output.push(c);}a.indexMax=Math.max(a.indexMax,a.index);}return true}},nr=(r,e)=>{const n=r.source,a=r.flags.replace(/y|$/,\"y\"),t=new RegExp(n,a);return g(o=>{t.lastIndex=o.index;const u=t.exec(o.input);if(u){if(!h(e)&&!o.options.silent){const s=d(e)?e(...u,o.input,String(o.index)):e;h(s)||o.output.push(s);}return o.index+=u[0].length,o.indexMax=Math.max(o.indexMax,o.index),true}else return false})},ar=(r,e)=>n=>{if(n.input.startsWith(r,n.index)){if(!h(e)&&!n.options.silent){const t=d(e)?e(r,n.input,String(n.index)):e;h(t)||n.output.push(t);}return n.index+=r.length,n.indexMax=Math.max(n.indexMax,n.index),true}else return false},C=(r,e,n,a)=>{const t=v(r);return g(_(M(o=>{let u=0;for(;u<n;){const s=o.index;if(!t(o)||(u+=1,o.index===s))break}return u>=e})))},tr=(r,e)=>C(r,0,1),f=(r,e)=>C(r,0,1/0),x=(r,e)=>{const n=r.map(v);return g(_(M(a=>{for(let t=0,o=n.length;t<o;t++)if(!n[t](a))return false;return true})))},l=(r,e)=>{const n=r.map(v);return g(_(a=>{for(let t=0,o=n.length;t<o;t++)if(n[t](a))return true;return false}))},M=(r,e=false)=>{const n=v(r);return a=>{const t=a.index,o=a.output.length,u=n(a);return (!u||e)&&(a.index=t,a.output.length!==o&&(a.output.length=o)),u}},_=(r,e)=>{const n=v(r);return n},g=(()=>{let r=0;return e=>{const n=v(e),a=r+=1;return t=>{var o;if(t.options.memoization===false)return n(t);const u=t.index,s=(o=t.cache)[a]||(o[a]=new Map),c=s.get(u);if(c===false)return false;if(W(c))return t.index=c,true;if(c)return t.index=c.index,c.output?.length&&t.output.push(...c.output),true;{const Z=t.output.length;if(n(t)){const D=t.index,U=t.output.length;if(U>Z){const ee=t.output.slice(Z,U);s.set(u,{index:D,output:ee});}else s.set(u,D);return true}else return s.set(u,false),false}}}})(),E=r=>{let e;return n=>(e||(e=v(r())),e(n))},v=Y(r=>{if(d(r))return Q(r)?E(r):r;if(b(r)||X(r))return i(r);if(A(r))return x(r);if(K(r))return l(Object.values(r));throw new Error(\"Invalid rule\")}),P=\"abcdefghijklmnopqrstuvwxyz\",ir=r=>{let e=\"\";for(;r>0;){const n=(r-1)%26;e=P[n]+e,r=Math.floor((r-1)/26);}return e},O=r=>{let e=0;for(let n=0,a=r.length;n<a;n++)e=e*26+P.indexOf(r[n])+1;return e},S=(r,e)=>{if(e<r)return S(e,r);const n=[];for(;r<=e;)n.push(r++);return n},or=(r,e,n)=>S(r,e).map(a=>String(a).padStart(n,\"0\")),R=(r,e)=>S(O(r),O(e)).map(ir),p=r=>r,z=r=>ur(e=>rr(e,r,{memoization:false}).join(\"\")),ur=r=>{const e={};return n=>e[n]??(e[n]=r(n))},sr=i(/^\\*\\*\\/\\*$/,\".*\"),cr=i(/^\\*\\*\\/(\\*)?([ a-zA-Z0-9._-]+)$/,(r,e,n)=>`.*${e?\"\":\"(?:^|/)\"}${n.replaceAll(\".\",\"\\\\.\")}`),lr=i(/^\\*\\*\\/(\\*)?([ a-zA-Z0-9._-]*)\\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\\}$/,(r,e,n,a)=>`.*${e?\"\":\"(?:^|/)\"}${n.replaceAll(\".\",\"\\\\.\")}(?:${a.replaceAll(\",\",\"|\").replaceAll(\".\",\"\\\\.\")})`),y=i(/\\\\./,p),pr=i(/[$.*+?^(){}[\\]\\|]/,r=>`\\\\${r}`),vr=i(/./,p),hr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r=i(/([^/{[(!])\\*\\*/,(r,e)=>`${e}*`),Qr=i(/(^|.)\\*\\*(?=[^*/)\\]}])/,(r,e)=>`${e}*`),Wr=f(l([Tr,Hr,Jr,Qr,qr])),Kr=Wr,Xr=z(Kr),Yr=Xr,$=(r,e)=>{const n=Array.isArray(r)?r:[r];if(!n.length)return false;const a=n.map($.compile),t=n.every(s=>/(\\/(?:\\*\\*)?|\\[\\/\\])$/.test(s)),o=e.replace(/[\\\\\\/]+/g,\"/\").replace(/\\/$/,t?\"/\":\"\");return a.some(s=>s.test(o))};$.compile=r=>new RegExp(`^${L(Yr(r))}$`,\"s\");var re=$;return J(w)})();\n return __lib__.default || __lib__; };\nlet _match;\nconst zeptomatch = (path, pattern) => {\n if (!_match) {\n _match = _lazyMatch();\n _lazyMatch = null;\n }\n return _match(path, pattern);\n};\n\nconst _DRIVE_LETTER_START_RE = /^[A-Za-z]:\\//;\nfunction normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n return input.replace(/\\\\/g, \"/\").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());\n}\n\nconst _UNC_REGEX = /^[/\\\\]{2}/;\nconst _IS_ABSOLUTE_RE = /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^[A-Za-z]:[/\\\\]/;\nconst _DRIVE_LETTER_RE = /^[A-Za-z]:$/;\nconst _ROOT_FOLDER_RE = /^\\/([A-Za-z]:)?$/;\nconst _EXTNAME_RE = /.(\\.[^./]+|\\.)$/;\nconst _PATH_ROOT_RE = /^[/\\\\]|^[a-zA-Z]:[/\\\\]/;\nconst sep = \"/\";\nconst normalize = function(path) {\n if (path.length === 0) {\n return \".\";\n }\n path = normalizeWindowsPath(path);\n const isUNCPath = path.match(_UNC_REGEX);\n const isPathAbsolute = isAbsolute(path);\n const trailingSeparator = path[path.length - 1] === \"/\";\n path = normalizeString(path, !isPathAbsolute);\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n if (trailingSeparator) {\n path += \"/\";\n }\n if (_DRIVE_LETTER_RE.test(path)) {\n path += \"/\";\n }\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;\n};\nconst join = function(...segments) {\n let path = \"\";\n for (const seg of segments) {\n if (!seg) {\n continue;\n }\n if (path.length > 0) {\n const pathTrailing = path[path.length - 1] === \"/\";\n const segLeading = seg[0] === \"/\";\n const both = pathTrailing && segLeading;\n if (both) {\n path += seg.slice(1);\n } else {\n path += pathTrailing || segLeading ? seg : `/${seg}`;\n }\n } else {\n path += seg;\n }\n }\n return normalize(path);\n};\nfunction cwd() {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n return process.cwd().replace(/\\\\/g, \"/\");\n }\n return \"/\";\n}\nconst resolve = function(...arguments_) {\n arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));\n let resolvedPath = \"\";\n let resolvedAbsolute = false;\n for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {\n const path = index >= 0 ? arguments_[index] : cwd();\n if (!path || path.length === 0) {\n continue;\n }\n resolvedPath = `${path}/${resolvedPath}`;\n resolvedAbsolute = isAbsolute(path);\n }\n resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);\n if (resolvedAbsolute && !isAbsolute(resolvedPath)) {\n return `/${resolvedPath}`;\n }\n return resolvedPath.length > 0 ? resolvedPath : \".\";\n};\nfunction normalizeString(path, allowAboveRoot) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n char = path[index];\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== \".\" || res[res.length - 2] !== \".\") {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\nconst isAbsolute = function(p) {\n return _IS_ABSOLUTE_RE.test(p);\n};\nconst toNamespacedPath = function(p) {\n return normalizeWindowsPath(p);\n};\nconst extname = function(p) {\n if (p === \"..\") return \"\";\n const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));\n return match && match[1] || \"\";\n};\nconst relative = function(from, to) {\n const _from = resolve(from).replace(_ROOT_FOLDER_RE, \"$1\").split(\"/\");\n const _to = resolve(to).replace(_ROOT_FOLDER_RE, \"$1\").split(\"/\");\n if (_to[0][1] === \":\" && _from[0][1] === \":\" && _from[0] !== _to[0]) {\n return _to.join(\"/\");\n }\n const _fromCopy = [..._from];\n for (const segment of _fromCopy) {\n if (_to[0] !== segment) {\n break;\n }\n _from.shift();\n _to.shift();\n }\n return [..._from.map(() => \"..\"), ..._to].join(\"/\");\n};\nconst dirname = function(p) {\n const segments = normalizeWindowsPath(p).replace(/\\/$/, \"\").split(\"/\").slice(0, -1);\n if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {\n segments[0] += \"/\";\n }\n return segments.join(\"/\") || (isAbsolute(p) ? \"/\" : \".\");\n};\nconst format = function(p) {\n const ext = p.ext ? p.ext.startsWith(\".\") ? p.ext : `.${p.ext}` : \"\";\n const segments = [p.root, p.dir, p.base ?? (p.name ?? \"\") + ext].filter(\n Boolean\n );\n return normalizeWindowsPath(\n p.root ? resolve(...segments) : segments.join(\"/\")\n );\n};\nconst basename = function(p, extension) {\n const segments = normalizeWindowsPath(p).split(\"/\");\n let lastSegment = \"\";\n for (let i = segments.length - 1; i >= 0; i--) {\n const val = segments[i];\n if (val) {\n lastSegment = val;\n break;\n }\n }\n return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;\n};\nconst parse = function(p) {\n const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\\\/g, \"/\") || \"\";\n const base = basename(p);\n const extension = extname(base);\n return {\n root,\n dir: dirname(p),\n base,\n ext: extension,\n name: base.slice(0, base.length - extension.length)\n };\n};\nconst matchesGlob = (path, pattern) => {\n return zeptomatch(pattern, normalize(path));\n};\n\nconst _path = {\n __proto__: null,\n basename: basename,\n dirname: dirname,\n extname: extname,\n format: format,\n isAbsolute: isAbsolute,\n join: join,\n matchesGlob: matchesGlob,\n normalize: normalize,\n normalizeString: normalizeString,\n parse: parse,\n relative: relative,\n resolve: resolve,\n sep: sep,\n toNamespacedPath: toNamespacedPath\n};\n\nexport { _path as _, normalizeString as a, relative as b, basename as c, dirname as d, extname as e, format as f, normalizeWindowsPath as g, isAbsolute as i, join as j, matchesGlob as m, normalize as n, parse as p, resolve as r, sep as s, toNamespacedPath as t };\n"],"x_google_ignoreList":[0],"mappings":";AAWA,MAAM,yBAAyB;AAC/B,SAAS,qBAAqB,QAAQ,IAAI;AACxC,KAAI,CAAC,MACH,QAAO;AAET,QAAO,MAAM,QAAQ,OAAO,IAAI,CAAC,QAAQ,yBAAyB,MAAM,EAAE,aAAa,CAAC;;AAG1F,MAAM,aAAa;AACnB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAEzB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,MAAM;AAExC,wBAAoB,QAAQ,YAAY;;AAE1C,eAAY;AACZ,UAAO;aACE,SAAS,OAAO,SAAS,GAClC,GAAE;MAEF,QAAO;;AAGX,QAAO;;AAET,MAAM,aAAa,SAAS,GAAG;AAC7B,QAAO,gBAAgB,KAAK,EAAE;;AAKhC,MAAM,UAAU,SAAS,GAAG;AAC1B,KAAI,MAAM,KAAM,QAAO;CACvB,MAAM,QAAQ,YAAY,KAAK,qBAAqB,EAAE,CAAC;AACvD,QAAO,SAAS,MAAM,MAAM;;AAkB9B,MAAM,UAAU,SAAS,GAAG;CAC1B,MAAM,WAAW,qBAAqB,EAAE,CAAC,QAAQ,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,GAAG;AACnF,KAAI,SAAS,WAAW,KAAK,iBAAiB,KAAK,SAAS,GAAG,CAC7D,UAAS,MAAM;AAEjB,QAAO,SAAS,KAAK,IAAI,KAAK,WAAW,EAAE,GAAG,MAAM;;AAWtD,MAAM,WAAW,SAAS,GAAG,WAAW;CACtC,MAAM,WAAW,qBAAqB,EAAE,CAAC,MAAM,IAAI;CACnD,IAAI,cAAc;AAClB,MAAK,IAAI,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;EAC7C,MAAM,MAAM,SAAS;AACrB,MAAI,KAAK;AACP,iBAAc;AACd;;;AAGJ,QAAO,aAAa,YAAY,SAAS,UAAU,GAAG,YAAY,MAAM,GAAG,CAAC,UAAU,OAAO,GAAG"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_pathe_M_eThtNZ = require('../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs');
|
|
3
|
-
const require_index = require('../../../../exsolve@1.0.8/node_modules/exsolve/dist/index.cjs');
|
|
4
|
-
const require_json = require('../../../../confbox@0.2.4/node_modules/confbox/dist/_chunks/json.cjs');
|
|
5
|
-
const require_jsonc = require('../../../../confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs');
|
|
6
|
-
let node_fs = require("node:fs");
|
|
7
|
-
let node_fs_promises = require("node:fs/promises");
|
|
8
|
-
let node_url = require("node:url");
|
|
9
|
-
|
|
10
|
-
//#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs
|
|
11
|
-
const defaultFindOptions = {
|
|
12
|
-
startingFrom: ".",
|
|
13
|
-
rootPattern: /^node_modules$/,
|
|
14
|
-
reverse: false,
|
|
15
|
-
test: (filePath) => {
|
|
16
|
-
try {
|
|
17
|
-
if ((0, node_fs.statSync)(filePath).isFile()) return true;
|
|
18
|
-
} catch {}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
async function findFile(filename, _options = {}) {
|
|
22
|
-
const filenames = Array.isArray(filename) ? filename : [filename];
|
|
23
|
-
const options = {
|
|
24
|
-
...defaultFindOptions,
|
|
25
|
-
..._options
|
|
26
|
-
};
|
|
27
|
-
const basePath = require_pathe_M_eThtNZ.resolve(options.startingFrom);
|
|
28
|
-
const leadingSlash = basePath[0] === "/";
|
|
29
|
-
const segments = basePath.split("/").filter(Boolean);
|
|
30
|
-
if (filenames.includes(segments.at(-1)) && await options.test(basePath)) return basePath;
|
|
31
|
-
if (leadingSlash) segments[0] = "/" + segments[0];
|
|
32
|
-
let root = segments.findIndex((r) => r.match(options.rootPattern));
|
|
33
|
-
if (root === -1) root = 0;
|
|
34
|
-
if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
|
|
35
|
-
const filePath = require_pathe_M_eThtNZ.join(...segments.slice(0, index), filename2);
|
|
36
|
-
if (await options.test(filePath)) return filePath;
|
|
37
|
-
}
|
|
38
|
-
else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
|
|
39
|
-
const filePath = require_pathe_M_eThtNZ.join(...segments.slice(0, index), filename2);
|
|
40
|
-
if (await options.test(filePath)) return filePath;
|
|
41
|
-
}
|
|
42
|
-
throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
|
|
43
|
-
}
|
|
44
|
-
function findNearestFile(filename, options = {}) {
|
|
45
|
-
return findFile(filename, options);
|
|
46
|
-
}
|
|
47
|
-
function _resolvePath(id, opts = {}) {
|
|
48
|
-
if (id instanceof URL || id.startsWith("file://")) return require_pathe_M_eThtNZ.normalize((0, node_url.fileURLToPath)(id));
|
|
49
|
-
if (require_pathe_M_eThtNZ.isAbsolute(id)) return require_pathe_M_eThtNZ.normalize(id);
|
|
50
|
-
return require_index.resolveModulePath(id, {
|
|
51
|
-
...opts,
|
|
52
|
-
from: opts.from || opts.parent || opts.url
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const lockFiles = [
|
|
56
|
-
"yarn.lock",
|
|
57
|
-
"package-lock.json",
|
|
58
|
-
"pnpm-lock.yaml",
|
|
59
|
-
"npm-shrinkwrap.json",
|
|
60
|
-
"bun.lockb",
|
|
61
|
-
"bun.lock",
|
|
62
|
-
"deno.lock"
|
|
63
|
-
];
|
|
64
|
-
const packageFiles = [
|
|
65
|
-
"package.json",
|
|
66
|
-
"package.json5",
|
|
67
|
-
"package.yaml"
|
|
68
|
-
];
|
|
69
|
-
const workspaceFiles = [
|
|
70
|
-
"pnpm-workspace.yaml",
|
|
71
|
-
"lerna.json",
|
|
72
|
-
"turbo.json",
|
|
73
|
-
"rush.json",
|
|
74
|
-
"deno.json",
|
|
75
|
-
"deno.jsonc"
|
|
76
|
-
];
|
|
77
|
-
const FileCache = /* @__PURE__ */ new Map();
|
|
78
|
-
async function readPackageJSON(id, options = {}) {
|
|
79
|
-
const resolvedPath = await resolvePackageJSON(id, options);
|
|
80
|
-
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
|
|
81
|
-
if (options.cache && cache.has(resolvedPath)) return cache.get(resolvedPath);
|
|
82
|
-
const blob = await node_fs.promises.readFile(resolvedPath, "utf8");
|
|
83
|
-
let parsed;
|
|
84
|
-
try {
|
|
85
|
-
parsed = require_json.n(blob);
|
|
86
|
-
} catch {
|
|
87
|
-
parsed = require_jsonc.parseJSONC(blob);
|
|
88
|
-
}
|
|
89
|
-
cache.set(resolvedPath, parsed);
|
|
90
|
-
return parsed;
|
|
91
|
-
}
|
|
92
|
-
async function resolvePackageJSON(id = process.cwd(), options = {}) {
|
|
93
|
-
return findNearestFile("package.json", {
|
|
94
|
-
...options,
|
|
95
|
-
startingFrom: _resolvePath(id, options)
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const workspaceTests = {
|
|
99
|
-
workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r) => require_pathe_M_eThtNZ.dirname(r)),
|
|
100
|
-
gitConfig: (opts) => findFile(".git/config", opts).then((r) => require_pathe_M_eThtNZ.resolve(r, "../..")),
|
|
101
|
-
lockFile: (opts) => findFile(lockFiles, opts).then((r) => require_pathe_M_eThtNZ.dirname(r)),
|
|
102
|
-
packageJson: (opts) => findFile(packageFiles, opts).then((r) => require_pathe_M_eThtNZ.dirname(r))
|
|
103
|
-
};
|
|
104
|
-
async function findWorkspaceDir(id = process.cwd(), options = {}) {
|
|
105
|
-
const startingFrom = _resolvePath(id, options);
|
|
106
|
-
const tests = options.tests || [
|
|
107
|
-
"workspaceFile",
|
|
108
|
-
"gitConfig",
|
|
109
|
-
"lockFile",
|
|
110
|
-
"packageJson"
|
|
111
|
-
];
|
|
112
|
-
for (const testName of tests) {
|
|
113
|
-
const test = workspaceTests[testName];
|
|
114
|
-
if (options[testName] === false || !test) continue;
|
|
115
|
-
const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
|
|
116
|
-
const detected = await test({
|
|
117
|
-
...options,
|
|
118
|
-
startingFrom,
|
|
119
|
-
reverse: direction === "furthest"
|
|
120
|
-
}).catch(() => {});
|
|
121
|
-
if (detected) return detected;
|
|
122
|
-
}
|
|
123
|
-
throw new Error(`Cannot detect workspace root from ${id}`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
exports.findWorkspaceDir = findWorkspaceDir;
|
|
128
|
-
exports.readPackageJSON = readPackageJSON;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { dirname, isAbsolute, join, normalize, resolve } from "../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs";
|
|
2
|
-
import { resolveModulePath } from "../../../../exsolve@1.0.8/node_modules/exsolve/dist/index.mjs";
|
|
3
|
-
import { n } from "../../../../confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs";
|
|
4
|
-
import { parseJSONC as r } from "../../../../confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs";
|
|
5
|
-
import { promises, statSync } from "node:fs";
|
|
6
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
|
-
//#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs
|
|
10
|
-
const defaultFindOptions = {
|
|
11
|
-
startingFrom: ".",
|
|
12
|
-
rootPattern: /^node_modules$/,
|
|
13
|
-
reverse: false,
|
|
14
|
-
test: (filePath) => {
|
|
15
|
-
try {
|
|
16
|
-
if (statSync(filePath).isFile()) return true;
|
|
17
|
-
} catch {}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
async function findFile(filename, _options = {}) {
|
|
21
|
-
const filenames = Array.isArray(filename) ? filename : [filename];
|
|
22
|
-
const options = {
|
|
23
|
-
...defaultFindOptions,
|
|
24
|
-
..._options
|
|
25
|
-
};
|
|
26
|
-
const basePath = resolve(options.startingFrom);
|
|
27
|
-
const leadingSlash = basePath[0] === "/";
|
|
28
|
-
const segments = basePath.split("/").filter(Boolean);
|
|
29
|
-
if (filenames.includes(segments.at(-1)) && await options.test(basePath)) return basePath;
|
|
30
|
-
if (leadingSlash) segments[0] = "/" + segments[0];
|
|
31
|
-
let root = segments.findIndex((r) => r.match(options.rootPattern));
|
|
32
|
-
if (root === -1) root = 0;
|
|
33
|
-
if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
|
|
34
|
-
const filePath = join(...segments.slice(0, index), filename2);
|
|
35
|
-
if (await options.test(filePath)) return filePath;
|
|
36
|
-
}
|
|
37
|
-
else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
|
|
38
|
-
const filePath = join(...segments.slice(0, index), filename2);
|
|
39
|
-
if (await options.test(filePath)) return filePath;
|
|
40
|
-
}
|
|
41
|
-
throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
|
|
42
|
-
}
|
|
43
|
-
function findNearestFile(filename, options = {}) {
|
|
44
|
-
return findFile(filename, options);
|
|
45
|
-
}
|
|
46
|
-
function _resolvePath(id, opts = {}) {
|
|
47
|
-
if (id instanceof URL || id.startsWith("file://")) return normalize(fileURLToPath(id));
|
|
48
|
-
if (isAbsolute(id)) return normalize(id);
|
|
49
|
-
return resolveModulePath(id, {
|
|
50
|
-
...opts,
|
|
51
|
-
from: opts.from || opts.parent || opts.url
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
const lockFiles = [
|
|
55
|
-
"yarn.lock",
|
|
56
|
-
"package-lock.json",
|
|
57
|
-
"pnpm-lock.yaml",
|
|
58
|
-
"npm-shrinkwrap.json",
|
|
59
|
-
"bun.lockb",
|
|
60
|
-
"bun.lock",
|
|
61
|
-
"deno.lock"
|
|
62
|
-
];
|
|
63
|
-
const packageFiles = [
|
|
64
|
-
"package.json",
|
|
65
|
-
"package.json5",
|
|
66
|
-
"package.yaml"
|
|
67
|
-
];
|
|
68
|
-
const workspaceFiles = [
|
|
69
|
-
"pnpm-workspace.yaml",
|
|
70
|
-
"lerna.json",
|
|
71
|
-
"turbo.json",
|
|
72
|
-
"rush.json",
|
|
73
|
-
"deno.json",
|
|
74
|
-
"deno.jsonc"
|
|
75
|
-
];
|
|
76
|
-
const FileCache = /* @__PURE__ */ new Map();
|
|
77
|
-
async function readPackageJSON(id, options = {}) {
|
|
78
|
-
const resolvedPath = await resolvePackageJSON(id, options);
|
|
79
|
-
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
|
|
80
|
-
if (options.cache && cache.has(resolvedPath)) return cache.get(resolvedPath);
|
|
81
|
-
const blob = await promises.readFile(resolvedPath, "utf8");
|
|
82
|
-
let parsed;
|
|
83
|
-
try {
|
|
84
|
-
parsed = n(blob);
|
|
85
|
-
} catch {
|
|
86
|
-
parsed = r(blob);
|
|
87
|
-
}
|
|
88
|
-
cache.set(resolvedPath, parsed);
|
|
89
|
-
return parsed;
|
|
90
|
-
}
|
|
91
|
-
async function resolvePackageJSON(id = process.cwd(), options = {}) {
|
|
92
|
-
return findNearestFile("package.json", {
|
|
93
|
-
...options,
|
|
94
|
-
startingFrom: _resolvePath(id, options)
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
const workspaceTests = {
|
|
98
|
-
workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r) => dirname(r)),
|
|
99
|
-
gitConfig: (opts) => findFile(".git/config", opts).then((r) => resolve(r, "../..")),
|
|
100
|
-
lockFile: (opts) => findFile(lockFiles, opts).then((r) => dirname(r)),
|
|
101
|
-
packageJson: (opts) => findFile(packageFiles, opts).then((r) => dirname(r))
|
|
102
|
-
};
|
|
103
|
-
async function findWorkspaceDir(id = process.cwd(), options = {}) {
|
|
104
|
-
const startingFrom = _resolvePath(id, options);
|
|
105
|
-
const tests = options.tests || [
|
|
106
|
-
"workspaceFile",
|
|
107
|
-
"gitConfig",
|
|
108
|
-
"lockFile",
|
|
109
|
-
"packageJson"
|
|
110
|
-
];
|
|
111
|
-
for (const testName of tests) {
|
|
112
|
-
const test = workspaceTests[testName];
|
|
113
|
-
if (options[testName] === false || !test) continue;
|
|
114
|
-
const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
|
|
115
|
-
const detected = await test({
|
|
116
|
-
...options,
|
|
117
|
-
startingFrom,
|
|
118
|
-
reverse: direction === "furthest"
|
|
119
|
-
}).catch(() => {});
|
|
120
|
-
if (detected) return detected;
|
|
121
|
-
}
|
|
122
|
-
throw new Error(`Cannot detect workspace root from ${id}`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
//#endregion
|
|
126
|
-
export { findWorkspaceDir, readPackageJSON };
|
|
127
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["parseJSON","parseJSONC"],"sources":["../../../../../../../../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs"],"sourcesContent":["import { statSync, promises } from 'node:fs';\nimport { resolve, join, normalize, isAbsolute, dirname } from 'pathe';\nimport { parseJSONC, stringifyJSONC, parseJSON, stringifyJSON, parseJSON5, parseYAML, stringifyJSON5, stringifyYAML } from 'confbox';\nimport { resolveModulePath } from 'exsolve';\nimport { fileURLToPath } from 'node:url';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { parseINI, stringifyINI } from 'confbox/ini';\n\nconst defaultFindOptions = {\n startingFrom: \".\",\n rootPattern: /^node_modules$/,\n reverse: false,\n test: (filePath) => {\n try {\n if (statSync(filePath).isFile()) {\n return true;\n }\n } catch {\n }\n }\n};\nasync function findFile(filename, _options = {}) {\n const filenames = Array.isArray(filename) ? filename : [filename];\n const options = { ...defaultFindOptions, ..._options };\n const basePath = resolve(options.startingFrom);\n const leadingSlash = basePath[0] === \"/\";\n const segments = basePath.split(\"/\").filter(Boolean);\n if (filenames.includes(segments.at(-1)) && await options.test(basePath)) {\n return basePath;\n }\n if (leadingSlash) {\n segments[0] = \"/\" + segments[0];\n }\n let root = segments.findIndex((r) => r.match(options.rootPattern));\n if (root === -1) {\n root = 0;\n }\n if (options.reverse) {\n for (let index = root + 1; index <= segments.length; index++) {\n for (const filename2 of filenames) {\n const filePath = join(...segments.slice(0, index), filename2);\n if (await options.test(filePath)) {\n return filePath;\n }\n }\n }\n } else {\n for (let index = segments.length; index > root; index--) {\n for (const filename2 of filenames) {\n const filePath = join(...segments.slice(0, index), filename2);\n if (await options.test(filePath)) {\n return filePath;\n }\n }\n }\n }\n throw new Error(\n `Cannot find matching ${filename} in ${options.startingFrom} or parent directories`\n );\n}\nfunction findNearestFile(filename, options = {}) {\n return findFile(filename, options);\n}\nfunction findFarthestFile(filename, options = {}) {\n return findFile(filename, { ...options, reverse: true });\n}\n\nfunction _resolvePath(id, opts = {}) {\n if (id instanceof URL || id.startsWith(\"file://\")) {\n return normalize(fileURLToPath(id));\n }\n if (isAbsolute(id)) {\n return normalize(id);\n }\n return resolveModulePath(id, {\n ...opts,\n from: opts.from || opts.parent || opts.url\n });\n}\n\nconst FileCache$1 = /* @__PURE__ */ new Map();\nfunction defineTSConfig(tsconfig) {\n return tsconfig;\n}\nasync function readTSConfig(id, options = {}) {\n const resolvedPath = await resolveTSConfig(id, options);\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : FileCache$1;\n if (options.cache && cache.has(resolvedPath)) {\n return cache.get(resolvedPath);\n }\n const text = await promises.readFile(resolvedPath, \"utf8\");\n const parsed = parseJSONC(text);\n cache.set(resolvedPath, parsed);\n return parsed;\n}\nasync function writeTSConfig(path, tsconfig) {\n await promises.writeFile(path, stringifyJSONC(tsconfig));\n}\nasync function resolveTSConfig(id = process.cwd(), options = {}) {\n return findNearestFile(\"tsconfig.json\", {\n ...options,\n startingFrom: _resolvePath(id, options)\n });\n}\n\nconst lockFiles = [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"npm-shrinkwrap.json\",\n \"bun.lockb\",\n \"bun.lock\",\n \"deno.lock\"\n];\nconst packageFiles = [\"package.json\", \"package.json5\", \"package.yaml\"];\nconst workspaceFiles = [\n \"pnpm-workspace.yaml\",\n \"lerna.json\",\n \"turbo.json\",\n \"rush.json\",\n \"deno.json\",\n \"deno.jsonc\"\n];\nconst FileCache = /* @__PURE__ */ new Map();\nfunction definePackageJSON(pkg) {\n return pkg;\n}\nasync function findPackage(id = process.cwd(), options = {}) {\n return findNearestFile(packageFiles, {\n ...options,\n startingFrom: _resolvePath(id, options)\n });\n}\nasync function readPackage(id, options = {}) {\n const resolvedPath = await findPackage(id, options);\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : FileCache;\n if (options.cache && cache.has(resolvedPath)) {\n return cache.get(resolvedPath);\n }\n const blob = await promises.readFile(resolvedPath, \"utf8\");\n let parsed;\n if (resolvedPath.endsWith(\".json5\")) {\n parsed = parseJSON5(blob);\n } else if (resolvedPath.endsWith(\".yaml\")) {\n parsed = parseYAML(blob);\n } else {\n try {\n parsed = parseJSON(blob);\n } catch {\n parsed = parseJSONC(blob);\n }\n }\n cache.set(resolvedPath, parsed);\n return parsed;\n}\nasync function writePackage(path, pkg) {\n let content;\n if (path.endsWith(\".json5\")) {\n content = stringifyJSON5(pkg);\n } else if (path.endsWith(\".yaml\")) {\n content = stringifyYAML(pkg);\n } else {\n content = stringifyJSON(pkg);\n }\n await promises.writeFile(path, content);\n}\nasync function readPackageJSON(id, options = {}) {\n const resolvedPath = await resolvePackageJSON(id, options);\n const cache = options.cache && typeof options.cache !== \"boolean\" ? options.cache : FileCache;\n if (options.cache && cache.has(resolvedPath)) {\n return cache.get(resolvedPath);\n }\n const blob = await promises.readFile(resolvedPath, \"utf8\");\n let parsed;\n try {\n parsed = parseJSON(blob);\n } catch {\n parsed = parseJSONC(blob);\n }\n cache.set(resolvedPath, parsed);\n return parsed;\n}\nasync function writePackageJSON(path, pkg) {\n await promises.writeFile(path, stringifyJSON(pkg));\n}\nasync function resolvePackageJSON(id = process.cwd(), options = {}) {\n return findNearestFile(\"package.json\", {\n ...options,\n startingFrom: _resolvePath(id, options)\n });\n}\nasync function resolveLockfile(id = process.cwd(), options = {}) {\n return findNearestFile(lockFiles, {\n ...options,\n startingFrom: _resolvePath(id, options)\n });\n}\nconst workspaceTests = {\n workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r) => dirname(r)),\n gitConfig: (opts) => findFile(\".git/config\", opts).then((r) => resolve(r, \"../..\")),\n lockFile: (opts) => findFile(lockFiles, opts).then((r) => dirname(r)),\n packageJson: (opts) => findFile(packageFiles, opts).then((r) => dirname(r))\n};\nasync function findWorkspaceDir(id = process.cwd(), options = {}) {\n const startingFrom = _resolvePath(id, options);\n const tests = options.tests || [\"workspaceFile\", \"gitConfig\", \"lockFile\", \"packageJson\"];\n for (const testName of tests) {\n const test = workspaceTests[testName];\n if (options[testName] === false || !test) {\n continue;\n }\n const direction = options[testName] || (testName === \"gitConfig\" ? \"closest\" : \"furthest\");\n const detected = await test({\n ...options,\n startingFrom,\n reverse: direction === \"furthest\"\n }).catch(() => {\n });\n if (detected) {\n return detected;\n }\n }\n throw new Error(`Cannot detect workspace root from ${id}`);\n}\nasync function updatePackage(id, callback, options = {}) {\n const resolvedPath = await findPackage(id, options);\n const pkg = await readPackage(id, options);\n const proxy = new Proxy(pkg, {\n get(target, prop) {\n if (typeof prop === \"string\" && objectKeys.has(prop) && !Object.hasOwn(target, prop)) {\n target[prop] = {};\n }\n return Reflect.get(target, prop);\n }\n });\n const updated = await callback(proxy) || pkg;\n await writePackage(resolvedPath, updated);\n}\nfunction sortPackage(pkg) {\n const sorted = {};\n const originalKeys = Object.keys(pkg);\n const knownKeysPresent = defaultFieldOrder.filter(\n (key) => Object.hasOwn(pkg, key)\n );\n for (const key of originalKeys) {\n const currentIndex = knownKeysPresent.indexOf(key);\n if (currentIndex === -1) {\n sorted[key] = pkg[key];\n continue;\n }\n for (let i = 0; i <= currentIndex; i++) {\n const knownKey = knownKeysPresent[i];\n if (!Object.hasOwn(sorted, knownKey)) {\n sorted[knownKey] = pkg[knownKey];\n }\n }\n }\n for (const key of [...dependencyKeys, \"scripts\"]) {\n const value = sorted[key];\n if (isObject(value)) {\n sorted[key] = sortObject(value);\n }\n }\n return sorted;\n}\nfunction normalizePackage(pkg) {\n const normalized = sortPackage(pkg);\n for (const key of dependencyKeys) {\n if (!Object.hasOwn(normalized, key)) {\n continue;\n }\n const value = normalized[key];\n if (!isObject(value)) {\n delete normalized[key];\n }\n }\n return normalized;\n}\nfunction isObject(value) {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction sortObject(obj) {\n return Object.fromEntries(\n Object.entries(obj).sort(([a], [b]) => a.localeCompare(b))\n );\n}\nconst dependencyKeys = [\n \"dependencies\",\n \"devDependencies\",\n \"optionalDependencies\",\n \"peerDependencies\"\n];\nconst objectKeys = /* @__PURE__ */ new Set([\n \"typesVersions\",\n \"scripts\",\n \"resolutions\",\n \"overrides\",\n \"dependencies\",\n \"devDependencies\",\n \"dependenciesMeta\",\n \"peerDependencies\",\n \"peerDependenciesMeta\",\n \"optionalDependencies\",\n \"engines\",\n \"publishConfig\"\n]);\nconst defaultFieldOrder = [\n \"$schema\",\n \"name\",\n \"version\",\n \"private\",\n \"description\",\n \"keywords\",\n \"homepage\",\n \"bugs\",\n \"repository\",\n \"funding\",\n \"license\",\n \"author\",\n \"sideEffects\",\n \"type\",\n \"imports\",\n \"exports\",\n \"main\",\n \"module\",\n \"browser\",\n \"types\",\n \"typesVersions\",\n \"typings\",\n \"bin\",\n \"man\",\n \"files\",\n \"workspaces\",\n \"scripts\",\n \"resolutions\",\n \"overrides\",\n \"dependencies\",\n \"devDependencies\",\n \"dependenciesMeta\",\n \"peerDependencies\",\n \"peerDependenciesMeta\",\n \"optionalDependencies\",\n \"bundledDependencies\",\n \"bundleDependencies\",\n \"packageManager\",\n \"engines\",\n \"publishConfig\"\n];\n\nfunction defineGitConfig(config) {\n return config;\n}\nasync function resolveGitConfig(dir, opts) {\n return findNearestFile(\".git/config\", { ...opts, startingFrom: dir });\n}\nasync function readGitConfig(dir, opts) {\n const path = await resolveGitConfig(dir, opts);\n const ini = await readFile(path, \"utf8\");\n return parseGitConfig(ini);\n}\nasync function writeGitConfig(path, config) {\n await writeFile(path, stringifyGitConfig(config));\n}\nfunction parseGitConfig(ini) {\n return parseINI(ini.replaceAll(/^\\[(\\w+) \"(.+)\"\\]$/gm, \"[$1.$2]\"));\n}\nfunction stringifyGitConfig(config) {\n return stringifyINI(config).replaceAll(/^\\[(\\w+)\\.(\\w+)\\]$/gm, '[$1 \"$2\"]');\n}\n\nexport { defineGitConfig, definePackageJSON, defineTSConfig, findFarthestFile, findFile, findNearestFile, findPackage, findWorkspaceDir, normalizePackage, parseGitConfig, readGitConfig, readPackage, readPackageJSON, readTSConfig, resolveGitConfig, resolveLockfile, resolvePackageJSON, resolveTSConfig, sortPackage, stringifyGitConfig, updatePackage, writeGitConfig, writePackage, writePackageJSON, writeTSConfig };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;AAQA,MAAM,qBAAqB;CACzB,cAAc;CACd,aAAa;CACb,SAAS;CACT,OAAO,aAAa;AAClB,MAAI;AACF,OAAI,SAAS,SAAS,CAAC,QAAQ,CAC7B,QAAO;UAEH;;CAGX;AACD,eAAe,SAAS,UAAU,WAAW,EAAE,EAAE;CAC/C,MAAM,YAAY,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS;CACjE,MAAM,UAAU;EAAE,GAAG;EAAoB,GAAG;EAAU;CACtD,MAAM,WAAW,QAAQ,QAAQ,aAAa;CAC9C,MAAM,eAAe,SAAS,OAAO;CACrC,MAAM,WAAW,SAAS,MAAM,IAAI,CAAC,OAAO,QAAQ;AACpD,KAAI,UAAU,SAAS,SAAS,GAAG,GAAG,CAAC,IAAI,MAAM,QAAQ,KAAK,SAAS,CACrE,QAAO;AAET,KAAI,aACF,UAAS,KAAK,MAAM,SAAS;CAE/B,IAAI,OAAO,SAAS,WAAW,MAAM,EAAE,MAAM,QAAQ,YAAY,CAAC;AAClE,KAAI,SAAS,GACX,QAAO;AAET,KAAI,QAAQ,QACV,MAAK,IAAI,QAAQ,OAAO,GAAG,SAAS,SAAS,QAAQ,QACnD,MAAK,MAAM,aAAa,WAAW;EACjC,MAAM,WAAW,KAAK,GAAG,SAAS,MAAM,GAA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