-
Notifications
You must be signed in to change notification settings - Fork 57
Description
What's happening
When you run metacall-deploy --force for a project that has never been deployed before, the CLI exits with an "Aborted" error instead of just deploying normally (skipping the deletion step).
The root cause is in src/force.ts. After calling api.inspect(), the code filters results for the matching suffix and stores it as repo: Deployment[]. It then checks:
When repo is empty, repo[0] is undefined — accessing .prefix on it throws a TypeError. The catch block then calls error() which exits the process with code 1.
The deploy never happens. But the comment at the bottom of force.ts says the intended behavior is exactly the opposite:
"if with force flag, a person tries to deploy an app, and the app is not present actually there then it should behave as normal deployment procedure"
Steps to reproduce
# First time deploying a project — no prior deployment exists
metacall-deploy --forceWhat you'd expect
CLI skips the deletion step, prints nothing alarming, and continues with the normal deploy flow.
What actually happens
CLI prints and exits with code 1:
X Deployment Aborted because this directory is not being used by any applications.
The fix
Two guards are needed in src/force.ts:
if (repo.length > 0) {
res = await del(repo[0].prefix, repo[0].suffix, repo[0].version, api);
// Guard subscription details separately inspect() and
// listSubscriptionsDeploys() are independent API calls and
// may not always have matching entries
if (repoSubscriptionDetails.length > 0) {
args['plan'] = repoSubscriptionDetails[0].plan;
}
}If neither condition is met, force() simply returns '' and the caller in index.ts continues to the normal plan selection and deploy flow which is the intended behavior.
I'm happy to open a PR for this.