@prisma/migrate 7.1.0-integration-fix-fix-missing-cockroach-wasm.1 → 7.1.0

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.
Files changed (100) hide show
  1. package/dist/CLI.js +2 -2
  2. package/dist/Migrate.js +3 -3
  3. package/dist/SchemaEngineCLI.js +3 -3
  4. package/dist/SchemaEngineWasm.js +3 -3
  5. package/dist/bin.js +32 -32
  6. package/dist/{chunk-DCXZOUQV.js → chunk-2HCAA4GX.js} +5 -5
  7. package/dist/{chunk-N4SBKLAB.js → chunk-4AAXJCSP.js} +16 -13
  8. package/dist/{chunk-TRUKHPCA.js → chunk-53R5LH65.js} +12 -9
  9. package/dist/{chunk-OZ26HKM7.js → chunk-57ZAVRJN.js} +5 -5
  10. package/dist/chunk-AFQKSVOE.js +3448 -0
  11. package/dist/{chunk-DYXUXG3K.js → chunk-DNNMOG7A.js} +5 -5
  12. package/dist/{chunk-AIUUIREM.js → chunk-EVFAYCUY.js} +15 -12
  13. package/dist/{chunk-S4LY555Z.js → chunk-GYEQCQWY.js} +15 -12
  14. package/dist/{chunk-TLHUBVSH.js → chunk-IWYA3D5K.js} +6 -6
  15. package/dist/{chunk-IQWOR45L.js → chunk-JXHYJMP6.js} +13 -10
  16. package/dist/{chunk-CQ6GMT2G.js → chunk-KZ7D4LBR.js} +10 -6
  17. package/dist/{chunk-ENVEA7LT.js → chunk-NSNXCZ53.js} +7 -7
  18. package/dist/{chunk-QAOWTYGM.js → chunk-OY3MHWEZ.js} +15 -12
  19. package/dist/{chunk-IVL273O6.js → chunk-RRCQPFON.js} +13 -10
  20. package/dist/{chunk-FEUKQ7J3.js → chunk-S3AXZP6Y.js} +14 -11
  21. package/dist/{chunk-OAHBNV3B.js → chunk-TXQI3C4H.js} +5 -5
  22. package/dist/{chunk-3MCWUFUJ.js → chunk-WRBJ3RMF.js} +5 -5
  23. package/dist/{chunk-7BNYLV6P.js → chunk-ZMOMF2GJ.js} +6 -6
  24. package/dist/{chunk-XGTVKL4L.js → chunk-ZUHJASAP.js} +5 -5
  25. package/dist/commands/DbCommand.js +2 -2
  26. package/dist/commands/DbDrop.js +3 -3
  27. package/dist/commands/DbExecute.js +4 -4
  28. package/dist/commands/DbPull.js +5 -5
  29. package/dist/commands/DbPush.js +5 -5
  30. package/dist/commands/MigrateCommand.js +2 -2
  31. package/dist/commands/MigrateDeploy.js +4 -4
  32. package/dist/commands/MigrateDev.js +5 -5
  33. package/dist/commands/MigrateDiff.js +5 -5
  34. package/dist/commands/MigrateReset.js +5 -5
  35. package/dist/commands/MigrateResolve.js +4 -4
  36. package/dist/commands/MigrateStatus.js +4 -4
  37. package/dist/index.js +35 -35
  38. package/dist/{migrate/src → src}/CLI.d.ts +1 -1
  39. package/dist/{migrate/src → src}/Migrate.d.ts +1 -1
  40. package/dist/{migrate/src → src}/SchemaEngineCLI.d.ts +2 -2
  41. package/dist/{migrate/src → src}/commands/DbCommand.d.ts +1 -1
  42. package/dist/{migrate/src → src}/commands/DbDrop.d.ts +1 -1
  43. package/dist/{migrate/src → src}/commands/DbExecute.d.ts +1 -1
  44. package/dist/{migrate/src → src}/commands/DbPull.d.ts +1 -1
  45. package/dist/{migrate/src → src}/commands/DbPush.d.ts +1 -1
  46. package/dist/{migrate/src → src}/commands/MigrateCommand.d.ts +1 -1
  47. package/dist/{migrate/src → src}/commands/MigrateDeploy.d.ts +1 -1
  48. package/dist/{migrate/src → src}/commands/MigrateDev.d.ts +1 -1
  49. package/dist/{migrate/src → src}/commands/MigrateDiff.d.ts +1 -1
  50. package/dist/{migrate/src → src}/commands/MigrateReset.d.ts +1 -1
  51. package/dist/{migrate/src → src}/commands/MigrateResolve.d.ts +1 -1
  52. package/dist/{migrate/src → src}/commands/MigrateStatus.d.ts +1 -1
  53. package/dist/{migrate/src → src}/utils/getDatabaseVersionSafe.d.ts +1 -1
  54. package/dist/{migrate/src → src}/utils/introspectSql.d.ts +1 -1
  55. package/dist/utils/errors.js +8 -8
  56. package/dist/utils/getDatabaseVersionSafe.js +4 -4
  57. package/dist/utils/introspectSql.js +4 -4
  58. package/package.json +10 -10
  59. package/dist/chunk-XFASRSQR.js +0 -5917
  60. package/dist/internals/src/cli/getSchema.d.ts +0 -24
  61. package/dist/internals/src/utils/schemaFileInput.d.ts +0 -5
  62. /package/dist/{migrate/src → src}/SchemaEngine.d.ts +0 -0
  63. /package/dist/{migrate/src → src}/SchemaEngineWasm.d.ts +0 -0
  64. /package/dist/{migrate/src → src}/bin.d.ts +0 -0
  65. /package/dist/{migrate/src → src}/commands/DbSeed.d.ts +0 -0
  66. /package/dist/{migrate/src → src}/extensions.d.ts +0 -0
  67. /package/dist/{migrate/src → src}/index.d.ts +0 -0
  68. /package/dist/{migrate/src → src}/types.d.ts +0 -0
  69. /package/dist/{migrate/src → src}/utils/ai-safety.d.ts +0 -0
  70. /package/dist/{migrate/src → src}/utils/byline.d.ts +0 -0
  71. /package/dist/{migrate/src → src}/utils/captureStdout.d.ts +0 -0
  72. /package/dist/{migrate/src → src}/utils/countModelsAndTypes.d.ts +0 -0
  73. /package/dist/{migrate/src → src}/utils/createMigration.d.ts +0 -0
  74. /package/dist/{migrate/src → src}/utils/customColors.d.ts +0 -0
  75. /package/dist/{migrate/src → src}/utils/ensureDatabaseExists.d.ts +0 -0
  76. /package/dist/{migrate/src → src}/utils/errors.d.ts +0 -0
  77. /package/dist/{migrate/src → src}/utils/flagErrors.d.ts +0 -0
  78. /package/dist/{migrate/src → src}/utils/handleEvaluateDataloss.d.ts +0 -0
  79. /package/dist/{migrate/src → src}/utils/isSchemaEmpty.d.ts +0 -0
  80. /package/dist/{migrate/src → src}/utils/listMigrations.d.ts +0 -0
  81. /package/dist/{migrate/src → src}/utils/now.d.ts +0 -0
  82. /package/dist/{migrate/src → src}/utils/printDatasource.d.ts +0 -0
  83. /package/dist/{migrate/src → src}/utils/printDatasources.d.ts +0 -0
  84. /package/dist/{migrate/src → src}/utils/printFiles.d.ts +0 -0
  85. /package/dist/{migrate/src → src}/utils/printIntrospectedSchema.d.ts +0 -0
  86. /package/dist/{migrate/src → src}/utils/printMigrationId.d.ts +0 -0
  87. /package/dist/{migrate/src → src}/utils/promptForMigrationName.d.ts +0 -0
  88. /package/dist/{migrate/src → src}/utils/removeSchemaFiles.d.ts +0 -0
  89. /package/dist/{migrate/src → src}/utils/saveSchemaFiles.d.ts +0 -0
  90. /package/dist/{migrate/src → src}/utils/seed.d.ts +0 -0
  91. /package/dist/{migrate/src → src}/utils/setupCockroach.d.ts +0 -0
  92. /package/dist/{migrate/src → src}/utils/setupMSSQL.d.ts +0 -0
  93. /package/dist/{migrate/src → src}/utils/setupMongo.d.ts +0 -0
  94. /package/dist/{migrate/src → src}/utils/setupMysql.d.ts +0 -0
  95. /package/dist/{migrate/src → src}/utils/setupPostgres.d.ts +0 -0
  96. /package/dist/{migrate/src → src}/utils/spinner.d.ts +0 -0
  97. /package/dist/{migrate/src → src}/utils/test-SchemaEngineCommands.d.ts +0 -0
  98. /package/dist/{migrate/src → src}/utils/test-handlePanic.d.ts +0 -0
  99. /package/dist/{migrate/src → src}/utils/unixSocket.d.ts +0 -0
  100. /package/dist/{migrate/src → src}/views/handleViewsIO.d.ts +0 -0
@@ -0,0 +1,3448 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_AFQKSVOE_exports = {};
30
+ __export(chunk_AFQKSVOE_exports, {
31
+ MigrateDiff: () => MigrateDiff,
32
+ getRemovedTargetParameterHint: () => getRemovedTargetParameterHint
33
+ });
34
+ module.exports = __toCommonJS(chunk_AFQKSVOE_exports);
35
+ var import_chunk_VAJ4VX67 = require("./chunk-VAJ4VX67.js");
36
+ var import_chunk_WRBJ3RMF = require("./chunk-WRBJ3RMF.js");
37
+ var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
38
+ var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
39
+ var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
40
+ var import_debug = __toESM(require("@prisma/debug"));
41
+ var import_internals = require("@prisma/internals");
42
+ var import_path = __toESM(require("path"));
43
+ var require_promisify = (0, import_chunk_2ESYSVXG.__commonJS)({
44
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/utils/promisify.js"(exports, module2) {
45
+ "use strict";
46
+ module2.exports = (fn) => {
47
+ return function() {
48
+ const length = arguments.length;
49
+ const args = new Array(length);
50
+ for (let i = 0; i < length; i += 1) {
51
+ args[i] = arguments[i];
52
+ }
53
+ return new Promise((resolve, reject) => {
54
+ args.push((err, data) => {
55
+ if (err) {
56
+ reject(err);
57
+ } else {
58
+ resolve(data);
59
+ }
60
+ });
61
+ fn.apply(null, args);
62
+ });
63
+ };
64
+ };
65
+ }
66
+ });
67
+ var require_fs = (0, import_chunk_2ESYSVXG.__commonJS)({
68
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/utils/fs.js"(exports, module2) {
69
+ "use strict";
70
+ var fs2 = (0, import_chunk_2ESYSVXG.__require)("fs");
71
+ var promisify = require_promisify();
72
+ var isCallbackMethod = (key) => {
73
+ return [
74
+ typeof fs2[key] === "function",
75
+ !key.match(/Sync$/),
76
+ !key.match(/^[A-Z]/),
77
+ !key.match(/^create/),
78
+ !key.match(/^(un)?watch/)
79
+ ].every(Boolean);
80
+ };
81
+ var adaptMethod = (name) => {
82
+ const original = fs2[name];
83
+ return promisify(original);
84
+ };
85
+ var adaptAllMethods = () => {
86
+ const adapted = {};
87
+ Object.keys(fs2).forEach((key) => {
88
+ if (isCallbackMethod(key)) {
89
+ if (key === "exists") {
90
+ adapted.exists = () => {
91
+ throw new Error("fs.exists() is deprecated");
92
+ };
93
+ } else {
94
+ adapted[key] = adaptMethod(key);
95
+ }
96
+ } else {
97
+ adapted[key] = fs2[key];
98
+ }
99
+ });
100
+ return adapted;
101
+ };
102
+ module2.exports = adaptAllMethods();
103
+ }
104
+ });
105
+ var require_validate = (0, import_chunk_2ESYSVXG.__commonJS)({
106
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/utils/validate.js"(exports, module2) {
107
+ "use strict";
108
+ var prettyPrintTypes = (types) => {
109
+ const addArticle = (str) => {
110
+ const vowels = ["a", "e", "i", "o", "u"];
111
+ if (vowels.indexOf(str[0]) !== -1) {
112
+ return `an ${str}`;
113
+ }
114
+ return `a ${str}`;
115
+ };
116
+ return types.map(addArticle).join(" or ");
117
+ };
118
+ var isArrayOfNotation = (typeDefinition) => {
119
+ return /array of /.test(typeDefinition);
120
+ };
121
+ var extractTypeFromArrayOfNotation = (typeDefinition) => {
122
+ return typeDefinition.split(" of ")[1];
123
+ };
124
+ var isValidTypeDefinition = (typeStr) => {
125
+ if (isArrayOfNotation(typeStr)) {
126
+ return isValidTypeDefinition(extractTypeFromArrayOfNotation(typeStr));
127
+ }
128
+ return [
129
+ "string",
130
+ "number",
131
+ "boolean",
132
+ "array",
133
+ "object",
134
+ "buffer",
135
+ "null",
136
+ "undefined",
137
+ "function"
138
+ ].some((validType) => {
139
+ return validType === typeStr;
140
+ });
141
+ };
142
+ var detectType = (value) => {
143
+ if (value === null) {
144
+ return "null";
145
+ }
146
+ if (Array.isArray(value)) {
147
+ return "array";
148
+ }
149
+ if (Buffer.isBuffer(value)) {
150
+ return "buffer";
151
+ }
152
+ return typeof value;
153
+ };
154
+ var onlyUniqueValuesInArrayFilter = (value, index, self) => {
155
+ return self.indexOf(value) === index;
156
+ };
157
+ var detectTypeDeep = (value) => {
158
+ let type = detectType(value);
159
+ let typesInArray;
160
+ if (type === "array") {
161
+ typesInArray = value.map((element) => {
162
+ return detectType(element);
163
+ }).filter(onlyUniqueValuesInArrayFilter);
164
+ type += ` of ${typesInArray.join(", ")}`;
165
+ }
166
+ return type;
167
+ };
168
+ var validateArray = (argumentValue, typeToCheck) => {
169
+ const allowedTypeInArray = extractTypeFromArrayOfNotation(typeToCheck);
170
+ if (detectType(argumentValue) !== "array") {
171
+ return false;
172
+ }
173
+ return argumentValue.every((element) => {
174
+ return detectType(element) === allowedTypeInArray;
175
+ });
176
+ };
177
+ var validateArgument = (methodName, argumentName, argumentValue, argumentMustBe) => {
178
+ const isOneOfAllowedTypes = argumentMustBe.some((type) => {
179
+ if (!isValidTypeDefinition(type)) {
180
+ throw new Error(`Unknown type "${type}"`);
181
+ }
182
+ if (isArrayOfNotation(type)) {
183
+ return validateArray(argumentValue, type);
184
+ }
185
+ return type === detectType(argumentValue);
186
+ });
187
+ if (!isOneOfAllowedTypes) {
188
+ throw new Error(
189
+ `Argument "${argumentName}" passed to ${methodName} must be ${prettyPrintTypes(
190
+ argumentMustBe
191
+ )}. Received ${detectTypeDeep(argumentValue)}`
192
+ );
193
+ }
194
+ };
195
+ var validateOptions = (methodName, optionsObjName, obj, allowedOptions) => {
196
+ if (obj !== void 0) {
197
+ validateArgument(methodName, optionsObjName, obj, ["object"]);
198
+ Object.keys(obj).forEach((key) => {
199
+ const argName = `${optionsObjName}.${key}`;
200
+ if (allowedOptions[key] !== void 0) {
201
+ validateArgument(methodName, argName, obj[key], allowedOptions[key]);
202
+ } else {
203
+ throw new Error(
204
+ `Unknown argument "${argName}" passed to ${methodName}`
205
+ );
206
+ }
207
+ });
208
+ }
209
+ };
210
+ module2.exports = {
211
+ argument: validateArgument,
212
+ options: validateOptions
213
+ };
214
+ }
215
+ });
216
+ var require_mode = (0, import_chunk_2ESYSVXG.__commonJS)({
217
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/utils/mode.js"(exports) {
218
+ "use strict";
219
+ exports.normalizeFileMode = (mode) => {
220
+ let modeAsString;
221
+ if (typeof mode === "number") {
222
+ modeAsString = mode.toString(8);
223
+ } else {
224
+ modeAsString = mode;
225
+ }
226
+ return modeAsString.substring(modeAsString.length - 3);
227
+ };
228
+ }
229
+ });
230
+ var require_remove = (0, import_chunk_2ESYSVXG.__commonJS)({
231
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/remove.js"(exports) {
232
+ "use strict";
233
+ var fs2 = require_fs();
234
+ var validate = require_validate();
235
+ var validateInput = (methodName, path2) => {
236
+ const methodSignature = `${methodName}([path])`;
237
+ validate.argument(methodSignature, "path", path2, ["string", "undefined"]);
238
+ };
239
+ var removeSync = (path2) => {
240
+ fs2.rmSync(path2, {
241
+ recursive: true,
242
+ force: true,
243
+ maxRetries: 3
244
+ });
245
+ };
246
+ var removeAsync = (path2) => {
247
+ return fs2.rm(path2, {
248
+ recursive: true,
249
+ force: true,
250
+ maxRetries: 3
251
+ });
252
+ };
253
+ exports.validateInput = validateInput;
254
+ exports.sync = removeSync;
255
+ exports.async = removeAsync;
256
+ }
257
+ });
258
+ var require_dir = (0, import_chunk_2ESYSVXG.__commonJS)({
259
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/dir.js"(exports) {
260
+ "use strict";
261
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
262
+ var fs2 = require_fs();
263
+ var modeUtil = require_mode();
264
+ var validate = require_validate();
265
+ var remove = require_remove();
266
+ var validateInput = (methodName, path2, criteria) => {
267
+ const methodSignature = `${methodName}(path, [criteria])`;
268
+ validate.argument(methodSignature, "path", path2, ["string"]);
269
+ validate.options(methodSignature, "criteria", criteria, {
270
+ empty: ["boolean"],
271
+ mode: ["string", "number"]
272
+ });
273
+ };
274
+ var getCriteriaDefaults = (passedCriteria) => {
275
+ const criteria = passedCriteria || {};
276
+ if (typeof criteria.empty !== "boolean") {
277
+ criteria.empty = false;
278
+ }
279
+ if (criteria.mode !== void 0) {
280
+ criteria.mode = modeUtil.normalizeFileMode(criteria.mode);
281
+ }
282
+ return criteria;
283
+ };
284
+ var generatePathOccupiedByNotDirectoryError = (path2) => {
285
+ return new Error(
286
+ `Path ${path2} exists but is not a directory. Halting jetpack.dir() call for safety reasons.`
287
+ );
288
+ };
289
+ var checkWhatAlreadyOccupiesPathSync = (path2) => {
290
+ let stat;
291
+ try {
292
+ stat = fs2.statSync(path2);
293
+ } catch (err) {
294
+ if (err.code !== "ENOENT") {
295
+ throw err;
296
+ }
297
+ }
298
+ if (stat && !stat.isDirectory()) {
299
+ throw generatePathOccupiedByNotDirectoryError(path2);
300
+ }
301
+ return stat;
302
+ };
303
+ var createBrandNewDirectorySync = (path2, opts) => {
304
+ const options = opts || {};
305
+ try {
306
+ fs2.mkdirSync(path2, options.mode);
307
+ } catch (err) {
308
+ if (err.code === "ENOENT") {
309
+ createBrandNewDirectorySync(pathUtil.dirname(path2), options);
310
+ fs2.mkdirSync(path2, options.mode);
311
+ } else if (err.code === "EEXIST") {
312
+ } else {
313
+ throw err;
314
+ }
315
+ }
316
+ };
317
+ var checkExistingDirectoryFulfillsCriteriaSync = (path2, stat, criteria) => {
318
+ const checkMode = () => {
319
+ const mode = modeUtil.normalizeFileMode(stat.mode);
320
+ if (criteria.mode !== void 0 && criteria.mode !== mode) {
321
+ fs2.chmodSync(path2, criteria.mode);
322
+ }
323
+ };
324
+ const checkEmptiness = () => {
325
+ if (criteria.empty) {
326
+ const list = fs2.readdirSync(path2);
327
+ list.forEach((filename) => {
328
+ remove.sync(pathUtil.resolve(path2, filename));
329
+ });
330
+ }
331
+ };
332
+ checkMode();
333
+ checkEmptiness();
334
+ };
335
+ var dirSync = (path2, passedCriteria) => {
336
+ const criteria = getCriteriaDefaults(passedCriteria);
337
+ const stat = checkWhatAlreadyOccupiesPathSync(path2);
338
+ if (stat) {
339
+ checkExistingDirectoryFulfillsCriteriaSync(path2, stat, criteria);
340
+ } else {
341
+ createBrandNewDirectorySync(path2, criteria);
342
+ }
343
+ };
344
+ var checkWhatAlreadyOccupiesPathAsync = (path2) => {
345
+ return new Promise((resolve, reject) => {
346
+ fs2.stat(path2).then((stat) => {
347
+ if (stat.isDirectory()) {
348
+ resolve(stat);
349
+ } else {
350
+ reject(generatePathOccupiedByNotDirectoryError(path2));
351
+ }
352
+ }).catch((err) => {
353
+ if (err.code === "ENOENT") {
354
+ resolve(void 0);
355
+ } else {
356
+ reject(err);
357
+ }
358
+ });
359
+ });
360
+ };
361
+ var emptyAsync = (path2) => {
362
+ return new Promise((resolve, reject) => {
363
+ fs2.readdir(path2).then((list) => {
364
+ const doOne = (index) => {
365
+ if (index === list.length) {
366
+ resolve();
367
+ } else {
368
+ const subPath = pathUtil.resolve(path2, list[index]);
369
+ remove.async(subPath).then(() => {
370
+ doOne(index + 1);
371
+ });
372
+ }
373
+ };
374
+ doOne(0);
375
+ }).catch(reject);
376
+ });
377
+ };
378
+ var checkExistingDirectoryFulfillsCriteriaAsync = (path2, stat, criteria) => {
379
+ return new Promise((resolve, reject) => {
380
+ const checkMode = () => {
381
+ const mode = modeUtil.normalizeFileMode(stat.mode);
382
+ if (criteria.mode !== void 0 && criteria.mode !== mode) {
383
+ return fs2.chmod(path2, criteria.mode);
384
+ }
385
+ return Promise.resolve();
386
+ };
387
+ const checkEmptiness = () => {
388
+ if (criteria.empty) {
389
+ return emptyAsync(path2);
390
+ }
391
+ return Promise.resolve();
392
+ };
393
+ checkMode().then(checkEmptiness).then(resolve, reject);
394
+ });
395
+ };
396
+ var createBrandNewDirectoryAsync = (path2, opts) => {
397
+ const options = opts || {};
398
+ return new Promise((resolve, reject) => {
399
+ fs2.mkdir(path2, options.mode).then(resolve).catch((err) => {
400
+ if (err.code === "ENOENT") {
401
+ createBrandNewDirectoryAsync(pathUtil.dirname(path2), options).then(() => {
402
+ return fs2.mkdir(path2, options.mode);
403
+ }).then(resolve).catch((err2) => {
404
+ if (err2.code === "EEXIST") {
405
+ resolve();
406
+ } else {
407
+ reject(err2);
408
+ }
409
+ });
410
+ } else if (err.code === "EEXIST") {
411
+ resolve();
412
+ } else {
413
+ reject(err);
414
+ }
415
+ });
416
+ });
417
+ };
418
+ var dirAsync = (path2, passedCriteria) => {
419
+ return new Promise((resolve, reject) => {
420
+ const criteria = getCriteriaDefaults(passedCriteria);
421
+ checkWhatAlreadyOccupiesPathAsync(path2).then((stat) => {
422
+ if (stat !== void 0) {
423
+ return checkExistingDirectoryFulfillsCriteriaAsync(
424
+ path2,
425
+ stat,
426
+ criteria
427
+ );
428
+ }
429
+ return createBrandNewDirectoryAsync(path2, criteria);
430
+ }).then(resolve, reject);
431
+ });
432
+ };
433
+ exports.validateInput = validateInput;
434
+ exports.sync = dirSync;
435
+ exports.createSync = createBrandNewDirectorySync;
436
+ exports.async = dirAsync;
437
+ exports.createAsync = createBrandNewDirectoryAsync;
438
+ }
439
+ });
440
+ var require_write = (0, import_chunk_2ESYSVXG.__commonJS)({
441
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/write.js"(exports) {
442
+ "use strict";
443
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
444
+ var fs2 = require_fs();
445
+ var validate = require_validate();
446
+ var dir = require_dir();
447
+ var validateInput = (methodName, path2, data, options) => {
448
+ const methodSignature = `${methodName}(path, data, [options])`;
449
+ validate.argument(methodSignature, "path", path2, ["string"]);
450
+ validate.argument(methodSignature, "data", data, [
451
+ "string",
452
+ "buffer",
453
+ "object",
454
+ "array"
455
+ ]);
456
+ validate.options(methodSignature, "options", options, {
457
+ mode: ["string", "number"],
458
+ atomic: ["boolean"],
459
+ jsonIndent: ["number"]
460
+ });
461
+ };
462
+ var newExt = ".__new__";
463
+ var serializeToJsonMaybe = (data, jsonIndent) => {
464
+ let indent = jsonIndent;
465
+ if (typeof indent !== "number") {
466
+ indent = 2;
467
+ }
468
+ if (typeof data === "object" && !Buffer.isBuffer(data) && data !== null) {
469
+ return JSON.stringify(data, null, indent);
470
+ }
471
+ return data;
472
+ };
473
+ var writeFileSync = (path2, data, options) => {
474
+ try {
475
+ fs2.writeFileSync(path2, data, options);
476
+ } catch (err) {
477
+ if (err.code === "ENOENT") {
478
+ dir.createSync(pathUtil.dirname(path2));
479
+ fs2.writeFileSync(path2, data, options);
480
+ } else {
481
+ throw err;
482
+ }
483
+ }
484
+ };
485
+ var writeAtomicSync = (path2, data, options) => {
486
+ writeFileSync(path2 + newExt, data, options);
487
+ fs2.renameSync(path2 + newExt, path2);
488
+ };
489
+ var writeSync = (path2, data, options) => {
490
+ const opts = options || {};
491
+ const processedData = serializeToJsonMaybe(data, opts.jsonIndent);
492
+ let writeStrategy = writeFileSync;
493
+ if (opts.atomic) {
494
+ writeStrategy = writeAtomicSync;
495
+ }
496
+ writeStrategy(path2, processedData, { mode: opts.mode });
497
+ };
498
+ var writeFileAsync = (path2, data, options) => {
499
+ return new Promise((resolve, reject) => {
500
+ fs2.writeFile(path2, data, options).then(resolve).catch((err) => {
501
+ if (err.code === "ENOENT") {
502
+ dir.createAsync(pathUtil.dirname(path2)).then(() => {
503
+ return fs2.writeFile(path2, data, options);
504
+ }).then(resolve, reject);
505
+ } else {
506
+ reject(err);
507
+ }
508
+ });
509
+ });
510
+ };
511
+ var writeAtomicAsync = (path2, data, options) => {
512
+ return new Promise((resolve, reject) => {
513
+ writeFileAsync(path2 + newExt, data, options).then(() => {
514
+ return fs2.rename(path2 + newExt, path2);
515
+ }).then(resolve, reject);
516
+ });
517
+ };
518
+ var writeAsync = (path2, data, options) => {
519
+ const opts = options || {};
520
+ const processedData = serializeToJsonMaybe(data, opts.jsonIndent);
521
+ let writeStrategy = writeFileAsync;
522
+ if (opts.atomic) {
523
+ writeStrategy = writeAtomicAsync;
524
+ }
525
+ return writeStrategy(path2, processedData, { mode: opts.mode });
526
+ };
527
+ exports.validateInput = validateInput;
528
+ exports.sync = writeSync;
529
+ exports.async = writeAsync;
530
+ }
531
+ });
532
+ var require_append = (0, import_chunk_2ESYSVXG.__commonJS)({
533
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/append.js"(exports) {
534
+ "use strict";
535
+ var fs2 = require_fs();
536
+ var write = require_write();
537
+ var validate = require_validate();
538
+ var validateInput = (methodName, path2, data, options) => {
539
+ const methodSignature = `${methodName}(path, data, [options])`;
540
+ validate.argument(methodSignature, "path", path2, ["string"]);
541
+ validate.argument(methodSignature, "data", data, ["string", "buffer"]);
542
+ validate.options(methodSignature, "options", options, {
543
+ mode: ["string", "number"]
544
+ });
545
+ };
546
+ var appendSync = (path2, data, options) => {
547
+ try {
548
+ fs2.appendFileSync(path2, data, options);
549
+ } catch (err) {
550
+ if (err.code === "ENOENT") {
551
+ write.sync(path2, data, options);
552
+ } else {
553
+ throw err;
554
+ }
555
+ }
556
+ };
557
+ var appendAsync = (path2, data, options) => {
558
+ return new Promise((resolve, reject) => {
559
+ fs2.appendFile(path2, data, options).then(resolve).catch((err) => {
560
+ if (err.code === "ENOENT") {
561
+ write.async(path2, data, options).then(resolve, reject);
562
+ } else {
563
+ reject(err);
564
+ }
565
+ });
566
+ });
567
+ };
568
+ exports.validateInput = validateInput;
569
+ exports.sync = appendSync;
570
+ exports.async = appendAsync;
571
+ }
572
+ });
573
+ var require_file = (0, import_chunk_2ESYSVXG.__commonJS)({
574
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/file.js"(exports) {
575
+ "use strict";
576
+ var fs2 = require_fs();
577
+ var modeUtil = require_mode();
578
+ var validate = require_validate();
579
+ var write = require_write();
580
+ var validateInput = (methodName, path2, criteria) => {
581
+ const methodSignature = `${methodName}(path, [criteria])`;
582
+ validate.argument(methodSignature, "path", path2, ["string"]);
583
+ validate.options(methodSignature, "criteria", criteria, {
584
+ content: ["string", "buffer", "object", "array"],
585
+ jsonIndent: ["number"],
586
+ mode: ["string", "number"]
587
+ });
588
+ };
589
+ var getCriteriaDefaults = (passedCriteria) => {
590
+ const criteria = passedCriteria || {};
591
+ if (criteria.mode !== void 0) {
592
+ criteria.mode = modeUtil.normalizeFileMode(criteria.mode);
593
+ }
594
+ return criteria;
595
+ };
596
+ var generatePathOccupiedByNotFileError = (path2) => {
597
+ return new Error(
598
+ `Path ${path2} exists but is not a file. Halting jetpack.file() call for safety reasons.`
599
+ );
600
+ };
601
+ var checkWhatAlreadyOccupiesPathSync = (path2) => {
602
+ let stat;
603
+ try {
604
+ stat = fs2.statSync(path2);
605
+ } catch (err) {
606
+ if (err.code !== "ENOENT") {
607
+ throw err;
608
+ }
609
+ }
610
+ if (stat && !stat.isFile()) {
611
+ throw generatePathOccupiedByNotFileError(path2);
612
+ }
613
+ return stat;
614
+ };
615
+ var checkExistingFileFulfillsCriteriaSync = (path2, stat, criteria) => {
616
+ const mode = modeUtil.normalizeFileMode(stat.mode);
617
+ const checkContent = () => {
618
+ if (criteria.content !== void 0) {
619
+ write.sync(path2, criteria.content, {
620
+ mode,
621
+ jsonIndent: criteria.jsonIndent
622
+ });
623
+ return true;
624
+ }
625
+ return false;
626
+ };
627
+ const checkMode = () => {
628
+ if (criteria.mode !== void 0 && criteria.mode !== mode) {
629
+ fs2.chmodSync(path2, criteria.mode);
630
+ }
631
+ };
632
+ const contentReplaced = checkContent();
633
+ if (!contentReplaced) {
634
+ checkMode();
635
+ }
636
+ };
637
+ var createBrandNewFileSync = (path2, criteria) => {
638
+ let content = "";
639
+ if (criteria.content !== void 0) {
640
+ content = criteria.content;
641
+ }
642
+ write.sync(path2, content, {
643
+ mode: criteria.mode,
644
+ jsonIndent: criteria.jsonIndent
645
+ });
646
+ };
647
+ var fileSync = (path2, passedCriteria) => {
648
+ const criteria = getCriteriaDefaults(passedCriteria);
649
+ const stat = checkWhatAlreadyOccupiesPathSync(path2);
650
+ if (stat !== void 0) {
651
+ checkExistingFileFulfillsCriteriaSync(path2, stat, criteria);
652
+ } else {
653
+ createBrandNewFileSync(path2, criteria);
654
+ }
655
+ };
656
+ var checkWhatAlreadyOccupiesPathAsync = (path2) => {
657
+ return new Promise((resolve, reject) => {
658
+ fs2.stat(path2).then((stat) => {
659
+ if (stat.isFile()) {
660
+ resolve(stat);
661
+ } else {
662
+ reject(generatePathOccupiedByNotFileError(path2));
663
+ }
664
+ }).catch((err) => {
665
+ if (err.code === "ENOENT") {
666
+ resolve(void 0);
667
+ } else {
668
+ reject(err);
669
+ }
670
+ });
671
+ });
672
+ };
673
+ var checkExistingFileFulfillsCriteriaAsync = (path2, stat, criteria) => {
674
+ const mode = modeUtil.normalizeFileMode(stat.mode);
675
+ const checkContent = () => {
676
+ return new Promise((resolve, reject) => {
677
+ if (criteria.content !== void 0) {
678
+ write.async(path2, criteria.content, {
679
+ mode,
680
+ jsonIndent: criteria.jsonIndent
681
+ }).then(() => {
682
+ resolve(true);
683
+ }).catch(reject);
684
+ } else {
685
+ resolve(false);
686
+ }
687
+ });
688
+ };
689
+ const checkMode = () => {
690
+ if (criteria.mode !== void 0 && criteria.mode !== mode) {
691
+ return fs2.chmod(path2, criteria.mode);
692
+ }
693
+ return void 0;
694
+ };
695
+ return checkContent().then((contentReplaced) => {
696
+ if (!contentReplaced) {
697
+ return checkMode();
698
+ }
699
+ return void 0;
700
+ });
701
+ };
702
+ var createBrandNewFileAsync = (path2, criteria) => {
703
+ let content = "";
704
+ if (criteria.content !== void 0) {
705
+ content = criteria.content;
706
+ }
707
+ return write.async(path2, content, {
708
+ mode: criteria.mode,
709
+ jsonIndent: criteria.jsonIndent
710
+ });
711
+ };
712
+ var fileAsync = (path2, passedCriteria) => {
713
+ return new Promise((resolve, reject) => {
714
+ const criteria = getCriteriaDefaults(passedCriteria);
715
+ checkWhatAlreadyOccupiesPathAsync(path2).then((stat) => {
716
+ if (stat !== void 0) {
717
+ return checkExistingFileFulfillsCriteriaAsync(path2, stat, criteria);
718
+ }
719
+ return createBrandNewFileAsync(path2, criteria);
720
+ }).then(resolve, reject);
721
+ });
722
+ };
723
+ exports.validateInput = validateInput;
724
+ exports.sync = fileSync;
725
+ exports.async = fileAsync;
726
+ }
727
+ });
728
+ var require_inspect = (0, import_chunk_2ESYSVXG.__commonJS)({
729
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/inspect.js"(exports) {
730
+ "use strict";
731
+ var crypto = (0, import_chunk_2ESYSVXG.__require)("crypto");
732
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
733
+ var fs2 = require_fs();
734
+ var validate = require_validate();
735
+ var supportedChecksumAlgorithms = ["md5", "sha1", "sha256", "sha512"];
736
+ var symlinkOptions = ["report", "follow"];
737
+ var validateInput = (methodName, path2, options) => {
738
+ const methodSignature = `${methodName}(path, [options])`;
739
+ validate.argument(methodSignature, "path", path2, ["string"]);
740
+ validate.options(methodSignature, "options", options, {
741
+ checksum: ["string"],
742
+ mode: ["boolean"],
743
+ times: ["boolean"],
744
+ absolutePath: ["boolean"],
745
+ symlinks: ["string"]
746
+ });
747
+ if (options && options.checksum !== void 0 && supportedChecksumAlgorithms.indexOf(options.checksum) === -1) {
748
+ throw new Error(
749
+ `Argument "options.checksum" passed to ${methodSignature} must have one of values: ${supportedChecksumAlgorithms.join(
750
+ ", "
751
+ )}`
752
+ );
753
+ }
754
+ if (options && options.symlinks !== void 0 && symlinkOptions.indexOf(options.symlinks) === -1) {
755
+ throw new Error(
756
+ `Argument "options.symlinks" passed to ${methodSignature} must have one of values: ${symlinkOptions.join(
757
+ ", "
758
+ )}`
759
+ );
760
+ }
761
+ };
762
+ var createInspectObj = (path2, options, stat) => {
763
+ const obj = {};
764
+ obj.name = pathUtil.basename(path2);
765
+ if (stat.isFile()) {
766
+ obj.type = "file";
767
+ obj.size = stat.size;
768
+ } else if (stat.isDirectory()) {
769
+ obj.type = "dir";
770
+ } else if (stat.isSymbolicLink()) {
771
+ obj.type = "symlink";
772
+ } else {
773
+ obj.type = "other";
774
+ }
775
+ if (options.mode) {
776
+ obj.mode = stat.mode;
777
+ }
778
+ if (options.times) {
779
+ obj.accessTime = stat.atime;
780
+ obj.modifyTime = stat.mtime;
781
+ obj.changeTime = stat.ctime;
782
+ obj.birthTime = stat.birthtime;
783
+ }
784
+ if (options.absolutePath) {
785
+ obj.absolutePath = path2;
786
+ }
787
+ return obj;
788
+ };
789
+ var fileChecksum = (path2, algo) => {
790
+ const hash = crypto.createHash(algo);
791
+ const data = fs2.readFileSync(path2);
792
+ hash.update(data);
793
+ return hash.digest("hex");
794
+ };
795
+ var addExtraFieldsSync = (path2, inspectObj, options) => {
796
+ if (inspectObj.type === "file" && options.checksum) {
797
+ inspectObj[options.checksum] = fileChecksum(path2, options.checksum);
798
+ } else if (inspectObj.type === "symlink") {
799
+ inspectObj.pointsAt = fs2.readlinkSync(path2);
800
+ }
801
+ };
802
+ var inspectSync = (path2, options) => {
803
+ let statOperation = fs2.lstatSync;
804
+ let stat;
805
+ const opts = options || {};
806
+ if (opts.symlinks === "follow") {
807
+ statOperation = fs2.statSync;
808
+ }
809
+ try {
810
+ stat = statOperation(path2);
811
+ } catch (err) {
812
+ if (err.code === "ENOENT") {
813
+ return void 0;
814
+ }
815
+ throw err;
816
+ }
817
+ const inspectObj = createInspectObj(path2, opts, stat);
818
+ addExtraFieldsSync(path2, inspectObj, opts);
819
+ return inspectObj;
820
+ };
821
+ var fileChecksumAsync = (path2, algo) => {
822
+ return new Promise((resolve, reject) => {
823
+ const hash = crypto.createHash(algo);
824
+ const s = fs2.createReadStream(path2);
825
+ s.on("data", (data) => {
826
+ hash.update(data);
827
+ });
828
+ s.on("end", () => {
829
+ resolve(hash.digest("hex"));
830
+ });
831
+ s.on("error", reject);
832
+ });
833
+ };
834
+ var addExtraFieldsAsync = (path2, inspectObj, options) => {
835
+ if (inspectObj.type === "file" && options.checksum) {
836
+ return fileChecksumAsync(path2, options.checksum).then((checksum) => {
837
+ inspectObj[options.checksum] = checksum;
838
+ return inspectObj;
839
+ });
840
+ } else if (inspectObj.type === "symlink") {
841
+ return fs2.readlink(path2).then((linkPath) => {
842
+ inspectObj.pointsAt = linkPath;
843
+ return inspectObj;
844
+ });
845
+ }
846
+ return Promise.resolve(inspectObj);
847
+ };
848
+ var inspectAsync = (path2, options) => {
849
+ return new Promise((resolve, reject) => {
850
+ let statOperation = fs2.lstat;
851
+ const opts = options || {};
852
+ if (opts.symlinks === "follow") {
853
+ statOperation = fs2.stat;
854
+ }
855
+ statOperation(path2).then((stat) => {
856
+ const inspectObj = createInspectObj(path2, opts, stat);
857
+ addExtraFieldsAsync(path2, inspectObj, opts).then(resolve, reject);
858
+ }).catch((err) => {
859
+ if (err.code === "ENOENT") {
860
+ resolve(void 0);
861
+ } else {
862
+ reject(err);
863
+ }
864
+ });
865
+ });
866
+ };
867
+ exports.supportedChecksumAlgorithms = supportedChecksumAlgorithms;
868
+ exports.symlinkOptions = symlinkOptions;
869
+ exports.validateInput = validateInput;
870
+ exports.sync = inspectSync;
871
+ exports.async = inspectAsync;
872
+ }
873
+ });
874
+ var require_list = (0, import_chunk_2ESYSVXG.__commonJS)({
875
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/list.js"(exports) {
876
+ "use strict";
877
+ var fs2 = require_fs();
878
+ var validate = require_validate();
879
+ var validateInput = (methodName, path2) => {
880
+ const methodSignature = `${methodName}(path)`;
881
+ validate.argument(methodSignature, "path", path2, ["string", "undefined"]);
882
+ };
883
+ var listSync = (path2) => {
884
+ try {
885
+ return fs2.readdirSync(path2);
886
+ } catch (err) {
887
+ if (err.code === "ENOENT") {
888
+ return void 0;
889
+ }
890
+ throw err;
891
+ }
892
+ };
893
+ var listAsync = (path2) => {
894
+ return new Promise((resolve, reject) => {
895
+ fs2.readdir(path2).then((list) => {
896
+ resolve(list);
897
+ }).catch((err) => {
898
+ if (err.code === "ENOENT") {
899
+ resolve(void 0);
900
+ } else {
901
+ reject(err);
902
+ }
903
+ });
904
+ });
905
+ };
906
+ exports.validateInput = validateInput;
907
+ exports.sync = listSync;
908
+ exports.async = listAsync;
909
+ }
910
+ });
911
+ var require_tree_walker = (0, import_chunk_2ESYSVXG.__commonJS)({
912
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/utils/tree_walker.js"(exports) {
913
+ "use strict";
914
+ var fs2 = (0, import_chunk_2ESYSVXG.__require)("fs");
915
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
916
+ var inspect = require_inspect();
917
+ var list = require_list();
918
+ var fileType = (dirent) => {
919
+ if (dirent.isDirectory()) {
920
+ return "dir";
921
+ }
922
+ if (dirent.isFile()) {
923
+ return "file";
924
+ }
925
+ if (dirent.isSymbolicLink()) {
926
+ return "symlink";
927
+ }
928
+ return "other";
929
+ };
930
+ var initialWalkSync = (path2, options, callback) => {
931
+ if (options.maxLevelsDeep === void 0) {
932
+ options.maxLevelsDeep = Infinity;
933
+ }
934
+ const performInspectOnEachNode = options.inspectOptions !== void 0;
935
+ if (options.symlinks) {
936
+ if (options.inspectOptions === void 0) {
937
+ options.inspectOptions = { symlinks: options.symlinks };
938
+ } else {
939
+ options.inspectOptions.symlinks = options.symlinks;
940
+ }
941
+ }
942
+ const walkSync = (path3, currentLevel) => {
943
+ fs2.readdirSync(path3, { withFileTypes: true }).forEach((direntItem) => {
944
+ const withFileTypesNotSupported = typeof direntItem === "string";
945
+ let fileItemPath;
946
+ if (withFileTypesNotSupported) {
947
+ fileItemPath = pathUtil.join(path3, direntItem);
948
+ } else {
949
+ fileItemPath = pathUtil.join(path3, direntItem.name);
950
+ }
951
+ let fileItem;
952
+ if (performInspectOnEachNode) {
953
+ fileItem = inspect.sync(fileItemPath, options.inspectOptions);
954
+ } else if (withFileTypesNotSupported) {
955
+ const inspectObject = inspect.sync(
956
+ fileItemPath,
957
+ options.inspectOptions
958
+ );
959
+ fileItem = { name: inspectObject.name, type: inspectObject.type };
960
+ } else {
961
+ const type = fileType(direntItem);
962
+ if (type === "symlink" && options.symlinks === "follow") {
963
+ const symlinkPointsTo = fs2.statSync(fileItemPath);
964
+ fileItem = { name: direntItem.name, type: fileType(symlinkPointsTo) };
965
+ } else {
966
+ fileItem = { name: direntItem.name, type };
967
+ }
968
+ }
969
+ if (fileItem !== void 0) {
970
+ callback(fileItemPath, fileItem);
971
+ if (fileItem.type === "dir" && currentLevel < options.maxLevelsDeep) {
972
+ walkSync(fileItemPath, currentLevel + 1);
973
+ }
974
+ }
975
+ });
976
+ };
977
+ const item = inspect.sync(path2, options.inspectOptions);
978
+ if (item) {
979
+ if (performInspectOnEachNode) {
980
+ callback(path2, item);
981
+ } else {
982
+ callback(path2, { name: item.name, type: item.type });
983
+ }
984
+ if (item.type === "dir") {
985
+ walkSync(path2, 1);
986
+ }
987
+ } else {
988
+ callback(path2, void 0);
989
+ }
990
+ };
991
+ var maxConcurrentOperations = 5;
992
+ var initialWalkAsync = (path2, options, callback, doneCallback) => {
993
+ if (options.maxLevelsDeep === void 0) {
994
+ options.maxLevelsDeep = Infinity;
995
+ }
996
+ const performInspectOnEachNode = options.inspectOptions !== void 0;
997
+ if (options.symlinks) {
998
+ if (options.inspectOptions === void 0) {
999
+ options.inspectOptions = { symlinks: options.symlinks };
1000
+ } else {
1001
+ options.inspectOptions.symlinks = options.symlinks;
1002
+ }
1003
+ }
1004
+ const concurrentOperationsQueue = [];
1005
+ let nowDoingConcurrentOperations = 0;
1006
+ const checkConcurrentOperations = () => {
1007
+ if (concurrentOperationsQueue.length === 0 && nowDoingConcurrentOperations === 0) {
1008
+ doneCallback();
1009
+ } else if (concurrentOperationsQueue.length > 0 && nowDoingConcurrentOperations < maxConcurrentOperations) {
1010
+ const operation = concurrentOperationsQueue.pop();
1011
+ nowDoingConcurrentOperations += 1;
1012
+ operation();
1013
+ }
1014
+ };
1015
+ const whenConcurrencySlotAvailable = (operation) => {
1016
+ concurrentOperationsQueue.push(operation);
1017
+ checkConcurrentOperations();
1018
+ };
1019
+ const concurrentOperationDone = () => {
1020
+ nowDoingConcurrentOperations -= 1;
1021
+ checkConcurrentOperations();
1022
+ };
1023
+ const walkAsync = (path3, currentLevel) => {
1024
+ const goDeeperIfDir = (fileItemPath, fileItem) => {
1025
+ if (fileItem.type === "dir" && currentLevel < options.maxLevelsDeep) {
1026
+ walkAsync(fileItemPath, currentLevel + 1);
1027
+ }
1028
+ };
1029
+ whenConcurrencySlotAvailable(() => {
1030
+ fs2.readdir(path3, { withFileTypes: true }, (err, files) => {
1031
+ if (err) {
1032
+ doneCallback(err);
1033
+ } else {
1034
+ files.forEach((direntItem) => {
1035
+ const withFileTypesNotSupported = typeof direntItem === "string";
1036
+ let fileItemPath;
1037
+ if (withFileTypesNotSupported) {
1038
+ fileItemPath = pathUtil.join(path3, direntItem);
1039
+ } else {
1040
+ fileItemPath = pathUtil.join(path3, direntItem.name);
1041
+ }
1042
+ if (performInspectOnEachNode || withFileTypesNotSupported) {
1043
+ whenConcurrencySlotAvailable(() => {
1044
+ inspect.async(fileItemPath, options.inspectOptions).then((fileItem) => {
1045
+ if (fileItem !== void 0) {
1046
+ if (performInspectOnEachNode) {
1047
+ callback(fileItemPath, fileItem);
1048
+ } else {
1049
+ callback(fileItemPath, {
1050
+ name: fileItem.name,
1051
+ type: fileItem.type
1052
+ });
1053
+ }
1054
+ goDeeperIfDir(fileItemPath, fileItem);
1055
+ }
1056
+ concurrentOperationDone();
1057
+ }).catch((err2) => {
1058
+ doneCallback(err2);
1059
+ });
1060
+ });
1061
+ } else {
1062
+ const type = fileType(direntItem);
1063
+ if (type === "symlink" && options.symlinks === "follow") {
1064
+ whenConcurrencySlotAvailable(() => {
1065
+ fs2.stat(fileItemPath, (err2, symlinkPointsTo) => {
1066
+ if (err2) {
1067
+ doneCallback(err2);
1068
+ } else {
1069
+ const fileItem = {
1070
+ name: direntItem.name,
1071
+ type: fileType(symlinkPointsTo)
1072
+ };
1073
+ callback(fileItemPath, fileItem);
1074
+ goDeeperIfDir(fileItemPath, fileItem);
1075
+ concurrentOperationDone();
1076
+ }
1077
+ });
1078
+ });
1079
+ } else {
1080
+ const fileItem = { name: direntItem.name, type };
1081
+ callback(fileItemPath, fileItem);
1082
+ goDeeperIfDir(fileItemPath, fileItem);
1083
+ }
1084
+ }
1085
+ });
1086
+ concurrentOperationDone();
1087
+ }
1088
+ });
1089
+ });
1090
+ };
1091
+ inspect.async(path2, options.inspectOptions).then((item) => {
1092
+ if (item) {
1093
+ if (performInspectOnEachNode) {
1094
+ callback(path2, item);
1095
+ } else {
1096
+ callback(path2, { name: item.name, type: item.type });
1097
+ }
1098
+ if (item.type === "dir") {
1099
+ walkAsync(path2, 1);
1100
+ } else {
1101
+ doneCallback();
1102
+ }
1103
+ } else {
1104
+ callback(path2, void 0);
1105
+ doneCallback();
1106
+ }
1107
+ }).catch((err) => {
1108
+ doneCallback(err);
1109
+ });
1110
+ };
1111
+ exports.sync = initialWalkSync;
1112
+ exports.async = initialWalkAsync;
1113
+ }
1114
+ });
1115
+ var require_path = (0, import_chunk_2ESYSVXG.__commonJS)({
1116
+ "../../node_modules/.pnpm/minimatch@5.1.0/node_modules/minimatch/lib/path.js"(exports, module2) {
1117
+ "use strict";
1118
+ var isWindows = typeof process === "object" && process && process.platform === "win32";
1119
+ module2.exports = isWindows ? { sep: "\\" } : { sep: "/" };
1120
+ }
1121
+ });
1122
+ var require_balanced_match = (0, import_chunk_2ESYSVXG.__commonJS)({
1123
+ "../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module2) {
1124
+ "use strict";
1125
+ module2.exports = balanced;
1126
+ function balanced(a, b, str) {
1127
+ if (a instanceof RegExp) a = maybeMatch(a, str);
1128
+ if (b instanceof RegExp) b = maybeMatch(b, str);
1129
+ var r = range(a, b, str);
1130
+ return r && {
1131
+ start: r[0],
1132
+ end: r[1],
1133
+ pre: str.slice(0, r[0]),
1134
+ body: str.slice(r[0] + a.length, r[1]),
1135
+ post: str.slice(r[1] + b.length)
1136
+ };
1137
+ }
1138
+ function maybeMatch(reg, str) {
1139
+ var m = str.match(reg);
1140
+ return m ? m[0] : null;
1141
+ }
1142
+ balanced.range = range;
1143
+ function range(a, b, str) {
1144
+ var begs, beg, left, right, result;
1145
+ var ai = str.indexOf(a);
1146
+ var bi = str.indexOf(b, ai + 1);
1147
+ var i = ai;
1148
+ if (ai >= 0 && bi > 0) {
1149
+ if (a === b) {
1150
+ return [ai, bi];
1151
+ }
1152
+ begs = [];
1153
+ left = str.length;
1154
+ while (i >= 0 && !result) {
1155
+ if (i == ai) {
1156
+ begs.push(i);
1157
+ ai = str.indexOf(a, i + 1);
1158
+ } else if (begs.length == 1) {
1159
+ result = [begs.pop(), bi];
1160
+ } else {
1161
+ beg = begs.pop();
1162
+ if (beg < left) {
1163
+ left = beg;
1164
+ right = bi;
1165
+ }
1166
+ bi = str.indexOf(b, i + 1);
1167
+ }
1168
+ i = ai < bi && ai >= 0 ? ai : bi;
1169
+ }
1170
+ if (begs.length) {
1171
+ result = [left, right];
1172
+ }
1173
+ }
1174
+ return result;
1175
+ }
1176
+ }
1177
+ });
1178
+ var require_brace_expansion = (0, import_chunk_2ESYSVXG.__commonJS)({
1179
+ "../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js"(exports, module2) {
1180
+ "use strict";
1181
+ var balanced = require_balanced_match();
1182
+ module2.exports = expandTop;
1183
+ var escSlash = "\0SLASH" + Math.random() + "\0";
1184
+ var escOpen = "\0OPEN" + Math.random() + "\0";
1185
+ var escClose = "\0CLOSE" + Math.random() + "\0";
1186
+ var escComma = "\0COMMA" + Math.random() + "\0";
1187
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
1188
+ function numeric(str) {
1189
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
1190
+ }
1191
+ function escapeBraces(str) {
1192
+ return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
1193
+ }
1194
+ function unescapeBraces(str) {
1195
+ return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
1196
+ }
1197
+ function parseCommaParts(str) {
1198
+ if (!str)
1199
+ return [""];
1200
+ var parts = [];
1201
+ var m = balanced("{", "}", str);
1202
+ if (!m)
1203
+ return str.split(",");
1204
+ var pre = m.pre;
1205
+ var body = m.body;
1206
+ var post = m.post;
1207
+ var p = pre.split(",");
1208
+ p[p.length - 1] += "{" + body + "}";
1209
+ var postParts = parseCommaParts(post);
1210
+ if (post.length) {
1211
+ p[p.length - 1] += postParts.shift();
1212
+ p.push.apply(p, postParts);
1213
+ }
1214
+ parts.push.apply(parts, p);
1215
+ return parts;
1216
+ }
1217
+ function expandTop(str) {
1218
+ if (!str)
1219
+ return [];
1220
+ if (str.substr(0, 2) === "{}") {
1221
+ str = "\\{\\}" + str.substr(2);
1222
+ }
1223
+ return expand(escapeBraces(str), true).map(unescapeBraces);
1224
+ }
1225
+ function embrace(str) {
1226
+ return "{" + str + "}";
1227
+ }
1228
+ function isPadded(el) {
1229
+ return /^-?0\d/.test(el);
1230
+ }
1231
+ function lte(i, y) {
1232
+ return i <= y;
1233
+ }
1234
+ function gte(i, y) {
1235
+ return i >= y;
1236
+ }
1237
+ function expand(str, isTop) {
1238
+ var expansions = [];
1239
+ var m = balanced("{", "}", str);
1240
+ if (!m) return [str];
1241
+ var pre = m.pre;
1242
+ var post = m.post.length ? expand(m.post, false) : [""];
1243
+ if (/\$$/.test(m.pre)) {
1244
+ for (var k = 0; k < post.length; k++) {
1245
+ var expansion = pre + "{" + m.body + "}" + post[k];
1246
+ expansions.push(expansion);
1247
+ }
1248
+ } else {
1249
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
1250
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
1251
+ var isSequence = isNumericSequence || isAlphaSequence;
1252
+ var isOptions = m.body.indexOf(",") >= 0;
1253
+ if (!isSequence && !isOptions) {
1254
+ if (m.post.match(/,.*\}/)) {
1255
+ str = m.pre + "{" + m.body + escClose + m.post;
1256
+ return expand(str);
1257
+ }
1258
+ return [str];
1259
+ }
1260
+ var n;
1261
+ if (isSequence) {
1262
+ n = m.body.split(/\.\./);
1263
+ } else {
1264
+ n = parseCommaParts(m.body);
1265
+ if (n.length === 1) {
1266
+ n = expand(n[0], false).map(embrace);
1267
+ if (n.length === 1) {
1268
+ return post.map(function(p) {
1269
+ return m.pre + n[0] + p;
1270
+ });
1271
+ }
1272
+ }
1273
+ }
1274
+ var N;
1275
+ if (isSequence) {
1276
+ var x = numeric(n[0]);
1277
+ var y = numeric(n[1]);
1278
+ var width = Math.max(n[0].length, n[1].length);
1279
+ var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
1280
+ var test = lte;
1281
+ var reverse = y < x;
1282
+ if (reverse) {
1283
+ incr *= -1;
1284
+ test = gte;
1285
+ }
1286
+ var pad = n.some(isPadded);
1287
+ N = [];
1288
+ for (var i = x; test(i, y); i += incr) {
1289
+ var c;
1290
+ if (isAlphaSequence) {
1291
+ c = String.fromCharCode(i);
1292
+ if (c === "\\")
1293
+ c = "";
1294
+ } else {
1295
+ c = String(i);
1296
+ if (pad) {
1297
+ var need = width - c.length;
1298
+ if (need > 0) {
1299
+ var z = new Array(need + 1).join("0");
1300
+ if (i < 0)
1301
+ c = "-" + z + c.slice(1);
1302
+ else
1303
+ c = z + c;
1304
+ }
1305
+ }
1306
+ }
1307
+ N.push(c);
1308
+ }
1309
+ } else {
1310
+ N = [];
1311
+ for (var j = 0; j < n.length; j++) {
1312
+ N.push.apply(N, expand(n[j], false));
1313
+ }
1314
+ }
1315
+ for (var j = 0; j < N.length; j++) {
1316
+ for (var k = 0; k < post.length; k++) {
1317
+ var expansion = pre + N[j] + post[k];
1318
+ if (!isTop || isSequence || expansion)
1319
+ expansions.push(expansion);
1320
+ }
1321
+ }
1322
+ }
1323
+ return expansions;
1324
+ }
1325
+ }
1326
+ });
1327
+ var require_minimatch = (0, import_chunk_2ESYSVXG.__commonJS)({
1328
+ "../../node_modules/.pnpm/minimatch@5.1.0/node_modules/minimatch/minimatch.js"(exports, module2) {
1329
+ "use strict";
1330
+ var minimatch = module2.exports = (p, pattern, options = {}) => {
1331
+ assertValidPattern(pattern);
1332
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1333
+ return false;
1334
+ }
1335
+ return new Minimatch(pattern, options).match(p);
1336
+ };
1337
+ module2.exports = minimatch;
1338
+ var path2 = require_path();
1339
+ minimatch.sep = path2.sep;
1340
+ var GLOBSTAR = Symbol("globstar **");
1341
+ minimatch.GLOBSTAR = GLOBSTAR;
1342
+ var expand = require_brace_expansion();
1343
+ var plTypes = {
1344
+ "!": { open: "(?:(?!(?:", close: "))[^/]*?)" },
1345
+ "?": { open: "(?:", close: ")?" },
1346
+ "+": { open: "(?:", close: ")+" },
1347
+ "*": { open: "(?:", close: ")*" },
1348
+ "@": { open: "(?:", close: ")" }
1349
+ };
1350
+ var qmark = "[^/]";
1351
+ var star = qmark + "*?";
1352
+ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
1353
+ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
1354
+ var charSet = (s) => s.split("").reduce((set, c) => {
1355
+ set[c] = true;
1356
+ return set;
1357
+ }, {});
1358
+ var reSpecials = charSet("().*{}+?[]^$\\!");
1359
+ var addPatternStartSet = charSet("[.(");
1360
+ var slashSplit = /\/+/;
1361
+ minimatch.filter = (pattern, options = {}) => (p, i, list) => minimatch(p, pattern, options);
1362
+ var ext = (a, b = {}) => {
1363
+ const t = {};
1364
+ Object.keys(a).forEach((k) => t[k] = a[k]);
1365
+ Object.keys(b).forEach((k) => t[k] = b[k]);
1366
+ return t;
1367
+ };
1368
+ minimatch.defaults = (def) => {
1369
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
1370
+ return minimatch;
1371
+ }
1372
+ const orig = minimatch;
1373
+ const m = (p, pattern, options) => orig(p, pattern, ext(def, options));
1374
+ m.Minimatch = class Minimatch extends orig.Minimatch {
1375
+ constructor(pattern, options) {
1376
+ super(pattern, ext(def, options));
1377
+ }
1378
+ };
1379
+ m.Minimatch.defaults = (options) => orig.defaults(ext(def, options)).Minimatch;
1380
+ m.filter = (pattern, options) => orig.filter(pattern, ext(def, options));
1381
+ m.defaults = (options) => orig.defaults(ext(def, options));
1382
+ m.makeRe = (pattern, options) => orig.makeRe(pattern, ext(def, options));
1383
+ m.braceExpand = (pattern, options) => orig.braceExpand(pattern, ext(def, options));
1384
+ m.match = (list, pattern, options) => orig.match(list, pattern, ext(def, options));
1385
+ return m;
1386
+ };
1387
+ minimatch.braceExpand = (pattern, options) => braceExpand(pattern, options);
1388
+ var braceExpand = (pattern, options = {}) => {
1389
+ assertValidPattern(pattern);
1390
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
1391
+ return [pattern];
1392
+ }
1393
+ return expand(pattern);
1394
+ };
1395
+ var MAX_PATTERN_LENGTH = 1024 * 64;
1396
+ var assertValidPattern = (pattern) => {
1397
+ if (typeof pattern !== "string") {
1398
+ throw new TypeError("invalid pattern");
1399
+ }
1400
+ if (pattern.length > MAX_PATTERN_LENGTH) {
1401
+ throw new TypeError("pattern is too long");
1402
+ }
1403
+ };
1404
+ var SUBPARSE = Symbol("subparse");
1405
+ minimatch.makeRe = (pattern, options) => new Minimatch(pattern, options || {}).makeRe();
1406
+ minimatch.match = (list, pattern, options = {}) => {
1407
+ const mm = new Minimatch(pattern, options);
1408
+ list = list.filter((f) => mm.match(f));
1409
+ if (mm.options.nonull && !list.length) {
1410
+ list.push(pattern);
1411
+ }
1412
+ return list;
1413
+ };
1414
+ var globUnescape = (s) => s.replace(/\\(.)/g, "$1");
1415
+ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1416
+ var Minimatch = class {
1417
+ constructor(pattern, options) {
1418
+ assertValidPattern(pattern);
1419
+ if (!options) options = {};
1420
+ this.options = options;
1421
+ this.set = [];
1422
+ this.pattern = pattern;
1423
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
1424
+ if (this.windowsPathsNoEscape) {
1425
+ this.pattern = this.pattern.replace(/\\/g, "/");
1426
+ }
1427
+ this.regexp = null;
1428
+ this.negate = false;
1429
+ this.comment = false;
1430
+ this.empty = false;
1431
+ this.partial = !!options.partial;
1432
+ this.make();
1433
+ }
1434
+ debug() {
1435
+ }
1436
+ make() {
1437
+ const pattern = this.pattern;
1438
+ const options = this.options;
1439
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1440
+ this.comment = true;
1441
+ return;
1442
+ }
1443
+ if (!pattern) {
1444
+ this.empty = true;
1445
+ return;
1446
+ }
1447
+ this.parseNegate();
1448
+ let set = this.globSet = this.braceExpand();
1449
+ if (options.debug) this.debug = (...args) => console.error(...args);
1450
+ this.debug(this.pattern, set);
1451
+ set = this.globParts = set.map((s) => s.split(slashSplit));
1452
+ this.debug(this.pattern, set);
1453
+ set = set.map((s, si, set2) => s.map(this.parse, this));
1454
+ this.debug(this.pattern, set);
1455
+ set = set.filter((s) => s.indexOf(false) === -1);
1456
+ this.debug(this.pattern, set);
1457
+ this.set = set;
1458
+ }
1459
+ parseNegate() {
1460
+ if (this.options.nonegate) return;
1461
+ const pattern = this.pattern;
1462
+ let negate = false;
1463
+ let negateOffset = 0;
1464
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
1465
+ negate = !negate;
1466
+ negateOffset++;
1467
+ }
1468
+ if (negateOffset) this.pattern = pattern.substr(negateOffset);
1469
+ this.negate = negate;
1470
+ }
1471
+ // set partial to true to test if, for example,
1472
+ // "/a/b" matches the start of "/*/b/*/d"
1473
+ // Partial means, if you run out of file before you run
1474
+ // out of pattern, then that's fine, as long as all
1475
+ // the parts match.
1476
+ matchOne(file, pattern, partial) {
1477
+ var options = this.options;
1478
+ this.debug(
1479
+ "matchOne",
1480
+ { "this": this, file, pattern }
1481
+ );
1482
+ this.debug("matchOne", file.length, pattern.length);
1483
+ for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1484
+ this.debug("matchOne loop");
1485
+ var p = pattern[pi];
1486
+ var f = file[fi];
1487
+ this.debug(pattern, p, f);
1488
+ if (p === false) return false;
1489
+ if (p === GLOBSTAR) {
1490
+ this.debug("GLOBSTAR", [pattern, p, f]);
1491
+ var fr = fi;
1492
+ var pr = pi + 1;
1493
+ if (pr === pl) {
1494
+ this.debug("** at the end");
1495
+ for (; fi < fl; fi++) {
1496
+ if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
1497
+ }
1498
+ return true;
1499
+ }
1500
+ while (fr < fl) {
1501
+ var swallowee = file[fr];
1502
+ this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
1503
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
1504
+ this.debug("globstar found match!", fr, fl, swallowee);
1505
+ return true;
1506
+ } else {
1507
+ if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
1508
+ this.debug("dot detected!", file, fr, pattern, pr);
1509
+ break;
1510
+ }
1511
+ this.debug("globstar swallow a segment, and continue");
1512
+ fr++;
1513
+ }
1514
+ }
1515
+ if (partial) {
1516
+ this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
1517
+ if (fr === fl) return true;
1518
+ }
1519
+ return false;
1520
+ }
1521
+ var hit;
1522
+ if (typeof p === "string") {
1523
+ hit = f === p;
1524
+ this.debug("string match", p, f, hit);
1525
+ } else {
1526
+ hit = f.match(p);
1527
+ this.debug("pattern match", p, f, hit);
1528
+ }
1529
+ if (!hit) return false;
1530
+ }
1531
+ if (fi === fl && pi === pl) {
1532
+ return true;
1533
+ } else if (fi === fl) {
1534
+ return partial;
1535
+ } else if (pi === pl) {
1536
+ return fi === fl - 1 && file[fi] === "";
1537
+ }
1538
+ throw new Error("wtf?");
1539
+ }
1540
+ braceExpand() {
1541
+ return braceExpand(this.pattern, this.options);
1542
+ }
1543
+ parse(pattern, isSub) {
1544
+ assertValidPattern(pattern);
1545
+ const options = this.options;
1546
+ if (pattern === "**") {
1547
+ if (!options.noglobstar)
1548
+ return GLOBSTAR;
1549
+ else
1550
+ pattern = "*";
1551
+ }
1552
+ if (pattern === "") return "";
1553
+ let re = "";
1554
+ let hasMagic = !!options.nocase;
1555
+ let escaping = false;
1556
+ const patternListStack = [];
1557
+ const negativeLists = [];
1558
+ let stateChar;
1559
+ let inClass = false;
1560
+ let reClassStart = -1;
1561
+ let classStart = -1;
1562
+ let cs;
1563
+ let pl;
1564
+ let sp;
1565
+ const patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
1566
+ const clearStateChar = () => {
1567
+ if (stateChar) {
1568
+ switch (stateChar) {
1569
+ case "*":
1570
+ re += star;
1571
+ hasMagic = true;
1572
+ break;
1573
+ case "?":
1574
+ re += qmark;
1575
+ hasMagic = true;
1576
+ break;
1577
+ default:
1578
+ re += "\\" + stateChar;
1579
+ break;
1580
+ }
1581
+ this.debug("clearStateChar %j %j", stateChar, re);
1582
+ stateChar = false;
1583
+ }
1584
+ };
1585
+ for (let i = 0, c; i < pattern.length && (c = pattern.charAt(i)); i++) {
1586
+ this.debug("%s %s %s %j", pattern, i, re, c);
1587
+ if (escaping) {
1588
+ if (c === "/") {
1589
+ return false;
1590
+ }
1591
+ if (reSpecials[c]) {
1592
+ re += "\\";
1593
+ }
1594
+ re += c;
1595
+ escaping = false;
1596
+ continue;
1597
+ }
1598
+ switch (c) {
1599
+ /* istanbul ignore next */
1600
+ case "/": {
1601
+ return false;
1602
+ }
1603
+ case "\\":
1604
+ clearStateChar();
1605
+ escaping = true;
1606
+ continue;
1607
+ // the various stateChar values
1608
+ // for the "extglob" stuff.
1609
+ case "?":
1610
+ case "*":
1611
+ case "+":
1612
+ case "@":
1613
+ case "!":
1614
+ this.debug("%s %s %s %j <-- stateChar", pattern, i, re, c);
1615
+ if (inClass) {
1616
+ this.debug(" in class");
1617
+ if (c === "!" && i === classStart + 1) c = "^";
1618
+ re += c;
1619
+ continue;
1620
+ }
1621
+ this.debug("call clearStateChar %j", stateChar);
1622
+ clearStateChar();
1623
+ stateChar = c;
1624
+ if (options.noext) clearStateChar();
1625
+ continue;
1626
+ case "(":
1627
+ if (inClass) {
1628
+ re += "(";
1629
+ continue;
1630
+ }
1631
+ if (!stateChar) {
1632
+ re += "\\(";
1633
+ continue;
1634
+ }
1635
+ patternListStack.push({
1636
+ type: stateChar,
1637
+ start: i - 1,
1638
+ reStart: re.length,
1639
+ open: plTypes[stateChar].open,
1640
+ close: plTypes[stateChar].close
1641
+ });
1642
+ re += stateChar === "!" ? "(?:(?!(?:" : "(?:";
1643
+ this.debug("plType %j %j", stateChar, re);
1644
+ stateChar = false;
1645
+ continue;
1646
+ case ")":
1647
+ if (inClass || !patternListStack.length) {
1648
+ re += "\\)";
1649
+ continue;
1650
+ }
1651
+ clearStateChar();
1652
+ hasMagic = true;
1653
+ pl = patternListStack.pop();
1654
+ re += pl.close;
1655
+ if (pl.type === "!") {
1656
+ negativeLists.push(pl);
1657
+ }
1658
+ pl.reEnd = re.length;
1659
+ continue;
1660
+ case "|":
1661
+ if (inClass || !patternListStack.length) {
1662
+ re += "\\|";
1663
+ continue;
1664
+ }
1665
+ clearStateChar();
1666
+ re += "|";
1667
+ continue;
1668
+ // these are mostly the same in regexp and glob
1669
+ case "[":
1670
+ clearStateChar();
1671
+ if (inClass) {
1672
+ re += "\\" + c;
1673
+ continue;
1674
+ }
1675
+ inClass = true;
1676
+ classStart = i;
1677
+ reClassStart = re.length;
1678
+ re += c;
1679
+ continue;
1680
+ case "]":
1681
+ if (i === classStart + 1 || !inClass) {
1682
+ re += "\\" + c;
1683
+ continue;
1684
+ }
1685
+ cs = pattern.substring(classStart + 1, i);
1686
+ try {
1687
+ RegExp("[" + cs + "]");
1688
+ } catch (er) {
1689
+ sp = this.parse(cs, SUBPARSE);
1690
+ re = re.substr(0, reClassStart) + "\\[" + sp[0] + "\\]";
1691
+ hasMagic = hasMagic || sp[1];
1692
+ inClass = false;
1693
+ continue;
1694
+ }
1695
+ hasMagic = true;
1696
+ inClass = false;
1697
+ re += c;
1698
+ continue;
1699
+ default:
1700
+ clearStateChar();
1701
+ if (reSpecials[c] && !(c === "^" && inClass)) {
1702
+ re += "\\";
1703
+ }
1704
+ re += c;
1705
+ break;
1706
+ }
1707
+ }
1708
+ if (inClass) {
1709
+ cs = pattern.substr(classStart + 1);
1710
+ sp = this.parse(cs, SUBPARSE);
1711
+ re = re.substr(0, reClassStart) + "\\[" + sp[0];
1712
+ hasMagic = hasMagic || sp[1];
1713
+ }
1714
+ for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
1715
+ let tail;
1716
+ tail = re.slice(pl.reStart + pl.open.length);
1717
+ this.debug("setting tail", re, pl);
1718
+ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
1719
+ if (!$2) {
1720
+ $2 = "\\";
1721
+ }
1722
+ return $1 + $1 + $2 + "|";
1723
+ });
1724
+ this.debug("tail=%j\n %s", tail, tail, pl, re);
1725
+ const t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
1726
+ hasMagic = true;
1727
+ re = re.slice(0, pl.reStart) + t + "\\(" + tail;
1728
+ }
1729
+ clearStateChar();
1730
+ if (escaping) {
1731
+ re += "\\\\";
1732
+ }
1733
+ const addPatternStart = addPatternStartSet[re.charAt(0)];
1734
+ for (let n = negativeLists.length - 1; n > -1; n--) {
1735
+ const nl = negativeLists[n];
1736
+ const nlBefore = re.slice(0, nl.reStart);
1737
+ const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
1738
+ let nlAfter = re.slice(nl.reEnd);
1739
+ const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
1740
+ const openParensBefore = nlBefore.split("(").length - 1;
1741
+ let cleanAfter = nlAfter;
1742
+ for (let i = 0; i < openParensBefore; i++) {
1743
+ cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
1744
+ }
1745
+ nlAfter = cleanAfter;
1746
+ const dollar = nlAfter === "" && isSub !== SUBPARSE ? "$" : "";
1747
+ re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
1748
+ }
1749
+ if (re !== "" && hasMagic) {
1750
+ re = "(?=.)" + re;
1751
+ }
1752
+ if (addPatternStart) {
1753
+ re = patternStart + re;
1754
+ }
1755
+ if (isSub === SUBPARSE) {
1756
+ return [re, hasMagic];
1757
+ }
1758
+ if (!hasMagic) {
1759
+ return globUnescape(pattern);
1760
+ }
1761
+ const flags = options.nocase ? "i" : "";
1762
+ try {
1763
+ return Object.assign(new RegExp("^" + re + "$", flags), {
1764
+ _glob: pattern,
1765
+ _src: re
1766
+ });
1767
+ } catch (er) {
1768
+ return new RegExp("$.");
1769
+ }
1770
+ }
1771
+ makeRe() {
1772
+ if (this.regexp || this.regexp === false) return this.regexp;
1773
+ const set = this.set;
1774
+ if (!set.length) {
1775
+ this.regexp = false;
1776
+ return this.regexp;
1777
+ }
1778
+ const options = this.options;
1779
+ const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
1780
+ const flags = options.nocase ? "i" : "";
1781
+ let re = set.map((pattern) => {
1782
+ pattern = pattern.map(
1783
+ (p) => typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src
1784
+ ).reduce((set2, p) => {
1785
+ if (!(set2[set2.length - 1] === GLOBSTAR && p === GLOBSTAR)) {
1786
+ set2.push(p);
1787
+ }
1788
+ return set2;
1789
+ }, []);
1790
+ pattern.forEach((p, i) => {
1791
+ if (p !== GLOBSTAR || pattern[i - 1] === GLOBSTAR) {
1792
+ return;
1793
+ }
1794
+ if (i === 0) {
1795
+ if (pattern.length > 1) {
1796
+ pattern[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + pattern[i + 1];
1797
+ } else {
1798
+ pattern[i] = twoStar;
1799
+ }
1800
+ } else if (i === pattern.length - 1) {
1801
+ pattern[i - 1] += "(?:\\/|" + twoStar + ")?";
1802
+ } else {
1803
+ pattern[i - 1] += "(?:\\/|\\/" + twoStar + "\\/)" + pattern[i + 1];
1804
+ pattern[i + 1] = GLOBSTAR;
1805
+ }
1806
+ });
1807
+ return pattern.filter((p) => p !== GLOBSTAR).join("/");
1808
+ }).join("|");
1809
+ re = "^(?:" + re + ")$";
1810
+ if (this.negate) re = "^(?!" + re + ").*$";
1811
+ try {
1812
+ this.regexp = new RegExp(re, flags);
1813
+ } catch (ex) {
1814
+ this.regexp = false;
1815
+ }
1816
+ return this.regexp;
1817
+ }
1818
+ match(f, partial = this.partial) {
1819
+ this.debug("match", f, this.pattern);
1820
+ if (this.comment) return false;
1821
+ if (this.empty) return f === "";
1822
+ if (f === "/" && partial) return true;
1823
+ const options = this.options;
1824
+ if (path2.sep !== "/") {
1825
+ f = f.split(path2.sep).join("/");
1826
+ }
1827
+ f = f.split(slashSplit);
1828
+ this.debug(this.pattern, "split", f);
1829
+ const set = this.set;
1830
+ this.debug(this.pattern, "set", set);
1831
+ let filename;
1832
+ for (let i = f.length - 1; i >= 0; i--) {
1833
+ filename = f[i];
1834
+ if (filename) break;
1835
+ }
1836
+ for (let i = 0; i < set.length; i++) {
1837
+ const pattern = set[i];
1838
+ let file = f;
1839
+ if (options.matchBase && pattern.length === 1) {
1840
+ file = [filename];
1841
+ }
1842
+ const hit = this.matchOne(file, pattern, partial);
1843
+ if (hit) {
1844
+ if (options.flipNegate) return true;
1845
+ return !this.negate;
1846
+ }
1847
+ }
1848
+ if (options.flipNegate) return false;
1849
+ return this.negate;
1850
+ }
1851
+ static defaults(def) {
1852
+ return minimatch.defaults(def).Minimatch;
1853
+ }
1854
+ };
1855
+ minimatch.Minimatch = Minimatch;
1856
+ }
1857
+ });
1858
+ var require_matcher = (0, import_chunk_2ESYSVXG.__commonJS)({
1859
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/utils/matcher.js"(exports) {
1860
+ "use strict";
1861
+ var Minimatch = require_minimatch().Minimatch;
1862
+ var convertPatternToAbsolutePath = (basePath, pattern) => {
1863
+ const hasSlash = pattern.indexOf("/") !== -1;
1864
+ const isAbsolute = /^!?\//.test(pattern);
1865
+ const isNegated = /^!/.test(pattern);
1866
+ let separator;
1867
+ if (!isAbsolute && hasSlash) {
1868
+ const patternWithoutFirstCharacters = pattern.replace(/^!/, "").replace(/^\.\//, "");
1869
+ if (/\/$/.test(basePath)) {
1870
+ separator = "";
1871
+ } else {
1872
+ separator = "/";
1873
+ }
1874
+ if (isNegated) {
1875
+ return `!${basePath}${separator}${patternWithoutFirstCharacters}`;
1876
+ }
1877
+ return `${basePath}${separator}${patternWithoutFirstCharacters}`;
1878
+ }
1879
+ return pattern;
1880
+ };
1881
+ exports.create = (basePath, patterns, ignoreCase) => {
1882
+ let normalizedPatterns;
1883
+ if (typeof patterns === "string") {
1884
+ normalizedPatterns = [patterns];
1885
+ } else {
1886
+ normalizedPatterns = patterns;
1887
+ }
1888
+ const matchers = normalizedPatterns.map((pattern) => {
1889
+ return convertPatternToAbsolutePath(basePath, pattern);
1890
+ }).map((pattern) => {
1891
+ return new Minimatch(pattern, {
1892
+ matchBase: true,
1893
+ nocomment: true,
1894
+ nocase: ignoreCase || false,
1895
+ dot: true,
1896
+ windowsPathsNoEscape: true
1897
+ });
1898
+ });
1899
+ const performMatch = (absolutePath) => {
1900
+ let mode = "matching";
1901
+ let weHaveMatch = false;
1902
+ let currentMatcher;
1903
+ let i;
1904
+ for (i = 0; i < matchers.length; i += 1) {
1905
+ currentMatcher = matchers[i];
1906
+ if (currentMatcher.negate) {
1907
+ mode = "negation";
1908
+ if (i === 0) {
1909
+ weHaveMatch = true;
1910
+ }
1911
+ }
1912
+ if (mode === "negation" && weHaveMatch && !currentMatcher.match(absolutePath)) {
1913
+ return false;
1914
+ }
1915
+ if (mode === "matching" && !weHaveMatch) {
1916
+ weHaveMatch = currentMatcher.match(absolutePath);
1917
+ }
1918
+ }
1919
+ return weHaveMatch;
1920
+ };
1921
+ return performMatch;
1922
+ };
1923
+ }
1924
+ });
1925
+ var require_find = (0, import_chunk_2ESYSVXG.__commonJS)({
1926
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/find.js"(exports) {
1927
+ "use strict";
1928
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
1929
+ var treeWalker = require_tree_walker();
1930
+ var inspect = require_inspect();
1931
+ var matcher = require_matcher();
1932
+ var validate = require_validate();
1933
+ var validateInput = (methodName, path2, options) => {
1934
+ const methodSignature = `${methodName}([path], options)`;
1935
+ validate.argument(methodSignature, "path", path2, ["string"]);
1936
+ validate.options(methodSignature, "options", options, {
1937
+ matching: ["string", "array of string"],
1938
+ filter: ["function"],
1939
+ files: ["boolean"],
1940
+ directories: ["boolean"],
1941
+ recursive: ["boolean"],
1942
+ ignoreCase: ["boolean"]
1943
+ });
1944
+ };
1945
+ var normalizeOptions = (options) => {
1946
+ const opts = options || {};
1947
+ if (opts.matching === void 0) {
1948
+ opts.matching = "*";
1949
+ }
1950
+ if (opts.files === void 0) {
1951
+ opts.files = true;
1952
+ }
1953
+ if (opts.ignoreCase === void 0) {
1954
+ opts.ignoreCase = false;
1955
+ }
1956
+ if (opts.directories === void 0) {
1957
+ opts.directories = false;
1958
+ }
1959
+ if (opts.recursive === void 0) {
1960
+ opts.recursive = true;
1961
+ }
1962
+ return opts;
1963
+ };
1964
+ var processFoundPaths = (foundPaths, cwd) => {
1965
+ return foundPaths.map((path2) => {
1966
+ return pathUtil.relative(cwd, path2);
1967
+ });
1968
+ };
1969
+ var generatePathDoesntExistError = (path2) => {
1970
+ const err = new Error(`Path you want to find stuff in doesn't exist ${path2}`);
1971
+ err.code = "ENOENT";
1972
+ return err;
1973
+ };
1974
+ var generatePathNotDirectoryError = (path2) => {
1975
+ const err = new Error(
1976
+ `Path you want to find stuff in must be a directory ${path2}`
1977
+ );
1978
+ err.code = "ENOTDIR";
1979
+ return err;
1980
+ };
1981
+ var findSync = (path2, options) => {
1982
+ const foundAbsolutePaths = [];
1983
+ const matchesAnyOfGlobs = matcher.create(
1984
+ path2,
1985
+ options.matching,
1986
+ options.ignoreCase
1987
+ );
1988
+ let maxLevelsDeep = Infinity;
1989
+ if (options.recursive === false) {
1990
+ maxLevelsDeep = 1;
1991
+ }
1992
+ treeWalker.sync(
1993
+ path2,
1994
+ {
1995
+ maxLevelsDeep,
1996
+ symlinks: "follow",
1997
+ inspectOptions: { times: true, absolutePath: true }
1998
+ },
1999
+ (itemPath, item) => {
2000
+ if (item && itemPath !== path2 && matchesAnyOfGlobs(itemPath)) {
2001
+ const weHaveMatch = item.type === "file" && options.files === true || item.type === "dir" && options.directories === true;
2002
+ if (weHaveMatch) {
2003
+ if (options.filter) {
2004
+ const passedThroughFilter = options.filter(item);
2005
+ if (passedThroughFilter) {
2006
+ foundAbsolutePaths.push(itemPath);
2007
+ }
2008
+ } else {
2009
+ foundAbsolutePaths.push(itemPath);
2010
+ }
2011
+ }
2012
+ }
2013
+ }
2014
+ );
2015
+ foundAbsolutePaths.sort();
2016
+ return processFoundPaths(foundAbsolutePaths, options.cwd);
2017
+ };
2018
+ var findSyncInit = (path2, options) => {
2019
+ const entryPointInspect = inspect.sync(path2, { symlinks: "follow" });
2020
+ if (entryPointInspect === void 0) {
2021
+ throw generatePathDoesntExistError(path2);
2022
+ } else if (entryPointInspect.type !== "dir") {
2023
+ throw generatePathNotDirectoryError(path2);
2024
+ }
2025
+ return findSync(path2, normalizeOptions(options));
2026
+ };
2027
+ var findAsync = (path2, options) => {
2028
+ return new Promise((resolve, reject) => {
2029
+ const foundAbsolutePaths = [];
2030
+ const matchesAnyOfGlobs = matcher.create(
2031
+ path2,
2032
+ options.matching,
2033
+ options.ignoreCase
2034
+ );
2035
+ let maxLevelsDeep = Infinity;
2036
+ if (options.recursive === false) {
2037
+ maxLevelsDeep = 1;
2038
+ }
2039
+ let waitingForFiltersToFinish = 0;
2040
+ let treeWalkerDone = false;
2041
+ const maybeDone = () => {
2042
+ if (treeWalkerDone && waitingForFiltersToFinish === 0) {
2043
+ foundAbsolutePaths.sort();
2044
+ resolve(processFoundPaths(foundAbsolutePaths, options.cwd));
2045
+ }
2046
+ };
2047
+ treeWalker.async(
2048
+ path2,
2049
+ {
2050
+ maxLevelsDeep,
2051
+ symlinks: "follow",
2052
+ inspectOptions: { times: true, absolutePath: true }
2053
+ },
2054
+ (itemPath, item) => {
2055
+ if (item && itemPath !== path2 && matchesAnyOfGlobs(itemPath)) {
2056
+ const weHaveMatch = item.type === "file" && options.files === true || item.type === "dir" && options.directories === true;
2057
+ if (weHaveMatch) {
2058
+ if (options.filter) {
2059
+ const passedThroughFilter = options.filter(item);
2060
+ const isPromise = typeof passedThroughFilter.then === "function";
2061
+ if (isPromise) {
2062
+ waitingForFiltersToFinish += 1;
2063
+ passedThroughFilter.then((passedThroughFilterResult) => {
2064
+ if (passedThroughFilterResult) {
2065
+ foundAbsolutePaths.push(itemPath);
2066
+ }
2067
+ waitingForFiltersToFinish -= 1;
2068
+ maybeDone();
2069
+ }).catch((err) => {
2070
+ reject(err);
2071
+ });
2072
+ } else if (passedThroughFilter) {
2073
+ foundAbsolutePaths.push(itemPath);
2074
+ }
2075
+ } else {
2076
+ foundAbsolutePaths.push(itemPath);
2077
+ }
2078
+ }
2079
+ }
2080
+ },
2081
+ (err) => {
2082
+ if (err) {
2083
+ reject(err);
2084
+ } else {
2085
+ treeWalkerDone = true;
2086
+ maybeDone();
2087
+ }
2088
+ }
2089
+ );
2090
+ });
2091
+ };
2092
+ var findAsyncInit = (path2, options) => {
2093
+ return inspect.async(path2, { symlinks: "follow" }).then((entryPointInspect) => {
2094
+ if (entryPointInspect === void 0) {
2095
+ throw generatePathDoesntExistError(path2);
2096
+ } else if (entryPointInspect.type !== "dir") {
2097
+ throw generatePathNotDirectoryError(path2);
2098
+ }
2099
+ return findAsync(path2, normalizeOptions(options));
2100
+ });
2101
+ };
2102
+ exports.validateInput = validateInput;
2103
+ exports.sync = findSyncInit;
2104
+ exports.async = findAsyncInit;
2105
+ }
2106
+ });
2107
+ var require_inspect_tree = (0, import_chunk_2ESYSVXG.__commonJS)({
2108
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/inspect_tree.js"(exports) {
2109
+ "use strict";
2110
+ var crypto = (0, import_chunk_2ESYSVXG.__require)("crypto");
2111
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2112
+ var inspect = require_inspect();
2113
+ var list = require_list();
2114
+ var validate = require_validate();
2115
+ var treeWalker = require_tree_walker();
2116
+ var validateInput = (methodName, path2, options) => {
2117
+ const methodSignature = `${methodName}(path, [options])`;
2118
+ validate.argument(methodSignature, "path", path2, ["string"]);
2119
+ validate.options(methodSignature, "options", options, {
2120
+ checksum: ["string"],
2121
+ relativePath: ["boolean"],
2122
+ times: ["boolean"],
2123
+ symlinks: ["string"]
2124
+ });
2125
+ if (options && options.checksum !== void 0 && inspect.supportedChecksumAlgorithms.indexOf(options.checksum) === -1) {
2126
+ throw new Error(
2127
+ `Argument "options.checksum" passed to ${methodSignature} must have one of values: ${inspect.supportedChecksumAlgorithms.join(
2128
+ ", "
2129
+ )}`
2130
+ );
2131
+ }
2132
+ if (options && options.symlinks !== void 0 && inspect.symlinkOptions.indexOf(options.symlinks) === -1) {
2133
+ throw new Error(
2134
+ `Argument "options.symlinks" passed to ${methodSignature} must have one of values: ${inspect.symlinkOptions.join(
2135
+ ", "
2136
+ )}`
2137
+ );
2138
+ }
2139
+ };
2140
+ var relativePathInTree = (parentInspectObj, inspectObj) => {
2141
+ if (parentInspectObj === void 0) {
2142
+ return ".";
2143
+ }
2144
+ return parentInspectObj.relativePath + "/" + inspectObj.name;
2145
+ };
2146
+ var checksumOfDir = (inspectList, algo) => {
2147
+ const hash = crypto.createHash(algo);
2148
+ inspectList.forEach((inspectObj) => {
2149
+ hash.update(inspectObj.name + inspectObj[algo]);
2150
+ });
2151
+ return hash.digest("hex");
2152
+ };
2153
+ var calculateTreeDependentProperties = (parentInspectObj, inspectObj, options) => {
2154
+ if (options.relativePath) {
2155
+ inspectObj.relativePath = relativePathInTree(parentInspectObj, inspectObj);
2156
+ }
2157
+ if (inspectObj.type === "dir") {
2158
+ inspectObj.children.forEach((childInspectObj) => {
2159
+ calculateTreeDependentProperties(inspectObj, childInspectObj, options);
2160
+ });
2161
+ inspectObj.size = 0;
2162
+ inspectObj.children.sort((a, b) => {
2163
+ if (a.type === "dir" && b.type === "file") {
2164
+ return -1;
2165
+ }
2166
+ if (a.type === "file" && b.type === "dir") {
2167
+ return 1;
2168
+ }
2169
+ return a.name.localeCompare(b.name);
2170
+ });
2171
+ inspectObj.children.forEach((child) => {
2172
+ inspectObj.size += child.size || 0;
2173
+ });
2174
+ if (options.checksum) {
2175
+ inspectObj[options.checksum] = checksumOfDir(
2176
+ inspectObj.children,
2177
+ options.checksum
2178
+ );
2179
+ }
2180
+ }
2181
+ };
2182
+ var findParentInTree = (treeNode, pathChain, item) => {
2183
+ const name = pathChain[0];
2184
+ if (pathChain.length > 1) {
2185
+ const itemInTreeForPathChain = treeNode.children.find((child) => {
2186
+ return child.name === name;
2187
+ });
2188
+ return findParentInTree(itemInTreeForPathChain, pathChain.slice(1), item);
2189
+ }
2190
+ return treeNode;
2191
+ };
2192
+ var inspectTreeSync = (path2, opts) => {
2193
+ const options = opts || {};
2194
+ let tree;
2195
+ treeWalker.sync(path2, { inspectOptions: options }, (itemPath, item) => {
2196
+ if (item) {
2197
+ if (item.type === "dir") {
2198
+ item.children = [];
2199
+ }
2200
+ const relativePath = pathUtil.relative(path2, itemPath);
2201
+ if (relativePath === "") {
2202
+ tree = item;
2203
+ } else {
2204
+ const parentItem = findParentInTree(
2205
+ tree,
2206
+ relativePath.split(pathUtil.sep),
2207
+ item
2208
+ );
2209
+ parentItem.children.push(item);
2210
+ }
2211
+ }
2212
+ });
2213
+ if (tree) {
2214
+ calculateTreeDependentProperties(void 0, tree, options);
2215
+ }
2216
+ return tree;
2217
+ };
2218
+ var inspectTreeAsync = (path2, opts) => {
2219
+ const options = opts || {};
2220
+ let tree;
2221
+ return new Promise((resolve, reject) => {
2222
+ treeWalker.async(
2223
+ path2,
2224
+ { inspectOptions: options },
2225
+ (itemPath, item) => {
2226
+ if (item) {
2227
+ if (item.type === "dir") {
2228
+ item.children = [];
2229
+ }
2230
+ const relativePath = pathUtil.relative(path2, itemPath);
2231
+ if (relativePath === "") {
2232
+ tree = item;
2233
+ } else {
2234
+ const parentItem = findParentInTree(
2235
+ tree,
2236
+ relativePath.split(pathUtil.sep),
2237
+ item
2238
+ );
2239
+ parentItem.children.push(item);
2240
+ }
2241
+ }
2242
+ },
2243
+ (err) => {
2244
+ if (err) {
2245
+ reject(err);
2246
+ } else {
2247
+ if (tree) {
2248
+ calculateTreeDependentProperties(void 0, tree, options);
2249
+ }
2250
+ resolve(tree);
2251
+ }
2252
+ }
2253
+ );
2254
+ });
2255
+ };
2256
+ exports.validateInput = validateInput;
2257
+ exports.sync = inspectTreeSync;
2258
+ exports.async = inspectTreeAsync;
2259
+ }
2260
+ });
2261
+ var require_exists = (0, import_chunk_2ESYSVXG.__commonJS)({
2262
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/exists.js"(exports) {
2263
+ "use strict";
2264
+ var fs2 = require_fs();
2265
+ var validate = require_validate();
2266
+ var validateInput = (methodName, path2) => {
2267
+ const methodSignature = `${methodName}(path)`;
2268
+ validate.argument(methodSignature, "path", path2, ["string"]);
2269
+ };
2270
+ var existsSync = (path2) => {
2271
+ try {
2272
+ const stat = fs2.statSync(path2);
2273
+ if (stat.isDirectory()) {
2274
+ return "dir";
2275
+ } else if (stat.isFile()) {
2276
+ return "file";
2277
+ }
2278
+ return "other";
2279
+ } catch (err) {
2280
+ if (err.code !== "ENOENT") {
2281
+ throw err;
2282
+ }
2283
+ }
2284
+ return false;
2285
+ };
2286
+ var existsAsync = (path2) => {
2287
+ return new Promise((resolve, reject) => {
2288
+ fs2.stat(path2).then((stat) => {
2289
+ if (stat.isDirectory()) {
2290
+ resolve("dir");
2291
+ } else if (stat.isFile()) {
2292
+ resolve("file");
2293
+ } else {
2294
+ resolve("other");
2295
+ }
2296
+ }).catch((err) => {
2297
+ if (err.code === "ENOENT") {
2298
+ resolve(false);
2299
+ } else {
2300
+ reject(err);
2301
+ }
2302
+ });
2303
+ });
2304
+ };
2305
+ exports.validateInput = validateInput;
2306
+ exports.sync = existsSync;
2307
+ exports.async = existsAsync;
2308
+ }
2309
+ });
2310
+ var require_copy = (0, import_chunk_2ESYSVXG.__commonJS)({
2311
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/copy.js"(exports) {
2312
+ "use strict";
2313
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2314
+ var fs2 = require_fs();
2315
+ var dir = require_dir();
2316
+ var exists = require_exists();
2317
+ var inspect = require_inspect();
2318
+ var write = require_write();
2319
+ var matcher = require_matcher();
2320
+ var fileMode = require_mode();
2321
+ var treeWalker = require_tree_walker();
2322
+ var validate = require_validate();
2323
+ var validateInput = (methodName, from, to, options) => {
2324
+ const methodSignature = `${methodName}(from, to, [options])`;
2325
+ validate.argument(methodSignature, "from", from, ["string"]);
2326
+ validate.argument(methodSignature, "to", to, ["string"]);
2327
+ validate.options(methodSignature, "options", options, {
2328
+ overwrite: ["boolean", "function"],
2329
+ matching: ["string", "array of string"],
2330
+ ignoreCase: ["boolean"]
2331
+ });
2332
+ };
2333
+ var parseOptions = (options, from) => {
2334
+ const opts = options || {};
2335
+ const parsedOptions = {};
2336
+ if (opts.ignoreCase === void 0) {
2337
+ opts.ignoreCase = false;
2338
+ }
2339
+ parsedOptions.overwrite = opts.overwrite;
2340
+ if (opts.matching) {
2341
+ parsedOptions.allowedToCopy = matcher.create(
2342
+ from,
2343
+ opts.matching,
2344
+ opts.ignoreCase
2345
+ );
2346
+ } else {
2347
+ parsedOptions.allowedToCopy = () => {
2348
+ return true;
2349
+ };
2350
+ }
2351
+ return parsedOptions;
2352
+ };
2353
+ var generateNoSourceError = (path2) => {
2354
+ const err = new Error(`Path to copy doesn't exist ${path2}`);
2355
+ err.code = "ENOENT";
2356
+ return err;
2357
+ };
2358
+ var generateDestinationExistsError = (path2) => {
2359
+ const err = new Error(`Destination path already exists ${path2}`);
2360
+ err.code = "EEXIST";
2361
+ return err;
2362
+ };
2363
+ var inspectOptions = {
2364
+ mode: true,
2365
+ symlinks: "report",
2366
+ times: true,
2367
+ absolutePath: true
2368
+ };
2369
+ var shouldThrowDestinationExistsError = (context) => {
2370
+ return typeof context.opts.overwrite !== "function" && context.opts.overwrite !== true;
2371
+ };
2372
+ var checksBeforeCopyingSync = (from, to, opts) => {
2373
+ if (!exists.sync(from)) {
2374
+ throw generateNoSourceError(from);
2375
+ }
2376
+ if (exists.sync(to) && !opts.overwrite) {
2377
+ throw generateDestinationExistsError(to);
2378
+ }
2379
+ };
2380
+ var canOverwriteItSync = (context) => {
2381
+ if (typeof context.opts.overwrite === "function") {
2382
+ const destInspectData = inspect.sync(context.destPath, inspectOptions);
2383
+ return context.opts.overwrite(context.srcInspectData, destInspectData);
2384
+ }
2385
+ return context.opts.overwrite === true;
2386
+ };
2387
+ var copyFileSync = (srcPath, destPath, mode, context) => {
2388
+ const data = fs2.readFileSync(srcPath);
2389
+ try {
2390
+ fs2.writeFileSync(destPath, data, { mode, flag: "wx" });
2391
+ } catch (err) {
2392
+ if (err.code === "ENOENT") {
2393
+ write.sync(destPath, data, { mode });
2394
+ } else if (err.code === "EEXIST") {
2395
+ if (canOverwriteItSync(context)) {
2396
+ fs2.writeFileSync(destPath, data, { mode });
2397
+ } else if (shouldThrowDestinationExistsError(context)) {
2398
+ throw generateDestinationExistsError(context.destPath);
2399
+ }
2400
+ } else {
2401
+ throw err;
2402
+ }
2403
+ }
2404
+ };
2405
+ var copySymlinkSync = (from, to) => {
2406
+ const symlinkPointsAt = fs2.readlinkSync(from);
2407
+ try {
2408
+ fs2.symlinkSync(symlinkPointsAt, to);
2409
+ } catch (err) {
2410
+ if (err.code === "EEXIST") {
2411
+ fs2.unlinkSync(to);
2412
+ fs2.symlinkSync(symlinkPointsAt, to);
2413
+ } else {
2414
+ throw err;
2415
+ }
2416
+ }
2417
+ };
2418
+ var copyItemSync = (srcPath, srcInspectData, destPath, opts) => {
2419
+ const context = { srcPath, destPath, srcInspectData, opts };
2420
+ const mode = fileMode.normalizeFileMode(srcInspectData.mode);
2421
+ if (srcInspectData.type === "dir") {
2422
+ dir.createSync(destPath, { mode });
2423
+ } else if (srcInspectData.type === "file") {
2424
+ copyFileSync(srcPath, destPath, mode, context);
2425
+ } else if (srcInspectData.type === "symlink") {
2426
+ copySymlinkSync(srcPath, destPath);
2427
+ }
2428
+ };
2429
+ var copySync = (from, to, options) => {
2430
+ const opts = parseOptions(options, from);
2431
+ checksBeforeCopyingSync(from, to, opts);
2432
+ treeWalker.sync(from, { inspectOptions }, (srcPath, srcInspectData) => {
2433
+ const rel = pathUtil.relative(from, srcPath);
2434
+ const destPath = pathUtil.resolve(to, rel);
2435
+ if (opts.allowedToCopy(srcPath, destPath, srcInspectData)) {
2436
+ copyItemSync(srcPath, srcInspectData, destPath, opts);
2437
+ }
2438
+ });
2439
+ };
2440
+ var checksBeforeCopyingAsync = (from, to, opts) => {
2441
+ return exists.async(from).then((srcPathExists) => {
2442
+ if (!srcPathExists) {
2443
+ throw generateNoSourceError(from);
2444
+ } else {
2445
+ return exists.async(to);
2446
+ }
2447
+ }).then((destPathExists) => {
2448
+ if (destPathExists && !opts.overwrite) {
2449
+ throw generateDestinationExistsError(to);
2450
+ }
2451
+ });
2452
+ };
2453
+ var canOverwriteItAsync = (context) => {
2454
+ return new Promise((resolve, reject) => {
2455
+ if (typeof context.opts.overwrite === "function") {
2456
+ inspect.async(context.destPath, inspectOptions).then((destInspectData) => {
2457
+ resolve(
2458
+ context.opts.overwrite(context.srcInspectData, destInspectData)
2459
+ );
2460
+ }).catch(reject);
2461
+ } else {
2462
+ resolve(context.opts.overwrite === true);
2463
+ }
2464
+ });
2465
+ };
2466
+ var copyFileAsync = (srcPath, destPath, mode, context, runOptions) => {
2467
+ return new Promise((resolve, reject) => {
2468
+ const runOpts = runOptions || {};
2469
+ let flags = "wx";
2470
+ if (runOpts.overwrite) {
2471
+ flags = "w";
2472
+ }
2473
+ const readStream = fs2.createReadStream(srcPath);
2474
+ const writeStream = fs2.createWriteStream(destPath, { mode, flags });
2475
+ readStream.on("error", reject);
2476
+ writeStream.on("error", (err) => {
2477
+ readStream.resume();
2478
+ if (err.code === "ENOENT") {
2479
+ dir.createAsync(pathUtil.dirname(destPath)).then(() => {
2480
+ copyFileAsync(srcPath, destPath, mode, context).then(
2481
+ resolve,
2482
+ reject
2483
+ );
2484
+ }).catch(reject);
2485
+ } else if (err.code === "EEXIST") {
2486
+ canOverwriteItAsync(context).then((canOverwite) => {
2487
+ if (canOverwite) {
2488
+ copyFileAsync(srcPath, destPath, mode, context, {
2489
+ overwrite: true
2490
+ }).then(resolve, reject);
2491
+ } else if (shouldThrowDestinationExistsError(context)) {
2492
+ reject(generateDestinationExistsError(destPath));
2493
+ } else {
2494
+ resolve();
2495
+ }
2496
+ }).catch(reject);
2497
+ } else {
2498
+ reject(err);
2499
+ }
2500
+ });
2501
+ writeStream.on("finish", resolve);
2502
+ readStream.pipe(writeStream);
2503
+ });
2504
+ };
2505
+ var copySymlinkAsync = (from, to) => {
2506
+ return fs2.readlink(from).then((symlinkPointsAt) => {
2507
+ return new Promise((resolve, reject) => {
2508
+ fs2.symlink(symlinkPointsAt, to).then(resolve).catch((err) => {
2509
+ if (err.code === "EEXIST") {
2510
+ fs2.unlink(to).then(() => {
2511
+ return fs2.symlink(symlinkPointsAt, to);
2512
+ }).then(resolve, reject);
2513
+ } else {
2514
+ reject(err);
2515
+ }
2516
+ });
2517
+ });
2518
+ });
2519
+ };
2520
+ var copyItemAsync = (srcPath, srcInspectData, destPath, opts) => {
2521
+ const context = { srcPath, destPath, srcInspectData, opts };
2522
+ const mode = fileMode.normalizeFileMode(srcInspectData.mode);
2523
+ if (srcInspectData.type === "dir") {
2524
+ return dir.createAsync(destPath, { mode });
2525
+ } else if (srcInspectData.type === "file") {
2526
+ return copyFileAsync(srcPath, destPath, mode, context);
2527
+ } else if (srcInspectData.type === "symlink") {
2528
+ return copySymlinkAsync(srcPath, destPath);
2529
+ }
2530
+ return Promise.resolve();
2531
+ };
2532
+ var copyAsync = (from, to, options) => {
2533
+ return new Promise((resolve, reject) => {
2534
+ const opts = parseOptions(options, from);
2535
+ checksBeforeCopyingAsync(from, to, opts).then(() => {
2536
+ let allFilesDelivered = false;
2537
+ let filesInProgress = 0;
2538
+ treeWalker.async(
2539
+ from,
2540
+ { inspectOptions },
2541
+ (srcPath, item) => {
2542
+ if (item) {
2543
+ const rel = pathUtil.relative(from, srcPath);
2544
+ const destPath = pathUtil.resolve(to, rel);
2545
+ if (opts.allowedToCopy(srcPath, item, destPath)) {
2546
+ filesInProgress += 1;
2547
+ copyItemAsync(srcPath, item, destPath, opts).then(() => {
2548
+ filesInProgress -= 1;
2549
+ if (allFilesDelivered && filesInProgress === 0) {
2550
+ resolve();
2551
+ }
2552
+ }).catch(reject);
2553
+ }
2554
+ }
2555
+ },
2556
+ (err) => {
2557
+ if (err) {
2558
+ reject(err);
2559
+ } else {
2560
+ allFilesDelivered = true;
2561
+ if (allFilesDelivered && filesInProgress === 0) {
2562
+ resolve();
2563
+ }
2564
+ }
2565
+ }
2566
+ );
2567
+ }).catch(reject);
2568
+ });
2569
+ };
2570
+ exports.validateInput = validateInput;
2571
+ exports.sync = copySync;
2572
+ exports.async = copyAsync;
2573
+ }
2574
+ });
2575
+ var require_move = (0, import_chunk_2ESYSVXG.__commonJS)({
2576
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/move.js"(exports) {
2577
+ "use strict";
2578
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2579
+ var fs2 = require_fs();
2580
+ var validate = require_validate();
2581
+ var copy = require_copy();
2582
+ var dir = require_dir();
2583
+ var exists = require_exists();
2584
+ var remove = require_remove();
2585
+ var validateInput = (methodName, from, to, options) => {
2586
+ const methodSignature = `${methodName}(from, to, [options])`;
2587
+ validate.argument(methodSignature, "from", from, ["string"]);
2588
+ validate.argument(methodSignature, "to", to, ["string"]);
2589
+ validate.options(methodSignature, "options", options, {
2590
+ overwrite: ["boolean"]
2591
+ });
2592
+ };
2593
+ var parseOptions = (options) => {
2594
+ const opts = options || {};
2595
+ return opts;
2596
+ };
2597
+ var generateDestinationExistsError = (path2) => {
2598
+ const err = new Error(`Destination path already exists ${path2}`);
2599
+ err.code = "EEXIST";
2600
+ return err;
2601
+ };
2602
+ var generateSourceDoesntExistError = (path2) => {
2603
+ const err = new Error(`Path to move doesn't exist ${path2}`);
2604
+ err.code = "ENOENT";
2605
+ return err;
2606
+ };
2607
+ var moveSync = (from, to, options) => {
2608
+ const opts = parseOptions(options);
2609
+ if (exists.sync(to) !== false && opts.overwrite !== true) {
2610
+ throw generateDestinationExistsError(to);
2611
+ }
2612
+ try {
2613
+ fs2.renameSync(from, to);
2614
+ } catch (err) {
2615
+ if (err.code === "EISDIR" || err.code === "EPERM") {
2616
+ remove.sync(to);
2617
+ fs2.renameSync(from, to);
2618
+ } else if (err.code === "EXDEV") {
2619
+ copy.sync(from, to, { overwrite: true });
2620
+ remove.sync(from);
2621
+ } else if (err.code === "ENOENT") {
2622
+ if (!exists.sync(from)) {
2623
+ throw generateSourceDoesntExistError(from);
2624
+ }
2625
+ dir.createSync(pathUtil.dirname(to));
2626
+ fs2.renameSync(from, to);
2627
+ } else {
2628
+ throw err;
2629
+ }
2630
+ }
2631
+ };
2632
+ var ensureDestinationPathExistsAsync = (to) => {
2633
+ return new Promise((resolve, reject) => {
2634
+ const destDir = pathUtil.dirname(to);
2635
+ exists.async(destDir).then((dstExists) => {
2636
+ if (!dstExists) {
2637
+ dir.createAsync(destDir).then(resolve, reject);
2638
+ } else {
2639
+ reject();
2640
+ }
2641
+ }).catch(reject);
2642
+ });
2643
+ };
2644
+ var moveAsync = (from, to, options) => {
2645
+ const opts = parseOptions(options);
2646
+ return new Promise((resolve, reject) => {
2647
+ exists.async(to).then((destinationExists) => {
2648
+ if (destinationExists !== false && opts.overwrite !== true) {
2649
+ reject(generateDestinationExistsError(to));
2650
+ } else {
2651
+ fs2.rename(from, to).then(resolve).catch((err) => {
2652
+ if (err.code === "EISDIR" || err.code === "EPERM") {
2653
+ remove.async(to).then(() => fs2.rename(from, to)).then(resolve, reject);
2654
+ } else if (err.code === "EXDEV") {
2655
+ copy.async(from, to, { overwrite: true }).then(() => remove.async(from)).then(resolve, reject);
2656
+ } else if (err.code === "ENOENT") {
2657
+ exists.async(from).then((srcExists) => {
2658
+ if (!srcExists) {
2659
+ reject(generateSourceDoesntExistError(from));
2660
+ } else {
2661
+ ensureDestinationPathExistsAsync(to).then(() => {
2662
+ return fs2.rename(from, to);
2663
+ }).then(resolve, reject);
2664
+ }
2665
+ }).catch(reject);
2666
+ } else {
2667
+ reject(err);
2668
+ }
2669
+ });
2670
+ }
2671
+ });
2672
+ });
2673
+ };
2674
+ exports.validateInput = validateInput;
2675
+ exports.sync = moveSync;
2676
+ exports.async = moveAsync;
2677
+ }
2678
+ });
2679
+ var require_read = (0, import_chunk_2ESYSVXG.__commonJS)({
2680
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/read.js"(exports) {
2681
+ "use strict";
2682
+ var fs2 = require_fs();
2683
+ var validate = require_validate();
2684
+ var supportedReturnAs = ["utf8", "buffer", "json", "jsonWithDates"];
2685
+ var validateInput = (methodName, path2, returnAs) => {
2686
+ const methodSignature = `${methodName}(path, returnAs)`;
2687
+ validate.argument(methodSignature, "path", path2, ["string"]);
2688
+ validate.argument(methodSignature, "returnAs", returnAs, [
2689
+ "string",
2690
+ "undefined"
2691
+ ]);
2692
+ if (returnAs && supportedReturnAs.indexOf(returnAs) === -1) {
2693
+ throw new Error(
2694
+ `Argument "returnAs" passed to ${methodSignature} must have one of values: ${supportedReturnAs.join(
2695
+ ", "
2696
+ )}`
2697
+ );
2698
+ }
2699
+ };
2700
+ var jsonDateParser = (key, value) => {
2701
+ const reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
2702
+ if (typeof value === "string") {
2703
+ if (reISO.exec(value)) {
2704
+ return new Date(value);
2705
+ }
2706
+ }
2707
+ return value;
2708
+ };
2709
+ var makeNicerJsonParsingError = (path2, err) => {
2710
+ const nicerError = new Error(
2711
+ `JSON parsing failed while reading ${path2} [${err}]`
2712
+ );
2713
+ nicerError.originalError = err;
2714
+ return nicerError;
2715
+ };
2716
+ var readSync = (path2, returnAs) => {
2717
+ const retAs = returnAs || "utf8";
2718
+ let data;
2719
+ let encoding = "utf8";
2720
+ if (retAs === "buffer") {
2721
+ encoding = null;
2722
+ }
2723
+ try {
2724
+ data = fs2.readFileSync(path2, { encoding });
2725
+ } catch (err) {
2726
+ if (err.code === "ENOENT") {
2727
+ return void 0;
2728
+ }
2729
+ throw err;
2730
+ }
2731
+ try {
2732
+ if (retAs === "json") {
2733
+ data = JSON.parse(data);
2734
+ } else if (retAs === "jsonWithDates") {
2735
+ data = JSON.parse(data, jsonDateParser);
2736
+ }
2737
+ } catch (err) {
2738
+ throw makeNicerJsonParsingError(path2, err);
2739
+ }
2740
+ return data;
2741
+ };
2742
+ var readAsync = (path2, returnAs) => {
2743
+ return new Promise((resolve, reject) => {
2744
+ const retAs = returnAs || "utf8";
2745
+ let encoding = "utf8";
2746
+ if (retAs === "buffer") {
2747
+ encoding = null;
2748
+ }
2749
+ fs2.readFile(path2, { encoding }).then((data) => {
2750
+ try {
2751
+ if (retAs === "json") {
2752
+ resolve(JSON.parse(data));
2753
+ } else if (retAs === "jsonWithDates") {
2754
+ resolve(JSON.parse(data, jsonDateParser));
2755
+ } else {
2756
+ resolve(data);
2757
+ }
2758
+ } catch (err) {
2759
+ reject(makeNicerJsonParsingError(path2, err));
2760
+ }
2761
+ }).catch((err) => {
2762
+ if (err.code === "ENOENT") {
2763
+ resolve(void 0);
2764
+ } else {
2765
+ reject(err);
2766
+ }
2767
+ });
2768
+ });
2769
+ };
2770
+ exports.validateInput = validateInput;
2771
+ exports.sync = readSync;
2772
+ exports.async = readAsync;
2773
+ }
2774
+ });
2775
+ var require_rename = (0, import_chunk_2ESYSVXG.__commonJS)({
2776
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/rename.js"(exports) {
2777
+ "use strict";
2778
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2779
+ var move = require_move();
2780
+ var validate = require_validate();
2781
+ var validateInput = (methodName, path2, newName, options) => {
2782
+ const methodSignature = `${methodName}(path, newName, [options])`;
2783
+ validate.argument(methodSignature, "path", path2, ["string"]);
2784
+ validate.argument(methodSignature, "newName", newName, ["string"]);
2785
+ validate.options(methodSignature, "options", options, {
2786
+ overwrite: ["boolean"]
2787
+ });
2788
+ if (pathUtil.basename(newName) !== newName) {
2789
+ throw new Error(
2790
+ `Argument "newName" passed to ${methodSignature} should be a filename, not a path. Received "${newName}"`
2791
+ );
2792
+ }
2793
+ };
2794
+ var renameSync = (path2, newName, options) => {
2795
+ const newPath = pathUtil.join(pathUtil.dirname(path2), newName);
2796
+ move.sync(path2, newPath, options);
2797
+ };
2798
+ var renameAsync = (path2, newName, options) => {
2799
+ const newPath = pathUtil.join(pathUtil.dirname(path2), newName);
2800
+ return move.async(path2, newPath, options);
2801
+ };
2802
+ exports.validateInput = validateInput;
2803
+ exports.sync = renameSync;
2804
+ exports.async = renameAsync;
2805
+ }
2806
+ });
2807
+ var require_symlink = (0, import_chunk_2ESYSVXG.__commonJS)({
2808
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/symlink.js"(exports) {
2809
+ "use strict";
2810
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2811
+ var fs2 = require_fs();
2812
+ var validate = require_validate();
2813
+ var dir = require_dir();
2814
+ var validateInput = (methodName, symlinkValue, path2) => {
2815
+ const methodSignature = `${methodName}(symlinkValue, path)`;
2816
+ validate.argument(methodSignature, "symlinkValue", symlinkValue, ["string"]);
2817
+ validate.argument(methodSignature, "path", path2, ["string"]);
2818
+ };
2819
+ var symlinkSync = (symlinkValue, path2) => {
2820
+ try {
2821
+ fs2.symlinkSync(symlinkValue, path2);
2822
+ } catch (err) {
2823
+ if (err.code === "ENOENT") {
2824
+ dir.createSync(pathUtil.dirname(path2));
2825
+ fs2.symlinkSync(symlinkValue, path2);
2826
+ } else {
2827
+ throw err;
2828
+ }
2829
+ }
2830
+ };
2831
+ var symlinkAsync = (symlinkValue, path2) => {
2832
+ return new Promise((resolve, reject) => {
2833
+ fs2.symlink(symlinkValue, path2).then(resolve).catch((err) => {
2834
+ if (err.code === "ENOENT") {
2835
+ dir.createAsync(pathUtil.dirname(path2)).then(() => {
2836
+ return fs2.symlink(symlinkValue, path2);
2837
+ }).then(resolve, reject);
2838
+ } else {
2839
+ reject(err);
2840
+ }
2841
+ });
2842
+ });
2843
+ };
2844
+ exports.validateInput = validateInput;
2845
+ exports.sync = symlinkSync;
2846
+ exports.async = symlinkAsync;
2847
+ }
2848
+ });
2849
+ var require_streams = (0, import_chunk_2ESYSVXG.__commonJS)({
2850
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/streams.js"(exports) {
2851
+ "use strict";
2852
+ var fs2 = (0, import_chunk_2ESYSVXG.__require)("fs");
2853
+ exports.createWriteStream = fs2.createWriteStream;
2854
+ exports.createReadStream = fs2.createReadStream;
2855
+ }
2856
+ });
2857
+ var require_tmp_dir = (0, import_chunk_2ESYSVXG.__commonJS)({
2858
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/tmp_dir.js"(exports) {
2859
+ "use strict";
2860
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2861
+ var os = (0, import_chunk_2ESYSVXG.__require)("os");
2862
+ var crypto = (0, import_chunk_2ESYSVXG.__require)("crypto");
2863
+ var dir = require_dir();
2864
+ var fs2 = require_fs();
2865
+ var validate = require_validate();
2866
+ var validateInput = (methodName, options) => {
2867
+ const methodSignature = `${methodName}([options])`;
2868
+ validate.options(methodSignature, "options", options, {
2869
+ prefix: ["string"],
2870
+ basePath: ["string"]
2871
+ });
2872
+ };
2873
+ var getOptionsDefaults = (passedOptions, cwdPath) => {
2874
+ passedOptions = passedOptions || {};
2875
+ const options = {};
2876
+ if (typeof passedOptions.prefix !== "string") {
2877
+ options.prefix = "";
2878
+ } else {
2879
+ options.prefix = passedOptions.prefix;
2880
+ }
2881
+ if (typeof passedOptions.basePath === "string") {
2882
+ options.basePath = pathUtil.resolve(cwdPath, passedOptions.basePath);
2883
+ } else {
2884
+ options.basePath = os.tmpdir();
2885
+ }
2886
+ return options;
2887
+ };
2888
+ var randomStringLength = 32;
2889
+ var tmpDirSync = (cwdPath, passedOptions) => {
2890
+ const options = getOptionsDefaults(passedOptions, cwdPath);
2891
+ const randomString = crypto.randomBytes(randomStringLength / 2).toString("hex");
2892
+ const dirPath = pathUtil.join(
2893
+ options.basePath,
2894
+ options.prefix + randomString
2895
+ );
2896
+ try {
2897
+ fs2.mkdirSync(dirPath);
2898
+ } catch (err) {
2899
+ if (err.code === "ENOENT") {
2900
+ dir.sync(dirPath);
2901
+ } else {
2902
+ throw err;
2903
+ }
2904
+ }
2905
+ return dirPath;
2906
+ };
2907
+ var tmpDirAsync = (cwdPath, passedOptions) => {
2908
+ return new Promise((resolve, reject) => {
2909
+ const options = getOptionsDefaults(passedOptions, cwdPath);
2910
+ crypto.randomBytes(randomStringLength / 2, (err, bytes) => {
2911
+ if (err) {
2912
+ reject(err);
2913
+ } else {
2914
+ const randomString = bytes.toString("hex");
2915
+ const dirPath = pathUtil.join(
2916
+ options.basePath,
2917
+ options.prefix + randomString
2918
+ );
2919
+ fs2.mkdir(dirPath, (err2) => {
2920
+ if (err2) {
2921
+ if (err2.code === "ENOENT") {
2922
+ dir.async(dirPath).then(() => {
2923
+ resolve(dirPath);
2924
+ }, reject);
2925
+ } else {
2926
+ reject(err2);
2927
+ }
2928
+ } else {
2929
+ resolve(dirPath);
2930
+ }
2931
+ });
2932
+ }
2933
+ });
2934
+ });
2935
+ };
2936
+ exports.validateInput = validateInput;
2937
+ exports.sync = tmpDirSync;
2938
+ exports.async = tmpDirAsync;
2939
+ }
2940
+ });
2941
+ var require_jetpack = (0, import_chunk_2ESYSVXG.__commonJS)({
2942
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/lib/jetpack.js"(exports, module2) {
2943
+ "use strict";
2944
+ var util = (0, import_chunk_2ESYSVXG.__require)("util");
2945
+ var pathUtil = (0, import_chunk_2ESYSVXG.__require)("path");
2946
+ var append = require_append();
2947
+ var dir = require_dir();
2948
+ var file = require_file();
2949
+ var find = require_find();
2950
+ var inspect = require_inspect();
2951
+ var inspectTree = require_inspect_tree();
2952
+ var copy = require_copy();
2953
+ var exists = require_exists();
2954
+ var list = require_list();
2955
+ var move = require_move();
2956
+ var read = require_read();
2957
+ var remove = require_remove();
2958
+ var rename = require_rename();
2959
+ var symlink = require_symlink();
2960
+ var streams = require_streams();
2961
+ var tmpDir = require_tmp_dir();
2962
+ var write = require_write();
2963
+ var jetpackContext = (cwdPath) => {
2964
+ const getCwdPath = () => {
2965
+ return cwdPath || process.cwd();
2966
+ };
2967
+ const cwd = function() {
2968
+ if (arguments.length === 0) {
2969
+ return getCwdPath();
2970
+ }
2971
+ const args = Array.prototype.slice.call(arguments);
2972
+ const pathParts = [getCwdPath()].concat(args);
2973
+ return jetpackContext(pathUtil.resolve.apply(null, pathParts));
2974
+ };
2975
+ const resolvePath = (path2) => {
2976
+ return pathUtil.resolve(getCwdPath(), path2);
2977
+ };
2978
+ const getPath = function() {
2979
+ Array.prototype.unshift.call(arguments, getCwdPath());
2980
+ return pathUtil.resolve.apply(null, arguments);
2981
+ };
2982
+ const normalizeOptions = (options) => {
2983
+ const opts = options || {};
2984
+ opts.cwd = getCwdPath();
2985
+ return opts;
2986
+ };
2987
+ const api = {
2988
+ cwd,
2989
+ path: getPath,
2990
+ append: (path2, data, options) => {
2991
+ append.validateInput("append", path2, data, options);
2992
+ append.sync(resolvePath(path2), data, options);
2993
+ },
2994
+ appendAsync: (path2, data, options) => {
2995
+ append.validateInput("appendAsync", path2, data, options);
2996
+ return append.async(resolvePath(path2), data, options);
2997
+ },
2998
+ copy: (from, to, options) => {
2999
+ copy.validateInput("copy", from, to, options);
3000
+ copy.sync(resolvePath(from), resolvePath(to), options);
3001
+ },
3002
+ copyAsync: (from, to, options) => {
3003
+ copy.validateInput("copyAsync", from, to, options);
3004
+ return copy.async(resolvePath(from), resolvePath(to), options);
3005
+ },
3006
+ createWriteStream: (path2, options) => {
3007
+ return streams.createWriteStream(resolvePath(path2), options);
3008
+ },
3009
+ createReadStream: (path2, options) => {
3010
+ return streams.createReadStream(resolvePath(path2), options);
3011
+ },
3012
+ dir: (path2, criteria) => {
3013
+ dir.validateInput("dir", path2, criteria);
3014
+ const normalizedPath = resolvePath(path2);
3015
+ dir.sync(normalizedPath, criteria);
3016
+ return cwd(normalizedPath);
3017
+ },
3018
+ dirAsync: (path2, criteria) => {
3019
+ dir.validateInput("dirAsync", path2, criteria);
3020
+ return new Promise((resolve, reject) => {
3021
+ const normalizedPath = resolvePath(path2);
3022
+ dir.async(normalizedPath, criteria).then(() => {
3023
+ resolve(cwd(normalizedPath));
3024
+ }, reject);
3025
+ });
3026
+ },
3027
+ exists: (path2) => {
3028
+ exists.validateInput("exists", path2);
3029
+ return exists.sync(resolvePath(path2));
3030
+ },
3031
+ existsAsync: (path2) => {
3032
+ exists.validateInput("existsAsync", path2);
3033
+ return exists.async(resolvePath(path2));
3034
+ },
3035
+ file: (path2, criteria) => {
3036
+ file.validateInput("file", path2, criteria);
3037
+ file.sync(resolvePath(path2), criteria);
3038
+ return api;
3039
+ },
3040
+ fileAsync: (path2, criteria) => {
3041
+ file.validateInput("fileAsync", path2, criteria);
3042
+ return new Promise((resolve, reject) => {
3043
+ file.async(resolvePath(path2), criteria).then(() => {
3044
+ resolve(api);
3045
+ }, reject);
3046
+ });
3047
+ },
3048
+ find: (startPath, options) => {
3049
+ if (typeof options === "undefined" && typeof startPath === "object") {
3050
+ options = startPath;
3051
+ startPath = ".";
3052
+ }
3053
+ find.validateInput("find", startPath, options);
3054
+ return find.sync(resolvePath(startPath), normalizeOptions(options));
3055
+ },
3056
+ findAsync: (startPath, options) => {
3057
+ if (typeof options === "undefined" && typeof startPath === "object") {
3058
+ options = startPath;
3059
+ startPath = ".";
3060
+ }
3061
+ find.validateInput("findAsync", startPath, options);
3062
+ return find.async(resolvePath(startPath), normalizeOptions(options));
3063
+ },
3064
+ inspect: (path2, fieldsToInclude) => {
3065
+ inspect.validateInput("inspect", path2, fieldsToInclude);
3066
+ return inspect.sync(resolvePath(path2), fieldsToInclude);
3067
+ },
3068
+ inspectAsync: (path2, fieldsToInclude) => {
3069
+ inspect.validateInput("inspectAsync", path2, fieldsToInclude);
3070
+ return inspect.async(resolvePath(path2), fieldsToInclude);
3071
+ },
3072
+ inspectTree: (path2, options) => {
3073
+ inspectTree.validateInput("inspectTree", path2, options);
3074
+ return inspectTree.sync(resolvePath(path2), options);
3075
+ },
3076
+ inspectTreeAsync: (path2, options) => {
3077
+ inspectTree.validateInput("inspectTreeAsync", path2, options);
3078
+ return inspectTree.async(resolvePath(path2), options);
3079
+ },
3080
+ list: (path2) => {
3081
+ list.validateInput("list", path2);
3082
+ return list.sync(resolvePath(path2 || "."));
3083
+ },
3084
+ listAsync: (path2) => {
3085
+ list.validateInput("listAsync", path2);
3086
+ return list.async(resolvePath(path2 || "."));
3087
+ },
3088
+ move: (from, to, options) => {
3089
+ move.validateInput("move", from, to, options);
3090
+ move.sync(resolvePath(from), resolvePath(to), options);
3091
+ },
3092
+ moveAsync: (from, to, options) => {
3093
+ move.validateInput("moveAsync", from, to, options);
3094
+ return move.async(resolvePath(from), resolvePath(to), options);
3095
+ },
3096
+ read: (path2, returnAs) => {
3097
+ read.validateInput("read", path2, returnAs);
3098
+ return read.sync(resolvePath(path2), returnAs);
3099
+ },
3100
+ readAsync: (path2, returnAs) => {
3101
+ read.validateInput("readAsync", path2, returnAs);
3102
+ return read.async(resolvePath(path2), returnAs);
3103
+ },
3104
+ remove: (path2) => {
3105
+ remove.validateInput("remove", path2);
3106
+ remove.sync(resolvePath(path2 || "."));
3107
+ },
3108
+ removeAsync: (path2) => {
3109
+ remove.validateInput("removeAsync", path2);
3110
+ return remove.async(resolvePath(path2 || "."));
3111
+ },
3112
+ rename: (path2, newName, options) => {
3113
+ rename.validateInput("rename", path2, newName, options);
3114
+ rename.sync(resolvePath(path2), newName, options);
3115
+ },
3116
+ renameAsync: (path2, newName, options) => {
3117
+ rename.validateInput("renameAsync", path2, newName, options);
3118
+ return rename.async(resolvePath(path2), newName, options);
3119
+ },
3120
+ symlink: (symlinkValue, path2) => {
3121
+ symlink.validateInput("symlink", symlinkValue, path2);
3122
+ symlink.sync(symlinkValue, resolvePath(path2));
3123
+ },
3124
+ symlinkAsync: (symlinkValue, path2) => {
3125
+ symlink.validateInput("symlinkAsync", symlinkValue, path2);
3126
+ return symlink.async(symlinkValue, resolvePath(path2));
3127
+ },
3128
+ tmpDir: (options) => {
3129
+ tmpDir.validateInput("tmpDir", options);
3130
+ const pathOfCreatedDirectory = tmpDir.sync(getCwdPath(), options);
3131
+ return cwd(pathOfCreatedDirectory);
3132
+ },
3133
+ tmpDirAsync: (options) => {
3134
+ tmpDir.validateInput("tmpDirAsync", options);
3135
+ return new Promise((resolve, reject) => {
3136
+ tmpDir.async(getCwdPath(), options).then((pathOfCreatedDirectory) => {
3137
+ resolve(cwd(pathOfCreatedDirectory));
3138
+ }, reject);
3139
+ });
3140
+ },
3141
+ write: (path2, data, options) => {
3142
+ write.validateInput("write", path2, data, options);
3143
+ write.sync(resolvePath(path2), data, options);
3144
+ },
3145
+ writeAsync: (path2, data, options) => {
3146
+ write.validateInput("writeAsync", path2, data, options);
3147
+ return write.async(resolvePath(path2), data, options);
3148
+ }
3149
+ };
3150
+ if (util.inspect.custom !== void 0) {
3151
+ api[util.inspect.custom] = () => {
3152
+ return `[fs-jetpack CWD: ${getCwdPath()}]`;
3153
+ };
3154
+ }
3155
+ return api;
3156
+ };
3157
+ module2.exports = jetpackContext;
3158
+ }
3159
+ });
3160
+ var require_main = (0, import_chunk_2ESYSVXG.__commonJS)({
3161
+ "../../node_modules/.pnpm/fs-jetpack@5.1.0/node_modules/fs-jetpack/main.js"(exports, module2) {
3162
+ "use strict";
3163
+ var jetpack = require_jetpack();
3164
+ module2.exports = jetpack();
3165
+ }
3166
+ });
3167
+ var import_fs_jetpack = (0, import_chunk_2ESYSVXG.__toESM)(require_main());
3168
+ var debug = (0, import_debug.default)("prisma:migrate:diff");
3169
+ var helpOptions = (0, import_internals.format)(
3170
+ `${(0, import_chunk_SKRR5WT4.bold)("Usage")}
3171
+
3172
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff [options]
3173
+
3174
+ ${(0, import_chunk_SKRR5WT4.bold)("Options")}
3175
+
3176
+ -h, --help Display this help message
3177
+ --config Custom path to your Prisma config file
3178
+ -o, --output Writes to a file instead of stdout
3179
+
3180
+ ${(0, import_chunk_SKRR5WT4.italic)("From and To inputs (1 `--from-...` and 1 `--to-...` must be provided):")}
3181
+ --from-empty Flag to assume from or to is an empty datamodel
3182
+ --to-empty
3183
+
3184
+ --from-schema Path to a Prisma schema file, uses the ${(0, import_chunk_SKRR5WT4.italic)("datamodel")} for the diff
3185
+ --to-schema
3186
+
3187
+ --from-migrations Path to the Prisma Migrate migrations directory
3188
+ --to-migrations
3189
+
3190
+ --from-config-datasource Flag to use the datasource from the Prisma config file
3191
+ --to-config-datasource
3192
+
3193
+ ${(0, import_chunk_SKRR5WT4.bold)("Flags")}
3194
+
3195
+ --script Render a SQL script to stdout instead of the default human readable summary (not supported on MongoDB)
3196
+ --exit-code Change the exit code behavior to signal if the diff is empty or not (Empty: 0, Error: 1, Not empty: 2). Default behavior is Success: 0, Error: 1.`
3197
+ );
3198
+ var MigrateDiff = class _MigrateDiff {
3199
+ static new() {
3200
+ return new _MigrateDiff();
3201
+ }
3202
+ static help = (0, import_internals.format)(`
3203
+ ${process.platform === "win32" ? "" : "\u{1F50D} "}Compares the database schema from two arbitrary sources, and outputs the differences either as a human-readable summary (by default) or an executable script.
3204
+
3205
+ ${(0, import_chunk_SKRR5WT4.green)(`prisma migrate diff`)} is a read-only command that does not write to your datasource(s).
3206
+ ${(0, import_chunk_SKRR5WT4.green)(`prisma db execute`)} can be used to execute its ${(0, import_chunk_SKRR5WT4.green)(`--script`)} output.
3207
+
3208
+ The command takes a source ${(0, import_chunk_SKRR5WT4.green)(`--from-...`)} and a destination ${(0, import_chunk_SKRR5WT4.green)(`--to-...`)}.
3209
+ The source and destination must use the same provider,
3210
+ e.g. a diff using 2 different providers like PostgreSQL and SQLite is not supported.
3211
+
3212
+ It compares the source with the destination to generate a diff.
3213
+ The diff can be interpreted as generating a migration that brings the source schema (from) to the shape of the destination schema (to).
3214
+ The default output is a human readable diff, it can be rendered as SQL using \`--script\` on SQL databases.
3215
+
3216
+ See the documentation for more information ${(0, import_internals.link)("https://pris.ly/d/migrate-diff")}
3217
+
3218
+ ${helpOptions}
3219
+ ${(0, import_chunk_SKRR5WT4.bold)("Examples")}
3220
+
3221
+ From the configured database to a Prisma datamodel
3222
+ e.g. roll forward after a migration failed in the middle
3223
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
3224
+ --from-config-datasource \\
3225
+ --to-schema=next_datamodel.prisma \\
3226
+ --script
3227
+
3228
+ From a peisma datamodel to the configured database
3229
+ e.g. roll forward after a migration failed in the middle
3230
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
3231
+ --from-schema=next_datamodel.prisma \\
3232
+ --to-config-datasource \\
3233
+ --script
3234
+
3235
+ From a Prisma Migrate \`migrations\` directory to the configured database
3236
+ e.g. generate a migration for a hotfix already applied on production
3237
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
3238
+ --from-migrations ./migrations \\
3239
+ --to-config-datasource \\
3240
+ --script
3241
+
3242
+ Execute the --script output with \`prisma db execute\` using bash pipe \`|\`
3243
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
3244
+ --from-[...] \\
3245
+ --to-[...] \\
3246
+ --script | prisma db execute --stdin --url="$DATABASE_URL"
3247
+
3248
+ Detect if both sources are in sync, it will exit with exit code 2 if changes are detected
3249
+ ${(0, import_chunk_SKRR5WT4.dim)("$")} prisma migrate diff \\
3250
+ --exit-code \\
3251
+ --from-[...] \\
3252
+ --to-[...]
3253
+ `);
3254
+ async parse(argv, config, baseDir) {
3255
+ const args = (0, import_internals.arg)(
3256
+ argv,
3257
+ {
3258
+ "--help": Boolean,
3259
+ "-h": "--help",
3260
+ "--output": String,
3261
+ "-o": "--output",
3262
+ // From
3263
+ "--from-empty": Boolean,
3264
+ "--from-config-datasource": Boolean,
3265
+ "--from-schema": String,
3266
+ "--from-migrations": String,
3267
+ // To
3268
+ "--to-empty": Boolean,
3269
+ "--to-config-datasource": Boolean,
3270
+ "--to-schema": String,
3271
+ "--to-migrations": String,
3272
+ // Others
3273
+ "--script": Boolean,
3274
+ "--exit-code": Boolean,
3275
+ "--telemetry-information": String,
3276
+ "--config": String,
3277
+ // Removed, but parsed to show help error
3278
+ "--from-url": String,
3279
+ "--to-url": String,
3280
+ "--from-schema-datasource": String,
3281
+ "--to-schema-datasource": String,
3282
+ "--from-schema-datamodel": String,
3283
+ "--to-schema-datamodel": String,
3284
+ "--from-local-d1": Boolean,
3285
+ "--to-local-d1": Boolean
3286
+ },
3287
+ false
3288
+ );
3289
+ if ((0, import_internals.isError)(args)) {
3290
+ return this.help(args.message);
3291
+ }
3292
+ if (args["--help"]) {
3293
+ return this.help();
3294
+ }
3295
+ const removedTargetParameterHint = Object.keys(args).map(getRemovedTargetParameterHint).find((msg) => msg !== void 0);
3296
+ if (removedTargetParameterHint) {
3297
+ return this.help(removedTargetParameterHint);
3298
+ }
3299
+ const numberOfFromParameterProvided = Number(Boolean(args["--from-empty"])) + Number(Boolean(args["--from-config-datasource"])) + Number(Boolean(args["--from-schema"])) + Number(Boolean(args["--from-migrations"]));
3300
+ const numberOfToParameterProvided = Number(Boolean(args["--to-empty"])) + Number(Boolean(args["--to-config-datasource"])) + Number(Boolean(args["--to-schema"])) + Number(Boolean(args["--to-migrations"]));
3301
+ if (numberOfFromParameterProvided !== 1 || numberOfToParameterProvided !== 1) {
3302
+ const errorMessages = [];
3303
+ if (numberOfFromParameterProvided !== 1) {
3304
+ errorMessages.push(`${numberOfFromParameterProvided} \`--from-...\` parameter(s) provided. 1 must be provided.`);
3305
+ }
3306
+ if (numberOfToParameterProvided !== 1) {
3307
+ errorMessages.push(`${numberOfToParameterProvided} \`--to-...\` parameter(s) provided. 1 must be provided.`);
3308
+ }
3309
+ return this.help(`${errorMessages.join("\n")}`);
3310
+ }
3311
+ let from;
3312
+ if (args["--from-empty"]) {
3313
+ from = {
3314
+ tag: "empty"
3315
+ };
3316
+ } else if (args["--from-schema"]) {
3317
+ const schema = await (0, import_internals.getSchemaWithPath)({
3318
+ schemaPath: (0, import_internals.createSchemaPathInput)({
3319
+ schemaPathFromArgs: import_path.default.resolve(args["--from-schema"]),
3320
+ schemaPathFromConfig: config.schema,
3321
+ baseDir
3322
+ }),
3323
+ argumentName: "--from-schema"
3324
+ });
3325
+ from = {
3326
+ tag: "schemaDatamodel",
3327
+ ...(0, import_internals.toSchemasContainer)(schema.schemas)
3328
+ };
3329
+ } else if (args["--from-migrations"]) {
3330
+ from = {
3331
+ tag: "migrations",
3332
+ ...await (0, import_chunk_GGA2F64G.listMigrations)(args["--from-migrations"], config.migrations?.initShadowDb ?? "")
3333
+ };
3334
+ } else if (args["--from-config-datasource"]) {
3335
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
3336
+ schemaPath: (0, import_internals.createSchemaPathInput)({ schemaPathFromConfig: config.schema, baseDir }),
3337
+ printLoadMessage: false
3338
+ });
3339
+ from = {
3340
+ tag: "schemaDatasource",
3341
+ ...(0, import_internals.toSchemasWithConfigDir)(schemaContext, baseDir)
3342
+ };
3343
+ }
3344
+ let to;
3345
+ if (args["--to-empty"]) {
3346
+ to = {
3347
+ tag: "empty"
3348
+ };
3349
+ } else if (args["--to-schema"]) {
3350
+ const schema = await (0, import_internals.getSchemaWithPath)({
3351
+ schemaPath: (0, import_internals.createSchemaPathInput)({
3352
+ schemaPathFromArgs: import_path.default.resolve(args["--to-schema"]),
3353
+ schemaPathFromConfig: config.schema,
3354
+ baseDir
3355
+ }),
3356
+ argumentName: "--to-schema"
3357
+ });
3358
+ to = {
3359
+ tag: "schemaDatamodel",
3360
+ ...(0, import_internals.toSchemasContainer)(schema.schemas)
3361
+ };
3362
+ } else if (args["--to-migrations"]) {
3363
+ to = {
3364
+ tag: "migrations",
3365
+ ...await (0, import_chunk_GGA2F64G.listMigrations)(args["--to-migrations"], config.migrations?.initShadowDb ?? "")
3366
+ };
3367
+ } else if (args["--to-config-datasource"]) {
3368
+ const schemaContext = await (0, import_internals.loadSchemaContext)({
3369
+ schemaPath: (0, import_internals.createSchemaPathInput)({ schemaPathFromConfig: config.schema, baseDir }),
3370
+ printLoadMessage: false
3371
+ });
3372
+ to = {
3373
+ tag: "schemaDatasource",
3374
+ ...(0, import_internals.toSchemasWithConfigDir)(schemaContext, baseDir)
3375
+ };
3376
+ }
3377
+ const schemaFilter = {
3378
+ externalTables: config.tables?.external ?? [],
3379
+ externalEnums: config.enums?.external ?? []
3380
+ };
3381
+ const migrate = await import_chunk_WRBJ3RMF.Migrate.setup({
3382
+ schemaEngineConfig: config,
3383
+ baseDir,
3384
+ schemaFilter,
3385
+ extensions: config["extensions"]
3386
+ });
3387
+ const captureStdout = new import_chunk_VAJ4VX67.CaptureStdout();
3388
+ const outputPath = args["--output"];
3389
+ const isOutputDefined = Boolean(outputPath);
3390
+ if (isOutputDefined) {
3391
+ captureStdout.startCapture();
3392
+ }
3393
+ let result;
3394
+ try {
3395
+ result = await migrate.engine.migrateDiff({
3396
+ from,
3397
+ to,
3398
+ script: args["--script"] || false,
3399
+ // default is false
3400
+ shadowDatabaseUrl: args["--shadow-database-url"] ?? null,
3401
+ exitCode: args["--exit-code"] ?? null,
3402
+ filters: {
3403
+ externalTables: config.tables?.external ?? [],
3404
+ externalEnums: config.enums?.external ?? []
3405
+ }
3406
+ });
3407
+ } finally {
3408
+ await migrate.stop();
3409
+ }
3410
+ if (isOutputDefined) {
3411
+ captureStdout.stopCapture();
3412
+ const diffOutput = captureStdout.getCapturedText();
3413
+ captureStdout.clearCaptureText();
3414
+ await import_fs_jetpack.default.writeAsync(outputPath, diffOutput.join("\n"));
3415
+ }
3416
+ debug({ migrateDiffOutput: result });
3417
+ if (args["--exit-code"] && result.exitCode) {
3418
+ process.exit(result.exitCode);
3419
+ }
3420
+ return ``;
3421
+ }
3422
+ help(error) {
3423
+ if (error) {
3424
+ throw new import_internals.HelpError(`
3425
+ ${error}
3426
+
3427
+ ${helpOptions}`);
3428
+ }
3429
+ return _MigrateDiff.help;
3430
+ }
3431
+ };
3432
+ function getRemovedTargetParameterHint(parameter) {
3433
+ switch (parameter) {
3434
+ case "--from-url":
3435
+ case "--to-url":
3436
+ case "--from-schema-datasource":
3437
+ case "--to-schema-datasource":
3438
+ return `\`${parameter}\` was removed. Please use \`--[from/to]-config-datasource\` in combination with a Prisma config file that contains the appropriate datasource instead.`;
3439
+ case "--from-schema-datamodel":
3440
+ case "--to-schema-datamodel":
3441
+ return `\`${parameter}\` was removed. Please use \`--[from/to]-schema\` instead.`;
3442
+ case "--from-local-d1":
3443
+ case "--to-local-d1":
3444
+ return `\`${parameter}\` was removed. Please use \`--[from/to]-config-datasource\` in combination with a Prisma config file that contains the appropriate datasource instead. The \`@prisma/adapter-d1\` package exposes a \`listLocalDatabases()\` helper function to help you locate your local D1 databases. You can use the paths returned from that function to construct your datasource URL(s).`;
3445
+ default:
3446
+ return;
3447
+ }
3448
+ }