@strapi/cloud-cli 0.0.0-next.c81cadaa87436c4661a7ec61cdda96a5540b2b42 → 0.0.0-next.d2d15ef227d67cce89c2673764c0555c841cd29c

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
@@ -43,6 +43,7 @@ const cliProgress = require("cli-progress");
43
43
  const pkgUp = require("pkg-up");
44
44
  const yup = require("yup");
45
45
  const EventSource = require("eventsource");
46
+ const commander = require("commander");
46
47
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
47
48
  function _interopNamespace(e) {
48
49
  if (e && e.__esModule)
@@ -192,7 +193,7 @@ async function saveLocalConfig(data) {
192
193
  await fse__namespace.default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
193
194
  }
194
195
  const name = "@strapi/cloud-cli";
195
- const version = "4.25.7";
196
+ const version = "5.0.0";
196
197
  const description = "Commands to interact with the Strapi Cloud";
197
198
  const keywords = [
198
199
  "strapi",
@@ -237,14 +238,14 @@ const scripts = {
237
238
  watch: "pack-up watch"
238
239
  };
239
240
  const dependencies = {
240
- "@strapi/utils": "4.25.7",
241
- axios: "1.6.0",
241
+ "@strapi/utils": "workspace:*",
242
+ axios: "1.7.4",
242
243
  chalk: "4.1.2",
243
244
  "cli-progress": "3.12.0",
244
245
  commander: "8.3.0",
245
246
  eventsource: "2.0.2",
246
247
  "fast-safe-stringify": "2.1.1",
247
- "fs-extra": "10.0.0",
248
+ "fs-extra": "11.2.0",
248
249
  inquirer: "8.2.5",
249
250
  jsonwebtoken: "9.0.0",
250
251
  "jwks-rsa": "3.1.0",
@@ -262,8 +263,8 @@ const devDependencies = {
262
263
  "@types/cli-progress": "3.11.5",
263
264
  "@types/eventsource": "1.1.15",
264
265
  "@types/lodash": "^4.14.191",
265
- "eslint-config-custom": "4.25.7",
266
- tsconfig: "4.25.7"
266
+ "eslint-config-custom": "workspace:*",
267
+ tsconfig: "workspace:*"
267
268
  };
268
269
  const engines = {
269
270
  node: ">=18.0.0 <=20.x.x",
@@ -375,7 +376,7 @@ async function cloudApiFactory({ logger }, token) {
375
376
  },
376
377
  async listLinkProjects() {
377
378
  try {
378
- const response = await axiosCloudAPI.get("/projects/linkable");
379
+ const response = await axiosCloudAPI.get("/projects-linkable");
379
380
  if (response.status !== 200) {
380
381
  throw new Error("Error fetching cloud projects from the server.");
381
382
  }
@@ -387,6 +388,20 @@ async function cloudApiFactory({ logger }, token) {
387
388
  throw error;
388
389
  }
389
390
  },
391
+ async getProject({ name: name2 }) {
392
+ try {
393
+ const response = await axiosCloudAPI.get(`/projects/${name2}`);
394
+ if (response.status !== 200) {
395
+ throw new Error("Error fetching project's details.");
396
+ }
397
+ return response;
398
+ } catch (error) {
399
+ logger.debug(
400
+ "🥲 Oops! There was a problem retrieving your project's details. Please try again."
401
+ );
402
+ throw error;
403
+ }
404
+ },
390
405
  track(event, payload = {}) {
391
406
  return axiosCloudAPI.post("/track", {
392
407
  event,
@@ -660,21 +675,24 @@ yup__namespace.object({
660
675
  name: yup__namespace.string().required(),
661
676
  exports: yup__namespace.lazy(
662
677
  (value) => yup__namespace.object(
663
- typeof value === "object" ? Object.entries(value).reduce((acc, [key, value2]) => {
664
- if (typeof value2 === "object") {
665
- acc[key] = yup__namespace.object({
666
- types: yup__namespace.string().optional(),
667
- source: yup__namespace.string().required(),
668
- module: yup__namespace.string().optional(),
669
- import: yup__namespace.string().required(),
670
- require: yup__namespace.string().required(),
671
- default: yup__namespace.string().required()
672
- }).noUnknown(true);
673
- } else {
674
- acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
675
- }
676
- return acc;
677
- }, {}) : void 0
678
+ typeof value === "object" ? Object.entries(value).reduce(
679
+ (acc, [key, value2]) => {
680
+ if (typeof value2 === "object") {
681
+ acc[key] = yup__namespace.object({
682
+ types: yup__namespace.string().optional(),
683
+ source: yup__namespace.string().required(),
684
+ module: yup__namespace.string().optional(),
685
+ import: yup__namespace.string().required(),
686
+ require: yup__namespace.string().required(),
687
+ default: yup__namespace.string().required()
688
+ }).noUnknown(true);
689
+ } else {
690
+ acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
691
+ }
692
+ return acc;
693
+ },
694
+ {}
695
+ ) : void 0
678
696
  ).optional()
679
697
  )
680
698
  });
@@ -1137,17 +1155,7 @@ async function upload(ctx, project, token, maxProjectFileSize) {
1137
1155
  return data.build_id;
1138
1156
  } catch (e) {
1139
1157
  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
- }
1158
+ ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1151
1159
  ctx.logger.debug(e);
1152
1160
  } finally {
1153
1161
  await fse__namespace.default.remove(tarFilePath);
@@ -1194,7 +1202,39 @@ const action$3 = async (ctx) => {
1194
1202
  if (!project) {
1195
1203
  return;
1196
1204
  }
1197
- const cloudApiService = await cloudApiFactory(ctx);
1205
+ const cloudApiService = await cloudApiFactory(ctx, token);
1206
+ try {
1207
+ const {
1208
+ data: { data: projectData, metadata }
1209
+ } = await cloudApiService.getProject({ name: project.name });
1210
+ const isProjectSuspended = projectData.suspendedAt;
1211
+ if (isProjectSuspended) {
1212
+ ctx.logger.log(
1213
+ "\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
1214
+ );
1215
+ ctx.logger.log(chalk__default.default.underline(`${metadata.dashboardUrls.project}`));
1216
+ return;
1217
+ }
1218
+ } catch (e) {
1219
+ if (e instanceof axios.AxiosError && e.response?.data) {
1220
+ if (e.response.status === 404) {
1221
+ ctx.logger.warn(
1222
+ `The project associated with this folder does not exist in Strapi Cloud.
1223
+ Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
1224
+ "link"
1225
+ )} command before deploying.`
1226
+ );
1227
+ } else {
1228
+ ctx.logger.error(e.response.data);
1229
+ }
1230
+ } else {
1231
+ ctx.logger.error(
1232
+ "An error occurred while retrieving the project's information. Please try again later."
1233
+ );
1234
+ }
1235
+ ctx.logger.debug(e);
1236
+ return;
1237
+ }
1198
1238
  await trackEvent(ctx, cloudApiService, "willDeployWithCLI", {
1199
1239
  projectInternalName: project.name
1200
1240
  });
@@ -1203,7 +1243,7 @@ const action$3 = async (ctx) => {
1203
1243
  const cliConfig2 = await getConfig({ ctx, cloudApiService });
1204
1244
  if (!cliConfig2) {
1205
1245
  ctx.logger.error(
1206
- "An error occurred while retrieving data from Strapi Cloud. Please try check your network or again later."
1246
+ "An error occurred while retrieving data from Strapi Cloud. Please check your network or try again later."
1207
1247
  );
1208
1248
  return;
1209
1249
  }
@@ -1263,8 +1303,8 @@ const runAction = (name2, action2) => (...args) => {
1263
1303
  process.exit(1);
1264
1304
  });
1265
1305
  };
1266
- const command$5 = ({ command: command2, ctx }) => {
1267
- command2.command("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").action(() => runAction("deploy", action$3)(ctx));
1306
+ const command$5 = ({ ctx }) => {
1307
+ return commander.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").action(() => runAction("deploy", action$3)(ctx));
1268
1308
  };
1269
1309
  const deployProject = {
1270
1310
  name: "deploy-project",
@@ -1418,8 +1458,8 @@ const link = {
1418
1458
  action: action$2,
1419
1459
  command: command$4
1420
1460
  };
1421
- const command$3 = ({ command: command2, ctx }) => {
1422
- command2.command("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
1461
+ const command$3 = ({ ctx }) => {
1462
+ return commander.createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
1423
1463
  "after",
1424
1464
  "\nAfter running this command, you will be prompted to enter your authentication information."
1425
1465
  ).option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("login", loginAction)(ctx));
@@ -1463,8 +1503,8 @@ const action$1 = async (ctx) => {
1463
1503
  }
1464
1504
  await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
1465
1505
  };
1466
- const command$2 = ({ command: command2, ctx }) => {
1467
- command2.command("cloud:logout").alias("logout").description("Strapi Cloud Logout").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("logout", action$1)(ctx));
1506
+ const command$2 = ({ ctx }) => {
1507
+ return commander.createCommand("cloud:logout").alias("logout").description("Strapi Cloud Logout").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("logout", action$1)(ctx));
1468
1508
  };
1469
1509
  const logout = {
1470
1510
  name: "logout",
@@ -1472,8 +1512,8 @@ const logout = {
1472
1512
  action: action$1,
1473
1513
  command: command$2
1474
1514
  };
1475
- const command$1 = ({ command: command2, ctx }) => {
1476
- command2.command("cloud:create-project").description("Create a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("cloud:create-project", action$4)(ctx));
1515
+ const command$1 = ({ ctx }) => {
1516
+ return commander.createCommand("cloud:create-project").description("Create a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("cloud:create-project", action$4)(ctx));
1477
1517
  };
1478
1518
  const createProject = {
1479
1519
  name: "create-project",
@@ -1534,7 +1574,10 @@ async function buildStrapiCloudCommands({
1534
1574
  await initCloudCLIConfig();
1535
1575
  for (const cloudCommand of cloudCommands) {
1536
1576
  try {
1537
- await cloudCommand.command({ command: command2, ctx, argv });
1577
+ const subCommand = await cloudCommand.command({ command: command2, ctx, argv });
1578
+ if (subCommand) {
1579
+ command2.addCommand(subCommand);
1580
+ }
1538
1581
  } catch (e) {
1539
1582
  console.error(`Failed to load command ${cloudCommand.name}`, e);
1540
1583
  }