A Shared Dev Portal Has No Lock: Making Direct Upload Safe
Why a Power Pages Dev portal shared by several developers needs a layer around it, and what ppai-devsync does before it lets pac upload anything
Power Pages keeps a site as rows in Dataverse. The code lives in git as a folder of yml and html, fetched with pac pages download and sent back with pac pages upload. A pro-code project adds TypeScript and SCSS in src/, built to bundles that go up as web files.
That works for one developer. Put several on the same Dev portal and you discover that it has no lock, no branch and no history. Whoever uploads last wins. Test and Prod are written by pipelines; Dev is written from developer machines, because that is where you see a change in two minutes.
Four ways it goes wrong
Overwriting. One developer uploads the portal folder. Another uploaded a template an hour earlier, not pushed yet. Gone from Dev.
Other people’s code in your commits. To see that template you download Dev. Now their uncommitted file is in your working copy, and it lands in your next commit with your name on it.
A bundle that does not match the source. Someone pushes a change in src/ without rebuilding. The next upload sends a bundle built from old source.
Uncommitted work in Dev. Upload takes what is in the folder, not what is committed. A half-finished css file goes up with everything else.
The manual answer is a recipe: stash, pull, download, apply, upload. It needs discipline, which is the first thing to go on a busy afternoon.
Why not a pipeline
A pipeline from main to Dev is the clean answer. Only the pipeline writes to Dev, and most of what follows becomes unnecessary. It suits a team on branches and pull requests. It does not suit a team that tests in Dev before pushing to main. There, one broken push stops Dev for everyone until it is fixed.
One portal per developer in the same environment removes the collisions at the root. The catch is that every portal component has a GUID that must be unique in the environment, and the GUIDs sit in the yml files and inside Liquid. Several portals means rewriting every GUID per portal, both ways. That moves the problem from “who owns this file” to “which GUID is right where”.
ppai-devsync
The repository is not public yet. It will be, soon; the link below will work when it is.
So, a tool. One principle: git is the source of truth, and your working copy never receives files from Dev. The flow is commit, run the sync, look at Dev, push. A config file per project names the Dev environment, the portal folder, the build command and which source files produce which bundles.
First, git. It fetches origin/main and rebases your commits on top. Uncommitted changes in tracked files, an unresolved conflict or a rebase in progress stop it. It never merges or stashes.
Then Dev. It reads every portal component through the Dataverse Web API, without content, and compares a content hash with the last sync. If nothing changed, nothing is downloaded. If something did, the whole site goes to a temporary folder, and every file is compared against the working copy, HEAD, origin/main and Dev: yours, someone else’s (owner is “last modified by” in Dev), already in origin/main, or a collision.
Other people’s files go into separate git bookkeeping under refs/dev-sync/, outside the working copy, and pre-commit and pre-push hooks keep them out of your commits. Files you changed yourself in the Power Pages studio are committed with you as author, so they do not live only in Dev. Built files never are.
Then the build, from HEAD. It stops on a build failure, on drift (the build gives different bundles from the committed ones), on someone else’s bundle in Dev without its source pushed, on a missing environment manifest (without it, pac uploads everything), and on a manifest that would delete records in Dev.
The upload tree is HEAD plus other people’s files unchanged from Dev, so nothing in Dev is lost. Right before upload, Dev is read again; if someone uploaded in the meantime, it stops. Then pac pages upload, and a fresh download to record what arrived.
A full sync takes four to five minutes. A plain upload without guards takes one or two. Three minutes per iteration is the price of not losing anyone’s work.
What turned up in use
None of the early faults were in the model. All were at the edges. A transient HTTP error from Dataverse failed the refresh after a successful upload; now every Web API read gets three attempts with backoff. From a non-interactive shell it asked for confirmation after building for a minute; now it stops before the build. The drift guard fired on a pushed change in src/ without a rebuild, which is what it is for, and the same check now sits in the pre-push hook.
And a hang. Node was waiting on git hash-object, which was waiting on stdin that never closed: a rare race in Node’s spawnSync with stdin as a pipe, about one call in three thousand. Git calls with input now read from a temporary file. No pipe, nothing to hang on.
When the full list of steps was first on the table, it looked far too complicated. It stayed. Each guard answers a failure that has actually happened.
Useful links
- ppai-devsync on GitHub
- Power Platform CLI for Power Pages
- pac pages command reference
- Dataverse Web API overview
- git rebase
- git hooks
Next: running the tool against a second portal, and what the config file has to say for that to work.