@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.mjs CHANGED
@@ -133,7 +133,7 @@ async function saveLocalConfig(data) {
133
133
  await fse__default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
134
134
  }
135
135
  const name = "@strapi/cloud-cli";
136
- const version = "4.25.8";
136
+ const version = "4.25.11";
137
137
  const description = "Commands to interact with the Strapi Cloud";
138
138
  const keywords = [
139
139
  "strapi",
@@ -178,8 +178,8 @@ const scripts = {
178
178
  watch: "pack-up watch"
179
179
  };
180
180
  const dependencies = {
181
- "@strapi/utils": "4.25.8",
182
- axios: "1.6.0",
181
+ "@strapi/utils": "4.25.11",
182
+ axios: "1.7.4",
183
183
  chalk: "4.1.2",
184
184
  "cli-progress": "3.12.0",
185
185
  commander: "8.3.0",
@@ -203,8 +203,8 @@ const devDependencies = {
203
203
  "@types/cli-progress": "3.11.5",
204
204
  "@types/eventsource": "1.1.15",
205
205
  "@types/lodash": "^4.14.191",
206
- "eslint-config-custom": "4.25.8",
207
- tsconfig: "4.25.8"
206
+ "eslint-config-custom": "4.25.11",
207
+ tsconfig: "4.25.11"
208
208
  };
209
209
  const engines = {
210
210
  node: ">=18.0.0 <=20.x.x",
@@ -316,7 +316,7 @@ async function cloudApiFactory({ logger }, token) {
316
316
  },
317
317
  async listLinkProjects() {
318
318
  try {
319
- const response = await axiosCloudAPI.get("/projects/linkable");
319
+ const response = await axiosCloudAPI.get("/projects-linkable");
320
320
  if (response.status !== 200) {
321
321
  throw new Error("Error fetching cloud projects from the server.");
322
322
  }
@@ -328,6 +328,20 @@ async function cloudApiFactory({ logger }, token) {
328
328
  throw error;
329
329
  }
330
330
  },
331
+ async getProject({ name: name2 }) {
332
+ try {
333
+ const response = await axiosCloudAPI.get(`/projects/${name2}`);
334
+ if (response.status !== 200) {
335
+ throw new Error("Error fetching project's details.");
336
+ }
337
+ return response;
338
+ } catch (error) {
339
+ logger.debug(
340
+ "🥲 Oops! There was a problem retrieving your project's details. Please try again."
341
+ );
342
+ throw error;
343
+ }
344
+ },
331
345
  track(event, payload = {}) {
332
346
  return axiosCloudAPI.post("/track", {
333
347
  event,
@@ -1078,17 +1092,7 @@ async function upload(ctx, project, token, maxProjectFileSize) {
1078
1092
  return data.build_id;
1079
1093
  } catch (e) {
1080
1094
  progressBar.stop();
1081
- if (e instanceof AxiosError && e.response?.data) {
1082
- if (e.response.status === 404) {
1083
- ctx.logger.warn(
1084
- `The project does not exist. Please link your local project to a Strapi Cloud project using the link command.`
1085
- );
1086
- } else {
1087
- ctx.logger.error(e.response.data);
1088
- }
1089
- } else {
1090
- ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1091
- }
1095
+ ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1092
1096
  ctx.logger.debug(e);
1093
1097
  } finally {
1094
1098
  await fse__default.remove(tarFilePath);
@@ -1125,6 +1129,40 @@ async function getConfig({
1125
1129
  return null;
1126
1130
  }
1127
1131
  }
1132
+ function assertProjectSuspension(ctx, projectSuspendedAt, projectPageURL) {
1133
+ if (projectSuspendedAt) {
1134
+ ctx.logger.log(
1135
+ "\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
1136
+ );
1137
+ ctx.logger.log(chalk.underline(projectPageURL));
1138
+ throw new Error("Project is suspended");
1139
+ }
1140
+ }
1141
+ async function getProjectData({ ctx, cloudApiService }, projectInternalName) {
1142
+ try {
1143
+ const { data } = await cloudApiService.getProject({ name: projectInternalName });
1144
+ return data;
1145
+ } catch (e) {
1146
+ if (e instanceof AxiosError && e.response?.data) {
1147
+ if (e.response.status === 404) {
1148
+ ctx.logger.warn(
1149
+ `The project associated with this folder does not exist in Strapi Cloud.
1150
+ Please link your local project to an existing Strapi Cloud project using the ${chalk.cyan(
1151
+ "link"
1152
+ )} command before deploying.`
1153
+ );
1154
+ } else {
1155
+ ctx.logger.error(e.response.data);
1156
+ }
1157
+ } else {
1158
+ ctx.logger.error(
1159
+ "An error occurred while retrieving the project's information. Please try again later."
1160
+ );
1161
+ }
1162
+ ctx.logger.debug(e);
1163
+ return null;
1164
+ }
1165
+ }
1128
1166
  const action$3 = async (ctx) => {
1129
1167
  const { getValidToken } = await tokenServiceFactory(ctx);
1130
1168
  const token = await getValidToken(ctx, promptLogin);
@@ -1135,7 +1173,17 @@ const action$3 = async (ctx) => {
1135
1173
  if (!project) {
1136
1174
  return;
1137
1175
  }
1138
- const cloudApiService = await cloudApiFactory(ctx);
1176
+ const cloudApiService = await cloudApiFactory(ctx, token);
1177
+ const projectResponse = await getProjectData({ ctx, cloudApiService }, project.name);
1178
+ if (!projectResponse) {
1179
+ return;
1180
+ }
1181
+ const { data: projectData, metadata: projectMetadata } = projectResponse;
1182
+ try {
1183
+ assertProjectSuspension(ctx, projectData.suspendedAt, projectMetadata.dashboardUrls.project);
1184
+ } catch (e) {
1185
+ return;
1186
+ }
1139
1187
  await trackEvent(ctx, cloudApiService, "willDeployWithCLI", {
1140
1188
  projectInternalName: project.name
1141
1189
  });
@@ -1144,7 +1192,7 @@ const action$3 = async (ctx) => {
1144
1192
  const cliConfig2 = await getConfig({ ctx, cloudApiService });
1145
1193
  if (!cliConfig2) {
1146
1194
  ctx.logger.error(
1147
- "An error occurred while retrieving data from Strapi Cloud. Please try check your network or again later."
1195
+ "An error occurred while retrieving data from Strapi Cloud. Please check your network or try again later."
1148
1196
  );
1149
1197
  return;
1150
1198
  }
@@ -1165,9 +1213,7 @@ const action$3 = async (ctx) => {
1165
1213
  ctx.logger.log(
1166
1214
  "Visit the following URL for deployment logs. Your deployment will be available here shortly."
1167
1215
  );
1168
- ctx.logger.log(
1169
- chalk.underline(`${apiConfig.dashboardBaseUrl}/projects/${project.name}/deployments`)
1170
- );
1216
+ ctx.logger.log(chalk.underline(projectMetadata.dashboardUrls.deployments));
1171
1217
  } catch (e) {
1172
1218
  ctx.logger.debug(e);
1173
1219
  if (e instanceof Error) {