agmd 0.3.8 → 0.3.12
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/bin/bin.js +88 -85
- package/bin/bin.js.map +4 -4
- package/lib/commands/change-path.d.ts +12 -12
- package/lib/commands/get-file.d.ts +26 -26
- package/lib/commands/wirte-md.d.ts +9 -9
- package/lib/index.cjs.js +99 -106
- package/lib/index.cjs.js.map +4 -4
- package/lib/index.d.ts +3 -3
- package/lib/index.esm.js +100 -107
- package/lib/index.esm.js.map +4 -4
- package/lib/shared/logger.d.ts +7 -7
- package/package.json +23 -22
package/lib/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* agmd v0.3.
|
|
2
|
+
* agmd v0.3.11
|
|
3
3
|
* author:kakajun <253495832@qq.com>
|
|
4
|
-
* Tue
|
|
4
|
+
* Tue Nov 28 2023 22:44:13 GMT+0800 (中国标准时间)
|
|
5
5
|
*/
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -14,7 +14,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
14
14
|
}) : x)(function(x) {
|
|
15
15
|
if (typeof require !== "undefined")
|
|
16
16
|
return require.apply(this, arguments);
|
|
17
|
-
throw
|
|
17
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
18
18
|
});
|
|
19
19
|
var __commonJS = (cb, mod) => function __require2() {
|
|
20
20
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -28,13 +28,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
28
28
|
return to;
|
|
29
29
|
};
|
|
30
30
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
35
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
36
|
mod
|
|
33
37
|
));
|
|
34
38
|
|
|
35
|
-
// node_modules/
|
|
36
|
-
var
|
|
37
|
-
"node_modules/
|
|
39
|
+
// node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
|
|
40
|
+
var require_ms = __commonJS({
|
|
41
|
+
"node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module) {
|
|
38
42
|
var s = 1e3;
|
|
39
43
|
var m = s * 60;
|
|
40
44
|
var h = m * 60;
|
|
@@ -148,9 +152,9 @@ var require_ms_2_1 = __commonJS({
|
|
|
148
152
|
}
|
|
149
153
|
});
|
|
150
154
|
|
|
151
|
-
// node_modules/
|
|
155
|
+
// node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js
|
|
152
156
|
var require_common = __commonJS({
|
|
153
|
-
"node_modules/
|
|
157
|
+
"node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js"(exports, module) {
|
|
154
158
|
function setup(env2) {
|
|
155
159
|
createDebug.debug = createDebug;
|
|
156
160
|
createDebug.default = createDebug;
|
|
@@ -158,7 +162,7 @@ var require_common = __commonJS({
|
|
|
158
162
|
createDebug.disable = disable;
|
|
159
163
|
createDebug.enable = enable;
|
|
160
164
|
createDebug.enabled = enabled2;
|
|
161
|
-
createDebug.humanize =
|
|
165
|
+
createDebug.humanize = require_ms();
|
|
162
166
|
createDebug.destroy = destroy;
|
|
163
167
|
Object.keys(env2).forEach((key) => {
|
|
164
168
|
createDebug[key] = env2[key];
|
|
@@ -185,7 +189,7 @@ var require_common = __commonJS({
|
|
|
185
189
|
return;
|
|
186
190
|
}
|
|
187
191
|
const self2 = debug4;
|
|
188
|
-
const curr = Number(new Date());
|
|
192
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
189
193
|
const ms = curr - (prevTime || curr);
|
|
190
194
|
self2.diff = ms;
|
|
191
195
|
self2.prev = prevTime;
|
|
@@ -311,9 +315,9 @@ var require_common = __commonJS({
|
|
|
311
315
|
}
|
|
312
316
|
});
|
|
313
317
|
|
|
314
|
-
// node_modules/
|
|
318
|
+
// node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js
|
|
315
319
|
var require_browser = __commonJS({
|
|
316
|
-
"node_modules/
|
|
320
|
+
"node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js"(exports, module) {
|
|
317
321
|
exports.formatArgs = formatArgs;
|
|
318
322
|
exports.save = save;
|
|
319
323
|
exports.load = load;
|
|
@@ -413,7 +417,11 @@ var require_browser = __commonJS({
|
|
|
413
417
|
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
414
418
|
return false;
|
|
415
419
|
}
|
|
416
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
|
|
420
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
421
|
+
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
422
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
423
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
424
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
417
425
|
}
|
|
418
426
|
function formatArgs(args) {
|
|
419
427
|
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
@@ -476,43 +484,35 @@ var require_browser = __commonJS({
|
|
|
476
484
|
}
|
|
477
485
|
});
|
|
478
486
|
|
|
479
|
-
// node_modules/
|
|
480
|
-
var
|
|
481
|
-
"node_modules/
|
|
487
|
+
// node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js
|
|
488
|
+
var require_has_flag = __commonJS({
|
|
489
|
+
"node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js"(exports, module) {
|
|
482
490
|
"use strict";
|
|
483
|
-
module.exports = (flag, argv
|
|
491
|
+
module.exports = (flag, argv) => {
|
|
492
|
+
argv = argv || process.argv;
|
|
484
493
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
485
|
-
const
|
|
486
|
-
const
|
|
487
|
-
return
|
|
494
|
+
const pos = argv.indexOf(prefix + flag);
|
|
495
|
+
const terminatorPos = argv.indexOf("--");
|
|
496
|
+
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
|
488
497
|
};
|
|
489
498
|
}
|
|
490
499
|
});
|
|
491
500
|
|
|
492
|
-
// node_modules/
|
|
493
|
-
var
|
|
494
|
-
"node_modules/
|
|
501
|
+
// node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js
|
|
502
|
+
var require_supports_color = __commonJS({
|
|
503
|
+
"node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports, module) {
|
|
495
504
|
"use strict";
|
|
496
505
|
var os = __require("os");
|
|
497
|
-
var
|
|
498
|
-
var
|
|
499
|
-
var
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
flagForceColor = 0;
|
|
506
|
+
var hasFlag = require_has_flag();
|
|
507
|
+
var env2 = process.env;
|
|
508
|
+
var forceColor;
|
|
509
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
|
|
510
|
+
forceColor = false;
|
|
503
511
|
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
504
|
-
|
|
512
|
+
forceColor = true;
|
|
505
513
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (env2.FORCE_COLOR === "true") {
|
|
509
|
-
return 1;
|
|
510
|
-
}
|
|
511
|
-
if (env2.FORCE_COLOR === "false") {
|
|
512
|
-
return 0;
|
|
513
|
-
}
|
|
514
|
-
return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
|
|
515
|
-
}
|
|
514
|
+
if ("FORCE_COLOR" in env2) {
|
|
515
|
+
forceColor = env2.FORCE_COLOR.length === 0 || parseInt(env2.FORCE_COLOR, 10) !== 0;
|
|
516
516
|
}
|
|
517
517
|
function translateLevel(level) {
|
|
518
518
|
if (level === 0) {
|
|
@@ -525,39 +525,29 @@ var require_supports_color_8_1 = __commonJS({
|
|
|
525
525
|
has16m: level >= 3
|
|
526
526
|
};
|
|
527
527
|
}
|
|
528
|
-
function supportsColor(
|
|
529
|
-
|
|
530
|
-
if (noFlagForceColor !== void 0) {
|
|
531
|
-
flagForceColor = noFlagForceColor;
|
|
532
|
-
}
|
|
533
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
534
|
-
if (forceColor === 0) {
|
|
528
|
+
function supportsColor(stream) {
|
|
529
|
+
if (forceColor === false) {
|
|
535
530
|
return 0;
|
|
536
531
|
}
|
|
537
|
-
if (
|
|
538
|
-
|
|
539
|
-
return 3;
|
|
540
|
-
}
|
|
541
|
-
if (hasFlag("color=256")) {
|
|
542
|
-
return 2;
|
|
543
|
-
}
|
|
532
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
533
|
+
return 3;
|
|
544
534
|
}
|
|
545
|
-
if (
|
|
546
|
-
return
|
|
535
|
+
if (hasFlag("color=256")) {
|
|
536
|
+
return 2;
|
|
547
537
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
return min;
|
|
538
|
+
if (stream && !stream.isTTY && forceColor !== true) {
|
|
539
|
+
return 0;
|
|
551
540
|
}
|
|
541
|
+
const min = forceColor ? 1 : 0;
|
|
552
542
|
if (process.platform === "win32") {
|
|
553
543
|
const osRelease = os.release().split(".");
|
|
554
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
544
|
+
if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
555
545
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
556
546
|
}
|
|
557
547
|
return 1;
|
|
558
548
|
}
|
|
559
549
|
if ("CI" in env2) {
|
|
560
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"
|
|
550
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
|
|
561
551
|
return 1;
|
|
562
552
|
}
|
|
563
553
|
return min;
|
|
@@ -569,7 +559,7 @@ var require_supports_color_8_1 = __commonJS({
|
|
|
569
559
|
return 3;
|
|
570
560
|
}
|
|
571
561
|
if ("TERM_PROGRAM" in env2) {
|
|
572
|
-
const version =
|
|
562
|
+
const version = parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
573
563
|
switch (env2.TERM_PROGRAM) {
|
|
574
564
|
case "iTerm.app":
|
|
575
565
|
return version >= 3 ? 3 : 2;
|
|
@@ -586,26 +576,26 @@ var require_supports_color_8_1 = __commonJS({
|
|
|
586
576
|
if ("COLORTERM" in env2) {
|
|
587
577
|
return 1;
|
|
588
578
|
}
|
|
579
|
+
if (env2.TERM === "dumb") {
|
|
580
|
+
return min;
|
|
581
|
+
}
|
|
589
582
|
return min;
|
|
590
583
|
}
|
|
591
|
-
function getSupportLevel(stream
|
|
592
|
-
const level = supportsColor(stream
|
|
593
|
-
streamIsTTY: stream && stream.isTTY,
|
|
594
|
-
...options2
|
|
595
|
-
});
|
|
584
|
+
function getSupportLevel(stream) {
|
|
585
|
+
const level = supportsColor(stream);
|
|
596
586
|
return translateLevel(level);
|
|
597
587
|
}
|
|
598
588
|
module.exports = {
|
|
599
589
|
supportsColor: getSupportLevel,
|
|
600
|
-
stdout: getSupportLevel(
|
|
601
|
-
stderr: getSupportLevel(
|
|
590
|
+
stdout: getSupportLevel(process.stdout),
|
|
591
|
+
stderr: getSupportLevel(process.stderr)
|
|
602
592
|
};
|
|
603
593
|
}
|
|
604
594
|
});
|
|
605
595
|
|
|
606
|
-
// node_modules/
|
|
596
|
+
// node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js
|
|
607
597
|
var require_node = __commonJS({
|
|
608
|
-
"node_modules/
|
|
598
|
+
"node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js"(exports, module) {
|
|
609
599
|
var tty = __require("tty");
|
|
610
600
|
var util = __require("util");
|
|
611
601
|
exports.init = init;
|
|
@@ -621,7 +611,7 @@ var require_node = __commonJS({
|
|
|
621
611
|
);
|
|
622
612
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
623
613
|
try {
|
|
624
|
-
const supportsColor =
|
|
614
|
+
const supportsColor = require_supports_color();
|
|
625
615
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
626
616
|
exports.colors = [
|
|
627
617
|
20,
|
|
@@ -742,7 +732,7 @@ var require_node = __commonJS({
|
|
|
742
732
|
if (exports.inspectOpts.hideDate) {
|
|
743
733
|
return "";
|
|
744
734
|
}
|
|
745
|
-
return new Date().toISOString() + " ";
|
|
735
|
+
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
746
736
|
}
|
|
747
737
|
function log(...args) {
|
|
748
738
|
return process.stderr.write(util.format(...args) + "\n");
|
|
@@ -777,9 +767,9 @@ var require_node = __commonJS({
|
|
|
777
767
|
}
|
|
778
768
|
});
|
|
779
769
|
|
|
780
|
-
// node_modules/
|
|
770
|
+
// node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js
|
|
781
771
|
var require_src = __commonJS({
|
|
782
|
-
"node_modules/
|
|
772
|
+
"node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js"(exports, module) {
|
|
783
773
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
784
774
|
module.exports = require_browser();
|
|
785
775
|
} else {
|
|
@@ -788,18 +778,18 @@ var require_src = __commonJS({
|
|
|
788
778
|
}
|
|
789
779
|
});
|
|
790
780
|
|
|
791
|
-
// node_modules/
|
|
781
|
+
// node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/compare-aliases.js
|
|
792
782
|
var require_compare_aliases = __commonJS({
|
|
793
|
-
"node_modules/
|
|
783
|
+
"node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/compare-aliases.js"(exports, module) {
|
|
794
784
|
module.exports = function compareAliases(env2, ...aliases) {
|
|
795
785
|
return aliases.some((alias) => alias.toLowerCase() === env2.toLowerCase());
|
|
796
786
|
};
|
|
797
787
|
}
|
|
798
788
|
});
|
|
799
789
|
|
|
800
|
-
// node_modules/
|
|
790
|
+
// node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/modes.enum.js
|
|
801
791
|
var require_modes_enum = __commonJS({
|
|
802
|
-
"node_modules/
|
|
792
|
+
"node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/modes.enum.js"(exports, module) {
|
|
803
793
|
var Development = {
|
|
804
794
|
dev: "dev",
|
|
805
795
|
development: "development"
|
|
@@ -815,9 +805,9 @@ var require_modes_enum = __commonJS({
|
|
|
815
805
|
}
|
|
816
806
|
});
|
|
817
807
|
|
|
818
|
-
// node_modules/
|
|
808
|
+
// node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/inspector.js
|
|
819
809
|
var require_inspector = __commonJS({
|
|
820
|
-
"node_modules/
|
|
810
|
+
"node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/inspector.js"(exports, module) {
|
|
821
811
|
var compare = require_compare_aliases();
|
|
822
812
|
var modes = require_modes_enum();
|
|
823
813
|
function inspector(...envs) {
|
|
@@ -847,9 +837,9 @@ var require_inspector = __commonJS({
|
|
|
847
837
|
}
|
|
848
838
|
});
|
|
849
839
|
|
|
850
|
-
// node_modules/
|
|
840
|
+
// node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/index.js
|
|
851
841
|
var require_lib = __commonJS({
|
|
852
|
-
"node_modules/
|
|
842
|
+
"node_modules/.pnpm/node-environment@0.5.1/node_modules/node-environment/lib/index.js"(exports, module) {
|
|
853
843
|
module.exports = {
|
|
854
844
|
env: require_inspector()
|
|
855
845
|
};
|
|
@@ -865,7 +855,7 @@ import path2 from "path";
|
|
|
865
855
|
import fs from "fs";
|
|
866
856
|
import path from "path";
|
|
867
857
|
|
|
868
|
-
// node_modules/
|
|
858
|
+
// node_modules/.pnpm/kolorist@1.8.0/node_modules/kolorist/dist/esm/index.mjs
|
|
869
859
|
var enabled = true;
|
|
870
860
|
var globalVar = typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
871
861
|
var supportLevel = 0;
|
|
@@ -977,7 +967,8 @@ var logger_default = logger;
|
|
|
977
967
|
// src/commands/change-path.ts
|
|
978
968
|
var import_debug = __toESM(require_src());
|
|
979
969
|
var debug = (0, import_debug.default)("change-path");
|
|
980
|
-
debug.enabled =
|
|
970
|
+
debug.enabled = true;
|
|
971
|
+
var rootPath = process.cwd().replace(/\\/g, "/");
|
|
981
972
|
function getRelatPath(absoluteImport, fullPath) {
|
|
982
973
|
let relatPath = path.relative(path.dirname(fullPath), absoluteImport);
|
|
983
974
|
relatPath = relatPath.replace(/\\/g, "/");
|
|
@@ -999,7 +990,7 @@ function makeSuffix(filePath, fullPath) {
|
|
|
999
990
|
debug("lastName", lastName);
|
|
1000
991
|
if (!lastName) {
|
|
1001
992
|
debug("!!!!!!!!!!!\u7F3A\u540E\u7F00\u6587\u4EF6: ", absoluteImport);
|
|
1002
|
-
const suffix = [".js", ".ts", ".vue", "/index.js", "/index.vue"];
|
|
993
|
+
const suffix = [".js", ".ts", ".vue", ".tsx", "/index.js", "/index.vue"];
|
|
1003
994
|
for (let j = 0; j < suffix.length; j++) {
|
|
1004
995
|
const fixStr = suffix[j];
|
|
1005
996
|
if (fs.existsSync(absoluteImport + fixStr)) {
|
|
@@ -1011,20 +1002,9 @@ function makeSuffix(filePath, fullPath) {
|
|
|
1011
1002
|
}
|
|
1012
1003
|
return absoluteImport.replace(/\\/g, "/");
|
|
1013
1004
|
}
|
|
1014
|
-
function getImportName(ele) {
|
|
1005
|
+
function getImportName(ele, dependencies) {
|
|
1015
1006
|
let str = "";
|
|
1016
|
-
const
|
|
1017
|
-
"xiwicloud",
|
|
1018
|
-
"bpmn-js",
|
|
1019
|
-
"element-ui",
|
|
1020
|
-
"lodash",
|
|
1021
|
-
"handsontable",
|
|
1022
|
-
"nprogress",
|
|
1023
|
-
"quill",
|
|
1024
|
-
"qrcodejs2",
|
|
1025
|
-
"echarts"
|
|
1026
|
-
];
|
|
1027
|
-
const flag = ignore.some((item) => ele.indexOf(item) > -1);
|
|
1007
|
+
const flag = dependencies.some((item) => ele.indexOf(item) > -1);
|
|
1028
1008
|
const reg = / from [\"|\'](.*)[\'|\"]/;
|
|
1029
1009
|
if (!flag && ele.indexOf("/") > -1 && ele.indexOf("//") !== 0) {
|
|
1030
1010
|
const impStr = ele.match(reg);
|
|
@@ -1033,13 +1013,13 @@ function getImportName(ele) {
|
|
|
1033
1013
|
}
|
|
1034
1014
|
return str;
|
|
1035
1015
|
}
|
|
1036
|
-
function changeImport(ele, fullPath, nochangePath) {
|
|
1037
|
-
|
|
1016
|
+
function changeImport(ele, fullPath, dependencies, nochangePath) {
|
|
1017
|
+
const obj = {
|
|
1038
1018
|
impName: "",
|
|
1039
1019
|
filePath: "",
|
|
1040
1020
|
absoluteImport: ""
|
|
1041
1021
|
};
|
|
1042
|
-
const impName = getImportName(ele);
|
|
1022
|
+
const impName = getImportName(ele, dependencies);
|
|
1043
1023
|
if (impName) {
|
|
1044
1024
|
obj.filePath = impName;
|
|
1045
1025
|
debug("!!!!!!!!!\u5339\u914Dimp: ", impName);
|
|
@@ -1057,6 +1037,7 @@ function changeImport(ele, fullPath, nochangePath) {
|
|
|
1057
1037
|
var import_node_environment = __toESM(require_lib());
|
|
1058
1038
|
var debug2 = (0, import_debug2.default)("get-file");
|
|
1059
1039
|
debug2.enabled = false;
|
|
1040
|
+
var rootPath2 = process.cwd().replace(/\\/g, "/");
|
|
1060
1041
|
var isDev = (0, import_node_environment.env)() === "development";
|
|
1061
1042
|
function getFile(fullPath) {
|
|
1062
1043
|
const str = fs2.readFileSync(fullPath, "utf-8");
|
|
@@ -1067,16 +1048,26 @@ function getFile(fullPath) {
|
|
|
1067
1048
|
const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
|
|
1068
1049
|
return {
|
|
1069
1050
|
note: f.replace(/<\/?[^>]*>|(\n|\r)/g, ""),
|
|
1051
|
+
// 去掉尾巴换行符号
|
|
1070
1052
|
size,
|
|
1071
1053
|
rowSize,
|
|
1072
1054
|
imports
|
|
1073
1055
|
};
|
|
1074
1056
|
}
|
|
1075
1057
|
function getImport(sarr, fullPath) {
|
|
1058
|
+
const dependencies = [];
|
|
1059
|
+
if (fs2.existsSync(rootPath2 + "/package.json")) {
|
|
1060
|
+
const pkg = __require(rootPath2 + "/package.json");
|
|
1061
|
+
if (pkg.devDependencies) {
|
|
1062
|
+
dependencies.push(...Object.keys(pkg.devDependencies));
|
|
1063
|
+
} else if (pkg.dependencies) {
|
|
1064
|
+
dependencies.push(...Object.keys(pkg.dependencies));
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1076
1067
|
const imports = [];
|
|
1077
1068
|
sarr.forEach((ele) => {
|
|
1078
1069
|
if (ele.indexOf("from") > -1) {
|
|
1079
|
-
const { absoluteImport } = changeImport(ele, fullPath);
|
|
1070
|
+
const { absoluteImport } = changeImport(ele, fullPath, dependencies);
|
|
1080
1071
|
if (absoluteImport) {
|
|
1081
1072
|
imports.push(absoluteImport);
|
|
1082
1073
|
}
|
|
@@ -1086,6 +1077,8 @@ function getImport(sarr, fullPath) {
|
|
|
1086
1077
|
}
|
|
1087
1078
|
function getFileNodes(dir = process.cwd(), option, nodes = [], level = 0) {
|
|
1088
1079
|
let ignore = [
|
|
1080
|
+
// 'api',
|
|
1081
|
+
// 'src',
|
|
1089
1082
|
"bin",
|
|
1090
1083
|
"lib",
|
|
1091
1084
|
"jest.config.js",
|
|
@@ -1103,13 +1096,13 @@ function getFileNodes(dir = process.cwd(), option, nodes = [], level = 0) {
|
|
|
1103
1096
|
"readme-file.js",
|
|
1104
1097
|
"readme-md.js"
|
|
1105
1098
|
];
|
|
1106
|
-
let include = isDev ? [".js", ".vue"] : [".js", ".vue", ".ts"];
|
|
1099
|
+
let include = isDev ? [".js", ".vue"] : [".js", ".vue", ".ts", ".tsx"];
|
|
1107
1100
|
if (option) {
|
|
1108
1101
|
ignore = option.ignore || ignore;
|
|
1109
1102
|
include = option.include || include;
|
|
1110
1103
|
}
|
|
1111
1104
|
const files = fs2.readdirSync(dir).map((item) => {
|
|
1112
|
-
|
|
1105
|
+
const fullPath = path2.join(dir, item);
|
|
1113
1106
|
const isDir = fs2.lstatSync(fullPath).isDirectory();
|
|
1114
1107
|
return {
|
|
1115
1108
|
name: item,
|
|
@@ -1181,7 +1174,7 @@ function setMd(obj, last) {
|
|
|
1181
1174
|
|
|
1182
1175
|
// src/commands/wirte-md.ts
|
|
1183
1176
|
var import_debug3 = __toESM(require_src());
|
|
1184
|
-
var
|
|
1177
|
+
var rootPath3 = process.cwd().replace(/\\/g, "/");
|
|
1185
1178
|
var debug3 = (0, import_debug3.default)("wirte-md");
|
|
1186
1179
|
debug3.enabled = false;
|
|
1187
1180
|
function getCountMd(datas) {
|
|
@@ -1232,7 +1225,7 @@ function setCountMd(obj) {
|
|
|
1232
1225
|
}
|
|
1233
1226
|
function getMd(option) {
|
|
1234
1227
|
logger_default.success("\u{1F449} \u547D\u4EE4\u8FD0\u884C\u4F4D\u7F6E: " + process.cwd() + "\n");
|
|
1235
|
-
const nodes = getFileNodes(
|
|
1228
|
+
const nodes = getFileNodes(rootPath3, option);
|
|
1236
1229
|
const countMdObj = getCountMd(nodes);
|
|
1237
1230
|
const coutMd = setCountMd(countMdObj);
|
|
1238
1231
|
logger_default.success(coutMd);
|