my-code-style 1.7.0 → 1.7.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -5
  2. package/README.md +60 -24
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,17 +1,24 @@
1
1
  ## 变更日志
2
2
 
3
- ## [1.7.0](https://github.com/myvn/codeStyle/compare/v1.6.1...v1.7.0) (2026-09-20)
4
-
3
+ ### [1.7.2](https://github.com/myvn/codeStyle/compare/v1.7.1...v1.7.2) (2026-09-20)
5
4
 
6
5
  ### 🐛 Bug Fixes | Bug 修复
7
6
 
8
- * **deps:** stylelint 生态 peer 放宽到 16/17 两条线,并补 Stylelint 17 运行时回归 ([a230edc](https://github.com/myvn/codeStyle/commit/a230edcae73d2b935977567b8f082aaaa74dc938))
7
+ - **publish:** 恢复 --provenance —— 1.7.1 因此丢了 npm 页面的绿勾 ([df8e379](https://github.com/myvn/codeStyle/commit/df8e37978df62265e11454050cb1afce6b003dbf))
8
+ - **release:** 发布前防呆,拦住 "tag 已在 HEAD" 时多发一个空版本 ([9da41a8](https://github.com/myvn/codeStyle/commit/9da41a88fdf275e29576daa03a350a6ac780d566))
9
+
10
+ ### [1.7.1](https://github.com/myvn/codeStyle/compare/v1.7.0...v1.7.1) (2026-09-20)
11
+
12
+ ## [1.7.0](https://github.com/myvn/codeStyle/compare/v1.6.1...v1.7.0) (2026-09-20)
13
+
14
+ ### 🐛 Bug Fixes | Bug 修复
9
15
 
16
+ - **deps:** stylelint 生态 peer 放宽到 16/17 两条线,并补 Stylelint 17 运行时回归 ([a230edc](https://github.com/myvn/codeStyle/commit/a230edcae73d2b935977567b8f082aaaa74dc938))
10
17
 
11
18
  ### ✨ Features | 新功能
12
19
 
13
- * **init:** 依赖版本体检 —— 已装但版本不匹配、上游配置 peer 冲突、parser 错位 ([2820834](https://github.com/myvn/codeStyle/commit/2820834bc3062900724132f7b29c2581eace13e8))
14
- * **init:** 版本体检精确到 minor —— 只比主版本会漏掉 10.2.0 vs ^10.3.0 ([d13629c](https://github.com/myvn/codeStyle/commit/d13629c947575109ed3319854ab902e5caada145))
20
+ - **init:** 依赖版本体检 —— 已装但版本不匹配、上游配置 peer 冲突、parser 错位 ([2820834](https://github.com/myvn/codeStyle/commit/2820834bc3062900724132f7b29c2581eace13e8))
21
+ - **init:** 版本体检精确到 minor —— 只比主版本会漏掉 10.2.0 vs ^10.3.0 ([d13629c](https://github.com/myvn/codeStyle/commit/d13629c947575109ed3319854ab902e5caada145))
15
22
 
16
23
  ### [1.6.1](https://github.com/myvn/codeStyle/compare/v1.6.0...v1.6.1) (2026-09-18)
17
24
 
package/README.md CHANGED
@@ -193,12 +193,12 @@ npx my-code-style-init [--dry-run] [--backup] [--version|-v] [--help|-h]
193
193
  ## 测试套件
194
194
 
195
195
  ```bash
196
- npm run test:all # 全量运行 168 项:用例明细 + 分类统计 + 最慢文件定位
196
+ npm run test:all # 全量运行 172 项:用例明细 + 分类统计 + 最慢文件定位
197
197
  npm run diagnose # 换机器后先跑它:进程 / git / 文件系统 / hooks 各占多少
198
198
  npm run sweep # 给本机找最佳文件级并发(扫 integration 套件)
199
- npm test # 只跑基础 CLI 与配置矩阵(70 项)
199
+ npm test # 只跑基础 CLI 与配置矩阵(78 项)
200
200
  npm run test:integration:setup # 安装现代化隔离依赖运行环境
201
- npm run test:integration # Flat Config、真实 Husky 及提交链路测试(55 项)
201
+ npm run test:integration # Flat Config、真实 Husky 及提交链路测试(59 项)
202
202
  npm run test:legacy:setup # 安装 ESLint 8 隔离运行环境
203
203
  npm run test:legacy # ESLint 8.57.0 兼容性回归测试(27 项)
204
204
  npm run test:stylelint17:setup # 安装 Stylelint 17 隔离运行环境
@@ -212,43 +212,45 @@ npm run test:stylelint17 # Stylelint 17 生态兼容性回归(8 项)
212
212
  my-code-style 测试套件
213
213
 
214
214
  ▶ [1/4] 基础 CLI 与配置矩阵 (共 78 项,5 文件 · 3 文件并发(自动:2 核 / 内存 4G))
215
- ✓ 运行器 TAP 解析:统计通过与失败、SKIP 与每用例耗时 · 2ms
216
- ✓ 依赖版本体检:两位数主版本(stylelint 17)不再被静默跳过 · 41ms
217
- ✓ 所有公共导出目标存在且可通过包名解析 · 3ms
215
+ ✓ 运行器 TAP 解析:统计通过与失败、SKIP 与每用例耗时 · 6ms
216
+ ✓ 运行器表格:CJK 宽度按两列计算,耗时格式化区分秒与毫秒 · 0ms
217
+ ✓ 依赖版本体检:minor 级错位也能发现(10.2.0 不满足 ^10.3.0) · 34ms
218
+ ✓ 所有公共导出目标存在且可通过包名解析 · 10ms
218
219
  …
219
- ✓ 通过 78 · 3.2s · 最慢文件 init-matrix.test.cjs 3.0s
220
+ ✓ 通过 78 · 2.5s · 最慢文件 init-matrix.test.cjs 2.3s
220
221
 
221
- ▶ [2/4] 现代工具链与提交链 (共 55 项,23 文件 · 3 文件并发(自动:2 核 / 内存 4G))
222
- ✓ 完整提交链:JS/TS/Vue/nvue/CSS/scss 自动修复及二次复检 · 10.7s
223
- ✓ Flat Config 启用 eslint:recommended 核心规则:no-debugger · 45ms
222
+ ▶ [2/4] 现代工具链与提交链 (共 59 项,23 文件 · 3 文件并发(自动:2 核 / 内存 4G))
223
+ ✓ 完整提交链:JS/TS/Vue/nvue/CSS/less 自动修复及二次复检 · 8.5s
224
+ ✓ 发布防呆:HEAD 已有 v* tag 时拦截(此时 standard-version 会静默抬版并写出空 CHANGELOG) · 461ms
224
225
  …
225
- ✓ 通过 55 · 42.7s · 最慢文件 commit-chain-scss.test.cjs 11.4s
226
+ ✓ 通过 59 · 31.7s · 最慢文件 commit-chain-both.test.cjs 8.9s
226
227
 
227
228
  ▶ [3/4] ESLint 8 兼容性 (共 27 项,1 文件 · 3 文件并发(自动:2 核 / 内存 4G))
228
- ✓ ESLint 8 base:生成的 lint 脚本遍历并拦截 broken.ts · 1.3s
229
+ ✓ 独立运行 ESLint 8 支持下限而非 ESLint 9 · 1ms
230
+ ✓ ESLint 8 base:实际 CLI 加载生成配置并接受正常文件 · 1.1s
229
231
  …
230
- ✓ 通过 27 · 19.0s
232
+ ✓ 通过 27 · 14.7s
231
233
 
232
234
  ▶ [4/4] Stylelint 17 兼容性 (共 8 项,1 文件 · 3 文件并发(自动:2 核 / 内存 4G))
233
- ✓ stylelint 17 下 --fix 生效且幂等(SCSS) · 1.4s
234
- ✓ stylelint-order(recess-order 7 的 peer)在 stylelint 17 下可用 · 1.0s
235
+ ✓ stylelint 17 下 --fix 生效且幂等(SCSS) · 1.1s
236
+ ✓ stylelint 17 下 Vue 单文件的内嵌 SCSS 样式被检查 · 596ms
235
237
  …
236
- ✓ 通过 8 · 7.4s
238
+ ✓ 通过 8 · 5.5s
237
239
 
238
240
  ──────────────────────────────────────────────────────
239
241
  套件 通过 失败 跳过 用时
240
242
  ──────────────────────────────────────────────────────
241
- 基础 CLI 与配置矩阵 78 0 - 3.2s
242
- 现代工具链与提交链 55 0 - 42.7s
243
- ESLint 8 兼容性 27 0 - 19.0s
244
- Stylelint 17 兼容性 8 0 - 7.4s
243
+ 基础 CLI 与配置矩阵 78 0 - 2.5s
244
+ 现代工具链与提交链 59 0 - 31.7s
245
+ ESLint 8 兼容性 27 0 - 14.7s
246
+ Stylelint 17 兼容性 8 0 - 5.5s
245
247
  ──────────────────────────────────────────────────────
246
- 合计 168 0 - 72.3s
248
+ 合计 172 0 - 54.5s
247
249
  ──────────────────────────────────────────────────────
248
250
 
249
- ⏱ 最慢文件:eslint8.test.cjs 19.0s · commit-chain-scss.test.cjs 11.4s · commit-chain-less.test.cjs 11.1s
251
+ ⏱ 最慢文件:eslint8.test.cjs 14.7s · commit-chain-both.test.cjs 8.9s · commit-chain-scss.test.cjs 8.7s
250
252
 
251
- ✅ 全部通过:168/168 项,用时 72.3s
253
+ ✅ 全部通过:172/172 项,用时 54.5s
252
254
  ```
253
255
 
254
256
 
@@ -317,7 +319,7 @@ npm run test:all -- --profile # 看每个测试文件耗时,定位瓶颈
317
319
  并发 git/npx 撑到 OOM(进程被 SIGKILL);文件数多于并发数时,**用例少的文件(多半是同
318
320
  一条重链)优先开跑**,避免长任务被排进最后一波、墙钟再多乘一倍。
319
321
 
320
- 实测(2 核沙箱,168 项;沙箱内存 4G,所以自动并发是 3):
322
+ 实测(2 核沙箱,沙箱内存 4G,所以自动并发是 3)——下表是引入 hook 优化那次的对照运行(当时 168 项):
321
323
 
322
324
  | 运行方式 | 墙钟时间 |
323
325
  | ----------------------------------- | ----------------------------------------------- |
@@ -328,6 +330,8 @@ npm run test:all -- --profile # 看每个测试文件耗时,定位瓶颈
328
330
  | `npm run test:integration`(运行器调度,自动并发 3) | 30.6s(只看集成套件那一段) |
329
331
  | 串行套件 + 文件级并发 23(全部一波) | ✗ 3.8G 内存沙箱被 OOM 压垮(19 项 SIGKILL) |
330
332
 
333
+ 同机复测(172 项;绝对秒数随机器负载波动,相对关系稳定):串行套件 + 文件级并发 1 = 69.7s、默认自动并发 3 = 54.5s、`--parallel` 四套件 = 49.2s、`npm run test:integration` = 33.5s、`node --test demo-test/integration/*.test.cjs` = 44.6s。
334
+
331
335
  (2 核沙箱里并行收益被 CPU 争抢吃掉大半,`--concurrency=1` 时单个文件只要 0.7–4.2s;
332
336
  16 核机器上集成套件那段 ≈ 最慢子文件,即"一次真实提交"的量级。)
333
337
  生成的 hook 优先直连本地 bin(husky 已把 `node_modules/.bin` 放进 PATH),
@@ -341,6 +345,38 @@ npm run test:all -- --profile # 看每个测试文件耗时,定位瓶颈
341
345
 
342
346
  未安装隔离运行环境时,对应套件会明确标记"未运行"并给出 setup 命令,退出码为 1(不会假装全绿)。
343
347
 
348
+ ## 发布(维护者)
349
+
350
+ 一条命令发布(升版本 → 更新 CHANGELOG → 提交 → 打 tag → 推送,推 tag 即触发发布工作流):
351
+
352
+ ```bash
353
+ npm run release:push
354
+ ```
355
+
356
+ 也可以拆成两步:`npm run release` 只做到打 tag,之后用 `git push --follow-tags origin <分支>` 手动推送。
357
+
358
+ > ⚠️ **别把两条命令连起来跑**:`release` 已经把 tag 打在 HEAD 上了,紧接着跑 `release:push`,standard-version **不会报错**,而是把版本号再抬一级、写出一个没有条目的空 CHANGELOG 并打出第二个 tag —— 等于多发一个空版本(npm 上不可撤销)。
359
+ >
360
+ > 两条命令的第一步都是 `scripts/release-guard.cjs` 发布前防呆,命中下面两种情况会直接中止并打印该执行的命令:HEAD 上已经有 `v*` tag(说明这一版已生成,只差推送)、已跟踪文件还有未提交改动(会被卷进版本提交)。未跟踪文件不拦截。
361
+
362
+ `.github/workflows/publish.yml` 只接受 **`v*` tag** 触发(`workflow_dispatch` 会先校验 ref,分支上手动触发直接失败),并且在测试全绿 + `npm pack --dry-run` 通过后才发布;发布步骤失败即失败,不做静默降级。
363
+
364
+ ### 发布凭据(推荐切到 Trusted Publishing)
365
+
366
+ 工作流默认按 **npm Trusted Publishing(OIDC)→ `NPM_TOKEN`** 的顺序取凭据:`NPM_TOKEN` secret 存在时用 token,删掉后**无需改代码**自动改走 OIDC。切换步骤:
367
+
368
+ 1. 打开 `https://www.npmjs.com/package/my-code-style/access` → Trusted Publisher → GitHub Actions,填:
369
+ - Organization or user:`myvn`
370
+ - Repository:`codeStyle`
371
+ - Workflow filename:`publish.yml`(大小写与 `.yml` 后缀都要精确匹配)
372
+ - Environment:`npm-publish`(与本仓库 Environments 里的名字一致)
373
+ 2. 仓库 Settings → Environments → `npm-publish` 添加 **required reviewers**(发布前人工批准;不配则该环境无保护)。
374
+ 3. 在 GitHub 仓库 Settings → Secrets 删除 `NPM_TOKEN`,并到 npm 账号下吊销对应 token。
375
+
376
+ OIDC 要求发布环境是 GitHub-hosted runner + `id-token: write` + npm CLI ≥ 11.5.1(工作流用 Node 24 自带),因此 `setup-node` **刻意不写 `registry-url`**——那会生成带 `_authToken` 的 `.npmrc`,让 npm 以为认证已就绪而跳过 OIDC。
377
+
378
+ 工作流里的 action 固定在大版本号上(`actions/checkout@v7` / `actions/setup-node@v7` / `softprops/action-gh-release@v3`),它们都已迁到 **Node 24 运行时**——GitHub 已弃用 Actions 的 Node 20 运行时,停留在 `@v4` 会在每次运行时报 `Node.js 20 is deprecated` 告警。自托管 runner 需 ≥ **v2.327.1**。
379
+
344
380
  ## License
345
381
 
346
382
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-code-style",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Lint/Format/Git 配置工程化 npm 包(ESLint + Prettier + Stylelint + Commitlint + Husky + standard-version)",
5
5
  "type": "commonjs",
6
6
  "main": "src/eslint/uniapp.cjs",
@@ -57,8 +57,8 @@
57
57
  "lint:fix": "eslint . --fix",
58
58
  "format": "prettier --write .",
59
59
  "prepare": "node -e \"if (!process.env.CI) { try { require('child_process').execSync('husky', { stdio: 'ignore' }) } catch {} }\"",
60
- "release": "standard-version",
61
- "release:push": "standard-version && git push --follow-tags origin HEAD",
60
+ "release": "node scripts/release-guard.cjs && standard-version",
61
+ "release:push": "node scripts/release-guard.cjs && standard-version && git push --follow-tags origin HEAD",
62
62
  "pub": "npm run release:push",
63
63
  "cz": "czg",
64
64
  "link": "pnpm link --global",