@wenyan-md/cli 1.0.0 → 1.0.2
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 +80 -25
- package/dist/commands/publish.js +7 -2
- package/dist/commands/render.js +7 -2
- package/dist/{commands → types/commands}/publish.d.ts +0 -1
- package/dist/{commands → types/commands}/render.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/{utils.d.ts → types/utils.d.ts} +0 -1
- package/package.json +25 -11
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/render.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,21 +4,37 @@
|
|
|
4
4
|
|
|
5
5
|
# 文颜 CLI
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
「文颜」是一款多平台排版美化工具,让你将 Markdown 一键发布至微信公众号、知乎、今日头条等主流写作平台。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**文颜**现已推出多个版本:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
* [macOS App Store 版](https://github.com/caol64/wenyan) - MAC 桌面应用
|
|
12
|
+
* [Windows + Linux 版](https://github.com/caol64/wenyan-pc) - 跨平台桌面应用
|
|
13
|
+
* [CLI 版本](https://github.com/caol64/wenyan-cli) - CI/CD 或脚本自动化发布公众号文章
|
|
14
|
+
* [MCP 版本](https://github.com/caol64/wenyan-mcp) - 让 AI 自动发布公众号文章
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
本项目是 **文颜的 CLI 版本**。
|
|
14
17
|
|
|
15
|
-
##
|
|
18
|
+
## 功能
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
* 使用内置主题对 Markdown 内容排版
|
|
21
|
+
* 支持图片自动上传
|
|
22
|
+
* 支持数学公式渲染
|
|
23
|
+
* 一键发布文章到微信公众号草稿箱
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
## 主题效果
|
|
26
|
+
|
|
27
|
+
👉 [内置主题预览](https://yuzhi.tech/docs/wenyan/theme)
|
|
28
|
+
|
|
29
|
+
文颜采用了多个开源的 Typora 主题,在此向各位作者表示感谢:
|
|
30
|
+
|
|
31
|
+
- [Orange Heart](https://github.com/evgo2017/typora-theme-orange-heart)
|
|
32
|
+
- [Rainbow](https://github.com/thezbm/typora-theme-rainbow)
|
|
33
|
+
- [Lapis](https://github.com/YiNNx/typora-theme-lapis)
|
|
34
|
+
- [Pie](https://github.com/kevinzhao2233/typora-theme-pie)
|
|
35
|
+
- [Maize](https://github.com/BEATREE/typora-maize-theme)
|
|
36
|
+
- [Purple](https://github.com/hliu202/typora-purple-theme)
|
|
37
|
+
- [物理猫-薄荷](https://github.com/sumruler/typora-theme-phycat)
|
|
22
38
|
|
|
23
39
|
## 安装
|
|
24
40
|
|
|
@@ -34,7 +50,41 @@ npm install -g @wenyan-md/cli
|
|
|
34
50
|
wenyan <command> [options]
|
|
35
51
|
```
|
|
36
52
|
|
|
37
|
-
|
|
53
|
+
## 环境变量
|
|
54
|
+
|
|
55
|
+
某些功能(如发布到微信公众号)需要配置以下环境变量:
|
|
56
|
+
|
|
57
|
+
* `WECHAT_APP_ID`
|
|
58
|
+
* `WECHAT_APP_SECRET`
|
|
59
|
+
|
|
60
|
+
### macOS / Linux
|
|
61
|
+
|
|
62
|
+
可在命令前临时设置:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
WECHAT_APP_ID=xxx WECHAT_APP_SECRET=yyy wenyan publish "your markdown"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
或在 `~/.bashrc` / `~/.zshrc` 中永久添加:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
export WECHAT_APP_ID=xxx
|
|
72
|
+
export WECHAT_APP_SECRET=yyy
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Windows (PowerShell)
|
|
76
|
+
|
|
77
|
+
临时设置:
|
|
78
|
+
|
|
79
|
+
```powershell
|
|
80
|
+
$env:WECHAT_APP_ID="xxx"; $env:WECHAT_APP_SECRET="yyy"; wenyan publish "your markdown"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
永久设置(在环境变量里添加):
|
|
84
|
+
|
|
85
|
+
控制面板 → 系统和安全 → 系统 → 高级系统设置 → 环境变量 → 添加 `WECHAT_APP_ID` 和 `WECHAT_APP_SECRET`。
|
|
86
|
+
|
|
87
|
+
## 子命令
|
|
38
88
|
|
|
39
89
|
`publish`
|
|
40
90
|
|
|
@@ -47,10 +97,27 @@ wenyan <command> [options]
|
|
|
47
97
|
### 选项
|
|
48
98
|
|
|
49
99
|
- `-t`,主题id,默认`default`
|
|
100
|
+
- default
|
|
101
|
+
- orangeheart
|
|
102
|
+
- rainbow
|
|
103
|
+
- lapis
|
|
104
|
+
- pie
|
|
105
|
+
- maize
|
|
106
|
+
- purple
|
|
107
|
+
- phycat
|
|
50
108
|
- `-h`,代码高亮主题,默认`solarized-light`
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
109
|
+
- atom-one-dark
|
|
110
|
+
- atom-one-light
|
|
111
|
+
- dracula
|
|
112
|
+
- github-dark
|
|
113
|
+
- github
|
|
114
|
+
- monokai
|
|
115
|
+
- solarized-dark
|
|
116
|
+
- solarized-light
|
|
117
|
+
- xcode
|
|
118
|
+
- 代码块默认使用 Mac 风格,如要关闭:`--no-mac-style`
|
|
119
|
+
|
|
120
|
+
## 示例
|
|
54
121
|
|
|
55
122
|
直接传入内容:
|
|
56
123
|
|
|
@@ -64,15 +131,11 @@ wenyan publish "# Hello, Wenyan" -t lapis -h solarized-light
|
|
|
64
131
|
cat example.md | wenyan publish -t lapis -h solarized-light --no-mac-style
|
|
65
132
|
```
|
|
66
133
|
|
|
67
|
-
---
|
|
68
|
-
|
|
69
134
|
## 微信公众号 IP 白名单
|
|
70
135
|
|
|
71
136
|
请务必将服务器 IP 加入公众号平台的 IP 白名单,以确保上传接口调用成功。
|
|
72
137
|
详细配置说明请参考:[https://yuzhi.tech/docs/wenyan/upload](https://yuzhi.tech/docs/wenyan/upload)
|
|
73
138
|
|
|
74
|
-
---
|
|
75
|
-
|
|
76
139
|
## 配置说明(Frontmatter)
|
|
77
140
|
|
|
78
141
|
为了可以正确上传文章,需要在每一篇 Markdown 文章的开头添加一段`frontmatter`,提供`title`、`cover`两个字段:
|
|
@@ -90,8 +153,6 @@ cover: /Users/lei/Downloads/result_image.jpg
|
|
|
90
153
|
* 如果正文有至少一张图片,可省略,此时将使用其中一张作为封面;
|
|
91
154
|
* 如果正文无图片,则必须提供 cover。
|
|
92
155
|
|
|
93
|
-
---
|
|
94
|
-
|
|
95
156
|
## 关于图片自动上传
|
|
96
157
|
|
|
97
158
|
* 支持图片路径:
|
|
@@ -99,8 +160,6 @@ cover: /Users/lei/Downloads/result_image.jpg
|
|
|
99
160
|
* 本地路径(如:`/Users/lei/Downloads/result_image.jpg`)
|
|
100
161
|
* 网络路径(如:`https://example.com/image.jpg`)
|
|
101
162
|
|
|
102
|
-
---
|
|
103
|
-
|
|
104
163
|
## 示例文章格式
|
|
105
164
|
|
|
106
165
|
```md
|
|
@@ -118,14 +177,10 @@ cover: /Users/lei/Downloads/result_image.jpg
|
|
|
118
177
|

|
|
119
178
|
```
|
|
120
179
|
|
|
121
|
-
---
|
|
122
|
-
|
|
123
180
|
## 赞助
|
|
124
181
|
|
|
125
182
|
如果您觉得不错,可以给我家猫咪买点罐头吃。[喂猫❤️](https://yuzhi.tech/sponsor)
|
|
126
183
|
|
|
127
|
-
---
|
|
128
|
-
|
|
129
184
|
## License
|
|
130
185
|
|
|
131
186
|
Apache License Version 2.0
|
package/dist/commands/publish.js
CHANGED
|
@@ -28,8 +28,13 @@ export async function publishCommand(inputContent, options) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (error instanceof Error) {
|
|
32
|
+
console.error("An unexpected error occurred during publishing:");
|
|
33
|
+
console.error(error.message);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.error("An unexpected error occurred:", error);
|
|
37
|
+
}
|
|
33
38
|
process.exit(1);
|
|
34
39
|
}
|
|
35
40
|
}
|
package/dist/commands/render.js
CHANGED
|
@@ -14,8 +14,13 @@ export async function renderCommand(inputContent, options) {
|
|
|
14
14
|
// process.exit(0);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (error instanceof Error) {
|
|
18
|
+
console.error("An unexpected error occurred during publishing:");
|
|
19
|
+
console.error(error.message);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.error("An unexpected error occurred:", error);
|
|
23
|
+
}
|
|
19
24
|
process.exit(1);
|
|
20
25
|
}
|
|
21
26
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenyan-md/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A CLI tool for Wenyan markdown rendering & publishing",
|
|
5
5
|
"author": "Lei <caol64@gmail.com> (https://github.com/caol64)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"keywords": [
|
|
7
|
+
"keywords": [
|
|
8
|
+
"公众号",
|
|
9
|
+
"markdown",
|
|
10
|
+
"文颜",
|
|
11
|
+
"wenyan",
|
|
12
|
+
"wechat",
|
|
13
|
+
"publishing",
|
|
14
|
+
"renderer"
|
|
15
|
+
],
|
|
8
16
|
"type": "module",
|
|
9
17
|
"bin": {
|
|
10
18
|
"wenyan": "./bin/cli.js"
|
|
11
19
|
},
|
|
12
20
|
"main": "./dist/index.js",
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
14
22
|
"files": [
|
|
15
23
|
"dist",
|
|
16
24
|
"bin"
|
|
17
25
|
],
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
"homepage": "https://github.com/caol64/wenyan-cli#readme",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/caol64/wenyan-cli.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/caol64/wenyan-cli/issues"
|
|
24
33
|
},
|
|
25
|
-
"packageManager": "pnpm@10.7.1",
|
|
26
34
|
"dependencies": {
|
|
27
35
|
"@wenyan-md/core": "^1.0.2",
|
|
28
36
|
"commander": "^14.0.0"
|
|
@@ -32,5 +40,11 @@
|
|
|
32
40
|
"dotenv-cli": "^10.0.0",
|
|
33
41
|
"tsx": "^4.20.5",
|
|
34
42
|
"typescript": "^5.9.2"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc",
|
|
46
|
+
"dev": "tsx src/index.ts",
|
|
47
|
+
"test:render": "cat test/publish.md | pnpm wenyan render",
|
|
48
|
+
"test:publish": "cat test/publish.md | pnpm dotenv -e .env.test -- wenyan publish -t lapis"
|
|
35
49
|
}
|
|
36
|
-
}
|
|
50
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAIA,UAAU,aAAa;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,iBA6BhF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,aAAa,iBAiB3F"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAQjD"}
|