@strapi/cloud-cli 0.0.0-next.ec9b1b708d4d319f2b8b39d9397bd752d250d541 → 0.0.0-next.eedb036f0a7ac282d2a645d8a40625091bd28b1e

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.
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@ import crypto$1 from "crypto";
2
2
  import * as fse from "fs-extra";
3
3
  import fse__default from "fs-extra";
4
4
  import inquirer from "inquirer";
5
+ import boxen from "boxen";
5
6
  import * as path from "path";
6
7
  import path__default from "path";
7
8
  import chalk from "chalk";
@@ -182,6 +183,7 @@ const scripts = {
182
183
  const dependencies = {
183
184
  "@strapi/utils": "5.4.0",
184
185
  axios: "1.7.4",
186
+ boxen: "5.1.2",
185
187
  chalk: "4.1.2",
186
188
  "cli-progress": "3.12.0",
187
189
  commander: "8.3.0",
@@ -1078,6 +1080,13 @@ const buildLogsServiceFactory = ({ logger }) => {
1078
1080
  });
1079
1081
  };
1080
1082
  };
1083
+ const boxenOptions = {
1084
+ padding: 1,
1085
+ margin: 1,
1086
+ align: "center",
1087
+ borderColor: "yellow",
1088
+ borderStyle: "round"
1089
+ };
1081
1090
  const QUIT_OPTION$2 = "Quit";
1082
1091
  async function promptForEnvironment(environments) {
1083
1092
  const choices = environments.map((env2) => ({ name: env2, value: env2 }));
@@ -1092,16 +1101,6 @@ async function promptForEnvironment(environments) {
1092
1101
  if (selectedEnvironment === null) {
1093
1102
  process.exit(1);
1094
1103
  }
1095
- const { confirm } = await inquirer.prompt([
1096
- {
1097
- type: "confirm",
1098
- name: "confirm",
1099
- message: `Do you want to proceed with deployment to ${chalk.cyan(selectedEnvironment)}?`
1100
- }
1101
- ]);
1102
- if (!confirm) {
1103
- process.exit(1);
1104
- }
1105
1104
  return selectedEnvironment;
1106
1105
  }
1107
1106
  async function upload(ctx, project, token, maxProjectFileSize) {
@@ -1226,6 +1225,13 @@ async function getTargetEnvironment(ctx, opts, project, environments) {
1226
1225
  }
1227
1226
  return environments[0];
1228
1227
  }
1228
+ function hasPendingOrLiveDeployment(environments, targetEnvironment) {
1229
+ const environment = environments.find((env2) => env2.name === targetEnvironment);
1230
+ if (!environment) {
1231
+ throw new Error(`Environment details ${targetEnvironment} not found.`);
1232
+ }
1233
+ return environment.hasPendingDeployment || environment.hasLiveDeployment || false;
1234
+ }
1229
1235
  const action$5 = async (ctx, opts) => {
1230
1236
  const { getValidToken } = await tokenServiceFactory(ctx);
1231
1237
  const token = await getValidToken(ctx, promptLogin);
@@ -1237,13 +1243,17 @@ const action$5 = async (ctx, opts) => {
1237
1243
  return;
1238
1244
  }
1239
1245
  const cloudApiService = await cloudApiFactory(ctx, token);
1246
+ let projectData;
1240
1247
  let environments;
1248
+ let environmentsDetails;
1241
1249
  try {
1242
1250
  const {
1243
- data: { data: projectData, metadata }
1251
+ data: { data, metadata }
1244
1252
  } = await cloudApiService.getProject({ name: project.name });
1245
- const isProjectSuspended = projectData.suspendedAt;
1253
+ projectData = data;
1246
1254
  environments = projectData.environments;
1255
+ environmentsDetails = projectData.environmentsDetails;
1256
+ const isProjectSuspended = projectData.suspendedAt;
1247
1257
  if (isProjectSuspended) {
1248
1258
  ctx.logger.log(
1249
1259
  "\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
@@ -1291,6 +1301,25 @@ Please link your local project to an existing Strapi Cloud project using the ${c
1291
1301
  maxSize = 1e8;
1292
1302
  }
1293
1303
  project.targetEnvironment = await getTargetEnvironment(ctx, opts, project, environments);
1304
+ if (!opts.force) {
1305
+ const shouldDisplayWarning = hasPendingOrLiveDeployment(
1306
+ environmentsDetails,
1307
+ project.targetEnvironment
1308
+ );
1309
+ if (shouldDisplayWarning) {
1310
+ ctx.logger.log(boxen(cliConfig2.projectDeployment.confirmationText, boxenOptions));
1311
+ const { confirm } = await inquirer.prompt([
1312
+ {
1313
+ type: "confirm",
1314
+ name: "confirm",
1315
+ message: `Do you want to proceed with deployment to ${chalk.cyan(projectData.displayName)} on ${chalk.cyan(project.targetEnvironment)} environment?`
1316
+ }
1317
+ ]);
1318
+ if (!confirm) {
1319
+ process.exit(1);
1320
+ }
1321
+ }
1322
+ }
1294
1323
  const buildId = await upload(ctx, project, token, maxSize);
1295
1324
  if (!buildId) {
1296
1325
  return;
@@ -1344,7 +1373,7 @@ const runAction = (name2, action2) => (...args) => {
1344
1373
  });
1345
1374
  };
1346
1375
  const command$7 = ({ ctx }) => {
1347
- return createCommand("cloud:deploy").alias("deploy").description("Deploy a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").option("-e, --env <name>", "Specify the environment to deploy").action((opts) => runAction("deploy", action$5)(ctx, opts));
1376
+ return createCommand("cloud:deploy").alias("deploy").description("Deploy a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").option("-f, --force", "Skip confirmation to deploy").option("-e, --env <name>", "Specify the environment to deploy").action((opts) => runAction("deploy", action$5)(ctx, opts));
1348
1377
  };
1349
1378
  const deployProject = {
1350
1379
  name: "deploy-project",