Skip to content

Commit

Permalink
feat(deploy): push initial deployment to prod (#158)
Browse files Browse the repository at this point in the history
This tweaks `deploy` behavior on empty projects, pushing the initial
deployment to prod and telling the user about futher updates requiring
`--prod` flag usage.
It also enhances the final status message in order to record which
environment got updated (production or preview).
  • Loading branch information
lucab authored Jun 13, 2023
1 parent f15f138 commit aefeebf
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/subcommands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,21 @@ async function deploy(opts: DeployOpts): Promise<void> {
projectSpinner.fail("Project not found.");
Deno.exit(1);
}
projectSpinner.succeed(`Project: ${project.name}`);

const deploymentsListing = await api.getDeployments(project!.id);
if (deploymentsListing === null) {
projectSpinner.fail("Project deployments details not found.");
Deno.exit(1);
}
const [projectDeployments, _pagination] = deploymentsListing!;
projectSpinner.succeed(`Project: ${project!.name}`);

if (projectDeployments.length === 0) {
wait("").start().info(
"Empty project detected, automatically pushing initial deployment to production (use --prod for further updates).",
);
opts.prod = true;
}

let url = opts.entrypoint;
const cwd = Deno.cwd();
Expand Down Expand Up @@ -234,13 +248,15 @@ async function deploy(opts: DeployOpts): Promise<void> {
case "uploadComplete":
deploySpinner!.text = `Finishing deployment...`;
break;
case "success":
deploySpinner!.succeed(`Deployment complete.`);
case "success": {
const deploymentKind = opts.prod ? "Production" : "Preview";
deploySpinner!.succeed(`${deploymentKind} deployment complete.`);
console.log("\nView at:");
for (const { domain } of event.domainMappings) {
console.log(` - https://${domain}`);
}
break;
}
case "error":
if (uploadSpinner) {
uploadSpinner.fail(`Upload failed.`);
Expand Down

0 comments on commit aefeebf

Please sign in to comment.