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