@pubinfo/commitlint 2.0.13 → 2.0.15

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.
@@ -1,2407 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { execSync, spawn } from "node:child_process";
3
- import { loadConfig } from "unconfig";
4
- import { join, resolve } from "node:path";
5
- import process$1 from "node:process";
6
- import CZGPackage from "czg/package.json" with { type: "json" };
7
- import fs from "node:fs";
8
-
9
- //#region rolldown:runtime
10
- var __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __commonJS = (cb, mod) => function() {
17
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
- key = keys[i];
22
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
- get: ((k) => from[k]).bind(null, key),
24
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
- });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
32
- }) : target, mod));
33
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
34
-
35
- //#endregion
36
- //#region src/config/index.ts
37
- const notWip = [
38
- "main",
39
- "master",
40
- "dev",
41
- "test",
42
- "release"
43
- ];
44
- function isMainBranch() {
45
- try {
46
- try {
47
- const currentBranch = execSync("git branch --show-current", { encoding: "utf8" }).trim();
48
- if (currentBranch) return notWip.includes(currentBranch);
49
- } catch {
50
- try {
51
- const currentBranch = execSync("git symbolic-ref --short HEAD", { encoding: "utf8" }).trim();
52
- return notWip.includes(currentBranch);
53
- } catch {
54
- return false;
55
- }
56
- }
57
- } catch {
58
- return false;
59
- }
60
- return false;
61
- }
62
- function generateCommitTypes() {
63
- const allTypes = [
64
- "feat",
65
- "fix",
66
- "docs",
67
- "style",
68
- "refactor",
69
- "perf",
70
- "test",
71
- "build",
72
- "ci",
73
- "chore",
74
- "revert",
75
- "types",
76
- "release",
77
- "init",
78
- "wip"
79
- ];
80
- if (isMainBranch()) return allTypes.filter((type) => type !== "wip");
81
- return allTypes;
82
- }
83
- function generateCzGitTypes() {
84
- const all = [
85
- {
86
- value: "feat",
87
- name: "feat: ✨ 新功能",
88
- emoji: ":sparkles:"
89
- },
90
- {
91
- value: "fix",
92
- name: "fix: 🐛 修复缺陷",
93
- emoji: ":bug:"
94
- },
95
- {
96
- value: "types",
97
- name: "types: 🎨 类型相关",
98
- emoji: ":art:"
99
- },
100
- {
101
- value: "docs",
102
- name: "docs: 📝 文档更新",
103
- emoji: ":memo:"
104
- },
105
- {
106
- value: "style",
107
- name: "style: 💄 代码格式",
108
- emoji: ":lipstick:"
109
- },
110
- {
111
- value: "refactor",
112
- name: "refactor: ♻️ 代码重构",
113
- emoji: ":recycle:"
114
- },
115
- {
116
- value: "perf",
117
- name: "perf: ⚡️ 性能提升",
118
- emoji: ":zap:"
119
- },
120
- {
121
- value: "test",
122
- name: "test: ✅ 测试相关",
123
- emoji: ":white_check_mark:"
124
- },
125
- {
126
- value: "build",
127
- name: "build: 📦️ 构建相关",
128
- emoji: ":package:"
129
- },
130
- {
131
- value: "release",
132
- name: "release: 🔖 版本提升",
133
- emoji: ":bookmark:"
134
- },
135
- {
136
- value: "ci",
137
- name: "ci: 🎡 持续集成",
138
- emoji: ":ferris_wheel:"
139
- },
140
- {
141
- value: "revert",
142
- name: "revert: ⏪️ 回退代码",
143
- emoji: ":rewind:"
144
- },
145
- {
146
- value: "chore",
147
- name: "chore: 🔨 其他修改",
148
- emoji: ":hammer:"
149
- },
150
- {
151
- value: "init",
152
- name: "init: 🎉 初始化",
153
- emoji: ":tada:"
154
- },
155
- {
156
- value: "wip",
157
- name: "wip: 🚧 工作进行中",
158
- emoji: ":construction:"
159
- }
160
- ];
161
- if (isMainBranch()) return all.filter((t) => t.value !== "wip");
162
- return all;
163
- }
164
- const commitPreset = {
165
- extends: ["@commitlint/config-conventional"],
166
- rules: {
167
- "scope-enum": [0],
168
- "type-enum": [
169
- 2,
170
- "always",
171
- generateCommitTypes()
172
- ],
173
- "type-empty": [2, "never"],
174
- "type-case": [
175
- 2,
176
- "always",
177
- "lower-case"
178
- ],
179
- "subject-empty": [2, "never"],
180
- "subject-full-stop": [
181
- 2,
182
- "never",
183
- "."
184
- ],
185
- "subject-case": [
186
- 2,
187
- "never",
188
- [
189
- "sentence-case",
190
- "start-case",
191
- "pascal-case",
192
- "upper-case"
193
- ]
194
- ],
195
- "header-max-length": [
196
- 2,
197
- "always",
198
- 100
199
- ],
200
- "body-leading-blank": [1, "always"],
201
- "footer-leading-blank": [1, "always"]
202
- },
203
- prompt: {
204
- alias: { fd: "docs: fix typos" },
205
- messages: {
206
- scope: "选择一个提交范围 (可回车跳过):",
207
- customScope: "请输入自定义的提交范围 :",
208
- type: "选择你要提交的类型 :",
209
- subject: "填写简短精炼的变更描述 :\n",
210
- body: "填写更加详细的变更描述(可选)。使用 \"|\" 换行 :\n",
211
- breaking: "列举非兼容性重大的变更(可选)。使用 \"|\" 换行 :\n",
212
- footerPrefixsSelect: "选择关联issue前缀(可选):",
213
- customFooterPrefixs: "输入自定义issue前缀 :",
214
- footer: "列举关联issue (可选) 例如: #31, #I3244 :\n",
215
- confirmCommit: "是否提交或修改commit ?"
216
- },
217
- types: generateCzGitTypes(),
218
- useEmoji: false,
219
- emojiAlign: "center",
220
- themeColorCode: "",
221
- enableMultipleScopes: true,
222
- skipQuestions: ["scope"],
223
- defaultScope: "___CUSTOM___:",
224
- customScopesAlign: "bottom",
225
- customScopesAlias: "custom",
226
- emptyScopesAlias: "empty",
227
- upperCaseSubject: false,
228
- markBreakingChangeMode: true,
229
- allowBreakingChanges: ["feat", "fix"],
230
- breaklineNumber: 100,
231
- breaklineChar: "|",
232
- issuePrefixs: [{
233
- value: "link",
234
- name: "link: 链接 ISSUES 进行中"
235
- }, {
236
- value: "closed",
237
- name: "closed: 标记 ISSUES 已完成"
238
- }],
239
- customIssuePrefixsAlign: "top",
240
- emptyIssuePrefixsAlias: "skip",
241
- customIssuePrefixsAlias: "custom",
242
- allowCustomIssuePrefixs: true,
243
- allowEmptyIssuePrefixs: true,
244
- confirmColorize: true,
245
- maxHeaderLength: Number.POSITIVE_INFINITY,
246
- maxSubjectLength: Number.POSITIVE_INFINITY,
247
- minSubjectLength: 0,
248
- scopeOverrides: void 0,
249
- defaultBody: "",
250
- defaultIssues: "",
251
- defaultSubject: ""
252
- }
253
- };
254
- function loadCommitConfig() {
255
- return commitPreset;
256
- }
257
-
258
- //#endregion
259
- //#region src/config/commitlint.ts
260
- let cachedState;
261
- function resolveCommitlintEnabled(value) {
262
- if (typeof value === "boolean") return value;
263
- if (value && typeof value === "object") {
264
- if (typeof value.enabled === "boolean") return value.enabled;
265
- if (typeof value.disable === "boolean") return !value.disable;
266
- }
267
- }
268
- async function isCommitlintEnabled() {
269
- if (typeof cachedState === "boolean") return cachedState;
270
- try {
271
- const resolved = resolveCommitlintEnabled((await loadConfig({
272
- sources: [{ files: "pubinfo.config" }],
273
- merge: false
274
- }))?.config?.commitlint);
275
- cachedState = typeof resolved === "boolean" ? resolved : true;
276
- } catch {
277
- cachedState = true;
278
- }
279
- return cachedState;
280
- }
281
-
282
- //#endregion
283
- //#region ../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js
284
- var require_universalify = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js": ((exports) => {
285
- exports.fromCallback = function(fn) {
286
- return Object.defineProperty(function(...args) {
287
- if (typeof args[args.length - 1] === "function") fn.apply(this, args);
288
- else return new Promise((resolve$1, reject) => {
289
- args.push((err, res) => err != null ? reject(err) : resolve$1(res));
290
- fn.apply(this, args);
291
- });
292
- }, "name", { value: fn.name });
293
- };
294
- exports.fromPromise = function(fn) {
295
- return Object.defineProperty(function(...args) {
296
- const cb = args[args.length - 1];
297
- if (typeof cb !== "function") return fn.apply(this, args);
298
- else {
299
- args.pop();
300
- fn.apply(this, args).then((r) => cb(null, r), cb);
301
- }
302
- }, "name", { value: fn.name });
303
- };
304
- }) });
305
-
306
- //#endregion
307
- //#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
308
- var require_polyfills = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js": ((exports, module) => {
309
- var constants = __require("constants");
310
- var origCwd = process.cwd;
311
- var cwd = null;
312
- var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
313
- process.cwd = function() {
314
- if (!cwd) cwd = origCwd.call(process);
315
- return cwd;
316
- };
317
- try {
318
- process.cwd();
319
- } catch (er) {}
320
- if (typeof process.chdir === "function") {
321
- var chdir = process.chdir;
322
- process.chdir = function(d) {
323
- cwd = null;
324
- chdir.call(process, d);
325
- };
326
- if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
327
- }
328
- module.exports = patch$1;
329
- function patch$1(fs$22) {
330
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(fs$22);
331
- if (!fs$22.lutimes) patchLutimes(fs$22);
332
- fs$22.chown = chownFix(fs$22.chown);
333
- fs$22.fchown = chownFix(fs$22.fchown);
334
- fs$22.lchown = chownFix(fs$22.lchown);
335
- fs$22.chmod = chmodFix(fs$22.chmod);
336
- fs$22.fchmod = chmodFix(fs$22.fchmod);
337
- fs$22.lchmod = chmodFix(fs$22.lchmod);
338
- fs$22.chownSync = chownFixSync(fs$22.chownSync);
339
- fs$22.fchownSync = chownFixSync(fs$22.fchownSync);
340
- fs$22.lchownSync = chownFixSync(fs$22.lchownSync);
341
- fs$22.chmodSync = chmodFixSync(fs$22.chmodSync);
342
- fs$22.fchmodSync = chmodFixSync(fs$22.fchmodSync);
343
- fs$22.lchmodSync = chmodFixSync(fs$22.lchmodSync);
344
- fs$22.stat = statFix(fs$22.stat);
345
- fs$22.fstat = statFix(fs$22.fstat);
346
- fs$22.lstat = statFix(fs$22.lstat);
347
- fs$22.statSync = statFixSync(fs$22.statSync);
348
- fs$22.fstatSync = statFixSync(fs$22.fstatSync);
349
- fs$22.lstatSync = statFixSync(fs$22.lstatSync);
350
- if (fs$22.chmod && !fs$22.lchmod) {
351
- fs$22.lchmod = function(path$12, mode, cb) {
352
- if (cb) process.nextTick(cb);
353
- };
354
- fs$22.lchmodSync = function() {};
355
- }
356
- if (fs$22.chown && !fs$22.lchown) {
357
- fs$22.lchown = function(path$12, uid, gid, cb) {
358
- if (cb) process.nextTick(cb);
359
- };
360
- fs$22.lchownSync = function() {};
361
- }
362
- if (platform === "win32") fs$22.rename = typeof fs$22.rename !== "function" ? fs$22.rename : (function(fs$rename) {
363
- function rename$1(from, to, cb) {
364
- var start = Date.now();
365
- var backoff = 0;
366
- fs$rename(from, to, function CB(er) {
367
- if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
368
- setTimeout(function() {
369
- fs$22.stat(to, function(stater, st) {
370
- if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
371
- else cb(er);
372
- });
373
- }, backoff);
374
- if (backoff < 100) backoff += 10;
375
- return;
376
- }
377
- if (cb) cb(er);
378
- });
379
- }
380
- if (Object.setPrototypeOf) Object.setPrototypeOf(rename$1, fs$rename);
381
- return rename$1;
382
- })(fs$22.rename);
383
- fs$22.read = typeof fs$22.read !== "function" ? fs$22.read : (function(fs$read) {
384
- function read(fd, buffer, offset, length, position, callback_) {
385
- var callback;
386
- if (callback_ && typeof callback_ === "function") {
387
- var eagCounter = 0;
388
- callback = function(er, _, __) {
389
- if (er && er.code === "EAGAIN" && eagCounter < 10) {
390
- eagCounter++;
391
- return fs$read.call(fs$22, fd, buffer, offset, length, position, callback);
392
- }
393
- callback_.apply(this, arguments);
394
- };
395
- }
396
- return fs$read.call(fs$22, fd, buffer, offset, length, position, callback);
397
- }
398
- if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
399
- return read;
400
- })(fs$22.read);
401
- fs$22.readSync = typeof fs$22.readSync !== "function" ? fs$22.readSync : (function(fs$readSync) {
402
- return function(fd, buffer, offset, length, position) {
403
- var eagCounter = 0;
404
- while (true) try {
405
- return fs$readSync.call(fs$22, fd, buffer, offset, length, position);
406
- } catch (er) {
407
- if (er.code === "EAGAIN" && eagCounter < 10) {
408
- eagCounter++;
409
- continue;
410
- }
411
- throw er;
412
- }
413
- };
414
- })(fs$22.readSync);
415
- function patchLchmod(fs$23) {
416
- fs$23.lchmod = function(path$12, mode, callback) {
417
- fs$23.open(path$12, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
418
- if (err) {
419
- if (callback) callback(err);
420
- return;
421
- }
422
- fs$23.fchmod(fd, mode, function(err$1) {
423
- fs$23.close(fd, function(err2) {
424
- if (callback) callback(err$1 || err2);
425
- });
426
- });
427
- });
428
- };
429
- fs$23.lchmodSync = function(path$12, mode) {
430
- var fd = fs$23.openSync(path$12, constants.O_WRONLY | constants.O_SYMLINK, mode);
431
- var threw = true;
432
- var ret;
433
- try {
434
- ret = fs$23.fchmodSync(fd, mode);
435
- threw = false;
436
- } finally {
437
- if (threw) try {
438
- fs$23.closeSync(fd);
439
- } catch (er) {}
440
- else fs$23.closeSync(fd);
441
- }
442
- return ret;
443
- };
444
- }
445
- function patchLutimes(fs$23) {
446
- if (constants.hasOwnProperty("O_SYMLINK") && fs$23.futimes) {
447
- fs$23.lutimes = function(path$12, at, mt, cb) {
448
- fs$23.open(path$12, constants.O_SYMLINK, function(er, fd) {
449
- if (er) {
450
- if (cb) cb(er);
451
- return;
452
- }
453
- fs$23.futimes(fd, at, mt, function(er$1) {
454
- fs$23.close(fd, function(er2) {
455
- if (cb) cb(er$1 || er2);
456
- });
457
- });
458
- });
459
- };
460
- fs$23.lutimesSync = function(path$12, at, mt) {
461
- var fd = fs$23.openSync(path$12, constants.O_SYMLINK);
462
- var ret;
463
- var threw = true;
464
- try {
465
- ret = fs$23.futimesSync(fd, at, mt);
466
- threw = false;
467
- } finally {
468
- if (threw) try {
469
- fs$23.closeSync(fd);
470
- } catch (er) {}
471
- else fs$23.closeSync(fd);
472
- }
473
- return ret;
474
- };
475
- } else if (fs$23.futimes) {
476
- fs$23.lutimes = function(_a, _b, _c, cb) {
477
- if (cb) process.nextTick(cb);
478
- };
479
- fs$23.lutimesSync = function() {};
480
- }
481
- }
482
- function chmodFix(orig) {
483
- if (!orig) return orig;
484
- return function(target, mode, cb) {
485
- return orig.call(fs$22, target, mode, function(er) {
486
- if (chownErOk(er)) er = null;
487
- if (cb) cb.apply(this, arguments);
488
- });
489
- };
490
- }
491
- function chmodFixSync(orig) {
492
- if (!orig) return orig;
493
- return function(target, mode) {
494
- try {
495
- return orig.call(fs$22, target, mode);
496
- } catch (er) {
497
- if (!chownErOk(er)) throw er;
498
- }
499
- };
500
- }
501
- function chownFix(orig) {
502
- if (!orig) return orig;
503
- return function(target, uid, gid, cb) {
504
- return orig.call(fs$22, target, uid, gid, function(er) {
505
- if (chownErOk(er)) er = null;
506
- if (cb) cb.apply(this, arguments);
507
- });
508
- };
509
- }
510
- function chownFixSync(orig) {
511
- if (!orig) return orig;
512
- return function(target, uid, gid) {
513
- try {
514
- return orig.call(fs$22, target, uid, gid);
515
- } catch (er) {
516
- if (!chownErOk(er)) throw er;
517
- }
518
- };
519
- }
520
- function statFix(orig) {
521
- if (!orig) return orig;
522
- return function(target, options, cb) {
523
- if (typeof options === "function") {
524
- cb = options;
525
- options = null;
526
- }
527
- function callback(er, stats) {
528
- if (stats) {
529
- if (stats.uid < 0) stats.uid += 4294967296;
530
- if (stats.gid < 0) stats.gid += 4294967296;
531
- }
532
- if (cb) cb.apply(this, arguments);
533
- }
534
- return options ? orig.call(fs$22, target, options, callback) : orig.call(fs$22, target, callback);
535
- };
536
- }
537
- function statFixSync(orig) {
538
- if (!orig) return orig;
539
- return function(target, options) {
540
- var stats = options ? orig.call(fs$22, target, options) : orig.call(fs$22, target);
541
- if (stats) {
542
- if (stats.uid < 0) stats.uid += 4294967296;
543
- if (stats.gid < 0) stats.gid += 4294967296;
544
- }
545
- return stats;
546
- };
547
- }
548
- function chownErOk(er) {
549
- if (!er) return true;
550
- if (er.code === "ENOSYS") return true;
551
- if (!process.getuid || process.getuid() !== 0) {
552
- if (er.code === "EINVAL" || er.code === "EPERM") return true;
553
- }
554
- return false;
555
- }
556
- }
557
- }) });
558
-
559
- //#endregion
560
- //#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
561
- var require_legacy_streams = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js": ((exports, module) => {
562
- var Stream = __require("stream").Stream;
563
- module.exports = legacy$1;
564
- function legacy$1(fs$22) {
565
- return {
566
- ReadStream,
567
- WriteStream
568
- };
569
- function ReadStream(path$12, options) {
570
- if (!(this instanceof ReadStream)) return new ReadStream(path$12, options);
571
- Stream.call(this);
572
- var self = this;
573
- this.path = path$12;
574
- this.fd = null;
575
- this.readable = true;
576
- this.paused = false;
577
- this.flags = "r";
578
- this.mode = 438;
579
- this.bufferSize = 64 * 1024;
580
- options = options || {};
581
- var keys = Object.keys(options);
582
- for (var index = 0, length = keys.length; index < length; index++) {
583
- var key = keys[index];
584
- this[key] = options[key];
585
- }
586
- if (this.encoding) this.setEncoding(this.encoding);
587
- if (this.start !== void 0) {
588
- if ("number" !== typeof this.start) throw TypeError("start must be a Number");
589
- if (this.end === void 0) this.end = Infinity;
590
- else if ("number" !== typeof this.end) throw TypeError("end must be a Number");
591
- if (this.start > this.end) throw new Error("start must be <= end");
592
- this.pos = this.start;
593
- }
594
- if (this.fd !== null) {
595
- process.nextTick(function() {
596
- self._read();
597
- });
598
- return;
599
- }
600
- fs$22.open(this.path, this.flags, this.mode, function(err, fd) {
601
- if (err) {
602
- self.emit("error", err);
603
- self.readable = false;
604
- return;
605
- }
606
- self.fd = fd;
607
- self.emit("open", fd);
608
- self._read();
609
- });
610
- }
611
- function WriteStream(path$12, options) {
612
- if (!(this instanceof WriteStream)) return new WriteStream(path$12, options);
613
- Stream.call(this);
614
- this.path = path$12;
615
- this.fd = null;
616
- this.writable = true;
617
- this.flags = "w";
618
- this.encoding = "binary";
619
- this.mode = 438;
620
- this.bytesWritten = 0;
621
- options = options || {};
622
- var keys = Object.keys(options);
623
- for (var index = 0, length = keys.length; index < length; index++) {
624
- var key = keys[index];
625
- this[key] = options[key];
626
- }
627
- if (this.start !== void 0) {
628
- if ("number" !== typeof this.start) throw TypeError("start must be a Number");
629
- if (this.start < 0) throw new Error("start must be >= zero");
630
- this.pos = this.start;
631
- }
632
- this.busy = false;
633
- this._queue = [];
634
- if (this.fd === null) {
635
- this._open = fs$22.open;
636
- this._queue.push([
637
- this._open,
638
- this.path,
639
- this.flags,
640
- this.mode,
641
- void 0
642
- ]);
643
- this.flush();
644
- }
645
- }
646
- }
647
- }) });
648
-
649
- //#endregion
650
- //#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
651
- var require_clone = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js": ((exports, module) => {
652
- module.exports = clone$1;
653
- var getPrototypeOf = Object.getPrototypeOf || function(obj) {
654
- return obj.__proto__;
655
- };
656
- function clone$1(obj) {
657
- if (obj === null || typeof obj !== "object") return obj;
658
- if (obj instanceof Object) var copy$2 = { __proto__: getPrototypeOf(obj) };
659
- else var copy$2 = Object.create(null);
660
- Object.getOwnPropertyNames(obj).forEach(function(key) {
661
- Object.defineProperty(copy$2, key, Object.getOwnPropertyDescriptor(obj, key));
662
- });
663
- return copy$2;
664
- }
665
- }) });
666
-
667
- //#endregion
668
- //#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
669
- var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js": ((exports, module) => {
670
- var fs$21 = __require("fs");
671
- var polyfills = require_polyfills();
672
- var legacy = require_legacy_streams();
673
- var clone = require_clone();
674
- var util = __require("util");
675
- /* istanbul ignore next - node 0.x polyfill */
676
- var gracefulQueue;
677
- var previousSymbol;
678
- /* istanbul ignore else - node 0.x polyfill */
679
- if (typeof Symbol === "function" && typeof Symbol.for === "function") {
680
- gracefulQueue = Symbol.for("graceful-fs.queue");
681
- previousSymbol = Symbol.for("graceful-fs.previous");
682
- } else {
683
- gracefulQueue = "___graceful-fs.queue";
684
- previousSymbol = "___graceful-fs.previous";
685
- }
686
- function noop() {}
687
- function publishQueue(context, queue) {
688
- Object.defineProperty(context, gracefulQueue, { get: function() {
689
- return queue;
690
- } });
691
- }
692
- var debug = noop;
693
- if (util.debuglog) debug = util.debuglog("gfs4");
694
- else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() {
695
- var m = util.format.apply(util, arguments);
696
- m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
697
- console.error(m);
698
- };
699
- if (!fs$21[gracefulQueue]) {
700
- publishQueue(fs$21, global[gracefulQueue] || []);
701
- fs$21.close = (function(fs$close) {
702
- function close(fd, cb) {
703
- return fs$close.call(fs$21, fd, function(err) {
704
- if (!err) resetQueue();
705
- if (typeof cb === "function") cb.apply(this, arguments);
706
- });
707
- }
708
- Object.defineProperty(close, previousSymbol, { value: fs$close });
709
- return close;
710
- })(fs$21.close);
711
- fs$21.closeSync = (function(fs$closeSync) {
712
- function closeSync(fd) {
713
- fs$closeSync.apply(fs$21, arguments);
714
- resetQueue();
715
- }
716
- Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
717
- return closeSync;
718
- })(fs$21.closeSync);
719
- if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
720
- debug(fs$21[gracefulQueue]);
721
- __require("assert").equal(fs$21[gracefulQueue].length, 0);
722
- });
723
- }
724
- if (!global[gracefulQueue]) publishQueue(global, fs$21[gracefulQueue]);
725
- module.exports = patch(clone(fs$21));
726
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$21.__patched) {
727
- module.exports = patch(fs$21);
728
- fs$21.__patched = true;
729
- }
730
- function patch(fs$22) {
731
- polyfills(fs$22);
732
- fs$22.gracefulify = patch;
733
- fs$22.createReadStream = createReadStream;
734
- fs$22.createWriteStream = createWriteStream;
735
- var fs$readFile = fs$22.readFile;
736
- fs$22.readFile = readFile$1;
737
- function readFile$1(path$12, options, cb) {
738
- if (typeof options === "function") cb = options, options = null;
739
- return go$readFile(path$12, options, cb);
740
- function go$readFile(path$13, options$1, cb$1, startTime) {
741
- return fs$readFile(path$13, options$1, function(err) {
742
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
743
- go$readFile,
744
- [
745
- path$13,
746
- options$1,
747
- cb$1
748
- ],
749
- err,
750
- startTime || Date.now(),
751
- Date.now()
752
- ]);
753
- else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
754
- });
755
- }
756
- }
757
- var fs$writeFile = fs$22.writeFile;
758
- fs$22.writeFile = writeFile$1;
759
- function writeFile$1(path$12, data, options, cb) {
760
- if (typeof options === "function") cb = options, options = null;
761
- return go$writeFile(path$12, data, options, cb);
762
- function go$writeFile(path$13, data$1, options$1, cb$1, startTime) {
763
- return fs$writeFile(path$13, data$1, options$1, function(err) {
764
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
765
- go$writeFile,
766
- [
767
- path$13,
768
- data$1,
769
- options$1,
770
- cb$1
771
- ],
772
- err,
773
- startTime || Date.now(),
774
- Date.now()
775
- ]);
776
- else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
777
- });
778
- }
779
- }
780
- var fs$appendFile = fs$22.appendFile;
781
- if (fs$appendFile) fs$22.appendFile = appendFile;
782
- function appendFile(path$12, data, options, cb) {
783
- if (typeof options === "function") cb = options, options = null;
784
- return go$appendFile(path$12, data, options, cb);
785
- function go$appendFile(path$13, data$1, options$1, cb$1, startTime) {
786
- return fs$appendFile(path$13, data$1, options$1, function(err) {
787
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
788
- go$appendFile,
789
- [
790
- path$13,
791
- data$1,
792
- options$1,
793
- cb$1
794
- ],
795
- err,
796
- startTime || Date.now(),
797
- Date.now()
798
- ]);
799
- else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
800
- });
801
- }
802
- }
803
- var fs$copyFile = fs$22.copyFile;
804
- if (fs$copyFile) fs$22.copyFile = copyFile$2;
805
- function copyFile$2(src, dest, flags, cb) {
806
- if (typeof flags === "function") {
807
- cb = flags;
808
- flags = 0;
809
- }
810
- return go$copyFile(src, dest, flags, cb);
811
- function go$copyFile(src$1, dest$1, flags$1, cb$1, startTime) {
812
- return fs$copyFile(src$1, dest$1, flags$1, function(err) {
813
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
814
- go$copyFile,
815
- [
816
- src$1,
817
- dest$1,
818
- flags$1,
819
- cb$1
820
- ],
821
- err,
822
- startTime || Date.now(),
823
- Date.now()
824
- ]);
825
- else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
826
- });
827
- }
828
- }
829
- var fs$readdir = fs$22.readdir;
830
- fs$22.readdir = readdir;
831
- var noReaddirOptionVersions = /^v[0-5]\./;
832
- function readdir(path$12, options, cb) {
833
- if (typeof options === "function") cb = options, options = null;
834
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir$1(path$13, options$1, cb$1, startTime) {
835
- return fs$readdir(path$13, fs$readdirCallback(path$13, options$1, cb$1, startTime));
836
- } : function go$readdir$1(path$13, options$1, cb$1, startTime) {
837
- return fs$readdir(path$13, options$1, fs$readdirCallback(path$13, options$1, cb$1, startTime));
838
- };
839
- return go$readdir(path$12, options, cb);
840
- function fs$readdirCallback(path$13, options$1, cb$1, startTime) {
841
- return function(err, files) {
842
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
843
- go$readdir,
844
- [
845
- path$13,
846
- options$1,
847
- cb$1
848
- ],
849
- err,
850
- startTime || Date.now(),
851
- Date.now()
852
- ]);
853
- else {
854
- if (files && files.sort) files.sort();
855
- if (typeof cb$1 === "function") cb$1.call(this, err, files);
856
- }
857
- };
858
- }
859
- }
860
- if (process.version.substr(0, 4) === "v0.8") {
861
- var legStreams = legacy(fs$22);
862
- ReadStream = legStreams.ReadStream;
863
- WriteStream = legStreams.WriteStream;
864
- }
865
- var fs$ReadStream = fs$22.ReadStream;
866
- if (fs$ReadStream) {
867
- ReadStream.prototype = Object.create(fs$ReadStream.prototype);
868
- ReadStream.prototype.open = ReadStream$open;
869
- }
870
- var fs$WriteStream = fs$22.WriteStream;
871
- if (fs$WriteStream) {
872
- WriteStream.prototype = Object.create(fs$WriteStream.prototype);
873
- WriteStream.prototype.open = WriteStream$open;
874
- }
875
- Object.defineProperty(fs$22, "ReadStream", {
876
- get: function() {
877
- return ReadStream;
878
- },
879
- set: function(val) {
880
- ReadStream = val;
881
- },
882
- enumerable: true,
883
- configurable: true
884
- });
885
- Object.defineProperty(fs$22, "WriteStream", {
886
- get: function() {
887
- return WriteStream;
888
- },
889
- set: function(val) {
890
- WriteStream = val;
891
- },
892
- enumerable: true,
893
- configurable: true
894
- });
895
- var FileReadStream = ReadStream;
896
- Object.defineProperty(fs$22, "FileReadStream", {
897
- get: function() {
898
- return FileReadStream;
899
- },
900
- set: function(val) {
901
- FileReadStream = val;
902
- },
903
- enumerable: true,
904
- configurable: true
905
- });
906
- var FileWriteStream = WriteStream;
907
- Object.defineProperty(fs$22, "FileWriteStream", {
908
- get: function() {
909
- return FileWriteStream;
910
- },
911
- set: function(val) {
912
- FileWriteStream = val;
913
- },
914
- enumerable: true,
915
- configurable: true
916
- });
917
- function ReadStream(path$12, options) {
918
- if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
919
- else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
920
- }
921
- function ReadStream$open() {
922
- var that = this;
923
- open(that.path, that.flags, that.mode, function(err, fd) {
924
- if (err) {
925
- if (that.autoClose) that.destroy();
926
- that.emit("error", err);
927
- } else {
928
- that.fd = fd;
929
- that.emit("open", fd);
930
- that.read();
931
- }
932
- });
933
- }
934
- function WriteStream(path$12, options) {
935
- if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
936
- else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
937
- }
938
- function WriteStream$open() {
939
- var that = this;
940
- open(that.path, that.flags, that.mode, function(err, fd) {
941
- if (err) {
942
- that.destroy();
943
- that.emit("error", err);
944
- } else {
945
- that.fd = fd;
946
- that.emit("open", fd);
947
- }
948
- });
949
- }
950
- function createReadStream(path$12, options) {
951
- return new fs$22.ReadStream(path$12, options);
952
- }
953
- function createWriteStream(path$12, options) {
954
- return new fs$22.WriteStream(path$12, options);
955
- }
956
- var fs$open = fs$22.open;
957
- fs$22.open = open;
958
- function open(path$12, flags, mode, cb) {
959
- if (typeof mode === "function") cb = mode, mode = null;
960
- return go$open(path$12, flags, mode, cb);
961
- function go$open(path$13, flags$1, mode$1, cb$1, startTime) {
962
- return fs$open(path$13, flags$1, mode$1, function(err, fd) {
963
- if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
964
- go$open,
965
- [
966
- path$13,
967
- flags$1,
968
- mode$1,
969
- cb$1
970
- ],
971
- err,
972
- startTime || Date.now(),
973
- Date.now()
974
- ]);
975
- else if (typeof cb$1 === "function") cb$1.apply(this, arguments);
976
- });
977
- }
978
- }
979
- return fs$22;
980
- }
981
- function enqueue(elem) {
982
- debug("ENQUEUE", elem[0].name, elem[1]);
983
- fs$21[gracefulQueue].push(elem);
984
- retry();
985
- }
986
- var retryTimer;
987
- function resetQueue() {
988
- var now = Date.now();
989
- for (var i = 0; i < fs$21[gracefulQueue].length; ++i) if (fs$21[gracefulQueue][i].length > 2) {
990
- fs$21[gracefulQueue][i][3] = now;
991
- fs$21[gracefulQueue][i][4] = now;
992
- }
993
- retry();
994
- }
995
- function retry() {
996
- clearTimeout(retryTimer);
997
- retryTimer = void 0;
998
- if (fs$21[gracefulQueue].length === 0) return;
999
- var elem = fs$21[gracefulQueue].shift();
1000
- var fn = elem[0];
1001
- var args = elem[1];
1002
- var err = elem[2];
1003
- var startTime = elem[3];
1004
- var lastTime = elem[4];
1005
- if (startTime === void 0) {
1006
- debug("RETRY", fn.name, args);
1007
- fn.apply(null, args);
1008
- } else if (Date.now() - startTime >= 6e4) {
1009
- debug("TIMEOUT", fn.name, args);
1010
- var cb = args.pop();
1011
- if (typeof cb === "function") cb.call(null, err);
1012
- } else {
1013
- var sinceAttempt = Date.now() - lastTime;
1014
- var sinceStart = Math.max(lastTime - startTime, 1);
1015
- if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
1016
- debug("RETRY", fn.name, args);
1017
- fn.apply(null, args.concat([startTime]));
1018
- } else fs$21[gracefulQueue].push(elem);
1019
- }
1020
- if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
1021
- }
1022
- }) });
1023
-
1024
- //#endregion
1025
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/fs/index.js
1026
- var require_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/fs/index.js": ((exports) => {
1027
- const u$15 = require_universalify().fromCallback;
1028
- const fs$20 = require_graceful_fs();
1029
- const api = [
1030
- "access",
1031
- "appendFile",
1032
- "chmod",
1033
- "chown",
1034
- "close",
1035
- "copyFile",
1036
- "cp",
1037
- "fchmod",
1038
- "fchown",
1039
- "fdatasync",
1040
- "fstat",
1041
- "fsync",
1042
- "ftruncate",
1043
- "futimes",
1044
- "glob",
1045
- "lchmod",
1046
- "lchown",
1047
- "lutimes",
1048
- "link",
1049
- "lstat",
1050
- "mkdir",
1051
- "mkdtemp",
1052
- "open",
1053
- "opendir",
1054
- "readdir",
1055
- "readFile",
1056
- "readlink",
1057
- "realpath",
1058
- "rename",
1059
- "rm",
1060
- "rmdir",
1061
- "stat",
1062
- "statfs",
1063
- "symlink",
1064
- "truncate",
1065
- "unlink",
1066
- "utimes",
1067
- "writeFile"
1068
- ].filter((key) => {
1069
- return typeof fs$20[key] === "function";
1070
- });
1071
- Object.assign(exports, fs$20);
1072
- api.forEach((method) => {
1073
- exports[method] = u$15(fs$20[method]);
1074
- });
1075
- exports.exists = function(filename, callback) {
1076
- if (typeof callback === "function") return fs$20.exists(filename, callback);
1077
- return new Promise((resolve$1) => {
1078
- return fs$20.exists(filename, resolve$1);
1079
- });
1080
- };
1081
- exports.read = function(fd, buffer, offset, length, position, callback) {
1082
- if (typeof callback === "function") return fs$20.read(fd, buffer, offset, length, position, callback);
1083
- return new Promise((resolve$1, reject) => {
1084
- fs$20.read(fd, buffer, offset, length, position, (err, bytesRead, buffer$1) => {
1085
- if (err) return reject(err);
1086
- resolve$1({
1087
- bytesRead,
1088
- buffer: buffer$1
1089
- });
1090
- });
1091
- });
1092
- };
1093
- exports.write = function(fd, buffer, ...args) {
1094
- if (typeof args[args.length - 1] === "function") return fs$20.write(fd, buffer, ...args);
1095
- return new Promise((resolve$1, reject) => {
1096
- fs$20.write(fd, buffer, ...args, (err, bytesWritten, buffer$1) => {
1097
- if (err) return reject(err);
1098
- resolve$1({
1099
- bytesWritten,
1100
- buffer: buffer$1
1101
- });
1102
- });
1103
- });
1104
- };
1105
- exports.readv = function(fd, buffers, ...args) {
1106
- if (typeof args[args.length - 1] === "function") return fs$20.readv(fd, buffers, ...args);
1107
- return new Promise((resolve$1, reject) => {
1108
- fs$20.readv(fd, buffers, ...args, (err, bytesRead, buffers$1) => {
1109
- if (err) return reject(err);
1110
- resolve$1({
1111
- bytesRead,
1112
- buffers: buffers$1
1113
- });
1114
- });
1115
- });
1116
- };
1117
- exports.writev = function(fd, buffers, ...args) {
1118
- if (typeof args[args.length - 1] === "function") return fs$20.writev(fd, buffers, ...args);
1119
- return new Promise((resolve$1, reject) => {
1120
- fs$20.writev(fd, buffers, ...args, (err, bytesWritten, buffers$1) => {
1121
- if (err) return reject(err);
1122
- resolve$1({
1123
- bytesWritten,
1124
- buffers: buffers$1
1125
- });
1126
- });
1127
- });
1128
- };
1129
- if (typeof fs$20.realpath.native === "function") exports.realpath.native = u$15(fs$20.realpath.native);
1130
- else process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?", "Warning", "fs-extra-WARN0003");
1131
- }) });
1132
-
1133
- //#endregion
1134
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/utils.js
1135
- var require_utils$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/utils.js": ((exports, module) => {
1136
- const path$11 = __require("path");
1137
- module.exports.checkPath = function checkPath$1(pth) {
1138
- if (process.platform === "win32") {
1139
- if (/[<>:"|?*]/.test(pth.replace(path$11.parse(pth).root, ""))) {
1140
- const error = /* @__PURE__ */ new Error(`Path contains invalid characters: ${pth}`);
1141
- error.code = "EINVAL";
1142
- throw error;
1143
- }
1144
- }
1145
- };
1146
- }) });
1147
-
1148
- //#endregion
1149
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/make-dir.js
1150
- var require_make_dir = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/make-dir.js": ((exports, module) => {
1151
- const fs$19 = require_fs();
1152
- const { checkPath } = require_utils$1();
1153
- const getMode = (options) => {
1154
- const defaults = { mode: 511 };
1155
- if (typeof options === "number") return options;
1156
- return {
1157
- ...defaults,
1158
- ...options
1159
- }.mode;
1160
- };
1161
- module.exports.makeDir = async (dir, options) => {
1162
- checkPath(dir);
1163
- return fs$19.mkdir(dir, {
1164
- mode: getMode(options),
1165
- recursive: true
1166
- });
1167
- };
1168
- module.exports.makeDirSync = (dir, options) => {
1169
- checkPath(dir);
1170
- return fs$19.mkdirSync(dir, {
1171
- mode: getMode(options),
1172
- recursive: true
1173
- });
1174
- };
1175
- }) });
1176
-
1177
- //#endregion
1178
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/index.js
1179
- var require_mkdirs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/mkdirs/index.js": ((exports, module) => {
1180
- const u$14 = require_universalify().fromPromise;
1181
- const { makeDir: _makeDir, makeDirSync } = require_make_dir();
1182
- const makeDir = u$14(_makeDir);
1183
- module.exports = {
1184
- mkdirs: makeDir,
1185
- mkdirsSync: makeDirSync,
1186
- mkdirp: makeDir,
1187
- mkdirpSync: makeDirSync,
1188
- ensureDir: makeDir,
1189
- ensureDirSync: makeDirSync
1190
- };
1191
- }) });
1192
-
1193
- //#endregion
1194
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/path-exists/index.js
1195
- var require_path_exists = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/path-exists/index.js": ((exports, module) => {
1196
- const u$13 = require_universalify().fromPromise;
1197
- const fs$18 = require_fs();
1198
- function pathExists$6(path$12) {
1199
- return fs$18.access(path$12).then(() => true).catch(() => false);
1200
- }
1201
- module.exports = {
1202
- pathExists: u$13(pathExists$6),
1203
- pathExistsSync: fs$18.existsSync
1204
- };
1205
- }) });
1206
-
1207
- //#endregion
1208
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/util/utimes.js
1209
- var require_utimes = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/util/utimes.js": ((exports, module) => {
1210
- const fs$17 = require_fs();
1211
- const u$12 = require_universalify().fromPromise;
1212
- async function utimesMillis$1(path$12, atime, mtime) {
1213
- const fd = await fs$17.open(path$12, "r+");
1214
- let closeErr = null;
1215
- try {
1216
- await fs$17.futimes(fd, atime, mtime);
1217
- } finally {
1218
- try {
1219
- await fs$17.close(fd);
1220
- } catch (e) {
1221
- closeErr = e;
1222
- }
1223
- }
1224
- if (closeErr) throw closeErr;
1225
- }
1226
- function utimesMillisSync$1(path$12, atime, mtime) {
1227
- const fd = fs$17.openSync(path$12, "r+");
1228
- fs$17.futimesSync(fd, atime, mtime);
1229
- return fs$17.closeSync(fd);
1230
- }
1231
- module.exports = {
1232
- utimesMillis: u$12(utimesMillis$1),
1233
- utimesMillisSync: utimesMillisSync$1
1234
- };
1235
- }) });
1236
-
1237
- //#endregion
1238
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/util/stat.js
1239
- var require_stat = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/util/stat.js": ((exports, module) => {
1240
- const fs$16 = require_fs();
1241
- const path$10 = __require("path");
1242
- const u$11 = require_universalify().fromPromise;
1243
- function getStats$1(src, dest, opts) {
1244
- const statFunc = opts.dereference ? (file) => fs$16.stat(file, { bigint: true }) : (file) => fs$16.lstat(file, { bigint: true });
1245
- return Promise.all([statFunc(src), statFunc(dest).catch((err) => {
1246
- if (err.code === "ENOENT") return null;
1247
- throw err;
1248
- })]).then(([srcStat, destStat]) => ({
1249
- srcStat,
1250
- destStat
1251
- }));
1252
- }
1253
- function getStatsSync(src, dest, opts) {
1254
- let destStat;
1255
- const statFunc = opts.dereference ? (file) => fs$16.statSync(file, { bigint: true }) : (file) => fs$16.lstatSync(file, { bigint: true });
1256
- const srcStat = statFunc(src);
1257
- try {
1258
- destStat = statFunc(dest);
1259
- } catch (err) {
1260
- if (err.code === "ENOENT") return {
1261
- srcStat,
1262
- destStat: null
1263
- };
1264
- throw err;
1265
- }
1266
- return {
1267
- srcStat,
1268
- destStat
1269
- };
1270
- }
1271
- async function checkPaths(src, dest, funcName, opts) {
1272
- const { srcStat, destStat } = await getStats$1(src, dest, opts);
1273
- if (destStat) {
1274
- if (areIdentical$2(srcStat, destStat)) {
1275
- const srcBaseName = path$10.basename(src);
1276
- const destBaseName = path$10.basename(dest);
1277
- if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) return {
1278
- srcStat,
1279
- destStat,
1280
- isChangingCase: true
1281
- };
1282
- throw new Error("Source and destination must not be the same.");
1283
- }
1284
- if (srcStat.isDirectory() && !destStat.isDirectory()) throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1285
- if (!srcStat.isDirectory() && destStat.isDirectory()) throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1286
- }
1287
- if (srcStat.isDirectory() && isSrcSubdir(src, dest)) throw new Error(errMsg(src, dest, funcName));
1288
- return {
1289
- srcStat,
1290
- destStat
1291
- };
1292
- }
1293
- function checkPathsSync(src, dest, funcName, opts) {
1294
- const { srcStat, destStat } = getStatsSync(src, dest, opts);
1295
- if (destStat) {
1296
- if (areIdentical$2(srcStat, destStat)) {
1297
- const srcBaseName = path$10.basename(src);
1298
- const destBaseName = path$10.basename(dest);
1299
- if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) return {
1300
- srcStat,
1301
- destStat,
1302
- isChangingCase: true
1303
- };
1304
- throw new Error("Source and destination must not be the same.");
1305
- }
1306
- if (srcStat.isDirectory() && !destStat.isDirectory()) throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1307
- if (!srcStat.isDirectory() && destStat.isDirectory()) throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1308
- }
1309
- if (srcStat.isDirectory() && isSrcSubdir(src, dest)) throw new Error(errMsg(src, dest, funcName));
1310
- return {
1311
- srcStat,
1312
- destStat
1313
- };
1314
- }
1315
- async function checkParentPaths(src, srcStat, dest, funcName) {
1316
- const srcParent = path$10.resolve(path$10.dirname(src));
1317
- const destParent = path$10.resolve(path$10.dirname(dest));
1318
- if (destParent === srcParent || destParent === path$10.parse(destParent).root) return;
1319
- let destStat;
1320
- try {
1321
- destStat = await fs$16.stat(destParent, { bigint: true });
1322
- } catch (err) {
1323
- if (err.code === "ENOENT") return;
1324
- throw err;
1325
- }
1326
- if (areIdentical$2(srcStat, destStat)) throw new Error(errMsg(src, dest, funcName));
1327
- return checkParentPaths(src, srcStat, destParent, funcName);
1328
- }
1329
- function checkParentPathsSync(src, srcStat, dest, funcName) {
1330
- const srcParent = path$10.resolve(path$10.dirname(src));
1331
- const destParent = path$10.resolve(path$10.dirname(dest));
1332
- if (destParent === srcParent || destParent === path$10.parse(destParent).root) return;
1333
- let destStat;
1334
- try {
1335
- destStat = fs$16.statSync(destParent, { bigint: true });
1336
- } catch (err) {
1337
- if (err.code === "ENOENT") return;
1338
- throw err;
1339
- }
1340
- if (areIdentical$2(srcStat, destStat)) throw new Error(errMsg(src, dest, funcName));
1341
- return checkParentPathsSync(src, srcStat, destParent, funcName);
1342
- }
1343
- function areIdentical$2(srcStat, destStat) {
1344
- return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
1345
- }
1346
- function isSrcSubdir(src, dest) {
1347
- const srcArr = path$10.resolve(src).split(path$10.sep).filter((i) => i);
1348
- const destArr = path$10.resolve(dest).split(path$10.sep).filter((i) => i);
1349
- return srcArr.every((cur, i) => destArr[i] === cur);
1350
- }
1351
- function errMsg(src, dest, funcName) {
1352
- return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
1353
- }
1354
- module.exports = {
1355
- checkPaths: u$11(checkPaths),
1356
- checkPathsSync,
1357
- checkParentPaths: u$11(checkParentPaths),
1358
- checkParentPathsSync,
1359
- isSrcSubdir,
1360
- areIdentical: areIdentical$2
1361
- };
1362
- }) });
1363
-
1364
- //#endregion
1365
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/copy.js
1366
- var require_copy$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/copy.js": ((exports, module) => {
1367
- const fs$15 = require_fs();
1368
- const path$9 = __require("path");
1369
- const { mkdirs: mkdirs$1 } = require_mkdirs();
1370
- const { pathExists: pathExists$5 } = require_path_exists();
1371
- const { utimesMillis } = require_utimes();
1372
- const stat$3 = require_stat();
1373
- async function copy$1(src, dest, opts = {}) {
1374
- if (typeof opts === "function") opts = { filter: opts };
1375
- opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1376
- opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1377
- if (opts.preserveTimestamps && process.arch === "ia32") process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0001");
1378
- const { srcStat, destStat } = await stat$3.checkPaths(src, dest, "copy", opts);
1379
- await stat$3.checkParentPaths(src, srcStat, dest, "copy");
1380
- if (!await runFilter(src, dest, opts)) return;
1381
- const destParent = path$9.dirname(dest);
1382
- if (!await pathExists$5(destParent)) await mkdirs$1(destParent);
1383
- await getStatsAndPerformCopy(destStat, src, dest, opts);
1384
- }
1385
- async function runFilter(src, dest, opts) {
1386
- if (!opts.filter) return true;
1387
- return opts.filter(src, dest);
1388
- }
1389
- async function getStatsAndPerformCopy(destStat, src, dest, opts) {
1390
- const srcStat = await (opts.dereference ? fs$15.stat : fs$15.lstat)(src);
1391
- if (srcStat.isDirectory()) return onDir$1(srcStat, destStat, src, dest, opts);
1392
- if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile$1(srcStat, destStat, src, dest, opts);
1393
- if (srcStat.isSymbolicLink()) return onLink$1(destStat, src, dest, opts);
1394
- if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
1395
- if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1396
- throw new Error(`Unknown file: ${src}`);
1397
- }
1398
- async function onFile$1(srcStat, destStat, src, dest, opts) {
1399
- if (!destStat) return copyFile$1(srcStat, src, dest, opts);
1400
- if (opts.overwrite) {
1401
- await fs$15.unlink(dest);
1402
- return copyFile$1(srcStat, src, dest, opts);
1403
- }
1404
- if (opts.errorOnExist) throw new Error(`'${dest}' already exists`);
1405
- }
1406
- async function copyFile$1(srcStat, src, dest, opts) {
1407
- await fs$15.copyFile(src, dest);
1408
- if (opts.preserveTimestamps) {
1409
- if (fileIsNotWritable$1(srcStat.mode)) await makeFileWritable$1(dest, srcStat.mode);
1410
- const updatedSrcStat = await fs$15.stat(src);
1411
- await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1412
- }
1413
- return fs$15.chmod(dest, srcStat.mode);
1414
- }
1415
- function fileIsNotWritable$1(srcMode) {
1416
- return (srcMode & 128) === 0;
1417
- }
1418
- function makeFileWritable$1(dest, srcMode) {
1419
- return fs$15.chmod(dest, srcMode | 128);
1420
- }
1421
- async function onDir$1(srcStat, destStat, src, dest, opts) {
1422
- if (!destStat) await fs$15.mkdir(dest);
1423
- const promises = [];
1424
- for await (const item of await fs$15.opendir(src)) {
1425
- const srcItem = path$9.join(src, item.name);
1426
- const destItem = path$9.join(dest, item.name);
1427
- promises.push(runFilter(srcItem, destItem, opts).then((include) => {
1428
- if (include) return stat$3.checkPaths(srcItem, destItem, "copy", opts).then(({ destStat: destStat$1 }) => {
1429
- return getStatsAndPerformCopy(destStat$1, srcItem, destItem, opts);
1430
- });
1431
- }));
1432
- }
1433
- await Promise.all(promises);
1434
- if (!destStat) await fs$15.chmod(dest, srcStat.mode);
1435
- }
1436
- async function onLink$1(destStat, src, dest, opts) {
1437
- let resolvedSrc = await fs$15.readlink(src);
1438
- if (opts.dereference) resolvedSrc = path$9.resolve(process.cwd(), resolvedSrc);
1439
- if (!destStat) return fs$15.symlink(resolvedSrc, dest);
1440
- let resolvedDest = null;
1441
- try {
1442
- resolvedDest = await fs$15.readlink(dest);
1443
- } catch (e) {
1444
- if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs$15.symlink(resolvedSrc, dest);
1445
- throw e;
1446
- }
1447
- if (opts.dereference) resolvedDest = path$9.resolve(process.cwd(), resolvedDest);
1448
- if (stat$3.isSrcSubdir(resolvedSrc, resolvedDest)) throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1449
- if (stat$3.isSrcSubdir(resolvedDest, resolvedSrc)) throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1450
- await fs$15.unlink(dest);
1451
- return fs$15.symlink(resolvedSrc, dest);
1452
- }
1453
- module.exports = copy$1;
1454
- }) });
1455
-
1456
- //#endregion
1457
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/copy-sync.js
1458
- var require_copy_sync = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/copy-sync.js": ((exports, module) => {
1459
- const fs$14 = require_graceful_fs();
1460
- const path$8 = __require("path");
1461
- const mkdirsSync$1 = require_mkdirs().mkdirsSync;
1462
- const utimesMillisSync = require_utimes().utimesMillisSync;
1463
- const stat$2 = require_stat();
1464
- function copySync$1(src, dest, opts) {
1465
- if (typeof opts === "function") opts = { filter: opts };
1466
- opts = opts || {};
1467
- opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1468
- opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1469
- if (opts.preserveTimestamps && process.arch === "ia32") process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0002");
1470
- const { srcStat, destStat } = stat$2.checkPathsSync(src, dest, "copy", opts);
1471
- stat$2.checkParentPathsSync(src, srcStat, dest, "copy");
1472
- if (opts.filter && !opts.filter(src, dest)) return;
1473
- const destParent = path$8.dirname(dest);
1474
- if (!fs$14.existsSync(destParent)) mkdirsSync$1(destParent);
1475
- return getStats(destStat, src, dest, opts);
1476
- }
1477
- function getStats(destStat, src, dest, opts) {
1478
- const srcStat = (opts.dereference ? fs$14.statSync : fs$14.lstatSync)(src);
1479
- if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
1480
- else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
1481
- else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts);
1482
- else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`);
1483
- else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1484
- throw new Error(`Unknown file: ${src}`);
1485
- }
1486
- function onFile(srcStat, destStat, src, dest, opts) {
1487
- if (!destStat) return copyFile(srcStat, src, dest, opts);
1488
- return mayCopyFile(srcStat, src, dest, opts);
1489
- }
1490
- function mayCopyFile(srcStat, src, dest, opts) {
1491
- if (opts.overwrite) {
1492
- fs$14.unlinkSync(dest);
1493
- return copyFile(srcStat, src, dest, opts);
1494
- } else if (opts.errorOnExist) throw new Error(`'${dest}' already exists`);
1495
- }
1496
- function copyFile(srcStat, src, dest, opts) {
1497
- fs$14.copyFileSync(src, dest);
1498
- if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
1499
- return setDestMode(dest, srcStat.mode);
1500
- }
1501
- function handleTimestamps(srcMode, src, dest) {
1502
- if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
1503
- return setDestTimestamps(src, dest);
1504
- }
1505
- function fileIsNotWritable(srcMode) {
1506
- return (srcMode & 128) === 0;
1507
- }
1508
- function makeFileWritable(dest, srcMode) {
1509
- return setDestMode(dest, srcMode | 128);
1510
- }
1511
- function setDestMode(dest, srcMode) {
1512
- return fs$14.chmodSync(dest, srcMode);
1513
- }
1514
- function setDestTimestamps(src, dest) {
1515
- const updatedSrcStat = fs$14.statSync(src);
1516
- return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1517
- }
1518
- function onDir(srcStat, destStat, src, dest, opts) {
1519
- if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts);
1520
- return copyDir(src, dest, opts);
1521
- }
1522
- function mkDirAndCopy(srcMode, src, dest, opts) {
1523
- fs$14.mkdirSync(dest);
1524
- copyDir(src, dest, opts);
1525
- return setDestMode(dest, srcMode);
1526
- }
1527
- function copyDir(src, dest, opts) {
1528
- const dir = fs$14.opendirSync(src);
1529
- try {
1530
- let dirent;
1531
- while ((dirent = dir.readSync()) !== null) copyDirItem(dirent.name, src, dest, opts);
1532
- } finally {
1533
- dir.closeSync();
1534
- }
1535
- }
1536
- function copyDirItem(item, src, dest, opts) {
1537
- const srcItem = path$8.join(src, item);
1538
- const destItem = path$8.join(dest, item);
1539
- if (opts.filter && !opts.filter(srcItem, destItem)) return;
1540
- const { destStat } = stat$2.checkPathsSync(srcItem, destItem, "copy", opts);
1541
- return getStats(destStat, srcItem, destItem, opts);
1542
- }
1543
- function onLink(destStat, src, dest, opts) {
1544
- let resolvedSrc = fs$14.readlinkSync(src);
1545
- if (opts.dereference) resolvedSrc = path$8.resolve(process.cwd(), resolvedSrc);
1546
- if (!destStat) return fs$14.symlinkSync(resolvedSrc, dest);
1547
- else {
1548
- let resolvedDest;
1549
- try {
1550
- resolvedDest = fs$14.readlinkSync(dest);
1551
- } catch (err) {
1552
- if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs$14.symlinkSync(resolvedSrc, dest);
1553
- throw err;
1554
- }
1555
- if (opts.dereference) resolvedDest = path$8.resolve(process.cwd(), resolvedDest);
1556
- if (stat$2.isSrcSubdir(resolvedSrc, resolvedDest)) throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1557
- if (stat$2.isSrcSubdir(resolvedDest, resolvedSrc)) throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1558
- return copyLink(resolvedSrc, dest);
1559
- }
1560
- }
1561
- function copyLink(resolvedSrc, dest) {
1562
- fs$14.unlinkSync(dest);
1563
- return fs$14.symlinkSync(resolvedSrc, dest);
1564
- }
1565
- module.exports = copySync$1;
1566
- }) });
1567
-
1568
- //#endregion
1569
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/index.js
1570
- var require_copy = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/copy/index.js": ((exports, module) => {
1571
- const u$10 = require_universalify().fromPromise;
1572
- module.exports = {
1573
- copy: u$10(require_copy$1()),
1574
- copySync: require_copy_sync()
1575
- };
1576
- }) });
1577
-
1578
- //#endregion
1579
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/remove/index.js
1580
- var require_remove = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/remove/index.js": ((exports, module) => {
1581
- const fs$13 = require_graceful_fs();
1582
- const u$9 = require_universalify().fromCallback;
1583
- function remove$2(path$12, callback) {
1584
- fs$13.rm(path$12, {
1585
- recursive: true,
1586
- force: true
1587
- }, callback);
1588
- }
1589
- function removeSync$1(path$12) {
1590
- fs$13.rmSync(path$12, {
1591
- recursive: true,
1592
- force: true
1593
- });
1594
- }
1595
- module.exports = {
1596
- remove: u$9(remove$2),
1597
- removeSync: removeSync$1
1598
- };
1599
- }) });
1600
-
1601
- //#endregion
1602
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/empty/index.js
1603
- var require_empty = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/empty/index.js": ((exports, module) => {
1604
- const u$8 = require_universalify().fromPromise;
1605
- const fs$12 = require_fs();
1606
- const path$7 = __require("path");
1607
- const mkdir$3 = require_mkdirs();
1608
- const remove$1 = require_remove();
1609
- const emptyDir = u$8(async function emptyDir$1(dir) {
1610
- let items;
1611
- try {
1612
- items = await fs$12.readdir(dir);
1613
- } catch {
1614
- return mkdir$3.mkdirs(dir);
1615
- }
1616
- return Promise.all(items.map((item) => remove$1.remove(path$7.join(dir, item))));
1617
- });
1618
- function emptyDirSync(dir) {
1619
- let items;
1620
- try {
1621
- items = fs$12.readdirSync(dir);
1622
- } catch {
1623
- return mkdir$3.mkdirsSync(dir);
1624
- }
1625
- items.forEach((item) => {
1626
- item = path$7.join(dir, item);
1627
- remove$1.removeSync(item);
1628
- });
1629
- }
1630
- module.exports = {
1631
- emptyDirSync,
1632
- emptydirSync: emptyDirSync,
1633
- emptyDir,
1634
- emptydir: emptyDir
1635
- };
1636
- }) });
1637
-
1638
- //#endregion
1639
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/file.js
1640
- var require_file = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/file.js": ((exports, module) => {
1641
- const u$7 = require_universalify().fromPromise;
1642
- const path$6 = __require("path");
1643
- const fs$11 = require_fs();
1644
- const mkdir$2 = require_mkdirs();
1645
- async function createFile$1(file) {
1646
- let stats;
1647
- try {
1648
- stats = await fs$11.stat(file);
1649
- } catch {}
1650
- if (stats && stats.isFile()) return;
1651
- const dir = path$6.dirname(file);
1652
- let dirStats = null;
1653
- try {
1654
- dirStats = await fs$11.stat(dir);
1655
- } catch (err) {
1656
- if (err.code === "ENOENT") {
1657
- await mkdir$2.mkdirs(dir);
1658
- await fs$11.writeFile(file, "");
1659
- return;
1660
- } else throw err;
1661
- }
1662
- if (dirStats.isDirectory()) await fs$11.writeFile(file, "");
1663
- else await fs$11.readdir(dir);
1664
- }
1665
- function createFileSync$1(file) {
1666
- let stats;
1667
- try {
1668
- stats = fs$11.statSync(file);
1669
- } catch {}
1670
- if (stats && stats.isFile()) return;
1671
- const dir = path$6.dirname(file);
1672
- try {
1673
- if (!fs$11.statSync(dir).isDirectory()) fs$11.readdirSync(dir);
1674
- } catch (err) {
1675
- if (err && err.code === "ENOENT") mkdir$2.mkdirsSync(dir);
1676
- else throw err;
1677
- }
1678
- fs$11.writeFileSync(file, "");
1679
- }
1680
- module.exports = {
1681
- createFile: u$7(createFile$1),
1682
- createFileSync: createFileSync$1
1683
- };
1684
- }) });
1685
-
1686
- //#endregion
1687
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/link.js
1688
- var require_link = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/link.js": ((exports, module) => {
1689
- const u$6 = require_universalify().fromPromise;
1690
- const path$5 = __require("path");
1691
- const fs$10 = require_fs();
1692
- const mkdir$1 = require_mkdirs();
1693
- const { pathExists: pathExists$4 } = require_path_exists();
1694
- const { areIdentical: areIdentical$1 } = require_stat();
1695
- async function createLink$1(srcpath, dstpath) {
1696
- let dstStat;
1697
- try {
1698
- dstStat = await fs$10.lstat(dstpath);
1699
- } catch {}
1700
- let srcStat;
1701
- try {
1702
- srcStat = await fs$10.lstat(srcpath);
1703
- } catch (err) {
1704
- err.message = err.message.replace("lstat", "ensureLink");
1705
- throw err;
1706
- }
1707
- if (dstStat && areIdentical$1(srcStat, dstStat)) return;
1708
- const dir = path$5.dirname(dstpath);
1709
- if (!await pathExists$4(dir)) await mkdir$1.mkdirs(dir);
1710
- await fs$10.link(srcpath, dstpath);
1711
- }
1712
- function createLinkSync$1(srcpath, dstpath) {
1713
- let dstStat;
1714
- try {
1715
- dstStat = fs$10.lstatSync(dstpath);
1716
- } catch {}
1717
- try {
1718
- const srcStat = fs$10.lstatSync(srcpath);
1719
- if (dstStat && areIdentical$1(srcStat, dstStat)) return;
1720
- } catch (err) {
1721
- err.message = err.message.replace("lstat", "ensureLink");
1722
- throw err;
1723
- }
1724
- const dir = path$5.dirname(dstpath);
1725
- if (fs$10.existsSync(dir)) return fs$10.linkSync(srcpath, dstpath);
1726
- mkdir$1.mkdirsSync(dir);
1727
- return fs$10.linkSync(srcpath, dstpath);
1728
- }
1729
- module.exports = {
1730
- createLink: u$6(createLink$1),
1731
- createLinkSync: createLinkSync$1
1732
- };
1733
- }) });
1734
-
1735
- //#endregion
1736
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink-paths.js
1737
- var require_symlink_paths = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink-paths.js": ((exports, module) => {
1738
- const path$4 = __require("path");
1739
- const fs$9 = require_fs();
1740
- const { pathExists: pathExists$3 } = require_path_exists();
1741
- const u$5 = require_universalify().fromPromise;
1742
- /**
1743
- * Function that returns two types of paths, one relative to symlink, and one
1744
- * relative to the current working directory. Checks if path is absolute or
1745
- * relative. If the path is relative, this function checks if the path is
1746
- * relative to symlink or relative to current working directory. This is an
1747
- * initiative to find a smarter `srcpath` to supply when building symlinks.
1748
- * This allows you to determine which path to use out of one of three possible
1749
- * types of source paths. The first is an absolute path. This is detected by
1750
- * `path.isAbsolute()`. When an absolute path is provided, it is checked to
1751
- * see if it exists. If it does it's used, if not an error is returned
1752
- * (callback)/ thrown (sync). The other two options for `srcpath` are a
1753
- * relative url. By default Node's `fs.symlink` works by creating a symlink
1754
- * using `dstpath` and expects the `srcpath` to be relative to the newly
1755
- * created symlink. If you provide a `srcpath` that does not exist on the file
1756
- * system it results in a broken symlink. To minimize this, the function
1757
- * checks to see if the 'relative to symlink' source file exists, and if it
1758
- * does it will use it. If it does not, it checks if there's a file that
1759
- * exists that is relative to the current working directory, if does its used.
1760
- * This preserves the expectations of the original fs.symlink spec and adds
1761
- * the ability to pass in `relative to current working direcotry` paths.
1762
- */
1763
- async function symlinkPaths$1(srcpath, dstpath) {
1764
- if (path$4.isAbsolute(srcpath)) {
1765
- try {
1766
- await fs$9.lstat(srcpath);
1767
- } catch (err) {
1768
- err.message = err.message.replace("lstat", "ensureSymlink");
1769
- throw err;
1770
- }
1771
- return {
1772
- toCwd: srcpath,
1773
- toDst: srcpath
1774
- };
1775
- }
1776
- const dstdir = path$4.dirname(dstpath);
1777
- const relativeToDst = path$4.join(dstdir, srcpath);
1778
- if (await pathExists$3(relativeToDst)) return {
1779
- toCwd: relativeToDst,
1780
- toDst: srcpath
1781
- };
1782
- try {
1783
- await fs$9.lstat(srcpath);
1784
- } catch (err) {
1785
- err.message = err.message.replace("lstat", "ensureSymlink");
1786
- throw err;
1787
- }
1788
- return {
1789
- toCwd: srcpath,
1790
- toDst: path$4.relative(dstdir, srcpath)
1791
- };
1792
- }
1793
- function symlinkPathsSync$1(srcpath, dstpath) {
1794
- if (path$4.isAbsolute(srcpath)) {
1795
- if (!fs$9.existsSync(srcpath)) throw new Error("absolute srcpath does not exist");
1796
- return {
1797
- toCwd: srcpath,
1798
- toDst: srcpath
1799
- };
1800
- }
1801
- const dstdir = path$4.dirname(dstpath);
1802
- const relativeToDst = path$4.join(dstdir, srcpath);
1803
- if (fs$9.existsSync(relativeToDst)) return {
1804
- toCwd: relativeToDst,
1805
- toDst: srcpath
1806
- };
1807
- if (!fs$9.existsSync(srcpath)) throw new Error("relative srcpath does not exist");
1808
- return {
1809
- toCwd: srcpath,
1810
- toDst: path$4.relative(dstdir, srcpath)
1811
- };
1812
- }
1813
- module.exports = {
1814
- symlinkPaths: u$5(symlinkPaths$1),
1815
- symlinkPathsSync: symlinkPathsSync$1
1816
- };
1817
- }) });
1818
-
1819
- //#endregion
1820
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink-type.js
1821
- var require_symlink_type = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink-type.js": ((exports, module) => {
1822
- const fs$8 = require_fs();
1823
- const u$4 = require_universalify().fromPromise;
1824
- async function symlinkType$1(srcpath, type) {
1825
- if (type) return type;
1826
- let stats;
1827
- try {
1828
- stats = await fs$8.lstat(srcpath);
1829
- } catch {
1830
- return "file";
1831
- }
1832
- return stats && stats.isDirectory() ? "dir" : "file";
1833
- }
1834
- function symlinkTypeSync$1(srcpath, type) {
1835
- if (type) return type;
1836
- let stats;
1837
- try {
1838
- stats = fs$8.lstatSync(srcpath);
1839
- } catch {
1840
- return "file";
1841
- }
1842
- return stats && stats.isDirectory() ? "dir" : "file";
1843
- }
1844
- module.exports = {
1845
- symlinkType: u$4(symlinkType$1),
1846
- symlinkTypeSync: symlinkTypeSync$1
1847
- };
1848
- }) });
1849
-
1850
- //#endregion
1851
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink.js
1852
- var require_symlink = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/symlink.js": ((exports, module) => {
1853
- const u$3 = require_universalify().fromPromise;
1854
- const path$3 = __require("path");
1855
- const fs$7 = require_fs();
1856
- const { mkdirs, mkdirsSync } = require_mkdirs();
1857
- const { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
1858
- const { symlinkType, symlinkTypeSync } = require_symlink_type();
1859
- const { pathExists: pathExists$2 } = require_path_exists();
1860
- const { areIdentical } = require_stat();
1861
- async function createSymlink$1(srcpath, dstpath, type) {
1862
- let stats;
1863
- try {
1864
- stats = await fs$7.lstat(dstpath);
1865
- } catch {}
1866
- if (stats && stats.isSymbolicLink()) {
1867
- const [srcStat, dstStat] = await Promise.all([fs$7.stat(srcpath), fs$7.stat(dstpath)]);
1868
- if (areIdentical(srcStat, dstStat)) return;
1869
- }
1870
- const relative = await symlinkPaths(srcpath, dstpath);
1871
- srcpath = relative.toDst;
1872
- const toType = await symlinkType(relative.toCwd, type);
1873
- const dir = path$3.dirname(dstpath);
1874
- if (!await pathExists$2(dir)) await mkdirs(dir);
1875
- return fs$7.symlink(srcpath, dstpath, toType);
1876
- }
1877
- function createSymlinkSync$1(srcpath, dstpath, type) {
1878
- let stats;
1879
- try {
1880
- stats = fs$7.lstatSync(dstpath);
1881
- } catch {}
1882
- if (stats && stats.isSymbolicLink()) {
1883
- if (areIdentical(fs$7.statSync(srcpath), fs$7.statSync(dstpath))) return;
1884
- }
1885
- const relative = symlinkPathsSync(srcpath, dstpath);
1886
- srcpath = relative.toDst;
1887
- type = symlinkTypeSync(relative.toCwd, type);
1888
- const dir = path$3.dirname(dstpath);
1889
- if (fs$7.existsSync(dir)) return fs$7.symlinkSync(srcpath, dstpath, type);
1890
- mkdirsSync(dir);
1891
- return fs$7.symlinkSync(srcpath, dstpath, type);
1892
- }
1893
- module.exports = {
1894
- createSymlink: u$3(createSymlink$1),
1895
- createSymlinkSync: createSymlinkSync$1
1896
- };
1897
- }) });
1898
-
1899
- //#endregion
1900
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/index.js
1901
- var require_ensure = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/ensure/index.js": ((exports, module) => {
1902
- const { createFile, createFileSync } = require_file();
1903
- const { createLink, createLinkSync } = require_link();
1904
- const { createSymlink, createSymlinkSync } = require_symlink();
1905
- module.exports = {
1906
- createFile,
1907
- createFileSync,
1908
- ensureFile: createFile,
1909
- ensureFileSync: createFileSync,
1910
- createLink,
1911
- createLinkSync,
1912
- ensureLink: createLink,
1913
- ensureLinkSync: createLinkSync,
1914
- createSymlink,
1915
- createSymlinkSync,
1916
- ensureSymlink: createSymlink,
1917
- ensureSymlinkSync: createSymlinkSync
1918
- };
1919
- }) });
1920
-
1921
- //#endregion
1922
- //#region ../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js
1923
- var require_utils = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js": ((exports, module) => {
1924
- function stringify$3(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
1925
- const EOF = finalEOL ? EOL : "";
1926
- return JSON.stringify(obj, replacer, spaces).replace(/\n/g, EOL) + EOF;
1927
- }
1928
- function stripBom$1(content) {
1929
- if (Buffer.isBuffer(content)) content = content.toString("utf8");
1930
- return content.replace(/^\uFEFF/, "");
1931
- }
1932
- module.exports = {
1933
- stringify: stringify$3,
1934
- stripBom: stripBom$1
1935
- };
1936
- }) });
1937
-
1938
- //#endregion
1939
- //#region ../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js
1940
- var require_jsonfile$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js": ((exports, module) => {
1941
- let _fs;
1942
- try {
1943
- _fs = require_graceful_fs();
1944
- } catch (_) {
1945
- _fs = __require("fs");
1946
- }
1947
- const universalify = require_universalify();
1948
- const { stringify: stringify$2, stripBom } = require_utils();
1949
- async function _readFile(file, options = {}) {
1950
- if (typeof options === "string") options = { encoding: options };
1951
- const fs$22 = options.fs || _fs;
1952
- const shouldThrow = "throws" in options ? options.throws : true;
1953
- let data = await universalify.fromCallback(fs$22.readFile)(file, options);
1954
- data = stripBom(data);
1955
- let obj;
1956
- try {
1957
- obj = JSON.parse(data, options ? options.reviver : null);
1958
- } catch (err) {
1959
- if (shouldThrow) {
1960
- err.message = `${file}: ${err.message}`;
1961
- throw err;
1962
- } else return null;
1963
- }
1964
- return obj;
1965
- }
1966
- const readFile = universalify.fromPromise(_readFile);
1967
- function readFileSync(file, options = {}) {
1968
- if (typeof options === "string") options = { encoding: options };
1969
- const fs$22 = options.fs || _fs;
1970
- const shouldThrow = "throws" in options ? options.throws : true;
1971
- try {
1972
- let content = fs$22.readFileSync(file, options);
1973
- content = stripBom(content);
1974
- return JSON.parse(content, options.reviver);
1975
- } catch (err) {
1976
- if (shouldThrow) {
1977
- err.message = `${file}: ${err.message}`;
1978
- throw err;
1979
- } else return null;
1980
- }
1981
- }
1982
- async function _writeFile(file, obj, options = {}) {
1983
- const fs$22 = options.fs || _fs;
1984
- const str = stringify$2(obj, options);
1985
- await universalify.fromCallback(fs$22.writeFile)(file, str, options);
1986
- }
1987
- const writeFile = universalify.fromPromise(_writeFile);
1988
- function writeFileSync(file, obj, options = {}) {
1989
- const fs$22 = options.fs || _fs;
1990
- const str = stringify$2(obj, options);
1991
- return fs$22.writeFileSync(file, str, options);
1992
- }
1993
- const jsonfile = {
1994
- readFile,
1995
- readFileSync,
1996
- writeFile,
1997
- writeFileSync
1998
- };
1999
- module.exports = jsonfile;
2000
- }) });
2001
-
2002
- //#endregion
2003
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/jsonfile.js
2004
- var require_jsonfile = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/jsonfile.js": ((exports, module) => {
2005
- const jsonFile$1 = require_jsonfile$1();
2006
- module.exports = {
2007
- readJson: jsonFile$1.readFile,
2008
- readJsonSync: jsonFile$1.readFileSync,
2009
- writeJson: jsonFile$1.writeFile,
2010
- writeJsonSync: jsonFile$1.writeFileSync
2011
- };
2012
- }) });
2013
-
2014
- //#endregion
2015
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/output-file/index.js
2016
- var require_output_file = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/output-file/index.js": ((exports, module) => {
2017
- const u$2 = require_universalify().fromPromise;
2018
- const fs$6 = require_fs();
2019
- const path$2 = __require("path");
2020
- const mkdir = require_mkdirs();
2021
- const pathExists$1 = require_path_exists().pathExists;
2022
- async function outputFile$1(file, data, encoding = "utf-8") {
2023
- const dir = path$2.dirname(file);
2024
- if (!await pathExists$1(dir)) await mkdir.mkdirs(dir);
2025
- return fs$6.writeFile(file, data, encoding);
2026
- }
2027
- function outputFileSync$1(file, ...args) {
2028
- const dir = path$2.dirname(file);
2029
- if (!fs$6.existsSync(dir)) mkdir.mkdirsSync(dir);
2030
- fs$6.writeFileSync(file, ...args);
2031
- }
2032
- module.exports = {
2033
- outputFile: u$2(outputFile$1),
2034
- outputFileSync: outputFileSync$1
2035
- };
2036
- }) });
2037
-
2038
- //#endregion
2039
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json.js
2040
- var require_output_json = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json.js": ((exports, module) => {
2041
- const { stringify: stringify$1 } = require_utils();
2042
- const { outputFile } = require_output_file();
2043
- async function outputJson(file, data, options = {}) {
2044
- await outputFile(file, stringify$1(data, options), options);
2045
- }
2046
- module.exports = outputJson;
2047
- }) });
2048
-
2049
- //#endregion
2050
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json-sync.js
2051
- var require_output_json_sync = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/output-json-sync.js": ((exports, module) => {
2052
- const { stringify } = require_utils();
2053
- const { outputFileSync } = require_output_file();
2054
- function outputJsonSync(file, data, options) {
2055
- outputFileSync(file, stringify(data, options), options);
2056
- }
2057
- module.exports = outputJsonSync;
2058
- }) });
2059
-
2060
- //#endregion
2061
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/index.js
2062
- var require_json = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/json/index.js": ((exports, module) => {
2063
- const u$1 = require_universalify().fromPromise;
2064
- const jsonFile = require_jsonfile();
2065
- jsonFile.outputJson = u$1(require_output_json());
2066
- jsonFile.outputJsonSync = require_output_json_sync();
2067
- jsonFile.outputJSON = jsonFile.outputJson;
2068
- jsonFile.outputJSONSync = jsonFile.outputJsonSync;
2069
- jsonFile.writeJSON = jsonFile.writeJson;
2070
- jsonFile.writeJSONSync = jsonFile.writeJsonSync;
2071
- jsonFile.readJSON = jsonFile.readJson;
2072
- jsonFile.readJSONSync = jsonFile.readJsonSync;
2073
- module.exports = jsonFile;
2074
- }) });
2075
-
2076
- //#endregion
2077
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/move.js
2078
- var require_move$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/move.js": ((exports, module) => {
2079
- const fs$5 = require_fs();
2080
- const path$1 = __require("path");
2081
- const { copy } = require_copy();
2082
- const { remove } = require_remove();
2083
- const { mkdirp } = require_mkdirs();
2084
- const { pathExists } = require_path_exists();
2085
- const stat$1 = require_stat();
2086
- async function move(src, dest, opts = {}) {
2087
- const overwrite = opts.overwrite || opts.clobber || false;
2088
- const { srcStat, isChangingCase = false } = await stat$1.checkPaths(src, dest, "move", opts);
2089
- await stat$1.checkParentPaths(src, srcStat, dest, "move");
2090
- const destParent = path$1.dirname(dest);
2091
- if (path$1.parse(destParent).root !== destParent) await mkdirp(destParent);
2092
- return doRename$1(src, dest, overwrite, isChangingCase);
2093
- }
2094
- async function doRename$1(src, dest, overwrite, isChangingCase) {
2095
- if (!isChangingCase) {
2096
- if (overwrite) await remove(dest);
2097
- else if (await pathExists(dest)) throw new Error("dest already exists.");
2098
- }
2099
- try {
2100
- await fs$5.rename(src, dest);
2101
- } catch (err) {
2102
- if (err.code !== "EXDEV") throw err;
2103
- await moveAcrossDevice$1(src, dest, overwrite);
2104
- }
2105
- }
2106
- async function moveAcrossDevice$1(src, dest, overwrite) {
2107
- await copy(src, dest, {
2108
- overwrite,
2109
- errorOnExist: true,
2110
- preserveTimestamps: true
2111
- });
2112
- return remove(src);
2113
- }
2114
- module.exports = move;
2115
- }) });
2116
-
2117
- //#endregion
2118
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/move-sync.js
2119
- var require_move_sync = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/move-sync.js": ((exports, module) => {
2120
- const fs$4 = require_graceful_fs();
2121
- const path = __require("path");
2122
- const copySync = require_copy().copySync;
2123
- const removeSync = require_remove().removeSync;
2124
- const mkdirpSync = require_mkdirs().mkdirpSync;
2125
- const stat = require_stat();
2126
- function moveSync(src, dest, opts) {
2127
- opts = opts || {};
2128
- const overwrite = opts.overwrite || opts.clobber || false;
2129
- const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
2130
- stat.checkParentPathsSync(src, srcStat, dest, "move");
2131
- if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest));
2132
- return doRename(src, dest, overwrite, isChangingCase);
2133
- }
2134
- function isParentRoot(dest) {
2135
- const parent = path.dirname(dest);
2136
- return path.parse(parent).root === parent;
2137
- }
2138
- function doRename(src, dest, overwrite, isChangingCase) {
2139
- if (isChangingCase) return rename(src, dest, overwrite);
2140
- if (overwrite) {
2141
- removeSync(dest);
2142
- return rename(src, dest, overwrite);
2143
- }
2144
- if (fs$4.existsSync(dest)) throw new Error("dest already exists.");
2145
- return rename(src, dest, overwrite);
2146
- }
2147
- function rename(src, dest, overwrite) {
2148
- try {
2149
- fs$4.renameSync(src, dest);
2150
- } catch (err) {
2151
- if (err.code !== "EXDEV") throw err;
2152
- return moveAcrossDevice(src, dest, overwrite);
2153
- }
2154
- }
2155
- function moveAcrossDevice(src, dest, overwrite) {
2156
- copySync(src, dest, {
2157
- overwrite,
2158
- errorOnExist: true,
2159
- preserveTimestamps: true
2160
- });
2161
- return removeSync(src);
2162
- }
2163
- module.exports = moveSync;
2164
- }) });
2165
-
2166
- //#endregion
2167
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/index.js
2168
- var require_move = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/move/index.js": ((exports, module) => {
2169
- const u = require_universalify().fromPromise;
2170
- module.exports = {
2171
- move: u(require_move$1()),
2172
- moveSync: require_move_sync()
2173
- };
2174
- }) });
2175
-
2176
- //#endregion
2177
- //#region ../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/index.js
2178
- var require_lib = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fs-extra@11.3.0/node_modules/fs-extra/lib/index.js": ((exports, module) => {
2179
- module.exports = {
2180
- ...require_fs(),
2181
- ...require_copy(),
2182
- ...require_empty(),
2183
- ...require_ensure(),
2184
- ...require_json(),
2185
- ...require_mkdirs(),
2186
- ...require_move(),
2187
- ...require_output_file(),
2188
- ...require_path_exists(),
2189
- ...require_remove()
2190
- };
2191
- }) });
2192
-
2193
- //#endregion
2194
- //#region src/init/cz.config.ts
2195
- var import_lib$2 = /* @__PURE__ */ __toESM(require_lib(), 1);
2196
- function createCzConfig(cwd$1 = process$1.cwd()) {
2197
- const target = resolve(cwd$1, "cz.config.cjs");
2198
- if (import_lib$2.default.existsSync(target)) import_lib$2.default.unlinkSync(target);
2199
- try {
2200
- const cfg = {
2201
- $schema: `https://raw.githubusercontent.com/Zhengqbbb/cz-git/refs/tags/v${CZGPackage.version}/docs/public/schema/cz-git.json`,
2202
- ...commitPreset.prompt,
2203
- types: commitPreset.prompt?.types?.map((t) => ({
2204
- value: t.value,
2205
- name: t.name,
2206
- emoji: t.emoji
2207
- })),
2208
- scopes: commitPreset.prompt?.scopes
2209
- };
2210
- const content = `module.exports = ${JSON.stringify(cfg, null, 2)}\n`;
2211
- import_lib$2.default.writeFileSync(target, content, "utf8");
2212
- return true;
2213
- } catch {
2214
- return false;
2215
- }
2216
- }
2217
- function runCzConfig(czConfigPath, cwd$1 = process$1.cwd()) {
2218
- const packagePath = resolve(cwd$1, "package.json");
2219
- if (!import_lib$2.default.existsSync(packagePath)) return false;
2220
- try {
2221
- const raw = import_lib$2.default.readFileSync(packagePath, "utf8");
2222
- const json = JSON.parse(raw);
2223
- const desiredPath = "node_modules/cz-git";
2224
- const desiredCzConfig = czConfigPath;
2225
- json.config = json.config || {};
2226
- json.config.commitizen = json.config.commitizen || {};
2227
- let changed = false;
2228
- if (json.config.commitizen.path !== desiredPath) {
2229
- json.config.commitizen.path = desiredPath;
2230
- changed = true;
2231
- }
2232
- const currentCz = json.config.commitizen.czConfig;
2233
- const normalize = (p) => p ? p.replace(/^\.\/?/, "") : p;
2234
- const isOldRoot = normalize(currentCz) === "cz.config.cjs" || normalize(currentCz) === "cz.config.js";
2235
- if (!currentCz || isOldRoot || normalize(currentCz) === "cz.config.mjs") {
2236
- if (currentCz !== desiredCzConfig) {
2237
- json.config.commitizen.czConfig = desiredCzConfig;
2238
- changed = true;
2239
- }
2240
- }
2241
- if (!changed) return false;
2242
- import_lib$2.default.writeFileSync(packagePath, `${JSON.stringify(json, null, 2)}\n`, "utf8");
2243
- return true;
2244
- } catch {
2245
- return false;
2246
- }
2247
- }
2248
-
2249
- //#endregion
2250
- //#region src/init/git.message.ts
2251
- var import_lib$1 = /* @__PURE__ */ __toESM(require_lib(), 1);
2252
- function createGitMessage(rootPath = process$1.cwd()) {
2253
- const target = resolve(rootPath, ".gitmessage");
2254
- if (import_lib$1.default.existsSync(target)) import_lib$1.default.unlinkSync(target);
2255
- const tpl = `# Commit Message 模板 (首行: <type>(<scope>): <subject>)\n# 可用类型: ${(commitPreset.prompt?.types || []).map((t) => t.value).join(", ")}\n# 可用范围: ${(commitPreset.prompt?.scopes || []).join(", ")}\n# 示例: feat(core): add http client abstraction\n# 空行后可写入 body, 使用 | 换行 (交互模式会自动处理)\n`;
2256
- import_lib$1.default.writeFileSync(target, tpl, "utf8");
2257
- return true;
2258
- }
2259
- function runGitMessage(rootPath = process$1.cwd()) {
2260
- try {
2261
- if (execSync("git config --get commit.template", {
2262
- cwd: rootPath,
2263
- stdio: "pipe"
2264
- }).toString().trim()) return false;
2265
- } catch {}
2266
- try {
2267
- execSync("git config commit.template .gitmessage", {
2268
- cwd: rootPath,
2269
- stdio: "ignore"
2270
- });
2271
- return true;
2272
- } catch {
2273
- return false;
2274
- }
2275
- }
2276
-
2277
- //#endregion
2278
- //#region src/init/simple.git.hook.ts
2279
- var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
2280
- function runSimpleGitHooks(script = "pubinfo-commit", cwd$1 = process$1.cwd(), enabled = true) {
2281
- if (!enabled) return false;
2282
- const pkgPath = resolve(cwd$1, "package.json");
2283
- if (!import_lib.default.existsSync(pkgPath)) return false;
2284
- try {
2285
- const raw = import_lib.default.readFileSync(pkgPath, "utf8");
2286
- const json = JSON.parse(raw);
2287
- const hooks = json["simple-git-hooks"] || {};
2288
- const desiredPre = "pnpm lint-staged";
2289
- const desiredCommitMsg = `pnpm exec ${script} --edit $1`;
2290
- json["simple-git-hooks"] = hooks;
2291
- if (hooks["pre-commit"] !== desiredPre) hooks["pre-commit"] = desiredPre;
2292
- if (hooks["commit-msg"] !== desiredCommitMsg) hooks["commit-msg"] = desiredCommitMsg;
2293
- json["simple-git-hooks"] = hooks;
2294
- import_lib.default.writeFileSync(pkgPath, `${JSON.stringify(json, null, 2)}\n`, "utf8");
2295
- return true;
2296
- } catch {
2297
- return false;
2298
- }
2299
- }
2300
- function runNpx(cwd$1 = process$1.cwd()) {
2301
- try {
2302
- execSync("npx simple-git-hooks", {
2303
- cwd: cwd$1,
2304
- stdio: "ignore"
2305
- });
2306
- return true;
2307
- } catch {
2308
- return false;
2309
- }
2310
- }
2311
- function configureGitHooksPath(enabled = true, cwd$1 = process$1.cwd()) {
2312
- try {
2313
- if (enabled) {
2314
- execSync("git config --unset core.hooksPath", {
2315
- cwd: cwd$1,
2316
- stdio: "ignore"
2317
- });
2318
- return true;
2319
- }
2320
- execSync("git config core.hooksPath /dev/null", {
2321
- cwd: cwd$1,
2322
- stdio: "ignore"
2323
- });
2324
- return true;
2325
- } catch {
2326
- return enabled;
2327
- }
2328
- }
2329
-
2330
- //#endregion
2331
- //#region src/prompt/index.ts
2332
- async function runPrompt() {
2333
- try {
2334
- const require$1 = createRequire(import.meta.url);
2335
- try {
2336
- const czg = require$1("czg");
2337
- if (czg && typeof czg.default === "function") {
2338
- const api$1 = await czg.default({ emoji: false });
2339
- if (api$1 && api$1.raw) return { raw: api$1.raw };
2340
- }
2341
- } catch {}
2342
- const binDir = resolve(process$1.cwd(), "node_modules/.bin");
2343
- const isWin = process$1.platform === "win32";
2344
- const czgBin = (isWin ? [
2345
- join(binDir, "czg.cmd"),
2346
- join(binDir, "czg.ps1"),
2347
- join(binDir, "czg")
2348
- ] : [join(binDir, "czg")]).find((p) => fs.existsSync(p));
2349
- if (czgBin) {
2350
- await new Promise((res) => {
2351
- const child = spawn(czgBin, [], {
2352
- stdio: "inherit",
2353
- shell: isWin
2354
- });
2355
- child.on("exit", () => res());
2356
- child.on("error", () => res());
2357
- });
2358
- const msgPath = resolve(process$1.cwd(), ".git/COMMIT_EDITMSG");
2359
- if (fs.existsSync(msgPath)) return { raw: fs.readFileSync(msgPath, "utf8").trim() };
2360
- }
2361
- return null;
2362
- } catch {
2363
- return null;
2364
- }
2365
- }
2366
-
2367
- //#endregion
2368
- //#region src/utils/git.ts
2369
- /**
2370
- * 判断当前工作目录是否处在 Git 仓库内。
2371
- */
2372
- function isInsideGitRepo() {
2373
- try {
2374
- const out = execSync("git rev-parse --is-inside-work-tree", { stdio: [
2375
- "ignore",
2376
- "pipe",
2377
- "ignore"
2378
- ] });
2379
- return String(out).trim() === "true";
2380
- } catch {
2381
- return false;
2382
- }
2383
- }
2384
-
2385
- //#endregion
2386
- //#region src/utils/lint.message.ts
2387
- async function lintMessage(message) {
2388
- if (!await isCommitlintEnabled()) return true;
2389
- try {
2390
- const result = await (await import("@commitlint/lint")).default(message, commitPreset.rules, commitPreset);
2391
- if (!result.valid) {
2392
- console.error("✖ Commit message failed lint:\n");
2393
- for (const err of result.errors) console.error(` • ${err.message}`);
2394
- process$1.exit(1);
2395
- }
2396
- } catch (e) {
2397
- console.error("[pubinfo-commit] lint failed to run:", e);
2398
- }
2399
- return true;
2400
- }
2401
- async function lintAndReturn(message) {
2402
- await lintMessage(message);
2403
- return message;
2404
- }
2405
-
2406
- //#endregion
2407
- export { configureGitHooksPath as a, createGitMessage as c, runCzConfig as d, isCommitlintEnabled as f, runPrompt as i, runGitMessage as l, loadCommitConfig as m, lintMessage as n, runNpx as o, commitPreset as p, isInsideGitRepo as r, runSimpleGitHooks as s, lintAndReturn as t, createCzConfig as u };