agmd 0.3.0-alpha0.4 → 0.3.5-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/bin/bin.js +81 -78
- package/bin/bin.js.map +3 -3
- package/lib/commands/change-path.d.ts +12 -0
- package/lib/commands/get-file.d.ts +15 -7
- package/lib/commands/wirte-md.d.ts +1 -1
- package/lib/index.cjs.js +388 -107
- package/lib/index.cjs.js.map +3 -3
- package/lib/index.esm.js +389 -108
- package/lib/index.esm.js.map +3 -3
- package/lib/shared/logger.d.ts +7 -0
- package/package.json +17 -8
package/lib/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* agmd v0.3.
|
|
2
|
+
* agmd v0.3.5-beta2
|
|
3
3
|
* author:kakajun <253495832@qq.com>
|
|
4
|
-
*
|
|
4
|
+
* Fri May 06 2022 09:36:13 GMT+0800 (中国标准时间)
|
|
5
5
|
*/
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -29,22 +29,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
29
29
|
};
|
|
30
30
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
31
31
|
|
|
32
|
-
// node_modules/ms/index.js
|
|
33
|
-
var
|
|
34
|
-
"node_modules/ms/index.js"(exports, module) {
|
|
32
|
+
// node_modules/_ms@2.1.2@ms/index.js
|
|
33
|
+
var require_ms_2_1 = __commonJS({
|
|
34
|
+
"node_modules/_ms@2.1.2@ms/index.js"(exports, module) {
|
|
35
35
|
var s = 1e3;
|
|
36
36
|
var m = s * 60;
|
|
37
37
|
var h = m * 60;
|
|
38
38
|
var d = h * 24;
|
|
39
39
|
var w = d * 7;
|
|
40
40
|
var y = d * 365.25;
|
|
41
|
-
module.exports = function(val,
|
|
42
|
-
|
|
41
|
+
module.exports = function(val, options2) {
|
|
42
|
+
options2 = options2 || {};
|
|
43
43
|
var type = typeof val;
|
|
44
44
|
if (type === "string" && val.length > 0) {
|
|
45
45
|
return parse(val);
|
|
46
46
|
} else if (type === "number" && isFinite(val)) {
|
|
47
|
-
return
|
|
47
|
+
return options2.long ? fmtLong(val) : fmtShort(val);
|
|
48
48
|
}
|
|
49
49
|
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
50
50
|
};
|
|
@@ -141,20 +141,20 @@ var require_ms = __commonJS({
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
// node_modules/debug/src/common.js
|
|
144
|
+
// node_modules/_debug@4.3.4@debug/src/common.js
|
|
145
145
|
var require_common = __commonJS({
|
|
146
|
-
"node_modules/debug/src/common.js"(exports, module) {
|
|
147
|
-
function setup(
|
|
146
|
+
"node_modules/_debug@4.3.4@debug/src/common.js"(exports, module) {
|
|
147
|
+
function setup(env2) {
|
|
148
148
|
createDebug.debug = createDebug;
|
|
149
149
|
createDebug.default = createDebug;
|
|
150
150
|
createDebug.coerce = coerce;
|
|
151
151
|
createDebug.disable = disable;
|
|
152
152
|
createDebug.enable = enable;
|
|
153
|
-
createDebug.enabled =
|
|
154
|
-
createDebug.humanize =
|
|
153
|
+
createDebug.enabled = enabled2;
|
|
154
|
+
createDebug.humanize = require_ms_2_1();
|
|
155
155
|
createDebug.destroy = destroy;
|
|
156
|
-
Object.keys(
|
|
157
|
-
createDebug[key] =
|
|
156
|
+
Object.keys(env2).forEach((key) => {
|
|
157
|
+
createDebug[key] = env2[key];
|
|
158
158
|
});
|
|
159
159
|
createDebug.names = [];
|
|
160
160
|
createDebug.skips = [];
|
|
@@ -173,16 +173,16 @@ var require_common = __commonJS({
|
|
|
173
173
|
let enableOverride = null;
|
|
174
174
|
let namespacesCache;
|
|
175
175
|
let enabledCache;
|
|
176
|
-
function
|
|
177
|
-
if (!
|
|
176
|
+
function debug4(...args) {
|
|
177
|
+
if (!debug4.enabled) {
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
|
-
const
|
|
180
|
+
const self2 = debug4;
|
|
181
181
|
const curr = Number(new Date());
|
|
182
182
|
const ms = curr - (prevTime || curr);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
self2.diff = ms;
|
|
184
|
+
self2.prev = prevTime;
|
|
185
|
+
self2.curr = curr;
|
|
186
186
|
prevTime = curr;
|
|
187
187
|
args[0] = createDebug.coerce(args[0]);
|
|
188
188
|
if (typeof args[0] !== "string") {
|
|
@@ -197,22 +197,22 @@ var require_common = __commonJS({
|
|
|
197
197
|
const formatter = createDebug.formatters[format2];
|
|
198
198
|
if (typeof formatter === "function") {
|
|
199
199
|
const val = args[index];
|
|
200
|
-
match = formatter.call(
|
|
200
|
+
match = formatter.call(self2, val);
|
|
201
201
|
args.splice(index, 1);
|
|
202
202
|
index--;
|
|
203
203
|
}
|
|
204
204
|
return match;
|
|
205
205
|
});
|
|
206
|
-
createDebug.formatArgs.call(
|
|
207
|
-
const logFn =
|
|
208
|
-
logFn.apply(
|
|
206
|
+
createDebug.formatArgs.call(self2, args);
|
|
207
|
+
const logFn = self2.log || createDebug.log;
|
|
208
|
+
logFn.apply(self2, args);
|
|
209
209
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Object.defineProperty(
|
|
210
|
+
debug4.namespace = namespace;
|
|
211
|
+
debug4.useColors = createDebug.useColors();
|
|
212
|
+
debug4.color = createDebug.selectColor(namespace);
|
|
213
|
+
debug4.extend = extend;
|
|
214
|
+
debug4.destroy = createDebug.destroy;
|
|
215
|
+
Object.defineProperty(debug4, "enabled", {
|
|
216
216
|
enumerable: true,
|
|
217
217
|
configurable: false,
|
|
218
218
|
get: () => {
|
|
@@ -230,9 +230,9 @@ var require_common = __commonJS({
|
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
232
|
if (typeof createDebug.init === "function") {
|
|
233
|
-
createDebug.init(
|
|
233
|
+
createDebug.init(debug4);
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return debug4;
|
|
236
236
|
}
|
|
237
237
|
function extend(namespace, delimiter) {
|
|
238
238
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
@@ -267,7 +267,7 @@ var require_common = __commonJS({
|
|
|
267
267
|
createDebug.enable("");
|
|
268
268
|
return namespaces;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function enabled2(name) {
|
|
271
271
|
if (name[name.length - 1] === "*") {
|
|
272
272
|
return true;
|
|
273
273
|
}
|
|
@@ -304,9 +304,9 @@ var require_common = __commonJS({
|
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
306
|
|
|
307
|
-
// node_modules/debug/src/browser.js
|
|
307
|
+
// node_modules/_debug@4.3.4@debug/src/browser.js
|
|
308
308
|
var require_browser = __commonJS({
|
|
309
|
-
"node_modules/debug/src/browser.js"(exports, module) {
|
|
309
|
+
"node_modules/_debug@4.3.4@debug/src/browser.js"(exports, module) {
|
|
310
310
|
exports.formatArgs = formatArgs;
|
|
311
311
|
exports.save = save;
|
|
312
312
|
exports.load = load;
|
|
@@ -469,9 +469,9 @@ var require_browser = __commonJS({
|
|
|
469
469
|
}
|
|
470
470
|
});
|
|
471
471
|
|
|
472
|
-
// node_modules/has-flag/index.js
|
|
473
|
-
var
|
|
474
|
-
"node_modules/has-flag/index.js"(exports, module) {
|
|
472
|
+
// node_modules/_has-flag@4.0.0@has-flag/index.js
|
|
473
|
+
var require_has_flag_4_0 = __commonJS({
|
|
474
|
+
"node_modules/_has-flag@4.0.0@has-flag/index.js"(exports, module) {
|
|
475
475
|
"use strict";
|
|
476
476
|
module.exports = (flag, argv = process.argv) => {
|
|
477
477
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
@@ -482,27 +482,29 @@ var require_has_flag = __commonJS({
|
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
484
|
|
|
485
|
-
// node_modules/supports-color/index.js
|
|
486
|
-
var
|
|
487
|
-
"node_modules/supports-color/index.js"(exports, module) {
|
|
485
|
+
// node_modules/_supports-color@8.1.1@supports-color/index.js
|
|
486
|
+
var require_supports_color_8_1 = __commonJS({
|
|
487
|
+
"node_modules/_supports-color@8.1.1@supports-color/index.js"(exports, module) {
|
|
488
488
|
"use strict";
|
|
489
489
|
var os = __require("os");
|
|
490
490
|
var tty = __require("tty");
|
|
491
|
-
var hasFlag =
|
|
492
|
-
var { env } = process;
|
|
493
|
-
var
|
|
491
|
+
var hasFlag = require_has_flag_4_0();
|
|
492
|
+
var { env: env2 } = process;
|
|
493
|
+
var flagForceColor;
|
|
494
494
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
495
|
-
|
|
495
|
+
flagForceColor = 0;
|
|
496
496
|
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
497
|
-
|
|
497
|
+
flagForceColor = 1;
|
|
498
498
|
}
|
|
499
|
-
|
|
500
|
-
if (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
499
|
+
function envForceColor() {
|
|
500
|
+
if ("FORCE_COLOR" in env2) {
|
|
501
|
+
if (env2.FORCE_COLOR === "true") {
|
|
502
|
+
return 1;
|
|
503
|
+
}
|
|
504
|
+
if (env2.FORCE_COLOR === "false") {
|
|
505
|
+
return 0;
|
|
506
|
+
}
|
|
507
|
+
return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
|
|
506
508
|
}
|
|
507
509
|
}
|
|
508
510
|
function translateLevel(level) {
|
|
@@ -516,21 +518,28 @@ var require_supports_color = __commonJS({
|
|
|
516
518
|
has16m: level >= 3
|
|
517
519
|
};
|
|
518
520
|
}
|
|
519
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
521
|
+
function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
522
|
+
const noFlagForceColor = envForceColor();
|
|
523
|
+
if (noFlagForceColor !== void 0) {
|
|
524
|
+
flagForceColor = noFlagForceColor;
|
|
525
|
+
}
|
|
526
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
520
527
|
if (forceColor === 0) {
|
|
521
528
|
return 0;
|
|
522
529
|
}
|
|
523
|
-
if (
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
530
|
+
if (sniffFlags) {
|
|
531
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
532
|
+
return 3;
|
|
533
|
+
}
|
|
534
|
+
if (hasFlag("color=256")) {
|
|
535
|
+
return 2;
|
|
536
|
+
}
|
|
528
537
|
}
|
|
529
538
|
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
530
539
|
return 0;
|
|
531
540
|
}
|
|
532
541
|
const min = forceColor || 0;
|
|
533
|
-
if (
|
|
542
|
+
if (env2.TERM === "dumb") {
|
|
534
543
|
return min;
|
|
535
544
|
}
|
|
536
545
|
if (process.platform === "win32") {
|
|
@@ -540,53 +549,56 @@ var require_supports_color = __commonJS({
|
|
|
540
549
|
}
|
|
541
550
|
return 1;
|
|
542
551
|
}
|
|
543
|
-
if ("CI" in
|
|
544
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in
|
|
552
|
+
if ("CI" in env2) {
|
|
553
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
|
|
545
554
|
return 1;
|
|
546
555
|
}
|
|
547
556
|
return min;
|
|
548
557
|
}
|
|
549
|
-
if ("TEAMCITY_VERSION" in
|
|
550
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(
|
|
558
|
+
if ("TEAMCITY_VERSION" in env2) {
|
|
559
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
|
|
551
560
|
}
|
|
552
|
-
if (
|
|
561
|
+
if (env2.COLORTERM === "truecolor") {
|
|
553
562
|
return 3;
|
|
554
563
|
}
|
|
555
|
-
if ("TERM_PROGRAM" in
|
|
556
|
-
const version = parseInt((
|
|
557
|
-
switch (
|
|
564
|
+
if ("TERM_PROGRAM" in env2) {
|
|
565
|
+
const version = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
566
|
+
switch (env2.TERM_PROGRAM) {
|
|
558
567
|
case "iTerm.app":
|
|
559
568
|
return version >= 3 ? 3 : 2;
|
|
560
569
|
case "Apple_Terminal":
|
|
561
570
|
return 2;
|
|
562
571
|
}
|
|
563
572
|
}
|
|
564
|
-
if (/-256(color)?$/i.test(
|
|
573
|
+
if (/-256(color)?$/i.test(env2.TERM)) {
|
|
565
574
|
return 2;
|
|
566
575
|
}
|
|
567
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
576
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
|
|
568
577
|
return 1;
|
|
569
578
|
}
|
|
570
|
-
if ("COLORTERM" in
|
|
579
|
+
if ("COLORTERM" in env2) {
|
|
571
580
|
return 1;
|
|
572
581
|
}
|
|
573
582
|
return min;
|
|
574
583
|
}
|
|
575
|
-
function getSupportLevel(stream) {
|
|
576
|
-
const level = supportsColor(stream,
|
|
584
|
+
function getSupportLevel(stream, options2 = {}) {
|
|
585
|
+
const level = supportsColor(stream, {
|
|
586
|
+
streamIsTTY: stream && stream.isTTY,
|
|
587
|
+
...options2
|
|
588
|
+
});
|
|
577
589
|
return translateLevel(level);
|
|
578
590
|
}
|
|
579
591
|
module.exports = {
|
|
580
592
|
supportsColor: getSupportLevel,
|
|
581
|
-
stdout:
|
|
582
|
-
stderr:
|
|
593
|
+
stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
|
|
594
|
+
stderr: getSupportLevel({ isTTY: tty.isatty(2) })
|
|
583
595
|
};
|
|
584
596
|
}
|
|
585
597
|
});
|
|
586
598
|
|
|
587
|
-
// node_modules/debug/src/node.js
|
|
599
|
+
// node_modules/_debug@4.3.4@debug/src/node.js
|
|
588
600
|
var require_node = __commonJS({
|
|
589
|
-
"node_modules/debug/src/node.js"(exports, module) {
|
|
601
|
+
"node_modules/_debug@4.3.4@debug/src/node.js"(exports, module) {
|
|
590
602
|
var tty = __require("tty");
|
|
591
603
|
var util = __require("util");
|
|
592
604
|
exports.init = init;
|
|
@@ -599,7 +611,7 @@ var require_node = __commonJS({
|
|
|
599
611
|
}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
600
612
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
601
613
|
try {
|
|
602
|
-
const supportsColor =
|
|
614
|
+
const supportsColor = require_supports_color_8_1();
|
|
603
615
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
604
616
|
exports.colors = [
|
|
605
617
|
20,
|
|
@@ -735,11 +747,11 @@ var require_node = __commonJS({
|
|
|
735
747
|
function load() {
|
|
736
748
|
return process.env.DEBUG;
|
|
737
749
|
}
|
|
738
|
-
function init(
|
|
739
|
-
|
|
750
|
+
function init(debug4) {
|
|
751
|
+
debug4.inspectOpts = {};
|
|
740
752
|
const keys = Object.keys(exports.inspectOpts);
|
|
741
753
|
for (let i = 0; i < keys.length; i++) {
|
|
742
|
-
|
|
754
|
+
debug4.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
743
755
|
}
|
|
744
756
|
}
|
|
745
757
|
module.exports = require_common()(exports);
|
|
@@ -755,9 +767,9 @@ var require_node = __commonJS({
|
|
|
755
767
|
}
|
|
756
768
|
});
|
|
757
769
|
|
|
758
|
-
// node_modules/debug/src/index.js
|
|
770
|
+
// node_modules/_debug@4.3.4@debug/src/index.js
|
|
759
771
|
var require_src = __commonJS({
|
|
760
|
-
"node_modules/debug/src/index.js"(exports, module) {
|
|
772
|
+
"node_modules/_debug@4.3.4@debug/src/index.js"(exports, module) {
|
|
761
773
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
762
774
|
module.exports = require_browser();
|
|
763
775
|
} else {
|
|
@@ -766,29 +778,295 @@ var require_src = __commonJS({
|
|
|
766
778
|
}
|
|
767
779
|
});
|
|
768
780
|
|
|
769
|
-
//
|
|
770
|
-
|
|
781
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/compare-aliases.js
|
|
782
|
+
var require_compare_aliases = __commonJS({
|
|
783
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/compare-aliases.js"(exports, module) {
|
|
784
|
+
module.exports = function compareAliases(env2, ...aliases) {
|
|
785
|
+
return aliases.some((alias) => alias.toLowerCase() === env2.toLowerCase());
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/modes.enum.js
|
|
791
|
+
var require_modes_enum = __commonJS({
|
|
792
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/modes.enum.js"(exports, module) {
|
|
793
|
+
var Development = {
|
|
794
|
+
dev: "dev",
|
|
795
|
+
development: "development"
|
|
796
|
+
};
|
|
797
|
+
var Production = {
|
|
798
|
+
prod: "prod",
|
|
799
|
+
production: "production"
|
|
800
|
+
};
|
|
801
|
+
module.exports = {
|
|
802
|
+
Production,
|
|
803
|
+
Development
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/inspector.js
|
|
809
|
+
var require_inspector = __commonJS({
|
|
810
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/inspector.js"(exports, module) {
|
|
811
|
+
var compare = require_compare_aliases();
|
|
812
|
+
var modes = require_modes_enum();
|
|
813
|
+
function inspector(...envs) {
|
|
814
|
+
const nodeEnv = process.env.NODE_ENV ?? "development";
|
|
815
|
+
if (envs.length === 0) {
|
|
816
|
+
return nodeEnv;
|
|
817
|
+
}
|
|
818
|
+
return envs.reduce((prev, env2) => {
|
|
819
|
+
if (isKnownMode(env2, nodeEnv)) {
|
|
820
|
+
return true;
|
|
821
|
+
}
|
|
822
|
+
return prev || compare(env2, nodeEnv);
|
|
823
|
+
}, false);
|
|
824
|
+
}
|
|
825
|
+
function isKnownMode(env2, nodeEnv) {
|
|
826
|
+
for (const mode of Object.values(modes)) {
|
|
827
|
+
if (compareKnownMode(env2, nodeEnv, Object.values(mode))) {
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
function compareKnownMode(env2, nodeEnv, possibleValues) {
|
|
834
|
+
return compare(env2, ...possibleValues) && compare(nodeEnv, ...possibleValues);
|
|
835
|
+
}
|
|
836
|
+
module.exports = inspector;
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/index.js
|
|
841
|
+
var require_lib = __commonJS({
|
|
842
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/index.js"(exports, module) {
|
|
843
|
+
module.exports = {
|
|
844
|
+
env: require_inspector()
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
});
|
|
771
848
|
|
|
772
849
|
// src/commands/get-file.ts
|
|
773
|
-
var
|
|
850
|
+
var import_debug2 = __toESM(require_src());
|
|
851
|
+
import fs2 from "fs";
|
|
852
|
+
import path2 from "path";
|
|
853
|
+
|
|
854
|
+
// src/commands/change-path.ts
|
|
774
855
|
import fs from "fs";
|
|
775
856
|
import path from "path";
|
|
776
|
-
|
|
857
|
+
|
|
858
|
+
// node_modules/_kolorist@1.5.1@kolorist/dist/esm/index.mjs
|
|
859
|
+
var enabled = true;
|
|
860
|
+
var globalVar = typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
861
|
+
var supportLevel = 0;
|
|
862
|
+
if (globalVar.process && globalVar.process.env && globalVar.process.stdout) {
|
|
863
|
+
const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = globalVar.process.env;
|
|
864
|
+
if (NODE_DISABLE_COLORS || FORCE_COLOR === "0") {
|
|
865
|
+
enabled = false;
|
|
866
|
+
} else if (FORCE_COLOR === "1") {
|
|
867
|
+
enabled = true;
|
|
868
|
+
} else if (TERM === "dumb") {
|
|
869
|
+
enabled = false;
|
|
870
|
+
} else if ("CI" in globalVar.process.env && [
|
|
871
|
+
"TRAVIS",
|
|
872
|
+
"CIRCLECI",
|
|
873
|
+
"APPVEYOR",
|
|
874
|
+
"GITLAB_CI",
|
|
875
|
+
"GITHUB_ACTIONS",
|
|
876
|
+
"BUILDKITE",
|
|
877
|
+
"DRONE"
|
|
878
|
+
].some((vendor) => vendor in globalVar.process.env)) {
|
|
879
|
+
enabled = true;
|
|
880
|
+
} else {
|
|
881
|
+
enabled = process.stdout.isTTY;
|
|
882
|
+
}
|
|
883
|
+
if (enabled) {
|
|
884
|
+
supportLevel = TERM && TERM.endsWith("-256color") ? 2 : 1;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
var options = {
|
|
888
|
+
enabled,
|
|
889
|
+
supportLevel
|
|
890
|
+
};
|
|
891
|
+
function kolorist(start, end, level = 1) {
|
|
892
|
+
const open = `\x1B[${start}m`;
|
|
893
|
+
const close = `\x1B[${end}m`;
|
|
894
|
+
const regex = new RegExp(`\\x1b\\[${end}m`, "g");
|
|
895
|
+
return (str) => {
|
|
896
|
+
return options.enabled && options.supportLevel >= level ? open + ("" + str).replace(regex, open) + close : "" + str;
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
var reset = kolorist(0, 0);
|
|
900
|
+
var bold = kolorist(1, 22);
|
|
901
|
+
var dim = kolorist(2, 22);
|
|
902
|
+
var italic = kolorist(3, 23);
|
|
903
|
+
var underline = kolorist(4, 24);
|
|
904
|
+
var inverse = kolorist(7, 27);
|
|
905
|
+
var hidden = kolorist(8, 28);
|
|
906
|
+
var strikethrough = kolorist(9, 29);
|
|
907
|
+
var black = kolorist(30, 39);
|
|
908
|
+
var red = kolorist(31, 39);
|
|
909
|
+
var green = kolorist(32, 39);
|
|
910
|
+
var yellow = kolorist(33, 39);
|
|
911
|
+
var blue = kolorist(34, 39);
|
|
912
|
+
var magenta = kolorist(35, 39);
|
|
913
|
+
var cyan = kolorist(36, 39);
|
|
914
|
+
var white = kolorist(97, 39);
|
|
915
|
+
var gray = kolorist(90, 39);
|
|
916
|
+
var lightGray = kolorist(37, 39);
|
|
917
|
+
var lightRed = kolorist(91, 39);
|
|
918
|
+
var lightGreen = kolorist(92, 39);
|
|
919
|
+
var lightYellow = kolorist(93, 39);
|
|
920
|
+
var lightBlue = kolorist(94, 39);
|
|
921
|
+
var lightMagenta = kolorist(95, 39);
|
|
922
|
+
var lightCyan = kolorist(96, 39);
|
|
923
|
+
var bgBlack = kolorist(40, 49);
|
|
924
|
+
var bgRed = kolorist(41, 49);
|
|
925
|
+
var bgGreen = kolorist(42, 49);
|
|
926
|
+
var bgYellow = kolorist(43, 49);
|
|
927
|
+
var bgBlue = kolorist(44, 49);
|
|
928
|
+
var bgMagenta = kolorist(45, 49);
|
|
929
|
+
var bgCyan = kolorist(46, 49);
|
|
930
|
+
var bgWhite = kolorist(107, 49);
|
|
931
|
+
var bgGray = kolorist(100, 49);
|
|
932
|
+
var bgLightRed = kolorist(101, 49);
|
|
933
|
+
var bgLightGreen = kolorist(102, 49);
|
|
934
|
+
var bgLightYellow = kolorist(103, 49);
|
|
935
|
+
var bgLightBlue = kolorist(104, 49);
|
|
936
|
+
var bgLightMagenta = kolorist(105, 49);
|
|
937
|
+
var bgLightCyan = kolorist(106, 49);
|
|
938
|
+
var bgLightGray = kolorist(47, 49);
|
|
939
|
+
|
|
940
|
+
// src/shared/logger.ts
|
|
941
|
+
var logger = {
|
|
942
|
+
info(text) {
|
|
943
|
+
console.log(lightBlue(`\u2708 - ${text}`));
|
|
944
|
+
},
|
|
945
|
+
success(text) {
|
|
946
|
+
console.log(lightGreen(`\u2714 - ${text}`));
|
|
947
|
+
},
|
|
948
|
+
warn(text) {
|
|
949
|
+
console.log(lightYellow(`\u25B6 - ${text}`));
|
|
950
|
+
},
|
|
951
|
+
error(text) {
|
|
952
|
+
console.log(lightRed(`\u2716 - ${text}`));
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
var logger_default = logger;
|
|
956
|
+
|
|
957
|
+
// src/commands/change-path.ts
|
|
958
|
+
var import_debug = __toESM(require_src());
|
|
959
|
+
var debug = (0, import_debug.default)("change-path");
|
|
777
960
|
debug.enabled = false;
|
|
778
|
-
function
|
|
779
|
-
|
|
961
|
+
function getRelatPath(absoluteImport, fullPath) {
|
|
962
|
+
let relatPath = path.relative(path.dirname(fullPath), absoluteImport);
|
|
963
|
+
relatPath = relatPath.replace(/\\/g, "/");
|
|
964
|
+
if (relatPath.indexOf(".") !== 0) {
|
|
965
|
+
relatPath = "./" + relatPath;
|
|
966
|
+
}
|
|
967
|
+
return relatPath;
|
|
968
|
+
}
|
|
969
|
+
function makeSuffix(filePath, fullPath) {
|
|
970
|
+
let absoluteImport = "";
|
|
971
|
+
if (filePath.indexOf("@") > -1) {
|
|
972
|
+
debug("!!!!!!!!!filePath: ", filePath);
|
|
973
|
+
absoluteImport = filePath.replace("@", process.cwd());
|
|
974
|
+
} else {
|
|
975
|
+
absoluteImport = path.resolve(path.dirname(fullPath), filePath);
|
|
976
|
+
}
|
|
977
|
+
debug("makeSuffix \u5165\u53C2: absoluteImport", absoluteImport);
|
|
978
|
+
const lastName = path.extname(absoluteImport);
|
|
979
|
+
debug("lastName", lastName);
|
|
980
|
+
if (!lastName) {
|
|
981
|
+
debug("!!!!!!!!!!!\u7F3A\u540E\u7F00\u6587\u4EF6: ", absoluteImport);
|
|
982
|
+
const suffix = [".js", ".ts", ".vue", "/index.js", "/index.vue"];
|
|
983
|
+
for (let j = 0; j < suffix.length; j++) {
|
|
984
|
+
const fixStr = suffix[j];
|
|
985
|
+
if (fs.existsSync(absoluteImport + fixStr)) {
|
|
986
|
+
debug("\u8865\u5168\u7684\u6587\u4EF6: ", absoluteImport + fixStr);
|
|
987
|
+
absoluteImport = absoluteImport + fixStr;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return absoluteImport.replace(/\\/g, "/");
|
|
993
|
+
}
|
|
994
|
+
function getImportName(ele) {
|
|
995
|
+
let str = "";
|
|
996
|
+
const ignore = [
|
|
997
|
+
"xiwicloud",
|
|
998
|
+
"bpmn-js",
|
|
999
|
+
"element-ui",
|
|
1000
|
+
"lodash",
|
|
1001
|
+
"handsontable",
|
|
1002
|
+
"nprogress",
|
|
1003
|
+
"quill",
|
|
1004
|
+
"qrcodejs2",
|
|
1005
|
+
"echarts"
|
|
1006
|
+
];
|
|
1007
|
+
const flag = ignore.some((item) => ele.indexOf(item) > -1);
|
|
1008
|
+
const reg = / from [\"|\'](.*)[\'|\"]/;
|
|
1009
|
+
if (!flag && ele.indexOf("/") > -1 && ele.indexOf("//") !== 0) {
|
|
1010
|
+
const impStr = ele.match(reg);
|
|
1011
|
+
if (impStr && impStr[1])
|
|
1012
|
+
str = impStr[1];
|
|
1013
|
+
}
|
|
1014
|
+
return str;
|
|
1015
|
+
}
|
|
1016
|
+
function changeImport(ele, fullPath) {
|
|
1017
|
+
let obj = {
|
|
1018
|
+
impName: "",
|
|
1019
|
+
filePath: "",
|
|
1020
|
+
absoluteImport: ""
|
|
1021
|
+
};
|
|
1022
|
+
const impName = getImportName(ele);
|
|
1023
|
+
if (impName) {
|
|
1024
|
+
obj.filePath = impName;
|
|
1025
|
+
debug("!!!!!!!!!\u5339\u914Dimp: ", impName);
|
|
1026
|
+
obj.absoluteImport = makeSuffix(obj.filePath, fullPath);
|
|
1027
|
+
debug("\u8865\u8FC7\u540E", obj.absoluteImport);
|
|
1028
|
+
obj.impName = getRelatPath(obj.absoluteImport, fullPath);
|
|
1029
|
+
debug("\u76F8\u5BF9\u8DEF\u5F84: ", obj.impName);
|
|
1030
|
+
}
|
|
1031
|
+
return obj;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/commands/get-file.ts
|
|
1035
|
+
var import_node_environment = __toESM(require_lib());
|
|
1036
|
+
var debug2 = (0, import_debug2.default)("get-file");
|
|
1037
|
+
debug2.enabled = false;
|
|
1038
|
+
var isDev = (0, import_node_environment.env)() === "development";
|
|
1039
|
+
function getFile(fullPath) {
|
|
1040
|
+
const str = fs2.readFileSync(fullPath, "utf-8");
|
|
780
1041
|
const size = str.length;
|
|
781
1042
|
const sarr = str.split(/[\n]/g);
|
|
782
1043
|
const rowSize = sarr.length;
|
|
1044
|
+
const imports = getImport(sarr, fullPath);
|
|
783
1045
|
const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
|
|
784
1046
|
return {
|
|
785
|
-
note: f,
|
|
1047
|
+
note: f.replace(/<\/?[^>]*>|(\n|\r)/g, ""),
|
|
786
1048
|
size,
|
|
787
|
-
rowSize
|
|
1049
|
+
rowSize,
|
|
1050
|
+
imports
|
|
788
1051
|
};
|
|
789
1052
|
}
|
|
790
|
-
function
|
|
1053
|
+
function getImport(sarr, fullPath) {
|
|
1054
|
+
const imports = [];
|
|
1055
|
+
sarr.forEach((ele) => {
|
|
1056
|
+
if (ele.indexOf("from") > -1) {
|
|
1057
|
+
const { absoluteImport } = changeImport(ele, fullPath);
|
|
1058
|
+
if (absoluteImport) {
|
|
1059
|
+
imports.push(absoluteImport);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
return imports;
|
|
1064
|
+
}
|
|
1065
|
+
function getFileNodes(dir = process.cwd(), option, nodes = [], level = 0) {
|
|
791
1066
|
let ignore = [
|
|
1067
|
+
"bin",
|
|
1068
|
+
"lib",
|
|
1069
|
+
"jest.config.js",
|
|
792
1070
|
"router",
|
|
793
1071
|
"img",
|
|
794
1072
|
"styles",
|
|
@@ -799,17 +1077,18 @@ function getFileNodes(dir = path.resolve("./"), option, nodes = [], level = 0) {
|
|
|
799
1077
|
"dist",
|
|
800
1078
|
".husky",
|
|
801
1079
|
".vscode",
|
|
1080
|
+
".eslintrc.js",
|
|
802
1081
|
"readme-file.js",
|
|
803
1082
|
"readme-md.js"
|
|
804
1083
|
];
|
|
805
|
-
let include = [".js", ".vue"];
|
|
1084
|
+
let include = isDev ? [".js", ".vue"] : [".js", ".vue", ".ts"];
|
|
806
1085
|
if (option) {
|
|
807
1086
|
ignore = option.ignore || ignore;
|
|
808
1087
|
include = option.include || include;
|
|
809
1088
|
}
|
|
810
|
-
const files =
|
|
811
|
-
|
|
812
|
-
const isDir =
|
|
1089
|
+
const files = fs2.readdirSync(dir).map((item) => {
|
|
1090
|
+
let fullPath = path2.join(dir, item);
|
|
1091
|
+
const isDir = fs2.lstatSync(fullPath).isDirectory();
|
|
813
1092
|
return {
|
|
814
1093
|
name: item,
|
|
815
1094
|
isDir,
|
|
@@ -831,10 +1110,11 @@ function getFileNodes(dir = path.resolve("./"), option, nodes = [], level = 0) {
|
|
|
831
1110
|
const item = files[index];
|
|
832
1111
|
const foldFlag = ignore.findIndex((obj) => obj === item.name);
|
|
833
1112
|
if (foldFlag === -1) {
|
|
834
|
-
const fullPath =
|
|
835
|
-
const isDir =
|
|
1113
|
+
const fullPath = path2.join(dir, item.name);
|
|
1114
|
+
const isDir = fs2.lstatSync(fullPath).isDirectory();
|
|
836
1115
|
if (isDir) {
|
|
837
1116
|
getFileNodes(fullPath, option, item.children = [], level + 1);
|
|
1117
|
+
item.fullPath = fullPath.replace(/\\/g, "/");
|
|
838
1118
|
nodes.push(item);
|
|
839
1119
|
} else {
|
|
840
1120
|
const i = fullPath.lastIndexOf(".");
|
|
@@ -843,7 +1123,7 @@ function getFileNodes(dir = path.resolve("./"), option, nodes = [], level = 0) {
|
|
|
843
1123
|
const obj = getFile(fullPath);
|
|
844
1124
|
Object.assign(item, obj);
|
|
845
1125
|
item.suffix = lastName;
|
|
846
|
-
item.fullPath = fullPath;
|
|
1126
|
+
item.fullPath = fullPath.replace(/\\/g, "/");
|
|
847
1127
|
nodes.push(item);
|
|
848
1128
|
}
|
|
849
1129
|
}
|
|
@@ -878,9 +1158,10 @@ function setMd(obj, last) {
|
|
|
878
1158
|
}
|
|
879
1159
|
|
|
880
1160
|
// src/commands/wirte-md.ts
|
|
881
|
-
var
|
|
882
|
-
var
|
|
883
|
-
|
|
1161
|
+
var import_debug3 = __toESM(require_src());
|
|
1162
|
+
var rootPath = process.cwd().replace(/\\/g, "/");
|
|
1163
|
+
var debug3 = (0, import_debug3.default)("wirte-md");
|
|
1164
|
+
debug3.enabled = false;
|
|
884
1165
|
function getCountMd(datas) {
|
|
885
1166
|
let rowTotleNumber = 0;
|
|
886
1167
|
let sizeTotleNumber = 0;
|
|
@@ -889,7 +1170,7 @@ function getCountMd(datas) {
|
|
|
889
1170
|
nodes.forEach((obj) => {
|
|
890
1171
|
if (obj.children)
|
|
891
1172
|
getDeatle(obj.children);
|
|
892
|
-
else {
|
|
1173
|
+
else if (obj.suffix && obj.rowSize && obj.size) {
|
|
893
1174
|
if (!coutObj.hasOwnProperty(obj.suffix))
|
|
894
1175
|
coutObj[obj.suffix] = 0;
|
|
895
1176
|
coutObj[obj.suffix]++;
|
|
@@ -927,16 +1208,16 @@ Total number of codes: ${format(sizeTotleNumber)}
|
|
|
927
1208
|
md = countMd + md;
|
|
928
1209
|
return md;
|
|
929
1210
|
}
|
|
930
|
-
function getMd(
|
|
931
|
-
|
|
1211
|
+
function getMd(option) {
|
|
1212
|
+
logger_default.success("*** run location: " + process.cwd() + "\n");
|
|
932
1213
|
const nodes = getFileNodes(rootPath, option);
|
|
933
1214
|
const countMdObj = getCountMd(nodes);
|
|
934
1215
|
const coutMd = setCountMd(countMdObj);
|
|
935
|
-
|
|
1216
|
+
logger_default.success(coutMd);
|
|
936
1217
|
const note = getNote(nodes);
|
|
937
1218
|
const md = note.join("") + "\n";
|
|
938
1219
|
if (md.length > 0) {
|
|
939
|
-
|
|
1220
|
+
logger_default.success("*** Automatic generation completed !");
|
|
940
1221
|
}
|
|
941
1222
|
return { md: md + coutMd, nodes };
|
|
942
1223
|
}
|