Power Pages Helper 2.0: Code Sites, Pickers and the Right Data Model

IMPORTANT
Help UKRAINE ! Your action matters! Donate to support Ukrainian Army! Donate to charity funds! Organize/join street protests in your city to support Ukraine and condemn Russian aggression! Expose and report Russian disinformation! #StandWithUkraine

The last time I wrote about Power Pages Helper was for version 1.4.0, three years ago (time flies fast, isn’t it?). Since then, Power Pages and the pac CLI have changed a lot: the Enhanced Data Model became the default, and code sites (SPA) arrived with their own download-code-site and upload-code-site commands. Version 2.0 catches up with all of it. The extension is rebuilt around the current pac CLI, it understands code sites, and it does a lot more of the guessing for you: which site, which auth profile, which data model, and whether the last command actually worked.

Before you upgrade

2.0 changes some defaults:

  • Enhanced Data Model is now the default. Every download and upload passes --modelVersion 2 unless the extension knows the site uses the Standard Data Model. Active Standard sites are detected and switched automatically. Inactive sites can’t be detected, so run Set Data Model Version once for each of them, or set portalHelper.modelVersion to 1.
  • VS Code 1.93 or later is required. The extension now uses the terminal shell integration API to follow each pac command.
  • portalHelper.downloadLatest.modelVersion is deprecated. Use portalHelper.modelVersion instead. The old setting is still read when the new one isn’t set, so nothing breaks right away.
IMPORTANT

If you still work with Standard Data Model sites that are not active in the environment, set their data model before your first upload with 2.0. Otherwise the upload uses the Enhanced Data Model.

Code sites (SPA)

Code sites are now first-class. The extension recognises a code-site project by its powerpages.config.json or .powerpages-site folder, and the usual commands do the right thing with it:

  • Upload Portal and Upload Current Portal run upload-code-site --rootPath and check that the build output exists before uploading.
  • Download Latest runs download-code-site, after a confirmation that warns you when pac would write to a differently named folder.
  • There are new Download Code Site and Upload Code Site commands.

You also no longer need to remember which download command a site needs. Both pac commands accept either kind of site, but then write the wrong folder layout. Power Pages Helper checks the site you picked: a code site chosen in Download Portal uses download-code-site, and a regular site chosen in Download Code Site uses download.

Pick, don’t paste

In 1.x you typed website IDs, auth profiles and folder paths. In 2.0 you pick them:

  • Websites come from pac pages list. The picker shows each site’s data model, whether it’s a code site, and whether it’s inactive.
  • Auth profiles come from pac auth list.
  • Folders are picked from the workspace, browsed, or typed as absolute paths.

Download Website Picker

Manual entry is still there as a fallback. If your workspace holds several sites, the extension finds them (in the workspace folder or its immediate subfolders) and lets you choose. Upload Current Portal uploads the site that contains the file you’re editing.

The right data model, automatically

The first time you use a site in a VS Code session, the extension runs pac pages list --verbose, reads the site’s data model and saves it for that website ID. Because it’s stored by website ID, re-downloading the site doesn’t lose it. If the data model differs from what was used before (for example, after a migration), you get a notification. You can turn detection off with portalHelper.detectModelVersion.

Know when pac is done

With shell integration, the extension now waits for each pac command and tells you how it went: a notification with the duration on success, or the error pac printed. Two errors get special handling:

  • Wrong data model. The extension saves the right version for the site and offers to Retry with it.
  • No auth profile. You get a shortcut to create or switch one.

Here’s the retry in action. Site V2 is an inactive Standard Data Model site, so detection can’t see its data model, and the first download runs with the default --modelVersion 2:

Shell integration works in PowerShell, bash, zsh and fish, but not in cmd.exe.

Check before you upload to the wrong environment

If you also upload to test or production, turn on portalHelper.confirmUploadEnvironment. It’s off by default, so the usual download, change, upload loop stays as fast as before.

  • whenChanged asks you to confirm only when the target environment isn’t the one the site folder was last synced with, according to the manifests pac keeps in .portalconfig.
  • always asks before every upload.

The prompt tells you whether the site exists in the target environment and offers Switch Auth Profile. If the extension can’t work out the target, it asks instead of skipping the check.

upload environment confirmation prompt

Notable fixes

A good part of 2.0 comes from issue #8. It reported two bugs. First, typing c for “current directory” in Download Portal created a folder named c instead. Second, Upload Current Portal didn’t pass the data model version, so uploads of Enhanced sites failed. The second one had a deeper cause: the extension kept its settings in the site folder’s .vscode folder, and pac deletes and recreates that folder on every download.

Both are fixed. The c shortcut is gone in favour of the folder picker, every upload passes --modelVersion, and the data model is saved per website ID by the extension, outside the site folder. The same issue also asked whether Enhanced should be the default by now. In 2.0, it is.

A few others worth mentioning:

  • Upload Portal and Migrate to Bootstrap 5 no longer reject every path except c.
  • Commands work again after you close the extension’s terminal.
  • Download Latest and Create Custom JS/CSS work on macOS and Linux.
  • pac auth create uses --environment instead of the deprecated --url.

There are also new commands (Migrate Data Model, Clone Portal, Show Active Auth Profile), new portalHelper.environment and portalHelper.pacPath settings, and more. The full list is in the changelog.

Conclusion

Update Power Pages Helper from the Visual Studio Marketplace, set the data model for any inactive Standard sites, and check the release notes for the details.

A single issue report shaped a good part of this release. If something doesn’t work as expected, or you have an idea for the next version, open an issue or start a discussion in the repository.

Credits

Cover image by Miguel Á. Padriñán from Pixabay