@nemo-cli/shared 0.0.1-beta.2
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 +9 -0
- package/dist/index.d.ts +290 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3078 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3078 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path, { dirname as dirname$1, resolve } from "node:path";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import { glob as glob$1 } from "glob";
|
|
5
|
+
import { cancel, confirm, group, groupMultiselect, intro, isCancel, log as log$1, multiselect, note, outro, progress, select, spinner, stream, taskLog, tasks, text } from "@clack/prompts";
|
|
6
|
+
import ansiEscapes, { clearScreen as clearScreen$1, clearTerminal as clearTerminal$1 } from "ansi-escapes";
|
|
7
|
+
import chalk, { default as colors } from "chalk";
|
|
8
|
+
import winston from "winston";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { loadConfig } from "unconfig";
|
|
11
|
+
import open, { apps, openApp } from "open";
|
|
12
|
+
import process$1 from "node:process";
|
|
13
|
+
import { Command } from "commander";
|
|
14
|
+
import { x as x$1 } from "tinyexec";
|
|
15
|
+
import { $ } from "zx";
|
|
16
|
+
import { ErrorMessage } from "@nemo-cli/ui";
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import Configstore from "configstore";
|
|
20
|
+
import { search } from "@inquirer/prompts";
|
|
21
|
+
import Fuse from "fuse.js";
|
|
22
|
+
import instance, { spinners } from "ora";
|
|
23
|
+
import fs from "node:fs/promises";
|
|
24
|
+
import yaml from "yaml";
|
|
25
|
+
|
|
26
|
+
//#region rolldown:runtime
|
|
27
|
+
var __create = Object.create;
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
31
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
32
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __copyProps = (to, from, except, desc) => {
|
|
35
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
36
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
37
|
+
key = keys[i];
|
|
38
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
39
|
+
__defProp(to, key, {
|
|
40
|
+
get: ((k) => from[k]).bind(null, key),
|
|
41
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
49
|
+
value: mod,
|
|
50
|
+
enumerable: true
|
|
51
|
+
}) : target, mod));
|
|
52
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/utils/types.ts
|
|
56
|
+
const hasOwn = (target, key) => Object.hasOwn(target, key);
|
|
57
|
+
const has = (target, key) => Reflect.has(target, key);
|
|
58
|
+
const isType = (type) => (obj) => Object.prototype.toString.call(obj) === `[object ${type}]`;
|
|
59
|
+
const isString = isType("String");
|
|
60
|
+
const isNumber = isType("Number");
|
|
61
|
+
const isBoolean = isType("Boolean");
|
|
62
|
+
const isNull = isType("Null");
|
|
63
|
+
const isUndefined = isType("Undefined");
|
|
64
|
+
const isError = isType("Error");
|
|
65
|
+
const isPromise = isType("Promise");
|
|
66
|
+
const isPlainObject = isType("Object");
|
|
67
|
+
const isArray = isType("Array");
|
|
68
|
+
const isDate = isType("Date");
|
|
69
|
+
const isFunction = isType("Function");
|
|
70
|
+
const isSymbol = isType("Symbol");
|
|
71
|
+
const isSet = isType("Set");
|
|
72
|
+
const isMap = isType("Map");
|
|
73
|
+
const isFormData = isType("FormData");
|
|
74
|
+
const isURLSearchParams = isType("URLSearchParams");
|
|
75
|
+
const isEmpty = (value) => {
|
|
76
|
+
if (value == null) return true;
|
|
77
|
+
if (isString(value)) return value.trim() === "";
|
|
78
|
+
if (isNumber(value)) return !Number.isFinite(value);
|
|
79
|
+
if (isArray(value)) return value.length === 0;
|
|
80
|
+
if (isPlainObject(value)) return Object.keys(value).length === 0;
|
|
81
|
+
return false;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/utils/log.ts
|
|
86
|
+
const customLevels = {
|
|
87
|
+
levels: {
|
|
88
|
+
error: 0,
|
|
89
|
+
warn: 1,
|
|
90
|
+
success: 2,
|
|
91
|
+
info: 3,
|
|
92
|
+
verbose: 4,
|
|
93
|
+
silly: 5,
|
|
94
|
+
timing: 6
|
|
95
|
+
},
|
|
96
|
+
colors: {
|
|
97
|
+
error: "red",
|
|
98
|
+
warn: "yellow",
|
|
99
|
+
success: "green",
|
|
100
|
+
info: "blue",
|
|
101
|
+
verbose: "cyan",
|
|
102
|
+
silly: "magenta",
|
|
103
|
+
timing: "grey"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const DEFAULT_OPTIONS = {
|
|
107
|
+
heading: "@nemo-cli",
|
|
108
|
+
level: "error"
|
|
109
|
+
};
|
|
110
|
+
winston.addColors(customLevels.colors);
|
|
111
|
+
const init = (customOptions) => {
|
|
112
|
+
const options = {
|
|
113
|
+
...customOptions,
|
|
114
|
+
...DEFAULT_OPTIONS
|
|
115
|
+
};
|
|
116
|
+
return winston.createLogger({
|
|
117
|
+
level: options.level,
|
|
118
|
+
levels: customLevels.levels,
|
|
119
|
+
format: winston.format.combine(winston.format.colorize({ all: true })),
|
|
120
|
+
transports: [new winston.transports.Console({ format: winston.format.simple() })]
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
const logger = init();
|
|
124
|
+
const transformMessage = (messages) => {
|
|
125
|
+
for (let i = 0; i < messages.length; i++) {
|
|
126
|
+
const [current, next] = [messages[i], messages[i + 1]];
|
|
127
|
+
if (isString(current) && isString(next)) messages.splice(i, 2, `${current}${next}`);
|
|
128
|
+
}
|
|
129
|
+
return messages;
|
|
130
|
+
};
|
|
131
|
+
const log = {
|
|
132
|
+
init,
|
|
133
|
+
get level() {
|
|
134
|
+
throw new Error("can't visit level");
|
|
135
|
+
},
|
|
136
|
+
set level(_) {
|
|
137
|
+
throw new Error("use setLevel");
|
|
138
|
+
},
|
|
139
|
+
setLevel(level) {
|
|
140
|
+
logger.level = level;
|
|
141
|
+
},
|
|
142
|
+
stopDebug() {
|
|
143
|
+
logger.level = "warn";
|
|
144
|
+
logger.warn("current winston level", logger.level);
|
|
145
|
+
},
|
|
146
|
+
show(message, options) {
|
|
147
|
+
const text$1 = options?.colors?.bold(message) ?? message;
|
|
148
|
+
const type = options?.type ?? "info";
|
|
149
|
+
if (options?.symbol) log$1.message(text$1, { symbol: options.symbol });
|
|
150
|
+
else log$1[type](text$1);
|
|
151
|
+
},
|
|
152
|
+
info(...messages) {
|
|
153
|
+
for (const message of transformMessage(messages)) if (isString(message)) logger.info(`${message}`);
|
|
154
|
+
else logger.info(`${JSON.stringify(message, null, 2)}`);
|
|
155
|
+
},
|
|
156
|
+
warn(...messages) {
|
|
157
|
+
for (const message of transformMessage(messages)) if (isString(message)) logger.warn(`${message}`);
|
|
158
|
+
else logger.warn(`${JSON.stringify(message, null, 2)}`);
|
|
159
|
+
},
|
|
160
|
+
debug() {
|
|
161
|
+
logger.warn("current winston level", logger.level);
|
|
162
|
+
},
|
|
163
|
+
timing(time) {
|
|
164
|
+
logger.log("timing", `${time}`);
|
|
165
|
+
},
|
|
166
|
+
error(...messages) {
|
|
167
|
+
for (const message of transformMessage(messages)) if (isString(message)) logger.error(`${chalk.red.bgBlack(message)}`);
|
|
168
|
+
else console.log(message);
|
|
169
|
+
},
|
|
170
|
+
verbose(...messages) {
|
|
171
|
+
for (const message of transformMessage(messages)) if (isString(message)) logger.verbose(`${message}`);
|
|
172
|
+
else logger.verbose(`${JSON.stringify(message, null, 2)}`);
|
|
173
|
+
},
|
|
174
|
+
success(...messages) {
|
|
175
|
+
for (const message of transformMessage(messages)) if (isString(message)) logger.log("success", `${chalk.green.bgBlack(message)}`);
|
|
176
|
+
else console.log(message);
|
|
177
|
+
},
|
|
178
|
+
clearScreen() {
|
|
179
|
+
process.stdout.write(ansiEscapes.clearScreen);
|
|
180
|
+
},
|
|
181
|
+
clearTerminal() {
|
|
182
|
+
process.stdout.write(ansiEscapes.clearTerminal);
|
|
183
|
+
},
|
|
184
|
+
beep() {
|
|
185
|
+
process.stdout.write(ansiEscapes.beep);
|
|
186
|
+
},
|
|
187
|
+
scrollDown() {
|
|
188
|
+
process.stdout.write(ansiEscapes.scrollDown);
|
|
189
|
+
},
|
|
190
|
+
scrollUp() {
|
|
191
|
+
process.stdout.write(ansiEscapes.scrollUp);
|
|
192
|
+
},
|
|
193
|
+
eraseEndLine() {
|
|
194
|
+
process.stdout.write(ansiEscapes.cursorPrevLine);
|
|
195
|
+
process.stdout.write(ansiEscapes.eraseLine);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/utils/pathname.ts
|
|
201
|
+
const filename = (importMate) => fileURLToPath(importMate.url);
|
|
202
|
+
const dirname = (importMate) => dirname$1(filename(importMate));
|
|
203
|
+
const cwdPathname = (dirname) => resolve(process.cwd(), dirname);
|
|
204
|
+
const REGEXP_SPLIT_NAMES = /\W+/gm;
|
|
205
|
+
const parseNames = (names) => names.split(REGEXP_SPLIT_NAMES);
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/utils/file.ts
|
|
209
|
+
const readPackage = (importMeta, ...paths) => {
|
|
210
|
+
try {
|
|
211
|
+
return readJSON(`${resolve(dirname(importMeta), ...paths)}/package.json`);
|
|
212
|
+
} catch (err) {
|
|
213
|
+
log.error("file readPackage error:", err.message);
|
|
214
|
+
process.exit(0);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const readJSON = (path$14, _overwrite = false) => {
|
|
218
|
+
if (fse.existsSync(path$14)) return fse.readJsonSync(path$14);
|
|
219
|
+
log.error("file", `你所查找的${path$14}文件不存在`);
|
|
220
|
+
};
|
|
221
|
+
const writeJSON = (path$14, content, force = false) => {
|
|
222
|
+
if (!fse.existsSync(path$14)) force ? fse.mkdirSync(dirname$1(path$14), { recursive: true }) : log.error("file", `你所查找的${path$14}文件不存在`);
|
|
223
|
+
return fse.writeFileSync(path$14, JSON.stringify(content, null, 2));
|
|
224
|
+
};
|
|
225
|
+
const readFile = (importMeta, ...paths) => {
|
|
226
|
+
const path$14 = resolve(dirname(importMeta), ...paths);
|
|
227
|
+
return fse.readFileSync(path$14, "utf-8");
|
|
228
|
+
};
|
|
229
|
+
const copyFile = (src, dest, _overwrite = false) => {
|
|
230
|
+
if (fse.existsSync(dest)) log.error("file", `${dest}`);
|
|
231
|
+
fse.copyFileSync(src, dest);
|
|
232
|
+
};
|
|
233
|
+
const checkFile = (src) => fse.existsSync(src);
|
|
234
|
+
const deleteFile = (file) => fse.removeSync(file);
|
|
235
|
+
const deleteFiles = (files) => {
|
|
236
|
+
for (const file of files) fse.removeSync(file);
|
|
237
|
+
};
|
|
238
|
+
const emptyDir = (src) => {
|
|
239
|
+
log.verbose("empty", src);
|
|
240
|
+
fse.emptyDirSync(src);
|
|
241
|
+
};
|
|
242
|
+
const emptyDirs = (dirs) => {
|
|
243
|
+
for (const dir of dirs) emptyDir(dir);
|
|
244
|
+
};
|
|
245
|
+
const isEmptyDir = (src) => {
|
|
246
|
+
return fse.readdirSync(src).length === 0;
|
|
247
|
+
};
|
|
248
|
+
const dirList = (src = "./") => {
|
|
249
|
+
return fileList(src).filter((file) => fse.statSync(`${src}/${file}`).isDirectory());
|
|
250
|
+
};
|
|
251
|
+
const fileList = (src = "./") => {
|
|
252
|
+
return fse.readdirSync(src);
|
|
253
|
+
};
|
|
254
|
+
const filterDirList = (list) => {
|
|
255
|
+
return list.filter((item) => fse.statSync(item).isDirectory());
|
|
256
|
+
};
|
|
257
|
+
function glob(pattern, options = {}) {
|
|
258
|
+
return glob$1(pattern, {
|
|
259
|
+
ignore: "node_modules/**",
|
|
260
|
+
...options
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* 读取当前执行文件夹内的 .gitignore 文件内容
|
|
265
|
+
* @param cwd 当前工作目录,默认为 process.cwd()
|
|
266
|
+
* @returns .gitignore 文件内容,如果文件不存在则返回 null
|
|
267
|
+
*/
|
|
268
|
+
const readGitignore = (cwd = process.cwd()) => {
|
|
269
|
+
const gitignorePath = resolve(cwd, ".gitignore");
|
|
270
|
+
if (!fse.existsSync(gitignorePath)) {
|
|
271
|
+
log.verbose("gitignore", `未找到 .gitignore 文件: ${gitignorePath}`);
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const content = fse.readFileSync(gitignorePath, "utf-8");
|
|
276
|
+
log.verbose("gitignore", `成功读取 .gitignore 文件: ${gitignorePath}`);
|
|
277
|
+
return content.split("\n");
|
|
278
|
+
} catch (err) {
|
|
279
|
+
log.error("gitignore", `读取 .gitignore 文件失败: ${err.message}`);
|
|
280
|
+
return [];
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/constants.ts
|
|
286
|
+
const LOWEST_NODE_VERSION = "18.0.0";
|
|
287
|
+
const CONFIG_NAME = ".nemoclirc";
|
|
288
|
+
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/utils/browser.ts
|
|
291
|
+
const openBrowser = (url) => {
|
|
292
|
+
open(url);
|
|
293
|
+
};
|
|
294
|
+
const openBrowserApp = (url) => {
|
|
295
|
+
openApp(url);
|
|
296
|
+
};
|
|
297
|
+
const getBrowserApps = () => {
|
|
298
|
+
return apps;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/utils/color.ts
|
|
303
|
+
const clearScreen = () => console.log(clearScreen$1);
|
|
304
|
+
const clearTerminal = () => console.log(clearTerminal$1);
|
|
305
|
+
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
308
|
+
function isPlainObject$1(value) {
|
|
309
|
+
if (!value || typeof value !== "object") return false;
|
|
310
|
+
const proto = Object.getPrototypeOf(value);
|
|
311
|
+
if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
|
|
312
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
|
|
317
|
+
function isUnsafeProperty(key) {
|
|
318
|
+
return key === "__proto__";
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.44.0/node_modules/es-toolkit/dist/object/merge.mjs
|
|
323
|
+
function merge(target, source) {
|
|
324
|
+
const sourceKeys = Object.keys(source);
|
|
325
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
326
|
+
const key = sourceKeys[i];
|
|
327
|
+
if (isUnsafeProperty(key)) continue;
|
|
328
|
+
const sourceValue = source[key];
|
|
329
|
+
const targetValue = target[key];
|
|
330
|
+
if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
|
|
331
|
+
else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
|
|
332
|
+
else if (isPlainObject$1(sourceValue)) target[key] = merge({}, sourceValue);
|
|
333
|
+
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
334
|
+
}
|
|
335
|
+
return target;
|
|
336
|
+
}
|
|
337
|
+
function isMergeableValue(value) {
|
|
338
|
+
return isPlainObject$1(value) || Array.isArray(value);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/utils/error.ts
|
|
343
|
+
const handleError = (err, message) => {
|
|
344
|
+
if (isError(err)) ErrorMessage({ text: `${message}: ${err.message}` });
|
|
345
|
+
else if (isString(err)) ErrorMessage({ text: `${message}: ${err}` });
|
|
346
|
+
else log.error(message, err);
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/utils/command.ts
|
|
351
|
+
const exit = (code) => process$1.exit(code);
|
|
352
|
+
const createHelpExample = (...commands) => {
|
|
353
|
+
return `
|
|
354
|
+
Example:
|
|
355
|
+
${commands.map((command) => ` $ ${command}`).join("\n")}
|
|
356
|
+
`;
|
|
357
|
+
};
|
|
358
|
+
const createCommand = (name) => {
|
|
359
|
+
const command = new Command(name);
|
|
360
|
+
command.allowExcessArguments();
|
|
361
|
+
command.allowUnknownOption();
|
|
362
|
+
return command;
|
|
363
|
+
};
|
|
364
|
+
const buildCommand = (command, dynamicParts = []) => {
|
|
365
|
+
return {
|
|
366
|
+
command,
|
|
367
|
+
parts: dynamicParts.filter((part) => !isEmpty(part)).map((part) => part?.toString())
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
const x = (command, args, options = {}) => {
|
|
371
|
+
return x$1(command, args, merge({
|
|
372
|
+
nodeOptions: {
|
|
373
|
+
cwd: process$1.cwd(),
|
|
374
|
+
FORCE_COLOR: "1"
|
|
375
|
+
},
|
|
376
|
+
throwOnError: true
|
|
377
|
+
}, options));
|
|
378
|
+
};
|
|
379
|
+
const zx = (baseCommand, dynamicParts = [], options = {}) => {
|
|
380
|
+
const { command, parts } = buildCommand(baseCommand, dynamicParts);
|
|
381
|
+
const { signal } = new AbortController();
|
|
382
|
+
try {
|
|
383
|
+
return (isEmpty(options) ? $ : $({
|
|
384
|
+
...options,
|
|
385
|
+
signal
|
|
386
|
+
}))`${command} ${parts}`;
|
|
387
|
+
} catch (error) {
|
|
388
|
+
handleError(error, `Failed to execute dynamic command: ${command}`);
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const checkCommand = async (_command) => {
|
|
393
|
+
try {
|
|
394
|
+
const a = await $`command -v git >/dev/null 2>&1`;
|
|
395
|
+
console.log("🚀 : checkCommand : a:", a);
|
|
396
|
+
const b = await x$1("command", [
|
|
397
|
+
"-v",
|
|
398
|
+
"git",
|
|
399
|
+
">/dev/null",
|
|
400
|
+
"2>&1"
|
|
401
|
+
]);
|
|
402
|
+
console.log("🚀 : checkCommand : b:", b);
|
|
403
|
+
const [error, result] = await xASync("command", [
|
|
404
|
+
"-v",
|
|
405
|
+
_command,
|
|
406
|
+
">/dev/null",
|
|
407
|
+
"2>&1"
|
|
408
|
+
]);
|
|
409
|
+
console.log("🚀 : checkCommand : result:", result);
|
|
410
|
+
if (error) return false;
|
|
411
|
+
return !!result.stdout;
|
|
412
|
+
} catch (error) {
|
|
413
|
+
console.log(error);
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const xASync = async (command, args, options) => {
|
|
418
|
+
try {
|
|
419
|
+
const result = await x$1(command, args, options);
|
|
420
|
+
if (result.exitCode) {
|
|
421
|
+
!options?.quiet && log.show(`Failed to execute command ${command}. Command exited with code ${result.exitCode}.`, { type: "error" });
|
|
422
|
+
!options?.quiet && log.show(result.stderr, { type: "error" });
|
|
423
|
+
return [new Error(result.stderr), null];
|
|
424
|
+
}
|
|
425
|
+
return [null, result];
|
|
426
|
+
} catch (error) {
|
|
427
|
+
handleError(error, `Failed to execute command ${command}.`);
|
|
428
|
+
return [isError(error) ? error : new Error(error), null];
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/utils/common.ts
|
|
434
|
+
const cached = (fn) => {
|
|
435
|
+
const map = /* @__PURE__ */ new Map();
|
|
436
|
+
return (content) => {
|
|
437
|
+
if (map.has(content)) return map.get(content);
|
|
438
|
+
const result = fn(content);
|
|
439
|
+
map.set(content, result);
|
|
440
|
+
return result;
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
const sleep = (millisecond, controller) => {
|
|
444
|
+
return new Promise((resolve$1, reject) => {
|
|
445
|
+
controller?.signal.addEventListener("abort", reject);
|
|
446
|
+
setTimeout(resolve$1, millisecond);
|
|
447
|
+
});
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
452
|
+
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
453
|
+
module.exports = {
|
|
454
|
+
"name": "dotenv",
|
|
455
|
+
"version": "17.2.3",
|
|
456
|
+
"description": "Loads environment variables from .env file",
|
|
457
|
+
"main": "lib/main.js",
|
|
458
|
+
"types": "lib/main.d.ts",
|
|
459
|
+
"exports": {
|
|
460
|
+
".": {
|
|
461
|
+
"types": "./lib/main.d.ts",
|
|
462
|
+
"require": "./lib/main.js",
|
|
463
|
+
"default": "./lib/main.js"
|
|
464
|
+
},
|
|
465
|
+
"./config": "./config.js",
|
|
466
|
+
"./config.js": "./config.js",
|
|
467
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
468
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
469
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
470
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
471
|
+
"./package.json": "./package.json"
|
|
472
|
+
},
|
|
473
|
+
"scripts": {
|
|
474
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
475
|
+
"lint": "standard",
|
|
476
|
+
"pretest": "npm run lint && npm run dts-check",
|
|
477
|
+
"test": "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
478
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
479
|
+
"prerelease": "npm test",
|
|
480
|
+
"release": "standard-version"
|
|
481
|
+
},
|
|
482
|
+
"repository": {
|
|
483
|
+
"type": "git",
|
|
484
|
+
"url": "git://github.com/motdotla/dotenv.git"
|
|
485
|
+
},
|
|
486
|
+
"homepage": "https://github.com/motdotla/dotenv#readme",
|
|
487
|
+
"funding": "https://dotenvx.com",
|
|
488
|
+
"keywords": [
|
|
489
|
+
"dotenv",
|
|
490
|
+
"env",
|
|
491
|
+
".env",
|
|
492
|
+
"environment",
|
|
493
|
+
"variables",
|
|
494
|
+
"config",
|
|
495
|
+
"settings"
|
|
496
|
+
],
|
|
497
|
+
"readmeFilename": "README.md",
|
|
498
|
+
"license": "BSD-2-Clause",
|
|
499
|
+
"devDependencies": {
|
|
500
|
+
"@types/node": "^18.11.3",
|
|
501
|
+
"decache": "^4.6.2",
|
|
502
|
+
"sinon": "^14.0.1",
|
|
503
|
+
"standard": "^17.0.0",
|
|
504
|
+
"standard-version": "^9.5.0",
|
|
505
|
+
"tap": "^19.2.0",
|
|
506
|
+
"typescript": "^4.8.4"
|
|
507
|
+
},
|
|
508
|
+
"engines": { "node": ">=12" },
|
|
509
|
+
"browser": { "fs": false }
|
|
510
|
+
};
|
|
511
|
+
}));
|
|
512
|
+
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
|
|
515
|
+
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
516
|
+
const fs$2 = __require("fs");
|
|
517
|
+
const path$13 = __require("path");
|
|
518
|
+
const os = __require("os");
|
|
519
|
+
const crypto = __require("crypto");
|
|
520
|
+
const version = require_package().version;
|
|
521
|
+
const TIPS = [
|
|
522
|
+
"🔐 encrypt with Dotenvx: https://dotenvx.com",
|
|
523
|
+
"🔐 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
524
|
+
"🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
525
|
+
"📡 add observability to secrets: https://dotenvx.com/ops",
|
|
526
|
+
"👥 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
527
|
+
"🗂️ backup and recover secrets: https://dotenvx.com/ops",
|
|
528
|
+
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
529
|
+
"🔄 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
530
|
+
"🔑 add access controls to secrets: https://dotenvx.com/ops",
|
|
531
|
+
"🛠️ run anywhere with `dotenvx run -- yourcommand`",
|
|
532
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
533
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
534
|
+
"⚙️ override existing env vars with { override: true }",
|
|
535
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
536
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
537
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
538
|
+
];
|
|
539
|
+
function _getRandomTip() {
|
|
540
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
541
|
+
}
|
|
542
|
+
function parseBoolean(value) {
|
|
543
|
+
if (typeof value === "string") return ![
|
|
544
|
+
"false",
|
|
545
|
+
"0",
|
|
546
|
+
"no",
|
|
547
|
+
"off",
|
|
548
|
+
""
|
|
549
|
+
].includes(value.toLowerCase());
|
|
550
|
+
return Boolean(value);
|
|
551
|
+
}
|
|
552
|
+
function supportsAnsi() {
|
|
553
|
+
return process.stdout.isTTY;
|
|
554
|
+
}
|
|
555
|
+
function dim(text$1) {
|
|
556
|
+
return supportsAnsi() ? `\x1b[2m${text$1}\x1b[0m` : text$1;
|
|
557
|
+
}
|
|
558
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
559
|
+
function parse(src) {
|
|
560
|
+
const obj = {};
|
|
561
|
+
let lines = src.toString();
|
|
562
|
+
lines = lines.replace(/\r\n?/gm, "\n");
|
|
563
|
+
let match;
|
|
564
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
565
|
+
const key = match[1];
|
|
566
|
+
let value = match[2] || "";
|
|
567
|
+
value = value.trim();
|
|
568
|
+
const maybeQuote = value[0];
|
|
569
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
570
|
+
if (maybeQuote === "\"") {
|
|
571
|
+
value = value.replace(/\\n/g, "\n");
|
|
572
|
+
value = value.replace(/\\r/g, "\r");
|
|
573
|
+
}
|
|
574
|
+
obj[key] = value;
|
|
575
|
+
}
|
|
576
|
+
return obj;
|
|
577
|
+
}
|
|
578
|
+
function _parseVault(options) {
|
|
579
|
+
options = options || {};
|
|
580
|
+
const vaultPath = _vaultPath(options);
|
|
581
|
+
options.path = vaultPath;
|
|
582
|
+
const result = DotenvModule.configDotenv(options);
|
|
583
|
+
if (!result.parsed) {
|
|
584
|
+
const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
585
|
+
err.code = "MISSING_DATA";
|
|
586
|
+
throw err;
|
|
587
|
+
}
|
|
588
|
+
const keys = _dotenvKey(options).split(",");
|
|
589
|
+
const length = keys.length;
|
|
590
|
+
let decrypted;
|
|
591
|
+
for (let i = 0; i < length; i++) try {
|
|
592
|
+
const attrs = _instructions(result, keys[i].trim());
|
|
593
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
594
|
+
break;
|
|
595
|
+
} catch (error) {
|
|
596
|
+
if (i + 1 >= length) throw error;
|
|
597
|
+
}
|
|
598
|
+
return DotenvModule.parse(decrypted);
|
|
599
|
+
}
|
|
600
|
+
function _warn(message) {
|
|
601
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
602
|
+
}
|
|
603
|
+
function _debug(message) {
|
|
604
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
605
|
+
}
|
|
606
|
+
function _log(message) {
|
|
607
|
+
console.log(`[dotenv@${version}] ${message}`);
|
|
608
|
+
}
|
|
609
|
+
function _dotenvKey(options) {
|
|
610
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
|
|
611
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
|
|
612
|
+
return "";
|
|
613
|
+
}
|
|
614
|
+
function _instructions(result, dotenvKey) {
|
|
615
|
+
let uri;
|
|
616
|
+
try {
|
|
617
|
+
uri = new URL(dotenvKey);
|
|
618
|
+
} catch (error) {
|
|
619
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
620
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
621
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
622
|
+
throw err;
|
|
623
|
+
}
|
|
624
|
+
throw error;
|
|
625
|
+
}
|
|
626
|
+
const key = uri.password;
|
|
627
|
+
if (!key) {
|
|
628
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
629
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
630
|
+
throw err;
|
|
631
|
+
}
|
|
632
|
+
const environment = uri.searchParams.get("environment");
|
|
633
|
+
if (!environment) {
|
|
634
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
635
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
636
|
+
throw err;
|
|
637
|
+
}
|
|
638
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
639
|
+
const ciphertext = result.parsed[environmentKey];
|
|
640
|
+
if (!ciphertext) {
|
|
641
|
+
const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
642
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
643
|
+
throw err;
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
ciphertext,
|
|
647
|
+
key
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
function _vaultPath(options) {
|
|
651
|
+
let possibleVaultPath = null;
|
|
652
|
+
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
|
|
653
|
+
for (const filepath of options.path) if (fs$2.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
654
|
+
} else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
655
|
+
else possibleVaultPath = path$13.resolve(process.cwd(), ".env.vault");
|
|
656
|
+
if (fs$2.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
657
|
+
return null;
|
|
658
|
+
}
|
|
659
|
+
function _resolveHome(envPath) {
|
|
660
|
+
return envPath[0] === "~" ? path$13.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
661
|
+
}
|
|
662
|
+
function _configVault(options) {
|
|
663
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
664
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
665
|
+
if (debug || !quiet) _log("Loading env from encrypted .env.vault");
|
|
666
|
+
const parsed = DotenvModule._parseVault(options);
|
|
667
|
+
let processEnv = process.env;
|
|
668
|
+
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
669
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
670
|
+
return { parsed };
|
|
671
|
+
}
|
|
672
|
+
function configDotenv(options) {
|
|
673
|
+
const dotenvPath = path$13.resolve(process.cwd(), ".env");
|
|
674
|
+
let encoding = "utf8";
|
|
675
|
+
let processEnv = process.env;
|
|
676
|
+
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
677
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
678
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
679
|
+
if (options && options.encoding) encoding = options.encoding;
|
|
680
|
+
else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
|
|
681
|
+
let optionPaths = [dotenvPath];
|
|
682
|
+
if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
|
|
683
|
+
else {
|
|
684
|
+
optionPaths = [];
|
|
685
|
+
for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
|
|
686
|
+
}
|
|
687
|
+
let lastError;
|
|
688
|
+
const parsedAll = {};
|
|
689
|
+
for (const path$14 of optionPaths) try {
|
|
690
|
+
const parsed = DotenvModule.parse(fs$2.readFileSync(path$14, { encoding }));
|
|
691
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
692
|
+
} catch (e) {
|
|
693
|
+
if (debug) _debug(`Failed to load ${path$14} ${e.message}`);
|
|
694
|
+
lastError = e;
|
|
695
|
+
}
|
|
696
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
697
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
698
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
699
|
+
if (debug || !quiet) {
|
|
700
|
+
const keysCount = Object.keys(populated).length;
|
|
701
|
+
const shortPaths = [];
|
|
702
|
+
for (const filePath of optionPaths) try {
|
|
703
|
+
const relative = path$13.relative(process.cwd(), filePath);
|
|
704
|
+
shortPaths.push(relative);
|
|
705
|
+
} catch (e) {
|
|
706
|
+
if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
|
|
707
|
+
lastError = e;
|
|
708
|
+
}
|
|
709
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
710
|
+
}
|
|
711
|
+
if (lastError) return {
|
|
712
|
+
parsed: parsedAll,
|
|
713
|
+
error: lastError
|
|
714
|
+
};
|
|
715
|
+
else return { parsed: parsedAll };
|
|
716
|
+
}
|
|
717
|
+
function config(options) {
|
|
718
|
+
if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
|
|
719
|
+
const vaultPath = _vaultPath(options);
|
|
720
|
+
if (!vaultPath) {
|
|
721
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
722
|
+
return DotenvModule.configDotenv(options);
|
|
723
|
+
}
|
|
724
|
+
return DotenvModule._configVault(options);
|
|
725
|
+
}
|
|
726
|
+
function decrypt(encrypted, keyStr) {
|
|
727
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
728
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
729
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
730
|
+
const authTag = ciphertext.subarray(-16);
|
|
731
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
732
|
+
try {
|
|
733
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
734
|
+
aesgcm.setAuthTag(authTag);
|
|
735
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
736
|
+
} catch (error) {
|
|
737
|
+
const isRange = error instanceof RangeError;
|
|
738
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
739
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
740
|
+
if (isRange || invalidKeyLength) {
|
|
741
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
742
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
743
|
+
throw err;
|
|
744
|
+
} else if (decryptionFailed) {
|
|
745
|
+
const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
746
|
+
err.code = "DECRYPTION_FAILED";
|
|
747
|
+
throw err;
|
|
748
|
+
} else throw error;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function populate(processEnv, parsed, options = {}) {
|
|
752
|
+
const debug = Boolean(options && options.debug);
|
|
753
|
+
const override = Boolean(options && options.override);
|
|
754
|
+
const populated = {};
|
|
755
|
+
if (typeof parsed !== "object") {
|
|
756
|
+
const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
757
|
+
err.code = "OBJECT_REQUIRED";
|
|
758
|
+
throw err;
|
|
759
|
+
}
|
|
760
|
+
for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
761
|
+
if (override === true) {
|
|
762
|
+
processEnv[key] = parsed[key];
|
|
763
|
+
populated[key] = parsed[key];
|
|
764
|
+
}
|
|
765
|
+
if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
|
|
766
|
+
else _debug(`"${key}" is already defined and was NOT overwritten`);
|
|
767
|
+
} else {
|
|
768
|
+
processEnv[key] = parsed[key];
|
|
769
|
+
populated[key] = parsed[key];
|
|
770
|
+
}
|
|
771
|
+
return populated;
|
|
772
|
+
}
|
|
773
|
+
const DotenvModule = {
|
|
774
|
+
configDotenv,
|
|
775
|
+
_configVault,
|
|
776
|
+
_parseVault,
|
|
777
|
+
config,
|
|
778
|
+
decrypt,
|
|
779
|
+
parse,
|
|
780
|
+
populate
|
|
781
|
+
};
|
|
782
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
783
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
784
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
785
|
+
module.exports.config = DotenvModule.config;
|
|
786
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
787
|
+
module.exports.parse = DotenvModule.parse;
|
|
788
|
+
module.exports.populate = DotenvModule.populate;
|
|
789
|
+
module.exports = DotenvModule;
|
|
790
|
+
}));
|
|
791
|
+
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/utils/config.ts
|
|
794
|
+
var import_main = require_main();
|
|
795
|
+
const configRootPath = path.resolve(homedir(), CONFIG_NAME);
|
|
796
|
+
const loadEnv = (importMeta, ...paths) => {
|
|
797
|
+
const providedPath = path.resolve(dirname(importMeta), ...paths);
|
|
798
|
+
if (existsSync(providedPath)) {
|
|
799
|
+
(0, import_main.config)({
|
|
800
|
+
path: providedPath,
|
|
801
|
+
quiet: true
|
|
802
|
+
});
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
throw new Error(`Environment file not found at ${providedPath}`);
|
|
806
|
+
};
|
|
807
|
+
const createStore = (name, options) => {
|
|
808
|
+
if (!options.path) throw Error("Store subpath is necessary!");
|
|
809
|
+
const configPath = path.resolve(configRootPath, options.path);
|
|
810
|
+
const store = new Configstore(name, options.default ?? {}, { configPath });
|
|
811
|
+
log.verbose("store created success", store.path);
|
|
812
|
+
return store;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/utils/env.ts
|
|
817
|
+
const isDebug = () => process.argv.includes("-d") || process.argv.includes("--debug");
|
|
818
|
+
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region src/utils/format.ts
|
|
821
|
+
const CHINESE_STRING_REGEXP = /[\u4e00-\u9fa5]/;
|
|
822
|
+
const isChinese = (text$1) => CHINESE_STRING_REGEXP.test(text$1);
|
|
823
|
+
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/utils/git-handle/index.ts
|
|
826
|
+
const require$1 = createRequire(import.meta.url);
|
|
827
|
+
const currentBranchPrefix = /^\* /;
|
|
828
|
+
const formatBranch = (branch) => branch?.trim().replace(currentBranchPrefix, "");
|
|
829
|
+
const getCurrentBranch = async () => {
|
|
830
|
+
const [error, result] = await xASync("git", ["branch", "--show-current"]);
|
|
831
|
+
if (error) return "";
|
|
832
|
+
return result.stdout.trim();
|
|
833
|
+
};
|
|
834
|
+
const getLocalBranches = async () => {
|
|
835
|
+
const list = (await x("git", ["branch"])).stdout.split("\n");
|
|
836
|
+
const currentBranch = list.find((line) => line.includes("*"));
|
|
837
|
+
return {
|
|
838
|
+
branches: list.filter((line) => line.trim() && !line.includes("->")).map((line) => line.trim().replace(currentBranchPrefix, "")),
|
|
839
|
+
currentBranch: formatBranch(currentBranch)
|
|
840
|
+
};
|
|
841
|
+
};
|
|
842
|
+
const getDiffFiles = async () => {
|
|
843
|
+
return (await x("git", [
|
|
844
|
+
"diff",
|
|
845
|
+
"HEAD",
|
|
846
|
+
"origin/main",
|
|
847
|
+
"--name-only"
|
|
848
|
+
])).stdout.split("\n").filter((line) => line.trim() !== "");
|
|
849
|
+
};
|
|
850
|
+
const getGitStatus = async () => {
|
|
851
|
+
const lines = (await x("git", ["status", "--porcelain"])).stdout.split("\n").filter((line) => line.trim() !== "");
|
|
852
|
+
const staged = [];
|
|
853
|
+
const modified = [];
|
|
854
|
+
const untracked = [];
|
|
855
|
+
for (const line of lines) {
|
|
856
|
+
const indexStatus = line[0];
|
|
857
|
+
const workingStatus = line[1];
|
|
858
|
+
const fileName = line.slice(3);
|
|
859
|
+
if (indexStatus !== " " && indexStatus !== "?") staged.push(fileName);
|
|
860
|
+
if (workingStatus === "M" || workingStatus === "D") modified.push(fileName);
|
|
861
|
+
if (indexStatus === "?" && workingStatus === "?") untracked.push(fileName);
|
|
862
|
+
}
|
|
863
|
+
return {
|
|
864
|
+
staged,
|
|
865
|
+
modified,
|
|
866
|
+
untracked,
|
|
867
|
+
unstaged: [...modified, ...untracked]
|
|
868
|
+
};
|
|
869
|
+
};
|
|
870
|
+
const addFiles = async (files) => {
|
|
871
|
+
if (files.length === 0) return;
|
|
872
|
+
return await x("git", ["add", ...files]);
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region ../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js
|
|
877
|
+
var require_universalify = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
878
|
+
exports.fromCallback = function(fn) {
|
|
879
|
+
return Object.defineProperty(function(...args) {
|
|
880
|
+
if (typeof args[args.length - 1] === "function") fn.apply(this, args);
|
|
881
|
+
else return new Promise((resolve$1, reject) => {
|
|
882
|
+
args.push((err, res) => err != null ? reject(err) : resolve$1(res));
|
|
883
|
+
fn.apply(this, args);
|
|
884
|
+
});
|
|
885
|
+
}, "name", { value: fn.name });
|
|
886
|
+
};
|
|
887
|
+
exports.fromPromise = function(fn) {
|
|
888
|
+
return Object.defineProperty(function(...args) {
|
|
889
|
+
const cb = args[args.length - 1];
|
|
890
|
+
if (typeof cb !== "function") return fn.apply(this, args);
|
|
891
|
+
else {
|
|
892
|
+
args.pop();
|
|
893
|
+
fn.apply(this, args).then((r) => cb(null, r), cb);
|
|
894
|
+
}
|
|
895
|
+
}, "name", { value: fn.name });
|
|
896
|
+
};
|
|
897
|
+
}));
|
|
898
|
+
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
|
|
901
|
+
var require_polyfills = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
902
|
+
var constants = __require("constants");
|
|
903
|
+
var origCwd = process.cwd;
|
|
904
|
+
var cwd = null;
|
|
905
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
906
|
+
process.cwd = function() {
|
|
907
|
+
if (!cwd) cwd = origCwd.call(process);
|
|
908
|
+
return cwd;
|
|
909
|
+
};
|
|
910
|
+
try {
|
|
911
|
+
process.cwd();
|
|
912
|
+
} catch (er) {}
|
|
913
|
+
if (typeof process.chdir === "function") {
|
|
914
|
+
var chdir = process.chdir;
|
|
915
|
+
process.chdir = function(d) {
|
|
916
|
+
cwd = null;
|
|
917
|
+
chdir.call(process, d);
|
|
918
|
+
};
|
|
919
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
920
|
+
}
|
|
921
|
+
module.exports = patch;
|
|
922
|
+
function patch(fs$3) {
|
|
923
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(fs$3);
|
|
924
|
+
if (!fs$3.lutimes) patchLutimes(fs$3);
|
|
925
|
+
fs$3.chown = chownFix(fs$3.chown);
|
|
926
|
+
fs$3.fchown = chownFix(fs$3.fchown);
|
|
927
|
+
fs$3.lchown = chownFix(fs$3.lchown);
|
|
928
|
+
fs$3.chmod = chmodFix(fs$3.chmod);
|
|
929
|
+
fs$3.fchmod = chmodFix(fs$3.fchmod);
|
|
930
|
+
fs$3.lchmod = chmodFix(fs$3.lchmod);
|
|
931
|
+
fs$3.chownSync = chownFixSync(fs$3.chownSync);
|
|
932
|
+
fs$3.fchownSync = chownFixSync(fs$3.fchownSync);
|
|
933
|
+
fs$3.lchownSync = chownFixSync(fs$3.lchownSync);
|
|
934
|
+
fs$3.chmodSync = chmodFixSync(fs$3.chmodSync);
|
|
935
|
+
fs$3.fchmodSync = chmodFixSync(fs$3.fchmodSync);
|
|
936
|
+
fs$3.lchmodSync = chmodFixSync(fs$3.lchmodSync);
|
|
937
|
+
fs$3.stat = statFix(fs$3.stat);
|
|
938
|
+
fs$3.fstat = statFix(fs$3.fstat);
|
|
939
|
+
fs$3.lstat = statFix(fs$3.lstat);
|
|
940
|
+
fs$3.statSync = statFixSync(fs$3.statSync);
|
|
941
|
+
fs$3.fstatSync = statFixSync(fs$3.fstatSync);
|
|
942
|
+
fs$3.lstatSync = statFixSync(fs$3.lstatSync);
|
|
943
|
+
if (fs$3.chmod && !fs$3.lchmod) {
|
|
944
|
+
fs$3.lchmod = function(path$14, mode, cb) {
|
|
945
|
+
if (cb) process.nextTick(cb);
|
|
946
|
+
};
|
|
947
|
+
fs$3.lchmodSync = function() {};
|
|
948
|
+
}
|
|
949
|
+
if (fs$3.chown && !fs$3.lchown) {
|
|
950
|
+
fs$3.lchown = function(path$14, uid, gid, cb) {
|
|
951
|
+
if (cb) process.nextTick(cb);
|
|
952
|
+
};
|
|
953
|
+
fs$3.lchownSync = function() {};
|
|
954
|
+
}
|
|
955
|
+
if (platform === "win32") fs$3.rename = typeof fs$3.rename !== "function" ? fs$3.rename : (function(fs$rename) {
|
|
956
|
+
function rename(from, to, cb) {
|
|
957
|
+
var start = Date.now();
|
|
958
|
+
var backoff = 0;
|
|
959
|
+
fs$rename(from, to, function CB(er) {
|
|
960
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
961
|
+
setTimeout(function() {
|
|
962
|
+
fs$3.stat(to, function(stater, st) {
|
|
963
|
+
if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
|
|
964
|
+
else cb(er);
|
|
965
|
+
});
|
|
966
|
+
}, backoff);
|
|
967
|
+
if (backoff < 100) backoff += 10;
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
if (cb) cb(er);
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
974
|
+
return rename;
|
|
975
|
+
})(fs$3.rename);
|
|
976
|
+
fs$3.read = typeof fs$3.read !== "function" ? fs$3.read : (function(fs$read) {
|
|
977
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
978
|
+
var callback;
|
|
979
|
+
if (callback_ && typeof callback_ === "function") {
|
|
980
|
+
var eagCounter = 0;
|
|
981
|
+
callback = function(er, _, __) {
|
|
982
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
983
|
+
eagCounter++;
|
|
984
|
+
return fs$read.call(fs$3, fd, buffer, offset, length, position, callback);
|
|
985
|
+
}
|
|
986
|
+
callback_.apply(this, arguments);
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
return fs$read.call(fs$3, fd, buffer, offset, length, position, callback);
|
|
990
|
+
}
|
|
991
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
992
|
+
return read;
|
|
993
|
+
})(fs$3.read);
|
|
994
|
+
fs$3.readSync = typeof fs$3.readSync !== "function" ? fs$3.readSync : (function(fs$readSync) {
|
|
995
|
+
return function(fd, buffer, offset, length, position) {
|
|
996
|
+
var eagCounter = 0;
|
|
997
|
+
while (true) try {
|
|
998
|
+
return fs$readSync.call(fs$3, fd, buffer, offset, length, position);
|
|
999
|
+
} catch (er) {
|
|
1000
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
1001
|
+
eagCounter++;
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
throw er;
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
})(fs$3.readSync);
|
|
1008
|
+
function patchLchmod(fs$4) {
|
|
1009
|
+
fs$4.lchmod = function(path$14, mode, callback) {
|
|
1010
|
+
fs$4.open(path$14, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
1011
|
+
if (err) {
|
|
1012
|
+
if (callback) callback(err);
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
fs$4.fchmod(fd, mode, function(err$1) {
|
|
1016
|
+
fs$4.close(fd, function(err2) {
|
|
1017
|
+
if (callback) callback(err$1 || err2);
|
|
1018
|
+
});
|
|
1019
|
+
});
|
|
1020
|
+
});
|
|
1021
|
+
};
|
|
1022
|
+
fs$4.lchmodSync = function(path$14, mode) {
|
|
1023
|
+
var fd = fs$4.openSync(path$14, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
1024
|
+
var threw = true;
|
|
1025
|
+
var ret;
|
|
1026
|
+
try {
|
|
1027
|
+
ret = fs$4.fchmodSync(fd, mode);
|
|
1028
|
+
threw = false;
|
|
1029
|
+
} finally {
|
|
1030
|
+
if (threw) try {
|
|
1031
|
+
fs$4.closeSync(fd);
|
|
1032
|
+
} catch (er) {}
|
|
1033
|
+
else fs$4.closeSync(fd);
|
|
1034
|
+
}
|
|
1035
|
+
return ret;
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
function patchLutimes(fs$4) {
|
|
1039
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs$4.futimes) {
|
|
1040
|
+
fs$4.lutimes = function(path$14, at, mt, cb) {
|
|
1041
|
+
fs$4.open(path$14, constants.O_SYMLINK, function(er, fd) {
|
|
1042
|
+
if (er) {
|
|
1043
|
+
if (cb) cb(er);
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
fs$4.futimes(fd, at, mt, function(er$1) {
|
|
1047
|
+
fs$4.close(fd, function(er2) {
|
|
1048
|
+
if (cb) cb(er$1 || er2);
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
1051
|
+
});
|
|
1052
|
+
};
|
|
1053
|
+
fs$4.lutimesSync = function(path$14, at, mt) {
|
|
1054
|
+
var fd = fs$4.openSync(path$14, constants.O_SYMLINK);
|
|
1055
|
+
var ret;
|
|
1056
|
+
var threw = true;
|
|
1057
|
+
try {
|
|
1058
|
+
ret = fs$4.futimesSync(fd, at, mt);
|
|
1059
|
+
threw = false;
|
|
1060
|
+
} finally {
|
|
1061
|
+
if (threw) try {
|
|
1062
|
+
fs$4.closeSync(fd);
|
|
1063
|
+
} catch (er) {}
|
|
1064
|
+
else fs$4.closeSync(fd);
|
|
1065
|
+
}
|
|
1066
|
+
return ret;
|
|
1067
|
+
};
|
|
1068
|
+
} else if (fs$4.futimes) {
|
|
1069
|
+
fs$4.lutimes = function(_a, _b, _c, cb) {
|
|
1070
|
+
if (cb) process.nextTick(cb);
|
|
1071
|
+
};
|
|
1072
|
+
fs$4.lutimesSync = function() {};
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
function chmodFix(orig) {
|
|
1076
|
+
if (!orig) return orig;
|
|
1077
|
+
return function(target, mode, cb) {
|
|
1078
|
+
return orig.call(fs$3, target, mode, function(er) {
|
|
1079
|
+
if (chownErOk(er)) er = null;
|
|
1080
|
+
if (cb) cb.apply(this, arguments);
|
|
1081
|
+
});
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
function chmodFixSync(orig) {
|
|
1085
|
+
if (!orig) return orig;
|
|
1086
|
+
return function(target, mode) {
|
|
1087
|
+
try {
|
|
1088
|
+
return orig.call(fs$3, target, mode);
|
|
1089
|
+
} catch (er) {
|
|
1090
|
+
if (!chownErOk(er)) throw er;
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function chownFix(orig) {
|
|
1095
|
+
if (!orig) return orig;
|
|
1096
|
+
return function(target, uid, gid, cb) {
|
|
1097
|
+
return orig.call(fs$3, target, uid, gid, function(er) {
|
|
1098
|
+
if (chownErOk(er)) er = null;
|
|
1099
|
+
if (cb) cb.apply(this, arguments);
|
|
1100
|
+
});
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
function chownFixSync(orig) {
|
|
1104
|
+
if (!orig) return orig;
|
|
1105
|
+
return function(target, uid, gid) {
|
|
1106
|
+
try {
|
|
1107
|
+
return orig.call(fs$3, target, uid, gid);
|
|
1108
|
+
} catch (er) {
|
|
1109
|
+
if (!chownErOk(er)) throw er;
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
function statFix(orig) {
|
|
1114
|
+
if (!orig) return orig;
|
|
1115
|
+
return function(target, options, cb) {
|
|
1116
|
+
if (typeof options === "function") {
|
|
1117
|
+
cb = options;
|
|
1118
|
+
options = null;
|
|
1119
|
+
}
|
|
1120
|
+
function callback(er, stats) {
|
|
1121
|
+
if (stats) {
|
|
1122
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
1123
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
1124
|
+
}
|
|
1125
|
+
if (cb) cb.apply(this, arguments);
|
|
1126
|
+
}
|
|
1127
|
+
return options ? orig.call(fs$3, target, options, callback) : orig.call(fs$3, target, callback);
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
function statFixSync(orig) {
|
|
1131
|
+
if (!orig) return orig;
|
|
1132
|
+
return function(target, options) {
|
|
1133
|
+
var stats = options ? orig.call(fs$3, target, options) : orig.call(fs$3, target);
|
|
1134
|
+
if (stats) {
|
|
1135
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
1136
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
1137
|
+
}
|
|
1138
|
+
return stats;
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
function chownErOk(er) {
|
|
1142
|
+
if (!er) return true;
|
|
1143
|
+
if (er.code === "ENOSYS") return true;
|
|
1144
|
+
if (!process.getuid || process.getuid() !== 0) {
|
|
1145
|
+
if (er.code === "EINVAL" || er.code === "EPERM") return true;
|
|
1146
|
+
}
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}));
|
|
1151
|
+
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
|
|
1154
|
+
var require_legacy_streams = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1155
|
+
var Stream = __require("stream").Stream;
|
|
1156
|
+
module.exports = legacy;
|
|
1157
|
+
function legacy(fs$3) {
|
|
1158
|
+
return {
|
|
1159
|
+
ReadStream,
|
|
1160
|
+
WriteStream
|
|
1161
|
+
};
|
|
1162
|
+
function ReadStream(path$14, options) {
|
|
1163
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path$14, options);
|
|
1164
|
+
Stream.call(this);
|
|
1165
|
+
var self = this;
|
|
1166
|
+
this.path = path$14;
|
|
1167
|
+
this.fd = null;
|
|
1168
|
+
this.readable = true;
|
|
1169
|
+
this.paused = false;
|
|
1170
|
+
this.flags = "r";
|
|
1171
|
+
this.mode = 438;
|
|
1172
|
+
this.bufferSize = 64 * 1024;
|
|
1173
|
+
options = options || {};
|
|
1174
|
+
var keys = Object.keys(options);
|
|
1175
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
1176
|
+
var key = keys[index];
|
|
1177
|
+
this[key] = options[key];
|
|
1178
|
+
}
|
|
1179
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
1180
|
+
if (this.start !== void 0) {
|
|
1181
|
+
if ("number" !== typeof this.start) throw TypeError("start must be a Number");
|
|
1182
|
+
if (this.end === void 0) this.end = Infinity;
|
|
1183
|
+
else if ("number" !== typeof this.end) throw TypeError("end must be a Number");
|
|
1184
|
+
if (this.start > this.end) throw new Error("start must be <= end");
|
|
1185
|
+
this.pos = this.start;
|
|
1186
|
+
}
|
|
1187
|
+
if (this.fd !== null) {
|
|
1188
|
+
process.nextTick(function() {
|
|
1189
|
+
self._read();
|
|
1190
|
+
});
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
fs$3.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
1194
|
+
if (err) {
|
|
1195
|
+
self.emit("error", err);
|
|
1196
|
+
self.readable = false;
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
self.fd = fd;
|
|
1200
|
+
self.emit("open", fd);
|
|
1201
|
+
self._read();
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
function WriteStream(path$14, options) {
|
|
1205
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path$14, options);
|
|
1206
|
+
Stream.call(this);
|
|
1207
|
+
this.path = path$14;
|
|
1208
|
+
this.fd = null;
|
|
1209
|
+
this.writable = true;
|
|
1210
|
+
this.flags = "w";
|
|
1211
|
+
this.encoding = "binary";
|
|
1212
|
+
this.mode = 438;
|
|
1213
|
+
this.bytesWritten = 0;
|
|
1214
|
+
options = options || {};
|
|
1215
|
+
var keys = Object.keys(options);
|
|
1216
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
1217
|
+
var key = keys[index];
|
|
1218
|
+
this[key] = options[key];
|
|
1219
|
+
}
|
|
1220
|
+
if (this.start !== void 0) {
|
|
1221
|
+
if ("number" !== typeof this.start) throw TypeError("start must be a Number");
|
|
1222
|
+
if (this.start < 0) throw new Error("start must be >= zero");
|
|
1223
|
+
this.pos = this.start;
|
|
1224
|
+
}
|
|
1225
|
+
this.busy = false;
|
|
1226
|
+
this._queue = [];
|
|
1227
|
+
if (this.fd === null) {
|
|
1228
|
+
this._open = fs$3.open;
|
|
1229
|
+
this._queue.push([
|
|
1230
|
+
this._open,
|
|
1231
|
+
this.path,
|
|
1232
|
+
this.flags,
|
|
1233
|
+
this.mode,
|
|
1234
|
+
void 0
|
|
1235
|
+
]);
|
|
1236
|
+
this.flush();
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}));
|
|
1241
|
+
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
|
|
1244
|
+
var require_clone = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1245
|
+
module.exports = clone;
|
|
1246
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
1247
|
+
return obj.__proto__;
|
|
1248
|
+
};
|
|
1249
|
+
function clone(obj) {
|
|
1250
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
1251
|
+
if (obj instanceof Object) var copy$1 = { __proto__: getPrototypeOf(obj) };
|
|
1252
|
+
else var copy$1 = Object.create(null);
|
|
1253
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
1254
|
+
Object.defineProperty(copy$1, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
1255
|
+
});
|
|
1256
|
+
return copy$1;
|
|
1257
|
+
}
|
|
1258
|
+
}));
|
|
1259
|
+
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
|
|
1262
|
+
var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1263
|
+
var fs$1 = __require("fs");
|
|
1264
|
+
var polyfills = require_polyfills();
|
|
1265
|
+
var legacy = require_legacy_streams();
|
|
1266
|
+
var clone = require_clone();
|
|
1267
|
+
var util = __require("util");
|
|
1268
|
+
/* istanbul ignore next - node 0.x polyfill */
|
|
1269
|
+
var gracefulQueue;
|
|
1270
|
+
var previousSymbol;
|
|
1271
|
+
/* istanbul ignore else - node 0.x polyfill */
|
|
1272
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
1273
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
1274
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
1275
|
+
} else {
|
|
1276
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
1277
|
+
previousSymbol = "___graceful-fs.previous";
|
|
1278
|
+
}
|
|
1279
|
+
function noop() {}
|
|
1280
|
+
function publishQueue(context, queue) {
|
|
1281
|
+
Object.defineProperty(context, gracefulQueue, { get: function() {
|
|
1282
|
+
return queue;
|
|
1283
|
+
} });
|
|
1284
|
+
}
|
|
1285
|
+
var debug = noop;
|
|
1286
|
+
if (util.debuglog) debug = util.debuglog("gfs4");
|
|
1287
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() {
|
|
1288
|
+
var m = util.format.apply(util, arguments);
|
|
1289
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
1290
|
+
console.error(m);
|
|
1291
|
+
};
|
|
1292
|
+
if (!fs$1[gracefulQueue]) {
|
|
1293
|
+
publishQueue(fs$1, global[gracefulQueue] || []);
|
|
1294
|
+
fs$1.close = (function(fs$close) {
|
|
1295
|
+
function close(fd, cb) {
|
|
1296
|
+
return fs$close.call(fs$1, fd, function(err) {
|
|
1297
|
+
if (!err) resetQueue();
|
|
1298
|
+
if (typeof cb === "function") cb.apply(this, arguments);
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
Object.defineProperty(close, previousSymbol, { value: fs$close });
|
|
1302
|
+
return close;
|
|
1303
|
+
})(fs$1.close);
|
|
1304
|
+
fs$1.closeSync = (function(fs$closeSync) {
|
|
1305
|
+
function closeSync(fd) {
|
|
1306
|
+
fs$closeSync.apply(fs$1, arguments);
|
|
1307
|
+
resetQueue();
|
|
1308
|
+
}
|
|
1309
|
+
Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
|
|
1310
|
+
return closeSync;
|
|
1311
|
+
})(fs$1.closeSync);
|
|
1312
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
|
|
1313
|
+
debug(fs$1[gracefulQueue]);
|
|
1314
|
+
__require("assert").equal(fs$1[gracefulQueue].length, 0);
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
if (!global[gracefulQueue]) publishQueue(global, fs$1[gracefulQueue]);
|
|
1318
|
+
module.exports = patch(clone(fs$1));
|
|
1319
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$1.__patched) {
|
|
1320
|
+
module.exports = patch(fs$1);
|
|
1321
|
+
fs$1.__patched = true;
|
|
1322
|
+
}
|
|
1323
|
+
function patch(fs$3) {
|
|
1324
|
+
polyfills(fs$3);
|
|
1325
|
+
fs$3.gracefulify = patch;
|
|
1326
|
+
fs$3.createReadStream = createReadStream;
|
|
1327
|
+
fs$3.createWriteStream = createWriteStream;
|
|
1328
|
+
var fs$readFile = fs$3.readFile;
|
|
1329
|
+
fs$3.readFile = readFile$1;
|
|
1330
|
+
function readFile$1(path$14, options, cb) {
|
|
1331
|
+
if (typeof options === "function") cb = options, options = null;
|
|
1332
|
+
return go$readFile(path$14, options, cb);
|
|
1333
|
+
function go$readFile(path$15, options$1, cb$1, startTime) {
|
|
1334
|
+
return fs$readFile(path$15, options$1, function(err) {
|
|
1335
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
1336
|
+
go$readFile,
|
|
1337
|
+
[
|
|
1338
|
+
path$15,
|
|
1339
|
+
options$1,
|
|
1340
|
+
cb$1
|
|
1341
|
+
],
|
|
1342
|
+
err,
|
|
1343
|
+
startTime || Date.now(),
|
|
1344
|
+
Date.now()
|
|
1345
|
+
]);
|
|
1346
|
+
else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
var fs$writeFile = fs$3.writeFile;
|
|
1351
|
+
fs$3.writeFile = writeFile;
|
|
1352
|
+
function writeFile(path$14, data, options, cb) {
|
|
1353
|
+
if (typeof options === "function") cb = options, options = null;
|
|
1354
|
+
return go$writeFile(path$14, data, options, cb);
|
|
1355
|
+
function go$writeFile(path$15, data$1, options$1, cb$1, startTime) {
|
|
1356
|
+
return fs$writeFile(path$15, data$1, options$1, function(err) {
|
|
1357
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
1358
|
+
go$writeFile,
|
|
1359
|
+
[
|
|
1360
|
+
path$15,
|
|
1361
|
+
data$1,
|
|
1362
|
+
options$1,
|
|
1363
|
+
cb$1
|
|
1364
|
+
],
|
|
1365
|
+
err,
|
|
1366
|
+
startTime || Date.now(),
|
|
1367
|
+
Date.now()
|
|
1368
|
+
]);
|
|
1369
|
+
else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
var fs$appendFile = fs$3.appendFile;
|
|
1374
|
+
if (fs$appendFile) fs$3.appendFile = appendFile;
|
|
1375
|
+
function appendFile(path$14, data, options, cb) {
|
|
1376
|
+
if (typeof options === "function") cb = options, options = null;
|
|
1377
|
+
return go$appendFile(path$14, data, options, cb);
|
|
1378
|
+
function go$appendFile(path$15, data$1, options$1, cb$1, startTime) {
|
|
1379
|
+
return fs$appendFile(path$15, data$1, options$1, function(err) {
|
|
1380
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
1381
|
+
go$appendFile,
|
|
1382
|
+
[
|
|
1383
|
+
path$15,
|
|
1384
|
+
data$1,
|
|
1385
|
+
options$1,
|
|
1386
|
+
cb$1
|
|
1387
|
+
],
|
|
1388
|
+
err,
|
|
1389
|
+
startTime || Date.now(),
|
|
1390
|
+
Date.now()
|
|
1391
|
+
]);
|
|
1392
|
+
else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
var fs$copyFile = fs$3.copyFile;
|
|
1397
|
+
if (fs$copyFile) fs$3.copyFile = copyFile$1;
|
|
1398
|
+
function copyFile$1(src, dest, flags, cb) {
|
|
1399
|
+
if (typeof flags === "function") {
|
|
1400
|
+
cb = flags;
|
|
1401
|
+
flags = 0;
|
|
1402
|
+
}
|
|
1403
|
+
return go$copyFile(src, dest, flags, cb);
|
|
1404
|
+
function go$copyFile(src$1, dest$1, flags$1, cb$1, startTime) {
|
|
1405
|
+
return fs$copyFile(src$1, dest$1, flags$1, function(err) {
|
|
1406
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
1407
|
+
go$copyFile,
|
|
1408
|
+
[
|
|
1409
|
+
src$1,
|
|
1410
|
+
dest$1,
|
|
1411
|
+
flags$1,
|
|
1412
|
+
cb$1
|
|
1413
|
+
],
|
|
1414
|
+
err,
|
|
1415
|
+
startTime || Date.now(),
|
|
1416
|
+
Date.now()
|
|
1417
|
+
]);
|
|
1418
|
+
else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
var fs$readdir = fs$3.readdir;
|
|
1423
|
+
fs$3.readdir = readdir;
|
|
1424
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
1425
|
+
function readdir(path$14, options, cb) {
|
|
1426
|
+
if (typeof options === "function") cb = options, options = null;
|
|
1427
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir$1(path$15, options$1, cb$1, startTime) {
|
|
1428
|
+
return fs$readdir(path$15, fs$readdirCallback(path$15, options$1, cb$1, startTime));
|
|
1429
|
+
} : function go$readdir$1(path$15, options$1, cb$1, startTime) {
|
|
1430
|
+
return fs$readdir(path$15, options$1, fs$readdirCallback(path$15, options$1, cb$1, startTime));
|
|
1431
|
+
};
|
|
1432
|
+
return go$readdir(path$14, options, cb);
|
|
1433
|
+
function fs$readdirCallback(path$15, options$1, cb$1, startTime) {
|
|
1434
|
+
return function(err, files) {
|
|
1435
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
1436
|
+
go$readdir,
|
|
1437
|
+
[
|
|
1438
|
+
path$15,
|
|
1439
|
+
options$1,
|
|
1440
|
+
cb$1
|
|
1441
|
+
],
|
|
1442
|
+
err,
|
|
1443
|
+
startTime || Date.now(),
|
|
1444
|
+
Date.now()
|
|
1445
|
+
]);
|
|
1446
|
+
else {
|
|
1447
|
+
if (files && files.sort) files.sort();
|
|
1448
|
+
if (typeof cb$1 === "function") cb$1.call(this, err, files);
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
1454
|
+
var legStreams = legacy(fs$3);
|
|
1455
|
+
ReadStream = legStreams.ReadStream;
|
|
1456
|
+
WriteStream = legStreams.WriteStream;
|
|
1457
|
+
}
|
|
1458
|
+
var fs$ReadStream = fs$3.ReadStream;
|
|
1459
|
+
if (fs$ReadStream) {
|
|
1460
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
1461
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
1462
|
+
}
|
|
1463
|
+
var fs$WriteStream = fs$3.WriteStream;
|
|
1464
|
+
if (fs$WriteStream) {
|
|
1465
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
1466
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
1467
|
+
}
|
|
1468
|
+
Object.defineProperty(fs$3, "ReadStream", {
|
|
1469
|
+
get: function() {
|
|
1470
|
+
return ReadStream;
|
|
1471
|
+
},
|
|
1472
|
+
set: function(val) {
|
|
1473
|
+
ReadStream = val;
|
|
1474
|
+
},
|
|
1475
|
+
enumerable: true,
|
|
1476
|
+
configurable: true
|
|
1477
|
+
});
|
|
1478
|
+
Object.defineProperty(fs$3, "WriteStream", {
|
|
1479
|
+
get: function() {
|
|
1480
|
+
return WriteStream;
|
|
1481
|
+
},
|
|
1482
|
+
set: function(val) {
|
|
1483
|
+
WriteStream = val;
|
|
1484
|
+
},
|
|
1485
|
+
enumerable: true,
|
|
1486
|
+
configurable: true
|
|
1487
|
+
});
|
|
1488
|
+
var FileReadStream = ReadStream;
|
|
1489
|
+
Object.defineProperty(fs$3, "FileReadStream", {
|
|
1490
|
+
get: function() {
|
|
1491
|
+
return FileReadStream;
|
|
1492
|
+
},
|
|
1493
|
+
set: function(val) {
|
|
1494
|
+
FileReadStream = val;
|
|
1495
|
+
},
|
|
1496
|
+
enumerable: true,
|
|
1497
|
+
configurable: true
|
|
1498
|
+
});
|
|
1499
|
+
var FileWriteStream = WriteStream;
|
|
1500
|
+
Object.defineProperty(fs$3, "FileWriteStream", {
|
|
1501
|
+
get: function() {
|
|
1502
|
+
return FileWriteStream;
|
|
1503
|
+
},
|
|
1504
|
+
set: function(val) {
|
|
1505
|
+
FileWriteStream = val;
|
|
1506
|
+
},
|
|
1507
|
+
enumerable: true,
|
|
1508
|
+
configurable: true
|
|
1509
|
+
});
|
|
1510
|
+
function ReadStream(path$14, options) {
|
|
1511
|
+
if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
|
|
1512
|
+
else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
1513
|
+
}
|
|
1514
|
+
function ReadStream$open() {
|
|
1515
|
+
var that = this;
|
|
1516
|
+
open$1(that.path, that.flags, that.mode, function(err, fd) {
|
|
1517
|
+
if (err) {
|
|
1518
|
+
if (that.autoClose) that.destroy();
|
|
1519
|
+
that.emit("error", err);
|
|
1520
|
+
} else {
|
|
1521
|
+
that.fd = fd;
|
|
1522
|
+
that.emit("open", fd);
|
|
1523
|
+
that.read();
|
|
1524
|
+
}
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function WriteStream(path$14, options) {
|
|
1528
|
+
if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
|
|
1529
|
+
else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
1530
|
+
}
|
|
1531
|
+
function WriteStream$open() {
|
|
1532
|
+
var that = this;
|
|
1533
|
+
open$1(that.path, that.flags, that.mode, function(err, fd) {
|
|
1534
|
+
if (err) {
|
|
1535
|
+
that.destroy();
|
|
1536
|
+
that.emit("error", err);
|
|
1537
|
+
} else {
|
|
1538
|
+
that.fd = fd;
|
|
1539
|
+
that.emit("open", fd);
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
function createReadStream(path$14, options) {
|
|
1544
|
+
return new fs$3.ReadStream(path$14, options);
|
|
1545
|
+
}
|
|
1546
|
+
function createWriteStream(path$14, options) {
|
|
1547
|
+
return new fs$3.WriteStream(path$14, options);
|
|
1548
|
+
}
|
|
1549
|
+
var fs$open = fs$3.open;
|
|
1550
|
+
fs$3.open = open$1;
|
|
1551
|
+
function open$1(path$14, flags, mode, cb) {
|
|
1552
|
+
if (typeof mode === "function") cb = mode, mode = null;
|
|
1553
|
+
return go$open(path$14, flags, mode, cb);
|
|
1554
|
+
function go$open(path$15, flags$1, mode$1, cb$1, startTime) {
|
|
1555
|
+
return fs$open(path$15, flags$1, mode$1, function(err, fd) {
|
|
1556
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
1557
|
+
go$open,
|
|
1558
|
+
[
|
|
1559
|
+
path$15,
|
|
1560
|
+
flags$1,
|
|
1561
|
+
mode$1,
|
|
1562
|
+
cb$1
|
|
1563
|
+
],
|
|
1564
|
+
err,
|
|
1565
|
+
startTime || Date.now(),
|
|
1566
|
+
Date.now()
|
|
1567
|
+
]);
|
|
1568
|
+
else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return fs$3;
|
|
1573
|
+
}
|
|
1574
|
+
function enqueue(elem) {
|
|
1575
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
1576
|
+
fs$1[gracefulQueue].push(elem);
|
|
1577
|
+
retry();
|
|
1578
|
+
}
|
|
1579
|
+
var retryTimer;
|
|
1580
|
+
function resetQueue() {
|
|
1581
|
+
var now = Date.now();
|
|
1582
|
+
for (var i = 0; i < fs$1[gracefulQueue].length; ++i) if (fs$1[gracefulQueue][i].length > 2) {
|
|
1583
|
+
fs$1[gracefulQueue][i][3] = now;
|
|
1584
|
+
fs$1[gracefulQueue][i][4] = now;
|
|
1585
|
+
}
|
|
1586
|
+
retry();
|
|
1587
|
+
}
|
|
1588
|
+
function retry() {
|
|
1589
|
+
clearTimeout(retryTimer);
|
|
1590
|
+
retryTimer = void 0;
|
|
1591
|
+
if (fs$1[gracefulQueue].length === 0) return;
|
|
1592
|
+
var elem = fs$1[gracefulQueue].shift();
|
|
1593
|
+
var fn = elem[0];
|
|
1594
|
+
var args = elem[1];
|
|
1595
|
+
var err = elem[2];
|
|
1596
|
+
var startTime = elem[3];
|
|
1597
|
+
var lastTime = elem[4];
|
|
1598
|
+
if (startTime === void 0) {
|
|
1599
|
+
debug("RETRY", fn.name, args);
|
|
1600
|
+
fn.apply(null, args);
|
|
1601
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
1602
|
+
debug("TIMEOUT", fn.name, args);
|
|
1603
|
+
var cb = args.pop();
|
|
1604
|
+
if (typeof cb === "function") cb.call(null, err);
|
|
1605
|
+
} else {
|
|
1606
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
1607
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
1608
|
+
if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
|
|
1609
|
+
debug("RETRY", fn.name, args);
|
|
1610
|
+
fn.apply(null, args.concat([startTime]));
|
|
1611
|
+
} else fs$1[gracefulQueue].push(elem);
|
|
1612
|
+
}
|
|
1613
|
+
if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
|
|
1614
|
+
}
|
|
1615
|
+
}));
|
|
1616
|
+
|
|
1617
|
+
//#endregion
|
|
1618
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/fs/index.js
|
|
1619
|
+
var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1620
|
+
const u = require_universalify().fromCallback;
|
|
1621
|
+
const fs = require_graceful_fs();
|
|
1622
|
+
const api = [
|
|
1623
|
+
"access",
|
|
1624
|
+
"appendFile",
|
|
1625
|
+
"chmod",
|
|
1626
|
+
"chown",
|
|
1627
|
+
"close",
|
|
1628
|
+
"copyFile",
|
|
1629
|
+
"cp",
|
|
1630
|
+
"fchmod",
|
|
1631
|
+
"fchown",
|
|
1632
|
+
"fdatasync",
|
|
1633
|
+
"fstat",
|
|
1634
|
+
"fsync",
|
|
1635
|
+
"ftruncate",
|
|
1636
|
+
"futimes",
|
|
1637
|
+
"glob",
|
|
1638
|
+
"lchmod",
|
|
1639
|
+
"lchown",
|
|
1640
|
+
"lutimes",
|
|
1641
|
+
"link",
|
|
1642
|
+
"lstat",
|
|
1643
|
+
"mkdir",
|
|
1644
|
+
"mkdtemp",
|
|
1645
|
+
"open",
|
|
1646
|
+
"opendir",
|
|
1647
|
+
"readdir",
|
|
1648
|
+
"readFile",
|
|
1649
|
+
"readlink",
|
|
1650
|
+
"realpath",
|
|
1651
|
+
"rename",
|
|
1652
|
+
"rm",
|
|
1653
|
+
"rmdir",
|
|
1654
|
+
"stat",
|
|
1655
|
+
"statfs",
|
|
1656
|
+
"symlink",
|
|
1657
|
+
"truncate",
|
|
1658
|
+
"unlink",
|
|
1659
|
+
"utimes",
|
|
1660
|
+
"writeFile"
|
|
1661
|
+
].filter((key) => {
|
|
1662
|
+
return typeof fs[key] === "function";
|
|
1663
|
+
});
|
|
1664
|
+
Object.assign(exports, fs);
|
|
1665
|
+
api.forEach((method) => {
|
|
1666
|
+
exports[method] = u(fs[method]);
|
|
1667
|
+
});
|
|
1668
|
+
exports.exists = function(filename$1, callback) {
|
|
1669
|
+
if (typeof callback === "function") return fs.exists(filename$1, callback);
|
|
1670
|
+
return new Promise((resolve$1) => {
|
|
1671
|
+
return fs.exists(filename$1, resolve$1);
|
|
1672
|
+
});
|
|
1673
|
+
};
|
|
1674
|
+
exports.read = function(fd, buffer, offset, length, position, callback) {
|
|
1675
|
+
if (typeof callback === "function") return fs.read(fd, buffer, offset, length, position, callback);
|
|
1676
|
+
return new Promise((resolve$1, reject) => {
|
|
1677
|
+
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer$1) => {
|
|
1678
|
+
if (err) return reject(err);
|
|
1679
|
+
resolve$1({
|
|
1680
|
+
bytesRead,
|
|
1681
|
+
buffer: buffer$1
|
|
1682
|
+
});
|
|
1683
|
+
});
|
|
1684
|
+
});
|
|
1685
|
+
};
|
|
1686
|
+
exports.write = function(fd, buffer, ...args) {
|
|
1687
|
+
if (typeof args[args.length - 1] === "function") return fs.write(fd, buffer, ...args);
|
|
1688
|
+
return new Promise((resolve$1, reject) => {
|
|
1689
|
+
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer$1) => {
|
|
1690
|
+
if (err) return reject(err);
|
|
1691
|
+
resolve$1({
|
|
1692
|
+
bytesWritten,
|
|
1693
|
+
buffer: buffer$1
|
|
1694
|
+
});
|
|
1695
|
+
});
|
|
1696
|
+
});
|
|
1697
|
+
};
|
|
1698
|
+
exports.readv = function(fd, buffers, ...args) {
|
|
1699
|
+
if (typeof args[args.length - 1] === "function") return fs.readv(fd, buffers, ...args);
|
|
1700
|
+
return new Promise((resolve$1, reject) => {
|
|
1701
|
+
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers$1) => {
|
|
1702
|
+
if (err) return reject(err);
|
|
1703
|
+
resolve$1({
|
|
1704
|
+
bytesRead,
|
|
1705
|
+
buffers: buffers$1
|
|
1706
|
+
});
|
|
1707
|
+
});
|
|
1708
|
+
});
|
|
1709
|
+
};
|
|
1710
|
+
exports.writev = function(fd, buffers, ...args) {
|
|
1711
|
+
if (typeof args[args.length - 1] === "function") return fs.writev(fd, buffers, ...args);
|
|
1712
|
+
return new Promise((resolve$1, reject) => {
|
|
1713
|
+
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers$1) => {
|
|
1714
|
+
if (err) return reject(err);
|
|
1715
|
+
resolve$1({
|
|
1716
|
+
bytesWritten,
|
|
1717
|
+
buffers: buffers$1
|
|
1718
|
+
});
|
|
1719
|
+
});
|
|
1720
|
+
});
|
|
1721
|
+
};
|
|
1722
|
+
if (typeof fs.realpath.native === "function") exports.realpath.native = u(fs.realpath.native);
|
|
1723
|
+
else process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?", "Warning", "fs-extra-WARN0003");
|
|
1724
|
+
}));
|
|
1725
|
+
|
|
1726
|
+
//#endregion
|
|
1727
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/mkdirs/utils.js
|
|
1728
|
+
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1729
|
+
const path$12 = __require("path");
|
|
1730
|
+
module.exports.checkPath = function checkPath(pth) {
|
|
1731
|
+
if (process.platform === "win32") {
|
|
1732
|
+
if (/[<>:"|?*]/.test(pth.replace(path$12.parse(pth).root, ""))) {
|
|
1733
|
+
const error = /* @__PURE__ */ new Error(`Path contains invalid characters: ${pth}`);
|
|
1734
|
+
error.code = "EINVAL";
|
|
1735
|
+
throw error;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
}));
|
|
1740
|
+
|
|
1741
|
+
//#endregion
|
|
1742
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/mkdirs/make-dir.js
|
|
1743
|
+
var require_make_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1744
|
+
const fs = require_fs();
|
|
1745
|
+
const { checkPath } = require_utils$1();
|
|
1746
|
+
const getMode = (options) => {
|
|
1747
|
+
const defaults = { mode: 511 };
|
|
1748
|
+
if (typeof options === "number") return options;
|
|
1749
|
+
return {
|
|
1750
|
+
...defaults,
|
|
1751
|
+
...options
|
|
1752
|
+
}.mode;
|
|
1753
|
+
};
|
|
1754
|
+
module.exports.makeDir = async (dir, options) => {
|
|
1755
|
+
checkPath(dir);
|
|
1756
|
+
return fs.mkdir(dir, {
|
|
1757
|
+
mode: getMode(options),
|
|
1758
|
+
recursive: true
|
|
1759
|
+
});
|
|
1760
|
+
};
|
|
1761
|
+
module.exports.makeDirSync = (dir, options) => {
|
|
1762
|
+
checkPath(dir);
|
|
1763
|
+
return fs.mkdirSync(dir, {
|
|
1764
|
+
mode: getMode(options),
|
|
1765
|
+
recursive: true
|
|
1766
|
+
});
|
|
1767
|
+
};
|
|
1768
|
+
}));
|
|
1769
|
+
|
|
1770
|
+
//#endregion
|
|
1771
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/mkdirs/index.js
|
|
1772
|
+
var require_mkdirs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1773
|
+
const u = require_universalify().fromPromise;
|
|
1774
|
+
const { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
|
1775
|
+
const makeDir = u(_makeDir);
|
|
1776
|
+
module.exports = {
|
|
1777
|
+
mkdirs: makeDir,
|
|
1778
|
+
mkdirsSync: makeDirSync,
|
|
1779
|
+
mkdirp: makeDir,
|
|
1780
|
+
mkdirpSync: makeDirSync,
|
|
1781
|
+
ensureDir: makeDir,
|
|
1782
|
+
ensureDirSync: makeDirSync
|
|
1783
|
+
};
|
|
1784
|
+
}));
|
|
1785
|
+
|
|
1786
|
+
//#endregion
|
|
1787
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/path-exists/index.js
|
|
1788
|
+
var require_path_exists = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1789
|
+
const u = require_universalify().fromPromise;
|
|
1790
|
+
const fs = require_fs();
|
|
1791
|
+
function pathExists(path$14) {
|
|
1792
|
+
return fs.access(path$14).then(() => true).catch(() => false);
|
|
1793
|
+
}
|
|
1794
|
+
module.exports = {
|
|
1795
|
+
pathExists: u(pathExists),
|
|
1796
|
+
pathExistsSync: fs.existsSync
|
|
1797
|
+
};
|
|
1798
|
+
}));
|
|
1799
|
+
|
|
1800
|
+
//#endregion
|
|
1801
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/util/utimes.js
|
|
1802
|
+
var require_utimes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1803
|
+
const fs = require_fs();
|
|
1804
|
+
const u = require_universalify().fromPromise;
|
|
1805
|
+
async function utimesMillis(path$14, atime, mtime) {
|
|
1806
|
+
const fd = await fs.open(path$14, "r+");
|
|
1807
|
+
let closeErr = null;
|
|
1808
|
+
try {
|
|
1809
|
+
await fs.futimes(fd, atime, mtime);
|
|
1810
|
+
} finally {
|
|
1811
|
+
try {
|
|
1812
|
+
await fs.close(fd);
|
|
1813
|
+
} catch (e) {
|
|
1814
|
+
closeErr = e;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
if (closeErr) throw closeErr;
|
|
1818
|
+
}
|
|
1819
|
+
function utimesMillisSync(path$14, atime, mtime) {
|
|
1820
|
+
const fd = fs.openSync(path$14, "r+");
|
|
1821
|
+
fs.futimesSync(fd, atime, mtime);
|
|
1822
|
+
return fs.closeSync(fd);
|
|
1823
|
+
}
|
|
1824
|
+
module.exports = {
|
|
1825
|
+
utimesMillis: u(utimesMillis),
|
|
1826
|
+
utimesMillisSync
|
|
1827
|
+
};
|
|
1828
|
+
}));
|
|
1829
|
+
|
|
1830
|
+
//#endregion
|
|
1831
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/util/stat.js
|
|
1832
|
+
var require_stat = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1833
|
+
const fs = require_fs();
|
|
1834
|
+
const path$11 = __require("path");
|
|
1835
|
+
const u = require_universalify().fromPromise;
|
|
1836
|
+
function getStats(src, dest, opts) {
|
|
1837
|
+
const statFunc = opts.dereference ? (file) => fs.stat(file, { bigint: true }) : (file) => fs.lstat(file, { bigint: true });
|
|
1838
|
+
return Promise.all([statFunc(src), statFunc(dest).catch((err) => {
|
|
1839
|
+
if (err.code === "ENOENT") return null;
|
|
1840
|
+
throw err;
|
|
1841
|
+
})]).then(([srcStat, destStat]) => ({
|
|
1842
|
+
srcStat,
|
|
1843
|
+
destStat
|
|
1844
|
+
}));
|
|
1845
|
+
}
|
|
1846
|
+
function getStatsSync(src, dest, opts) {
|
|
1847
|
+
let destStat;
|
|
1848
|
+
const statFunc = opts.dereference ? (file) => fs.statSync(file, { bigint: true }) : (file) => fs.lstatSync(file, { bigint: true });
|
|
1849
|
+
const srcStat = statFunc(src);
|
|
1850
|
+
try {
|
|
1851
|
+
destStat = statFunc(dest);
|
|
1852
|
+
} catch (err) {
|
|
1853
|
+
if (err.code === "ENOENT") return {
|
|
1854
|
+
srcStat,
|
|
1855
|
+
destStat: null
|
|
1856
|
+
};
|
|
1857
|
+
throw err;
|
|
1858
|
+
}
|
|
1859
|
+
return {
|
|
1860
|
+
srcStat,
|
|
1861
|
+
destStat
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
async function checkPaths(src, dest, funcName, opts) {
|
|
1865
|
+
const { srcStat, destStat } = await getStats(src, dest, opts);
|
|
1866
|
+
if (destStat) {
|
|
1867
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1868
|
+
const srcBaseName = path$11.basename(src);
|
|
1869
|
+
const destBaseName = path$11.basename(dest);
|
|
1870
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) return {
|
|
1871
|
+
srcStat,
|
|
1872
|
+
destStat,
|
|
1873
|
+
isChangingCase: true
|
|
1874
|
+
};
|
|
1875
|
+
throw new Error("Source and destination must not be the same.");
|
|
1876
|
+
}
|
|
1877
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
1878
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
1879
|
+
}
|
|
1880
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) throw new Error(errMsg(src, dest, funcName));
|
|
1881
|
+
return {
|
|
1882
|
+
srcStat,
|
|
1883
|
+
destStat
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
function checkPathsSync(src, dest, funcName, opts) {
|
|
1887
|
+
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
|
1888
|
+
if (destStat) {
|
|
1889
|
+
if (areIdentical(srcStat, destStat)) {
|
|
1890
|
+
const srcBaseName = path$11.basename(src);
|
|
1891
|
+
const destBaseName = path$11.basename(dest);
|
|
1892
|
+
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) return {
|
|
1893
|
+
srcStat,
|
|
1894
|
+
destStat,
|
|
1895
|
+
isChangingCase: true
|
|
1896
|
+
};
|
|
1897
|
+
throw new Error("Source and destination must not be the same.");
|
|
1898
|
+
}
|
|
1899
|
+
if (srcStat.isDirectory() && !destStat.isDirectory()) throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
|
1900
|
+
if (!srcStat.isDirectory() && destStat.isDirectory()) throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
|
1901
|
+
}
|
|
1902
|
+
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) throw new Error(errMsg(src, dest, funcName));
|
|
1903
|
+
return {
|
|
1904
|
+
srcStat,
|
|
1905
|
+
destStat
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
async function checkParentPaths(src, srcStat, dest, funcName) {
|
|
1909
|
+
const srcParent = path$11.resolve(path$11.dirname(src));
|
|
1910
|
+
const destParent = path$11.resolve(path$11.dirname(dest));
|
|
1911
|
+
if (destParent === srcParent || destParent === path$11.parse(destParent).root) return;
|
|
1912
|
+
let destStat;
|
|
1913
|
+
try {
|
|
1914
|
+
destStat = await fs.stat(destParent, { bigint: true });
|
|
1915
|
+
} catch (err) {
|
|
1916
|
+
if (err.code === "ENOENT") return;
|
|
1917
|
+
throw err;
|
|
1918
|
+
}
|
|
1919
|
+
if (areIdentical(srcStat, destStat)) throw new Error(errMsg(src, dest, funcName));
|
|
1920
|
+
return checkParentPaths(src, srcStat, destParent, funcName);
|
|
1921
|
+
}
|
|
1922
|
+
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
1923
|
+
const srcParent = path$11.resolve(path$11.dirname(src));
|
|
1924
|
+
const destParent = path$11.resolve(path$11.dirname(dest));
|
|
1925
|
+
if (destParent === srcParent || destParent === path$11.parse(destParent).root) return;
|
|
1926
|
+
let destStat;
|
|
1927
|
+
try {
|
|
1928
|
+
destStat = fs.statSync(destParent, { bigint: true });
|
|
1929
|
+
} catch (err) {
|
|
1930
|
+
if (err.code === "ENOENT") return;
|
|
1931
|
+
throw err;
|
|
1932
|
+
}
|
|
1933
|
+
if (areIdentical(srcStat, destStat)) throw new Error(errMsg(src, dest, funcName));
|
|
1934
|
+
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
1935
|
+
}
|
|
1936
|
+
function areIdentical(srcStat, destStat) {
|
|
1937
|
+
return destStat.ino !== void 0 && destStat.dev !== void 0 && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
|
1938
|
+
}
|
|
1939
|
+
function isSrcSubdir(src, dest) {
|
|
1940
|
+
const srcArr = path$11.resolve(src).split(path$11.sep).filter((i) => i);
|
|
1941
|
+
const destArr = path$11.resolve(dest).split(path$11.sep).filter((i) => i);
|
|
1942
|
+
return srcArr.every((cur, i) => destArr[i] === cur);
|
|
1943
|
+
}
|
|
1944
|
+
function errMsg(src, dest, funcName) {
|
|
1945
|
+
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
|
1946
|
+
}
|
|
1947
|
+
module.exports = {
|
|
1948
|
+
checkPaths: u(checkPaths),
|
|
1949
|
+
checkPathsSync,
|
|
1950
|
+
checkParentPaths: u(checkParentPaths),
|
|
1951
|
+
checkParentPathsSync,
|
|
1952
|
+
isSrcSubdir,
|
|
1953
|
+
areIdentical
|
|
1954
|
+
};
|
|
1955
|
+
}));
|
|
1956
|
+
|
|
1957
|
+
//#endregion
|
|
1958
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/util/async.js
|
|
1959
|
+
var require_async = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1960
|
+
async function asyncIteratorConcurrentProcess(iterator, fn) {
|
|
1961
|
+
const promises = [];
|
|
1962
|
+
for await (const item of iterator) promises.push(fn(item).then(() => null, (err) => err ?? /* @__PURE__ */ new Error("unknown error")));
|
|
1963
|
+
await Promise.all(promises.map((promise) => promise.then((possibleErr) => {
|
|
1964
|
+
if (possibleErr !== null) throw possibleErr;
|
|
1965
|
+
})));
|
|
1966
|
+
}
|
|
1967
|
+
module.exports = { asyncIteratorConcurrentProcess };
|
|
1968
|
+
}));
|
|
1969
|
+
|
|
1970
|
+
//#endregion
|
|
1971
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/copy/copy.js
|
|
1972
|
+
var require_copy$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1973
|
+
const fs = require_fs();
|
|
1974
|
+
const path$10 = __require("path");
|
|
1975
|
+
const { mkdirs } = require_mkdirs();
|
|
1976
|
+
const { pathExists } = require_path_exists();
|
|
1977
|
+
const { utimesMillis } = require_utimes();
|
|
1978
|
+
const stat = require_stat();
|
|
1979
|
+
const { asyncIteratorConcurrentProcess } = require_async();
|
|
1980
|
+
async function copy(src, dest, opts = {}) {
|
|
1981
|
+
if (typeof opts === "function") opts = { filter: opts };
|
|
1982
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
1983
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
1984
|
+
if (opts.preserveTimestamps && process.arch === "ia32") process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0001");
|
|
1985
|
+
const { srcStat, destStat } = await stat.checkPaths(src, dest, "copy", opts);
|
|
1986
|
+
await stat.checkParentPaths(src, srcStat, dest, "copy");
|
|
1987
|
+
if (!await runFilter(src, dest, opts)) return;
|
|
1988
|
+
const destParent = path$10.dirname(dest);
|
|
1989
|
+
if (!await pathExists(destParent)) await mkdirs(destParent);
|
|
1990
|
+
await getStatsAndPerformCopy(destStat, src, dest, opts);
|
|
1991
|
+
}
|
|
1992
|
+
async function runFilter(src, dest, opts) {
|
|
1993
|
+
if (!opts.filter) return true;
|
|
1994
|
+
return opts.filter(src, dest);
|
|
1995
|
+
}
|
|
1996
|
+
async function getStatsAndPerformCopy(destStat, src, dest, opts) {
|
|
1997
|
+
const srcStat = await (opts.dereference ? fs.stat : fs.lstat)(src);
|
|
1998
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
1999
|
+
if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
2000
|
+
if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
2001
|
+
if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
2002
|
+
if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
2003
|
+
throw new Error(`Unknown file: ${src}`);
|
|
2004
|
+
}
|
|
2005
|
+
async function onFile(srcStat, destStat, src, dest, opts) {
|
|
2006
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
2007
|
+
if (opts.overwrite) {
|
|
2008
|
+
await fs.unlink(dest);
|
|
2009
|
+
return copyFile(srcStat, src, dest, opts);
|
|
2010
|
+
}
|
|
2011
|
+
if (opts.errorOnExist) throw new Error(`'${dest}' already exists`);
|
|
2012
|
+
}
|
|
2013
|
+
async function copyFile(srcStat, src, dest, opts) {
|
|
2014
|
+
await fs.copyFile(src, dest);
|
|
2015
|
+
if (opts.preserveTimestamps) {
|
|
2016
|
+
if (fileIsNotWritable(srcStat.mode)) await makeFileWritable(dest, srcStat.mode);
|
|
2017
|
+
const updatedSrcStat = await fs.stat(src);
|
|
2018
|
+
await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
2019
|
+
}
|
|
2020
|
+
return fs.chmod(dest, srcStat.mode);
|
|
2021
|
+
}
|
|
2022
|
+
function fileIsNotWritable(srcMode) {
|
|
2023
|
+
return (srcMode & 128) === 0;
|
|
2024
|
+
}
|
|
2025
|
+
function makeFileWritable(dest, srcMode) {
|
|
2026
|
+
return fs.chmod(dest, srcMode | 128);
|
|
2027
|
+
}
|
|
2028
|
+
async function onDir(srcStat, destStat, src, dest, opts) {
|
|
2029
|
+
if (!destStat) await fs.mkdir(dest);
|
|
2030
|
+
await asyncIteratorConcurrentProcess(await fs.opendir(src), async (item) => {
|
|
2031
|
+
const srcItem = path$10.join(src, item.name);
|
|
2032
|
+
const destItem = path$10.join(dest, item.name);
|
|
2033
|
+
if (await runFilter(srcItem, destItem, opts)) {
|
|
2034
|
+
const { destStat: destStat$1 } = await stat.checkPaths(srcItem, destItem, "copy", opts);
|
|
2035
|
+
await getStatsAndPerformCopy(destStat$1, srcItem, destItem, opts);
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
if (!destStat) await fs.chmod(dest, srcStat.mode);
|
|
2039
|
+
}
|
|
2040
|
+
async function onLink(destStat, src, dest, opts) {
|
|
2041
|
+
let resolvedSrc = await fs.readlink(src);
|
|
2042
|
+
if (opts.dereference) resolvedSrc = path$10.resolve(process.cwd(), resolvedSrc);
|
|
2043
|
+
if (!destStat) return fs.symlink(resolvedSrc, dest);
|
|
2044
|
+
let resolvedDest = null;
|
|
2045
|
+
try {
|
|
2046
|
+
resolvedDest = await fs.readlink(dest);
|
|
2047
|
+
} catch (e) {
|
|
2048
|
+
if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs.symlink(resolvedSrc, dest);
|
|
2049
|
+
throw e;
|
|
2050
|
+
}
|
|
2051
|
+
if (opts.dereference) resolvedDest = path$10.resolve(process.cwd(), resolvedDest);
|
|
2052
|
+
if (resolvedSrc !== resolvedDest) {
|
|
2053
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
2054
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
2055
|
+
}
|
|
2056
|
+
await fs.unlink(dest);
|
|
2057
|
+
return fs.symlink(resolvedSrc, dest);
|
|
2058
|
+
}
|
|
2059
|
+
module.exports = copy;
|
|
2060
|
+
}));
|
|
2061
|
+
|
|
2062
|
+
//#endregion
|
|
2063
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/copy/copy-sync.js
|
|
2064
|
+
var require_copy_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2065
|
+
const fs = require_graceful_fs();
|
|
2066
|
+
const path$9 = __require("path");
|
|
2067
|
+
const mkdirsSync = require_mkdirs().mkdirsSync;
|
|
2068
|
+
const utimesMillisSync = require_utimes().utimesMillisSync;
|
|
2069
|
+
const stat = require_stat();
|
|
2070
|
+
function copySync(src, dest, opts) {
|
|
2071
|
+
if (typeof opts === "function") opts = { filter: opts };
|
|
2072
|
+
opts = opts || {};
|
|
2073
|
+
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
|
2074
|
+
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
|
2075
|
+
if (opts.preserveTimestamps && process.arch === "ia32") process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0002");
|
|
2076
|
+
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
2077
|
+
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
2078
|
+
if (opts.filter && !opts.filter(src, dest)) return;
|
|
2079
|
+
const destParent = path$9.dirname(dest);
|
|
2080
|
+
if (!fs.existsSync(destParent)) mkdirsSync(destParent);
|
|
2081
|
+
return getStats(destStat, src, dest, opts);
|
|
2082
|
+
}
|
|
2083
|
+
function getStats(destStat, src, dest, opts) {
|
|
2084
|
+
const srcStat = (opts.dereference ? fs.statSync : fs.lstatSync)(src);
|
|
2085
|
+
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
|
|
2086
|
+
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
|
|
2087
|
+
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
|
|
2088
|
+
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
|
|
2089
|
+
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
|
2090
|
+
throw new Error(`Unknown file: ${src}`);
|
|
2091
|
+
}
|
|
2092
|
+
function onFile(srcStat, destStat, src, dest, opts) {
|
|
2093
|
+
if (!destStat) return copyFile(srcStat, src, dest, opts);
|
|
2094
|
+
return mayCopyFile(srcStat, src, dest, opts);
|
|
2095
|
+
}
|
|
2096
|
+
function mayCopyFile(srcStat, src, dest, opts) {
|
|
2097
|
+
if (opts.overwrite) {
|
|
2098
|
+
fs.unlinkSync(dest);
|
|
2099
|
+
return copyFile(srcStat, src, dest, opts);
|
|
2100
|
+
} else if (opts.errorOnExist) throw new Error(`'${dest}' already exists`);
|
|
2101
|
+
}
|
|
2102
|
+
function copyFile(srcStat, src, dest, opts) {
|
|
2103
|
+
fs.copyFileSync(src, dest);
|
|
2104
|
+
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
|
|
2105
|
+
return setDestMode(dest, srcStat.mode);
|
|
2106
|
+
}
|
|
2107
|
+
function handleTimestamps(srcMode, src, dest) {
|
|
2108
|
+
if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
|
|
2109
|
+
return setDestTimestamps(src, dest);
|
|
2110
|
+
}
|
|
2111
|
+
function fileIsNotWritable(srcMode) {
|
|
2112
|
+
return (srcMode & 128) === 0;
|
|
2113
|
+
}
|
|
2114
|
+
function makeFileWritable(dest, srcMode) {
|
|
2115
|
+
return setDestMode(dest, srcMode | 128);
|
|
2116
|
+
}
|
|
2117
|
+
function setDestMode(dest, srcMode) {
|
|
2118
|
+
return fs.chmodSync(dest, srcMode);
|
|
2119
|
+
}
|
|
2120
|
+
function setDestTimestamps(src, dest) {
|
|
2121
|
+
const updatedSrcStat = fs.statSync(src);
|
|
2122
|
+
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
2123
|
+
}
|
|
2124
|
+
function onDir(srcStat, destStat, src, dest, opts) {
|
|
2125
|
+
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
|
2126
|
+
return copyDir(src, dest, opts);
|
|
2127
|
+
}
|
|
2128
|
+
function mkDirAndCopy(srcMode, src, dest, opts) {
|
|
2129
|
+
fs.mkdirSync(dest);
|
|
2130
|
+
copyDir(src, dest, opts);
|
|
2131
|
+
return setDestMode(dest, srcMode);
|
|
2132
|
+
}
|
|
2133
|
+
function copyDir(src, dest, opts) {
|
|
2134
|
+
const dir = fs.opendirSync(src);
|
|
2135
|
+
try {
|
|
2136
|
+
let dirent;
|
|
2137
|
+
while ((dirent = dir.readSync()) !== null) copyDirItem(dirent.name, src, dest, opts);
|
|
2138
|
+
} finally {
|
|
2139
|
+
dir.closeSync();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function copyDirItem(item, src, dest, opts) {
|
|
2143
|
+
const srcItem = path$9.join(src, item);
|
|
2144
|
+
const destItem = path$9.join(dest, item);
|
|
2145
|
+
if (opts.filter && !opts.filter(srcItem, destItem)) return;
|
|
2146
|
+
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
2147
|
+
return getStats(destStat, srcItem, destItem, opts);
|
|
2148
|
+
}
|
|
2149
|
+
function onLink(destStat, src, dest, opts) {
|
|
2150
|
+
let resolvedSrc = fs.readlinkSync(src);
|
|
2151
|
+
if (opts.dereference) resolvedSrc = path$9.resolve(process.cwd(), resolvedSrc);
|
|
2152
|
+
if (!destStat) return fs.symlinkSync(resolvedSrc, dest);
|
|
2153
|
+
else {
|
|
2154
|
+
let resolvedDest;
|
|
2155
|
+
try {
|
|
2156
|
+
resolvedDest = fs.readlinkSync(dest);
|
|
2157
|
+
} catch (err) {
|
|
2158
|
+
if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs.symlinkSync(resolvedSrc, dest);
|
|
2159
|
+
throw err;
|
|
2160
|
+
}
|
|
2161
|
+
if (opts.dereference) resolvedDest = path$9.resolve(process.cwd(), resolvedDest);
|
|
2162
|
+
if (resolvedSrc !== resolvedDest) {
|
|
2163
|
+
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
2164
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
2165
|
+
}
|
|
2166
|
+
return copyLink(resolvedSrc, dest);
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
function copyLink(resolvedSrc, dest) {
|
|
2170
|
+
fs.unlinkSync(dest);
|
|
2171
|
+
return fs.symlinkSync(resolvedSrc, dest);
|
|
2172
|
+
}
|
|
2173
|
+
module.exports = copySync;
|
|
2174
|
+
}));
|
|
2175
|
+
|
|
2176
|
+
//#endregion
|
|
2177
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/copy/index.js
|
|
2178
|
+
var require_copy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2179
|
+
const u = require_universalify().fromPromise;
|
|
2180
|
+
module.exports = {
|
|
2181
|
+
copy: u(require_copy$1()),
|
|
2182
|
+
copySync: require_copy_sync()
|
|
2183
|
+
};
|
|
2184
|
+
}));
|
|
2185
|
+
|
|
2186
|
+
//#endregion
|
|
2187
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/remove/index.js
|
|
2188
|
+
var require_remove = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2189
|
+
const fs = require_graceful_fs();
|
|
2190
|
+
const u = require_universalify().fromCallback;
|
|
2191
|
+
function remove(path$14, callback) {
|
|
2192
|
+
fs.rm(path$14, {
|
|
2193
|
+
recursive: true,
|
|
2194
|
+
force: true
|
|
2195
|
+
}, callback);
|
|
2196
|
+
}
|
|
2197
|
+
function removeSync(path$14) {
|
|
2198
|
+
fs.rmSync(path$14, {
|
|
2199
|
+
recursive: true,
|
|
2200
|
+
force: true
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
module.exports = {
|
|
2204
|
+
remove: u(remove),
|
|
2205
|
+
removeSync
|
|
2206
|
+
};
|
|
2207
|
+
}));
|
|
2208
|
+
|
|
2209
|
+
//#endregion
|
|
2210
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/empty/index.js
|
|
2211
|
+
var require_empty = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2212
|
+
const u = require_universalify().fromPromise;
|
|
2213
|
+
const fs = require_fs();
|
|
2214
|
+
const path$8 = __require("path");
|
|
2215
|
+
const mkdir = require_mkdirs();
|
|
2216
|
+
const remove = require_remove();
|
|
2217
|
+
const emptyDir = u(async function emptyDir$2(dir) {
|
|
2218
|
+
let items;
|
|
2219
|
+
try {
|
|
2220
|
+
items = await fs.readdir(dir);
|
|
2221
|
+
} catch {
|
|
2222
|
+
return mkdir.mkdirs(dir);
|
|
2223
|
+
}
|
|
2224
|
+
return Promise.all(items.map((item) => remove.remove(path$8.join(dir, item))));
|
|
2225
|
+
});
|
|
2226
|
+
function emptyDirSync(dir) {
|
|
2227
|
+
let items;
|
|
2228
|
+
try {
|
|
2229
|
+
items = fs.readdirSync(dir);
|
|
2230
|
+
} catch {
|
|
2231
|
+
return mkdir.mkdirsSync(dir);
|
|
2232
|
+
}
|
|
2233
|
+
items.forEach((item) => {
|
|
2234
|
+
item = path$8.join(dir, item);
|
|
2235
|
+
remove.removeSync(item);
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
module.exports = {
|
|
2239
|
+
emptyDirSync,
|
|
2240
|
+
emptydirSync: emptyDirSync,
|
|
2241
|
+
emptyDir,
|
|
2242
|
+
emptydir: emptyDir
|
|
2243
|
+
};
|
|
2244
|
+
}));
|
|
2245
|
+
|
|
2246
|
+
//#endregion
|
|
2247
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/ensure/file.js
|
|
2248
|
+
var require_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2249
|
+
const u = require_universalify().fromPromise;
|
|
2250
|
+
const path$7 = __require("path");
|
|
2251
|
+
const fs = require_fs();
|
|
2252
|
+
const mkdir = require_mkdirs();
|
|
2253
|
+
async function createFile(file) {
|
|
2254
|
+
let stats;
|
|
2255
|
+
try {
|
|
2256
|
+
stats = await fs.stat(file);
|
|
2257
|
+
} catch {}
|
|
2258
|
+
if (stats && stats.isFile()) return;
|
|
2259
|
+
const dir = path$7.dirname(file);
|
|
2260
|
+
let dirStats = null;
|
|
2261
|
+
try {
|
|
2262
|
+
dirStats = await fs.stat(dir);
|
|
2263
|
+
} catch (err) {
|
|
2264
|
+
if (err.code === "ENOENT") {
|
|
2265
|
+
await mkdir.mkdirs(dir);
|
|
2266
|
+
await fs.writeFile(file, "");
|
|
2267
|
+
return;
|
|
2268
|
+
} else throw err;
|
|
2269
|
+
}
|
|
2270
|
+
if (dirStats.isDirectory()) await fs.writeFile(file, "");
|
|
2271
|
+
else await fs.readdir(dir);
|
|
2272
|
+
}
|
|
2273
|
+
function createFileSync(file) {
|
|
2274
|
+
let stats;
|
|
2275
|
+
try {
|
|
2276
|
+
stats = fs.statSync(file);
|
|
2277
|
+
} catch {}
|
|
2278
|
+
if (stats && stats.isFile()) return;
|
|
2279
|
+
const dir = path$7.dirname(file);
|
|
2280
|
+
try {
|
|
2281
|
+
if (!fs.statSync(dir).isDirectory()) fs.readdirSync(dir);
|
|
2282
|
+
} catch (err) {
|
|
2283
|
+
if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
|
|
2284
|
+
else throw err;
|
|
2285
|
+
}
|
|
2286
|
+
fs.writeFileSync(file, "");
|
|
2287
|
+
}
|
|
2288
|
+
module.exports = {
|
|
2289
|
+
createFile: u(createFile),
|
|
2290
|
+
createFileSync
|
|
2291
|
+
};
|
|
2292
|
+
}));
|
|
2293
|
+
|
|
2294
|
+
//#endregion
|
|
2295
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/ensure/link.js
|
|
2296
|
+
var require_link = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2297
|
+
const u = require_universalify().fromPromise;
|
|
2298
|
+
const path$6 = __require("path");
|
|
2299
|
+
const fs = require_fs();
|
|
2300
|
+
const mkdir = require_mkdirs();
|
|
2301
|
+
const { pathExists } = require_path_exists();
|
|
2302
|
+
const { areIdentical } = require_stat();
|
|
2303
|
+
async function createLink(srcpath, dstpath) {
|
|
2304
|
+
let dstStat;
|
|
2305
|
+
try {
|
|
2306
|
+
dstStat = await fs.lstat(dstpath);
|
|
2307
|
+
} catch {}
|
|
2308
|
+
let srcStat;
|
|
2309
|
+
try {
|
|
2310
|
+
srcStat = await fs.lstat(srcpath);
|
|
2311
|
+
} catch (err) {
|
|
2312
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
2313
|
+
throw err;
|
|
2314
|
+
}
|
|
2315
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
2316
|
+
const dir = path$6.dirname(dstpath);
|
|
2317
|
+
if (!await pathExists(dir)) await mkdir.mkdirs(dir);
|
|
2318
|
+
await fs.link(srcpath, dstpath);
|
|
2319
|
+
}
|
|
2320
|
+
function createLinkSync(srcpath, dstpath) {
|
|
2321
|
+
let dstStat;
|
|
2322
|
+
try {
|
|
2323
|
+
dstStat = fs.lstatSync(dstpath);
|
|
2324
|
+
} catch {}
|
|
2325
|
+
try {
|
|
2326
|
+
const srcStat = fs.lstatSync(srcpath);
|
|
2327
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return;
|
|
2328
|
+
} catch (err) {
|
|
2329
|
+
err.message = err.message.replace("lstat", "ensureLink");
|
|
2330
|
+
throw err;
|
|
2331
|
+
}
|
|
2332
|
+
const dir = path$6.dirname(dstpath);
|
|
2333
|
+
if (fs.existsSync(dir)) return fs.linkSync(srcpath, dstpath);
|
|
2334
|
+
mkdir.mkdirsSync(dir);
|
|
2335
|
+
return fs.linkSync(srcpath, dstpath);
|
|
2336
|
+
}
|
|
2337
|
+
module.exports = {
|
|
2338
|
+
createLink: u(createLink),
|
|
2339
|
+
createLinkSync
|
|
2340
|
+
};
|
|
2341
|
+
}));
|
|
2342
|
+
|
|
2343
|
+
//#endregion
|
|
2344
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/ensure/symlink-paths.js
|
|
2345
|
+
var require_symlink_paths = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2346
|
+
const path$5 = __require("path");
|
|
2347
|
+
const fs = require_fs();
|
|
2348
|
+
const { pathExists } = require_path_exists();
|
|
2349
|
+
const u = require_universalify().fromPromise;
|
|
2350
|
+
/**
|
|
2351
|
+
* Function that returns two types of paths, one relative to symlink, and one
|
|
2352
|
+
* relative to the current working directory. Checks if path is absolute or
|
|
2353
|
+
* relative. If the path is relative, this function checks if the path is
|
|
2354
|
+
* relative to symlink or relative to current working directory. This is an
|
|
2355
|
+
* initiative to find a smarter `srcpath` to supply when building symlinks.
|
|
2356
|
+
* This allows you to determine which path to use out of one of three possible
|
|
2357
|
+
* types of source paths. The first is an absolute path. This is detected by
|
|
2358
|
+
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
|
|
2359
|
+
* see if it exists. If it does it's used, if not an error is returned
|
|
2360
|
+
* (callback)/ thrown (sync). The other two options for `srcpath` are a
|
|
2361
|
+
* relative url. By default Node's `fs.symlink` works by creating a symlink
|
|
2362
|
+
* using `dstpath` and expects the `srcpath` to be relative to the newly
|
|
2363
|
+
* created symlink. If you provide a `srcpath` that does not exist on the file
|
|
2364
|
+
* system it results in a broken symlink. To minimize this, the function
|
|
2365
|
+
* checks to see if the 'relative to symlink' source file exists, and if it
|
|
2366
|
+
* does it will use it. If it does not, it checks if there's a file that
|
|
2367
|
+
* exists that is relative to the current working directory, if does its used.
|
|
2368
|
+
* This preserves the expectations of the original fs.symlink spec and adds
|
|
2369
|
+
* the ability to pass in `relative to current working direcotry` paths.
|
|
2370
|
+
*/
|
|
2371
|
+
async function symlinkPaths(srcpath, dstpath) {
|
|
2372
|
+
if (path$5.isAbsolute(srcpath)) {
|
|
2373
|
+
try {
|
|
2374
|
+
await fs.lstat(srcpath);
|
|
2375
|
+
} catch (err) {
|
|
2376
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
2377
|
+
throw err;
|
|
2378
|
+
}
|
|
2379
|
+
return {
|
|
2380
|
+
toCwd: srcpath,
|
|
2381
|
+
toDst: srcpath
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
const dstdir = path$5.dirname(dstpath);
|
|
2385
|
+
const relativeToDst = path$5.join(dstdir, srcpath);
|
|
2386
|
+
if (await pathExists(relativeToDst)) return {
|
|
2387
|
+
toCwd: relativeToDst,
|
|
2388
|
+
toDst: srcpath
|
|
2389
|
+
};
|
|
2390
|
+
try {
|
|
2391
|
+
await fs.lstat(srcpath);
|
|
2392
|
+
} catch (err) {
|
|
2393
|
+
err.message = err.message.replace("lstat", "ensureSymlink");
|
|
2394
|
+
throw err;
|
|
2395
|
+
}
|
|
2396
|
+
return {
|
|
2397
|
+
toCwd: srcpath,
|
|
2398
|
+
toDst: path$5.relative(dstdir, srcpath)
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
function symlinkPathsSync(srcpath, dstpath) {
|
|
2402
|
+
if (path$5.isAbsolute(srcpath)) {
|
|
2403
|
+
if (!fs.existsSync(srcpath)) throw new Error("absolute srcpath does not exist");
|
|
2404
|
+
return {
|
|
2405
|
+
toCwd: srcpath,
|
|
2406
|
+
toDst: srcpath
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
const dstdir = path$5.dirname(dstpath);
|
|
2410
|
+
const relativeToDst = path$5.join(dstdir, srcpath);
|
|
2411
|
+
if (fs.existsSync(relativeToDst)) return {
|
|
2412
|
+
toCwd: relativeToDst,
|
|
2413
|
+
toDst: srcpath
|
|
2414
|
+
};
|
|
2415
|
+
if (!fs.existsSync(srcpath)) throw new Error("relative srcpath does not exist");
|
|
2416
|
+
return {
|
|
2417
|
+
toCwd: srcpath,
|
|
2418
|
+
toDst: path$5.relative(dstdir, srcpath)
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
2421
|
+
module.exports = {
|
|
2422
|
+
symlinkPaths: u(symlinkPaths),
|
|
2423
|
+
symlinkPathsSync
|
|
2424
|
+
};
|
|
2425
|
+
}));
|
|
2426
|
+
|
|
2427
|
+
//#endregion
|
|
2428
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/ensure/symlink-type.js
|
|
2429
|
+
var require_symlink_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2430
|
+
const fs = require_fs();
|
|
2431
|
+
const u = require_universalify().fromPromise;
|
|
2432
|
+
async function symlinkType(srcpath, type) {
|
|
2433
|
+
if (type) return type;
|
|
2434
|
+
let stats;
|
|
2435
|
+
try {
|
|
2436
|
+
stats = await fs.lstat(srcpath);
|
|
2437
|
+
} catch {
|
|
2438
|
+
return "file";
|
|
2439
|
+
}
|
|
2440
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
2441
|
+
}
|
|
2442
|
+
function symlinkTypeSync(srcpath, type) {
|
|
2443
|
+
if (type) return type;
|
|
2444
|
+
let stats;
|
|
2445
|
+
try {
|
|
2446
|
+
stats = fs.lstatSync(srcpath);
|
|
2447
|
+
} catch {
|
|
2448
|
+
return "file";
|
|
2449
|
+
}
|
|
2450
|
+
return stats && stats.isDirectory() ? "dir" : "file";
|
|
2451
|
+
}
|
|
2452
|
+
module.exports = {
|
|
2453
|
+
symlinkType: u(symlinkType),
|
|
2454
|
+
symlinkTypeSync
|
|
2455
|
+
};
|
|
2456
|
+
}));
|
|
2457
|
+
|
|
2458
|
+
//#endregion
|
|
2459
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/ensure/symlink.js
|
|
2460
|
+
var require_symlink = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2461
|
+
const u = require_universalify().fromPromise;
|
|
2462
|
+
const path$4 = __require("path");
|
|
2463
|
+
const fs = require_fs();
|
|
2464
|
+
const { mkdirs, mkdirsSync } = require_mkdirs();
|
|
2465
|
+
const { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
|
|
2466
|
+
const { symlinkType, symlinkTypeSync } = require_symlink_type();
|
|
2467
|
+
const { pathExists } = require_path_exists();
|
|
2468
|
+
const { areIdentical } = require_stat();
|
|
2469
|
+
async function createSymlink(srcpath, dstpath, type) {
|
|
2470
|
+
let stats;
|
|
2471
|
+
try {
|
|
2472
|
+
stats = await fs.lstat(dstpath);
|
|
2473
|
+
} catch {}
|
|
2474
|
+
if (stats && stats.isSymbolicLink()) {
|
|
2475
|
+
const [srcStat, dstStat] = await Promise.all([fs.stat(srcpath), fs.stat(dstpath)]);
|
|
2476
|
+
if (areIdentical(srcStat, dstStat)) return;
|
|
2477
|
+
}
|
|
2478
|
+
const relative = await symlinkPaths(srcpath, dstpath);
|
|
2479
|
+
srcpath = relative.toDst;
|
|
2480
|
+
const toType = await symlinkType(relative.toCwd, type);
|
|
2481
|
+
const dir = path$4.dirname(dstpath);
|
|
2482
|
+
if (!await pathExists(dir)) await mkdirs(dir);
|
|
2483
|
+
return fs.symlink(srcpath, dstpath, toType);
|
|
2484
|
+
}
|
|
2485
|
+
function createSymlinkSync(srcpath, dstpath, type) {
|
|
2486
|
+
let stats;
|
|
2487
|
+
try {
|
|
2488
|
+
stats = fs.lstatSync(dstpath);
|
|
2489
|
+
} catch {}
|
|
2490
|
+
if (stats && stats.isSymbolicLink()) {
|
|
2491
|
+
if (areIdentical(fs.statSync(srcpath), fs.statSync(dstpath))) return;
|
|
2492
|
+
}
|
|
2493
|
+
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
2494
|
+
srcpath = relative.toDst;
|
|
2495
|
+
type = symlinkTypeSync(relative.toCwd, type);
|
|
2496
|
+
const dir = path$4.dirname(dstpath);
|
|
2497
|
+
if (fs.existsSync(dir)) return fs.symlinkSync(srcpath, dstpath, type);
|
|
2498
|
+
mkdirsSync(dir);
|
|
2499
|
+
return fs.symlinkSync(srcpath, dstpath, type);
|
|
2500
|
+
}
|
|
2501
|
+
module.exports = {
|
|
2502
|
+
createSymlink: u(createSymlink),
|
|
2503
|
+
createSymlinkSync
|
|
2504
|
+
};
|
|
2505
|
+
}));
|
|
2506
|
+
|
|
2507
|
+
//#endregion
|
|
2508
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/ensure/index.js
|
|
2509
|
+
var require_ensure = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2510
|
+
const { createFile, createFileSync } = require_file();
|
|
2511
|
+
const { createLink, createLinkSync } = require_link();
|
|
2512
|
+
const { createSymlink, createSymlinkSync } = require_symlink();
|
|
2513
|
+
module.exports = {
|
|
2514
|
+
createFile,
|
|
2515
|
+
createFileSync,
|
|
2516
|
+
ensureFile: createFile,
|
|
2517
|
+
ensureFileSync: createFileSync,
|
|
2518
|
+
createLink,
|
|
2519
|
+
createLinkSync,
|
|
2520
|
+
ensureLink: createLink,
|
|
2521
|
+
ensureLinkSync: createLinkSync,
|
|
2522
|
+
createSymlink,
|
|
2523
|
+
createSymlinkSync,
|
|
2524
|
+
ensureSymlink: createSymlink,
|
|
2525
|
+
ensureSymlinkSync: createSymlinkSync
|
|
2526
|
+
};
|
|
2527
|
+
}));
|
|
2528
|
+
|
|
2529
|
+
//#endregion
|
|
2530
|
+
//#region ../../node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/utils.js
|
|
2531
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2532
|
+
function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
|
2533
|
+
const EOF = finalEOL ? EOL : "";
|
|
2534
|
+
return JSON.stringify(obj, replacer, spaces).replace(/\n/g, EOL) + EOF;
|
|
2535
|
+
}
|
|
2536
|
+
function stripBom(content) {
|
|
2537
|
+
if (Buffer.isBuffer(content)) content = content.toString("utf8");
|
|
2538
|
+
return content.replace(/^\uFEFF/, "");
|
|
2539
|
+
}
|
|
2540
|
+
module.exports = {
|
|
2541
|
+
stringify,
|
|
2542
|
+
stripBom
|
|
2543
|
+
};
|
|
2544
|
+
}));
|
|
2545
|
+
|
|
2546
|
+
//#endregion
|
|
2547
|
+
//#region ../../node_modules/.pnpm/jsonfile@6.2.0/node_modules/jsonfile/index.js
|
|
2548
|
+
var require_jsonfile$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2549
|
+
let _fs;
|
|
2550
|
+
try {
|
|
2551
|
+
_fs = require_graceful_fs();
|
|
2552
|
+
} catch (_) {
|
|
2553
|
+
_fs = __require("fs");
|
|
2554
|
+
}
|
|
2555
|
+
const universalify = require_universalify();
|
|
2556
|
+
const { stringify, stripBom } = require_utils();
|
|
2557
|
+
async function _readFile(file, options = {}) {
|
|
2558
|
+
if (typeof options === "string") options = { encoding: options };
|
|
2559
|
+
const fs$3 = options.fs || _fs;
|
|
2560
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
2561
|
+
let data = await universalify.fromCallback(fs$3.readFile)(file, options);
|
|
2562
|
+
data = stripBom(data);
|
|
2563
|
+
let obj;
|
|
2564
|
+
try {
|
|
2565
|
+
obj = JSON.parse(data, options ? options.reviver : null);
|
|
2566
|
+
} catch (err) {
|
|
2567
|
+
if (shouldThrow) {
|
|
2568
|
+
err.message = `${file}: ${err.message}`;
|
|
2569
|
+
throw err;
|
|
2570
|
+
} else return null;
|
|
2571
|
+
}
|
|
2572
|
+
return obj;
|
|
2573
|
+
}
|
|
2574
|
+
const readFile = universalify.fromPromise(_readFile);
|
|
2575
|
+
function readFileSync(file, options = {}) {
|
|
2576
|
+
if (typeof options === "string") options = { encoding: options };
|
|
2577
|
+
const fs$3 = options.fs || _fs;
|
|
2578
|
+
const shouldThrow = "throws" in options ? options.throws : true;
|
|
2579
|
+
try {
|
|
2580
|
+
let content = fs$3.readFileSync(file, options);
|
|
2581
|
+
content = stripBom(content);
|
|
2582
|
+
return JSON.parse(content, options.reviver);
|
|
2583
|
+
} catch (err) {
|
|
2584
|
+
if (shouldThrow) {
|
|
2585
|
+
err.message = `${file}: ${err.message}`;
|
|
2586
|
+
throw err;
|
|
2587
|
+
} else return null;
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
async function _writeFile(file, obj, options = {}) {
|
|
2591
|
+
const fs$3 = options.fs || _fs;
|
|
2592
|
+
const str = stringify(obj, options);
|
|
2593
|
+
await universalify.fromCallback(fs$3.writeFile)(file, str, options);
|
|
2594
|
+
}
|
|
2595
|
+
const writeFile = universalify.fromPromise(_writeFile);
|
|
2596
|
+
function writeFileSync(file, obj, options = {}) {
|
|
2597
|
+
const fs$3 = options.fs || _fs;
|
|
2598
|
+
const str = stringify(obj, options);
|
|
2599
|
+
return fs$3.writeFileSync(file, str, options);
|
|
2600
|
+
}
|
|
2601
|
+
module.exports = {
|
|
2602
|
+
readFile,
|
|
2603
|
+
readFileSync,
|
|
2604
|
+
writeFile,
|
|
2605
|
+
writeFileSync
|
|
2606
|
+
};
|
|
2607
|
+
}));
|
|
2608
|
+
|
|
2609
|
+
//#endregion
|
|
2610
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/json/jsonfile.js
|
|
2611
|
+
var require_jsonfile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2612
|
+
const jsonFile = require_jsonfile$1();
|
|
2613
|
+
module.exports = {
|
|
2614
|
+
readJson: jsonFile.readFile,
|
|
2615
|
+
readJsonSync: jsonFile.readFileSync,
|
|
2616
|
+
writeJson: jsonFile.writeFile,
|
|
2617
|
+
writeJsonSync: jsonFile.writeFileSync
|
|
2618
|
+
};
|
|
2619
|
+
}));
|
|
2620
|
+
|
|
2621
|
+
//#endregion
|
|
2622
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/output-file/index.js
|
|
2623
|
+
var require_output_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2624
|
+
const u = require_universalify().fromPromise;
|
|
2625
|
+
const fs = require_fs();
|
|
2626
|
+
const path$3 = __require("path");
|
|
2627
|
+
const mkdir = require_mkdirs();
|
|
2628
|
+
const pathExists = require_path_exists().pathExists;
|
|
2629
|
+
async function outputFile(file, data, encoding = "utf-8") {
|
|
2630
|
+
const dir = path$3.dirname(file);
|
|
2631
|
+
if (!await pathExists(dir)) await mkdir.mkdirs(dir);
|
|
2632
|
+
return fs.writeFile(file, data, encoding);
|
|
2633
|
+
}
|
|
2634
|
+
function outputFileSync(file, ...args) {
|
|
2635
|
+
const dir = path$3.dirname(file);
|
|
2636
|
+
if (!fs.existsSync(dir)) mkdir.mkdirsSync(dir);
|
|
2637
|
+
fs.writeFileSync(file, ...args);
|
|
2638
|
+
}
|
|
2639
|
+
module.exports = {
|
|
2640
|
+
outputFile: u(outputFile),
|
|
2641
|
+
outputFileSync
|
|
2642
|
+
};
|
|
2643
|
+
}));
|
|
2644
|
+
|
|
2645
|
+
//#endregion
|
|
2646
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/json/output-json.js
|
|
2647
|
+
var require_output_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2648
|
+
const { stringify } = require_utils();
|
|
2649
|
+
const { outputFile } = require_output_file();
|
|
2650
|
+
async function outputJson(file, data, options = {}) {
|
|
2651
|
+
await outputFile(file, stringify(data, options), options);
|
|
2652
|
+
}
|
|
2653
|
+
module.exports = outputJson;
|
|
2654
|
+
}));
|
|
2655
|
+
|
|
2656
|
+
//#endregion
|
|
2657
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/json/output-json-sync.js
|
|
2658
|
+
var require_output_json_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2659
|
+
const { stringify } = require_utils();
|
|
2660
|
+
const { outputFileSync } = require_output_file();
|
|
2661
|
+
function outputJsonSync(file, data, options) {
|
|
2662
|
+
outputFileSync(file, stringify(data, options), options);
|
|
2663
|
+
}
|
|
2664
|
+
module.exports = outputJsonSync;
|
|
2665
|
+
}));
|
|
2666
|
+
|
|
2667
|
+
//#endregion
|
|
2668
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/json/index.js
|
|
2669
|
+
var require_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2670
|
+
const u = require_universalify().fromPromise;
|
|
2671
|
+
const jsonFile = require_jsonfile();
|
|
2672
|
+
jsonFile.outputJson = u(require_output_json());
|
|
2673
|
+
jsonFile.outputJsonSync = require_output_json_sync();
|
|
2674
|
+
jsonFile.outputJSON = jsonFile.outputJson;
|
|
2675
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
2676
|
+
jsonFile.writeJSON = jsonFile.writeJson;
|
|
2677
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
2678
|
+
jsonFile.readJSON = jsonFile.readJson;
|
|
2679
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
2680
|
+
module.exports = jsonFile;
|
|
2681
|
+
}));
|
|
2682
|
+
|
|
2683
|
+
//#endregion
|
|
2684
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/move/move.js
|
|
2685
|
+
var require_move$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2686
|
+
const fs = require_fs();
|
|
2687
|
+
const path$2 = __require("path");
|
|
2688
|
+
const { copy } = require_copy();
|
|
2689
|
+
const { remove } = require_remove();
|
|
2690
|
+
const { mkdirp } = require_mkdirs();
|
|
2691
|
+
const { pathExists } = require_path_exists();
|
|
2692
|
+
const stat = require_stat();
|
|
2693
|
+
async function move(src, dest, opts = {}) {
|
|
2694
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2695
|
+
const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
|
|
2696
|
+
await stat.checkParentPaths(src, srcStat, dest, "move");
|
|
2697
|
+
const destParent = path$2.dirname(dest);
|
|
2698
|
+
if (path$2.parse(destParent).root !== destParent) await mkdirp(destParent);
|
|
2699
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
2700
|
+
}
|
|
2701
|
+
async function doRename(src, dest, overwrite, isChangingCase) {
|
|
2702
|
+
if (!isChangingCase) {
|
|
2703
|
+
if (overwrite) await remove(dest);
|
|
2704
|
+
else if (await pathExists(dest)) throw new Error("dest already exists.");
|
|
2705
|
+
}
|
|
2706
|
+
try {
|
|
2707
|
+
await fs.rename(src, dest);
|
|
2708
|
+
} catch (err) {
|
|
2709
|
+
if (err.code !== "EXDEV") throw err;
|
|
2710
|
+
await moveAcrossDevice(src, dest, overwrite);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
async function moveAcrossDevice(src, dest, overwrite) {
|
|
2714
|
+
await copy(src, dest, {
|
|
2715
|
+
overwrite,
|
|
2716
|
+
errorOnExist: true,
|
|
2717
|
+
preserveTimestamps: true
|
|
2718
|
+
});
|
|
2719
|
+
return remove(src);
|
|
2720
|
+
}
|
|
2721
|
+
module.exports = move;
|
|
2722
|
+
}));
|
|
2723
|
+
|
|
2724
|
+
//#endregion
|
|
2725
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/move/move-sync.js
|
|
2726
|
+
var require_move_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2727
|
+
const fs = require_graceful_fs();
|
|
2728
|
+
const path$1 = __require("path");
|
|
2729
|
+
const copySync = require_copy().copySync;
|
|
2730
|
+
const removeSync = require_remove().removeSync;
|
|
2731
|
+
const mkdirpSync = require_mkdirs().mkdirpSync;
|
|
2732
|
+
const stat = require_stat();
|
|
2733
|
+
function moveSync(src, dest, opts) {
|
|
2734
|
+
opts = opts || {};
|
|
2735
|
+
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2736
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
|
2737
|
+
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
|
2738
|
+
if (!isParentRoot(dest)) mkdirpSync(path$1.dirname(dest));
|
|
2739
|
+
return doRename(src, dest, overwrite, isChangingCase);
|
|
2740
|
+
}
|
|
2741
|
+
function isParentRoot(dest) {
|
|
2742
|
+
const parent = path$1.dirname(dest);
|
|
2743
|
+
return path$1.parse(parent).root === parent;
|
|
2744
|
+
}
|
|
2745
|
+
function doRename(src, dest, overwrite, isChangingCase) {
|
|
2746
|
+
if (isChangingCase) return rename(src, dest, overwrite);
|
|
2747
|
+
if (overwrite) {
|
|
2748
|
+
removeSync(dest);
|
|
2749
|
+
return rename(src, dest, overwrite);
|
|
2750
|
+
}
|
|
2751
|
+
if (fs.existsSync(dest)) throw new Error("dest already exists.");
|
|
2752
|
+
return rename(src, dest, overwrite);
|
|
2753
|
+
}
|
|
2754
|
+
function rename(src, dest, overwrite) {
|
|
2755
|
+
try {
|
|
2756
|
+
fs.renameSync(src, dest);
|
|
2757
|
+
} catch (err) {
|
|
2758
|
+
if (err.code !== "EXDEV") throw err;
|
|
2759
|
+
return moveAcrossDevice(src, dest, overwrite);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
function moveAcrossDevice(src, dest, overwrite) {
|
|
2763
|
+
copySync(src, dest, {
|
|
2764
|
+
overwrite,
|
|
2765
|
+
errorOnExist: true,
|
|
2766
|
+
preserveTimestamps: true
|
|
2767
|
+
});
|
|
2768
|
+
return removeSync(src);
|
|
2769
|
+
}
|
|
2770
|
+
module.exports = moveSync;
|
|
2771
|
+
}));
|
|
2772
|
+
|
|
2773
|
+
//#endregion
|
|
2774
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/move/index.js
|
|
2775
|
+
var require_move = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2776
|
+
const u = require_universalify().fromPromise;
|
|
2777
|
+
module.exports = {
|
|
2778
|
+
move: u(require_move$1()),
|
|
2779
|
+
moveSync: require_move_sync()
|
|
2780
|
+
};
|
|
2781
|
+
}));
|
|
2782
|
+
|
|
2783
|
+
//#endregion
|
|
2784
|
+
//#region ../../node_modules/.pnpm/fs-extra@11.3.3/node_modules/fs-extra/lib/esm.mjs
|
|
2785
|
+
var import_copy = /* @__PURE__ */ __toESM(require_copy(), 1);
|
|
2786
|
+
var import_empty = /* @__PURE__ */ __toESM(require_empty(), 1);
|
|
2787
|
+
var import_ensure = /* @__PURE__ */ __toESM(require_ensure(), 1);
|
|
2788
|
+
var import_json = /* @__PURE__ */ __toESM(require_json(), 1);
|
|
2789
|
+
var import_mkdirs = /* @__PURE__ */ __toESM(require_mkdirs(), 1);
|
|
2790
|
+
var import_move = /* @__PURE__ */ __toESM(require_move(), 1);
|
|
2791
|
+
var import_output_file = /* @__PURE__ */ __toESM(require_output_file(), 1);
|
|
2792
|
+
var import_path_exists = /* @__PURE__ */ __toESM(require_path_exists(), 1);
|
|
2793
|
+
var import_remove = /* @__PURE__ */ __toESM(require_remove(), 1);
|
|
2794
|
+
const copy = import_copy.default.copy;
|
|
2795
|
+
const copySync = import_copy.default.copySync;
|
|
2796
|
+
const emptyDirSync = import_empty.default.emptyDirSync;
|
|
2797
|
+
const emptydirSync = import_empty.default.emptydirSync;
|
|
2798
|
+
const emptyDir$1 = import_empty.default.emptyDir;
|
|
2799
|
+
const emptydir = import_empty.default.emptydir;
|
|
2800
|
+
const createFile = import_ensure.default.createFile;
|
|
2801
|
+
const createFileSync = import_ensure.default.createFileSync;
|
|
2802
|
+
const ensureFile = import_ensure.default.ensureFile;
|
|
2803
|
+
const ensureFileSync = import_ensure.default.ensureFileSync;
|
|
2804
|
+
const createLink = import_ensure.default.createLink;
|
|
2805
|
+
const createLinkSync = import_ensure.default.createLinkSync;
|
|
2806
|
+
const ensureLink = import_ensure.default.ensureLink;
|
|
2807
|
+
const ensureLinkSync = import_ensure.default.ensureLinkSync;
|
|
2808
|
+
const createSymlink = import_ensure.default.createSymlink;
|
|
2809
|
+
const createSymlinkSync = import_ensure.default.createSymlinkSync;
|
|
2810
|
+
const ensureSymlink = import_ensure.default.ensureSymlink;
|
|
2811
|
+
const ensureSymlinkSync = import_ensure.default.ensureSymlinkSync;
|
|
2812
|
+
const readJson = import_json.default.readJson;
|
|
2813
|
+
const readJSON$1 = import_json.default.readJSON;
|
|
2814
|
+
const readJsonSync = import_json.default.readJsonSync;
|
|
2815
|
+
const readJSONSync = import_json.default.readJSONSync;
|
|
2816
|
+
const writeJson = import_json.default.writeJson;
|
|
2817
|
+
const writeJSON$1 = import_json.default.writeJSON;
|
|
2818
|
+
const writeJsonSync = import_json.default.writeJsonSync;
|
|
2819
|
+
const writeJSONSync = import_json.default.writeJSONSync;
|
|
2820
|
+
const outputJson = import_json.default.outputJson;
|
|
2821
|
+
const outputJSON = import_json.default.outputJSON;
|
|
2822
|
+
const outputJsonSync = import_json.default.outputJsonSync;
|
|
2823
|
+
const outputJSONSync = import_json.default.outputJSONSync;
|
|
2824
|
+
const mkdirs = import_mkdirs.default.mkdirs;
|
|
2825
|
+
const mkdirsSync = import_mkdirs.default.mkdirsSync;
|
|
2826
|
+
const mkdirp = import_mkdirs.default.mkdirp;
|
|
2827
|
+
const mkdirpSync = import_mkdirs.default.mkdirpSync;
|
|
2828
|
+
const ensureDir = import_mkdirs.default.ensureDir;
|
|
2829
|
+
const ensureDirSync = import_mkdirs.default.ensureDirSync;
|
|
2830
|
+
const move = import_move.default.move;
|
|
2831
|
+
const moveSync = import_move.default.moveSync;
|
|
2832
|
+
const outputFile = import_output_file.default.outputFile;
|
|
2833
|
+
const outputFileSync = import_output_file.default.outputFileSync;
|
|
2834
|
+
const pathExists = import_path_exists.default.pathExists;
|
|
2835
|
+
const pathExistsSync = import_path_exists.default.pathExistsSync;
|
|
2836
|
+
const remove = import_remove.default.remove;
|
|
2837
|
+
const removeSync = import_remove.default.removeSync;
|
|
2838
|
+
var esm_default = {
|
|
2839
|
+
...import_copy.default,
|
|
2840
|
+
...import_empty.default,
|
|
2841
|
+
...import_ensure.default,
|
|
2842
|
+
...import_json.default,
|
|
2843
|
+
...import_mkdirs.default,
|
|
2844
|
+
...import_move.default,
|
|
2845
|
+
...import_output_file.default,
|
|
2846
|
+
...import_path_exists.default,
|
|
2847
|
+
...import_remove.default
|
|
2848
|
+
};
|
|
2849
|
+
|
|
2850
|
+
//#endregion
|
|
2851
|
+
//#region src/utils/packageJson.ts
|
|
2852
|
+
async function getPackageDependencies(packageDir) {
|
|
2853
|
+
const dependenciesList = [];
|
|
2854
|
+
const packageJsonPath = path.join(packageDir, "package.json");
|
|
2855
|
+
try {
|
|
2856
|
+
log.info(`Reading package.json from: ${packageJsonPath}`);
|
|
2857
|
+
const packageJson = await esm_default.readJSON(packageJsonPath);
|
|
2858
|
+
if (packageJson.dependencies) for (const [name, version] of Object.entries(packageJson.dependencies)) dependenciesList.push({
|
|
2859
|
+
name,
|
|
2860
|
+
version,
|
|
2861
|
+
type: "dependencies"
|
|
2862
|
+
});
|
|
2863
|
+
if (packageJson.devDependencies) for (const [name, version] of Object.entries(packageJson.devDependencies)) dependenciesList.push({
|
|
2864
|
+
name,
|
|
2865
|
+
version,
|
|
2866
|
+
type: "devDependencies"
|
|
2867
|
+
});
|
|
2868
|
+
log.info(`Found ${dependenciesList.length} dependencies in ${packageJsonPath}`);
|
|
2869
|
+
return dependenciesList;
|
|
2870
|
+
} catch (err) {
|
|
2871
|
+
handleError(err, `Failed to read or parse package.json at ${packageJsonPath}: `);
|
|
2872
|
+
return [];
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
//#endregion
|
|
2877
|
+
//#region src/utils/promise.ts
|
|
2878
|
+
const nativeExceptions = [
|
|
2879
|
+
EvalError,
|
|
2880
|
+
RangeError,
|
|
2881
|
+
ReferenceError,
|
|
2882
|
+
SyntaxError,
|
|
2883
|
+
TypeError,
|
|
2884
|
+
URIError
|
|
2885
|
+
].filter((except) => typeof except === "function");
|
|
2886
|
+
function throwNative(error) {
|
|
2887
|
+
for (const Exception of nativeExceptions) if (error instanceof Exception) throw error;
|
|
2888
|
+
}
|
|
2889
|
+
const safeAwait = async (promise) => {
|
|
2890
|
+
try {
|
|
2891
|
+
const data = await promise;
|
|
2892
|
+
if (data instanceof Error) {
|
|
2893
|
+
throwNative(data);
|
|
2894
|
+
return [data];
|
|
2895
|
+
}
|
|
2896
|
+
return [void 0, data];
|
|
2897
|
+
} catch (error) {
|
|
2898
|
+
throwNative(error);
|
|
2899
|
+
return [error];
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
|
|
2903
|
+
//#endregion
|
|
2904
|
+
//#region src/utils/prompts.ts
|
|
2905
|
+
const createOptions = (options) => options.map((option) => ({
|
|
2906
|
+
label: option.toString(),
|
|
2907
|
+
value: option
|
|
2908
|
+
}));
|
|
2909
|
+
const createPrompt = (fn) => {
|
|
2910
|
+
return async (options) => {
|
|
2911
|
+
const result = await fn(options);
|
|
2912
|
+
if (isCancel(result)) {
|
|
2913
|
+
cancel("User cancelled");
|
|
2914
|
+
exit(0);
|
|
2915
|
+
}
|
|
2916
|
+
return result;
|
|
2917
|
+
};
|
|
2918
|
+
};
|
|
2919
|
+
const createShowList = createPrompt((options) => {
|
|
2920
|
+
options.map((option) => {
|
|
2921
|
+
return isString(option) ? option : option.label;
|
|
2922
|
+
}).forEach((item) => {
|
|
2923
|
+
log.show(item, { type: "step" });
|
|
2924
|
+
});
|
|
2925
|
+
});
|
|
2926
|
+
const createSearch = ({ message, options }) => {
|
|
2927
|
+
const fuse = new Fuse(options, { keys: ["label"] });
|
|
2928
|
+
return search({
|
|
2929
|
+
message,
|
|
2930
|
+
source: (term) => {
|
|
2931
|
+
if (!term) return options;
|
|
2932
|
+
return fuse.search(term).map(({ item }) => item);
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
};
|
|
2936
|
+
process.on("uncaughtException", (error) => {
|
|
2937
|
+
if (error instanceof Error && error.name === "ExitPromptError") log.show("User cancelled", { type: "error" });
|
|
2938
|
+
else throw error;
|
|
2939
|
+
});
|
|
2940
|
+
const createCheckbox = async (opts) => {
|
|
2941
|
+
const result = await multiselect(opts);
|
|
2942
|
+
if (isCancel(result)) {
|
|
2943
|
+
cancel("User cancelled");
|
|
2944
|
+
exit(0);
|
|
2945
|
+
}
|
|
2946
|
+
return result;
|
|
2947
|
+
};
|
|
2948
|
+
const createNote = ({ message = "", title = "", opts }) => note(message, title, opts);
|
|
2949
|
+
const createConfirm = createPrompt(confirm);
|
|
2950
|
+
const createTasks = createPrompt(tasks);
|
|
2951
|
+
const createSelect = async (opts) => {
|
|
2952
|
+
const result = await select(opts);
|
|
2953
|
+
if (isCancel(result)) {
|
|
2954
|
+
cancel("User cancelled");
|
|
2955
|
+
exit(0);
|
|
2956
|
+
}
|
|
2957
|
+
return result;
|
|
2958
|
+
};
|
|
2959
|
+
const createInput = async (opts) => {
|
|
2960
|
+
const result = await text(opts);
|
|
2961
|
+
if (isCancel(result)) {
|
|
2962
|
+
cancel("User cancelled");
|
|
2963
|
+
exit(0);
|
|
2964
|
+
}
|
|
2965
|
+
return result;
|
|
2966
|
+
};
|
|
2967
|
+
const createGroupMultiSelect = async (opts) => {
|
|
2968
|
+
const result = await groupMultiselect(opts);
|
|
2969
|
+
if (isCancel(result)) {
|
|
2970
|
+
cancel("User cancelled");
|
|
2971
|
+
process.exit(0);
|
|
2972
|
+
}
|
|
2973
|
+
return result;
|
|
2974
|
+
};
|
|
2975
|
+
const createGroup = async (opts) => {
|
|
2976
|
+
const result = await group(opts);
|
|
2977
|
+
if (isCancel(result)) {
|
|
2978
|
+
cancel("User cancelled");
|
|
2979
|
+
exit(0);
|
|
2980
|
+
}
|
|
2981
|
+
return result;
|
|
2982
|
+
};
|
|
2983
|
+
const createSpinner = (message, options) => {
|
|
2984
|
+
const s = spinner(options);
|
|
2985
|
+
s.start(message);
|
|
2986
|
+
return s;
|
|
2987
|
+
};
|
|
2988
|
+
const createTaskLog = (title, options) => taskLog({
|
|
2989
|
+
title,
|
|
2990
|
+
...options
|
|
2991
|
+
});
|
|
2992
|
+
|
|
2993
|
+
//#endregion
|
|
2994
|
+
//#region src/utils/spinner.ts
|
|
2995
|
+
const BASE_OPTIONS = { timeout: 1e4 };
|
|
2996
|
+
const ora = (options) => {
|
|
2997
|
+
if (!isString(options)) return instance(options);
|
|
2998
|
+
return instance({
|
|
2999
|
+
spinner: spinners.circleHalves,
|
|
3000
|
+
text: chalk.green(options)
|
|
3001
|
+
});
|
|
3002
|
+
};
|
|
3003
|
+
|
|
3004
|
+
//#endregion
|
|
3005
|
+
//#region src/utils/workspace.ts
|
|
3006
|
+
async function findWorkspaceRoot(startDir = process.cwd()) {
|
|
3007
|
+
let currentDir = startDir;
|
|
3008
|
+
while (true) try {
|
|
3009
|
+
await fs.access(path.join(currentDir, "pnpm-workspace.yaml"));
|
|
3010
|
+
return currentDir;
|
|
3011
|
+
} catch {
|
|
3012
|
+
const parentDir = path.dirname(currentDir);
|
|
3013
|
+
if (parentDir === currentDir) throw new Error("pnpm-workspace.yaml not found in any parent directory.");
|
|
3014
|
+
currentDir = parentDir;
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
async function getWorkspaceDirs() {
|
|
3018
|
+
const workspaceRoot = await findWorkspaceRoot();
|
|
3019
|
+
try {
|
|
3020
|
+
log.info(`Found workspace root at: ${workspaceRoot}`);
|
|
3021
|
+
const workspaceConfigPath = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
3022
|
+
const configFileContent = await fs.readFile(workspaceConfigPath, "utf8");
|
|
3023
|
+
const workspaceConfig = yaml.parse(configFileContent);
|
|
3024
|
+
if (!workspaceConfig?.packages?.length) {
|
|
3025
|
+
log.warn("No packages defined in pnpm-workspace.yaml or file is empty.");
|
|
3026
|
+
return {
|
|
3027
|
+
root: workspaceRoot,
|
|
3028
|
+
packages: []
|
|
3029
|
+
};
|
|
3030
|
+
}
|
|
3031
|
+
log.info(`Workspace package patterns: ${workspaceConfig.packages.join(", ")}`);
|
|
3032
|
+
const dirs = [];
|
|
3033
|
+
for (const pattern of workspaceConfig.packages) {
|
|
3034
|
+
const packagePaths = await glob(pattern, {
|
|
3035
|
+
cwd: workspaceRoot,
|
|
3036
|
+
absolute: true
|
|
3037
|
+
});
|
|
3038
|
+
dirs.push(...packagePaths);
|
|
3039
|
+
}
|
|
3040
|
+
return {
|
|
3041
|
+
root: workspaceRoot,
|
|
3042
|
+
packages: filterDirList(dirs)
|
|
3043
|
+
};
|
|
3044
|
+
} catch (err) {
|
|
3045
|
+
handleError(err, "Failed to get workspace dirs: ");
|
|
3046
|
+
return {
|
|
3047
|
+
root: workspaceRoot,
|
|
3048
|
+
packages: []
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
async function getWorkspaceNames() {
|
|
3053
|
+
const workspacePackages = [];
|
|
3054
|
+
try {
|
|
3055
|
+
const { root, packages } = await getWorkspaceDirs();
|
|
3056
|
+
for (const packageDir of packages) {
|
|
3057
|
+
const packageJson = readJSON(`${packageDir}/package.json`);
|
|
3058
|
+
if (packageJson) workspacePackages.push({
|
|
3059
|
+
name: packageJson.name,
|
|
3060
|
+
path: path.relative(root, packageDir)
|
|
3061
|
+
});
|
|
3062
|
+
else log.warn(`Skipping directory ${packageDir} as package.json does not contain a name.`);
|
|
3063
|
+
}
|
|
3064
|
+
log.info(`Found ${workspacePackages.length} packages.`);
|
|
3065
|
+
return workspacePackages;
|
|
3066
|
+
} catch (err) {
|
|
3067
|
+
handleError(err, "Failed to get workspace packages: ");
|
|
3068
|
+
return [];
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
|
|
3072
|
+
//#endregion
|
|
3073
|
+
//#region src/index.ts
|
|
3074
|
+
const pkg = readPackage(import.meta, "..");
|
|
3075
|
+
|
|
3076
|
+
//#endregion
|
|
3077
|
+
export { $, BASE_OPTIONS, CONFIG_NAME, Configstore, LOWEST_NODE_VERSION, addFiles, buildCommand, cached, checkCommand, checkFile, clearScreen, clearTerminal, colors, copyFile, createCheckbox, createCommand, createConfirm, createGroup, createGroupMultiSelect, createHelpExample, createInput, createNote, createOptions, createSearch, createSelect, createShowList, createSpinner, createStore, createTaskLog, createTasks, cwdPathname, deleteFile, deleteFiles, dirList, dirname, emptyDir, emptyDirs, exit, fileList, filename, filterDirList, getBrowserApps, getCurrentBranch, getDiffFiles, getGitStatus, getLocalBranches, getPackageDependencies, getWorkspaceDirs, getWorkspaceNames, glob, handleError, has, hasOwn, intro, isArray, isBoolean, isChinese, isDate, isDebug, isEmpty, isEmptyDir, isError, isFormData, isFunction, isMap, isNull, isNumber, isPlainObject, isPromise, isSet, isString, isSymbol, isURLSearchParams, isUndefined, loadConfig, loadEnv, log, logger, openBrowser, openBrowserApp, ora, outro, parseNames, pkg, progress, readFile, readGitignore, readJSON, readPackage, require$1 as require, safeAwait, sleep, stream, writeJSON, x, xASync, zx };
|
|
3078
|
+
//# sourceMappingURL=index.js.map
|