@strapi/cloud-cli 0.0.0-next.a237dfc081ee4788ee5abb71a735161aebec0ee5 → 0.0.0-next.ac2b9fdba5ef59eb22c4e387ac1c5a13dd219f29

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.js CHANGED
@@ -192,7 +192,7 @@ async function saveLocalConfig(data) {
192
192
  await fse__namespace.default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
193
193
  }
194
194
  const name = "@strapi/cloud-cli";
195
- const version = "4.25.8";
195
+ const version = "4.25.11";
196
196
  const description = "Commands to interact with the Strapi Cloud";
197
197
  const keywords = [
198
198
  "strapi",
@@ -237,8 +237,8 @@ const scripts = {
237
237
  watch: "pack-up watch"
238
238
  };
239
239
  const dependencies = {
240
- "@strapi/utils": "4.25.8",
241
- axios: "1.6.0",
240
+ "@strapi/utils": "4.25.11",
241
+ axios: "1.7.4",
242
242
  chalk: "4.1.2",
243
243
  "cli-progress": "3.12.0",
244
244
  commander: "8.3.0",
@@ -262,8 +262,8 @@ const devDependencies = {
262
262
  "@types/cli-progress": "3.11.5",
263
263
  "@types/eventsource": "1.1.15",
264
264
  "@types/lodash": "^4.14.191",
265
- "eslint-config-custom": "4.25.8",
266
- tsconfig: "4.25.8"
265
+ "eslint-config-custom": "4.25.11",
266
+ tsconfig: "4.25.11"
267
267
  };
268
268
  const engines = {
269
269
  node: ">=18.0.0 <=20.x.x",
@@ -375,7 +375,7 @@ async function cloudApiFactory({ logger }, token) {
375
375
  },
376
376
  async listLinkProjects() {
377
377
  try {
378
- const response = await axiosCloudAPI.get("/projects/linkable");
378
+ const response = await axiosCloudAPI.get("/projects-linkable");
379
379
  if (response.status !== 200) {
380
380
  throw new Error("Error fetching cloud projects from the server.");
381
381
  }
@@ -387,6 +387,20 @@ async function cloudApiFactory({ logger }, token) {
387
387
  throw error;
388
388
  }
389
389
  },
390
+ async getProject({ name: name2 }) {
391
+ try {
392
+ const response = await axiosCloudAPI.get(`/projects/${name2}`);
393
+ if (response.status !== 200) {
394
+ throw new Error("Error fetching project's details.");
395
+ }
396
+ return response;
397
+ } catch (error) {
398
+ logger.debug(
399
+ "🥲 Oops! There was a problem retrieving your project's details. Please try again."
400
+ );
401
+ throw error;
402
+ }
403
+ },
390
404
  track(event, payload = {}) {
391
405
  return axiosCloudAPI.post("/track", {
392
406
  event,
@@ -1137,17 +1151,7 @@ async function upload(ctx, project, token, maxProjectFileSize) {
1137
1151
  return data.build_id;
1138
1152
  } catch (e) {
1139
1153
  progressBar.stop();
1140
- if (e instanceof axios.AxiosError && e.response?.data) {
1141
- if (e.response.status === 404) {
1142
- ctx.logger.warn(
1143
- `The project does not exist. Please link your local project to a Strapi Cloud project using the link command.`
1144
- );
1145
- } else {
1146
- ctx.logger.error(e.response.data);
1147
- }
1148
- } else {
1149
- ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1150
- }
1154
+ ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1151
1155
  ctx.logger.debug(e);
1152
1156
  } finally {
1153
1157
  await fse__namespace.default.remove(tarFilePath);
@@ -1184,6 +1188,40 @@ async function getConfig({
1184
1188
  return null;
1185
1189
  }
1186
1190
  }
1191
+ function assertProjectSuspension(ctx, projectSuspendedAt, projectPageURL) {
1192
+ if (projectSuspendedAt) {
1193
+ ctx.logger.log(
1194
+ "\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
1195
+ );
1196
+ ctx.logger.log(chalk__default.default.underline(projectPageURL));
1197
+ throw new Error("Project is suspended");
1198
+ }
1199
+ }
1200
+ async function getProjectData({ ctx, cloudApiService }, projectInternalName) {
1201
+ try {
1202
+ const { data } = await cloudApiService.getProject({ name: projectInternalName });
1203
+ return data;
1204
+ } catch (e) {
1205
+ if (e instanceof axios.AxiosError && e.response?.data) {
1206
+ if (e.response.status === 404) {
1207
+ ctx.logger.warn(
1208
+ `The project associated with this folder does not exist in Strapi Cloud.
1209
+ Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
1210
+ "link"
1211
+ )} command before deploying.`
1212
+ );
1213
+ } else {
1214
+ ctx.logger.error(e.response.data);
1215
+ }
1216
+ } else {
1217
+ ctx.logger.error(
1218
+ "An error occurred while retrieving the project's information. Please try again later."
1219
+ );
1220
+ }
1221
+ ctx.logger.debug(e);
1222
+ return null;
1223
+ }
1224
+ }
1187
1225
  const action$3 = async (ctx) => {
1188
1226
  const { getValidToken } = await tokenServiceFactory(ctx);
1189
1227
  const token = await getValidToken(ctx, promptLogin);
@@ -1194,7 +1232,17 @@ const action$3 = async (ctx) => {
1194
1232
  if (!project) {
1195
1233
  return;
1196
1234
  }
1197
- const cloudApiService = await cloudApiFactory(ctx);
1235
+ const cloudApiService = await cloudApiFactory(ctx, token);
1236
+ const projectResponse = await getProjectData({ ctx, cloudApiService }, project.name);
1237
+ if (!projectResponse) {
1238
+ return;
1239
+ }
1240
+ const { data: projectData, metadata: projectMetadata } = projectResponse;
1241
+ try {
1242
+ assertProjectSuspension(ctx, projectData.suspendedAt, projectMetadata.dashboardUrls.project);
1243
+ } catch (e) {
1244
+ return;
1245
+ }
1198
1246
  await trackEvent(ctx, cloudApiService, "willDeployWithCLI", {
1199
1247
  projectInternalName: project.name
1200
1248
  });
@@ -1203,7 +1251,7 @@ const action$3 = async (ctx) => {
1203
1251
  const cliConfig2 = await getConfig({ ctx, cloudApiService });
1204
1252
  if (!cliConfig2) {
1205
1253
  ctx.logger.error(
1206
- "An error occurred while retrieving data from Strapi Cloud. Please try check your network or again later."
1254
+ "An error occurred while retrieving data from Strapi Cloud. Please check your network or try again later."
1207
1255
  );
1208
1256
  return;
1209
1257
  }
@@ -1224,9 +1272,7 @@ const action$3 = async (ctx) => {
1224
1272
  ctx.logger.log(
1225
1273
  "Visit the following URL for deployment logs. Your deployment will be available here shortly."
1226
1274
  );
1227
- ctx.logger.log(
1228
- chalk__default.default.underline(`${apiConfig.dashboardBaseUrl}/projects/${project.name}/deployments`)
1229
- );
1275
+ ctx.logger.log(chalk__default.default.underline(projectMetadata.dashboardUrls.deployments));
1230
1276
  } catch (e) {
1231
1277
  ctx.logger.debug(e);
1232
1278
  if (e instanceof Error) {