@strapi/cloud-cli 5.0.6 → 5.1.1
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 +121 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +121 -32
- package/dist/index.mjs.map +1 -1
- package/dist/src/cloud/command.d.ts +3 -0
- package/dist/src/cloud/command.d.ts.map +1 -0
- package/dist/src/environment/command.d.ts +3 -0
- package/dist/src/environment/command.d.ts.map +1 -0
- package/dist/src/environment/list/action.d.ts +4 -0
- package/dist/src/environment/list/action.d.ts.map +1 -0
- package/dist/src/environment/list/command.d.ts +4 -0
- package/dist/src/environment/list/command.d.ts.map +1 -0
- package/dist/src/environment/list/index.d.ts +7 -0
- package/dist/src/environment/list/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/cli-api.d.ts +9 -0
- package/dist/src/services/cli-api.d.ts.map +1 -1
- package/dist/src/types.d.ts +3 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +5 -5
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.
|
|
137
|
+
const version = "5.1.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 <=
|
|
211
|
+
node: ">=18.0.0 <=22.x.x",
|
|
212
212
|
npm: ">=6.0.0"
|
|
213
213
|
};
|
|
214
214
|
const packageJson = {
|
|
@@ -329,6 +329,20 @@ 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
|
+
},
|
|
332
346
|
async getProject({ name: name2 }) {
|
|
333
347
|
try {
|
|
334
348
|
const response = await axiosCloudAPI.get(`/projects/${name2}`);
|
|
@@ -901,7 +915,7 @@ async function createProject$1(ctx, cloudApi, projectInput) {
|
|
|
901
915
|
throw e;
|
|
902
916
|
}
|
|
903
917
|
}
|
|
904
|
-
const action$
|
|
918
|
+
const action$5 = async (ctx) => {
|
|
905
919
|
const { logger } = ctx;
|
|
906
920
|
const { getValidToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
907
921
|
const token = await getValidToken(ctx, promptLogin);
|
|
@@ -1108,11 +1122,11 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1108
1122
|
process.exit(1);
|
|
1109
1123
|
}
|
|
1110
1124
|
}
|
|
1111
|
-
async function getProject(ctx) {
|
|
1125
|
+
async function getProject$1(ctx) {
|
|
1112
1126
|
const { project } = await retrieve();
|
|
1113
1127
|
if (!project) {
|
|
1114
1128
|
try {
|
|
1115
|
-
return await action$
|
|
1129
|
+
return await action$5(ctx);
|
|
1116
1130
|
} catch (e) {
|
|
1117
1131
|
ctx.logger.error("An error occurred while deploying the project. Please try again later.");
|
|
1118
1132
|
ctx.logger.debug(e);
|
|
@@ -1133,13 +1147,13 @@ async function getConfig({
|
|
|
1133
1147
|
return null;
|
|
1134
1148
|
}
|
|
1135
1149
|
}
|
|
1136
|
-
const action$
|
|
1150
|
+
const action$4 = async (ctx) => {
|
|
1137
1151
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1138
1152
|
const token = await getValidToken(ctx, promptLogin);
|
|
1139
1153
|
if (!token) {
|
|
1140
1154
|
return;
|
|
1141
1155
|
}
|
|
1142
|
-
const project = await getProject(ctx);
|
|
1156
|
+
const project = await getProject$1(ctx);
|
|
1143
1157
|
if (!project) {
|
|
1144
1158
|
return;
|
|
1145
1159
|
}
|
|
@@ -1244,14 +1258,14 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1244
1258
|
process.exit(1);
|
|
1245
1259
|
});
|
|
1246
1260
|
};
|
|
1247
|
-
const command$
|
|
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$
|
|
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));
|
|
1249
1263
|
};
|
|
1250
1264
|
const deployProject = {
|
|
1251
1265
|
name: "deploy-project",
|
|
1252
1266
|
description: "Deploy a Strapi Cloud project",
|
|
1253
|
-
action: action$
|
|
1254
|
-
command: command$
|
|
1267
|
+
action: action$4,
|
|
1268
|
+
command: command$6
|
|
1255
1269
|
};
|
|
1256
1270
|
const QUIT_OPTION = "Quit";
|
|
1257
1271
|
async function getExistingConfig(ctx) {
|
|
@@ -1335,7 +1349,7 @@ async function getUserSelection(ctx, projects) {
|
|
|
1335
1349
|
return null;
|
|
1336
1350
|
}
|
|
1337
1351
|
}
|
|
1338
|
-
const action$
|
|
1352
|
+
const action$3 = async (ctx) => {
|
|
1339
1353
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1340
1354
|
const token = await getValidToken(ctx, promptLogin);
|
|
1341
1355
|
const { logger } = ctx;
|
|
@@ -1390,16 +1404,16 @@ const action$2 = async (ctx) => {
|
|
|
1390
1404
|
});
|
|
1391
1405
|
}
|
|
1392
1406
|
};
|
|
1393
|
-
const command$
|
|
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$
|
|
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));
|
|
1395
1409
|
};
|
|
1396
1410
|
const link = {
|
|
1397
1411
|
name: "link-project",
|
|
1398
1412
|
description: "Link a local directory to a Strapi Cloud project",
|
|
1399
|
-
action: action$
|
|
1400
|
-
command: command$
|
|
1413
|
+
action: action$3,
|
|
1414
|
+
command: command$5
|
|
1401
1415
|
};
|
|
1402
|
-
const command$
|
|
1416
|
+
const command$4 = ({ ctx }) => {
|
|
1403
1417
|
return createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
|
|
1404
1418
|
"after",
|
|
1405
1419
|
"\nAfter running this command, you will be prompted to enter your authentication information."
|
|
@@ -1409,10 +1423,10 @@ const login = {
|
|
|
1409
1423
|
name: "login",
|
|
1410
1424
|
description: "Strapi Cloud Login",
|
|
1411
1425
|
action: loginAction,
|
|
1412
|
-
command: command$
|
|
1426
|
+
command: command$4
|
|
1413
1427
|
};
|
|
1414
1428
|
const openModule = import("open");
|
|
1415
|
-
const action$
|
|
1429
|
+
const action$2 = async (ctx) => {
|
|
1416
1430
|
const { logger } = ctx;
|
|
1417
1431
|
const { retrieveToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
1418
1432
|
const token = await retrieveToken();
|
|
@@ -1444,25 +1458,25 @@ const action$1 = async (ctx) => {
|
|
|
1444
1458
|
}
|
|
1445
1459
|
await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
|
|
1446
1460
|
};
|
|
1447
|
-
const command$
|
|
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$
|
|
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));
|
|
1449
1463
|
};
|
|
1450
1464
|
const logout = {
|
|
1451
1465
|
name: "logout",
|
|
1452
1466
|
description: "Strapi Cloud Logout",
|
|
1453
|
-
action: action$
|
|
1454
|
-
command: command$
|
|
1467
|
+
action: action$2,
|
|
1468
|
+
command: command$3
|
|
1455
1469
|
};
|
|
1456
|
-
const command$
|
|
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$
|
|
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));
|
|
1458
1472
|
};
|
|
1459
1473
|
const createProject = {
|
|
1460
1474
|
name: "create-project",
|
|
1461
1475
|
description: "Create a new project",
|
|
1462
|
-
action: action$
|
|
1463
|
-
command: command$
|
|
1476
|
+
action: action$5,
|
|
1477
|
+
command: command$2
|
|
1464
1478
|
};
|
|
1465
|
-
const action = async (ctx) => {
|
|
1479
|
+
const action$1 = async (ctx) => {
|
|
1466
1480
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1467
1481
|
const token = await getValidToken(ctx, promptLogin);
|
|
1468
1482
|
const { logger } = ctx;
|
|
@@ -1482,12 +1496,86 @@ const action = async (ctx) => {
|
|
|
1482
1496
|
spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
|
|
1483
1497
|
}
|
|
1484
1498
|
};
|
|
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));
|
|
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));
|
|
1487
1501
|
};
|
|
1488
1502
|
const listProjects = {
|
|
1489
1503
|
name: "list-projects",
|
|
1490
1504
|
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",
|
|
1491
1579
|
action,
|
|
1492
1580
|
command
|
|
1493
1581
|
};
|
|
@@ -1497,9 +1585,10 @@ const cli = {
|
|
|
1497
1585
|
login,
|
|
1498
1586
|
logout,
|
|
1499
1587
|
createProject,
|
|
1500
|
-
listProjects
|
|
1588
|
+
listProjects,
|
|
1589
|
+
listEnvironments
|
|
1501
1590
|
};
|
|
1502
|
-
const cloudCommands = [deployProject, link, login, logout, listProjects];
|
|
1591
|
+
const cloudCommands = [deployProject, link, login, logout, listProjects, listEnvironments];
|
|
1503
1592
|
async function initCloudCLIConfig() {
|
|
1504
1593
|
const localConfig = await getLocalConfig();
|
|
1505
1594
|
if (!localConfig.deviceId) {
|