@strapi/cloud-cli 5.0.5 → 5.0.6

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
@@ -134,7 +134,7 @@ async function saveLocalConfig(data) {
134
134
  await fse__default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
135
135
  }
136
136
  const name = "@strapi/cloud-cli";
137
- const version = "5.0.4";
137
+ const version = "5.0.0";
138
138
  const description = "Commands to interact with the Strapi Cloud";
139
139
  const keywords = [
140
140
  "strapi",
@@ -208,7 +208,7 @@ const devDependencies = {
208
208
  tsconfig: "workspace:*"
209
209
  };
210
210
  const engines = {
211
- node: ">=18.0.0 <=22.x.x",
211
+ node: ">=18.0.0 <=20.x.x",
212
212
  npm: ">=6.0.0"
213
213
  };
214
214
  const packageJson = {
@@ -329,20 +329,6 @@ async function cloudApiFactory({ logger }, token) {
329
329
  throw error;
330
330
  }
331
331
  },
332
- async listEnvironments({ name: name2 }) {
333
- try {
334
- const response = await axiosCloudAPI.get(`/projects/${name2}/environments`);
335
- if (response.status !== 200) {
336
- throw new Error("Error fetching cloud environments from the server.");
337
- }
338
- return response;
339
- } catch (error) {
340
- logger.debug(
341
- "🥲 Oops! Couldn't retrieve your project's environments from the server. Please try again."
342
- );
343
- throw error;
344
- }
345
- },
346
332
  async getProject({ name: name2 }) {
347
333
  try {
348
334
  const response = await axiosCloudAPI.get(`/projects/${name2}`);
@@ -915,7 +901,7 @@ async function createProject$1(ctx, cloudApi, projectInput) {
915
901
  throw e;
916
902
  }
917
903
  }
918
- const action$5 = async (ctx) => {
904
+ const action$4 = async (ctx) => {
919
905
  const { logger } = ctx;
920
906
  const { getValidToken, eraseToken } = await tokenServiceFactory(ctx);
921
907
  const token = await getValidToken(ctx, promptLogin);
@@ -1122,11 +1108,11 @@ async function upload(ctx, project, token, maxProjectFileSize) {
1122
1108
  process.exit(1);
1123
1109
  }
1124
1110
  }
1125
- async function getProject$1(ctx) {
1111
+ async function getProject(ctx) {
1126
1112
  const { project } = await retrieve();
1127
1113
  if (!project) {
1128
1114
  try {
1129
- return await action$5(ctx);
1115
+ return await action$4(ctx);
1130
1116
  } catch (e) {
1131
1117
  ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1132
1118
  ctx.logger.debug(e);
@@ -1147,13 +1133,13 @@ async function getConfig({
1147
1133
  return null;
1148
1134
  }
1149
1135
  }
1150
- const action$4 = async (ctx) => {
1136
+ const action$3 = async (ctx) => {
1151
1137
  const { getValidToken } = await tokenServiceFactory(ctx);
1152
1138
  const token = await getValidToken(ctx, promptLogin);
1153
1139
  if (!token) {
1154
1140
  return;
1155
1141
  }
1156
- const project = await getProject$1(ctx);
1142
+ const project = await getProject(ctx);
1157
1143
  if (!project) {
1158
1144
  return;
1159
1145
  }
@@ -1258,14 +1244,14 @@ const runAction = (name2, action2) => (...args) => {
1258
1244
  process.exit(1);
1259
1245
  });
1260
1246
  };
1261
- const command$6 = ({ ctx }) => {
1262
- 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").action(() => runAction("deploy", action$4)(ctx));
1247
+ const command$5 = ({ ctx }) => {
1248
+ 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").action(() => runAction("deploy", action$3)(ctx));
1263
1249
  };
1264
1250
  const deployProject = {
1265
1251
  name: "deploy-project",
1266
1252
  description: "Deploy a Strapi Cloud project",
1267
- action: action$4,
1268
- command: command$6
1253
+ action: action$3,
1254
+ command: command$5
1269
1255
  };
1270
1256
  const QUIT_OPTION = "Quit";
1271
1257
  async function getExistingConfig(ctx) {
@@ -1349,7 +1335,7 @@ async function getUserSelection(ctx, projects) {
1349
1335
  return null;
1350
1336
  }
1351
1337
  }
1352
- const action$3 = async (ctx) => {
1338
+ const action$2 = async (ctx) => {
1353
1339
  const { getValidToken } = await tokenServiceFactory(ctx);
1354
1340
  const token = await getValidToken(ctx, promptLogin);
1355
1341
  const { logger } = ctx;
@@ -1404,16 +1390,16 @@ const action$3 = async (ctx) => {
1404
1390
  });
1405
1391
  }
1406
1392
  };
1407
- const command$5 = ({ command: command2, ctx }) => {
1408
- command2.command("cloud:link").alias("link").description("Link a local directory to a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("link", action$3)(ctx));
1393
+ const command$4 = ({ command: command2, ctx }) => {
1394
+ command2.command("cloud:link").alias("link").description("Link a local directory to a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("link", action$2)(ctx));
1409
1395
  };
1410
1396
  const link = {
1411
1397
  name: "link-project",
1412
1398
  description: "Link a local directory to a Strapi Cloud project",
1413
- action: action$3,
1414
- command: command$5
1399
+ action: action$2,
1400
+ command: command$4
1415
1401
  };
1416
- const command$4 = ({ ctx }) => {
1402
+ const command$3 = ({ ctx }) => {
1417
1403
  return createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
1418
1404
  "after",
1419
1405
  "\nAfter running this command, you will be prompted to enter your authentication information."
@@ -1423,10 +1409,10 @@ const login = {
1423
1409
  name: "login",
1424
1410
  description: "Strapi Cloud Login",
1425
1411
  action: loginAction,
1426
- command: command$4
1412
+ command: command$3
1427
1413
  };
1428
1414
  const openModule = import("open");
1429
- const action$2 = async (ctx) => {
1415
+ const action$1 = async (ctx) => {
1430
1416
  const { logger } = ctx;
1431
1417
  const { retrieveToken, eraseToken } = await tokenServiceFactory(ctx);
1432
1418
  const token = await retrieveToken();
@@ -1458,25 +1444,25 @@ const action$2 = async (ctx) => {
1458
1444
  }
1459
1445
  await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
1460
1446
  };
1461
- const command$3 = ({ ctx }) => {
1462
- return 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$2)(ctx));
1447
+ const command$2 = ({ ctx }) => {
1448
+ return 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));
1463
1449
  };
1464
1450
  const logout = {
1465
1451
  name: "logout",
1466
1452
  description: "Strapi Cloud Logout",
1467
- action: action$2,
1468
- command: command$3
1453
+ action: action$1,
1454
+ command: command$2
1469
1455
  };
1470
- const command$2 = ({ ctx }) => {
1471
- return 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$5)(ctx));
1456
+ const command$1 = ({ ctx }) => {
1457
+ return 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));
1472
1458
  };
1473
1459
  const createProject = {
1474
1460
  name: "create-project",
1475
1461
  description: "Create a new project",
1476
- action: action$5,
1477
- command: command$2
1462
+ action: action$4,
1463
+ command: command$1
1478
1464
  };
1479
- const action$1 = async (ctx) => {
1465
+ const action = async (ctx) => {
1480
1466
  const { getValidToken } = await tokenServiceFactory(ctx);
1481
1467
  const token = await getValidToken(ctx, promptLogin);
1482
1468
  const { logger } = ctx;
@@ -1496,86 +1482,12 @@ const action$1 = async (ctx) => {
1496
1482
  spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
1497
1483
  }
1498
1484
  };
1499
- const command$1 = ({ command: command2, ctx }) => {
1500
- command2.command("cloud:projects").alias("projects").description("List Strapi Cloud projects").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("projects", action$1)(ctx));
1485
+ const command = ({ command: command2, ctx }) => {
1486
+ command2.command("cloud:projects").alias("projects").description("List Strapi Cloud projects").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("projects", action)(ctx));
1501
1487
  };
1502
1488
  const listProjects = {
1503
1489
  name: "list-projects",
1504
1490
  description: "List Strapi Cloud projects",
1505
- action: action$1,
1506
- command: command$1
1507
- };
1508
- async function getProject(ctx) {
1509
- const { project } = await retrieve();
1510
- if (!project) {
1511
- ctx.logger.warn(
1512
- `
1513
- We couldn't find a valid local project config.
1514
- Please link your local project to an existing Strapi Cloud project using the ${chalk.cyan(
1515
- "link"
1516
- )} command`
1517
- );
1518
- process.exit(1);
1519
- }
1520
- return project;
1521
- }
1522
- const action = async (ctx) => {
1523
- const { getValidToken } = await tokenServiceFactory(ctx);
1524
- const token = await getValidToken(ctx, promptLogin);
1525
- const { logger } = ctx;
1526
- if (!token) {
1527
- return;
1528
- }
1529
- const project = await getProject(ctx);
1530
- if (!project) {
1531
- ctx.logger.debug(`No valid local project configuration was found.`);
1532
- return;
1533
- }
1534
- const cloudApiService = await cloudApiFactory(ctx, token);
1535
- const spinner = logger.spinner("Fetching environments...").start();
1536
- await trackEvent(ctx, cloudApiService, "willListEnvironment", {
1537
- projectInternalName: project.name
1538
- });
1539
- try {
1540
- const {
1541
- data: { data: environmentsList }
1542
- } = await cloudApiService.listEnvironments({ name: project.name });
1543
- spinner.succeed();
1544
- logger.log(environmentsList);
1545
- await trackEvent(ctx, cloudApiService, "didListEnvironment", {
1546
- projectInternalName: project.name
1547
- });
1548
- } catch (e) {
1549
- if (e.response && e.response.status === 404) {
1550
- spinner.succeed();
1551
- logger.warn(
1552
- `
1553
- The project associated with this folder does not exist in Strapi Cloud.
1554
- Please link your local project to an existing Strapi Cloud project using the ${chalk.cyan(
1555
- "link"
1556
- )} command`
1557
- );
1558
- } else {
1559
- spinner.fail("An error occurred while fetching environments data from Strapi Cloud.");
1560
- logger.debug("Failed to list environments", e);
1561
- }
1562
- await trackEvent(ctx, cloudApiService, "didNotListEnvironment", {
1563
- projectInternalName: project.name
1564
- });
1565
- }
1566
- };
1567
- function defineCloudNamespace(command2) {
1568
- return command2.command("cloud").description("Manage Strapi Cloud projects");
1569
- }
1570
- const command = ({ command: command2, ctx }) => {
1571
- const cloud = defineCloudNamespace(command2);
1572
- cloud.command("environments").description("Alias for cloud environment list").action(() => runAction("list", action)(ctx));
1573
- const environment = cloud.command("environment").description("Manage environments for a Strapi Cloud project");
1574
- environment.command("list").description("List Strapi Cloud project environments").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("list", action)(ctx));
1575
- };
1576
- const listEnvironments = {
1577
- name: "list-environments",
1578
- description: "List Strapi Cloud environments",
1579
1491
  action,
1580
1492
  command
1581
1493
  };
@@ -1585,10 +1497,9 @@ const cli = {
1585
1497
  login,
1586
1498
  logout,
1587
1499
  createProject,
1588
- listProjects,
1589
- listEnvironments
1500
+ listProjects
1590
1501
  };
1591
- const cloudCommands = [deployProject, link, login, logout, listProjects, listEnvironments];
1502
+ const cloudCommands = [deployProject, link, login, logout, listProjects];
1592
1503
  async function initCloudCLIConfig() {
1593
1504
  const localConfig = await getLocalConfig();
1594
1505
  if (!localConfig.deviceId) {