Skip to content

Commit 52aa98a

Browse files
committed
fix: streamline npm publish artifacts
1 parent 5a03778 commit 52aa98a

7 files changed

Lines changed: 21 additions & 12 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ jobs:
6666
npm whoami --registry=https://registry.npmjs.org/
6767
6868
- name: Publish to npm
69-
run: npm publish --provenance --access public
69+
run: npm publish --provenance --access public --ignore-scripts
7070
env:
7171
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
| Version | Date | Summary | Details |
1111
|---------|------|---------|---------|
12-
| [v2.0.0](./changelogs/v2.0.0.md) | 2026-06-01 | 🎉 **v2.0.0 — TypeScript rewrite**: full TypeScript source, cache-hub integration, schema-dsl `^2.0.3` TS dependency, Apache-2.0 licensing, English README, MultiLevel cache support, v1 API compat preserved, JSDoc coverage complete, `getPoolStats/getPoolHealth` keyed by pool name, v1 compat fixes included, workspace smooth-upgrade bridge validated for downstream consumers | [View](./changelogs/v2.0.0.md) |
12+
| [v2.0.0](./changelogs/v2.0.0.md) | 2026-06-01 | 🎉 **v2.0.0 — TypeScript rewrite**: full TypeScript source, cache-hub integration, schema-dsl `^2.0.3` TS dependency, Apache-2.0 licensing, English README, MultiLevel cache support, v1 API compat preserved, optimized npm artifact boundary without default sourcemaps, JSDoc coverage complete, `getPoolStats/getPoolHealth` keyed by pool name, v1 compat fixes included, workspace smooth-upgrade bridge validated for downstream consumers | [View](./changelogs/v2.0.0.md) |
1313
| [v1.3.0](https://github.com/vextjs/monSQLize/blob/main/changelogs/v1.3.0.md) | 2026-04-27 | 🆕 **新功能**:链式池访问 API — `pool(name)` / `use(dbName)` / `scopedCollection()` / `scopedModel()` 四个公开方法,支持多连接池多数据库路由,connection 合并语义,TypeScript 类型签名完整覆盖 | [查看](https://github.com/vextjs/monSQLize/blob/main/changelogs/v1.3.0.md) |
1414
| [v1.2.3](https://github.com/vextjs/monSQLize/blob/main/changelogs/v1.2.3.md) | 2026-04-26 | 🐛 **Bug Fix**:`model()` 方法修复注册 key 直接作为 MongoDB 集合名的问题,优先读 `definition.collection > definition.name`,注册 key 仅作 fallback,向后兼容 | [查看](https://github.com/vextjs/monSQLize/blob/main/changelogs/v1.2.3.md) |
1515
| [v1.2.2](https://github.com/vextjs/monSQLize/blob/main/changelogs/v1.2.2.md) | 2026-04-24 | 🆕 **新功能**:Model 数据源绑定 — `connection: { pool?, database? }` 支持 Model 绑定指定连接池和/或数据库,四种组合路由,向后兼容;🐛 **Bug Fix**:修复 `Model._clear()` 导致 `msq.model()` 实例缓存失效失效,populate 关系丢失问题 | [查看](https://github.com/vextjs/monSQLize/blob/main/changelogs/v1.2.2.md) |

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ npm run release:preflight
475475

476476
Release preflight runs linting, type checks, size guards, runtime checks, compatibility checks, refactor guards, the default test suite, and `npm pack --dry-run`.
477477

478+
`npm run release:publish` runs the preflight gate once and then calls `npm publish --ignore-scripts` so the final publish step does not repeat the full lifecycle gate. Raw `npm publish` is still guarded by `prepublishOnly`.
479+
478480
Optional commands:
479481

480482
```bash
@@ -494,9 +496,10 @@ Key release-readiness points:
494496

495497
- TypeScript rewrite completed for the current runtime and test entry points.
496498
- Package exports are consolidated under `dist/cjs`, `dist/esm`, and `dist/types`.
499+
- npm packages include the runtime bundles and declaration files only; source maps are disabled by default and can be generated locally with `MONSQLIZE_BUILD_SOURCEMAPS=1 npm run build`.
497500
- v1 smooth-upgrade compatibility has been validated against the target workspace consumers.
498501
- `schema-dsl` follows the npm `latest` TypeScript line `^2.0.3`; deprecated `2.3.x` mistake releases are intentionally excluded.
499-
- GitHub Actions publishes to npm from `v*` tags after running `npm run release:preflight`.
502+
- GitHub Actions publishes to npm from `v*` tags after running `npm run release:preflight`; the publish step skips duplicate lifecycle scripts because the gate already ran in the same job.
500503

501504
## Roadmap
502505

@@ -532,4 +535,3 @@ monSQLize is released under the [Apache License 2.0](./LICENSE).
532535
- Issues: [GitHub Issues](https://github.com/vextjs/monSQLize/issues)
533536
- npm: [monsqlize](https://www.npmjs.com/package/monsqlize)
534537
- Website: [https://vextjs.github.io/monSQLize/](https://vextjs.github.io/monSQLize/)
535-

‎changelogs/v2.0.0.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ All public API surface now carries complete English JSDoc:
206206
- The transaction/cache-lock unit test was stabilized, and release preflight now runs the default `npm test` gate before pack dry-run.
207207
- Runtime dependency `schema-dsl` now follows npm `latest` TypeScript line `^2.0.3`; deprecated mistake releases in the `2.3.x` range are explicitly excluded from the upgrade target.
208208
- Project licensing is now Apache-2.0, and the package README is published in English for npm and GitHub users.
209+
- npm package artifacts are limited to runtime CJS / ESM bundles, public `.d.ts` declarations, and release documentation. Source maps are disabled by default and excluded from the package boundary even when generated locally.
210+
- GitHub Actions publish flow now runs `release:preflight` once before `npm publish --ignore-scripts`, avoiding duplicate `prepublishOnly` lifecycle execution inside the final publish step while preserving raw `npm publish` safeguards.
209211

210212
---
211213

‎docs/release-preflight.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ npm run release:preflight
1919
4. 运行 `npm run verify:fast`
2020
5. 运行 `npm test`
2121
6. 运行 `npm pack --dry-run`
22-
7. `npm publish` 会先触发 `prepublishOnly`,从而执行同一套 `release:preflight`
23-
8. **不会**运行 `npm run verify:release`(后者依赖私有真实环境,属于操作者显式 opt-in 的补充复核)
22+
7. 原始 `npm publish` 仍会通过 `prepublishOnly` 触发同一套 `release:preflight`,防止绕过门禁
23+
8. 仓库发布 workflow 和 `npm run release:publish` 会先显式执行 `release:preflight`,再用 `npm publish --ignore-scripts` 发布,避免在发布动作内重复执行完整门禁
24+
9. **不会**运行 `npm run verify:release`(后者依赖私有真实环境,属于操作者显式 opt-in 的补充复核)
2425

2526
## 为什么不是直接 publish
2627

@@ -38,4 +39,4 @@ git tag vX.Y.Z
3839
npm run release:publish
3940
```
4041

41-
> 若走仓库自动化路径,可先手动运行 GitHub Actions 的 `Release Preflight`,确认通过后再执行 tag / publish。
42+
> 若走仓库自动化路径,可先手动运行 GitHub Actions 的 `Release Preflight`,确认通过后再推送 `v*` tag 或手动运行 `Publish to npm` workflow。真实 publish step 已跳过重复 lifecycle scripts,因为同一 job 前置步骤已经完成 `release:preflight`。

‎package.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"./package.json": "./package.json"
1616
},
1717
"files": [
18-
"dist/",
18+
"dist/**/*.cjs",
19+
"dist/**/*.mjs",
20+
"dist/**/*.d.ts",
1921
"changelogs/v2.0.0.md",
2022
"README.md",
2123
"LICENSE",
@@ -80,7 +82,7 @@
8082
"verify": "npm run verify:full",
8183
"release:preflight": "node scripts/release-preflight.cjs",
8284
"prepublishOnly": "npm run release:preflight",
83-
"release:publish": "npm publish",
85+
"release:publish": "npm run release:preflight && npm publish --ignore-scripts",
8486
"postpublish": "echo '✅ 发布成功!请创建 GitHub Release: https://github.com/vextjs/monSQLize/releases/new?tag=v'$npm_package_version"
8587
},
8688
"peerDependenciesMeta": {

‎scripts/build-p1.cjs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { cpSync, mkdirSync, rmSync } = require('node:fs');
22
const { build } = require('esbuild');
33

4+
const emitSourceMaps = process.env.MONSQLIZE_BUILD_SOURCEMAPS === '1';
5+
46
async function main() {
57
rmSync('lib', { recursive: true, force: true });
68
rmSync('dist', { recursive: true, force: true });
@@ -17,7 +19,7 @@ async function main() {
1719
platform: 'node',
1820
format: 'cjs',
1921
target: 'node18',
20-
sourcemap: true,
22+
sourcemap: emitSourceMaps,
2123
logLevel: 'info',
2224
});
2325

@@ -29,7 +31,7 @@ async function main() {
2931
platform: 'node',
3032
format: 'esm',
3133
target: 'node18',
32-
sourcemap: true,
34+
sourcemap: emitSourceMaps,
3335
logLevel: 'info',
3436
});
3537

@@ -49,7 +51,7 @@ async function main() {
4951
platform: 'node',
5052
format: 'cjs',
5153
target: 'node18',
52-
sourcemap: true,
54+
sourcemap: emitSourceMaps,
5355
logLevel: 'info',
5456
});
5557
}

0 commit comments

Comments
 (0)