meocli 0.1.6 → 0.1.8
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 +642 -115
- package/dist/commands/js/clash.d.ts +13 -0
- package/dist/commands/js/clash.js +160 -0
- package/dist/lib/ast.d.ts +8 -0
- package/dist/lib/ast.js +69 -0
- package/dist/tests/d3-test.js +1 -1
- package/oclif.manifest.json +44 -1
- package/package.json +18 -11
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# meocli
|
|
2
|
-
|
|
3
|
-
Node CLI generated with oclif, Integrate Prettier
|
|
4
|
-
|
|
5
|
-
[](https://oclif.io)
|
|
6
|
-
[](https://npmjs.org/package/meocli)
|
|
7
|
-
[](https://npmjs.org/package/meocli)
|
|
8
|
-
|
|
1
|
+
# meocli
|
|
2
|
+
|
|
3
|
+
Node CLI generated with oclif, Integrate Prettier
|
|
4
|
+
|
|
5
|
+
[](https://oclif.io)
|
|
6
|
+
[](https://npmjs.org/package/meocli)
|
|
7
|
+
[](https://npmjs.org/package/meocli)
|
|
8
|
+
|
|
9
9
|
<!-- toc -->
|
|
10
10
|
* [meocli](#meocli)
|
|
11
11
|
* [Dev](#dev)
|
|
@@ -14,124 +14,137 @@ Node CLI generated with oclif, Integrate Prettier
|
|
|
14
14
|
* [Publish](#publish)
|
|
15
15
|
* [Usage](#usage)
|
|
16
16
|
* [Commands](#commands)
|
|
17
|
-
<!-- tocstop -->
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<!--
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
$ pnpm
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
$ pnpm
|
|
38
|
-
$
|
|
39
|
-
$
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
//
|
|
63
|
-
"match": "\\.(
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"isAsync": true,
|
|
84
|
-
"cmd": "me prettier ${file}"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
//
|
|
88
|
-
"match": "Dockerfile$",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
# Publish
|
|
104
|
-
|
|
105
|
-
```sh-session
|
|
106
|
-
$ pnpm login
|
|
107
|
-
$ pnpm build
|
|
108
|
-
$ pnpm publish
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
# Usage
|
|
112
|
-
|
|
17
|
+
<!-- tocstop -->
|
|
18
|
+
* [meocli](#meocli)
|
|
19
|
+
* [Dev](#dev)
|
|
20
|
+
* [Prettier](#prettier)
|
|
21
|
+
* [Prettier.Vscode](#prettiervscode)
|
|
22
|
+
* [Publish](#publish)
|
|
23
|
+
* [Usage](#usage)
|
|
24
|
+
* [Commands](#commands)
|
|
25
|
+
<!-- tocstop -->
|
|
26
|
+
|
|
27
|
+
# Dev
|
|
28
|
+
|
|
29
|
+
```sh-session
|
|
30
|
+
<!-- pnpm exec -->
|
|
31
|
+
$ pnpm ncu # 检查更新
|
|
32
|
+
$ pnpm ncu -u # 升级更新
|
|
33
|
+
<!-- demo -->
|
|
34
|
+
$ pnpm run dev hello foo
|
|
35
|
+
$ pnpm run prod hello foo -f bar
|
|
36
|
+
<!-- prettier -->
|
|
37
|
+
$ pnpm run dev prettier ./tmp/test.svg --verbose
|
|
38
|
+
$ pnpm run dev prettier ./tmp/test.json --config=auto --ignore=auto
|
|
39
|
+
$ pnpm run dev prettier ./tmp/test.svg --config=built_in --ignore=auto
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
# Prettier
|
|
43
|
+
|
|
44
|
+
```sh-session
|
|
45
|
+
$ pnpm install -g meocli
|
|
46
|
+
$ me prettier --help
|
|
47
|
+
$ me prettier reset --verbose # 重置Prettier配置
|
|
48
|
+
$ me prettier ./test.svg --verbose # 使用prettier格式化文件
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
# Prettier.Vscode
|
|
52
|
+
|
|
53
|
+
1. `pnpm install -g meocli`
|
|
54
|
+
|
|
55
|
+
2. 配合vscode插件:[emeraldwalk.RunOnSave](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) 保存时自动格式化
|
|
56
|
+
3. 配置 `.vscode/settings.json` 添加 `"emeraldwalk.runonsave"` 节点,以下为参考配置⤵︎
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
"emeraldwalk.runonsave": {
|
|
60
|
+
"commands": [
|
|
61
|
+
{
|
|
62
|
+
// prettier
|
|
63
|
+
"match": "\\.(txt|ts|js|jsx|tsx|json|html|css|graphql|gql|yaml|yml|md)$",
|
|
64
|
+
"notMatch": "node_modules/*$",
|
|
65
|
+
"isAsync": true,
|
|
66
|
+
"cmd": "me prettier \"${file}\""
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
// @prettier/plugin-xml
|
|
70
|
+
"match": "\\.(xml|svg)$",
|
|
71
|
+
"isAsync": true,
|
|
72
|
+
"cmd": "me prettier \"${file}\""
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
// prettier-plugin-toml
|
|
76
|
+
"match": "\\.(toml)$",
|
|
77
|
+
"isAsync": true,
|
|
78
|
+
"cmd": "me prettier \"${file}\""
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
// prettier-plugin-nginx
|
|
82
|
+
"match": "\\.(nginx)$",
|
|
83
|
+
"isAsync": true,
|
|
84
|
+
"cmd": "me prettier \"${file}\""
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
// prettier-plugin-sh
|
|
88
|
+
"match": "\\.(sh|env|Dockerfile|properties|gitignore|dockerignore|prettierignore)$",
|
|
89
|
+
"notMatch": "\\.(nu)$",
|
|
90
|
+
"isAsync": true,
|
|
91
|
+
"cmd": "me prettier \"${file}\""
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
// no-dot-ext
|
|
95
|
+
"match": "Dockerfile$|web.config",
|
|
96
|
+
"isAsync": true,
|
|
97
|
+
"cmd": "me prettier \"${file}\""
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
# Publish
|
|
104
|
+
|
|
105
|
+
```sh-session
|
|
106
|
+
$ pnpm login
|
|
107
|
+
$ pnpm build
|
|
108
|
+
$ pnpm publish
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
# Usage
|
|
112
|
+
|
|
113
113
|
<!-- usage -->
|
|
114
114
|
```sh-session
|
|
115
115
|
$ npm install -g meocli
|
|
116
116
|
$ me COMMAND
|
|
117
117
|
running command...
|
|
118
118
|
$ me (--version)
|
|
119
|
-
meocli/0.1.
|
|
119
|
+
meocli/0.1.8 win32-x64 node-v24.18.0
|
|
120
120
|
$ me --help [COMMAND]
|
|
121
121
|
USAGE
|
|
122
122
|
$ me COMMAND
|
|
123
123
|
...
|
|
124
124
|
```
|
|
125
|
-
<!-- usagestop -->
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
<!-- usagestop -->
|
|
126
|
+
```sh-session
|
|
127
|
+
$ npm install -g meocli
|
|
128
|
+
$ me COMMAND
|
|
129
|
+
running command...
|
|
130
|
+
$ me (--version)
|
|
131
|
+
meocli/0.1.7 win32-x64 node-v24.14.0
|
|
132
|
+
$ me --help [COMMAND]
|
|
133
|
+
USAGE
|
|
134
|
+
$ me COMMAND
|
|
135
|
+
...
|
|
136
|
+
```
|
|
137
|
+
<!-- usagestop -->
|
|
138
|
+
|
|
139
|
+
# Commands
|
|
140
|
+
|
|
129
141
|
<!-- commands -->
|
|
130
142
|
* [`me env [FILEPATH]`](#me-env-filepath)
|
|
131
143
|
* [`me env apifox [FILEPATH]`](#me-env-apifox-filepath)
|
|
132
144
|
* [`me hello PERSON`](#me-hello-person)
|
|
133
145
|
* [`me hello world`](#me-hello-world)
|
|
134
146
|
* [`me help [COMMAND]`](#me-help-command)
|
|
147
|
+
* [`me js clash FILEPATH TEMPLATEPATH`](#me-js-clash-filepath-templatepath)
|
|
135
148
|
* [`me plugins`](#me-plugins)
|
|
136
149
|
* [`me plugins add PLUGIN`](#me-plugins-add-plugin)
|
|
137
150
|
* [`me plugins:inspect PLUGIN...`](#me-pluginsinspect-plugin)
|
|
@@ -166,7 +179,7 @@ EXAMPLES
|
|
|
166
179
|
me env .env
|
|
167
180
|
```
|
|
168
181
|
|
|
169
|
-
_See code: [src/commands/env/index.ts](https://github.com/meme2046/meocli/blob/v0.1.
|
|
182
|
+
_See code: [src/commands/env/index.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/env/index.ts)_
|
|
170
183
|
|
|
171
184
|
## `me env apifox [FILEPATH]`
|
|
172
185
|
|
|
@@ -189,7 +202,7 @@ EXAMPLES
|
|
|
189
202
|
me env apifox .env
|
|
190
203
|
```
|
|
191
204
|
|
|
192
|
-
_See code: [src/commands/env/apifox.ts](https://github.com/meme2046/meocli/blob/v0.1.
|
|
205
|
+
_See code: [src/commands/env/apifox.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/env/apifox.ts)_
|
|
193
206
|
|
|
194
207
|
## `me hello PERSON`
|
|
195
208
|
|
|
@@ -213,7 +226,7 @@ EXAMPLES
|
|
|
213
226
|
hello friend --from oclif (./src/commands/hello/index.ts)
|
|
214
227
|
```
|
|
215
228
|
|
|
216
|
-
_See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.
|
|
229
|
+
_See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/hello/index.ts)_
|
|
217
230
|
|
|
218
231
|
## `me hello world`
|
|
219
232
|
|
|
@@ -231,7 +244,7 @@ EXAMPLES
|
|
|
231
244
|
hello world! (./src/commands/hello/world.ts)
|
|
232
245
|
```
|
|
233
246
|
|
|
234
|
-
_See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.
|
|
247
|
+
_See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/hello/world.ts)_
|
|
235
248
|
|
|
236
249
|
## `me help [COMMAND]`
|
|
237
250
|
|
|
@@ -253,6 +266,30 @@ DESCRIPTION
|
|
|
253
266
|
|
|
254
267
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
|
|
255
268
|
|
|
269
|
+
## `me js clash FILEPATH TEMPLATEPATH`
|
|
270
|
+
|
|
271
|
+
修改Clash脚本
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
USAGE
|
|
275
|
+
$ me js clash FILEPATH TEMPLATEPATH [-v]
|
|
276
|
+
|
|
277
|
+
ARGUMENTS
|
|
278
|
+
FILEPATH 目标js文件路径
|
|
279
|
+
TEMPLATEPATH template.json配置文件路径
|
|
280
|
+
|
|
281
|
+
FLAGS
|
|
282
|
+
-v, --verbose Show verbose output
|
|
283
|
+
|
|
284
|
+
DESCRIPTION
|
|
285
|
+
修改Clash脚本
|
|
286
|
+
|
|
287
|
+
EXAMPLES
|
|
288
|
+
$ me js clash ./test.js ./template.json
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
_See code: [src/commands/js/clash.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/js/clash.ts)_
|
|
292
|
+
|
|
256
293
|
## `me plugins`
|
|
257
294
|
|
|
258
295
|
List installed plugins.
|
|
@@ -571,7 +608,7 @@ EXAMPLES
|
|
|
571
608
|
$ me prettier ./src/file.ts --config ./.prettierrc.yaml
|
|
572
609
|
```
|
|
573
610
|
|
|
574
|
-
_See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.
|
|
611
|
+
_See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/prettier/index.ts)_
|
|
575
612
|
|
|
576
613
|
## `me prettier reset`
|
|
577
614
|
|
|
@@ -591,5 +628,495 @@ EXAMPLES
|
|
|
591
628
|
$ me prettier reset --verbose
|
|
592
629
|
```
|
|
593
630
|
|
|
594
|
-
_See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.
|
|
631
|
+
_See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.8/src/commands/prettier/reset.ts)_
|
|
632
|
+
<!-- commandsstop -->
|
|
633
|
+
* [`me env [FILEPATH]`](#me-env-filepath)
|
|
634
|
+
* [`me env apifox [FILEPATH]`](#me-env-apifox-filepath)
|
|
635
|
+
* [`me hello PERSON`](#me-hello-person)
|
|
636
|
+
* [`me hello world`](#me-hello-world)
|
|
637
|
+
* [`me help [COMMAND]`](#me-help-command)
|
|
638
|
+
* [`me js clash FILEPATH`](#me-js-clash-filepath)
|
|
639
|
+
* [`me plugins`](#me-plugins)
|
|
640
|
+
* [`me plugins add PLUGIN`](#me-plugins-add-plugin)
|
|
641
|
+
* [`me plugins:inspect PLUGIN...`](#me-pluginsinspect-plugin)
|
|
642
|
+
* [`me plugins install PLUGIN`](#me-plugins-install-plugin)
|
|
643
|
+
* [`me plugins link PATH`](#me-plugins-link-path)
|
|
644
|
+
* [`me plugins remove [PLUGIN]`](#me-plugins-remove-plugin)
|
|
645
|
+
* [`me plugins reset`](#me-plugins-reset)
|
|
646
|
+
* [`me plugins uninstall [PLUGIN]`](#me-plugins-uninstall-plugin)
|
|
647
|
+
* [`me plugins unlink [PLUGIN]`](#me-plugins-unlink-plugin)
|
|
648
|
+
* [`me plugins update`](#me-plugins-update)
|
|
649
|
+
* [`me prettier FILEPATH`](#me-prettier-filepath)
|
|
650
|
+
* [`me prettier reset`](#me-prettier-reset)
|
|
651
|
+
|
|
652
|
+
## `me env [FILEPATH]`
|
|
653
|
+
|
|
654
|
+
读取.env环境变量并打印(json格式)
|
|
655
|
+
|
|
656
|
+
```
|
|
657
|
+
USAGE
|
|
658
|
+
$ me env [FILEPATH] [-v]
|
|
659
|
+
|
|
660
|
+
ARGUMENTS
|
|
661
|
+
[FILEPATH] [default: .env] .env文件路径,不传默认值为.env
|
|
662
|
+
|
|
663
|
+
FLAGS
|
|
664
|
+
-v, --verbose Show verbose output
|
|
665
|
+
|
|
666
|
+
DESCRIPTION
|
|
667
|
+
读取.env环境变量并打印(json格式)
|
|
668
|
+
|
|
669
|
+
EXAMPLES
|
|
670
|
+
me env .env
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
_See code: [src/commands/env/index.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/env/index.ts)_
|
|
674
|
+
|
|
675
|
+
## `me env apifox [FILEPATH]`
|
|
676
|
+
|
|
677
|
+
读取.env环境变量,输出apifox需要的csv格式
|
|
678
|
+
|
|
679
|
+
```
|
|
680
|
+
USAGE
|
|
681
|
+
$ me env apifox [FILEPATH] [-v]
|
|
682
|
+
|
|
683
|
+
ARGUMENTS
|
|
684
|
+
[FILEPATH] [default: .env] .env文件路径,不传默认值为.env
|
|
685
|
+
|
|
686
|
+
FLAGS
|
|
687
|
+
-v, --verbose Show verbose output
|
|
688
|
+
|
|
689
|
+
DESCRIPTION
|
|
690
|
+
读取.env环境变量,输出apifox需要的csv格式
|
|
691
|
+
|
|
692
|
+
EXAMPLES
|
|
693
|
+
me env apifox .env
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
_See code: [src/commands/env/apifox.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/env/apifox.ts)_
|
|
697
|
+
|
|
698
|
+
## `me hello PERSON`
|
|
699
|
+
|
|
700
|
+
Say hello
|
|
701
|
+
|
|
702
|
+
```
|
|
703
|
+
USAGE
|
|
704
|
+
$ me hello PERSON [-f <value>]
|
|
705
|
+
|
|
706
|
+
ARGUMENTS
|
|
707
|
+
PERSON Person to say hello to
|
|
708
|
+
|
|
709
|
+
FLAGS
|
|
710
|
+
-f, --from=<value> [default: meocli] Who is saying hello
|
|
711
|
+
|
|
712
|
+
DESCRIPTION
|
|
713
|
+
Say hello
|
|
714
|
+
|
|
715
|
+
EXAMPLES
|
|
716
|
+
me hello friend --from oclif
|
|
717
|
+
hello friend --from oclif (./src/commands/hello/index.ts)
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
_See code: [src/commands/hello/index.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/hello/index.ts)_
|
|
721
|
+
|
|
722
|
+
## `me hello world`
|
|
723
|
+
|
|
724
|
+
Say hello world
|
|
725
|
+
|
|
726
|
+
```
|
|
727
|
+
USAGE
|
|
728
|
+
$ me hello world
|
|
729
|
+
|
|
730
|
+
DESCRIPTION
|
|
731
|
+
Say hello world
|
|
732
|
+
|
|
733
|
+
EXAMPLES
|
|
734
|
+
$ me hello world
|
|
735
|
+
hello world! (./src/commands/hello/world.ts)
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
_See code: [src/commands/hello/world.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/hello/world.ts)_
|
|
739
|
+
|
|
740
|
+
## `me help [COMMAND]`
|
|
741
|
+
|
|
742
|
+
Display help for me.
|
|
743
|
+
|
|
744
|
+
```
|
|
745
|
+
USAGE
|
|
746
|
+
$ me help [COMMAND...] [-n]
|
|
747
|
+
|
|
748
|
+
ARGUMENTS
|
|
749
|
+
[COMMAND...] Command to show help for.
|
|
750
|
+
|
|
751
|
+
FLAGS
|
|
752
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
753
|
+
|
|
754
|
+
DESCRIPTION
|
|
755
|
+
Display help for me.
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
|
|
759
|
+
|
|
760
|
+
## `me js clash FILEPATH`
|
|
761
|
+
|
|
762
|
+
修改Clash脚本
|
|
763
|
+
|
|
764
|
+
```
|
|
765
|
+
USAGE
|
|
766
|
+
$ me js clash FILEPATH [-v]
|
|
767
|
+
|
|
768
|
+
ARGUMENTS
|
|
769
|
+
FILEPATH 目标js文件路径
|
|
770
|
+
|
|
771
|
+
FLAGS
|
|
772
|
+
-v, --verbose Show verbose output
|
|
773
|
+
|
|
774
|
+
DESCRIPTION
|
|
775
|
+
修改Clash脚本
|
|
776
|
+
|
|
777
|
+
EXAMPLES
|
|
778
|
+
$ me js clash ./tests/test.js
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
_See code: [src/commands/js/clash.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/js/clash.ts)_
|
|
782
|
+
|
|
783
|
+
## `me plugins`
|
|
784
|
+
|
|
785
|
+
List installed plugins.
|
|
786
|
+
|
|
787
|
+
```
|
|
788
|
+
USAGE
|
|
789
|
+
$ me plugins [--json] [--core]
|
|
790
|
+
|
|
791
|
+
FLAGS
|
|
792
|
+
--core Show core plugins.
|
|
793
|
+
|
|
794
|
+
GLOBAL FLAGS
|
|
795
|
+
--json Format output as json.
|
|
796
|
+
|
|
797
|
+
DESCRIPTION
|
|
798
|
+
List installed plugins.
|
|
799
|
+
|
|
800
|
+
EXAMPLES
|
|
801
|
+
$ me plugins
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/index.ts)_
|
|
805
|
+
|
|
806
|
+
## `me plugins add PLUGIN`
|
|
807
|
+
|
|
808
|
+
Installs a plugin into me.
|
|
809
|
+
|
|
810
|
+
```
|
|
811
|
+
USAGE
|
|
812
|
+
$ me plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
813
|
+
|
|
814
|
+
ARGUMENTS
|
|
815
|
+
PLUGIN... Plugin to install.
|
|
816
|
+
|
|
817
|
+
FLAGS
|
|
818
|
+
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
819
|
+
-h, --help Show CLI help.
|
|
820
|
+
-s, --silent Silences npm output.
|
|
821
|
+
-v, --verbose Show verbose npm output.
|
|
822
|
+
|
|
823
|
+
GLOBAL FLAGS
|
|
824
|
+
--json Format output as json.
|
|
825
|
+
|
|
826
|
+
DESCRIPTION
|
|
827
|
+
Installs a plugin into me.
|
|
828
|
+
|
|
829
|
+
Uses npm to install plugins.
|
|
830
|
+
|
|
831
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
832
|
+
|
|
833
|
+
Use the ME_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
834
|
+
Use the ME_NPM_REGISTRY environment variable to set the npm registry.
|
|
835
|
+
|
|
836
|
+
ALIASES
|
|
837
|
+
$ me plugins add
|
|
838
|
+
|
|
839
|
+
EXAMPLES
|
|
840
|
+
Install a plugin from npm registry.
|
|
841
|
+
|
|
842
|
+
$ me plugins add myplugin
|
|
843
|
+
|
|
844
|
+
Install a plugin from a github url.
|
|
845
|
+
|
|
846
|
+
$ me plugins add https://github.com/someuser/someplugin
|
|
847
|
+
|
|
848
|
+
Install a plugin from a github slug.
|
|
849
|
+
|
|
850
|
+
$ me plugins add someuser/someplugin
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
## `me plugins:inspect PLUGIN...`
|
|
854
|
+
|
|
855
|
+
Displays installation properties of a plugin.
|
|
856
|
+
|
|
857
|
+
```
|
|
858
|
+
USAGE
|
|
859
|
+
$ me plugins inspect PLUGIN...
|
|
860
|
+
|
|
861
|
+
ARGUMENTS
|
|
862
|
+
PLUGIN... [default: .] Plugin to inspect.
|
|
863
|
+
|
|
864
|
+
FLAGS
|
|
865
|
+
-h, --help Show CLI help.
|
|
866
|
+
-v, --verbose
|
|
867
|
+
|
|
868
|
+
GLOBAL FLAGS
|
|
869
|
+
--json Format output as json.
|
|
870
|
+
|
|
871
|
+
DESCRIPTION
|
|
872
|
+
Displays installation properties of a plugin.
|
|
873
|
+
|
|
874
|
+
EXAMPLES
|
|
875
|
+
$ me plugins inspect myplugin
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/inspect.ts)_
|
|
879
|
+
|
|
880
|
+
## `me plugins install PLUGIN`
|
|
881
|
+
|
|
882
|
+
Installs a plugin into me.
|
|
883
|
+
|
|
884
|
+
```
|
|
885
|
+
USAGE
|
|
886
|
+
$ me plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
887
|
+
|
|
888
|
+
ARGUMENTS
|
|
889
|
+
PLUGIN... Plugin to install.
|
|
890
|
+
|
|
891
|
+
FLAGS
|
|
892
|
+
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
893
|
+
-h, --help Show CLI help.
|
|
894
|
+
-s, --silent Silences npm output.
|
|
895
|
+
-v, --verbose Show verbose npm output.
|
|
896
|
+
|
|
897
|
+
GLOBAL FLAGS
|
|
898
|
+
--json Format output as json.
|
|
899
|
+
|
|
900
|
+
DESCRIPTION
|
|
901
|
+
Installs a plugin into me.
|
|
902
|
+
|
|
903
|
+
Uses npm to install plugins.
|
|
904
|
+
|
|
905
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
906
|
+
|
|
907
|
+
Use the ME_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
908
|
+
Use the ME_NPM_REGISTRY environment variable to set the npm registry.
|
|
909
|
+
|
|
910
|
+
ALIASES
|
|
911
|
+
$ me plugins add
|
|
912
|
+
|
|
913
|
+
EXAMPLES
|
|
914
|
+
Install a plugin from npm registry.
|
|
915
|
+
|
|
916
|
+
$ me plugins install myplugin
|
|
917
|
+
|
|
918
|
+
Install a plugin from a github url.
|
|
919
|
+
|
|
920
|
+
$ me plugins install https://github.com/someuser/someplugin
|
|
921
|
+
|
|
922
|
+
Install a plugin from a github slug.
|
|
923
|
+
|
|
924
|
+
$ me plugins install someuser/someplugin
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/install.ts)_
|
|
928
|
+
|
|
929
|
+
## `me plugins link PATH`
|
|
930
|
+
|
|
931
|
+
Links a plugin into the CLI for development.
|
|
932
|
+
|
|
933
|
+
```
|
|
934
|
+
USAGE
|
|
935
|
+
$ me plugins link PATH [-h] [--install] [-v]
|
|
936
|
+
|
|
937
|
+
ARGUMENTS
|
|
938
|
+
PATH [default: .] path to plugin
|
|
939
|
+
|
|
940
|
+
FLAGS
|
|
941
|
+
-h, --help Show CLI help.
|
|
942
|
+
-v, --verbose
|
|
943
|
+
--[no-]install Install dependencies after linking the plugin.
|
|
944
|
+
|
|
945
|
+
DESCRIPTION
|
|
946
|
+
Links a plugin into the CLI for development.
|
|
947
|
+
|
|
948
|
+
Installation of a linked plugin will override a user-installed or core plugin.
|
|
949
|
+
|
|
950
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
951
|
+
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
EXAMPLES
|
|
955
|
+
$ me plugins link myplugin
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/link.ts)_
|
|
959
|
+
|
|
960
|
+
## `me plugins remove [PLUGIN]`
|
|
961
|
+
|
|
962
|
+
Removes a plugin from the CLI.
|
|
963
|
+
|
|
964
|
+
```
|
|
965
|
+
USAGE
|
|
966
|
+
$ me plugins remove [PLUGIN...] [-h] [-v]
|
|
967
|
+
|
|
968
|
+
ARGUMENTS
|
|
969
|
+
[PLUGIN...] plugin to uninstall
|
|
970
|
+
|
|
971
|
+
FLAGS
|
|
972
|
+
-h, --help Show CLI help.
|
|
973
|
+
-v, --verbose
|
|
974
|
+
|
|
975
|
+
DESCRIPTION
|
|
976
|
+
Removes a plugin from the CLI.
|
|
977
|
+
|
|
978
|
+
ALIASES
|
|
979
|
+
$ me plugins unlink
|
|
980
|
+
$ me plugins remove
|
|
981
|
+
|
|
982
|
+
EXAMPLES
|
|
983
|
+
$ me plugins remove myplugin
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
## `me plugins reset`
|
|
987
|
+
|
|
988
|
+
Remove all user-installed and linked plugins.
|
|
989
|
+
|
|
990
|
+
```
|
|
991
|
+
USAGE
|
|
992
|
+
$ me plugins reset [--hard] [--reinstall]
|
|
993
|
+
|
|
994
|
+
FLAGS
|
|
995
|
+
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
|
996
|
+
--reinstall Reinstall all plugins after uninstalling.
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/reset.ts)_
|
|
1000
|
+
|
|
1001
|
+
## `me plugins uninstall [PLUGIN]`
|
|
1002
|
+
|
|
1003
|
+
Removes a plugin from the CLI.
|
|
1004
|
+
|
|
1005
|
+
```
|
|
1006
|
+
USAGE
|
|
1007
|
+
$ me plugins uninstall [PLUGIN...] [-h] [-v]
|
|
1008
|
+
|
|
1009
|
+
ARGUMENTS
|
|
1010
|
+
[PLUGIN...] plugin to uninstall
|
|
1011
|
+
|
|
1012
|
+
FLAGS
|
|
1013
|
+
-h, --help Show CLI help.
|
|
1014
|
+
-v, --verbose
|
|
1015
|
+
|
|
1016
|
+
DESCRIPTION
|
|
1017
|
+
Removes a plugin from the CLI.
|
|
1018
|
+
|
|
1019
|
+
ALIASES
|
|
1020
|
+
$ me plugins unlink
|
|
1021
|
+
$ me plugins remove
|
|
1022
|
+
|
|
1023
|
+
EXAMPLES
|
|
1024
|
+
$ me plugins uninstall myplugin
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/uninstall.ts)_
|
|
1028
|
+
|
|
1029
|
+
## `me plugins unlink [PLUGIN]`
|
|
1030
|
+
|
|
1031
|
+
Removes a plugin from the CLI.
|
|
1032
|
+
|
|
1033
|
+
```
|
|
1034
|
+
USAGE
|
|
1035
|
+
$ me plugins unlink [PLUGIN...] [-h] [-v]
|
|
1036
|
+
|
|
1037
|
+
ARGUMENTS
|
|
1038
|
+
[PLUGIN...] plugin to uninstall
|
|
1039
|
+
|
|
1040
|
+
FLAGS
|
|
1041
|
+
-h, --help Show CLI help.
|
|
1042
|
+
-v, --verbose
|
|
1043
|
+
|
|
1044
|
+
DESCRIPTION
|
|
1045
|
+
Removes a plugin from the CLI.
|
|
1046
|
+
|
|
1047
|
+
ALIASES
|
|
1048
|
+
$ me plugins unlink
|
|
1049
|
+
$ me plugins remove
|
|
1050
|
+
|
|
1051
|
+
EXAMPLES
|
|
1052
|
+
$ me plugins unlink myplugin
|
|
1053
|
+
```
|
|
1054
|
+
|
|
1055
|
+
## `me plugins update`
|
|
1056
|
+
|
|
1057
|
+
Update installed plugins.
|
|
1058
|
+
|
|
1059
|
+
```
|
|
1060
|
+
USAGE
|
|
1061
|
+
$ me plugins update [-h] [-v]
|
|
1062
|
+
|
|
1063
|
+
FLAGS
|
|
1064
|
+
-h, --help Show CLI help.
|
|
1065
|
+
-v, --verbose
|
|
1066
|
+
|
|
1067
|
+
DESCRIPTION
|
|
1068
|
+
Update installed plugins.
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.55/src/commands/plugins/update.ts)_
|
|
1072
|
+
|
|
1073
|
+
## `me prettier FILEPATH`
|
|
1074
|
+
|
|
1075
|
+
Use Prettier to format file,集成:『@prettier/plugin-xml、prettier-plugin-toml、prettier-plugin-sh』、prettier-plugin-nginx
|
|
1076
|
+
|
|
1077
|
+
```
|
|
1078
|
+
USAGE
|
|
1079
|
+
$ me prettier FILEPATH [-c <value>] [-i <value>] [-v]
|
|
1080
|
+
|
|
1081
|
+
ARGUMENTS
|
|
1082
|
+
FILEPATH file path that need to be formatted by Prettier
|
|
1083
|
+
|
|
1084
|
+
FLAGS
|
|
1085
|
+
-c, --config=<value> [default: built_in] built_in:使用内置规则(默认值), 传入路径则是使用自定义配置,
|
|
1086
|
+
auto:自动检测config file
|
|
1087
|
+
-i, --ignore=<value> [default: built_in] built_in:使用内置规则(默认值), 传入路径则是使用自定义规则,
|
|
1088
|
+
auto:自动检测ignore file
|
|
1089
|
+
-v, --verbose Show verbose output
|
|
1090
|
+
|
|
1091
|
+
DESCRIPTION
|
|
1092
|
+
Use Prettier to format
|
|
1093
|
+
file,集成:『@prettier/plugin-xml、prettier-plugin-toml、prettier-plugin-sh』、prettier-plugin-nginx
|
|
1094
|
+
|
|
1095
|
+
EXAMPLES
|
|
1096
|
+
$ me prettier ./tests/test.svg
|
|
1097
|
+
|
|
1098
|
+
$ me prettier ./src/file.ts --config ./.prettierrc.yaml
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1101
|
+
_See code: [src/commands/prettier/index.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/prettier/index.ts)_
|
|
1102
|
+
|
|
1103
|
+
## `me prettier reset`
|
|
1104
|
+
|
|
1105
|
+
reset prettier config and ignore file,『~/.meocli/.prettierrc.yaml, ~/.meocli/.prettierignore』
|
|
1106
|
+
|
|
1107
|
+
```
|
|
1108
|
+
USAGE
|
|
1109
|
+
$ me prettier reset [-v]
|
|
1110
|
+
|
|
1111
|
+
FLAGS
|
|
1112
|
+
-v, --verbose Show verbose output
|
|
1113
|
+
|
|
1114
|
+
DESCRIPTION
|
|
1115
|
+
reset prettier config and ignore file,『~/.meocli/.prettierrc.yaml, ~/.meocli/.prettierignore』
|
|
1116
|
+
|
|
1117
|
+
EXAMPLES
|
|
1118
|
+
$ me prettier reset --verbose
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
_See code: [src/commands/prettier/reset.ts](https://github.com/meme2046/meocli/blob/v0.1.7/src/commands/prettier/reset.ts)_
|
|
595
1122
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class ClashModify extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
filePath: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
templatePath: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static flags: {
|
|
10
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import traverse from "@babel/traverse";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import { Args, Command, Flags } from "@oclif/core";
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { extname } from "node:path";
|
|
6
|
+
import { objToAst, readJsAst, writeAst } from "../../lib/ast.js";
|
|
7
|
+
import { require } from "../../lib/commonjs.js";
|
|
8
|
+
export default class ClashModify extends Command {
|
|
9
|
+
static args = {
|
|
10
|
+
filePath: Args.string({ description: "目标js文件路径", required: true }),
|
|
11
|
+
templatePath: Args.string({
|
|
12
|
+
description: "template.json配置文件路径",
|
|
13
|
+
required: true,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
static description = "修改Clash脚本";
|
|
17
|
+
static examples = [
|
|
18
|
+
"<%= config.bin %> <%= command.id %> ./test.js ./template.json",
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
verbose: Flags.boolean({
|
|
22
|
+
char: "v",
|
|
23
|
+
default: false,
|
|
24
|
+
description: "Show verbose output",
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
const { args, flags } = await this.parse(ClashModify);
|
|
29
|
+
const { filePath, templatePath } = args;
|
|
30
|
+
const { verbose } = flags;
|
|
31
|
+
if (verbose) {
|
|
32
|
+
process.env.DEBUG = "oclif:me:js";
|
|
33
|
+
require("debug").enable(process.env.DEBUG);
|
|
34
|
+
}
|
|
35
|
+
if (!existsSync(filePath)) {
|
|
36
|
+
this.error(`file『${filePath}』not found`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!existsSync(templatePath)) {
|
|
40
|
+
this.error(`template file『${templatePath}』not found`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const templateContent = readFileSync(templatePath, "utf8");
|
|
44
|
+
const template = JSON.parse(templateContent);
|
|
45
|
+
const { ruleProviders, ruleSet, v6Domains } = template;
|
|
46
|
+
this.log("✔ 已读取 template.json 配置:");
|
|
47
|
+
this.log(` - ruleSet: ${JSON.stringify(ruleSet)}`);
|
|
48
|
+
this.log(` - ruleProviders: ${Object.keys(ruleProviders || {}).join(", ")}`);
|
|
49
|
+
this.log(` - v6Domains: ${JSON.stringify(v6Domains)}`);
|
|
50
|
+
this.log("");
|
|
51
|
+
const ast = await readJsAst(filePath);
|
|
52
|
+
traverse(ast, {
|
|
53
|
+
FunctionDeclaration: (path) => {
|
|
54
|
+
if (path.node.id?.name === "main") {
|
|
55
|
+
path.traverse({
|
|
56
|
+
TryStatement: (tryPath) => {
|
|
57
|
+
const tryBody = tryPath.node.block.body;
|
|
58
|
+
for (let i = tryBody.length - 1; i >= 0; i--) {
|
|
59
|
+
const stmt = tryBody[i];
|
|
60
|
+
if (t.isReturnStatement(stmt) &&
|
|
61
|
+
t.isIdentifier(stmt.argument) &&
|
|
62
|
+
stmt.argument.name === "config") {
|
|
63
|
+
const insertStatements = [];
|
|
64
|
+
// 1. ruleSet
|
|
65
|
+
if (ruleSet && Array.isArray(ruleSet)) {
|
|
66
|
+
const ruleSetVar = t.variableDeclaration("const", [
|
|
67
|
+
t.variableDeclarator(t.identifier("ruleSet"), objToAst(ruleSet)),
|
|
68
|
+
]);
|
|
69
|
+
insertStatements.push(ruleSetVar);
|
|
70
|
+
const rulesAssign = t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("config"), t.identifier("rules")), t.arrayExpression([
|
|
71
|
+
t.spreadElement(t.identifier("ruleSet")),
|
|
72
|
+
t.spreadElement(t.memberExpression(t.identifier("config"), t.identifier("rules"))),
|
|
73
|
+
])));
|
|
74
|
+
insertStatements.push(rulesAssign);
|
|
75
|
+
this.log("✔ 已添加 ruleSet 到 config.rules 开头");
|
|
76
|
+
}
|
|
77
|
+
// 2. ruleProviders
|
|
78
|
+
if (ruleProviders && typeof ruleProviders === "object") {
|
|
79
|
+
const ruleProvidersVar = t.variableDeclaration("const", [
|
|
80
|
+
t.variableDeclarator(t.identifier("ruleProviders"), objToAst(ruleProviders)),
|
|
81
|
+
]);
|
|
82
|
+
insertStatements.push(ruleProvidersVar);
|
|
83
|
+
// 使用 forEach 方式合并 ruleProviders
|
|
84
|
+
const forEachRuleProviders = t.expressionStatement(t.callExpression(t.memberExpression(t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("keys")), [t.identifier("ruleProviders")]), t.identifier("forEach")), [
|
|
85
|
+
t.functionExpression(null, [t.identifier("key")], t.blockStatement([
|
|
86
|
+
t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.memberExpression(t.identifier("config"), t.stringLiteral("rule-providers"), true), t.identifier("key"), true), t.memberExpression(t.identifier("ruleProviders"), t.identifier("key"), true))),
|
|
87
|
+
])),
|
|
88
|
+
]));
|
|
89
|
+
insertStatements.push(forEachRuleProviders);
|
|
90
|
+
this.log(`✔ 已合并 ruleProviders: ${Object.keys(ruleProviders).join(", ")}`);
|
|
91
|
+
}
|
|
92
|
+
// 3. IPv6 配置
|
|
93
|
+
if (v6Domains && Array.isArray(v6Domains)) {
|
|
94
|
+
const v6DomainsVar = t.variableDeclaration("const", [
|
|
95
|
+
t.variableDeclarator(t.identifier("v6Domains"), objToAst(v6Domains)),
|
|
96
|
+
]);
|
|
97
|
+
insertStatements.push(v6DomainsVar, t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("config"), t.identifier("ipv6")), t.booleanLiteral(true))), t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.memberExpression(t.identifier("config"), t.identifier("dns")), t.identifier("ipv6")), t.booleanLiteral(true))));
|
|
98
|
+
// domesticDoH
|
|
99
|
+
const domesticDoHDecl = t.variableDeclaration("const", [
|
|
100
|
+
t.variableDeclarator(t.identifier("domesticDoH"), t.arrayExpression([
|
|
101
|
+
t.stringLiteral("https://dns.alidns.com/dns-query"),
|
|
102
|
+
t.stringLiteral("https://doh.pub/dns-query"),
|
|
103
|
+
])),
|
|
104
|
+
]);
|
|
105
|
+
insertStatements.push(domesticDoHDecl);
|
|
106
|
+
// ipv6Doh
|
|
107
|
+
const ipv6DohDecl = t.variableDeclaration("const", [
|
|
108
|
+
t.variableDeclarator(t.identifier("ipv6Doh"), t.arrayExpression([
|
|
109
|
+
t.stringLiteral("https://[2402:4e00::]/dns-query"),
|
|
110
|
+
t.stringLiteral("https://[2400:3200::1]/dns-query"),
|
|
111
|
+
])),
|
|
112
|
+
]);
|
|
113
|
+
insertStatements.push(ipv6DohDecl);
|
|
114
|
+
// mixedDns
|
|
115
|
+
const mixedDnsDecl = t.variableDeclaration("const", [
|
|
116
|
+
t.variableDeclarator(t.identifier("mixedDns"), t.arrayExpression([
|
|
117
|
+
t.spreadElement(t.identifier("domesticDoH")),
|
|
118
|
+
t.spreadElement(t.identifier("ipv6Doh")),
|
|
119
|
+
])),
|
|
120
|
+
]);
|
|
121
|
+
insertStatements.push(mixedDnsDecl);
|
|
122
|
+
// v6Domains.forEach nameserver-policy
|
|
123
|
+
const forEachDnsPolicy = t.expressionStatement(t.callExpression(t.memberExpression(t.identifier("v6Domains"), t.identifier("forEach")), [
|
|
124
|
+
t.functionExpression(null, [t.identifier("host")], t.blockStatement([
|
|
125
|
+
t.ifStatement(t.unaryExpression("!", t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("config"), t.identifier("dns")), t.stringLiteral("nameserver-policy"), true), t.identifier("host"), true)), t.blockStatement([
|
|
126
|
+
t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("config"), t.identifier("dns")), t.stringLiteral("nameserver-policy"), true), t.identifier("host"), true), t.callExpression(t.memberExpression(t.identifier("mixedDns"), t.identifier("slice")), []))),
|
|
127
|
+
])),
|
|
128
|
+
])),
|
|
129
|
+
]));
|
|
130
|
+
insertStatements.push(forEachDnsPolicy);
|
|
131
|
+
// v6Domains.forEach fake-ip-filter
|
|
132
|
+
const forEachFakeIpFilter = t.expressionStatement(t.callExpression(t.memberExpression(t.identifier("v6Domains"), t.identifier("forEach")), [
|
|
133
|
+
t.functionExpression(null, [t.identifier("domain")], t.blockStatement([
|
|
134
|
+
t.ifStatement(t.unaryExpression("!", t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("config"), t.identifier("dns")), t.stringLiteral("fake-ip-filter"), true), t.identifier("includes")), [t.identifier("domain")])), t.blockStatement([
|
|
135
|
+
t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("config"), t.identifier("dns")), t.stringLiteral("fake-ip-filter"), true), t.identifier("push")), [t.identifier("domain")])),
|
|
136
|
+
])),
|
|
137
|
+
])),
|
|
138
|
+
]));
|
|
139
|
+
insertStatements.push(forEachFakeIpFilter);
|
|
140
|
+
this.log(`✔ 已添加 IPv6 配置,目标域名: ${v6Domains.join(", ")}`);
|
|
141
|
+
}
|
|
142
|
+
if (insertStatements.length > 0) {
|
|
143
|
+
tryBody.splice(i, 0, ...insertStatements);
|
|
144
|
+
this.log("");
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
const ext = extname(filePath);
|
|
155
|
+
const baseName = filePath.slice(0, -ext.length);
|
|
156
|
+
const outputPath = `${baseName}_update${ext}`;
|
|
157
|
+
await writeAst(ast, outputPath);
|
|
158
|
+
this.log("✔ 自定义clash配置添加完成");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
/** JS对象转babel ObjectExpression AST节点 */
|
|
3
|
+
/** JS值转babel AST节点(支持对象和数组) */
|
|
4
|
+
export declare function objToAst(value: Record<string, unknown> | unknown[]): t.Expression;
|
|
5
|
+
/** 读取JS文件并返回AST */
|
|
6
|
+
export declare function readJsAst(filePath: string): Promise<import("@babel/parser").ParseResult<t.File>>;
|
|
7
|
+
/** AST 生成并覆盖写入文件 */
|
|
8
|
+
export declare function writeAst(ast: t.Node, filePath: string): Promise<void>;
|
package/dist/lib/ast.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { generate } from "@babel/generator";
|
|
2
|
+
import { parse } from "@babel/parser";
|
|
3
|
+
import * as t from "@babel/types";
|
|
4
|
+
import fs from "node:fs/promises";
|
|
5
|
+
/** 创建字面量节点 */
|
|
6
|
+
function createLiteralNode(value) {
|
|
7
|
+
if (typeof value === "string")
|
|
8
|
+
return t.stringLiteral(value);
|
|
9
|
+
if (typeof value === "number")
|
|
10
|
+
return t.numericLiteral(value);
|
|
11
|
+
if (typeof value === "boolean")
|
|
12
|
+
return t.booleanLiteral(value);
|
|
13
|
+
return t.stringLiteral(String(value));
|
|
14
|
+
}
|
|
15
|
+
/** JS对象转babel ObjectExpression AST节点 */
|
|
16
|
+
/** JS值转babel AST节点(支持对象和数组) */
|
|
17
|
+
export function objToAst(value) {
|
|
18
|
+
// 如果是数组
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
const elements = value.map((item) => {
|
|
21
|
+
if (typeof item === "string" ||
|
|
22
|
+
typeof item === "number" ||
|
|
23
|
+
typeof item === "boolean") {
|
|
24
|
+
return createLiteralNode(item);
|
|
25
|
+
}
|
|
26
|
+
// 递归处理嵌套对象/数组
|
|
27
|
+
return objToAst(item);
|
|
28
|
+
});
|
|
29
|
+
return t.arrayExpression(elements);
|
|
30
|
+
}
|
|
31
|
+
// 如果是对象
|
|
32
|
+
const props = [];
|
|
33
|
+
for (const [k, v] of Object.entries(value)) {
|
|
34
|
+
let valNode;
|
|
35
|
+
if (typeof v === "string" ||
|
|
36
|
+
typeof v === "number" ||
|
|
37
|
+
typeof v === "boolean") {
|
|
38
|
+
valNode = createLiteralNode(v);
|
|
39
|
+
}
|
|
40
|
+
else if (Array.isArray(v)) {
|
|
41
|
+
// 递归处理数组
|
|
42
|
+
valNode = objToAst(v);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// 递归处理嵌套对象
|
|
46
|
+
valNode = objToAst(v);
|
|
47
|
+
}
|
|
48
|
+
// 判断键名是否为有效标识符,不是则使用字符串字面量
|
|
49
|
+
const keyNode = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k)
|
|
50
|
+
? t.identifier(k)
|
|
51
|
+
: t.stringLiteral(k);
|
|
52
|
+
// shorthand 只能在 key 是 Identifier 时为 true
|
|
53
|
+
// computed: false 表示不使用方括号语法
|
|
54
|
+
props.push(t.objectProperty(keyNode, valNode, false, false));
|
|
55
|
+
}
|
|
56
|
+
return t.objectExpression(props);
|
|
57
|
+
}
|
|
58
|
+
/** 读取JS文件并返回AST */
|
|
59
|
+
export async function readJsAst(filePath) {
|
|
60
|
+
const source = await fs.readFile(filePath, "utf8");
|
|
61
|
+
return parse(source, {
|
|
62
|
+
sourceType: "script",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** AST 生成并覆盖写入文件 */
|
|
66
|
+
export async function writeAst(ast, filePath) {
|
|
67
|
+
const output = generate(ast, { compact: false, retainLines: true }).code;
|
|
68
|
+
await fs.writeFile(filePath, output, "utf8");
|
|
69
|
+
}
|
package/dist/tests/d3-test.js
CHANGED
|
@@ -12,4 +12,4 @@ console.log(formatNumberWithUnit(1));
|
|
|
12
12
|
console.log(formatNumberWithUnit(150_123)); // 输出: 150.1k
|
|
13
13
|
console.log(formatNumberWithUnit(23_200_000)); // 输出: 23.2M
|
|
14
14
|
console.log(formatNumberWithUnit(1_600_000_000)); // 输出: 1.6B
|
|
15
|
-
console.log(formatNumberWithUnit(123_456, 2)); // 输出:
|
|
15
|
+
console.log(formatNumberWithUnit(123_456, 2)); // 输出: 124.46k(自定义精度)
|
package/oclif.manifest.json
CHANGED
|
@@ -143,6 +143,49 @@
|
|
|
143
143
|
"world.js"
|
|
144
144
|
]
|
|
145
145
|
},
|
|
146
|
+
"js:clash": {
|
|
147
|
+
"aliases": [],
|
|
148
|
+
"args": {
|
|
149
|
+
"filePath": {
|
|
150
|
+
"description": "目标js文件路径",
|
|
151
|
+
"name": "filePath",
|
|
152
|
+
"required": true
|
|
153
|
+
},
|
|
154
|
+
"templatePath": {
|
|
155
|
+
"description": "template.json配置文件路径",
|
|
156
|
+
"name": "templatePath",
|
|
157
|
+
"required": true
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"description": "修改Clash脚本",
|
|
161
|
+
"examples": [
|
|
162
|
+
"<%= config.bin %> <%= command.id %> ./test.js ./template.json"
|
|
163
|
+
],
|
|
164
|
+
"flags": {
|
|
165
|
+
"verbose": {
|
|
166
|
+
"char": "v",
|
|
167
|
+
"description": "Show verbose output",
|
|
168
|
+
"name": "verbose",
|
|
169
|
+
"allowNo": false,
|
|
170
|
+
"type": "boolean"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"hasDynamicHelp": false,
|
|
174
|
+
"hiddenAliases": [],
|
|
175
|
+
"id": "js:clash",
|
|
176
|
+
"pluginAlias": "meocli",
|
|
177
|
+
"pluginName": "meocli",
|
|
178
|
+
"pluginType": "core",
|
|
179
|
+
"strict": true,
|
|
180
|
+
"enableJsonFlag": false,
|
|
181
|
+
"isESM": true,
|
|
182
|
+
"relativePath": [
|
|
183
|
+
"dist",
|
|
184
|
+
"commands",
|
|
185
|
+
"js",
|
|
186
|
+
"clash.js"
|
|
187
|
+
]
|
|
188
|
+
},
|
|
146
189
|
"prettier": {
|
|
147
190
|
"aliases": [],
|
|
148
191
|
"args": {
|
|
@@ -235,5 +278,5 @@
|
|
|
235
278
|
]
|
|
236
279
|
}
|
|
237
280
|
},
|
|
238
|
-
"version": "0.1.
|
|
281
|
+
"version": "0.1.8"
|
|
239
282
|
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meocli",
|
|
3
3
|
"description": "Node CLI generated with oclif, Integrate Prettier",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"author": "meme2046",
|
|
6
6
|
"bin": {
|
|
7
7
|
"me": "./bin/run.js"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/meme2046/meocli/issues",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@
|
|
11
|
+
"@babel/generator": "^8.0.0",
|
|
12
|
+
"@babel/parser": "^8.0.0",
|
|
13
|
+
"@babel/traverse": "^8.0.0",
|
|
14
|
+
"@babel/types": "^8.0.0",
|
|
15
|
+
"@oclif/core": "^4.11.14",
|
|
12
16
|
"@oclif/plugin-help": "^6",
|
|
13
17
|
"@oclif/plugin-plugins": "^5",
|
|
14
18
|
"@prettier/plugin-xml": "^3.4.2",
|
|
15
19
|
"d3-format": "^3.1.2",
|
|
16
|
-
"dayjs": "^1.11.
|
|
20
|
+
"dayjs": "^1.11.21",
|
|
17
21
|
"debug": "^4.4.3",
|
|
18
|
-
"dotenv": "^17.2
|
|
22
|
+
"dotenv": "^17.4.2",
|
|
19
23
|
"execa": "^9.6.1",
|
|
20
|
-
"js-yaml": "^4.
|
|
21
|
-
"lodash": "^4.
|
|
22
|
-
"prettier": "^3.
|
|
24
|
+
"js-yaml": "^4.3.0",
|
|
25
|
+
"lodash": "^4.18.1",
|
|
26
|
+
"prettier": "^3.9.4",
|
|
23
27
|
"prettier-plugin-nginx": "^1.0.3",
|
|
24
|
-
"prettier-plugin-sh": "^0.18.
|
|
28
|
+
"prettier-plugin-sh": "^0.18.1",
|
|
25
29
|
"prettier-plugin-toml": "^2.0.6",
|
|
26
30
|
"trading-signals": "^7.4.3"
|
|
27
31
|
},
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
"@types/chai": "^4",
|
|
33
37
|
"@types/d3-format": "^3.0.4",
|
|
34
38
|
"@types/js-yaml": "^4.0.9",
|
|
35
|
-
"@types/lodash": "^4.17.
|
|
39
|
+
"@types/lodash": "^4.17.24",
|
|
36
40
|
"@types/mocha": "^10",
|
|
37
41
|
"@types/node": "^18",
|
|
38
42
|
"chai": "^4",
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
"eslint-config-oclif": "^6",
|
|
41
45
|
"eslint-config-prettier": "^10",
|
|
42
46
|
"mocha": "^10",
|
|
43
|
-
"npm-check-updates": "^19.
|
|
47
|
+
"npm-check-updates": "^19.6.6",
|
|
44
48
|
"oclif": "^4",
|
|
45
49
|
"shx": "^0.3.3",
|
|
46
50
|
"ts-node": "^10",
|
|
@@ -78,7 +82,10 @@
|
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
},
|
|
81
|
-
"repository":
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "meme2046/meocli"
|
|
88
|
+
},
|
|
82
89
|
"types": "dist/index.d.ts",
|
|
83
90
|
"scripts": {
|
|
84
91
|
"ncu": "ncu --target minor --reject webpack,shx",
|