bulk-release 4.0.0 → 4.0.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [4.0.1](https://github.com/semrel-extra/zx-bulk-release/compare/v4.0.0...v4.0.1) (2026-10-12)
2
+
3
+ ### Fixes & improvements
4
+ * fix(pack): replace manifests atomically, siblings never read a torn package.json ([01f9784](https://github.com/semrel-extra/zx-bulk-release/commit/01f9784fc702b167e941840d99d1ee5e243a3986))
5
+
1
6
  ## [4.0.0](https://github.com/semrel-extra/zx-bulk-release/compare/v3.3.0...v4.0.0) (2026-10-12)
2
7
 
3
8
  ### Features
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bulk-release",
3
3
  "alias": "bulk-release",
4
- "version": "4.0.0",
4
+ "version": "4.0.1",
5
5
  "description": "zx-based alternative for multi-semantic-release",
6
6
  "type": "module",
7
7
  "exports": {
@@ -1,4 +1,5 @@
1
1
  import zlib from 'node:zlib'
2
+ import {randomUUID} from 'node:crypto'
2
3
  import _fs from 'node:fs/promises'
3
4
  import _path from 'node:path'
4
5
  import tar from 'tar-stream'
@@ -69,13 +70,29 @@ export const fetchManifest = async (pkg, {nothrow} = {}) => {
69
70
  export const npmPersist = async (pkg) => {
70
71
  const {name, version, manifest, manifestAbsPath} = pkg
71
72
  log.info(`updating ${manifestAbsPath} inners: ${name} ${version}`)
72
- await fs.writeJson(manifestAbsPath, manifest, {spaces: 2})
73
+ await replaceFile(manifestAbsPath, JSON.stringify(manifest, null, 2) + '\n')
73
74
  }
74
75
 
75
76
  export const npmRestore = async (pkg) => {
76
77
  const {manifestRaw, manifestAbsPath} = pkg
77
78
  log.info(`rolling back ${manifestAbsPath} inners to manifestRaw`)
78
- await fs.writeFile(manifestAbsPath, manifestRaw, {encoding: 'utf8'})
79
+ await replaceFile(manifestAbsPath, manifestRaw)
80
+ }
81
+
82
+ // Packages go in parallel, and npm (yarn, pnpm) in any of them reads every manifest of the workspace:
83
+ // a reader sees the old file or the new one, never a torn one. A symlinked manifest stays a symlink.
84
+ const replaceFile = async (file, data) => {
85
+ const target = await fs.realpath(file)
86
+ const {mode} = await fs.stat(target)
87
+ const tmp = `${target}.${randomUUID()}.tmp`
88
+ try {
89
+ await fs.writeFile(tmp, data, 'utf8')
90
+ await fs.chmod(tmp, mode & 0o7777)
91
+ await fs.rename(tmp, target)
92
+ } catch (e) {
93
+ await fs.rm(tmp, {force: true})
94
+ throw e
95
+ }
79
96
  }
80
97
 
81
98
  export const npmPublish = async (pkg) => {