fix: aio app deploy fails when packages: {} is declared#233
Conversation
When a manifest declares `packages: {}` the build step produces no
output so the dist directory is never created. The existing dist check
was throwing "missing files in dist/…, maybe you forgot to build your
actions?" even though there was nothing to build.
* deploy-actions.js: gate the dist check on `hasAnyActions` — only
validate the build directory when at least one package actually
defines actions. Two tests cover both branches of `pkg.actions || {}`
(empty packages and package with no actions key), keeping 100%
branch coverage on deploy-actions.js.
* utils.js (replacePackagePlaceHolder): guard the `packageNames[0]`
assignment so an empty packages object no longer clobbers `ow.package`
with `undefined`.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The dist-existence check had an operator-precedence bug: `!fs.readdirSync(dist).length === 0` parses as `(!length) === 0`, which is always false, so the empty-build-directory branch never fired. Correct it to `fs.readdirSync(dist).length === 0` so a dist directory that exists but contains no built actions now raises the "missing files" error as intended. Adds a test covering that branch.
|
Thanks for this @iivvaannxx, really useful fix, and the One thing came up in review that I'd like to sort before we ship. As written, when Proposal: when no actions are declared, skip the sync entirely (early return) instead of proceeding to the delete. That keeps your fix's intent, so no more spurious |
When the manifest declares `packages: {}` (e.g. only to trigger database
auto-provisioning), deployActions previously fell through to a full sync
against an empty manifest, which undeploys every previously-deployed
entity for the project. Return early instead so an empty manifest is a
true no-op that leaves existing entities untouched. `aio app undeploy`
remains the explicit way to remove everything.
|
Thanks @iivvaannxx! "Allow edits by maintainers" was enabled on the PR so it made it easy to add a commit |
Summary
packages: {}(empty packages), the build step produces no output so the dist directory is never created. The deploy command was throwing a spurious "missing files in dist/…, maybe you forgot to build your actions?" error.replacePackagePlaceHoldersilently setow.package = undefinedwhen packages was empty, causingsyncProjectto search the runtime server for a project namedundefined.Changes
src/deploy-actions.jsGate the dist-existence check behind
hasAnyActions— only validate the build directory when at least one package actually declares actions. Removed the redundant|| {}fallback (packages is always an object at this point) and the deadpkg &&guard (null-valued packages already fail elsewhere in the pipeline).src/utils.js(replacePackagePlaceHolder)Guard the
packageNames[0]assignment so an empty packages object no longer clobbersow.packagewithundefined.Note
Deploying with
packages: {}is effectively a no-op — no package, action, trigger, rule, or API is created on Adobe I/O Runtime. If the project was previously deployed with actual entities, the runtime's sync mechanism will treat the empty manifest as the desired state and undeploy them. This is consistent with how the full-sync model works in general, though it may be unexpected if packages: {} is used as a placeholder during development.