@borurio-print/print-designer 1.0.7 → 1.0.9

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
@@ -104,27 +104,159 @@ i18n.global.mergeLocaleMessage('zh-cn', printDesignerZhCN)
104
104
  i18n.global.mergeLocaleMessage('en', printDesignerEnUS)
105
105
  ```
106
106
 
107
- ## npm 发布
108
-
109
- 首次发布前,需要确认当前 npm 账号拥有 `@borurio-print` 组织作用域的发布权限。先登录并检查
110
- 即将进入安装包的文件:
111
-
112
- ```bash
113
- npm login
114
- pnpm build:lib
115
- npm pack --dry-run
116
- ```
117
-
118
- 确认内容无误后发布公开包:
119
-
120
- ```bash
121
- pnpm publish --access public
122
- ```
123
-
124
- 同一个版本号不能重复发布;后续修改需要先更新 `package.json` 中的版本号。
107
+ ## npm 发布
108
+
109
+ 包名和 npm registry 已在 `package.json` 中配置:
110
+
111
+ - 包名:`@borurio-print/print-designer`
112
+ - registry:`https://registry.npmjs.org/`
113
+ - 公开范围:`public`
114
+ - 发布前钩子:`prepublishOnly` 会自动执行 `pnpm build:lib`
115
+
116
+ ### 1. 检查本地和线上版本
117
+
118
+ 进入项目目录,确认当前工作区状态以及本地版本:
119
+
120
+ ```bash
121
+ git status
122
+ node -p "require('./package.json').version"
123
+ ```
124
+
125
+ 查询 npm 当前已经发布的版本:
126
+
127
+ ```bash
128
+ npm view @borurio-print/print-designer version --registry=https://registry.npmjs.org/
129
+ ```
130
+
131
+ 同一个版本不能重复发布。如果本地版本与线上版本相同,先升级版本号:
132
+
133
+ ```bash
134
+ pnpm version patch --no-git-tag-version
135
+ ```
136
+
137
+ 根据实际变更范围,也可以把 `patch` 换成 `minor` 或 `major`。如果上一次发布只是因为
138
+ 登录失效或权限不足而失败,并且线上还没有该版本,不要再次升级版本号。
139
+
140
+ ### 2. 检查 npm 登录和发布权限
141
+
142
+ 先检查当前 npm 登录状态:
143
+
144
+ ```bash
145
+ npm whoami --registry=https://registry.npmjs.org/
146
+ ```
147
+
148
+ 如果返回 `E401 Unauthorized`,重新登录:
149
+
150
+ ```bash
151
+ npm login --auth-type=web --registry=https://registry.npmjs.org/
152
+ ```
153
+
154
+ 登录成功后,再检查当前账号是否拥有该包的发布权限:
155
+
156
+ ```bash
157
+ npm owner ls @borurio-print/print-designer --registry=https://registry.npmjs.org/
158
+ ```
159
+
160
+ 当前账号必须出现在 owner 列表中。如果不在,需要使用已有 owner 账号登录,或者由已有
161
+ owner 为当前账号授予权限。
162
+
163
+ ### 3. 执行发布前构建和检查
164
+
165
+ 安装锁文件对应的依赖,并完整构建 Web 与 npm 两种产物:
166
+
167
+ ```bash
168
+ pnpm install --frozen-lockfile
169
+ pnpm build
170
+ ```
171
+
172
+ 检查 npm 包最终会包含哪些文件:
173
+
174
+ ```bash
175
+ npm pack --dry-run
176
+ ```
177
+
178
+ 至少应确认以下文件存在:
179
+
180
+ - `dist-lib/index.js`
181
+ - `dist-lib/index.d.ts`
182
+ - `dist-lib/style.css`
183
+ - `dist-lib/PrintDesigner.vue.d.ts`
184
+ - `dist-lib/core/types.d.ts`
185
+ - `dist-lib/core/theme.d.ts`
186
+ - `package.json`
187
+
188
+ 如果仓库跟踪 `dist-lib`,发布前应检查并提交最新构建产物。不要在存在来源不明的工作区
189
+ 改动时直接执行批量提交。
190
+
191
+ ### 4. 正式发布
192
+
193
+ 确认版本、账号、权限和打包内容无误后执行:
194
+
195
+ ```bash
196
+ npm publish --access public --registry=https://registry.npmjs.org/
197
+ ```
198
+
199
+ 发布时会再次触发 `prepublishOnly`,自动执行 `pnpm build:lib`。终端出现下面格式的输出才
200
+ 表示上传成功:
201
+
202
+ ```text
203
+ + @borurio-print/print-designer@1.0.7
204
+ ```
205
+
206
+ `resolveComponent is imported ... but never used` 和 chunk size 属于构建警告,不等于发布
207
+ 失败;应以命令退出码和最后的 npm 发布结果为准。
208
+
209
+ ### 5. 发布后验证
210
+
211
+ npm 新版本可能需要短暂处理时间。查询线上版本:
212
+
213
+ ```bash
214
+ npm view @borurio-print/print-designer version --registry=https://registry.npmjs.org/
215
+ ```
216
+
217
+ 在临时目录或业务系统中安装明确版本进行验证:
218
+
219
+ ```bash
220
+ npm install @borurio-print/print-designer@1.0.7
221
+ ```
222
+
223
+ 确认线上版本和业务系统验证正常后,再按团队 Git 流程提交版本变更并创建对应版本标签。
224
+
225
+ ### 常见发布错误
226
+
227
+ #### `E401 Unauthorized`
228
+
229
+ 当前 npm 登录已失效。重新执行:
230
+
231
+ ```bash
232
+ npm login --auth-type=web --registry=https://registry.npmjs.org/
233
+ npm whoami --registry=https://registry.npmjs.org/
234
+ ```
235
+
236
+ #### scoped 包发布时报 `E404 Not Found - PUT`
237
+
238
+ 对于已经存在的 scoped 包,这通常表示当前账号没有发布权限,或者认证信息已经失效,并不
239
+ 代表包真的不存在。依次检查:
240
+
241
+ ```bash
242
+ npm whoami --registry=https://registry.npmjs.org/
243
+ npm owner ls @borurio-print/print-designer --registry=https://registry.npmjs.org/
244
+ npm view @borurio-print/print-designer version --registry=https://registry.npmjs.org/
245
+ ```
246
+
247
+ 如果 `npm whoami` 返回 `E401`,重新登录后再发布。如果账号不在 owner 列表中,需要切换
248
+ 到有权限的账号或申请权限。权限问题解决前不要继续递增版本号。
249
+
250
+ #### 版本已经存在
251
+
252
+ npm 不允许覆盖已经发布的相同版本。确认线上已经存在当前版本后,执行:
253
+
254
+ ```bash
255
+ pnpm version patch --no-git-tag-version
256
+ ```
257
+
258
+ 重新构建、检查并发布新版本。
125
259
 
126
260
  ## 自动生成文件
127
261
 
128
- `src/auto-imports.d.ts` 和 `src/components.d.ts` 由自动按需引入插件生成;`pnpm-lock.yaml` 由 pnpm 生成。这些文件不应手动添加说明或修改内容。
129
-
130
- pnpm publish --access public
262
+ `src/auto-imports.d.ts` 和 `src/components.d.ts` 由自动按需引入插件生成;`pnpm-lock.yaml` 由 pnpm 生成。这些文件不应手动添加说明或修改内容。