agmd 0.1.4 → 0.2.9

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) <year> <author>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <year> <author>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.EN.md CHANGED
@@ -1,108 +1,175 @@
1
- # agmd(auto generate md)
2
-
3
-
4
-
5
- >If you need to generate documents, enter 'AGMD' in the console under the folder to automatically generate the directory MD description
6
-
7
-
8
-
9
- [![]( https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667 )]( https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667 )
10
-
11
-
12
-
13
-
14
- ### Case
15
-
16
-
17
-
18
- ! [image]( https://github.com/kakajun/auto-generate-md/blob/master/md.png )
19
-
20
-
21
-
22
- ### Method of use
23
-
24
- Node environment is required
25
-
26
- 1. Global installation (Global installation is required, otherwise it will be reported that the "AGMD" item cannot be recognized as the name of cmdlet, function, script file or runnable program)
27
-
28
-
29
-
30
- > npm i agmd -g
31
-
32
-
33
-
34
- After installation, enter 'AGMD' under the folder where MD needs to be recorded, and the names of folders and files under the relative path will be automatically generated. If comments are written in the header of the file, it will be brought together to automatically generate MD files. The generated file name is' readme md.md ', and the path is the path just entered. At the same level, for the development of large projects, this script may save you some time.
35
-
36
-
37
-
38
- Example is some of the files I prepared for the demonstration, which is of no other use
39
-
40
-
41
-
42
- 2. Advanced usage
43
-
44
- Some need to insert automatically generated documents into an automatically generated MD. the plug-in exports the automatically generated MD data method, and 'getfilenodes' obtains the specific information of all files. You can DIY different documents
45
-
46
- >const { getFileNodes, getMd } = require('agmd')
47
-
48
-
49
-
50
- In es:
51
-
52
- >import {getFileNodes, getMd} from 'agmd'
53
-
54
-
55
-
56
- -Getfilenodes can obtain information related to specific files
57
-
58
- -Getmd gets the final output information
59
-
60
-
61
-
62
- ### Creative background
63
-
64
-
65
-
66
- 1. Have you been asked to write a MD description of the directory file?
67
-
68
- 2. Or if the project directory and files have been relocated and reconstructed, the directory description in the MD file needs to be modified again
69
-
70
- 3. After taking over the old project and reading the MD instructions, you can see the file functions in the folder at a glance instead of clicking on the corresponding file
71
-
72
- 4. You need to take notes to analyze the source code project
73
-
74
-
75
-
76
- ### Function
77
-
78
-
79
-
80
- 1. Automatically generate folder names and files matching directories (sorted by name)
81
-
82
- 2. Automatically determine the hierarchical directory and indent it
83
-
84
- 3. If there is a comment at the top of the file, it will be judged automatically
85
-
86
- 4. Support recursive search of subordinate files in any file directory (do not execute in a large directory!!! Recursion until there are no files in this directory)
87
-
88
- 5. Current support record js . vue . Ts and folders, of course, also support others. I've written so much about this version. You can mention PR if you need it later
89
-
90
-
91
-
92
- ### Related articles
93
-
94
-
95
-
96
- [Nuggets - auto generate directory MD file]( https://juejin.cn/post/7030030599268073508 )
97
-
98
-
99
-
100
- ### Update record
101
-
102
- 0.1. 0
103
-
104
- 1. Package with esbuild
105
-
106
- 2. It is written in eslint and preter specifications
107
-
108
- 3. Rewrite with TS
1
+ # agmd(auto generate md)
2
+
3
+
4
+
5
+ >For any document that needs to be generated, enter 'AGMD' in the console under the folder to automatically generate the directory MD description
6
+
7
+
8
+
9
+ [![]( https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667 )]( https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667 )
10
+
11
+
12
+ 🚀 Features
13
+
14
+ 🔥 Written in TypeScript
15
+
16
+ 🔋 build with esbuild
17
+
18
+ 💡 easy get foldName and fileName.
19
+
20
+
21
+
22
+ ### Case
23
+
24
+
25
+
26
+ ! [image]( https://github.com/kakajun/auto-generate-md/blob/master/md2.png )
27
+
28
+
29
+
30
+ ### Method of use
31
+
32
+ Node environment is required
33
+
34
+ 1. Global installation
35
+
36
+ > npm i agmd -g
37
+
38
+
39
+
40
+ After installation, enter 'AGMD' under the folder where MD needs to be recorded, and the names of folders and files under the relative path will be automatically generated. If comments are written in the header of the file, it will be brought together to automatically generate MD files. The generated file name is' readme md.md ', and the path is the path just entered. At the same level, for the development of large projects, this script may save you some time.
41
+
42
+
43
+
44
+ 2. Install as a dependency
45
+
46
+ > npm i agmd -D
47
+
48
+
49
+
50
+ In package Configure AGMD in scripts of JSON: NPX AGMD -- ignore lib, node_ modules,dist --include . js,. ts,. Vue can automatically update the document with the command line every time it is started or packaged
51
+
52
+
53
+
54
+
55
+ Example is some of the files I prepared for the demonstration, which is of no other use
56
+
57
+
58
+
59
+ 3. Advanced usage
60
+
61
+ Some need to insert the automatically generated documents into an automatically generated MD. the plug-in exports the automatically generated MD data method, and 'getfilenodes' obtains the specific information of all files. You can DIY different documents (the method name does not need to be remembered, because it is written by TS, so it will be automatically clicked)
62
+
63
+ >const agmd = require('agmd')
64
+
65
+
66
+
67
+ In es:
68
+
69
+ >import agmd from 'agmd'
70
+
71
+
72
+
73
+ - AGMD Getfilenodes () can obtain information related to specific files, and this function can pass a parameter
74
+
75
+
76
+
77
+ - agmd. Getmd() gets the final output information
78
+
79
+ Note: the above two methods can pass an option input parameter in the following format:
80
+
81
+ option: { ignore: string[] | undefined; include: string[] | undefined }
82
+
83
+ #### Command line parameter description
84
+
85
+ 1. Use AGMD - h to view help
86
+
87
+ 2. You can bring -- ignore to ignore the output file or folder. The default is: IMG, styles, node_ modules,LICENSE,. git,. github,dist,. husky,. vscode,readme-file. js,readme-md.js
88
+
89
+ 3. You can bring -- include. Only files with this suffix are required to be output. By default, only files are output js,. vue,. TS, you can add JSX, JSON, etc
90
+
91
+
92
+
93
+ ### Creative background
94
+
95
+ 1. Have you been asked to write a MD description of the directory file?
96
+
97
+ 2. Or if the project directory and files are reconstructed after being moved, the directory description in the MD file needs to be modified again
98
+
99
+ 3. After taking over the old project and reading the MD instructions, you can see the file functions in the folder at a glance, rather than clicking on the corresponding file
100
+
101
+ 4. You need to take notes to analyze the source code project
102
+
103
+
104
+
105
+ ### Function
106
+
107
+ 1. Automatically generate folder names and files matching directories (sorted by name)
108
+
109
+ 2. Automatically determine the hierarchical directory and indent it
110
+
111
+ 3. If there is a comment at the top of the file, it will be judged automatically
112
+
113
+ 4. Support recursive search of subordinate files in any file directory (do not execute in a large directory!!! Recursion until there are no files in this directory)
114
+
115
+ 5. Support command line parameter configuration, and can customize ignore files and filter suffix files
116
+
117
+ 6. Command line parsing
118
+
119
+
120
+
121
+ `Usage: agmd--include str--ignore str
122
+
123
+
124
+
125
+ Options:
126
+
127
+ --include string / -i string.......... include file extension
128
+
129
+ --ignore string / -in string........... ignore file or fold
130
+
131
+
132
+
133
+ Str deafult:
134
+
135
+ --ignore / -i img,styles,node_ modules,LICENSE,. git,. github,dist,. husky,. vscode,readme-file. js,readme-md.js
136
+
137
+ --include / -in . js,. vue,. ts
138
+
139
+
140
+
141
+ Note:
142
+
143
+ There should be no space between strings in a configuration
144
+
145
+
146
+
147
+ Examples:
148
+
149
+ $ agmd --ignore lib,node_ modules,dist --include . js,. ts,. vue`
150
+
151
+
152
+
153
+ ### Related articles
154
+
155
+ [Nuggets - auto generate directory MD file]( https://juejin.cn/post/7030030599268073508 )
156
+
157
+
158
+
159
+ ### Update record
160
+
161
+ 0.1.3
162
+
163
+ 1. Package with esbuild
164
+
165
+ 2. It is written in eslint and preter specification
166
+
167
+ 3. Rewrite with TS
168
+
169
+ 4. Support gitee one key synchronization test11253123
170
+
171
+
172
+
173
+ 0.2.0
174
+
175
+ Support command-line parsing parameters, and can transfer parameters dynamically
package/README.md CHANGED
@@ -1,57 +1,103 @@
1
- # agmd(auto generate md)
2
-
3
- > 在任何需要生成文档的,文件夹下的控制台中输入`agmd`, 就能自动生成目录 md 说明
4
-
5
- [![](https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667)](https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667)
6
-
7
- 简体中文 | [English](https://github.com/kakajun/auto-generate-md/blob/master/README.EN.md)
8
-
9
- ### 案例
10
-
11
- ![image](https://github.com/kakajun/auto-generate-md/blob/master/md.png)
12
-
13
- ### 使用方法
14
- 需要有node环境
15
- 1. 全局安装(必须全局安装,否则会报`无法将“agmd”项识别为 cmdlet、函数、脚本文件或可运行程序的名称`)
16
-
17
- > npm i agmd -g
18
-
19
- 安装完成后,在需要记录 md 的文件夹下面输入`agmd`,会自动生成相对路径下的文件夹和文件的名字,如果文件里面还有在头部写注释的话,那么会一并带过来自动生成 md 文件。生成的文件名为`readme-md.md`, 路径为刚刚输入命名的路径同级别下,对于工程比较大的开发来说,这个脚本或许会帮你省下些许时间。
20
-
21
- example,是我为演示准备的一些文件,并没有其他用
22
-
23
- 2. 高级用法
24
- 有些需要把自动生成的文档插入到某个自动生成的 md 当中, 该插件导出了自动生成的 md 数据方法, 还有`getFileNodes`获得所有文件的具体信息, 可以 DIY 做出不同的文档
25
- >const { getFileNodes, getMd } = require('agmd')
26
-
27
- es中:
28
- >import {getFileNodes, getMd} from 'agmd'
29
-
30
- - 其中 getFileNodes 可以获得具体文件相关的信息
31
- - getMd 得到最终输出的信息
32
-
33
- ### 创作背景
34
-
35
- 1. 大家有没有被要求写一个目录文件的 md 说明呢?
36
- 2. 或者工程目录和文件被移动位置重构了,这时还需要重新修改 md 文件里面的目录说明
37
- 3. 接手老工程,看了 md 说明,能对文件夹里面的文件功能做到一目了然,而不是点开对应文件去看
38
- 4. 分析源码工程需要做点笔记
39
-
40
- ### 功能
41
-
42
- 1. 自动生成匹配目录的文件夹名和文件(已经按名称进行排序)
43
- 2. 自动进行层级目录判断进行缩进
44
- 3. 如果文件顶部有注释, 那么会自动进行判断
45
- 4. 支持在任意文件目录下递归查找下级文件(不要在很大目录下执行啊!!!递归直到该级目录下没有文件为止)
46
- 5. 目前支持记录 .js .vue .ts 和文件夹, 当然也支持其他, 这个版本我就写这么多, 后续有需要的可以提 pr
47
-
48
- ### 相关文章
49
-
50
- [掘金-自动生成目录 md 文件](https://juejin.cn/post/7030030599268073508)
51
-
52
- ### 更新记录
53
- 0.1.3
54
- 1. 采用esbuild 进行打包
55
- 2. 并且用eslint, preter规范写法, 规范
56
- 3. 用ts进行改写
57
- 4. 支持gitee一键同步test11253123
1
+ # agmd(auto generate md)
2
+
3
+ > 在任何需要生成文档的,文件夹下的控制台中输入`agmd`, 就能自动生成目录 md 说明
4
+
5
+ [![](https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667)](https://camo.githubusercontent.com/28479a7a834310a667f36760a27283f7389e864a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f76322d646174657069636b65722e737667)
6
+
7
+ 简体中文 | [English](https://github.com/kakajun/auto-generate-md/blob/master/README.EN.md)
8
+
9
+ ## 🚀 Features
10
+
11
+ 🔥 Written in TypeScript
12
+
13
+ 🔋 build with esbuild
14
+
15
+ 💡 easy get foldName and fileName.
16
+
17
+ ### 案例
18
+
19
+ ![image](https://github.com/kakajun/auto-generate-md/blob/master/md2.png)
20
+
21
+ ### 使用方法
22
+ 需要有node环境
23
+ 1. 全局安装
24
+ > npm i agmd -g
25
+
26
+ 安装完成后,在需要记录 md 的文件夹下面输入`agmd`,会自动生成相对路径下的文件夹和文件的名字,如果文件里面还有在头部写注释的话,那么会一并带过来自动生成 md 文件。生成的文件名为`readme-md.md`, 路径为刚刚输入命名的路径同级别下,对于工程比较大的开发来说,这个脚本或许会帮你省下些许时间。
27
+
28
+ 2. 作为依赖安装
29
+ > npm i agmd -D
30
+
31
+ 在package.json的scripts 中配置 agmd: npx agmd --ignore lib,node_modules,dist --include .js,.ts,.vue 可以在每次启动或打包时,带上命令行来自动更新文档
32
+
33
+
34
+ example,是我为演示准备的一些文件,并没有其他用
35
+
36
+ 3. 高级用法
37
+ 有些需要把自动生成的文档插入到某个自动生成的 md 当中, 该插件导出了自动生成的 md 数据方法, 还有`getFileNodes`获得所有文件的具体信息, 可以 DIY 做出不同的文档( 方法名不用记忆, 由于是ts写的,所以会自动点出来)
38
+ >const agmd = require('agmd')
39
+
40
+ es中:
41
+ >import agmd from 'agmd'
42
+
43
+ - 其中 agmd.getFileNodes() 可以获得具体文件相关的信息, 该函数可传一个参数
44
+
45
+ - agmd.getMd() 得到最终输出的信息
46
+ note: 上面两个方法均可传一个option入参,其格式为:
47
+ option: { ignore: string[] | undefined; include: string[] | undefined }
48
+ #### 命令行参数说明
49
+ 1. 使用agmd -h 来查看帮助
50
+ 2. 可以带上 --ignore 忽略输出文件或文件夹, 默认为: img,styles,node_modules,LICENSE,.git,.github,dist,.husky,.vscode,readme-file.js,readme-md.js
51
+ 3. 可以带上 --include 要求只输出带此后缀文件, 默认只输出 .js,.vue,.ts, 可自己加jsx,json 等
52
+
53
+ ### 创作背景
54
+
55
+ 1. 大家有没有被要求写一个目录文件的 md 说明呢?
56
+ 2. 或者工程目录和文件被移动位置重构了,这时还需要重新修改 md 文件里面的目录说明
57
+ 3. 接手老工程,看了 md 说明,能对文件夹里面的文件功能做到一目了然,而不是点开对应文件去看
58
+ 4. 分析源码工程需要做点笔记
59
+
60
+ ### 功能
61
+
62
+ 1. 自动生成匹配目录的文件夹名和文件(已经按名称进行排序)
63
+ 2. 自动进行层级目录判断进行缩进
64
+ 3. 如果文件顶部有注释, 那么会自动进行判断
65
+ 4. 支持在任意文件目录下递归查找下级文件(不要在很大目录下执行啊!!!递归直到该级目录下没有文件为止)
66
+ 5. 支持命令行参数配置, 可以自定义忽略文件和过滤后缀名文件
67
+ 6. 命令行解析
68
+
69
+ 控制台命令: agmd--include str--ignore str
70
+
71
+ 可选项:
72
+ --include string / -i string.......... 包含解析的后缀
73
+ --ignore string / -in string........... 忽略文件名
74
+
75
+ 例子:
76
+ --ignore / -i img,styles,node_modules,LICENSE,.git,.github,dist,.husky,.vscode,readme-file.js,readme-md.js
77
+ --include / -in .js,.vue,.ts
78
+
79
+ 注意:
80
+ 配置中的字符串之间不应有空格
81
+
82
+ 命令行例子:
83
+ $ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`
84
+
85
+ ### 相关文章
86
+
87
+ [掘金-自动生成目录 md 文件](https://juejin.cn/post/7030030599268073508)
88
+
89
+ ### 更新记录
90
+ 0.1.3
91
+ 1. 采用esbuild 进行打包
92
+ 2. 并且用eslint, preter规范写法, 规范
93
+ 3. 用ts进行改写
94
+ 4. 支持gitee一键同步
95
+
96
+ 0.2.0
97
+ 支持命令行解析参数,可以动态传参
98
+
99
+ 0.2.6
100
+ 修复全局安装报错
101
+
102
+ 0.2.9
103
+ 新增文件统计功能
package/bin/agmd.js CHANGED
@@ -1,139 +1,24 @@
1
1
  #!/usr/bin/env node
2
- /*!
3
- * agmd v0.1.4
4
- * author:majun <253495832@qq.com>
5
- * Sun Dec 19 2021 11:54:00 GMT+0800 (中国标准时间)
6
- */
7
- var __create = Object.create;
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __getProtoOf = Object.getPrototypeOf;
12
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
14
- var __reExport = (target, module2, copyDefault, desc) => {
15
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
16
- for (let key of __getOwnPropNames(module2))
17
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
18
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
19
- }
20
- return target;
21
- };
22
- var __toESM = (module2, isNodeMode) => {
23
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
24
- };
2
+ "use strict";var z=Object.create;var T=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var L=e=>T(e,"__esModule",{value:!0});var H=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var J=(e,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of U(n))!K.call(e,t)&&(s||t!=="default")&&T(e,t,{get:()=>n[t],enumerable:!(r=q(n,t))||r.enumerable});return e},O=(e,n)=>J(L(T(e!=null?z(Y(e)):{},"default",!n&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var E=H((Ie,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 t={_:[]},u={},l={};for(let i of Object.keys(e)){if(!i)throw new m("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(i[0]!=="-")throw new m(`argument key must start with '-' but found: '${i}'`,"ARG_CONFIG_NONOPT_KEY");if(i.length===1)throw new m(`argument key must have a name; singular '-' keys are not allowed: ${i}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[i]=="string"){u[i]=e[i];continue}let o=e[i],a=!1;if(Array.isArray(o)&&o.length===1&&typeof o[0]=="function"){let[f]=o;o=(p,h,g=[])=>(g.push(f(p,h,g[g.length-1])),g),a=f===Boolean||f[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: ${i}`,"ARG_CONFIG_VAD_TYPE");if(i[1]!=="-"&&i.length>2)throw new m(`short argument keys (with a single hyphen) must have only one character: ${i}`,"ARG_CONFIG_SHORTOPT_TOOLONG");l[i]=[o,a]}for(let i=0,o=n.length;i<o;i++){let a=n[i];if(r&&t._.length>0){t._=t._.concat(n.slice(i));break}if(a==="--"){t._=t._.concat(n.slice(i+1));break}if(a.length>1&&a[0]==="-"){let f=a[1]==="-"||a.length===2?[a]:a.slice(1).split("").map(p=>`-${p}`);for(let p=0;p<f.length;p++){let h=f[p],[g,_]=h[1]==="-"?h.split(/=(.*)/,2):[h,void 0],c=g;for(;c in u;)c=u[c];if(!(c in l))if(s){t._.push(h);continue}else throw new m(`unknown or unexpected option: ${g}`,"ARG_UNKNOWN_OPTION");let[b,I]=l[c];if(!I&&p+1<f.length)throw new m(`option requires argument (but was followed by another short argument): ${g}`,"ARG_MISSING_REQUIRED_SHORTARG");if(I)t[c]=b(!0,c,t[c]);else if(_===void 0){if(n.length<i+2||n[i+1].length>1&&n[i+1][0]==="-"&&!(n[i+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(b===Number||typeof BigInt!="undefined"&&b===BigInt))){let P=g===c?"":` (alias for ${c})`;throw new m(`option requires argument: ${g}${P}`,"ARG_MISSING_REQUIRED_LONGARG")}t[c]=b(n[i+1],c,t[c]),++i}else t[c]=b(_,c,t[c])}}else t._.push(a)}return t}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=O(require("path"));var y=O(require("fs")),x=O(require("path"));function Q(e){let n=y.default.readFileSync(e,"utf-8"),s=n.length,r=n.split(/[\n,]/g),t=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:t}}function A(e,n=[],s=x.default.resolve("./"),r=0){let t=["img","styles","node_modules","LICENSE",".git",".github","dist",".husky",".vscode","readme-file.js","readme-md.js"],u=[".js",".vue",".ts"];e&&(t=e.ignore||t,u=e.include||u);let l=y.default.readdirSync(s).map(i=>{let o=x.default.join(s,i),a=y.default.lstatSync(o).isDirectory();return{name:i,isDir:a,level:r,note:""}}).sort((i,o)=>!i.isDir&&o.isDir?1:i.isDir&&!o.isDir?-1:(i.isDir&&o.isDir||!i.isDir&&!o.isDir,0));for(let i=0;i<l.length;i+=1){let o=l[i];if(t.findIndex(f=>f===o.name)===-1){let f=x.default.join(s,o.name);if(y.default.lstatSync(f).isDirectory())A(e,o.children=[],f,r+1),n.push(o);else{let h=f.lastIndexOf("."),g=f.substring(h);if(u.includes(g)){let _=Q(f);Object.assign(o,_),o.suffix=g,n.push(o)}}}}return n}function $(e,n){let s=n||[];return e.forEach((r,t)=>{let u=t===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="",t=`${"\u2502 ".repeat(e.level)}${n?"\u2514\u2500\u2500":"\u251C\u2500\u2500"} ${e.name}`;return e.isDir?s+=`${t}
3
+ `:s+=`${t} ${e.note}
4
+ `,s}function V(e,n){let s=x.default.resolve(__dirname,n),r="export default";y.default.writeFile(s,r+e,{encoding:"utf8"},t=>{console.error(t)})}function S(e){var n=/\d{1,3}(?=(\d{3})+$)/g;return(e+"").replace(n,"$&,")}function W(e){let{rowTotleNumber:n,sizeTotleNumber:s,coutObj:r}=e,t="",u=0;for(let i in r){let o=r[i];u+=o,t+=`The suffix is ${i} has ${o} files
5
+ `}t+=`The totle has ${u} files
6
+ `;let l=`Total number of file lines: ${S(n)},
7
+ Total number of codes: ${S(s)}
8
+ `;return l=t+l,l}function X(e){let n=0,s=0,r={};function t(u){u.forEach(l=>{l.children?t(l.children):(r.hasOwnProperty(l.suffix)||(r[l.suffix]=0),r[l.suffix]++,n+=l.rowSize,s+=l.size)})}return t(e),{rowTotleNumber:n,sizeTotleNumber:s,coutObj:r}}function j(e){console.log("\x1B[36m%s\x1B[0m","*** run location: ",x.default.resolve("./"));let n=A(e);V(JSON.stringify(n),__dirname+"\\readme-file.js");let s=X(n),r=W(s),u=$(n).join("")+`
9
+ `;return u.length>0&&console.log("\x1B[36m%s\x1B[0m","*** Automatic generation completed ! "),console.log("\x1B[33m%s\x1B[0m:",r),u+r}function D(e,n){let s=x.default.resolve(__dirname,n);y.default.writeFile(s,e,{encoding:"utf8"},r=>{console.error(r)})}var B=O(E()),Z=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=Z;var ee=`Usage: agmd--include str--ignore str
25
10
 
26
- // src/agmd.ts
27
- var import_path2 = __toESM(require("path"));
28
- var import_fs2 = __toESM(require("fs"));
11
+ Options:
12
+ --include string / -i string.......... include file extension
13
+ --ignore string / -in string........... ignore file or fold
14
+ --version / -v ........... seach vesion
15
+ Str deafult:
16
+ --ignore img,styles,node_modules,LICENSE,.git,.github,dist,.husky,.vscode,readme-file.js,readme-md.js
17
+ --include .js,.vue,.ts
29
18
 
30
- // src/index.ts
31
- var import_fs = __toESM(require("fs"));
32
- var import_path = __toESM(require("path"));
33
- function getFile(file) {
34
- const str = import_fs.default.readFileSync(file, "utf-8");
35
- const sarr = str.split(/[\n,]/g);
36
- const f = sarr[0].indexOf("eslint") === -1 && (sarr[0].indexOf("-->") > -1 || sarr[0].indexOf("*/") > -1 || sarr[0].indexOf("//") > -1) ? sarr[0] : "";
37
- return f;
38
- }
39
- var filterArr = ["img", "styles", "node_modules", "LICENSE", ".git", ".github", "dist", ".husky", ".vscode"];
40
- var includeArrs = [".js", ".vue", ".ts"];
41
- function getFileNodes(nodes = [], dir = import_path.default.resolve("./"), level = 0) {
42
- const files = import_fs.default.readdirSync(dir).map((item) => {
43
- const fullPath = import_path.default.join(dir, item);
44
- const isDir = import_fs.default.lstatSync(fullPath).isDirectory();
45
- return {
46
- name: item,
47
- isDir,
48
- level,
49
- note: ""
50
- };
51
- }).sort((a, b) => {
52
- if (!a.isDir && b.isDir)
53
- return 1;
54
- if (a.isDir && !b.isDir)
55
- return -1;
56
- if (a.isDir && b.isDir || !a.isDir && !b.isDir)
57
- return 0;
58
- return 0;
59
- });
60
- for (let index = 0; index < files.length; index += 1) {
61
- const item = files[index];
62
- let note = "";
63
- const arr = filterArr.findIndex((obj) => obj === item.name);
64
- if (arr === -1) {
65
- const fullPath = import_path.default.join(dir, item.name);
66
- const isDir = import_fs.default.lstatSync(fullPath).isDirectory();
67
- if (isDir) {
68
- getFileNodes(item.children = [], fullPath, level + 1);
69
- } else {
70
- const i = fullPath.lastIndexOf(".");
71
- const lastName = fullPath.substring(i);
72
- if ([".js", ".vue", ".ts"].includes(lastName)) {
73
- note = getFile(fullPath);
74
- }
75
- item.note = note;
76
- }
77
- nodes.push(item);
78
- }
79
- }
80
- return nodes;
81
- }
82
- function getNote(datas, keys) {
83
- const nodes = keys || [];
84
- datas.forEach((obj) => {
85
- if (obj.children) {
86
- const md = setMd(obj);
87
- nodes.push(md);
88
- getNote(obj.children, nodes);
89
- } else {
90
- const md = setMd(obj);
91
- nodes.push(md);
92
- }
93
- });
94
- return nodes;
95
- }
96
- function setMd(obj) {
97
- let filesString = "";
98
- const blank = " ".repeat(obj.level);
99
- if (obj.isDir) {
100
- filesString += `${blank}+ ${obj.name}
101
- `;
102
- } else {
103
- const index = obj.name.lastIndexOf(".");
104
- const lastName = obj.name.substring(index);
105
- if (includeArrs.includes(lastName) || index === -1) {
106
- filesString += `${blank} ${obj.name} ${obj.note}
107
- `;
108
- }
109
- }
110
- return filesString;
111
- }
112
- function getMd() {
113
- console.log("%s", "*** run location: ", import_path.default.resolve("./"));
114
- const nodes = getFileNodes();
115
- const note = getNote(nodes);
116
- const md = note.join("");
117
- if (md.length > 0) {
118
- console.log("%s", "*** Automatic generation completed ! ");
119
- }
120
- return md;
121
- }
19
+ Note:
20
+ There should be no space between strings in a configuration
122
21
 
123
- // src/agmd.ts
124
- var __dirname = import_path2.default.resolve();
125
- function wirteMd(data, filePath) {
126
- const file = import_path2.default.resolve(__dirname, filePath);
127
- const pre = "```js\n";
128
- const last = "```\n";
129
- import_fs2.default.writeFile(file, pre + data + last, { encoding: "utf8" }, (err) => {
130
- console.error(err);
131
- });
132
- }
133
- function agmd() {
134
- const md = getMd();
135
- console.log("%s", "*** location: ", `${import_path2.default.resolve("./")}\\readme-md.md`);
136
- wirteMd(md, `${import_path2.default.resolve("./")}\\readme-md.md`);
137
- }
138
- agmd();
22
+ Examples:
23
+ $ agmd --ignore lib,node_modules,dist --include .js,.ts,.vue`;function ne(){console.log(ee),process.exit(0)}var F=ne;var te="agmd",ie="0.2.8",re="auto generate markdown for node",se=["node","auto","generate","md","markdown"],oe="lib/index.cjs.js",le="lib/index.esm.js",ue="lib/index.d.ts",de={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"},ae="kakajun <253495832@qq.com>",fe={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"},me={"*.{ts,tsx,js}":"prettier --write","*.{ts,tsx}":"eslint --fix"},pe="MIT",he={url:"https://github.com/kakajun/auto-generate-md/issues"},ye="https://github.com/kakajun/auto-generate-md",xe=["bin","lib"],M={name:te,version:ie,description:re,keywords:se,main:oe,module:le,typings:ue,bin:de,scripts:ce,author:ae,repository:fe,devDependencies:ge,"lint-staged":me,license:pe,bugs:he,homepage:ye,files:xe};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 we=R(process.argv),{ignores:_e,includes:Oe}=C(we);function Te(){let e=j({ignore:_e,include:Oe});console.log("\x1B[36m%s\x1B[0m","*** location: ",`${k.default.resolve("./")}\\readme-md.md`),D(e,`${k.default.resolve("./")}\\readme-md.md`)}Te();
139
24
  //# sourceMappingURL=agmd.js.map