Fixing 'neo sync Broke My .neo.yml'
neo sync now writes into the right environment block, in place, without touching your comments or formatting.
What neo sync is for
Some changes happen on the server first — a domain set with neo domain, an env var set with neo env set. neo sync reads that server state back and writes it into .neo.yml, so your repo doesn't drift from what's actually deployed.
neo sync my-app --dry-run # preview first
neo sync my-app
Environment-aware by default
With environments: defined, neo deploy ignores a root-level domain: — so writing there, which sync used to do, produced a .neo.yml that deploy then refused with "root-level domain:/domains: is ignored when environments: are defined." Sync now resolves which environment the app belongs to — from --to, the only environment present, or a prompt — derives the app name the same way deploy does (including the -<environment> suffix), and writes into that environment's block:
neo sync --to staging
Only your comments survive if the edit is done right
The earlier implementation re-marshalled the whole NeoConfig struct back over the file — which destroyed every comment, reordered keys, changed 2-space indent to 4, and re-quoted values (CADDY_AUTO_HTTPS: on became "on"). Sync now edits the parsed YAML node tree in place and touches only the keys that changed:
name: shop
port: 8080
edge_https: true # HTTP origin, app sees X-Forwarded-Proto: https ← survives untouched
environments:
dev:
domain: shop-dev.example.com ← only this line changes
Blank lines between blocks are the one thing still lost — the underlying YAML library doesn't model them.
What sync deliberately leaves alone
Only domain, port and https sync. Env vars, volumes and workers stay source-of-truth in .neo.yml, not the server — syncing them back would mean the server, not your repo, decides what's correct. And a domains: (plural) list is left untouched entirely, since rewriting it from one state value would drop every other entry in the list.
Try it yourself — Neo is free, with every feature unlocked.
Get started free