fix: preserve an existing non-PortOS ecosystem.config.cjs during PM2 standardization#2087
Merged
Merged
Conversation
…dization Standardizing an app unconditionally overwrote ecosystem.config.cjs, silently destroying a hand-authored config (its custom ports/settings). Now a config PortOS didn't generate — detected via the header marker — is preserved by default, and its ports are left untouched in .env/vite; only PortOS's own previously-generated config is regenerated. Add an explicit overwriteEcosystem opt-in (apply-route body + both standardize socket events) to force a rewrite.
…erve-existing-ecosystem # Conflicts: # .changelog/NEXT.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running PM2 standardization on an app unconditionally overwrote
ecosystem.config.cjs. If the app already had a hand-authored PM2 config, standardizing silently replaced it — losing its custom ports and settings. (Hit in practice: a work app's carefully-tuned local-dev config, with non-default ports wired into itsscripts, README, and OIDC callback, got clobbered by the standardizer's generic template.)Fix
Make the standardizer respect an existing config it didn't create:
ecosystem.config.cjsexists and does not carry PortOS's generated-header marker (i.e. it's user-authored or another tool's), it is left untouched. Only a file PortOS previously generated (marker present) is regenerated — the normal re-standardize flow still works..env/vite.configstray-port removal is skipped — pulling ports out of those only makes sense once PortOS's generated ecosystem owns them.overwriteEcosystemflag forces regeneration of a user-authored config. Exposed on the/api/standardize/applyrequest body and bothstandardize:start/app:standardizesocket events (validated, optional, defaultfalse).PORTOS_ECOSYSTEM_MARKERconstant that also stamps generated output, so the stamp and the check can't drift. Results now reportfilesPreservedalongsidefilesModified, surfaced through the flow + socket events.Tests
applyStandardizationcases (temp dirs): preserves a user-authored config by default; regenerates a PortOS-generated one; overwrites whenoverwriteEcosystem: true; writes fresh when none exists; leaves.envstray ports alone when preserving but still strips them when regenerating.runStandardizeFlowcases for the opt-in forwarding and thefilesPreservedpassthrough.Changelog
Added a
## Fixedentry to.changelog/NEXT.md.