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