@prisma/cli 3.0.0-dev.131.1 → 3.0.0-dev.133.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -333,12 +333,13 @@ function createRollbackCommand(runtime) {
333
333
  }
334
334
  function createRemoveCommand(runtime) {
335
335
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "app.remove");
336
- command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
336
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--branch <name>", "Branch name"));
337
337
  addGlobalFlags(command);
338
338
  command.action(async (configTarget, options) => {
339
339
  const appName = options.app;
340
340
  const projectRef = options.project;
341
- await runCommand(runtime, "app.remove", options, (context) => runAppRemove(context, appName, projectRef, configTarget), {
341
+ const branchName = options.branch;
342
+ await runCommand(runtime, "app.remove", options, (context) => runAppRemove(context, appName, projectRef, configTarget, branchName), {
342
343
  renderHuman: (context, descriptor, result) => renderAppRemove(context, descriptor, result),
343
344
  renderJson: (result) => serializeAppRemove(result)
344
345
  });
@@ -967,11 +967,19 @@ async function runAppRollback(context, appName, deploymentId, projectRef, config
967
967
  nextSteps: ["prisma-cli app list-deploys", `prisma-cli app show-deploy ${targetDeployment.id}`]
968
968
  };
969
969
  }
970
- async function runAppRemove(context, appName, projectRef, configTarget) {
970
+ /**
971
+ * Removes an app and every deployment it owns in the resolved branch.
972
+ *
973
+ * @param branchName Scopes the removal to this branch. When omitted the branch
974
+ * is inferred from the local Git branch, falling back to the production branch.
975
+ */
976
+ async function runAppRemove(context, appName, projectRef, configTarget, branchName) {
971
977
  ensurePreviewAppMode(context);
972
978
  const compute = await resolveComputeManagementContext(context, configTarget, "remove");
973
979
  appName = appName ?? compute.configAppName;
980
+ if (branchName !== void 0 && branchName.trim() === "") throw usageError("The --branch value cannot be empty", "app remove scopes the removal to the given branch; an empty --branch would silently fall back to the inferred (possibly production) branch.", "Pass a non-empty branch name, e.g. --branch <branch>, or omit --branch to use the inferred branch.", ["prisma-cli app remove --app <name> --branch <branch>"], "app");
974
981
  const { provider, target, projectId } = await requireProviderAndProjectContext(context, projectRef, {
982
+ branch: branchName !== void 0 ? await resolveDeployBranch(context, branchName) : void 0,
975
983
  commandName: "app remove",
976
984
  projectDir: compute.projectDir
977
985
  });
@@ -1502,13 +1510,21 @@ function requireDeploymentForApp(deployments, deploymentId, appName) {
1502
1510
  nextSteps: ["prisma-cli app list-deploys"]
1503
1511
  });
1504
1512
  }
1513
+ /**
1514
+ * Resolves the app's live deployment from the app pointer, the provider's live
1515
+ * flag, then locally cached state.
1516
+ *
1517
+ * @returns the live deployment id, or null when no authoritative signal exists.
1518
+ * Callers must treat null as "not known to be live" rather than assuming the
1519
+ * newest deployment is live.
1520
+ */
1505
1521
  async function resolveCurrentLiveDeploymentId(context, projectId, app, deployments) {
1506
1522
  if (app.liveDeploymentId && deployments.some((deployment) => deployment.id === app.liveDeploymentId)) return app.liveDeploymentId;
1507
1523
  const providerLiveDeployment = deployments.find((deployment) => deployment.live === true);
1508
1524
  if (providerLiveDeployment) return providerLiveDeployment.id;
1509
1525
  const knownLiveDeploymentId = await context.stateStore.readKnownLiveDeployment(projectId, app.id);
1510
1526
  if (knownLiveDeploymentId && deployments.some((deployment) => deployment.id === knownLiveDeploymentId)) return knownLiveDeploymentId;
1511
- return deployments[0]?.id ?? null;
1527
+ return null;
1512
1528
  }
1513
1529
  function buildAppShowNextSteps(liveUrl, liveDeployment, deployments) {
1514
1530
  const nextSteps = [];
@@ -798,8 +798,12 @@ const DESCRIPTORS = [
798
798
  "app",
799
799
  "remove"
800
800
  ],
801
- description: "Remove the app from the current branch",
802
- examples: ["prisma-cli app remove --app hello-world", "prisma-cli app remove --app hello-world --yes"]
801
+ description: "Remove the app from the resolved branch",
802
+ examples: [
803
+ "prisma-cli app remove --app hello-world",
804
+ "prisma-cli app remove --app hello-world --yes",
805
+ "prisma-cli app remove --app hello-world --branch feature/foo --yes"
806
+ ]
803
807
  },
804
808
  {
805
809
  id: "project.env",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli",
3
- "version": "3.0.0-dev.131.1",
3
+ "version": "3.0.0-dev.133.1",
4
4
  "description": "Command-line interface for the Prisma Developer Platform.",
5
5
  "type": "module",
6
6
  "bin": {