@strapi/cloud-cli 0.0.0-next.d7fa025a4eacdc27490fb1629b0efb93e3cb58b9 → 0.0.0-next.ee56af7ae29770097422de95c0d5500908dce15c
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 +201 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -69
- 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/create-project/command.d.ts.map +1 -1
- package/dist/src/deploy-project/action.d.ts.map +1 -1
- package/dist/src/deploy-project/command.d.ts.map +1 -1
- 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/login/command.d.ts.map +1 -1
- package/dist/src/logout/command.d.ts.map +1 -1
- package/dist/src/services/cli-api.d.ts +25 -0
- package/dist/src/services/cli-api.d.ts.map +1 -1
- package/dist/src/types.d.ts +4 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/pkg.d.ts.map +1 -1
- package/dist/src/utils/tests/compress-files.test.d.ts +2 -0
- package/dist/src/utils/tests/compress-files.test.d.ts.map +1 -0
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import * as cliProgress from "cli-progress";
|
|
|
21
21
|
import pkgUp from "pkg-up";
|
|
22
22
|
import * as yup from "yup";
|
|
23
23
|
import EventSource from "eventsource";
|
|
24
|
+
import { createCommand } from "commander";
|
|
24
25
|
const apiConfig = {
|
|
25
26
|
apiBaseUrl: env("STRAPI_CLI_CLOUD_API", "https://cloud-cli-api.strapi.io"),
|
|
26
27
|
dashboardBaseUrl: env("STRAPI_CLI_CLOUD_DASHBOARD", "https://cloud.strapi.io")
|
|
@@ -133,7 +134,7 @@ async function saveLocalConfig(data) {
|
|
|
133
134
|
await fse__default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
|
|
134
135
|
}
|
|
135
136
|
const name = "@strapi/cloud-cli";
|
|
136
|
-
const version = "
|
|
137
|
+
const version = "5.0.6";
|
|
137
138
|
const description = "Commands to interact with the Strapi Cloud";
|
|
138
139
|
const keywords = [
|
|
139
140
|
"strapi",
|
|
@@ -178,14 +179,14 @@ const scripts = {
|
|
|
178
179
|
watch: "pack-up watch"
|
|
179
180
|
};
|
|
180
181
|
const dependencies = {
|
|
181
|
-
"@strapi/utils": "
|
|
182
|
-
axios: "1.
|
|
182
|
+
"@strapi/utils": "workspace:*",
|
|
183
|
+
axios: "1.7.4",
|
|
183
184
|
chalk: "4.1.2",
|
|
184
185
|
"cli-progress": "3.12.0",
|
|
185
186
|
commander: "8.3.0",
|
|
186
187
|
eventsource: "2.0.2",
|
|
187
188
|
"fast-safe-stringify": "2.1.1",
|
|
188
|
-
"fs-extra": "
|
|
189
|
+
"fs-extra": "11.2.0",
|
|
189
190
|
inquirer: "8.2.5",
|
|
190
191
|
jsonwebtoken: "9.0.0",
|
|
191
192
|
"jwks-rsa": "3.1.0",
|
|
@@ -194,7 +195,7 @@ const dependencies = {
|
|
|
194
195
|
open: "8.4.0",
|
|
195
196
|
ora: "5.4.1",
|
|
196
197
|
"pkg-up": "3.1.0",
|
|
197
|
-
tar: "6.1
|
|
198
|
+
tar: "6.2.1",
|
|
198
199
|
"xdg-app-paths": "8.3.0",
|
|
199
200
|
yup: "0.32.9"
|
|
200
201
|
};
|
|
@@ -203,11 +204,11 @@ const devDependencies = {
|
|
|
203
204
|
"@types/cli-progress": "3.11.5",
|
|
204
205
|
"@types/eventsource": "1.1.15",
|
|
205
206
|
"@types/lodash": "^4.14.191",
|
|
206
|
-
"eslint-config-custom": "
|
|
207
|
-
tsconfig: "
|
|
207
|
+
"eslint-config-custom": "workspace:*",
|
|
208
|
+
tsconfig: "workspace:*"
|
|
208
209
|
};
|
|
209
210
|
const engines = {
|
|
210
|
-
node: ">=18.0.0 <=
|
|
211
|
+
node: ">=18.0.0 <=22.x.x",
|
|
211
212
|
npm: ">=6.0.0"
|
|
212
213
|
};
|
|
213
214
|
const packageJson = {
|
|
@@ -316,7 +317,7 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
316
317
|
},
|
|
317
318
|
async listLinkProjects() {
|
|
318
319
|
try {
|
|
319
|
-
const response = await axiosCloudAPI.get("/projects
|
|
320
|
+
const response = await axiosCloudAPI.get("/projects-linkable");
|
|
320
321
|
if (response.status !== 200) {
|
|
321
322
|
throw new Error("Error fetching cloud projects from the server.");
|
|
322
323
|
}
|
|
@@ -328,6 +329,34 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
328
329
|
throw error;
|
|
329
330
|
}
|
|
330
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
|
+
async getProject({ name: name2 }) {
|
|
347
|
+
try {
|
|
348
|
+
const response = await axiosCloudAPI.get(`/projects/${name2}`);
|
|
349
|
+
if (response.status !== 200) {
|
|
350
|
+
throw new Error("Error fetching project's details.");
|
|
351
|
+
}
|
|
352
|
+
return response;
|
|
353
|
+
} catch (error) {
|
|
354
|
+
logger.debug(
|
|
355
|
+
"🥲 Oops! There was a problem retrieving your project's details. Please try again."
|
|
356
|
+
);
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
359
|
+
},
|
|
331
360
|
track(event, payload = {}) {
|
|
332
361
|
return axiosCloudAPI.post("/track", {
|
|
333
362
|
event,
|
|
@@ -601,21 +630,24 @@ yup.object({
|
|
|
601
630
|
name: yup.string().required(),
|
|
602
631
|
exports: yup.lazy(
|
|
603
632
|
(value) => yup.object(
|
|
604
|
-
typeof value === "object" ? Object.entries(value).reduce(
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
633
|
+
typeof value === "object" ? Object.entries(value).reduce(
|
|
634
|
+
(acc, [key, value2]) => {
|
|
635
|
+
if (typeof value2 === "object") {
|
|
636
|
+
acc[key] = yup.object({
|
|
637
|
+
types: yup.string().optional(),
|
|
638
|
+
source: yup.string().required(),
|
|
639
|
+
module: yup.string().optional(),
|
|
640
|
+
import: yup.string().required(),
|
|
641
|
+
require: yup.string().required(),
|
|
642
|
+
default: yup.string().required()
|
|
643
|
+
}).noUnknown(true);
|
|
644
|
+
} else {
|
|
645
|
+
acc[key] = yup.string().matches(/^\.\/.*\.json$/).required();
|
|
646
|
+
}
|
|
647
|
+
return acc;
|
|
648
|
+
},
|
|
649
|
+
{}
|
|
650
|
+
) : void 0
|
|
619
651
|
).optional()
|
|
620
652
|
)
|
|
621
653
|
});
|
|
@@ -883,7 +915,7 @@ async function createProject$1(ctx, cloudApi, projectInput) {
|
|
|
883
915
|
throw e;
|
|
884
916
|
}
|
|
885
917
|
}
|
|
886
|
-
const action$
|
|
918
|
+
const action$5 = async (ctx) => {
|
|
887
919
|
const { logger } = ctx;
|
|
888
920
|
const { getValidToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
889
921
|
const token = await getValidToken(ctx, promptLogin);
|
|
@@ -1078,17 +1110,7 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1078
1110
|
return data.build_id;
|
|
1079
1111
|
} catch (e) {
|
|
1080
1112
|
progressBar.stop();
|
|
1081
|
-
|
|
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
|
-
}
|
|
1113
|
+
ctx.logger.error("An error occurred while deploying the project. Please try again later.");
|
|
1092
1114
|
ctx.logger.debug(e);
|
|
1093
1115
|
} finally {
|
|
1094
1116
|
await fse__default.remove(tarFilePath);
|
|
@@ -1100,11 +1122,11 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1100
1122
|
process.exit(1);
|
|
1101
1123
|
}
|
|
1102
1124
|
}
|
|
1103
|
-
async function getProject(ctx) {
|
|
1125
|
+
async function getProject$1(ctx) {
|
|
1104
1126
|
const { project } = await retrieve();
|
|
1105
1127
|
if (!project) {
|
|
1106
1128
|
try {
|
|
1107
|
-
return await action$
|
|
1129
|
+
return await action$5(ctx);
|
|
1108
1130
|
} catch (e) {
|
|
1109
1131
|
ctx.logger.error("An error occurred while deploying the project. Please try again later.");
|
|
1110
1132
|
ctx.logger.debug(e);
|
|
@@ -1125,17 +1147,49 @@ async function getConfig({
|
|
|
1125
1147
|
return null;
|
|
1126
1148
|
}
|
|
1127
1149
|
}
|
|
1128
|
-
const action$
|
|
1150
|
+
const action$4 = async (ctx) => {
|
|
1129
1151
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1130
1152
|
const token = await getValidToken(ctx, promptLogin);
|
|
1131
1153
|
if (!token) {
|
|
1132
1154
|
return;
|
|
1133
1155
|
}
|
|
1134
|
-
const project = await getProject(ctx);
|
|
1156
|
+
const project = await getProject$1(ctx);
|
|
1135
1157
|
if (!project) {
|
|
1136
1158
|
return;
|
|
1137
1159
|
}
|
|
1138
|
-
const cloudApiService = await cloudApiFactory(ctx);
|
|
1160
|
+
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1161
|
+
try {
|
|
1162
|
+
const {
|
|
1163
|
+
data: { data: projectData, metadata }
|
|
1164
|
+
} = await cloudApiService.getProject({ name: project.name });
|
|
1165
|
+
const isProjectSuspended = projectData.suspendedAt;
|
|
1166
|
+
if (isProjectSuspended) {
|
|
1167
|
+
ctx.logger.log(
|
|
1168
|
+
"\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
|
|
1169
|
+
);
|
|
1170
|
+
ctx.logger.log(chalk.underline(`${metadata.dashboardUrls.project}`));
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
} catch (e) {
|
|
1174
|
+
if (e instanceof AxiosError && e.response?.data) {
|
|
1175
|
+
if (e.response.status === 404) {
|
|
1176
|
+
ctx.logger.warn(
|
|
1177
|
+
`The project associated with this folder does not exist in Strapi Cloud.
|
|
1178
|
+
Please link your local project to an existing Strapi Cloud project using the ${chalk.cyan(
|
|
1179
|
+
"link"
|
|
1180
|
+
)} command before deploying.`
|
|
1181
|
+
);
|
|
1182
|
+
} else {
|
|
1183
|
+
ctx.logger.error(e.response.data);
|
|
1184
|
+
}
|
|
1185
|
+
} else {
|
|
1186
|
+
ctx.logger.error(
|
|
1187
|
+
"An error occurred while retrieving the project's information. Please try again later."
|
|
1188
|
+
);
|
|
1189
|
+
}
|
|
1190
|
+
ctx.logger.debug(e);
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1139
1193
|
await trackEvent(ctx, cloudApiService, "willDeployWithCLI", {
|
|
1140
1194
|
projectInternalName: project.name
|
|
1141
1195
|
});
|
|
@@ -1144,7 +1198,7 @@ const action$3 = async (ctx) => {
|
|
|
1144
1198
|
const cliConfig2 = await getConfig({ ctx, cloudApiService });
|
|
1145
1199
|
if (!cliConfig2) {
|
|
1146
1200
|
ctx.logger.error(
|
|
1147
|
-
"An error occurred while retrieving data from Strapi Cloud. Please
|
|
1201
|
+
"An error occurred while retrieving data from Strapi Cloud. Please check your network or try again later."
|
|
1148
1202
|
);
|
|
1149
1203
|
return;
|
|
1150
1204
|
}
|
|
@@ -1204,14 +1258,14 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1204
1258
|
process.exit(1);
|
|
1205
1259
|
});
|
|
1206
1260
|
};
|
|
1207
|
-
const command$
|
|
1208
|
-
|
|
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));
|
|
1209
1263
|
};
|
|
1210
1264
|
const deployProject = {
|
|
1211
1265
|
name: "deploy-project",
|
|
1212
1266
|
description: "Deploy a Strapi Cloud project",
|
|
1213
|
-
action: action$
|
|
1214
|
-
command: command$
|
|
1267
|
+
action: action$4,
|
|
1268
|
+
command: command$6
|
|
1215
1269
|
};
|
|
1216
1270
|
const QUIT_OPTION = "Quit";
|
|
1217
1271
|
async function getExistingConfig(ctx) {
|
|
@@ -1295,7 +1349,7 @@ async function getUserSelection(ctx, projects) {
|
|
|
1295
1349
|
return null;
|
|
1296
1350
|
}
|
|
1297
1351
|
}
|
|
1298
|
-
const action$
|
|
1352
|
+
const action$3 = async (ctx) => {
|
|
1299
1353
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1300
1354
|
const token = await getValidToken(ctx, promptLogin);
|
|
1301
1355
|
const { logger } = ctx;
|
|
@@ -1350,17 +1404,17 @@ const action$2 = async (ctx) => {
|
|
|
1350
1404
|
});
|
|
1351
1405
|
}
|
|
1352
1406
|
};
|
|
1353
|
-
const command$
|
|
1354
|
-
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));
|
|
1355
1409
|
};
|
|
1356
1410
|
const link = {
|
|
1357
1411
|
name: "link-project",
|
|
1358
1412
|
description: "Link a local directory to a Strapi Cloud project",
|
|
1359
|
-
action: action$
|
|
1360
|
-
command: command$
|
|
1413
|
+
action: action$3,
|
|
1414
|
+
command: command$5
|
|
1361
1415
|
};
|
|
1362
|
-
const command$
|
|
1363
|
-
|
|
1416
|
+
const command$4 = ({ ctx }) => {
|
|
1417
|
+
return createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
|
|
1364
1418
|
"after",
|
|
1365
1419
|
"\nAfter running this command, you will be prompted to enter your authentication information."
|
|
1366
1420
|
).option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("login", loginAction)(ctx));
|
|
@@ -1369,10 +1423,10 @@ const login = {
|
|
|
1369
1423
|
name: "login",
|
|
1370
1424
|
description: "Strapi Cloud Login",
|
|
1371
1425
|
action: loginAction,
|
|
1372
|
-
command: command$
|
|
1426
|
+
command: command$4
|
|
1373
1427
|
};
|
|
1374
1428
|
const openModule = import("open");
|
|
1375
|
-
const action$
|
|
1429
|
+
const action$2 = async (ctx) => {
|
|
1376
1430
|
const { logger } = ctx;
|
|
1377
1431
|
const { retrieveToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
1378
1432
|
const token = await retrieveToken();
|
|
@@ -1404,25 +1458,25 @@ const action$1 = async (ctx) => {
|
|
|
1404
1458
|
}
|
|
1405
1459
|
await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
|
|
1406
1460
|
};
|
|
1407
|
-
const command$
|
|
1408
|
-
|
|
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));
|
|
1409
1463
|
};
|
|
1410
1464
|
const logout = {
|
|
1411
1465
|
name: "logout",
|
|
1412
1466
|
description: "Strapi Cloud Logout",
|
|
1413
|
-
action: action$
|
|
1414
|
-
command: command$
|
|
1467
|
+
action: action$2,
|
|
1468
|
+
command: command$3
|
|
1415
1469
|
};
|
|
1416
|
-
const command$
|
|
1417
|
-
|
|
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));
|
|
1418
1472
|
};
|
|
1419
1473
|
const createProject = {
|
|
1420
1474
|
name: "create-project",
|
|
1421
1475
|
description: "Create a new project",
|
|
1422
|
-
action: action$
|
|
1423
|
-
command: command$
|
|
1476
|
+
action: action$5,
|
|
1477
|
+
command: command$2
|
|
1424
1478
|
};
|
|
1425
|
-
const action = async (ctx) => {
|
|
1479
|
+
const action$1 = async (ctx) => {
|
|
1426
1480
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1427
1481
|
const token = await getValidToken(ctx, promptLogin);
|
|
1428
1482
|
const { logger } = ctx;
|
|
@@ -1442,12 +1496,86 @@ const action = async (ctx) => {
|
|
|
1442
1496
|
spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
|
|
1443
1497
|
}
|
|
1444
1498
|
};
|
|
1445
|
-
const command = ({ command: command2, ctx }) => {
|
|
1446
|
-
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));
|
|
1447
1501
|
};
|
|
1448
1502
|
const listProjects = {
|
|
1449
1503
|
name: "list-projects",
|
|
1450
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",
|
|
1451
1579
|
action,
|
|
1452
1580
|
command
|
|
1453
1581
|
};
|
|
@@ -1457,9 +1585,10 @@ const cli = {
|
|
|
1457
1585
|
login,
|
|
1458
1586
|
logout,
|
|
1459
1587
|
createProject,
|
|
1460
|
-
listProjects
|
|
1588
|
+
listProjects,
|
|
1589
|
+
listEnvironments
|
|
1461
1590
|
};
|
|
1462
|
-
const cloudCommands = [deployProject, link, login, logout, listProjects];
|
|
1591
|
+
const cloudCommands = [deployProject, link, login, logout, listProjects, listEnvironments];
|
|
1463
1592
|
async function initCloudCLIConfig() {
|
|
1464
1593
|
const localConfig = await getLocalConfig();
|
|
1465
1594
|
if (!localConfig.deviceId) {
|
|
@@ -1475,7 +1604,10 @@ async function buildStrapiCloudCommands({
|
|
|
1475
1604
|
await initCloudCLIConfig();
|
|
1476
1605
|
for (const cloudCommand of cloudCommands) {
|
|
1477
1606
|
try {
|
|
1478
|
-
await cloudCommand.command({ command: command2, ctx, argv });
|
|
1607
|
+
const subCommand = await cloudCommand.command({ command: command2, ctx, argv });
|
|
1608
|
+
if (subCommand) {
|
|
1609
|
+
command2.addCommand(subCommand);
|
|
1610
|
+
}
|
|
1479
1611
|
} catch (e) {
|
|
1480
1612
|
console.error(`Failed to load command ${cloudCommand.name}`, e);
|
|
1481
1613
|
}
|