agmd 0.3.0-alpha0.2 → 0.3.3
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 +7 -1
- package/bin/bin.js +83 -80
- 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 +340 -70
- package/lib/index.cjs.js.map +3 -3
- package/lib/index.esm.js +341 -71
- 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.2
|
|
3
3
|
* author:kakajun <253495832@qq.com>
|
|
4
|
-
*
|
|
4
|
+
* Thu Apr 28 2022 22:42:06 GMT+0800 (中国标准时间)
|
|
5
5
|
*/
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -38,13 +38,13 @@ var require_ms = __commonJS({
|
|
|
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
|
};
|
|
@@ -144,17 +144,17 @@ var require_ms = __commonJS({
|
|
|
144
144
|
// node_modules/debug/src/common.js
|
|
145
145
|
var require_common = __commonJS({
|
|
146
146
|
"node_modules/debug/src/common.js"(exports, module) {
|
|
147
|
-
function setup(
|
|
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 =
|
|
153
|
+
createDebug.enabled = enabled2;
|
|
154
154
|
createDebug.humanize = require_ms();
|
|
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
|
}
|
|
@@ -489,20 +489,20 @@ var require_supports_color = __commonJS({
|
|
|
489
489
|
var os = __require("os");
|
|
490
490
|
var tty = __require("tty");
|
|
491
491
|
var hasFlag = require_has_flag();
|
|
492
|
-
var { env } = process;
|
|
492
|
+
var { env: env2 } = process;
|
|
493
493
|
var forceColor;
|
|
494
494
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
495
495
|
forceColor = 0;
|
|
496
496
|
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
497
497
|
forceColor = 1;
|
|
498
498
|
}
|
|
499
|
-
if ("FORCE_COLOR" in
|
|
500
|
-
if (
|
|
499
|
+
if ("FORCE_COLOR" in env2) {
|
|
500
|
+
if (env2.FORCE_COLOR === "true") {
|
|
501
501
|
forceColor = 1;
|
|
502
|
-
} else if (
|
|
502
|
+
} else if (env2.FORCE_COLOR === "false") {
|
|
503
503
|
forceColor = 0;
|
|
504
504
|
} else {
|
|
505
|
-
forceColor =
|
|
505
|
+
forceColor = env2.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env2.FORCE_COLOR, 10), 3);
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
function translateLevel(level) {
|
|
@@ -530,7 +530,7 @@ var require_supports_color = __commonJS({
|
|
|
530
530
|
return 0;
|
|
531
531
|
}
|
|
532
532
|
const min = forceColor || 0;
|
|
533
|
-
if (
|
|
533
|
+
if (env2.TERM === "dumb") {
|
|
534
534
|
return min;
|
|
535
535
|
}
|
|
536
536
|
if (process.platform === "win32") {
|
|
@@ -540,34 +540,34 @@ var require_supports_color = __commonJS({
|
|
|
540
540
|
}
|
|
541
541
|
return 1;
|
|
542
542
|
}
|
|
543
|
-
if ("CI" in
|
|
544
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in
|
|
543
|
+
if ("CI" in env2) {
|
|
544
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
|
|
545
545
|
return 1;
|
|
546
546
|
}
|
|
547
547
|
return min;
|
|
548
548
|
}
|
|
549
|
-
if ("TEAMCITY_VERSION" in
|
|
550
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(
|
|
549
|
+
if ("TEAMCITY_VERSION" in env2) {
|
|
550
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
|
|
551
551
|
}
|
|
552
|
-
if (
|
|
552
|
+
if (env2.COLORTERM === "truecolor") {
|
|
553
553
|
return 3;
|
|
554
554
|
}
|
|
555
|
-
if ("TERM_PROGRAM" in
|
|
556
|
-
const version = parseInt((
|
|
557
|
-
switch (
|
|
555
|
+
if ("TERM_PROGRAM" in env2) {
|
|
556
|
+
const version = parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
557
|
+
switch (env2.TERM_PROGRAM) {
|
|
558
558
|
case "iTerm.app":
|
|
559
559
|
return version >= 3 ? 3 : 2;
|
|
560
560
|
case "Apple_Terminal":
|
|
561
561
|
return 2;
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
if (/-256(color)?$/i.test(
|
|
564
|
+
if (/-256(color)?$/i.test(env2.TERM)) {
|
|
565
565
|
return 2;
|
|
566
566
|
}
|
|
567
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
567
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
|
|
568
568
|
return 1;
|
|
569
569
|
}
|
|
570
|
-
if ("COLORTERM" in
|
|
570
|
+
if ("COLORTERM" in env2) {
|
|
571
571
|
return 1;
|
|
572
572
|
}
|
|
573
573
|
return min;
|
|
@@ -735,11 +735,11 @@ var require_node = __commonJS({
|
|
|
735
735
|
function load() {
|
|
736
736
|
return process.env.DEBUG;
|
|
737
737
|
}
|
|
738
|
-
function init(
|
|
739
|
-
|
|
738
|
+
function init(debug4) {
|
|
739
|
+
debug4.inspectOpts = {};
|
|
740
740
|
const keys = Object.keys(exports.inspectOpts);
|
|
741
741
|
for (let i = 0; i < keys.length; i++) {
|
|
742
|
-
|
|
742
|
+
debug4.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
745
|
module.exports = require_common()(exports);
|
|
@@ -766,29 +766,296 @@ var require_src = __commonJS({
|
|
|
766
766
|
}
|
|
767
767
|
});
|
|
768
768
|
|
|
769
|
-
//
|
|
770
|
-
|
|
769
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/compare-aliases.js
|
|
770
|
+
var require_compare_aliases = __commonJS({
|
|
771
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/compare-aliases.js"(exports, module) {
|
|
772
|
+
module.exports = function compareAliases(env2, ...aliases) {
|
|
773
|
+
return aliases.some((alias) => alias.toLowerCase() === env2.toLowerCase());
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/modes.enum.js
|
|
779
|
+
var require_modes_enum = __commonJS({
|
|
780
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/modes.enum.js"(exports, module) {
|
|
781
|
+
var Development = {
|
|
782
|
+
dev: "dev",
|
|
783
|
+
development: "development"
|
|
784
|
+
};
|
|
785
|
+
var Production = {
|
|
786
|
+
prod: "prod",
|
|
787
|
+
production: "production"
|
|
788
|
+
};
|
|
789
|
+
module.exports = {
|
|
790
|
+
Production,
|
|
791
|
+
Development
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/inspector.js
|
|
797
|
+
var require_inspector = __commonJS({
|
|
798
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/inspector.js"(exports, module) {
|
|
799
|
+
var compare = require_compare_aliases();
|
|
800
|
+
var modes = require_modes_enum();
|
|
801
|
+
function inspector(...envs) {
|
|
802
|
+
const nodeEnv = process.env.NODE_ENV ?? "development";
|
|
803
|
+
if (envs.length === 0) {
|
|
804
|
+
return nodeEnv;
|
|
805
|
+
}
|
|
806
|
+
return envs.reduce((prev, env2) => {
|
|
807
|
+
if (isKnownMode(env2, nodeEnv)) {
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
return prev || compare(env2, nodeEnv);
|
|
811
|
+
}, false);
|
|
812
|
+
}
|
|
813
|
+
function isKnownMode(env2, nodeEnv) {
|
|
814
|
+
for (const mode of Object.values(modes)) {
|
|
815
|
+
if (compareKnownMode(env2, nodeEnv, Object.values(mode))) {
|
|
816
|
+
return true;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
function compareKnownMode(env2, nodeEnv, possibleValues) {
|
|
822
|
+
return compare(env2, ...possibleValues) && compare(nodeEnv, ...possibleValues);
|
|
823
|
+
}
|
|
824
|
+
module.exports = inspector;
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
// node_modules/_node-environment@0.5.1@node-environment/lib/index.js
|
|
829
|
+
var require_lib = __commonJS({
|
|
830
|
+
"node_modules/_node-environment@0.5.1@node-environment/lib/index.js"(exports, module) {
|
|
831
|
+
module.exports = {
|
|
832
|
+
env: require_inspector()
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
});
|
|
771
836
|
|
|
772
837
|
// src/commands/get-file.ts
|
|
773
|
-
var
|
|
838
|
+
var import_debug2 = __toESM(require_src());
|
|
839
|
+
import fs2 from "fs";
|
|
840
|
+
import path2 from "path";
|
|
841
|
+
|
|
842
|
+
// src/commands/change-path.ts
|
|
774
843
|
import fs from "fs";
|
|
775
844
|
import path from "path";
|
|
776
|
-
|
|
845
|
+
|
|
846
|
+
// node_modules/kolorist/dist/esm/index.mjs
|
|
847
|
+
var enabled = true;
|
|
848
|
+
var globalVar = typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
849
|
+
var supportLevel = 0;
|
|
850
|
+
if (globalVar.process && globalVar.process.env && globalVar.process.stdout) {
|
|
851
|
+
const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = globalVar.process.env;
|
|
852
|
+
if (NODE_DISABLE_COLORS || FORCE_COLOR === "0") {
|
|
853
|
+
enabled = false;
|
|
854
|
+
} else if (FORCE_COLOR === "1") {
|
|
855
|
+
enabled = true;
|
|
856
|
+
} else if (TERM === "dumb") {
|
|
857
|
+
enabled = false;
|
|
858
|
+
} else if ("CI" in globalVar.process.env && [
|
|
859
|
+
"TRAVIS",
|
|
860
|
+
"CIRCLECI",
|
|
861
|
+
"APPVEYOR",
|
|
862
|
+
"GITLAB_CI",
|
|
863
|
+
"GITHUB_ACTIONS",
|
|
864
|
+
"BUILDKITE",
|
|
865
|
+
"DRONE"
|
|
866
|
+
].some((vendor) => vendor in globalVar.process.env)) {
|
|
867
|
+
enabled = true;
|
|
868
|
+
} else {
|
|
869
|
+
enabled = process.stdout.isTTY;
|
|
870
|
+
}
|
|
871
|
+
if (enabled) {
|
|
872
|
+
supportLevel = TERM && TERM.endsWith("-256color") ? 2 : 1;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
var options = {
|
|
876
|
+
enabled,
|
|
877
|
+
supportLevel
|
|
878
|
+
};
|
|
879
|
+
function kolorist(start, end, level = 1) {
|
|
880
|
+
const open = `\x1B[${start}m`;
|
|
881
|
+
const close = `\x1B[${end}m`;
|
|
882
|
+
const regex = new RegExp(`\\x1b\\[${end}m`, "g");
|
|
883
|
+
return (str) => {
|
|
884
|
+
return options.enabled && options.supportLevel >= level ? open + ("" + str).replace(regex, open) + close : "" + str;
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
var reset = kolorist(0, 0);
|
|
888
|
+
var bold = kolorist(1, 22);
|
|
889
|
+
var dim = kolorist(2, 22);
|
|
890
|
+
var italic = kolorist(3, 23);
|
|
891
|
+
var underline = kolorist(4, 24);
|
|
892
|
+
var inverse = kolorist(7, 27);
|
|
893
|
+
var hidden = kolorist(8, 28);
|
|
894
|
+
var strikethrough = kolorist(9, 29);
|
|
895
|
+
var black = kolorist(30, 39);
|
|
896
|
+
var red = kolorist(31, 39);
|
|
897
|
+
var green = kolorist(32, 39);
|
|
898
|
+
var yellow = kolorist(33, 39);
|
|
899
|
+
var blue = kolorist(34, 39);
|
|
900
|
+
var magenta = kolorist(35, 39);
|
|
901
|
+
var cyan = kolorist(36, 39);
|
|
902
|
+
var white = kolorist(97, 39);
|
|
903
|
+
var gray = kolorist(90, 39);
|
|
904
|
+
var lightGray = kolorist(37, 39);
|
|
905
|
+
var lightRed = kolorist(91, 39);
|
|
906
|
+
var lightGreen = kolorist(92, 39);
|
|
907
|
+
var lightYellow = kolorist(93, 39);
|
|
908
|
+
var lightBlue = kolorist(94, 39);
|
|
909
|
+
var lightMagenta = kolorist(95, 39);
|
|
910
|
+
var lightCyan = kolorist(96, 39);
|
|
911
|
+
var bgBlack = kolorist(40, 49);
|
|
912
|
+
var bgRed = kolorist(41, 49);
|
|
913
|
+
var bgGreen = kolorist(42, 49);
|
|
914
|
+
var bgYellow = kolorist(43, 49);
|
|
915
|
+
var bgBlue = kolorist(44, 49);
|
|
916
|
+
var bgMagenta = kolorist(45, 49);
|
|
917
|
+
var bgCyan = kolorist(46, 49);
|
|
918
|
+
var bgWhite = kolorist(107, 49);
|
|
919
|
+
var bgGray = kolorist(100, 49);
|
|
920
|
+
var bgLightRed = kolorist(101, 49);
|
|
921
|
+
var bgLightGreen = kolorist(102, 49);
|
|
922
|
+
var bgLightYellow = kolorist(103, 49);
|
|
923
|
+
var bgLightBlue = kolorist(104, 49);
|
|
924
|
+
var bgLightMagenta = kolorist(105, 49);
|
|
925
|
+
var bgLightCyan = kolorist(106, 49);
|
|
926
|
+
var bgLightGray = kolorist(47, 49);
|
|
927
|
+
|
|
928
|
+
// src/shared/logger.ts
|
|
929
|
+
var logger = {
|
|
930
|
+
info(text) {
|
|
931
|
+
console.log(lightBlue(`\u2708 - ${text}`));
|
|
932
|
+
},
|
|
933
|
+
success(text) {
|
|
934
|
+
console.log(lightGreen(`\u2714 - ${text}`));
|
|
935
|
+
},
|
|
936
|
+
warn(text) {
|
|
937
|
+
console.log(lightYellow(`\u25B6 - ${text}`));
|
|
938
|
+
},
|
|
939
|
+
error(text) {
|
|
940
|
+
console.log(lightRed(`\u2716 - ${text}`));
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
var logger_default = logger;
|
|
944
|
+
|
|
945
|
+
// src/commands/change-path.ts
|
|
946
|
+
var import_debug = __toESM(require_src());
|
|
947
|
+
var debug = (0, import_debug.default)("change-path");
|
|
777
948
|
debug.enabled = false;
|
|
778
|
-
function
|
|
779
|
-
|
|
949
|
+
function getRelatPath(absoluteImport, fullPath) {
|
|
950
|
+
let relatPath = path.relative(path.dirname(fullPath), absoluteImport);
|
|
951
|
+
relatPath = relatPath.replace(/\\/g, "/");
|
|
952
|
+
if (relatPath.indexOf(".") !== 0) {
|
|
953
|
+
relatPath = "./" + relatPath;
|
|
954
|
+
}
|
|
955
|
+
return relatPath;
|
|
956
|
+
}
|
|
957
|
+
function makeSuffix(filePath, fullPath) {
|
|
958
|
+
let absoluteImport = "";
|
|
959
|
+
if (filePath.indexOf("@") > -1) {
|
|
960
|
+
debug("!!!!!!!!!filePath: ", filePath);
|
|
961
|
+
absoluteImport = filePath.replace("@", process.cwd());
|
|
962
|
+
} else {
|
|
963
|
+
absoluteImport = path.resolve(path.dirname(fullPath), filePath);
|
|
964
|
+
}
|
|
965
|
+
debug("makeSuffix \u5165\u53C2: absoluteImport", absoluteImport);
|
|
966
|
+
const lastName = path.extname(absoluteImport);
|
|
967
|
+
debug("lastName", lastName);
|
|
968
|
+
if (!lastName) {
|
|
969
|
+
debug("!!!!!!!!!!!\u7F3A\u540E\u7F00\u6587\u4EF6: ", absoluteImport);
|
|
970
|
+
const suffix = [".js", ".ts", ".vue", "/index.js", "/index.vue"];
|
|
971
|
+
for (let j = 0; j < suffix.length; j++) {
|
|
972
|
+
const fixStr = suffix[j];
|
|
973
|
+
if (fs.existsSync(absoluteImport + fixStr)) {
|
|
974
|
+
debug("\u8865\u5168\u7684\u6587\u4EF6: ", absoluteImport + fixStr);
|
|
975
|
+
absoluteImport = absoluteImport + fixStr;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return absoluteImport.replace(/\\/g, "/");
|
|
981
|
+
}
|
|
982
|
+
function getImportName(ele) {
|
|
983
|
+
let str = "";
|
|
984
|
+
const ignore = [
|
|
985
|
+
"xiwicloud",
|
|
986
|
+
"bpmn-js",
|
|
987
|
+
"element-ui",
|
|
988
|
+
"lodash",
|
|
989
|
+
"handsontable",
|
|
990
|
+
"nprogress",
|
|
991
|
+
"quill",
|
|
992
|
+
"qrcodejs2",
|
|
993
|
+
"echarts"
|
|
994
|
+
];
|
|
995
|
+
const flag = ignore.some((item) => ele.indexOf(item) > -1);
|
|
996
|
+
const reg = / from [\"|\'](.*)[\'|\"]/;
|
|
997
|
+
if (!flag && ele.indexOf("/") > -1 && ele.indexOf("//") !== 0) {
|
|
998
|
+
const impStr = ele.match(reg);
|
|
999
|
+
if (impStr && impStr[1])
|
|
1000
|
+
str = impStr[1];
|
|
1001
|
+
}
|
|
1002
|
+
return str;
|
|
1003
|
+
}
|
|
1004
|
+
function changeImport(ele, fullPath) {
|
|
1005
|
+
let obj = {
|
|
1006
|
+
impName: "",
|
|
1007
|
+
filePath: "",
|
|
1008
|
+
absoluteImport: ""
|
|
1009
|
+
};
|
|
1010
|
+
const impName = getImportName(ele);
|
|
1011
|
+
if (impName) {
|
|
1012
|
+
obj.filePath = impName;
|
|
1013
|
+
debug("!!!!!!!!!\u5339\u914Dimp: ", impName);
|
|
1014
|
+
obj.absoluteImport = makeSuffix(obj.filePath, fullPath);
|
|
1015
|
+
debug("\u8865\u8FC7\u540E", obj.absoluteImport);
|
|
1016
|
+
obj.impName = getRelatPath(obj.absoluteImport, fullPath);
|
|
1017
|
+
debug("\u76F8\u5BF9\u8DEF\u5F84: ", obj.impName);
|
|
1018
|
+
}
|
|
1019
|
+
return obj;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// src/commands/get-file.ts
|
|
1023
|
+
var import_node_environment = __toESM(require_lib());
|
|
1024
|
+
var debug2 = (0, import_debug2.default)("get-file");
|
|
1025
|
+
debug2.enabled = false;
|
|
1026
|
+
var isDev = (0, import_node_environment.env)() === "development";
|
|
1027
|
+
function getFile(fullPath) {
|
|
1028
|
+
const str = fs2.readFileSync(fullPath, "utf-8");
|
|
780
1029
|
const size = str.length;
|
|
781
1030
|
const sarr = str.split(/[\n]/g);
|
|
782
1031
|
const rowSize = sarr.length;
|
|
1032
|
+
const imports = getImport(sarr, fullPath);
|
|
783
1033
|
const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
|
|
784
1034
|
return {
|
|
785
1035
|
note: f,
|
|
786
1036
|
size,
|
|
787
|
-
rowSize
|
|
1037
|
+
rowSize,
|
|
1038
|
+
imports
|
|
788
1039
|
};
|
|
789
1040
|
}
|
|
790
|
-
function
|
|
1041
|
+
function getImport(sarr, fullPath) {
|
|
1042
|
+
const imports = [];
|
|
1043
|
+
sarr.forEach((ele) => {
|
|
1044
|
+
if (ele.indexOf("from") > -1) {
|
|
1045
|
+
const { absoluteImport } = changeImport(ele, fullPath);
|
|
1046
|
+
if (absoluteImport) {
|
|
1047
|
+
imports.push(absoluteImport);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
return imports;
|
|
1052
|
+
}
|
|
1053
|
+
function getFileNodes(dir = process.cwd(), option, nodes = [], level = 0) {
|
|
791
1054
|
let ignore = [
|
|
1055
|
+
"bin",
|
|
1056
|
+
"lib",
|
|
1057
|
+
"jest.config.js",
|
|
1058
|
+
"router",
|
|
792
1059
|
"img",
|
|
793
1060
|
"styles",
|
|
794
1061
|
"node_modules",
|
|
@@ -798,17 +1065,18 @@ function getFileNodes(dir = path.resolve("./"), option, nodes = [], level = 0) {
|
|
|
798
1065
|
"dist",
|
|
799
1066
|
".husky",
|
|
800
1067
|
".vscode",
|
|
1068
|
+
".eslintrc.js",
|
|
801
1069
|
"readme-file.js",
|
|
802
1070
|
"readme-md.js"
|
|
803
1071
|
];
|
|
804
|
-
let include = [".js", ".vue"];
|
|
1072
|
+
let include = isDev ? [".js", ".vue"] : [".js", ".vue", ".ts"];
|
|
805
1073
|
if (option) {
|
|
806
1074
|
ignore = option.ignore || ignore;
|
|
807
1075
|
include = option.include || include;
|
|
808
1076
|
}
|
|
809
|
-
const files =
|
|
810
|
-
|
|
811
|
-
const isDir =
|
|
1077
|
+
const files = fs2.readdirSync(dir).map((item) => {
|
|
1078
|
+
let fullPath = path2.join(dir, item);
|
|
1079
|
+
const isDir = fs2.lstatSync(fullPath).isDirectory();
|
|
812
1080
|
return {
|
|
813
1081
|
name: item,
|
|
814
1082
|
isDir,
|
|
@@ -830,10 +1098,11 @@ function getFileNodes(dir = path.resolve("./"), option, nodes = [], level = 0) {
|
|
|
830
1098
|
const item = files[index];
|
|
831
1099
|
const foldFlag = ignore.findIndex((obj) => obj === item.name);
|
|
832
1100
|
if (foldFlag === -1) {
|
|
833
|
-
const fullPath =
|
|
834
|
-
const isDir =
|
|
1101
|
+
const fullPath = path2.join(dir, item.name);
|
|
1102
|
+
const isDir = fs2.lstatSync(fullPath).isDirectory();
|
|
835
1103
|
if (isDir) {
|
|
836
1104
|
getFileNodes(fullPath, option, item.children = [], level + 1);
|
|
1105
|
+
item.fullPath = fullPath.replace(/\\/g, "/");
|
|
837
1106
|
nodes.push(item);
|
|
838
1107
|
} else {
|
|
839
1108
|
const i = fullPath.lastIndexOf(".");
|
|
@@ -842,7 +1111,7 @@ function getFileNodes(dir = path.resolve("./"), option, nodes = [], level = 0) {
|
|
|
842
1111
|
const obj = getFile(fullPath);
|
|
843
1112
|
Object.assign(item, obj);
|
|
844
1113
|
item.suffix = lastName;
|
|
845
|
-
item.fullPath = fullPath;
|
|
1114
|
+
item.fullPath = fullPath.replace(/\\/g, "/");
|
|
846
1115
|
nodes.push(item);
|
|
847
1116
|
}
|
|
848
1117
|
}
|
|
@@ -877,9 +1146,10 @@ function setMd(obj, last) {
|
|
|
877
1146
|
}
|
|
878
1147
|
|
|
879
1148
|
// src/commands/wirte-md.ts
|
|
880
|
-
var
|
|
881
|
-
var
|
|
882
|
-
|
|
1149
|
+
var import_debug3 = __toESM(require_src());
|
|
1150
|
+
var rootPath = process.cwd().replace(/\\/g, "/");
|
|
1151
|
+
var debug3 = (0, import_debug3.default)("wirte-md");
|
|
1152
|
+
debug3.enabled = false;
|
|
883
1153
|
function getCountMd(datas) {
|
|
884
1154
|
let rowTotleNumber = 0;
|
|
885
1155
|
let sizeTotleNumber = 0;
|
|
@@ -888,7 +1158,7 @@ function getCountMd(datas) {
|
|
|
888
1158
|
nodes.forEach((obj) => {
|
|
889
1159
|
if (obj.children)
|
|
890
1160
|
getDeatle(obj.children);
|
|
891
|
-
else {
|
|
1161
|
+
else if (obj.suffix && obj.rowSize && obj.size) {
|
|
892
1162
|
if (!coutObj.hasOwnProperty(obj.suffix))
|
|
893
1163
|
coutObj[obj.suffix] = 0;
|
|
894
1164
|
coutObj[obj.suffix]++;
|
|
@@ -926,16 +1196,16 @@ Total number of codes: ${format(sizeTotleNumber)}
|
|
|
926
1196
|
md = countMd + md;
|
|
927
1197
|
return md;
|
|
928
1198
|
}
|
|
929
|
-
function getMd(
|
|
930
|
-
|
|
1199
|
+
function getMd(option) {
|
|
1200
|
+
logger_default.success("*** run location: " + process.cwd() + "\n");
|
|
931
1201
|
const nodes = getFileNodes(rootPath, option);
|
|
932
1202
|
const countMdObj = getCountMd(nodes);
|
|
933
1203
|
const coutMd = setCountMd(countMdObj);
|
|
934
|
-
|
|
1204
|
+
logger_default.success(coutMd);
|
|
935
1205
|
const note = getNote(nodes);
|
|
936
1206
|
const md = note.join("") + "\n";
|
|
937
1207
|
if (md.length > 0) {
|
|
938
|
-
|
|
1208
|
+
logger_default.success("*** Automatic generation completed !");
|
|
939
1209
|
}
|
|
940
1210
|
return { md: md + coutMd, nodes };
|
|
941
1211
|
}
|