feat(maker-pkg)!: write PKGs to arch subdirectories - #4383
Conversation
Every other maker writes into `<maker>/<arch>` under the make directory; the PKG maker was the last one writing flat into `out/make`. Match the layout that #4275 gave the DMG maker so parallel makers cannot collide and downstream tooling can rely on one shape. BREAKING CHANGE: `.pkg` files are now written to `out/make/pkg/<arch>/` instead of directly into `out/make/`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ThYQswo8p2Rixc5sYLkDF5
| const name = | ||
| this.config.name || `${appName}-${packageJSON.version}-${targetArch}`; | ||
| const outPath = path.resolve(makeDir, `${name}.pkg`); | ||
| const outPath = path.resolve(makeDir, 'pkg', targetArch, `${name}.pkg`); |
There was a problem hiding this comment.
🟣 Pre-existing: outPath is namespaced only by targetArch (pkg/{targetArch}/{name}.pkg), not by targetPlatform, and the default name ${appName}-${version}-${targetArch} also omits platform. Building both darwin and mas for the same arch (a common flow: notarized direct-download build plus App Store build) still writes to the identical path, so ensureFile() silently deletes/overwrites the other platform's .pkg. Fix: include targetPlatform in the arch subdirectory or default name so darwin/mas outputs never collide, same as the arch fix just applied.
Extended reasoning...
make.ts calls maker.make() once per CLI invocation with a single platform, so building darwin then mas (e.g. two sequential electron-forge make --platform=X runs, or a CI pipeline producing both distributables) reuses the same persistent actualOutDir/make makeDir. Both runs compute outPath = makeDir/pkg/{targetArch}/{appName}-{version}-{targetArch}.pkg — identical for darwin and mas since neither the new subdirectory nor the default name includes platform. The second run's ensureFile() does fs.rm() on that exact path before flat() writes the mas .pkg, silently destroying the darwin .pkg artifact with no warning to the user. This is the same defect that existed pre-diff (old path was makeDir/{name}.pkg, also platform-agnostic); the diff touches this exact line to fix the arch axis but leaves the platform axis with the identical unresolved collision.
Verification: pre-existing. The defect is real: outPath at MakerPKG.ts:36 (path.resolve(makeDir, 'pkg', targetArch, ${name}.pkg)) and the default name at line 34-35 (${appName}-${packageJSON.version}-${targetArch}) both omit targetPlatform. makeDir = actualOutDir/make (make.ts:348) has no platform component either. So a darwin build and a mas build for the same arch both resolve to… | pre-existing: The…
BREAKING CHANGE:
maker-pkgnow writes the distributable to arch-specific subdirectories