@wenyan-md/cli 2.0.1 → 2.0.3
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 +6 -0
- package/dist/cli.js +5 -2
- package/dist/commands/serve.js +2 -2
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/utils.d.ts +1 -0
- package/dist/utils.js +23 -5
- package/package.json +16 -11
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -125,5 +125,8 @@ async function runCommandWrapper(action) {
|
|
|
125
125
|
process.exit(1);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const program = createProgram();
|
|
129
|
-
|
|
128
|
+
export const program = createProgram();
|
|
129
|
+
// 仅在作为主模块运行时执行 parse,防止测试文件 import 时意外触发
|
|
130
|
+
if (import.meta.main) {
|
|
131
|
+
program.parse(process.argv);
|
|
132
|
+
}
|
package/dist/commands/serve.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import crypto from "node:crypto";
|
|
5
5
|
import { configDir } from "@wenyan-md/core/wrapper";
|
|
6
6
|
import multer from "multer";
|
|
7
|
-
import { publishToWechatDraft } from "@wenyan-md/core/
|
|
7
|
+
import { publishToWechatDraft } from "@wenyan-md/core/wrapper";
|
|
8
8
|
class AppError extends Error {
|
|
9
9
|
message;
|
|
10
10
|
constructor(message) {
|
|
@@ -214,7 +214,7 @@ async function cleanupOldUploads() {
|
|
|
214
214
|
await fs.unlink(filePath);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
catch (
|
|
217
|
+
catch (_e) {
|
|
218
218
|
// 忽略单个文件处理错误
|
|
219
219
|
}
|
|
220
220
|
}
|
package/dist/types/cli.d.ts
CHANGED
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function readStdin(): Promise<string>;
|
|
2
|
+
export declare function readStream(stream: NodeJS.ReadableStream): Promise<string>;
|
|
2
3
|
export declare function getInputContent(inputContent?: string, file?: string): Promise<{
|
|
3
4
|
content: string;
|
|
4
5
|
absoluteDirPath: string | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import { getNormalizeFilePath } from "@wenyan-md/core/wrapper";
|
|
4
|
-
export
|
|
4
|
+
export function readStdin() {
|
|
5
|
+
return readStream(process.stdin);
|
|
6
|
+
}
|
|
7
|
+
export async function readStream(stream) {
|
|
5
8
|
return new Promise((resolve, reject) => {
|
|
6
9
|
let data = "";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
stream.setEncoding?.("utf8");
|
|
11
|
+
const onData = (chunk) => (data += chunk);
|
|
12
|
+
const onEnd = () => {
|
|
13
|
+
cleanup();
|
|
14
|
+
resolve(data);
|
|
15
|
+
};
|
|
16
|
+
const onError = (err) => {
|
|
17
|
+
cleanup();
|
|
18
|
+
reject(err);
|
|
19
|
+
};
|
|
20
|
+
const cleanup = () => {
|
|
21
|
+
stream.removeListener("data", onData);
|
|
22
|
+
stream.removeListener("end", onEnd);
|
|
23
|
+
stream.removeListener("error", onError);
|
|
24
|
+
};
|
|
25
|
+
stream.on("data", onData);
|
|
26
|
+
stream.on("end", onEnd);
|
|
27
|
+
stream.on("error", onError);
|
|
28
|
+
stream.resume?.();
|
|
11
29
|
});
|
|
12
30
|
}
|
|
13
31
|
export async function getInputContent(inputContent, file) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenyan-md/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/caol64/wenyan-cli/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@wenyan-md/core": "^
|
|
34
|
+
"@wenyan-md/core": "^3.0.3",
|
|
35
35
|
"commander": "^14.0.0",
|
|
36
36
|
"express": "^5.2.1",
|
|
37
37
|
"form-data-encoder": "^4.1.0",
|
|
@@ -40,24 +40,29 @@
|
|
|
40
40
|
"multer": "^2.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^10.0.1",
|
|
43
44
|
"@types/express": "^5.0.6",
|
|
44
45
|
"@types/multer": "^2.0.0",
|
|
45
46
|
"@types/node": "^24.3.0",
|
|
46
|
-
"
|
|
47
|
+
"eslint": "^10.1.0",
|
|
48
|
+
"globals": "^17.4.0",
|
|
47
49
|
"tsx": "^4.21.0",
|
|
48
50
|
"typescript": "^5.9.2",
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
+
"typescript-eslint": "^8.58.0"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
55
|
},
|
|
52
56
|
"scripts": {
|
|
53
57
|
"build": "tsc",
|
|
54
58
|
"upgrade:core": "pnpm update @wenyan-md/core",
|
|
55
|
-
"
|
|
59
|
+
"test": "node --import tsx --test",
|
|
60
|
+
"test:watch": "node --import tsx --test --watch",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"lint": "eslint . --fix",
|
|
56
63
|
"test:bin": "pnpm build && node ./dist/cli.js render -f tests/publish.md -c tests/manhua.css --no-mac-style",
|
|
57
|
-
"test:
|
|
58
|
-
"test:
|
|
59
|
-
"test:
|
|
60
|
-
"test:realPublish": "pnpm build && pnpm dotenv -e .env.test -- node ./dist/cli.js publish -f tests/publish.md -c tests/manhua.css --no-mac-style",
|
|
61
|
-
"test:serverPublish": "pnpm build && node ./dist/cli.js publish -f tests/publish.md -c tests/manhua.css --no-mac-style --server http://localhost:3000"
|
|
64
|
+
"test:realPublish": "pnpm build && node --env-file=.env.test ./dist/cli.js publish -f tests/publish.md -t phycat",
|
|
65
|
+
"test:serverPublish": "pnpm build && node ./dist/cli.js publish -f tests/publish.md -c tests/manhua.css --no-mac-style --server http://localhost:3000",
|
|
66
|
+
"test:serve": "pnpm build && node --env-file=.env.test ./dist/cli.js serve"
|
|
62
67
|
}
|
|
63
68
|
}
|