agmd 0.2.0 → 0.2.10
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 +20 -11
- package/bin/agmd.js +11 -403
- package/bin/agmd.js.map +2 -2
- package/bin/readme-file.js +1 -0
- package/lib/index.cjs.js +80 -11
- package/lib/index.cjs.js.map +2 -2
- package/lib/index.d.ts +6 -1
- package/lib/index.esm.js +78 -10
- package/lib/index.esm.js.map +2 -2
- package/package.json +63 -61
package/README.md
CHANGED
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
简体中文 | [English](https://github.com/kakajun/auto-generate-md/blob/master/README.EN.md)
|
|
8
8
|
|
|
9
|
-
🚀
|
|
9
|
+
## 🚀 Features
|
|
10
|
+
|
|
10
11
|
🔥 Written in TypeScript
|
|
12
|
+
|
|
11
13
|
🔋 build with esbuild
|
|
14
|
+
|
|
12
15
|
💡 easy get foldName and fileName.
|
|
13
16
|
|
|
14
17
|
### 案例
|
|
@@ -63,21 +66,21 @@ note: 上面两个方法均可传一个option入参,其格式为:
|
|
|
63
66
|
5. 支持命令行参数配置, 可以自定义忽略文件和过滤后缀名文件
|
|
64
67
|
6. 命令行解析
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
控制台命令: agmd--include str--ignore str
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
--include string / -i string..........
|
|
70
|
-
--ignore string / -in string...........
|
|
71
|
+
可选项:
|
|
72
|
+
--include string / -i string.......... 包含解析的后缀
|
|
73
|
+
--ignore string / -in string........... 忽略文件名
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
例子:
|
|
73
76
|
--ignore / -i img,styles,node_modules,LICENSE,.git,.github,dist,.husky,.vscode,readme-file.js,readme-md.js
|
|
74
77
|
--include / -in .js,.vue,.ts
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
注意:
|
|
80
|
+
配置中的字符串之间不应有空格
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
命令行例子:
|
|
83
|
+
$ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`
|
|
81
84
|
|
|
82
85
|
### 相关文章
|
|
83
86
|
|
|
@@ -88,7 +91,13 @@ note: 上面两个方法均可传一个option入参,其格式为:
|
|
|
88
91
|
1. 采用esbuild 进行打包
|
|
89
92
|
2. 并且用eslint, preter规范写法, 规范
|
|
90
93
|
3. 用ts进行改写
|
|
91
|
-
4. 支持gitee一键同步
|
|
94
|
+
4. 支持gitee一键同步
|
|
92
95
|
|
|
93
96
|
0.2.0
|
|
94
97
|
支持命令行解析参数,可以动态传参
|
|
98
|
+
|
|
99
|
+
0.2.6
|
|
100
|
+
修复全局安装报错
|
|
101
|
+
|
|
102
|
+
0.2.9
|
|
103
|
+
新增文件统计功能
|
package/bin/agmd.js
CHANGED
|
@@ -1,284 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
13
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __reExport = (target, module3, copyDefault, desc) => {
|
|
17
|
-
if (module3 && typeof module3 === "object" || typeof module3 === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(module3))
|
|
19
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
20
|
-
__defProp(target, key, { get: () => module3[key], enumerable: !(desc = __getOwnPropDesc(module3, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return target;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (module3, isNodeMode) => {
|
|
25
|
-
return __reExport(__markAsModule(__defProp(module3 != null ? __create(__getProtoOf(module3)) : {}, "default", !isNodeMode && module3 && module3.__esModule ? { get: () => module3.default, enumerable: true } : { value: module3, enumerable: true })), module3);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// node_modules/arg/index.js
|
|
29
|
-
var require_arg = __commonJS({
|
|
30
|
-
"node_modules/arg/index.js"(exports, module3) {
|
|
31
|
-
var flagSymbol = Symbol("arg flag");
|
|
32
|
-
var ArgError = class extends Error {
|
|
33
|
-
constructor(msg, code) {
|
|
34
|
-
super(msg);
|
|
35
|
-
this.name = "ArgError";
|
|
36
|
-
this.code = code;
|
|
37
|
-
Object.setPrototypeOf(this, ArgError.prototype);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
function arg2(opts, {
|
|
41
|
-
argv = process.argv.slice(2),
|
|
42
|
-
permissive = false,
|
|
43
|
-
stopAtPositional = false
|
|
44
|
-
} = {}) {
|
|
45
|
-
if (!opts) {
|
|
46
|
-
throw new ArgError("argument specification object is required", "ARG_CONFIG_NO_SPEC");
|
|
47
|
-
}
|
|
48
|
-
const result = { _: [] };
|
|
49
|
-
const aliases = {};
|
|
50
|
-
const handlers = {};
|
|
51
|
-
for (const key of Object.keys(opts)) {
|
|
52
|
-
if (!key) {
|
|
53
|
-
throw new ArgError("argument key cannot be an empty string", "ARG_CONFIG_EMPTY_KEY");
|
|
54
|
-
}
|
|
55
|
-
if (key[0] !== "-") {
|
|
56
|
-
throw new ArgError(`argument key must start with '-' but found: '${key}'`, "ARG_CONFIG_NONOPT_KEY");
|
|
57
|
-
}
|
|
58
|
-
if (key.length === 1) {
|
|
59
|
-
throw new ArgError(`argument key must have a name; singular '-' keys are not allowed: ${key}`, "ARG_CONFIG_NONAME_KEY");
|
|
60
|
-
}
|
|
61
|
-
if (typeof opts[key] === "string") {
|
|
62
|
-
aliases[key] = opts[key];
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
let type = opts[key];
|
|
66
|
-
let isFlag = false;
|
|
67
|
-
if (Array.isArray(type) && type.length === 1 && typeof type[0] === "function") {
|
|
68
|
-
const [fn] = type;
|
|
69
|
-
type = (value, name2, prev = []) => {
|
|
70
|
-
prev.push(fn(value, name2, prev[prev.length - 1]));
|
|
71
|
-
return prev;
|
|
72
|
-
};
|
|
73
|
-
isFlag = fn === Boolean || fn[flagSymbol] === true;
|
|
74
|
-
} else if (typeof type === "function") {
|
|
75
|
-
isFlag = type === Boolean || type[flagSymbol] === true;
|
|
76
|
-
} else {
|
|
77
|
-
throw new ArgError(`type missing or not a function or valid array type: ${key}`, "ARG_CONFIG_VAD_TYPE");
|
|
78
|
-
}
|
|
79
|
-
if (key[1] !== "-" && key.length > 2) {
|
|
80
|
-
throw new ArgError(`short argument keys (with a single hyphen) must have only one character: ${key}`, "ARG_CONFIG_SHORTOPT_TOOLONG");
|
|
81
|
-
}
|
|
82
|
-
handlers[key] = [type, isFlag];
|
|
83
|
-
}
|
|
84
|
-
for (let i = 0, len = argv.length; i < len; i++) {
|
|
85
|
-
const wholeArg = argv[i];
|
|
86
|
-
if (stopAtPositional && result._.length > 0) {
|
|
87
|
-
result._ = result._.concat(argv.slice(i));
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (wholeArg === "--") {
|
|
91
|
-
result._ = result._.concat(argv.slice(i + 1));
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (wholeArg.length > 1 && wholeArg[0] === "-") {
|
|
95
|
-
const separatedArguments = wholeArg[1] === "-" || wholeArg.length === 2 ? [wholeArg] : wholeArg.slice(1).split("").map((a) => `-${a}`);
|
|
96
|
-
for (let j = 0; j < separatedArguments.length; j++) {
|
|
97
|
-
const arg3 = separatedArguments[j];
|
|
98
|
-
const [originalArgName, argStr] = arg3[1] === "-" ? arg3.split(/=(.*)/, 2) : [arg3, void 0];
|
|
99
|
-
let argName = originalArgName;
|
|
100
|
-
while (argName in aliases) {
|
|
101
|
-
argName = aliases[argName];
|
|
102
|
-
}
|
|
103
|
-
if (!(argName in handlers)) {
|
|
104
|
-
if (permissive) {
|
|
105
|
-
result._.push(arg3);
|
|
106
|
-
continue;
|
|
107
|
-
} else {
|
|
108
|
-
throw new ArgError(`unknown or unexpected option: ${originalArgName}`, "ARG_UNKNOWN_OPTION");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const [type, isFlag] = handlers[argName];
|
|
112
|
-
if (!isFlag && j + 1 < separatedArguments.length) {
|
|
113
|
-
throw new ArgError(`option requires argument (but was followed by another short argument): ${originalArgName}`, "ARG_MISSING_REQUIRED_SHORTARG");
|
|
114
|
-
}
|
|
115
|
-
if (isFlag) {
|
|
116
|
-
result[argName] = type(true, argName, result[argName]);
|
|
117
|
-
} else if (argStr === void 0) {
|
|
118
|
-
if (argv.length < i + 2 || argv[i + 1].length > 1 && argv[i + 1][0] === "-" && !(argv[i + 1].match(/^-?\d*(\.(?=\d))?\d*$/) && (type === Number || typeof BigInt !== "undefined" && type === BigInt))) {
|
|
119
|
-
const extended = originalArgName === argName ? "" : ` (alias for ${argName})`;
|
|
120
|
-
throw new ArgError(`option requires argument: ${originalArgName}${extended}`, "ARG_MISSING_REQUIRED_LONGARG");
|
|
121
|
-
}
|
|
122
|
-
result[argName] = type(argv[i + 1], argName, result[argName]);
|
|
123
|
-
++i;
|
|
124
|
-
} else {
|
|
125
|
-
result[argName] = type(argStr, argName, result[argName]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
result._.push(wholeArg);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
arg2.flag = (fn) => {
|
|
135
|
-
fn[flagSymbol] = true;
|
|
136
|
-
return fn;
|
|
137
|
-
};
|
|
138
|
-
arg2.COUNT = arg2.flag((v, name2, existingCount) => (existingCount || 0) + 1);
|
|
139
|
-
arg2.ArgError = ArgError;
|
|
140
|
-
module3.exports = arg2;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// src/agmd.ts
|
|
145
|
-
var import_path2 = __toESM(require("path"));
|
|
146
|
-
var import_fs2 = __toESM(require("fs"));
|
|
147
|
-
|
|
148
|
-
// src/index.ts
|
|
149
|
-
var import_fs = __toESM(require("fs"));
|
|
150
|
-
var import_path = __toESM(require("path"));
|
|
151
|
-
function getFile(file) {
|
|
152
|
-
const str = import_fs.default.readFileSync(file, "utf-8");
|
|
153
|
-
const sarr = str.split(/[\n,]/g);
|
|
154
|
-
const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
|
|
155
|
-
return f;
|
|
156
|
-
}
|
|
157
|
-
function getFileNodes(option, nodes = [], dir = import_path.default.resolve("./"), level = 0) {
|
|
158
|
-
let ignore2 = [
|
|
159
|
-
"img",
|
|
160
|
-
"styles",
|
|
161
|
-
"node_modules",
|
|
162
|
-
"LICENSE",
|
|
163
|
-
".git",
|
|
164
|
-
".github",
|
|
165
|
-
"dist",
|
|
166
|
-
".husky",
|
|
167
|
-
".vscode",
|
|
168
|
-
"readme-file.js",
|
|
169
|
-
"readme-md.js"
|
|
170
|
-
];
|
|
171
|
-
let include2 = [".js", ".vue", ".ts"];
|
|
172
|
-
if (option) {
|
|
173
|
-
ignore2 = option.ignore || ignore2;
|
|
174
|
-
include2 = option.include || include2;
|
|
175
|
-
}
|
|
176
|
-
const files2 = import_fs.default.readdirSync(dir).map((item) => {
|
|
177
|
-
const fullPath = import_path.default.join(dir, item);
|
|
178
|
-
const isDir = import_fs.default.lstatSync(fullPath).isDirectory();
|
|
179
|
-
return {
|
|
180
|
-
name: item,
|
|
181
|
-
isDir,
|
|
182
|
-
level,
|
|
183
|
-
note: ""
|
|
184
|
-
};
|
|
185
|
-
}).sort((a, b) => {
|
|
186
|
-
if (!a.isDir && b.isDir)
|
|
187
|
-
return 1;
|
|
188
|
-
if (a.isDir && !b.isDir)
|
|
189
|
-
return -1;
|
|
190
|
-
if (a.isDir && b.isDir || !a.isDir && !b.isDir)
|
|
191
|
-
return 0;
|
|
192
|
-
return 0;
|
|
193
|
-
});
|
|
194
|
-
for (let index = 0; index < files2.length; index += 1) {
|
|
195
|
-
const item = files2[index];
|
|
196
|
-
let note = "";
|
|
197
|
-
const foldFlag = ignore2.findIndex((obj) => obj === item.name);
|
|
198
|
-
if (foldFlag === -1) {
|
|
199
|
-
const fullPath = import_path.default.join(dir, item.name);
|
|
200
|
-
const isDir = import_fs.default.lstatSync(fullPath).isDirectory();
|
|
201
|
-
if (isDir) {
|
|
202
|
-
getFileNodes(option, item.children = [], fullPath, level + 1);
|
|
203
|
-
nodes.push(item);
|
|
204
|
-
} else {
|
|
205
|
-
const i = fullPath.lastIndexOf(".");
|
|
206
|
-
const lastName = fullPath.substring(i);
|
|
207
|
-
if (include2.includes(lastName)) {
|
|
208
|
-
note = getFile(fullPath);
|
|
209
|
-
item.note = note;
|
|
210
|
-
nodes.push(item);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return nodes;
|
|
216
|
-
}
|
|
217
|
-
function getNote(datas, keys) {
|
|
218
|
-
const nodes = keys || [];
|
|
219
|
-
datas.forEach((obj, index) => {
|
|
220
|
-
const last = index === datas.length - 1;
|
|
221
|
-
if (obj.children) {
|
|
222
|
-
const md = setMd(obj, last);
|
|
223
|
-
nodes.push(md);
|
|
224
|
-
getNote(obj.children, nodes);
|
|
225
|
-
} else {
|
|
226
|
-
const md = setMd(obj, last);
|
|
227
|
-
nodes.push(md);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
return nodes;
|
|
231
|
-
}
|
|
232
|
-
function setMd(obj, last) {
|
|
233
|
-
let filesString = "";
|
|
234
|
-
const blank = "\u2502 ".repeat(obj.level);
|
|
235
|
-
const pre = `${blank}${last ? "\u2514\u2500\u2500" : "\u251C\u2500\u2500"} ${obj.name}`;
|
|
236
|
-
if (obj.isDir) {
|
|
237
|
-
filesString += `${pre}
|
|
238
|
-
`;
|
|
239
|
-
} else {
|
|
240
|
-
filesString += `${pre} ${obj.note}
|
|
241
|
-
`;
|
|
242
|
-
}
|
|
243
|
-
return filesString;
|
|
244
|
-
}
|
|
245
|
-
function getMd(option) {
|
|
246
|
-
console.log("\x1B[36m%s\x1B[0m", "*** run location: ", import_path.default.resolve("./"));
|
|
247
|
-
const nodes = getFileNodes(option);
|
|
248
|
-
const note = getNote(nodes);
|
|
249
|
-
const md = note.join("");
|
|
250
|
-
if (md.length > 0) {
|
|
251
|
-
console.log("\x1B[36m%s\x1B[0m", "*** Automatic generation completed ! ");
|
|
252
|
-
}
|
|
253
|
-
return md;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// script/cli/index.ts
|
|
257
|
-
var import_arg = __toESM(require_arg());
|
|
258
|
-
var stringToArgs = (rawArgs) => {
|
|
259
|
-
const args = (0, import_arg.default)({
|
|
260
|
-
"--ignore": String,
|
|
261
|
-
"--include": String,
|
|
262
|
-
"--version": Boolean,
|
|
263
|
-
"--help": Boolean,
|
|
264
|
-
"-h": "--help",
|
|
265
|
-
"-i": "--ignore",
|
|
266
|
-
"-in": "--include",
|
|
267
|
-
"-v": "--version"
|
|
268
|
-
}, {
|
|
269
|
-
argv: rawArgs.slice(2)
|
|
270
|
-
});
|
|
271
|
-
return {
|
|
272
|
-
help: args["--help"],
|
|
273
|
-
ignore: args["--ignore"],
|
|
274
|
-
include: args["--include"],
|
|
275
|
-
version: args["--version"]
|
|
276
|
-
};
|
|
277
|
-
};
|
|
278
|
-
var cli_default = stringToArgs;
|
|
279
|
-
|
|
280
|
-
// script/help/index.ts
|
|
281
|
-
var st = `Usage: agmd--include str--ignore str
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var z=Object.create;var O=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var L=e=>O(e,"__esModule",{value:!0});var H=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Q=(e,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of U(n))!K.call(e,i)&&(s||i!=="default")&&O(e,i,{get:()=>n[i],enumerable:!(r=q(n,i))||r.enumerable});return e},T=(e,n)=>Q(L(O(e!=null?z(Y(e)):{},"default",!n&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var E=H((ke,G)=>{var N=Symbol("arg flag"),m=class extends Error{constructor(n,s){super(n);this.name="ArgError",this.code=s,Object.setPrototypeOf(this,m.prototype)}};function w(e,{argv:n=process.argv.slice(2),permissive:s=!1,stopAtPositional:r=!1}={}){if(!e)throw new m("argument specification object is required","ARG_CONFIG_NO_SPEC");let i={_:[]},u={},l={};for(let t of Object.keys(e)){if(!t)throw new m("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(t[0]!=="-")throw new m(`argument key must start with '-' but found: '${t}'`,"ARG_CONFIG_NONOPT_KEY");if(t.length===1)throw new m(`argument key must have a name; singular '-' keys are not allowed: ${t}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[t]=="string"){u[t]=e[t];continue}let o=e[t],a=!1;if(Array.isArray(o)&&o.length===1&&typeof o[0]=="function"){let[g]=o;o=(p,h,f=[])=>(f.push(g(p,h,f[f.length-1])),f),a=g===Boolean||g[N]===!0}else if(typeof o=="function")a=o===Boolean||o[N]===!0;else throw new m(`type missing or not a function or valid array type: ${t}`,"ARG_CONFIG_VAD_TYPE");if(t[1]!=="-"&&t.length>2)throw new m(`short argument keys (with a single hyphen) must have only one character: ${t}`,"ARG_CONFIG_SHORTOPT_TOOLONG");l[t]=[o,a]}for(let t=0,o=n.length;t<o;t++){let a=n[t];if(r&&i._.length>0){i._=i._.concat(n.slice(t));break}if(a==="--"){i._=i._.concat(n.slice(t+1));break}if(a.length>1&&a[0]==="-"){let g=a[1]==="-"||a.length===2?[a]:a.slice(1).split("").map(p=>`-${p}`);for(let p=0;p<g.length;p++){let h=g[p],[f,_]=h[1]==="-"?h.split(/=(.*)/,2):[h,void 0],d=f;for(;d in u;)d=u[d];if(!(d in l))if(s){i._.push(h);continue}else throw new m(`unknown or unexpected option: ${f}`,"ARG_UNKNOWN_OPTION");let[x,I]=l[d];if(!I&&p+1<g.length)throw new m(`option requires argument (but was followed by another short argument): ${f}`,"ARG_MISSING_REQUIRED_SHORTARG");if(I)i[d]=x(!0,d,i[d]);else if(_===void 0){if(n.length<t+2||n[t+1].length>1&&n[t+1][0]==="-"&&!(n[t+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(x===Number||typeof BigInt!="undefined"&&x===BigInt))){let P=f===d?"":` (alias for ${d})`;throw new m(`option requires argument: ${f}${P}`,"ARG_MISSING_REQUIRED_LONGARG")}i[d]=x(n[t+1],d,i[d]),++t}else i[d]=x(_,d,i[d])}}else i._.push(a)}return i}w.flag=e=>(e[N]=!0,e);w.COUNT=w.flag((e,n,s)=>(s||0)+1);w.ArgError=m;G.exports=w});var k=T(require("path"));var y=T(require("fs")),b=T(require("path"));function W(e){let n=y.default.readFileSync(e,"utf-8"),s=n.length,r=n.split(/[\n,]/g),i=r.length;return{note:r[0].indexOf("eslint")===-1&&(r[0].indexOf("-->")>-1||r[0].indexOf("*/")>-1||r[0].indexOf("//")>-1)?r[0]:"",size:s,rowSize:i}}function A(e,n=[],s=b.default.resolve("./"),r=0){let i=["public","build","img","assets","mock","api","styles","node_modules","LICENSE",".git",".github","dist",".husky",".vscode","babel.config.js","prettier.config.js","commitlint.config.js","readme-file.js","vue.config.js",".eslintrc.js","readme-md.js"],u=[".js",".vue",".ts"];e&&(i=e.ignore||i,u=e.include||u);let l=y.default.readdirSync(s).map(t=>{let o=b.default.join(s,t),a=y.default.lstatSync(o).isDirectory();return{name:t,isDir:a,level:r,note:""}}).sort((t,o)=>!t.isDir&&o.isDir?1:t.isDir&&!o.isDir?-1:(t.isDir&&o.isDir||!t.isDir&&!o.isDir,0));for(let t=0;t<l.length;t+=1){let o=l[t];if(i.findIndex(g=>g===o.name)===-1){let g=b.default.join(s,o.name);if(y.default.lstatSync(g).isDirectory())A(e,o.children=[],g,r+1),n.push(o);else{let h=g.lastIndexOf("."),f=g.substring(h);if(u.includes(f)){let _=W(g);Object.assign(o,_),o.suffix=f,n.push(o)}}}}return n}function $(e,n){let s=n||[];return e.forEach((r,i)=>{let u=i===e.length-1;if(r.children){let l=v(r,u);s.push(l),$(r.children,s)}else{let l=v(r,u);s.push(l)}}),s}function v(e,n){let s="",i=`${"\u2502 ".repeat(e.level)}${n?"\u2514\u2500\u2500":"\u251C\u2500\u2500"} ${e.name}`;return e.isDir?s+=`${i}
|
|
3
|
+
`:s+=`${i} ${e.note}
|
|
4
|
+
`,s}function j(e){var n=/\d{1,3}(?=(\d{3})+$)/g;return(e+"").replace(n,"$&,")}function V(e){let{rowTotleNumber:n,sizeTotleNumber:s,coutObj:r}=e,i="",u=0;for(let t in r){let o=r[t];u+=o,i+=`The suffix is ${t} has ${o} files
|
|
5
|
+
`}i+=`The totle has ${u} files
|
|
6
|
+
`;let l=`Total number of file lines: ${j(n)},
|
|
7
|
+
Total number of codes: ${j(s)}
|
|
8
|
+
`;return l=i+l,l}function J(e){let n=0,s=0,r={};function i(u){u.forEach(l=>{l.children?i(l.children):(r.hasOwnProperty(l.suffix)||(r[l.suffix]=0),r[l.suffix]++,n+=l.rowSize,s+=l.size)})}return i(e),{rowTotleNumber:n,sizeTotleNumber:s,coutObj:r}}function S(e){console.log("\x1B[36m%s\x1B[0m","*** run location: ",b.default.resolve("./")+`
|
|
9
|
+
`);let n=A(e),s=J(n),r=V(s);console.log("\x1B[33m%s\x1B[0m",r);let u=$(n).join("")+`
|
|
10
|
+
`;return u.length>0&&console.log("\x1B[36m%s\x1B[0m","*** Automatic generation completed ! "),u+r}function D(e,n){let s=b.default.resolve(__dirname,n);y.default.writeFile(s,e,{encoding:"utf8"},()=>{console.log("Write successful")})}var B=T(E()),X=e=>{let n=(0,B.default)({"--ignore":String,"--include":String,"--version":Boolean,"--help":Boolean,"-h":"--help","-i":"--ignore","-in":"--include","-v":"--version"},{argv:e.slice(2)});return{help:n["--help"],ignore:n["--ignore"],include:n["--include"],version:n["--version"]}},R=X;var Z=`Usage: agmd--include str--ignore str
|
|
282
11
|
|
|
283
12
|
Options:
|
|
284
13
|
--include string / -i string.......... include file extension
|
|
@@ -292,126 +21,5 @@ var st = `Usage: agmd--include str--ignore str
|
|
|
292
21
|
There should be no space between strings in a configuration
|
|
293
22
|
|
|
294
23
|
Examples:
|
|
295
|
-
$ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`;
|
|
296
|
-
function help() {
|
|
297
|
-
console.log(st);
|
|
298
|
-
process.exit(0);
|
|
299
|
-
}
|
|
300
|
-
var help_default = help;
|
|
301
|
-
|
|
302
|
-
// package.json
|
|
303
|
-
var name = "agmd";
|
|
304
|
-
var version = "0.2.0";
|
|
305
|
-
var description = "auto generate markdown for node";
|
|
306
|
-
var keywords = [
|
|
307
|
-
"node",
|
|
308
|
-
"auto",
|
|
309
|
-
"generate",
|
|
310
|
-
"md",
|
|
311
|
-
"markdown"
|
|
312
|
-
];
|
|
313
|
-
var main = "lib/index.cjs.js";
|
|
314
|
-
var module2 = "lib/index.esm.js";
|
|
315
|
-
var typings = "lib/index.d.ts";
|
|
316
|
-
var bin = {
|
|
317
|
-
agmd: "./bin/agmd.js"
|
|
318
|
-
};
|
|
319
|
-
var scripts = {
|
|
320
|
-
dev: "npx nodemon src/agmd.ts",
|
|
321
|
-
agmd: "npx agmd --ignore lib,node_modules,dist --include .js,.ts,.vue",
|
|
322
|
-
lint: 'eslint "src/**/*.{ts}" --max-warnings=0',
|
|
323
|
-
build: "node script/build.js",
|
|
324
|
-
prepare: "husky install",
|
|
325
|
-
"lint-fix": "eslint --fix --ext .js,.ts",
|
|
326
|
-
test: "npm run build && node bin/agmd"
|
|
327
|
-
};
|
|
328
|
-
var author = "kakajun <253495832@qq.com>";
|
|
329
|
-
var repository = {
|
|
330
|
-
type: "git",
|
|
331
|
-
url: "git@github.com:kakajun/auto-generate-md.git"
|
|
332
|
-
};
|
|
333
|
-
var devDependencies = {
|
|
334
|
-
"@types/node": "^17.0.0",
|
|
335
|
-
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
|
336
|
-
"@typescript-eslint/parser": "^4.31.0",
|
|
337
|
-
esbuild: "^0.14.5",
|
|
338
|
-
"esbuild-plugin-d.ts": "^1.1.0",
|
|
339
|
-
eslint: "^8.8.0",
|
|
340
|
-
"eslint-config-prettier": "^8.3.0",
|
|
341
|
-
"fs-extra": "^10.0.0",
|
|
342
|
-
husky: "^7.0.2",
|
|
343
|
-
"lint-staged": "^11.1.2",
|
|
344
|
-
nodemon: "^2.0.15",
|
|
345
|
-
prettier: "^2.5.1",
|
|
346
|
-
arg: "5.0.1",
|
|
347
|
-
typescript: "^4.5.5"
|
|
348
|
-
};
|
|
349
|
-
var lint_staged = {
|
|
350
|
-
"*.{ts,tsx,js}": "prettier --write",
|
|
351
|
-
"*.{ts,tsx}": "eslint --fix"
|
|
352
|
-
};
|
|
353
|
-
var license = "MIT";
|
|
354
|
-
var bugs = {
|
|
355
|
-
url: "https://github.com/kakajun/auto-generate-md/issues"
|
|
356
|
-
};
|
|
357
|
-
var homepage = "https://github.com/kakajun/auto-generate-md";
|
|
358
|
-
var files = [
|
|
359
|
-
"bin",
|
|
360
|
-
"lib"
|
|
361
|
-
];
|
|
362
|
-
var package_default = {
|
|
363
|
-
name,
|
|
364
|
-
version,
|
|
365
|
-
description,
|
|
366
|
-
keywords,
|
|
367
|
-
main,
|
|
368
|
-
module: module2,
|
|
369
|
-
typings,
|
|
370
|
-
bin,
|
|
371
|
-
scripts,
|
|
372
|
-
author,
|
|
373
|
-
repository,
|
|
374
|
-
devDependencies,
|
|
375
|
-
"lint-staged": lint_staged,
|
|
376
|
-
license,
|
|
377
|
-
bugs,
|
|
378
|
-
homepage,
|
|
379
|
-
files
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
// script/cli/handle.ts
|
|
383
|
-
function handle(settings) {
|
|
384
|
-
if (settings.help) {
|
|
385
|
-
help_default();
|
|
386
|
-
}
|
|
387
|
-
if (settings.version) {
|
|
388
|
-
console.log(`agmd version is: \x1B[36m%s\x1B[0m`, package_default.version);
|
|
389
|
-
process.exit(0);
|
|
390
|
-
}
|
|
391
|
-
if (settings.ignore) {
|
|
392
|
-
settings.ignores = settings.ignore.split(" ");
|
|
393
|
-
}
|
|
394
|
-
if (settings.include) {
|
|
395
|
-
settings.includes = settings.include.split(" ");
|
|
396
|
-
}
|
|
397
|
-
return settings;
|
|
398
|
-
}
|
|
399
|
-
var handle_default = handle;
|
|
400
|
-
|
|
401
|
-
// src/agmd.ts
|
|
402
|
-
var options = cli_default(process.argv);
|
|
403
|
-
var { ignores: ignore, includes: include } = handle_default(options);
|
|
404
|
-
var __dirname = import_path2.default.resolve();
|
|
405
|
-
function wirteMd(data, filePath) {
|
|
406
|
-
const file = import_path2.default.resolve(__dirname, filePath);
|
|
407
|
-
import_fs2.default.writeFile(file, data, { encoding: "utf8" }, (err) => {
|
|
408
|
-
console.error(err);
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
function agmd() {
|
|
412
|
-
const md = getMd({ ignore, include });
|
|
413
|
-
console.log("\x1B[36m%s\x1B[0m", "*** location: ", `${import_path2.default.resolve("./")}\\readme-md.md`);
|
|
414
|
-
wirteMd(md, `${import_path2.default.resolve("./")}\\readme-md.md`);
|
|
415
|
-
}
|
|
416
|
-
agmd();
|
|
24
|
+
$ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`;function ee(){console.log(Z),process.exit(0)}var F=ee;var ne="agmd",te="0.2.9",ie="auto generate markdown for node",se=["node","auto","generate","md","markdown"],re="lib/index.cjs.js",oe="lib/index.esm.js",le="lib/index.d.ts",ue={agmd:"./bin/agmd.js"},ce={dev:"npx nodemon src/agmd.ts",agmd:"npx agmd --ignore lib,node_modules,dist --include .js,.ts,.vue",lint:'eslint "src/**/*.{ts}" --max-warnings=0',build:"node script/build.js",prepare:"husky install","lint-fix":"eslint --fix --ext .js,.ts",test:"npm run build && node bin/agmd"},de="kakajun <253495832@qq.com>",ae={type:"git",url:"git@github.com:kakajun/auto-generate-md.git"},ge={"@types/node":"^17.0.0","@typescript-eslint/eslint-plugin":"^4.31.0","@typescript-eslint/parser":"^4.31.0",agmd:"^0.2.2",arg:"5.0.1",esbuild:"^0.14.5","esbuild-plugin-d.ts":"^1.1.0",eslint:"^8.8.0","eslint-config-prettier":"^8.3.0","fs-extra":"^10.0.0",husky:"^7.0.2","lint-staged":"^11.1.2",nodemon:"^2.0.15",prettier:"^2.5.1","ts-node":"^10.7.0",typescript:"^4.5.5"},fe={"*.{ts,tsx,js}":"prettier --write","*.{ts,tsx}":"eslint --fix"},me="MIT",pe={url:"https://github.com/kakajun/auto-generate-md/issues"},he="https://github.com/kakajun/auto-generate-md",ye=["bin","lib"],M={name:ne,version:te,description:ie,keywords:se,main:re,module:oe,typings:le,bin:ue,scripts:ce,author:de,repository:ae,devDependencies:ge,"lint-staged":fe,license:me,bugs:pe,homepage:he,files:ye};function be(e){return e.help&&F(),e.version&&(console.log("agmd version is: \x1B[36m%s\x1B[0m",M.version),process.exit(0)),e.ignore&&(e.ignores=e.ignore.split(" ")),e.include&&(e.includes=e.include.split(" ")),e}var C=be;var xe=R(process.argv),{ignores:we,includes:_e}=C(xe);function Te(){let e=S({ignore:we,include:_e});console.log("\x1B[36m%s\x1B[0m","*** location: ",`${k.default.resolve("./")}\\readme-md.md`),D(e,`${k.default.resolve("./")}\\readme-md.md`)}Te();
|
|
417
25
|
//# sourceMappingURL=agmd.js.map
|
package/bin/agmd.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../node_modules/arg/index.js", "../src/agmd.ts", "../src/index.ts", "../script/cli/index.ts", "../script/help/index.ts", "../script/cli/handle.ts"],
|
|
4
|
-
"sourcesContent": ["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n", "import path from 'path'\r\nimport fs from 'fs'\r\nimport { getMd } from './index'\r\nimport stringToArgs from '../script/cli'\r\nimport handle from '../script/cli/handle'\r\n// console.log(process.argv)\r\nconst options = stringToArgs(process.argv)\r\nconst { ignores: ignore, includes: include } = handle(options)\r\nvar __dirname = path.resolve()\r\n\r\n/**\r\n * @description:Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\nfunction wirteMd(data: string, filePath: string) {\r\n const file = path.resolve(__dirname, filePath)\r\n // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n fs.writeFile(file, data, { encoding: 'utf8' }, (err) => {\r\n console.error(err)\r\n })\r\n}\r\n\r\n/**\r\n * @description:Automatic generation of the whole process \u81EA\u52A8\u751F\u6210\u5168\u6D41\u7A0B\r\n * @param {*}\r\n * @return {*}\r\n */\r\nfunction agmd() {\r\n const md = getMd({ ignore, include })\r\n // \u5F97\u5230md\u6587\u6863\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** location: ', `${path.resolve('./')}\\\\readme-md.md`)\r\n wirteMd(md, `${path.resolve('./')}\\\\readme-md.md`)\r\n}\r\nagmd()\r\n", "import fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @description:Gets the header comment of the file \u83B7\u53D6\u6587\u4EF6\u7684\u5934\u90E8\u6CE8\u91CA\r\n * @param {*} file\r\n * @return {*}\r\n */\r\nfunction getFile(file: fs.PathOrFileDescriptor) {\r\n const str = fs.readFileSync(file, 'utf-8')\r\n const sarr = str.split(/[\\n,]/g)\r\n // console.log(file);\r\n const f =\r\n sarr[0].indexOf('eslint') === -1 &&\r\n (sarr[0].indexOf('-->') > -1 || sarr[0].indexOf('*/') > -1 || sarr[0].indexOf('//') > -1)\r\n ? sarr[0]\r\n : ''\r\n // console.log(f);\r\n return f\r\n}\r\n\r\nexport type ItemType = {\r\n name: string\r\n isDir: boolean\r\n level: number\r\n note: string\r\n children?: ItemType[]\r\n}\r\n\r\n/**\r\n * @description:Generate node information for all files \u751F\u6210\u6240\u6709\u6587\u4EF6\u7684node\u4FE1\u606F\r\n * @param {Array} nodes\r\n * @param {*} dir\r\n * @param {Number} level\r\n * @return {*}\r\n */\r\nexport function getFileNodes(\r\n option: { ignore: string[] | undefined; include: string[] | undefined } | undefined,\r\n nodes: Array<ItemType> = [],\r\n dir = path.resolve('./'),\r\n level = 0\r\n): Array<ItemType> {\r\n //File filtering -- full name with suffix required \u6587\u4EF6\u8FC7\u6EE4--\u9700\u8981\u5168\u79F0\u5E26\u540E\u7F00\r\n let ignore = [\r\n 'img',\r\n 'styles',\r\n 'node_modules',\r\n 'LICENSE',\r\n '.git',\r\n '.github',\r\n 'dist',\r\n '.husky',\r\n '.vscode',\r\n 'readme-file.js',\r\n 'readme-md.js'\r\n ]\r\n //File suffix contains only \u6587\u4EF6\u540E\u7F00\u53EA\u5305\u542B\r\n let include = ['.js', '.vue', '.ts']\r\n\r\n if (option) {\r\n ignore = option.ignore || ignore\r\n include = option.include || include\r\n }\r\n const files = fs\r\n .readdirSync(dir)\r\n .map((item) => {\r\n const fullPath = path.join(dir, item)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n return {\r\n name: item,\r\n isDir,\r\n level,\r\n note: ''\r\n } as ItemType\r\n })\r\n //Sort folders and files, otherwise the generated will not correspond to the opening order of the editor \u5BF9\u6587\u4EF6\u5939\u548C\u6587\u4EF6\u8FDB\u884C\u6392\u5E8F,\u8981\u4E0D\u7136\u751F\u6210\u7684\u548C\u7F16\u8F91\u5668\u6253\u5F00\u7684\u987A\u5E8F\u4E0D\u5BF9\u5E94\r\n .sort((a, b) => {\r\n if (!a.isDir && b.isDir) return 1\r\n if (a.isDir && !b.isDir) return -1\r\n if ((a.isDir && b.isDir) || (!a.isDir && !b.isDir)) return 0\r\n return 0\r\n })\r\n for (let index = 0; index < files.length; index += 1) {\r\n const item = files[index]\r\n let note = '' //File Comments \u6587\u4EF6\u6CE8\u91CA\r\n //Folder filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u5939\u8FC7\u6EE4\r\n const foldFlag = ignore.findIndex((obj: string) => obj === item.name)\r\n if (foldFlag === -1) {\r\n const fullPath = path.join(dir, item.name)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n if (isDir) {\r\n //recursion \u9012\u5F52\r\n getFileNodes(option, (item.children = []), fullPath, level + 1)\r\n nodes.push(item)\r\n } else {\r\n const i = fullPath.lastIndexOf('.')\r\n const lastName = fullPath.substring(i)\r\n //File filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u8FC7\u6EE4\r\n if (include.includes(lastName)) {\r\n note = getFile(fullPath)\r\n item.note = note\r\n nodes.push(item)\r\n }\r\n }\r\n }\r\n }\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:Recursive file name + note \u9012\u5F52\u5F97\u5230\u6587\u4EF6\u540D+note\r\n * @param {Array} datas\r\n * @param {string} keys\r\n * @return {*}\r\n */\r\nfunction getNote(datas: Array<ItemType>, keys?: string[]) {\r\n const nodes = keys || []\r\n datas.forEach((obj: ItemType, index: Number) => {\r\n const last = index === datas.length - 1\r\n if (obj.children) {\r\n //fold\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n getNote(obj.children, nodes)\r\n }\r\n // file\r\n else {\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n }\r\n })\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:One obj generates one line of text \u4E00\u4E2Aobj\u751F\u6210\u4E00\u4E2A\u4E00\u884C\u6587\u5B57\r\n * @param {ItemType} obj\r\n * @param {Boolean} last Is it the last one \u662F\u4E0D\u662F\u6700\u540E\u4E00\u4E2A\r\n * @return {*}\r\n */\r\nfunction setMd(obj: ItemType, last: Boolean): string {\r\n let filesString = ''\r\n const blank = '\u2502 '.repeat(obj.level) // \u91CD\u590D\u7A7A\u767D\r\n const pre = `${blank}${last ? '\u2514\u2500\u2500' : '\u251C\u2500\u2500'} ${obj.name}`\r\n if (obj.isDir) {\r\n filesString += `${pre}\\n`\r\n } else {\r\n filesString += `${pre} ${obj.note}\\n`\r\n }\r\n return filesString\r\n}\r\n\r\n/**\r\n * @description: \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\n// function wirteJs(data: string, filePath: string) {\r\n// const file = path.resolve(__dirname, filePath)\r\n// const pre = 'export default'\r\n// // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n// fs.writeFile(file, pre + data, { encoding: 'utf8' }, (err) => {\r\n// console.error(err)\r\n// })\r\n// }\r\n\r\n/**\r\n * @description: Generate MD \u751F\u6210md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nexport function getMd(option?: { ignore: string[] | undefined; include: string[] | undefined } | undefined) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** run location: ', path.resolve('./'))\r\n const nodes = getFileNodes(option)\r\n // \u5F97\u5230md\u5BF9\u8C61\r\n // wirteJs(JSON.stringify(nodes), __dirname + '\\\\readme-file.js')\r\n const note = getNote(nodes) // \u5F97\u5230\u6240\u6709note\u7684\u6570\u7EC4\r\n const md = note.join('') // \u6570\u7EC4\u8F6C\u5B57\u7B26\u4E32\r\n if (md.length > 0) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** Automatic generation completed ! ')\r\n }\r\n return md\r\n}\r\n", "import arg from 'arg'\r\nconst stringToArgs = (rawArgs: string[]) => {\r\n const args = arg(\r\n {\r\n '--ignore': String,\r\n '--include': String,\r\n '--version': Boolean,\r\n '--help': Boolean,\r\n '-h': '--help',\r\n '-i': '--ignore',\r\n '-in': '--include',\r\n '-v': '--version'\r\n },\r\n {\r\n argv: rawArgs.slice(2)\r\n }\r\n )\r\n return {\r\n help: args['--help'],\r\n ignore: args['--ignore'],\r\n include: args['--include'],\r\n version: args['--version']\r\n }\r\n}\r\n\r\nexport default stringToArgs\r\n", "const st = `Usage: agmd--include str--ignore str\r\n\r\n Options:\r\n --include string / -i string.......... include file extension\r\n --ignore string / -in string........... ignore file or fold\r\n --version / -v ........... seach vesion\r\n Str deafult:\r\n --ignore img,styles,node_modules,LICENSE,.git,.github,dist,.husky,.vscode,readme-file.js,readme-md.js\r\n --include .js,.vue,.ts\r\n\r\n Note:\r\n There should be no space between strings in a configuration\r\n\r\n Examples:\r\n $ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`\r\n\r\nfunction help() {\r\n console.log(st)\r\n process.exit(0)\r\n}\r\nexport default help\r\n", "import help from '../help'\r\nimport pkg from '../../package.json'\r\ninterface parseType {\r\n version?: Boolean | undefined\r\n includes?: string[]\r\n ignores?: string[]\r\n help: Boolean | undefined\r\n ignore: string | undefined\r\n include: string | undefined\r\n}\r\nfunction handle(settings: parseType) {\r\n if (settings.help) {\r\n help()\r\n }\r\n if (settings.version) {\r\n console.log(`agmd version is: ` + '\\x1B[36m%s\\x1B[0m', pkg.version)\r\n process.exit(0)\r\n }\r\n if (settings.ignore) {\r\n settings.ignores = settings.ignore.split(' ')\r\n }\r\n if (settings.include) {\r\n settings.includes = settings.include.split(' ')\r\n }\r\n return settings\r\n}\r\n\r\nexport default handle\r\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["const flagSymbol = Symbol('arg flag');\n\nclass ArgError extends Error {\n\tconstructor(msg, code) {\n\t\tsuper(msg);\n\t\tthis.name = 'ArgError';\n\t\tthis.code = code;\n\n\t\tObject.setPrototypeOf(this, ArgError.prototype);\n\t}\n}\n\nfunction arg(\n\topts,\n\t{\n\t\targv = process.argv.slice(2),\n\t\tpermissive = false,\n\t\tstopAtPositional = false\n\t} = {}\n) {\n\tif (!opts) {\n\t\tthrow new ArgError(\n\t\t\t'argument specification object is required',\n\t\t\t'ARG_CONFIG_NO_SPEC'\n\t\t);\n\t}\n\n\tconst result = { _: [] };\n\n\tconst aliases = {};\n\tconst handlers = {};\n\n\tfor (const key of Object.keys(opts)) {\n\t\tif (!key) {\n\t\t\tthrow new ArgError(\n\t\t\t\t'argument key cannot be an empty string',\n\t\t\t\t'ARG_CONFIG_EMPTY_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key[0] !== '-') {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must start with '-' but found: '${key}'`,\n\t\t\t\t'ARG_CONFIG_NONOPT_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (key.length === 1) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`argument key must have a name; singular '-' keys are not allowed: ${key}`,\n\t\t\t\t'ARG_CONFIG_NONAME_KEY'\n\t\t\t);\n\t\t}\n\n\t\tif (typeof opts[key] === 'string') {\n\t\t\taliases[key] = opts[key];\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet type = opts[key];\n\t\tlet isFlag = false;\n\n\t\tif (\n\t\t\tArray.isArray(type) &&\n\t\t\ttype.length === 1 &&\n\t\t\ttypeof type[0] === 'function'\n\t\t) {\n\t\t\tconst [fn] = type;\n\t\t\ttype = (value, name, prev = []) => {\n\t\t\t\tprev.push(fn(value, name, prev[prev.length - 1]));\n\t\t\t\treturn prev;\n\t\t\t};\n\t\t\tisFlag = fn === Boolean || fn[flagSymbol] === true;\n\t\t} else if (typeof type === 'function') {\n\t\t\tisFlag = type === Boolean || type[flagSymbol] === true;\n\t\t} else {\n\t\t\tthrow new ArgError(\n\t\t\t\t`type missing or not a function or valid array type: ${key}`,\n\t\t\t\t'ARG_CONFIG_VAD_TYPE'\n\t\t\t);\n\t\t}\n\n\t\tif (key[1] !== '-' && key.length > 2) {\n\t\t\tthrow new ArgError(\n\t\t\t\t`short argument keys (with a single hyphen) must have only one character: ${key}`,\n\t\t\t\t'ARG_CONFIG_SHORTOPT_TOOLONG'\n\t\t\t);\n\t\t}\n\n\t\thandlers[key] = [type, isFlag];\n\t}\n\n\tfor (let i = 0, len = argv.length; i < len; i++) {\n\t\tconst wholeArg = argv[i];\n\n\t\tif (stopAtPositional && result._.length > 0) {\n\t\t\tresult._ = result._.concat(argv.slice(i));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg === '--') {\n\t\t\tresult._ = result._.concat(argv.slice(i + 1));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (wholeArg.length > 1 && wholeArg[0] === '-') {\n\t\t\t/* eslint-disable operator-linebreak */\n\t\t\tconst separatedArguments =\n\t\t\t\twholeArg[1] === '-' || wholeArg.length === 2\n\t\t\t\t\t? [wholeArg]\n\t\t\t\t\t: wholeArg\n\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t\t.map((a) => `-${a}`);\n\t\t\t/* eslint-enable operator-linebreak */\n\n\t\t\tfor (let j = 0; j < separatedArguments.length; j++) {\n\t\t\t\tconst arg = separatedArguments[j];\n\t\t\t\tconst [originalArgName, argStr] =\n\t\t\t\t\targ[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];\n\n\t\t\t\tlet argName = originalArgName;\n\t\t\t\twhile (argName in aliases) {\n\t\t\t\t\targName = aliases[argName];\n\t\t\t\t}\n\n\t\t\t\tif (!(argName in handlers)) {\n\t\t\t\t\tif (permissive) {\n\t\t\t\t\t\tresult._.push(arg);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`unknown or unexpected option: ${originalArgName}`,\n\t\t\t\t\t\t\t'ARG_UNKNOWN_OPTION'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst [type, isFlag] = handlers[argName];\n\n\t\t\t\tif (!isFlag && j + 1 < separatedArguments.length) {\n\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t`option requires argument (but was followed by another short argument): ${originalArgName}`,\n\t\t\t\t\t\t'ARG_MISSING_REQUIRED_SHORTARG'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isFlag) {\n\t\t\t\t\tresult[argName] = type(true, argName, result[argName]);\n\t\t\t\t} else if (argStr === undefined) {\n\t\t\t\t\tif (\n\t\t\t\t\t\targv.length < i + 2 ||\n\t\t\t\t\t\t(argv[i + 1].length > 1 &&\n\t\t\t\t\t\t\targv[i + 1][0] === '-' &&\n\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\targv[i + 1].match(/^-?\\d*(\\.(?=\\d))?\\d*$/) &&\n\t\t\t\t\t\t\t\t(type === Number ||\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-undef\n\t\t\t\t\t\t\t\t\t(typeof BigInt !== 'undefined' && type === BigInt))\n\t\t\t\t\t\t\t))\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst extended =\n\t\t\t\t\t\t\toriginalArgName === argName ? '' : ` (alias for ${argName})`;\n\t\t\t\t\t\tthrow new ArgError(\n\t\t\t\t\t\t\t`option requires argument: ${originalArgName}${extended}`,\n\t\t\t\t\t\t\t'ARG_MISSING_REQUIRED_LONGARG'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[argName] = type(argv[i + 1], argName, result[argName]);\n\t\t\t\t\t++i;\n\t\t\t\t} else {\n\t\t\t\t\tresult[argName] = type(argStr, argName, result[argName]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresult._.push(wholeArg);\n\t\t}\n\t}\n\n\treturn result;\n}\n\narg.flag = (fn) => {\n\tfn[flagSymbol] = true;\n\treturn fn;\n};\n\n// Utility types\narg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);\n\n// Expose error class\narg.ArgError = ArgError;\n\nmodule.exports = arg;\n", "#!/usr/bin/env node\r\n'use strict'\r\nimport path from 'path'\r\nimport { getMd, wirteMd } from './index'\r\nimport stringToArgs from '../script/cli'\r\nimport handle from '../script/cli/handle'\r\nconst options = stringToArgs(process.argv)\r\nconst { ignores: ignore, includes: include } = handle(options)\r\n/**\r\n * @description:Automatic generation of the whole process \u81EA\u52A8\u751F\u6210\u5168\u6D41\u7A0B\r\n * @param {*}\r\n * @return {*}\r\n */\r\nfunction agmd() {\r\n const md = getMd({ ignore, include })\r\n // \u5F97\u5230md\u6587\u6863\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** location: ', `${path.resolve('./')}\\\\readme-md.md`)\r\n wirteMd(md, `${path.resolve('./')}\\\\readme-md.md`)\r\n}\r\nagmd()\r\n", "import fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @description:Gets the header comment of the file \u83B7\u53D6\u6587\u4EF6\u7684\u5934\u90E8\u6CE8\u91CA\r\n * @param {*} file\r\n * @return {*}\r\n */\r\nfunction getFile(file: fs.PathOrFileDescriptor) {\r\n const str = fs.readFileSync(file, 'utf-8')\r\n const size = str.length\r\n const sarr = str.split(/[\\n,]/g)\r\n const rowSize = sarr.length\r\n const f =\r\n sarr[0].indexOf('eslint') === -1 &&\r\n (sarr[0].indexOf('-->') > -1 || sarr[0].indexOf('*/') > -1 || sarr[0].indexOf('//') > -1)\r\n ? sarr[0]\r\n : ''\r\n return { note: f, size, rowSize }\r\n}\r\n\r\ntype ItemType = {\r\n name: string\r\n isDir: boolean\r\n level: number\r\n note: string\r\n size: number\r\n suffix: string\r\n rowSize: number\r\n children?: ItemType[]\r\n}\r\n\r\ntype secoutType = { rowTotleNumber: number; sizeTotleNumber: number; coutObj: { [key: string]: number } }\r\n\r\n/**\r\n * @description:Generate node information for all files \u751F\u6210\u6240\u6709\u6587\u4EF6\u7684node\u4FE1\u606F\r\n * @param {Array} nodes\r\n * @param {*} dir\r\n * @param {Number} level\r\n * @return {*}\r\n */\r\nexport function getFileNodes(\r\n option: { ignore: string[] | undefined; include: string[] | undefined } | undefined,\r\n nodes: Array<ItemType> = [],\r\n dir = path.resolve('./'),\r\n level = 0\r\n): Array<ItemType> {\r\n //File filtering -- full name with suffix required \u6587\u4EF6\u8FC7\u6EE4--\u9700\u8981\u5168\u79F0\u5E26\u540E\u7F00\r\n let ignore = [\r\n 'public',\r\n 'build',\r\n 'img',\r\n 'assets',\r\n 'mock',\r\n 'api',\r\n 'styles',\r\n 'node_modules',\r\n 'LICENSE',\r\n '.git',\r\n '.github',\r\n 'dist',\r\n '.husky',\r\n '.vscode',\r\n 'babel.config.js',\r\n 'prettier.config.js',\r\n 'commitlint.config.js',\r\n 'readme-file.js',\r\n 'vue.config.js',\r\n '.eslintrc.js',\r\n 'readme-md.js'\r\n ]\r\n //File suffix contains only \u6587\u4EF6\u540E\u7F00\u53EA\u5305\u542B\r\n let include = ['.js', '.vue', '.ts']\r\n\r\n if (option) {\r\n ignore = option.ignore || ignore\r\n include = option.include || include\r\n }\r\n const files = fs\r\n .readdirSync(dir)\r\n .map((item) => {\r\n const fullPath = path.join(dir, item)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n return {\r\n name: item,\r\n isDir,\r\n level,\r\n note: ''\r\n } as ItemType\r\n })\r\n //Sort folders and files, otherwise the generated will not correspond to the opening order of the editor \u5BF9\u6587\u4EF6\u5939\u548C\u6587\u4EF6\u8FDB\u884C\u6392\u5E8F,\u8981\u4E0D\u7136\u751F\u6210\u7684\u548C\u7F16\u8F91\u5668\u6253\u5F00\u7684\u987A\u5E8F\u4E0D\u5BF9\u5E94\r\n .sort((a, b) => {\r\n if (!a.isDir && b.isDir) return 1\r\n if (a.isDir && !b.isDir) return -1\r\n if ((a.isDir && b.isDir) || (!a.isDir && !b.isDir)) return 0\r\n return 0\r\n })\r\n for (let index = 0; index < files.length; index += 1) {\r\n const item = files[index]\r\n //Folder filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u5939\u8FC7\u6EE4\r\n const foldFlag = ignore.findIndex((obj: string) => obj === item.name)\r\n if (foldFlag === -1) {\r\n const fullPath = path.join(dir, item.name)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n if (isDir) {\r\n //recursion \u9012\u5F52\r\n getFileNodes(option, (item.children = []), fullPath, level + 1)\r\n nodes.push(item)\r\n } else {\r\n const i = fullPath.lastIndexOf('.')\r\n const lastName = fullPath.substring(i)\r\n //File filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u8FC7\u6EE4\r\n if (include.includes(lastName)) {\r\n const obj = getFile(fullPath)\r\n Object.assign(item, obj)\r\n item.suffix = lastName\r\n nodes.push(item)\r\n }\r\n }\r\n }\r\n }\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:Recursive file name + note \u9012\u5F52\u5F97\u5230\u6587\u4EF6\u540D+note\r\n * @param {Array} datas\r\n * @param {string} keys\r\n * @return {*}\r\n */\r\nfunction getNote(datas: Array<ItemType>, keys?: string[]) {\r\n const nodes = keys || []\r\n datas.forEach((obj: ItemType, index: Number) => {\r\n const last = index === datas.length - 1\r\n if (obj.children) {\r\n //fold\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n getNote(obj.children, nodes)\r\n }\r\n // file\r\n else {\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n }\r\n })\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:One obj generates one line of text \u4E00\u4E2Aobj\u751F\u6210\u4E00\u4E2A\u4E00\u884C\u6587\u5B57\r\n * @param {ItemType} obj\r\n * @param {Boolean} last Is it the last one \u662F\u4E0D\u662F\u6700\u540E\u4E00\u4E2A\r\n * @return {*}\r\n */\r\nfunction setMd(obj: ItemType, last: Boolean): string {\r\n let filesString = ''\r\n const blank = '\u2502 '.repeat(obj.level) // \u91CD\u590D\u7A7A\u767D\r\n const pre = `${blank}${last ? '\u2514\u2500\u2500' : '\u251C\u2500\u2500'} ${obj.name}`\r\n if (obj.isDir) {\r\n filesString += `${pre}\\n`\r\n } else {\r\n filesString += `${pre} ${obj.note}\\n`\r\n }\r\n return filesString\r\n}\r\n\r\n/**\r\n * @description: Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\n// function wirteJs(data: string, filePath: string) {\r\n// const file = path.resolve(__dirname, filePath)\r\n// const pre = 'export default'\r\n// // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n// fs.writeFile(file, pre + data, { encoding: 'utf8' }, (err) => {\r\n// console.error(err)\r\n// })\r\n// }\r\n/**\r\n * @description:Thousands format \u5343\u5206\u4F4D\u683C\u5F0F\u5316\r\n * @param {num} To format a number \u8981\u683C\u5F0F\u5316\u6570\u5B57\r\n * @return {string}\r\n */\r\nfunction format(num: number) {\r\n var reg = /\\d{1,3}(?=(\\d{3})+$)/g\r\n return (num + '').replace(reg, '$&,')\r\n}\r\n/**\r\n * @description: Generate statistics MD \u751F\u6210\u7EDF\u8BA1md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nfunction setCountMd(obj: secoutType) {\r\n const { rowTotleNumber, sizeTotleNumber, coutObj } = obj\r\n let countMd = ''\r\n let totle=0\r\n for (const key in coutObj) {\r\n const ele = coutObj[key]\r\n totle += ele\r\n countMd += `The suffix is ${key} has ${ele} files\\n`\r\n }\r\n countMd += `The totle has ${totle} files\\n`\r\n let md = `Total number of file lines: ${format(rowTotleNumber)},\r\nTotal number of codes: ${format(sizeTotleNumber)} \\n`\r\n md = countMd + md\r\n return md\r\n // wirteMd(md, `${path.resolve('./')}\\\\count-md.md`)\r\n}\r\n/**\r\n * @description: Get statistics \u5F97\u5230\u7EDF\u8BA1\r\n * @param {Array} nodes\r\n * @return {*}\r\n */\r\nfunction getCountMd(datas: Array<ItemType>) {\r\n let rowTotleNumber = 0\r\n let sizeTotleNumber = 0\r\n const coutObj: { [key: string]: number } = {}\r\n function getDeatle(nodes: Array<ItemType>) {\r\n nodes.forEach((obj: ItemType) => {\r\n if (obj.children) getDeatle(obj.children)\r\n else {\r\n if (!coutObj.hasOwnProperty(obj.suffix)) coutObj[obj.suffix] = 0\r\n coutObj[obj.suffix]++\r\n rowTotleNumber += obj.rowSize\r\n sizeTotleNumber += obj.size\r\n }\r\n })\r\n }\r\n getDeatle(datas)\r\n return {\r\n rowTotleNumber,\r\n sizeTotleNumber,\r\n coutObj\r\n }\r\n}\r\n\r\n/**\r\n * @description: Generate MD \u751F\u6210md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nexport function getMd(option?: { ignore: string[] | undefined; include: string[] | undefined } | undefined) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** run location: ', path.resolve('./')+'\\n')\r\n const nodes = getFileNodes(option)\r\n // \u5F97\u5230md\u5BF9\u8C61\r\n // wirteJs(JSON.stringify(nodes), __dirname + '\\\\readme-file.js')\r\n const countMdObj = getCountMd(nodes)\r\n const coutMd = setCountMd(countMdObj)\r\n console.log('\\x1B[33m%s\\x1b[0m', coutMd)\r\n const note = getNote(nodes) // \u5F97\u5230\u6240\u6709note\u7684\u6570\u7EC4\r\n const md = note.join('')+'\\n' // \u6570\u7EC4\u8F6C\u5B57\u7B26\u4E32\r\n if (md.length > 0) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** Automatic generation completed ! ')\r\n }\r\n\r\n return md + coutMd\r\n}\r\n\r\n/**\r\n * @description:Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\nexport function wirteMd(data: string, filePath: string) {\r\n const file = path.resolve(__dirname, filePath)\r\n // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n fs.writeFile(file, data, { encoding: 'utf8' }, () => {\r\n console.log('Write successful')\r\n })\r\n}\r\n", "import arg from 'arg'\r\nconst stringToArgs = (rawArgs: string[]) => {\r\n const args = arg(\r\n {\r\n '--ignore': String,\r\n '--include': String,\r\n '--version': Boolean,\r\n '--help': Boolean,\r\n '-h': '--help',\r\n '-i': '--ignore',\r\n '-in': '--include',\r\n '-v': '--version'\r\n },\r\n {\r\n argv: rawArgs.slice(2)\r\n }\r\n )\r\n return {\r\n help: args['--help'],\r\n ignore: args['--ignore'],\r\n include: args['--include'],\r\n version: args['--version']\r\n }\r\n}\r\n\r\nexport default stringToArgs\r\n", "const st = `Usage: agmd--include str--ignore str\r\n\r\n Options:\r\n --include string / -i string.......... include file extension\r\n --ignore string / -in string........... ignore file or fold\r\n --version / -v ........... seach vesion\r\n Str deafult:\r\n --ignore img,styles,node_modules,LICENSE,.git,.github,dist,.husky,.vscode,readme-file.js,readme-md.js\r\n --include .js,.vue,.ts\r\n\r\n Note:\r\n There should be no space between strings in a configuration\r\n\r\n Examples:\r\n $ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`\r\n\r\nfunction help() {\r\n console.log(st)\r\n process.exit(0)\r\n}\r\nexport default help\r\n", "import help from '../help'\r\nimport pkg from '../../package.json'\r\ninterface parseType {\r\n version?: Boolean | undefined\r\n includes?: string[]\r\n ignores?: string[]\r\n help: Boolean | undefined\r\n ignore: string | undefined\r\n include: string | undefined\r\n}\r\nfunction handle(settings: parseType) {\r\n if (settings.help) {\r\n help()\r\n }\r\n if (settings.version) {\r\n console.log(`agmd version is: ` + '\\x1B[36m%s\\x1B[0m', pkg.version)\r\n process.exit(0)\r\n }\r\n if (settings.ignore) {\r\n settings.ignores = settings.ignore.split(' ')\r\n }\r\n if (settings.include) {\r\n settings.includes = settings.include.split(' ')\r\n }\r\n return settings\r\n}\r\n\r\nexport default handle\r\n"],
|
|
5
|
+
"mappings": ";+lBAAA,oBAAM,GAAa,OAAO,YAE1B,eAAuB,MAAM,CAC5B,YAAY,EAAK,EAAM,CACtB,MAAM,GACN,KAAK,KAAO,WACZ,KAAK,KAAO,EAEZ,OAAO,eAAe,KAAM,EAAS,aAIvC,WACC,EACA,CACC,OAAO,QAAQ,KAAK,MAAM,GAC1B,aAAa,GACb,mBAAmB,IAChB,GACH,CACD,GAAI,CAAC,EACJ,KAAM,IAAI,GACT,4CACA,sBAIF,GAAM,GAAS,CAAE,EAAG,IAEd,EAAU,GACV,EAAW,GAEjB,OAAW,KAAO,QAAO,KAAK,GAAO,CACpC,GAAI,CAAC,EACJ,KAAM,IAAI,GACT,yCACA,wBAIF,GAAI,EAAI,KAAO,IACd,KAAM,IAAI,GACT,gDAAgD,KAChD,yBAIF,GAAI,EAAI,SAAW,EAClB,KAAM,IAAI,GACT,qEAAqE,IACrE,yBAIF,GAAI,MAAO,GAAK,IAAS,SAAU,CAClC,EAAQ,GAAO,EAAK,GACpB,SAGD,GAAI,GAAO,EAAK,GACZ,EAAS,GAEb,GACC,MAAM,QAAQ,IACd,EAAK,SAAW,GAChB,MAAO,GAAK,IAAO,WAClB,CACD,GAAM,CAAC,GAAM,EACb,EAAO,CAAC,EAAO,EAAM,EAAO,KAC3B,GAAK,KAAK,EAAG,EAAO,EAAM,EAAK,EAAK,OAAS,KACtC,GAER,EAAS,IAAO,SAAW,EAAG,KAAgB,WACpC,MAAO,IAAS,WAC1B,EAAS,IAAS,SAAW,EAAK,KAAgB,OAElD,MAAM,IAAI,GACT,uDAAuD,IACvD,uBAIF,GAAI,EAAI,KAAO,KAAO,EAAI,OAAS,EAClC,KAAM,IAAI,GACT,4EAA4E,IAC5E,+BAIF,EAAS,GAAO,CAAC,EAAM,GAGxB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IAAI,GACZ,QAAQ,KAAK,GAEf,GAAO,GAAQ,80CCVf,YAAgB,EAAqB,CACnC,MAAI,GAAS,MACX,IAEE,EAAS,SACX,SAAQ,IAAI,qCAA2C,EAAI,SAC3D,QAAQ,KAAK,IAEX,EAAS,QACX,GAAS,QAAU,EAAS,OAAO,MAAM,MAEvC,EAAS,SACX,GAAS,SAAW,EAAS,QAAQ,MAAM,MAEtC,EAGT,GAAO,GAAQ,GJrBf,GAAM,IAAU,EAAa,QAAQ,MAC/B,CAAE,QAAS,GAAQ,SAAU,IAAY,EAAO,IAMtD,aAAgB,CACd,GAAM,GAAK,EAAM,CAAE,UAAQ,aAE3B,QAAQ,IAAI,oBAAqB,iBAAkB,GAAG,UAAK,QAAQ,uBACnE,EAAQ,EAAI,GAAG,UAAK,QAAQ,uBAE9B",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default[{"name":"bin","isDir":true,"level":0,"note":"","children":[{"name":"agmd.js","isDir":false,"level":1,"note":"","noteText":"","size":8211,"rowSize":290,"suffix":".js"}]},{"name":"lib","isDir":true,"level":0,"note":"","children":[{"name":"index.cjs.js","isDir":false,"level":1,"note":"","noteText":"","size":6805,"rowSize":305,"suffix":".js"},{"name":"index.d.ts","isDir":false,"level":1,"note":"","noteText":"","size":630,"rowSize":25,"suffix":".ts"},{"name":"index.esm.js","isDir":false,"level":1,"note":"","noteText":"","size":4825,"rowSize":240,"suffix":".js"}]},{"name":"script","isDir":true,"level":0,"note":"","children":[{"name":"cli","isDir":true,"level":1,"note":"","children":[{"name":"handle.ts","isDir":false,"level":2,"note":"","noteText":"","size":681,"rowSize":30,"suffix":".ts"},{"name":"index.ts","isDir":false,"level":2,"note":"","noteText":"","size":539,"rowSize":38,"suffix":".ts"}]},{"name":"help","isDir":true,"level":1,"note":"","children":[{"name":"index.ts","isDir":false,"level":2,"note":"","noteText":"","size":640,"rowSize":38,"suffix":".ts"}]},{"name":"build.js","isDir":false,"level":1,"note":"","noteText":"","size":172,"rowSize":8,"suffix":".js"},{"name":"builder.js","isDir":false,"level":1,"note":"","noteText":"","size":1239,"rowSize":74,"suffix":".js"}]},{"name":"src","isDir":true,"level":0,"note":"","children":[{"name":"agmd.ts","isDir":false,"level":1,"note":"","noteText":"","size":635,"rowSize":27,"suffix":".ts"},{"name":"index.ts","isDir":false,"level":1,"note":"","noteText":"","size":7116,"rowSize":317,"suffix":".ts"}]},{"name":"test","isDir":true,"level":0,"note":"","children":[{"name":"index.js","isDir":false,"level":1,"note":"","noteText":"","size":88,"rowSize":4,"suffix":".js"}]},{"name":"unuse","isDir":true,"level":0,"note":"","children":[{"name":"assets","isDir":true,"level":1,"note":"","children":[]},{"name":"components","isDir":true,"level":1,"note":"","children":[{"name":"user-ruler.vue","isDir":false,"level":2,"note":"","noteText":"/* 这是vue2.0写法 */\r","size":3652,"rowSize":204,"suffix":".vue"},{"name":"user-rulerts.vue","isDir":false,"level":2,"note":"","noteText":"/* 这是ts写法 */\r","size":4219,"rowSize":239,"suffix":".vue"}]},{"name":"App.vue","isDir":false,"level":1,"note":"","noteText":"/* App主入口 */\r","size":695,"rowSize":31,"suffix":".vue"},{"name":"main.js","isDir":false,"level":1,"note":"","noteText":"/* 入口 */\r","size":340,"rowSize":13,"suffix":".js"}]},{"name":".eslintrc.js","isDir":false,"level":0,"note":"","noteText":"","size":938,"rowSize":67,"suffix":".js"}]
|
package/lib/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* agmd v0.2.
|
|
2
|
+
* agmd v0.2.9
|
|
3
3
|
* author:kakajun <253495832@qq.com>
|
|
4
|
-
*
|
|
4
|
+
* Tue Mar 22 2022 21:32:12 GMT+0800 (中国标准时间)
|
|
5
5
|
*/
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -35,19 +35,27 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
35
35
|
var src_exports = {};
|
|
36
36
|
__export(src_exports, {
|
|
37
37
|
getFileNodes: () => getFileNodes,
|
|
38
|
-
getMd: () => getMd
|
|
38
|
+
getMd: () => getMd,
|
|
39
|
+
wirteMd: () => wirteMd
|
|
39
40
|
});
|
|
40
41
|
var import_fs = __toESM(require("fs"));
|
|
41
42
|
var import_path = __toESM(require("path"));
|
|
42
43
|
function getFile(file) {
|
|
43
44
|
const str = import_fs.default.readFileSync(file, "utf-8");
|
|
45
|
+
const size = str.length;
|
|
44
46
|
const sarr = str.split(/[\n,]/g);
|
|
47
|
+
const rowSize = sarr.length;
|
|
45
48
|
const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
|
|
46
|
-
return f;
|
|
49
|
+
return { note: f, size, rowSize };
|
|
47
50
|
}
|
|
48
51
|
function getFileNodes(option, nodes = [], dir = import_path.default.resolve("./"), level = 0) {
|
|
49
52
|
let ignore = [
|
|
53
|
+
"public",
|
|
54
|
+
"build",
|
|
50
55
|
"img",
|
|
56
|
+
"assets",
|
|
57
|
+
"mock",
|
|
58
|
+
"api",
|
|
51
59
|
"styles",
|
|
52
60
|
"node_modules",
|
|
53
61
|
"LICENSE",
|
|
@@ -56,7 +64,12 @@ function getFileNodes(option, nodes = [], dir = import_path.default.resolve("./"
|
|
|
56
64
|
"dist",
|
|
57
65
|
".husky",
|
|
58
66
|
".vscode",
|
|
67
|
+
"babel.config.js",
|
|
68
|
+
"prettier.config.js",
|
|
69
|
+
"commitlint.config.js",
|
|
59
70
|
"readme-file.js",
|
|
71
|
+
"vue.config.js",
|
|
72
|
+
".eslintrc.js",
|
|
60
73
|
"readme-md.js"
|
|
61
74
|
];
|
|
62
75
|
let include = [".js", ".vue", ".ts"];
|
|
@@ -84,7 +97,6 @@ function getFileNodes(option, nodes = [], dir = import_path.default.resolve("./"
|
|
|
84
97
|
});
|
|
85
98
|
for (let index = 0; index < files.length; index += 1) {
|
|
86
99
|
const item = files[index];
|
|
87
|
-
let note = "";
|
|
88
100
|
const foldFlag = ignore.findIndex((obj) => obj === item.name);
|
|
89
101
|
if (foldFlag === -1) {
|
|
90
102
|
const fullPath = import_path.default.join(dir, item.name);
|
|
@@ -96,8 +108,9 @@ function getFileNodes(option, nodes = [], dir = import_path.default.resolve("./"
|
|
|
96
108
|
const i = fullPath.lastIndexOf(".");
|
|
97
109
|
const lastName = fullPath.substring(i);
|
|
98
110
|
if (include.includes(lastName)) {
|
|
99
|
-
|
|
100
|
-
item
|
|
111
|
+
const obj = getFile(fullPath);
|
|
112
|
+
Object.assign(item, obj);
|
|
113
|
+
item.suffix = lastName;
|
|
101
114
|
nodes.push(item);
|
|
102
115
|
}
|
|
103
116
|
}
|
|
@@ -133,20 +146,76 @@ function setMd(obj, last) {
|
|
|
133
146
|
}
|
|
134
147
|
return filesString;
|
|
135
148
|
}
|
|
149
|
+
function format(num) {
|
|
150
|
+
var reg = /\d{1,3}(?=(\d{3})+$)/g;
|
|
151
|
+
return (num + "").replace(reg, "$&,");
|
|
152
|
+
}
|
|
153
|
+
function setCountMd(obj) {
|
|
154
|
+
const { rowTotleNumber, sizeTotleNumber, coutObj } = obj;
|
|
155
|
+
let countMd = "";
|
|
156
|
+
let totle = 0;
|
|
157
|
+
for (const key in coutObj) {
|
|
158
|
+
const ele = coutObj[key];
|
|
159
|
+
totle += ele;
|
|
160
|
+
countMd += `The suffix is ${key} has ${ele} files
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
countMd += `The totle has ${totle} files
|
|
164
|
+
`;
|
|
165
|
+
let md = `Total number of file lines: ${format(rowTotleNumber)},
|
|
166
|
+
Total number of codes: ${format(sizeTotleNumber)}
|
|
167
|
+
`;
|
|
168
|
+
md = countMd + md;
|
|
169
|
+
return md;
|
|
170
|
+
}
|
|
171
|
+
function getCountMd(datas) {
|
|
172
|
+
let rowTotleNumber = 0;
|
|
173
|
+
let sizeTotleNumber = 0;
|
|
174
|
+
const coutObj = {};
|
|
175
|
+
function getDeatle(nodes) {
|
|
176
|
+
nodes.forEach((obj) => {
|
|
177
|
+
if (obj.children)
|
|
178
|
+
getDeatle(obj.children);
|
|
179
|
+
else {
|
|
180
|
+
if (!coutObj.hasOwnProperty(obj.suffix))
|
|
181
|
+
coutObj[obj.suffix] = 0;
|
|
182
|
+
coutObj[obj.suffix]++;
|
|
183
|
+
rowTotleNumber += obj.rowSize;
|
|
184
|
+
sizeTotleNumber += obj.size;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
getDeatle(datas);
|
|
189
|
+
return {
|
|
190
|
+
rowTotleNumber,
|
|
191
|
+
sizeTotleNumber,
|
|
192
|
+
coutObj
|
|
193
|
+
};
|
|
194
|
+
}
|
|
136
195
|
function getMd(option) {
|
|
137
|
-
console.log("\x1B[36m%s\x1B[0m", "*** run location: ", import_path.default.resolve("./"));
|
|
196
|
+
console.log("\x1B[36m%s\x1B[0m", "*** run location: ", import_path.default.resolve("./") + "\n");
|
|
138
197
|
const nodes = getFileNodes(option);
|
|
198
|
+
const countMdObj = getCountMd(nodes);
|
|
199
|
+
const coutMd = setCountMd(countMdObj);
|
|
200
|
+
console.log("\x1B[33m%s\x1B[0m", coutMd);
|
|
139
201
|
const note = getNote(nodes);
|
|
140
|
-
const md = note.join("");
|
|
202
|
+
const md = note.join("") + "\n";
|
|
141
203
|
if (md.length > 0) {
|
|
142
204
|
console.log("\x1B[36m%s\x1B[0m", "*** Automatic generation completed ! ");
|
|
143
205
|
}
|
|
144
|
-
return md;
|
|
206
|
+
return md + coutMd;
|
|
207
|
+
}
|
|
208
|
+
function wirteMd(data, filePath) {
|
|
209
|
+
const file = import_path.default.resolve(__dirname, filePath);
|
|
210
|
+
import_fs.default.writeFile(file, data, { encoding: "utf8" }, () => {
|
|
211
|
+
console.log("Write successful");
|
|
212
|
+
});
|
|
145
213
|
}
|
|
146
214
|
module.exports = __toCommonJS(src_exports);
|
|
147
215
|
// Annotate the CommonJS export names for ESM import in node:
|
|
148
216
|
0 && (module.exports = {
|
|
149
217
|
getFileNodes,
|
|
150
|
-
getMd
|
|
218
|
+
getMd,
|
|
219
|
+
wirteMd
|
|
151
220
|
});
|
|
152
221
|
//# sourceMappingURL=index.cjs.js.map
|
package/lib/index.cjs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @description:Gets the header comment of the file \u83B7\u53D6\u6587\u4EF6\u7684\u5934\u90E8\u6CE8\u91CA\r\n * @param {*} file\r\n * @return {*}\r\n */\r\nfunction getFile(file: fs.PathOrFileDescriptor) {\r\n const str = fs.readFileSync(file, 'utf-8')\r\n const sarr = str.split(/[\\n,]/g)\r\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AAOjB,iBAAiB,MAA+B;AAC9C,QAAM,MAAM,kBAAG,aAAa,MAAM;AAClC,QAAM,OAAO,IAAI,MAAM;
|
|
4
|
+
"sourcesContent": ["import fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @description:Gets the header comment of the file \u83B7\u53D6\u6587\u4EF6\u7684\u5934\u90E8\u6CE8\u91CA\r\n * @param {*} file\r\n * @return {*}\r\n */\r\nfunction getFile(file: fs.PathOrFileDescriptor) {\r\n const str = fs.readFileSync(file, 'utf-8')\r\n const size = str.length\r\n const sarr = str.split(/[\\n,]/g)\r\n const rowSize = sarr.length\r\n const f =\r\n sarr[0].indexOf('eslint') === -1 &&\r\n (sarr[0].indexOf('-->') > -1 || sarr[0].indexOf('*/') > -1 || sarr[0].indexOf('//') > -1)\r\n ? sarr[0]\r\n : ''\r\n return { note: f, size, rowSize }\r\n}\r\n\r\ntype ItemType = {\r\n name: string\r\n isDir: boolean\r\n level: number\r\n note: string\r\n size: number\r\n suffix: string\r\n rowSize: number\r\n children?: ItemType[]\r\n}\r\n\r\ntype secoutType = { rowTotleNumber: number; sizeTotleNumber: number; coutObj: { [key: string]: number } }\r\n\r\n/**\r\n * @description:Generate node information for all files \u751F\u6210\u6240\u6709\u6587\u4EF6\u7684node\u4FE1\u606F\r\n * @param {Array} nodes\r\n * @param {*} dir\r\n * @param {Number} level\r\n * @return {*}\r\n */\r\nexport function getFileNodes(\r\n option: { ignore: string[] | undefined; include: string[] | undefined } | undefined,\r\n nodes: Array<ItemType> = [],\r\n dir = path.resolve('./'),\r\n level = 0\r\n): Array<ItemType> {\r\n //File filtering -- full name with suffix required \u6587\u4EF6\u8FC7\u6EE4--\u9700\u8981\u5168\u79F0\u5E26\u540E\u7F00\r\n let ignore = [\r\n 'public',\r\n 'build',\r\n 'img',\r\n 'assets',\r\n 'mock',\r\n 'api',\r\n 'styles',\r\n 'node_modules',\r\n 'LICENSE',\r\n '.git',\r\n '.github',\r\n 'dist',\r\n '.husky',\r\n '.vscode',\r\n 'babel.config.js',\r\n 'prettier.config.js',\r\n 'commitlint.config.js',\r\n 'readme-file.js',\r\n 'vue.config.js',\r\n '.eslintrc.js',\r\n 'readme-md.js'\r\n ]\r\n //File suffix contains only \u6587\u4EF6\u540E\u7F00\u53EA\u5305\u542B\r\n let include = ['.js', '.vue', '.ts']\r\n\r\n if (option) {\r\n ignore = option.ignore || ignore\r\n include = option.include || include\r\n }\r\n const files = fs\r\n .readdirSync(dir)\r\n .map((item) => {\r\n const fullPath = path.join(dir, item)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n return {\r\n name: item,\r\n isDir,\r\n level,\r\n note: ''\r\n } as ItemType\r\n })\r\n //Sort folders and files, otherwise the generated will not correspond to the opening order of the editor \u5BF9\u6587\u4EF6\u5939\u548C\u6587\u4EF6\u8FDB\u884C\u6392\u5E8F,\u8981\u4E0D\u7136\u751F\u6210\u7684\u548C\u7F16\u8F91\u5668\u6253\u5F00\u7684\u987A\u5E8F\u4E0D\u5BF9\u5E94\r\n .sort((a, b) => {\r\n if (!a.isDir && b.isDir) return 1\r\n if (a.isDir && !b.isDir) return -1\r\n if ((a.isDir && b.isDir) || (!a.isDir && !b.isDir)) return 0\r\n return 0\r\n })\r\n for (let index = 0; index < files.length; index += 1) {\r\n const item = files[index]\r\n //Folder filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u5939\u8FC7\u6EE4\r\n const foldFlag = ignore.findIndex((obj: string) => obj === item.name)\r\n if (foldFlag === -1) {\r\n const fullPath = path.join(dir, item.name)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n if (isDir) {\r\n //recursion \u9012\u5F52\r\n getFileNodes(option, (item.children = []), fullPath, level + 1)\r\n nodes.push(item)\r\n } else {\r\n const i = fullPath.lastIndexOf('.')\r\n const lastName = fullPath.substring(i)\r\n //File filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u8FC7\u6EE4\r\n if (include.includes(lastName)) {\r\n const obj = getFile(fullPath)\r\n Object.assign(item, obj)\r\n item.suffix = lastName\r\n nodes.push(item)\r\n }\r\n }\r\n }\r\n }\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:Recursive file name + note \u9012\u5F52\u5F97\u5230\u6587\u4EF6\u540D+note\r\n * @param {Array} datas\r\n * @param {string} keys\r\n * @return {*}\r\n */\r\nfunction getNote(datas: Array<ItemType>, keys?: string[]) {\r\n const nodes = keys || []\r\n datas.forEach((obj: ItemType, index: Number) => {\r\n const last = index === datas.length - 1\r\n if (obj.children) {\r\n //fold\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n getNote(obj.children, nodes)\r\n }\r\n // file\r\n else {\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n }\r\n })\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:One obj generates one line of text \u4E00\u4E2Aobj\u751F\u6210\u4E00\u4E2A\u4E00\u884C\u6587\u5B57\r\n * @param {ItemType} obj\r\n * @param {Boolean} last Is it the last one \u662F\u4E0D\u662F\u6700\u540E\u4E00\u4E2A\r\n * @return {*}\r\n */\r\nfunction setMd(obj: ItemType, last: Boolean): string {\r\n let filesString = ''\r\n const blank = '\u2502 '.repeat(obj.level) // \u91CD\u590D\u7A7A\u767D\r\n const pre = `${blank}${last ? '\u2514\u2500\u2500' : '\u251C\u2500\u2500'} ${obj.name}`\r\n if (obj.isDir) {\r\n filesString += `${pre}\\n`\r\n } else {\r\n filesString += `${pre} ${obj.note}\\n`\r\n }\r\n return filesString\r\n}\r\n\r\n/**\r\n * @description: Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\n// function wirteJs(data: string, filePath: string) {\r\n// const file = path.resolve(__dirname, filePath)\r\n// const pre = 'export default'\r\n// // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n// fs.writeFile(file, pre + data, { encoding: 'utf8' }, (err) => {\r\n// console.error(err)\r\n// })\r\n// }\r\n/**\r\n * @description:Thousands format \u5343\u5206\u4F4D\u683C\u5F0F\u5316\r\n * @param {num} To format a number \u8981\u683C\u5F0F\u5316\u6570\u5B57\r\n * @return {string}\r\n */\r\nfunction format(num: number) {\r\n var reg = /\\d{1,3}(?=(\\d{3})+$)/g\r\n return (num + '').replace(reg, '$&,')\r\n}\r\n/**\r\n * @description: Generate statistics MD \u751F\u6210\u7EDF\u8BA1md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nfunction setCountMd(obj: secoutType) {\r\n const { rowTotleNumber, sizeTotleNumber, coutObj } = obj\r\n let countMd = ''\r\n let totle=0\r\n for (const key in coutObj) {\r\n const ele = coutObj[key]\r\n totle += ele\r\n countMd += `The suffix is ${key} has ${ele} files\\n`\r\n }\r\n countMd += `The totle has ${totle} files\\n`\r\n let md = `Total number of file lines: ${format(rowTotleNumber)},\r\nTotal number of codes: ${format(sizeTotleNumber)} \\n`\r\n md = countMd + md\r\n return md\r\n // wirteMd(md, `${path.resolve('./')}\\\\count-md.md`)\r\n}\r\n/**\r\n * @description: Get statistics \u5F97\u5230\u7EDF\u8BA1\r\n * @param {Array} nodes\r\n * @return {*}\r\n */\r\nfunction getCountMd(datas: Array<ItemType>) {\r\n let rowTotleNumber = 0\r\n let sizeTotleNumber = 0\r\n const coutObj: { [key: string]: number } = {}\r\n function getDeatle(nodes: Array<ItemType>) {\r\n nodes.forEach((obj: ItemType) => {\r\n if (obj.children) getDeatle(obj.children)\r\n else {\r\n if (!coutObj.hasOwnProperty(obj.suffix)) coutObj[obj.suffix] = 0\r\n coutObj[obj.suffix]++\r\n rowTotleNumber += obj.rowSize\r\n sizeTotleNumber += obj.size\r\n }\r\n })\r\n }\r\n getDeatle(datas)\r\n return {\r\n rowTotleNumber,\r\n sizeTotleNumber,\r\n coutObj\r\n }\r\n}\r\n\r\n/**\r\n * @description: Generate MD \u751F\u6210md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nexport function getMd(option?: { ignore: string[] | undefined; include: string[] | undefined } | undefined) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** run location: ', path.resolve('./')+'\\n')\r\n const nodes = getFileNodes(option)\r\n // \u5F97\u5230md\u5BF9\u8C61\r\n // wirteJs(JSON.stringify(nodes), __dirname + '\\\\readme-file.js')\r\n const countMdObj = getCountMd(nodes)\r\n const coutMd = setCountMd(countMdObj)\r\n console.log('\\x1B[33m%s\\x1b[0m', coutMd)\r\n const note = getNote(nodes) // \u5F97\u5230\u6240\u6709note\u7684\u6570\u7EC4\r\n const md = note.join('')+'\\n' // \u6570\u7EC4\u8F6C\u5B57\u7B26\u4E32\r\n if (md.length > 0) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** Automatic generation completed ! ')\r\n }\r\n\r\n return md + coutMd\r\n}\r\n\r\n/**\r\n * @description:Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\nexport function wirteMd(data: string, filePath: string) {\r\n const file = path.resolve(__dirname, filePath)\r\n // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n fs.writeFile(file, data, { encoding: 'utf8' }, () => {\r\n console.log('Write successful')\r\n })\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AAOjB,iBAAiB,MAA+B;AAC9C,QAAM,MAAM,kBAAG,aAAa,MAAM;AAClC,QAAM,OAAO,IAAI;AACjB,QAAM,OAAO,IAAI,MAAM;AACvB,QAAM,UAAU,KAAK;AACrB,QAAM,IACJ,KAAK,GAAG,QAAQ,cAAc,MAC7B,MAAK,GAAG,QAAQ,SAAS,MAAM,KAAK,GAAG,QAAQ,QAAQ,MAAM,KAAK,GAAG,QAAQ,QAAQ,MAClF,KAAK,KACL;AACN,SAAO,EAAE,MAAM,GAAG,MAAM;AAAA;AAuBnB,sBACL,QACA,QAAyB,IACzB,MAAM,oBAAK,QAAQ,OACnB,QAAQ,GACS;AAEjB,MAAI,SAAS;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGF,MAAI,UAAU,CAAC,OAAO,QAAQ;AAE9B,MAAI,QAAQ;AACV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AQ,IAAI,qBAAqB,sBAAsB,oBAAK,QAAQ,QAAM;AAC1E,QAAM,QAAQ,aAAa;AAG3B,QAAM,aAAa,WAAW;AAC9B,QAAM,SAAS,WAAW;AAC1B,UAAQ,IAAI,qBAAqB;AACjC,QAAM,OAAO,QAAQ;AACrB,QAAM,KAAK,KAAK,KAAK,MAAI;AACzB,MAAI,GAAG,SAAS,GAAG;AACjB,YAAQ,IAAI,qBAAqB;AAAA;AAGnC,SAAO,KAAK;AAAA;AAQP,iBAAiB,MAAc,UAAkB;AACtD,QAAM,OAAO,oBAAK,QAAQ,WAAW;AAErC,oBAAG,UAAU,MAAM,MAAM,EAAE,UAAU,UAAU,MAAM;AACnD,YAAQ,IAAI;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
declare type ItemType = {
|
|
2
2
|
name: string;
|
|
3
3
|
isDir: boolean;
|
|
4
4
|
level: number;
|
|
5
5
|
note: string;
|
|
6
|
+
size: number;
|
|
7
|
+
suffix: string;
|
|
8
|
+
rowSize: number;
|
|
6
9
|
children?: ItemType[];
|
|
7
10
|
};
|
|
8
11
|
export declare function getFileNodes(option: {
|
|
@@ -13,3 +16,5 @@ export declare function getMd(option?: {
|
|
|
13
16
|
ignore: string[] | undefined;
|
|
14
17
|
include: string[] | undefined;
|
|
15
18
|
} | undefined): string;
|
|
19
|
+
export declare function wirteMd(data: string, filePath: string): void;
|
|
20
|
+
export {};
|
package/lib/index.esm.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* agmd v0.2.
|
|
2
|
+
* agmd v0.2.9
|
|
3
3
|
* author:kakajun <253495832@qq.com>
|
|
4
|
-
*
|
|
4
|
+
* Tue Mar 22 2022 21:32:12 GMT+0800 (中国标准时间)
|
|
5
5
|
*/
|
|
6
6
|
// src/index.ts
|
|
7
7
|
import fs from "fs";
|
|
8
8
|
import path from "path";
|
|
9
9
|
function getFile(file) {
|
|
10
10
|
const str = fs.readFileSync(file, "utf-8");
|
|
11
|
+
const size = str.length;
|
|
11
12
|
const sarr = str.split(/[\n,]/g);
|
|
13
|
+
const rowSize = sarr.length;
|
|
12
14
|
const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
|
|
13
|
-
return f;
|
|
15
|
+
return { note: f, size, rowSize };
|
|
14
16
|
}
|
|
15
17
|
function getFileNodes(option, nodes = [], dir = path.resolve("./"), level = 0) {
|
|
16
18
|
let ignore = [
|
|
19
|
+
"public",
|
|
20
|
+
"build",
|
|
17
21
|
"img",
|
|
22
|
+
"assets",
|
|
23
|
+
"mock",
|
|
24
|
+
"api",
|
|
18
25
|
"styles",
|
|
19
26
|
"node_modules",
|
|
20
27
|
"LICENSE",
|
|
@@ -23,7 +30,12 @@ function getFileNodes(option, nodes = [], dir = path.resolve("./"), level = 0) {
|
|
|
23
30
|
"dist",
|
|
24
31
|
".husky",
|
|
25
32
|
".vscode",
|
|
33
|
+
"babel.config.js",
|
|
34
|
+
"prettier.config.js",
|
|
35
|
+
"commitlint.config.js",
|
|
26
36
|
"readme-file.js",
|
|
37
|
+
"vue.config.js",
|
|
38
|
+
".eslintrc.js",
|
|
27
39
|
"readme-md.js"
|
|
28
40
|
];
|
|
29
41
|
let include = [".js", ".vue", ".ts"];
|
|
@@ -51,7 +63,6 @@ function getFileNodes(option, nodes = [], dir = path.resolve("./"), level = 0) {
|
|
|
51
63
|
});
|
|
52
64
|
for (let index = 0; index < files.length; index += 1) {
|
|
53
65
|
const item = files[index];
|
|
54
|
-
let note = "";
|
|
55
66
|
const foldFlag = ignore.findIndex((obj) => obj === item.name);
|
|
56
67
|
if (foldFlag === -1) {
|
|
57
68
|
const fullPath = path.join(dir, item.name);
|
|
@@ -63,8 +74,9 @@ function getFileNodes(option, nodes = [], dir = path.resolve("./"), level = 0) {
|
|
|
63
74
|
const i = fullPath.lastIndexOf(".");
|
|
64
75
|
const lastName = fullPath.substring(i);
|
|
65
76
|
if (include.includes(lastName)) {
|
|
66
|
-
|
|
67
|
-
item
|
|
77
|
+
const obj = getFile(fullPath);
|
|
78
|
+
Object.assign(item, obj);
|
|
79
|
+
item.suffix = lastName;
|
|
68
80
|
nodes.push(item);
|
|
69
81
|
}
|
|
70
82
|
}
|
|
@@ -100,18 +112,74 @@ function setMd(obj, last) {
|
|
|
100
112
|
}
|
|
101
113
|
return filesString;
|
|
102
114
|
}
|
|
115
|
+
function format(num) {
|
|
116
|
+
var reg = /\d{1,3}(?=(\d{3})+$)/g;
|
|
117
|
+
return (num + "").replace(reg, "$&,");
|
|
118
|
+
}
|
|
119
|
+
function setCountMd(obj) {
|
|
120
|
+
const { rowTotleNumber, sizeTotleNumber, coutObj } = obj;
|
|
121
|
+
let countMd = "";
|
|
122
|
+
let totle = 0;
|
|
123
|
+
for (const key in coutObj) {
|
|
124
|
+
const ele = coutObj[key];
|
|
125
|
+
totle += ele;
|
|
126
|
+
countMd += `The suffix is ${key} has ${ele} files
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
countMd += `The totle has ${totle} files
|
|
130
|
+
`;
|
|
131
|
+
let md = `Total number of file lines: ${format(rowTotleNumber)},
|
|
132
|
+
Total number of codes: ${format(sizeTotleNumber)}
|
|
133
|
+
`;
|
|
134
|
+
md = countMd + md;
|
|
135
|
+
return md;
|
|
136
|
+
}
|
|
137
|
+
function getCountMd(datas) {
|
|
138
|
+
let rowTotleNumber = 0;
|
|
139
|
+
let sizeTotleNumber = 0;
|
|
140
|
+
const coutObj = {};
|
|
141
|
+
function getDeatle(nodes) {
|
|
142
|
+
nodes.forEach((obj) => {
|
|
143
|
+
if (obj.children)
|
|
144
|
+
getDeatle(obj.children);
|
|
145
|
+
else {
|
|
146
|
+
if (!coutObj.hasOwnProperty(obj.suffix))
|
|
147
|
+
coutObj[obj.suffix] = 0;
|
|
148
|
+
coutObj[obj.suffix]++;
|
|
149
|
+
rowTotleNumber += obj.rowSize;
|
|
150
|
+
sizeTotleNumber += obj.size;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
getDeatle(datas);
|
|
155
|
+
return {
|
|
156
|
+
rowTotleNumber,
|
|
157
|
+
sizeTotleNumber,
|
|
158
|
+
coutObj
|
|
159
|
+
};
|
|
160
|
+
}
|
|
103
161
|
function getMd(option) {
|
|
104
|
-
console.log("\x1B[36m%s\x1B[0m", "*** run location: ", path.resolve("./"));
|
|
162
|
+
console.log("\x1B[36m%s\x1B[0m", "*** run location: ", path.resolve("./") + "\n");
|
|
105
163
|
const nodes = getFileNodes(option);
|
|
164
|
+
const countMdObj = getCountMd(nodes);
|
|
165
|
+
const coutMd = setCountMd(countMdObj);
|
|
166
|
+
console.log("\x1B[33m%s\x1B[0m", coutMd);
|
|
106
167
|
const note = getNote(nodes);
|
|
107
|
-
const md = note.join("");
|
|
168
|
+
const md = note.join("") + "\n";
|
|
108
169
|
if (md.length > 0) {
|
|
109
170
|
console.log("\x1B[36m%s\x1B[0m", "*** Automatic generation completed ! ");
|
|
110
171
|
}
|
|
111
|
-
return md;
|
|
172
|
+
return md + coutMd;
|
|
173
|
+
}
|
|
174
|
+
function wirteMd(data, filePath) {
|
|
175
|
+
const file = path.resolve(__dirname, filePath);
|
|
176
|
+
fs.writeFile(file, data, { encoding: "utf8" }, () => {
|
|
177
|
+
console.log("Write successful");
|
|
178
|
+
});
|
|
112
179
|
}
|
|
113
180
|
export {
|
|
114
181
|
getFileNodes,
|
|
115
|
-
getMd
|
|
182
|
+
getMd,
|
|
183
|
+
wirteMd
|
|
116
184
|
};
|
|
117
185
|
//# sourceMappingURL=index.esm.js.map
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @description:Gets the header comment of the file \u83B7\u53D6\u6587\u4EF6\u7684\u5934\u90E8\u6CE8\u91CA\r\n * @param {*} file\r\n * @return {*}\r\n */\r\nfunction getFile(file: fs.PathOrFileDescriptor) {\r\n const str = fs.readFileSync(file, 'utf-8')\r\n const sarr = str.split(/[\\n,]/g)\r\n
|
|
5
|
-
"mappings": ";;;;;;AAAA;AACA;AAOA,iBAAiB,MAA+B;AAC9C,QAAM,MAAM,GAAG,aAAa,MAAM;AAClC,QAAM,OAAO,IAAI,MAAM;
|
|
4
|
+
"sourcesContent": ["import fs from 'fs'\r\nimport path from 'path'\r\n\r\n/**\r\n * @description:Gets the header comment of the file \u83B7\u53D6\u6587\u4EF6\u7684\u5934\u90E8\u6CE8\u91CA\r\n * @param {*} file\r\n * @return {*}\r\n */\r\nfunction getFile(file: fs.PathOrFileDescriptor) {\r\n const str = fs.readFileSync(file, 'utf-8')\r\n const size = str.length\r\n const sarr = str.split(/[\\n,]/g)\r\n const rowSize = sarr.length\r\n const f =\r\n sarr[0].indexOf('eslint') === -1 &&\r\n (sarr[0].indexOf('-->') > -1 || sarr[0].indexOf('*/') > -1 || sarr[0].indexOf('//') > -1)\r\n ? sarr[0]\r\n : ''\r\n return { note: f, size, rowSize }\r\n}\r\n\r\ntype ItemType = {\r\n name: string\r\n isDir: boolean\r\n level: number\r\n note: string\r\n size: number\r\n suffix: string\r\n rowSize: number\r\n children?: ItemType[]\r\n}\r\n\r\ntype secoutType = { rowTotleNumber: number; sizeTotleNumber: number; coutObj: { [key: string]: number } }\r\n\r\n/**\r\n * @description:Generate node information for all files \u751F\u6210\u6240\u6709\u6587\u4EF6\u7684node\u4FE1\u606F\r\n * @param {Array} nodes\r\n * @param {*} dir\r\n * @param {Number} level\r\n * @return {*}\r\n */\r\nexport function getFileNodes(\r\n option: { ignore: string[] | undefined; include: string[] | undefined } | undefined,\r\n nodes: Array<ItemType> = [],\r\n dir = path.resolve('./'),\r\n level = 0\r\n): Array<ItemType> {\r\n //File filtering -- full name with suffix required \u6587\u4EF6\u8FC7\u6EE4--\u9700\u8981\u5168\u79F0\u5E26\u540E\u7F00\r\n let ignore = [\r\n 'public',\r\n 'build',\r\n 'img',\r\n 'assets',\r\n 'mock',\r\n 'api',\r\n 'styles',\r\n 'node_modules',\r\n 'LICENSE',\r\n '.git',\r\n '.github',\r\n 'dist',\r\n '.husky',\r\n '.vscode',\r\n 'babel.config.js',\r\n 'prettier.config.js',\r\n 'commitlint.config.js',\r\n 'readme-file.js',\r\n 'vue.config.js',\r\n '.eslintrc.js',\r\n 'readme-md.js'\r\n ]\r\n //File suffix contains only \u6587\u4EF6\u540E\u7F00\u53EA\u5305\u542B\r\n let include = ['.js', '.vue', '.ts']\r\n\r\n if (option) {\r\n ignore = option.ignore || ignore\r\n include = option.include || include\r\n }\r\n const files = fs\r\n .readdirSync(dir)\r\n .map((item) => {\r\n const fullPath = path.join(dir, item)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n return {\r\n name: item,\r\n isDir,\r\n level,\r\n note: ''\r\n } as ItemType\r\n })\r\n //Sort folders and files, otherwise the generated will not correspond to the opening order of the editor \u5BF9\u6587\u4EF6\u5939\u548C\u6587\u4EF6\u8FDB\u884C\u6392\u5E8F,\u8981\u4E0D\u7136\u751F\u6210\u7684\u548C\u7F16\u8F91\u5668\u6253\u5F00\u7684\u987A\u5E8F\u4E0D\u5BF9\u5E94\r\n .sort((a, b) => {\r\n if (!a.isDir && b.isDir) return 1\r\n if (a.isDir && !b.isDir) return -1\r\n if ((a.isDir && b.isDir) || (!a.isDir && !b.isDir)) return 0\r\n return 0\r\n })\r\n for (let index = 0; index < files.length; index += 1) {\r\n const item = files[index]\r\n //Folder filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u5939\u8FC7\u6EE4\r\n const foldFlag = ignore.findIndex((obj: string) => obj === item.name)\r\n if (foldFlag === -1) {\r\n const fullPath = path.join(dir, item.name)\r\n const isDir = fs.lstatSync(fullPath).isDirectory()\r\n if (isDir) {\r\n //recursion \u9012\u5F52\r\n getFileNodes(option, (item.children = []), fullPath, level + 1)\r\n nodes.push(item)\r\n } else {\r\n const i = fullPath.lastIndexOf('.')\r\n const lastName = fullPath.substring(i)\r\n //File filtering is handled here \u8FD9\u91CC\u5904\u7406\u6587\u4EF6\u8FC7\u6EE4\r\n if (include.includes(lastName)) {\r\n const obj = getFile(fullPath)\r\n Object.assign(item, obj)\r\n item.suffix = lastName\r\n nodes.push(item)\r\n }\r\n }\r\n }\r\n }\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:Recursive file name + note \u9012\u5F52\u5F97\u5230\u6587\u4EF6\u540D+note\r\n * @param {Array} datas\r\n * @param {string} keys\r\n * @return {*}\r\n */\r\nfunction getNote(datas: Array<ItemType>, keys?: string[]) {\r\n const nodes = keys || []\r\n datas.forEach((obj: ItemType, index: Number) => {\r\n const last = index === datas.length - 1\r\n if (obj.children) {\r\n //fold\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n getNote(obj.children, nodes)\r\n }\r\n // file\r\n else {\r\n const md = setMd(obj, last)\r\n nodes.push(md)\r\n }\r\n })\r\n return nodes\r\n}\r\n\r\n/**\r\n * @description:One obj generates one line of text \u4E00\u4E2Aobj\u751F\u6210\u4E00\u4E2A\u4E00\u884C\u6587\u5B57\r\n * @param {ItemType} obj\r\n * @param {Boolean} last Is it the last one \u662F\u4E0D\u662F\u6700\u540E\u4E00\u4E2A\r\n * @return {*}\r\n */\r\nfunction setMd(obj: ItemType, last: Boolean): string {\r\n let filesString = ''\r\n const blank = '\u2502 '.repeat(obj.level) // \u91CD\u590D\u7A7A\u767D\r\n const pre = `${blank}${last ? '\u2514\u2500\u2500' : '\u251C\u2500\u2500'} ${obj.name}`\r\n if (obj.isDir) {\r\n filesString += `${pre}\\n`\r\n } else {\r\n filesString += `${pre} ${obj.note}\\n`\r\n }\r\n return filesString\r\n}\r\n\r\n/**\r\n * @description: Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\n// function wirteJs(data: string, filePath: string) {\r\n// const file = path.resolve(__dirname, filePath)\r\n// const pre = 'export default'\r\n// // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n// fs.writeFile(file, pre + data, { encoding: 'utf8' }, (err) => {\r\n// console.error(err)\r\n// })\r\n// }\r\n/**\r\n * @description:Thousands format \u5343\u5206\u4F4D\u683C\u5F0F\u5316\r\n * @param {num} To format a number \u8981\u683C\u5F0F\u5316\u6570\u5B57\r\n * @return {string}\r\n */\r\nfunction format(num: number) {\r\n var reg = /\\d{1,3}(?=(\\d{3})+$)/g\r\n return (num + '').replace(reg, '$&,')\r\n}\r\n/**\r\n * @description: Generate statistics MD \u751F\u6210\u7EDF\u8BA1md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nfunction setCountMd(obj: secoutType) {\r\n const { rowTotleNumber, sizeTotleNumber, coutObj } = obj\r\n let countMd = ''\r\n let totle=0\r\n for (const key in coutObj) {\r\n const ele = coutObj[key]\r\n totle += ele\r\n countMd += `The suffix is ${key} has ${ele} files\\n`\r\n }\r\n countMd += `The totle has ${totle} files\\n`\r\n let md = `Total number of file lines: ${format(rowTotleNumber)},\r\nTotal number of codes: ${format(sizeTotleNumber)} \\n`\r\n md = countMd + md\r\n return md\r\n // wirteMd(md, `${path.resolve('./')}\\\\count-md.md`)\r\n}\r\n/**\r\n * @description: Get statistics \u5F97\u5230\u7EDF\u8BA1\r\n * @param {Array} nodes\r\n * @return {*}\r\n */\r\nfunction getCountMd(datas: Array<ItemType>) {\r\n let rowTotleNumber = 0\r\n let sizeTotleNumber = 0\r\n const coutObj: { [key: string]: number } = {}\r\n function getDeatle(nodes: Array<ItemType>) {\r\n nodes.forEach((obj: ItemType) => {\r\n if (obj.children) getDeatle(obj.children)\r\n else {\r\n if (!coutObj.hasOwnProperty(obj.suffix)) coutObj[obj.suffix] = 0\r\n coutObj[obj.suffix]++\r\n rowTotleNumber += obj.rowSize\r\n sizeTotleNumber += obj.size\r\n }\r\n })\r\n }\r\n getDeatle(datas)\r\n return {\r\n rowTotleNumber,\r\n sizeTotleNumber,\r\n coutObj\r\n }\r\n}\r\n\r\n/**\r\n * @description: Generate MD \u751F\u6210md\r\n * @param {object} option\r\n * @return {*}\r\n */\r\nexport function getMd(option?: { ignore: string[] | undefined; include: string[] | undefined } | undefined) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** run location: ', path.resolve('./')+'\\n')\r\n const nodes = getFileNodes(option)\r\n // \u5F97\u5230md\u5BF9\u8C61\r\n // wirteJs(JSON.stringify(nodes), __dirname + '\\\\readme-file.js')\r\n const countMdObj = getCountMd(nodes)\r\n const coutMd = setCountMd(countMdObj)\r\n console.log('\\x1B[33m%s\\x1b[0m', coutMd)\r\n const note = getNote(nodes) // \u5F97\u5230\u6240\u6709note\u7684\u6570\u7EC4\r\n const md = note.join('')+'\\n' // \u6570\u7EC4\u8F6C\u5B57\u7B26\u4E32\r\n if (md.length > 0) {\r\n console.log('\\x1B[36m%s\\x1B[0m', '*** Automatic generation completed ! ')\r\n }\r\n\r\n return md + coutMd\r\n}\r\n\r\n/**\r\n * @description:Write the result to JS file \u628A\u7ED3\u679C\u5199\u5165\u5230js\u6587\u4EF6\r\n * @param {data} \u8981\u5199\u7684\u6570\u636E\r\n * @return {fileName} \u8981\u5199\u5165\u6587\u4EF6\u5730\u5740\r\n */\r\nexport function wirteMd(data: string, filePath: string) {\r\n const file = path.resolve(__dirname, filePath)\r\n // \u5F02\u6B65\u5199\u5165\u6570\u636E\u5230\u6587\u4EF6\r\n fs.writeFile(file, data, { encoding: 'utf8' }, () => {\r\n console.log('Write successful')\r\n })\r\n}\r\n"],
|
|
5
|
+
"mappings":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HANGED
|
@@ -1,61 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "agmd",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "auto generate markdown for node",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"node",
|
|
7
|
-
"auto",
|
|
8
|
-
"generate",
|
|
9
|
-
"md",
|
|
10
|
-
"markdown"
|
|
11
|
-
],
|
|
12
|
-
"main": "lib/index.cjs.js",
|
|
13
|
-
"module": "lib/index.esm.js",
|
|
14
|
-
"typings": "lib/index.d.ts",
|
|
15
|
-
"bin": {
|
|
16
|
-
"agmd": "./bin/agmd.js"
|
|
17
|
-
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"dev": "npx nodemon src/agmd.ts",
|
|
20
|
-
"agmd":"npx agmd --ignore lib,node_modules,dist --include .js,.ts,.vue",
|
|
21
|
-
"lint": "eslint \"src/**/*.{ts}\" --max-warnings=0",
|
|
22
|
-
"build": "node script/build.js",
|
|
23
|
-
"prepare": "husky install",
|
|
24
|
-
"lint-fix": "eslint --fix --ext .js,.ts",
|
|
25
|
-
"test": "npm run build && node bin/agmd"
|
|
26
|
-
},
|
|
27
|
-
"author": "kakajun <253495832@qq.com>",
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "git@github.com:kakajun/auto-generate-md.git"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/node": "^17.0.0",
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
|
35
|
-
"@typescript-eslint/parser": "^4.31.0",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "agmd",
|
|
3
|
+
"version": "0.2.10",
|
|
4
|
+
"description": "auto generate markdown for node",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"node",
|
|
7
|
+
"auto",
|
|
8
|
+
"generate",
|
|
9
|
+
"md",
|
|
10
|
+
"markdown"
|
|
11
|
+
],
|
|
12
|
+
"main": "lib/index.cjs.js",
|
|
13
|
+
"module": "lib/index.esm.js",
|
|
14
|
+
"typings": "lib/index.d.ts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"agmd": "./bin/agmd.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "npx nodemon src/agmd.ts",
|
|
20
|
+
"agmd": "npx agmd --ignore lib,node_modules,dist --include .js,.ts,.vue",
|
|
21
|
+
"lint": "eslint \"src/**/*.{ts}\" --max-warnings=0",
|
|
22
|
+
"build": "node script/build.js",
|
|
23
|
+
"prepare": "husky install",
|
|
24
|
+
"lint-fix": "eslint --fix --ext .js,.ts",
|
|
25
|
+
"test": "npm run build && node bin/agmd"
|
|
26
|
+
},
|
|
27
|
+
"author": "kakajun <253495832@qq.com>",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git@github.com:kakajun/auto-generate-md.git"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^17.0.0",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
|
35
|
+
"@typescript-eslint/parser": "^4.31.0",
|
|
36
|
+
"agmd": "^0.2.2",
|
|
37
|
+
"arg": "5.0.1",
|
|
38
|
+
"esbuild": "^0.14.5",
|
|
39
|
+
"esbuild-plugin-d.ts": "^1.1.0",
|
|
40
|
+
"eslint": "^8.8.0",
|
|
41
|
+
"eslint-config-prettier": "^8.3.0",
|
|
42
|
+
"fs-extra": "^10.0.0",
|
|
43
|
+
"husky": "^7.0.2",
|
|
44
|
+
"lint-staged": "^11.1.2",
|
|
45
|
+
"nodemon": "^2.0.15",
|
|
46
|
+
"prettier": "^2.5.1",
|
|
47
|
+
"ts-node": "^10.7.0",
|
|
48
|
+
"typescript": "^4.5.5"
|
|
49
|
+
},
|
|
50
|
+
"lint-staged": {
|
|
51
|
+
"*.{ts,tsx,js}": "prettier --write",
|
|
52
|
+
"*.{ts,tsx}": "eslint --fix"
|
|
53
|
+
},
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/kakajun/auto-generate-md/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/kakajun/auto-generate-md",
|
|
59
|
+
"files": [
|
|
60
|
+
"bin",
|
|
61
|
+
"lib"
|
|
62
|
+
]
|
|
63
|
+
}
|