@dinoxx/dinox-cli 1.0.4 → 1.0.6
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 +32 -0
- package/dist/utils/tokenize.js +6 -17
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -520,3 +520,35 @@ dino <命令> <子命令> --help
|
|
|
520
520
|
dino note --help
|
|
521
521
|
dino note create --help
|
|
522
522
|
```
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 10. GitHub Action 自动发布 npm
|
|
527
|
+
|
|
528
|
+
仓库已内置工作流:`/Users/shanks/Documents/GitHub/dinox-cli/.github/workflows/publish-npm.yml`
|
|
529
|
+
|
|
530
|
+
### 10.1 先配置 Secret
|
|
531
|
+
|
|
532
|
+
在 GitHub 仓库设置里添加:
|
|
533
|
+
|
|
534
|
+
- `NPM_TOKEN`:npm 的 publish token(建议使用 granular token,并开启 bypass 2FA)
|
|
535
|
+
|
|
536
|
+
### 10.2 手动触发发布
|
|
537
|
+
|
|
538
|
+
1. 打开 GitHub 仓库 → **Actions** → **Publish NPM**
|
|
539
|
+
2. 点击 **Run workflow**
|
|
540
|
+
3. 选择参数:
|
|
541
|
+
- `dry_run`:`true` 只做演练,不真正发布
|
|
542
|
+
- `run_tests`:`true` 时会先执行测试
|
|
543
|
+
|
|
544
|
+
### 10.3 Push 自动触发
|
|
545
|
+
|
|
546
|
+
- 每次 push 到默认分支(当前为 `main`)会自动触发发布流程
|
|
547
|
+
- 为兼容分支命名迁移,workflow 也监听 `master`,但发布阶段会只允许默认分支执行
|
|
548
|
+
- 为防止递归触发,workflow 会跳过 `github-actions[bot]` 自己提交的版本 bump commit
|
|
549
|
+
|
|
550
|
+
### 10.4 工作流行为
|
|
551
|
+
|
|
552
|
+
- 只允许在仓库默认分支执行发布(默认分支改名后无需改 workflow 逻辑)
|
|
553
|
+
- 调用仓库脚本 `publish-npm.sh` 自动递增 patch 版本并发布
|
|
554
|
+
- 发布成功后自动提交 `package.json` 版本变更、打 `vX.Y.Z` tag 并 push 回仓库
|
package/dist/utils/tokenize.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
let jiebaReady = false;
|
|
1
|
+
import { Jieba } from '@node-rs/jieba';
|
|
2
|
+
import { dict } from '@node-rs/jieba/dict.js';
|
|
4
3
|
let jieba = null;
|
|
5
4
|
function ensureJiebaReady() {
|
|
6
|
-
if (
|
|
7
|
-
try {
|
|
8
|
-
jieba = require('nodejieba');
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
12
|
-
throw new Error(`Failed to load nodejieba module: ${message}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (jiebaReady) {
|
|
5
|
+
if (jieba) {
|
|
16
6
|
return;
|
|
17
7
|
}
|
|
18
8
|
try {
|
|
19
|
-
jieba.
|
|
20
|
-
jiebaReady = true;
|
|
9
|
+
jieba = Jieba.withDict(dict);
|
|
21
10
|
}
|
|
22
11
|
catch (error) {
|
|
23
12
|
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
-
throw new Error(`Failed to initialize
|
|
13
|
+
throw new Error(`Failed to initialize @node-rs/jieba: ${message}`);
|
|
25
14
|
}
|
|
26
15
|
}
|
|
27
16
|
function normalizeToken(token) {
|
|
@@ -40,7 +29,7 @@ export function tokenizeWithJieba(text, limit = 500) {
|
|
|
40
29
|
return [];
|
|
41
30
|
}
|
|
42
31
|
ensureJiebaReady();
|
|
43
|
-
const raw = jieba.
|
|
32
|
+
const raw = jieba.cutForSearch(text, false);
|
|
44
33
|
const tokens = [];
|
|
45
34
|
for (const token of raw) {
|
|
46
35
|
const normalized = normalizeToken(token);
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinoxx/dinox-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Dinox CLI",
|
|
5
5
|
"main": "dist/dinox.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -p tsconfig.json && node scripts/add-shebang.mjs",
|
|
8
8
|
"dev": "tsx src/dinox.ts",
|
|
9
9
|
"prepublishOnly": "npm run build",
|
|
10
|
-
"publish:npm": "sh
|
|
11
|
-
"publish:npm:dry-run": "sh
|
|
10
|
+
"publish:npm": "sh ./publish-npm.sh",
|
|
11
|
+
"publish:npm:dry-run": "sh ./publish-npm.sh --dry-run",
|
|
12
12
|
"start": "node dist/dinox.js",
|
|
13
|
-
"test": "node --test --import tsx test
|
|
13
|
+
"test": "node --test --import tsx test/*.test.ts"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"author": "",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"node": ">=20"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@powersync/
|
|
33
|
+
"@node-rs/jieba": "^2.0.1",
|
|
34
|
+
"@powersync/common": "^1.47.0",
|
|
35
|
+
"@powersync/node": "^0.17.1",
|
|
35
36
|
"@tiptap/core": "^3.20.0",
|
|
36
37
|
"@tiptap/extension-image": "^3.20.0",
|
|
37
38
|
"@tiptap/extension-list": "^3.20.0",
|
|
@@ -41,7 +42,6 @@
|
|
|
41
42
|
"@tiptap/starter-kit": "^3.20.0",
|
|
42
43
|
"better-sqlite3": "^12.6.2",
|
|
43
44
|
"commander": "^14.0.3",
|
|
44
|
-
"nodejieba": "^3.5.2",
|
|
45
45
|
"remark-gfm": "^4.0.1",
|
|
46
46
|
"remark-parse": "^11.0.0",
|
|
47
47
|
"remark-stringify": "^11.0.0",
|
|
@@ -58,8 +58,7 @@
|
|
|
58
58
|
"pnpm": {
|
|
59
59
|
"onlyBuiltDependencies": [
|
|
60
60
|
"better-sqlite3",
|
|
61
|
-
"esbuild"
|
|
62
|
-
"nodejieba"
|
|
61
|
+
"esbuild"
|
|
63
62
|
]
|
|
64
63
|
}
|
|
65
64
|
}
|