oh-my-dws 0.0.1 → 0.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 CHANGED
@@ -157,11 +157,31 @@ dws chat +chat-messages --group "<cid>" --page-all --download-resources --output
157
157
  ## 开发
158
158
 
159
159
  ```bash
160
- node bin/oh-my-dws.js --no-open --port 8850 # 本地调试
161
- npm pack --dry-run # 检查发布内容
162
- npm publish # 发布(需 npm 登录)
160
+ node bin/oh-my-dws.js --no-open --port 26000 # 本地调试(前台)
161
+ npm run check # 语法 + 网页 id 引用自检
162
+ npm pack --dry-run # 检查发布内容
163
163
  ```
164
164
 
165
+ ## 发版(打 tag 自动发 npm)
166
+
167
+ 仓库里已有 `.github/workflows/release.yml`:**推 `v*` tag 就自动 `npm publish`**。
168
+
169
+ 1. 一次性(二选一):
170
+ - **可信发布(推荐)**:npm 包页面 `/access` → Trusted Publishers → Add publisher → GitHub Actions,
171
+ 填 `duzhenxun` / `oh-my-dws` / `release.yml`,Environment 留空;不用任何 token
172
+ - **或用 token**:npm 建 **Automation** token,存进 GitHub Secrets,名字 `NPM_TOKEN`
173
+ 2. 以后一条命令发版:
174
+
175
+ ```bash
176
+ npm run release # 0.0.1 → 0.0.2(改版本 + commit + tag + push)
177
+ npm run release:minor # → 0.1.0
178
+ npm run release:major # → 1.0.0
179
+ ```
180
+
181
+ CI 会校验 **tag 与 `package.json` 版本一致**、跑 `npm run check`、`npm pack --dry-run`、
182
+ 已发布过则跳过,最后 `npm publish --access public` 并建 GitHub Release。
183
+ 细节与报错处理见 [docs/使用说明.md](docs/使用说明.md)。
184
+
165
185
  ## 注意
166
186
 
167
187
  - 图片消息正文只返回 `mediaId`,需要实际图片时由网页按需下载。
@@ -113,17 +113,77 @@ oh-my-dws start
113
113
 
114
114
  **macOS 双击 `启动.command`**:等价 `oh-my-dws start`(后台常驻 + 开浏览器),关掉终端窗口服务照旧跑;停用 `oh-my-dws stop`。
115
115
 
116
- ## 六、自己发布这个包
116
+ ## 六、发版:打 tag 自动发 npm
117
+
118
+ 发版已经交给 CI(`.github/workflows/release.yml`):**推 `v*` tag → GitHub Actions 自动 `npm publish`**。
119
+
120
+ ### 一次性配置(二选一)
121
+
122
+ **方式 A:可信发布(推荐,不用管 token)**
123
+
124
+ 在 https://www.npmjs.com/package/oh-my-dws/access → **Trusted Publishers** → Add publisher,
125
+ 选 **GitHub Actions**,按这样填(大小写、名字必须一模一样):
126
+
127
+ | 字段 | 填什么 |
128
+ |---|---|
129
+ | Publisher | `GitHub Actions` |
130
+ | Organization or user | `duzhenxun` |
131
+ | Repository | `oh-my-dws` |
132
+ | Workflow filename | `release.yml` |
133
+ | Environment name | 留空 |
134
+
135
+ 保存后 CI 里不需要任何 token;workflow 已带 `id-token: write` 并把 npm 升到 ≥ 11.5.1。
136
+
137
+ **方式 B:Automation token(旧做法)**
138
+
139
+ 1. npmjs.com → Access Tokens → Generate New Token → **Automation**
140
+ 2. 仓库 → Settings → Secrets and variables → Actions → New repository secret,名字 `NPM_TOKEN`
141
+
142
+ workflow 两种都兼容:有 `NPM_TOKEN` 就用它,没有就走 OIDC 可信发布。
143
+
144
+ > 别加 `--provenance`:provenance 只允许**公开仓库**,本仓库是 private,加了会 422。
145
+
146
+ ### 以后发版
147
+
148
+ ```bash
149
+ npm run release # 补丁版 0.0.1 → 0.0.2(改 package.json + commit + tag + push)
150
+ npm run release:minor # 次版本 0.1.0
151
+ npm run release:major # 主版本 1.0.0
152
+ ```
153
+
154
+ 这三个脚本做的是 `npm version <x> -m "chore: release v%s"` + `git push --follow-tags`,
155
+ tag 推上去后 CI 自动跑完发布。想手动控制也可以:
117
156
 
118
157
  ```bash
119
- npm login # 账号:你的 npm 用户
120
- npm --version && npm pack --dry-run # 先看打包内容
121
- npm publish # 第一次发 0.0.1(publishConfig.access=public)
158
+ npm version 0.0.3 -m "chore: release v%s"
159
+ git push --follow-tags
122
160
  ```
123
161
 
124
- 发布后就能:
162
+ ### CI 做了什么
163
+
164
+ 1. 校验 **tag 与 `package.json` 版本一致**(`v0.0.3` ↔ `0.0.3`,不一致直接失败,不会发错版本)
165
+ 2. 跑 `npm run check`(全部 JS 语法 + 网页内联脚本 + `$("#id")` 引用是否都存在)
166
+ 3. `npm pack --dry-run` 看打包内容
167
+ 4. npm 上已有该版本则跳过(可安全重跑)
168
+ 5. `npm publish --access public`(token 走 `NPM_TOKEN`)
169
+ 6. 建同名 GitHub Release
170
+
171
+ ### 发了之后
125
172
 
126
173
  ```bash
127
174
  npm i -g oh-my-dws # 装
128
- oh-my-dws update # 以后升级 + 自动重启
175
+ oh-my-dws update # 升级到 latest 并自动重启
129
176
  ```
177
+
178
+ ### 常见错误
179
+
180
+ | 报错 | 原因 / 处理 |
181
+ |---|---|
182
+ | `EOTP` / 要求一次性验证码 | 本地发布才会遇到;CI 用可信发布或 Automation token 不会 |
183
+ | `E401` / `Unable to authenticate` | 可信发布里的 Workflow filename / repo 写错,或 `id-token: write` 没开 |
184
+ | `E403` 无权限发布 | token 没给这个包的读写权限,或包名被别人占 |
185
+ | `422 Unsupported ... visibility: private` | 给私有仓库加了 `--provenance`,去掉它 |
186
+ | `npm 版本太低` | 可信发布需要 npm ≥ 11.5.1,workflow 里已自动 `npm i -g npm@latest` |
187
+ | CI 报 tag 与版本不一致 | 先 `npm version` 再打 tag,不要直接手推 tag |
188
+
189
+ > 手动应急发布(不经过 CI):`npm publish --otp=<6位码>`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-dws",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "钉钉群消息归档:本地网页控制台浏览、增量拉取、按群归档与全文 Markdown 导出,数据存放于 ~/.oh-my-dws(支持 start/stop/restart/status/update)",
5
5
  "keywords": [
6
6
  "dingtalk",
@@ -37,7 +37,11 @@
37
37
  "stop": "node bin/oh-my-dws.js stop",
38
38
  "status": "node bin/oh-my-dws.js status",
39
39
  "restart": "node bin/oh-my-dws.js restart",
40
- "prepublishOnly": "node -e \"require('fs').accessSync('web/index.html')\""
40
+ "prepublishOnly": "node -e \"require('fs').accessSync('web/index.html')\"",
41
+ "check": "node scripts/check.js",
42
+ "release": "npm version patch -m \"chore: release v%s\" && git push --follow-tags",
43
+ "release:minor": "npm version minor -m \"chore: release v%s\" && git push --follow-tags",
44
+ "release:major": "npm version major -m \"chore: release v%s\" && git push --follow-tags"
41
45
  },
42
46
  "engines": {
43
47
  "node": ">=18"