@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 +87 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -44
- package/dist/index.mjs.map +1 -1
- 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/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 +16 -0
- package/dist/src/services/cli-api.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -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 +7 -7
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.0";
|
|
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",
|
|
@@ -203,8 +204,8 @@ 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
211
|
node: ">=18.0.0 <=20.x.x",
|
|
@@ -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,20 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
328
329
|
throw error;
|
|
329
330
|
}
|
|
330
331
|
},
|
|
332
|
+
async getProject({ name: name2 }) {
|
|
333
|
+
try {
|
|
334
|
+
const response = await axiosCloudAPI.get(`/projects/${name2}`);
|
|
335
|
+
if (response.status !== 200) {
|
|
336
|
+
throw new Error("Error fetching project's details.");
|
|
337
|
+
}
|
|
338
|
+
return response;
|
|
339
|
+
} catch (error) {
|
|
340
|
+
logger.debug(
|
|
341
|
+
"🥲 Oops! There was a problem retrieving your project's details. Please try again."
|
|
342
|
+
);
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
},
|
|
331
346
|
track(event, payload = {}) {
|
|
332
347
|
return axiosCloudAPI.post("/track", {
|
|
333
348
|
event,
|
|
@@ -601,21 +616,24 @@ yup.object({
|
|
|
601
616
|
name: yup.string().required(),
|
|
602
617
|
exports: yup.lazy(
|
|
603
618
|
(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
|
-
|
|
619
|
+
typeof value === "object" ? Object.entries(value).reduce(
|
|
620
|
+
(acc, [key, value2]) => {
|
|
621
|
+
if (typeof value2 === "object") {
|
|
622
|
+
acc[key] = yup.object({
|
|
623
|
+
types: yup.string().optional(),
|
|
624
|
+
source: yup.string().required(),
|
|
625
|
+
module: yup.string().optional(),
|
|
626
|
+
import: yup.string().required(),
|
|
627
|
+
require: yup.string().required(),
|
|
628
|
+
default: yup.string().required()
|
|
629
|
+
}).noUnknown(true);
|
|
630
|
+
} else {
|
|
631
|
+
acc[key] = yup.string().matches(/^\.\/.*\.json$/).required();
|
|
632
|
+
}
|
|
633
|
+
return acc;
|
|
634
|
+
},
|
|
635
|
+
{}
|
|
636
|
+
) : void 0
|
|
619
637
|
).optional()
|
|
620
638
|
)
|
|
621
639
|
});
|
|
@@ -1078,17 +1096,7 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1078
1096
|
return data.build_id;
|
|
1079
1097
|
} catch (e) {
|
|
1080
1098
|
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
|
-
}
|
|
1099
|
+
ctx.logger.error("An error occurred while deploying the project. Please try again later.");
|
|
1092
1100
|
ctx.logger.debug(e);
|
|
1093
1101
|
} finally {
|
|
1094
1102
|
await fse__default.remove(tarFilePath);
|
|
@@ -1135,7 +1143,39 @@ const action$3 = async (ctx) => {
|
|
|
1135
1143
|
if (!project) {
|
|
1136
1144
|
return;
|
|
1137
1145
|
}
|
|
1138
|
-
const cloudApiService = await cloudApiFactory(ctx);
|
|
1146
|
+
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1147
|
+
try {
|
|
1148
|
+
const {
|
|
1149
|
+
data: { data: projectData, metadata }
|
|
1150
|
+
} = await cloudApiService.getProject({ name: project.name });
|
|
1151
|
+
const isProjectSuspended = projectData.suspendedAt;
|
|
1152
|
+
if (isProjectSuspended) {
|
|
1153
|
+
ctx.logger.log(
|
|
1154
|
+
"\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
|
|
1155
|
+
);
|
|
1156
|
+
ctx.logger.log(chalk.underline(`${metadata.dashboardUrls.project}`));
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
} catch (e) {
|
|
1160
|
+
if (e instanceof AxiosError && e.response?.data) {
|
|
1161
|
+
if (e.response.status === 404) {
|
|
1162
|
+
ctx.logger.warn(
|
|
1163
|
+
`The project associated with this folder does not exist in Strapi Cloud.
|
|
1164
|
+
Please link your local project to an existing Strapi Cloud project using the ${chalk.cyan(
|
|
1165
|
+
"link"
|
|
1166
|
+
)} command before deploying.`
|
|
1167
|
+
);
|
|
1168
|
+
} else {
|
|
1169
|
+
ctx.logger.error(e.response.data);
|
|
1170
|
+
}
|
|
1171
|
+
} else {
|
|
1172
|
+
ctx.logger.error(
|
|
1173
|
+
"An error occurred while retrieving the project's information. Please try again later."
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
ctx.logger.debug(e);
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1139
1179
|
await trackEvent(ctx, cloudApiService, "willDeployWithCLI", {
|
|
1140
1180
|
projectInternalName: project.name
|
|
1141
1181
|
});
|
|
@@ -1144,7 +1184,7 @@ const action$3 = async (ctx) => {
|
|
|
1144
1184
|
const cliConfig2 = await getConfig({ ctx, cloudApiService });
|
|
1145
1185
|
if (!cliConfig2) {
|
|
1146
1186
|
ctx.logger.error(
|
|
1147
|
-
"An error occurred while retrieving data from Strapi Cloud. Please
|
|
1187
|
+
"An error occurred while retrieving data from Strapi Cloud. Please check your network or try again later."
|
|
1148
1188
|
);
|
|
1149
1189
|
return;
|
|
1150
1190
|
}
|
|
@@ -1204,8 +1244,8 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1204
1244
|
process.exit(1);
|
|
1205
1245
|
});
|
|
1206
1246
|
};
|
|
1207
|
-
const command$5 = ({
|
|
1208
|
-
|
|
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));
|
|
1209
1249
|
};
|
|
1210
1250
|
const deployProject = {
|
|
1211
1251
|
name: "deploy-project",
|
|
@@ -1359,8 +1399,8 @@ const link = {
|
|
|
1359
1399
|
action: action$2,
|
|
1360
1400
|
command: command$4
|
|
1361
1401
|
};
|
|
1362
|
-
const command$3 = ({
|
|
1363
|
-
|
|
1402
|
+
const command$3 = ({ ctx }) => {
|
|
1403
|
+
return createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
|
|
1364
1404
|
"after",
|
|
1365
1405
|
"\nAfter running this command, you will be prompted to enter your authentication information."
|
|
1366
1406
|
).option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("login", loginAction)(ctx));
|
|
@@ -1404,8 +1444,8 @@ const action$1 = async (ctx) => {
|
|
|
1404
1444
|
}
|
|
1405
1445
|
await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
|
|
1406
1446
|
};
|
|
1407
|
-
const command$2 = ({
|
|
1408
|
-
|
|
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));
|
|
1409
1449
|
};
|
|
1410
1450
|
const logout = {
|
|
1411
1451
|
name: "logout",
|
|
@@ -1413,8 +1453,8 @@ const logout = {
|
|
|
1413
1453
|
action: action$1,
|
|
1414
1454
|
command: command$2
|
|
1415
1455
|
};
|
|
1416
|
-
const command$1 = ({
|
|
1417
|
-
|
|
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));
|
|
1418
1458
|
};
|
|
1419
1459
|
const createProject = {
|
|
1420
1460
|
name: "create-project",
|
|
@@ -1475,7 +1515,10 @@ async function buildStrapiCloudCommands({
|
|
|
1475
1515
|
await initCloudCLIConfig();
|
|
1476
1516
|
for (const cloudCommand of cloudCommands) {
|
|
1477
1517
|
try {
|
|
1478
|
-
await cloudCommand.command({ command: command2, ctx, argv });
|
|
1518
|
+
const subCommand = await cloudCommand.command({ command: command2, ctx, argv });
|
|
1519
|
+
if (subCommand) {
|
|
1520
|
+
command2.addCommand(subCommand);
|
|
1521
|
+
}
|
|
1479
1522
|
} catch (e) {
|
|
1480
1523
|
console.error(`Failed to load command ${cloudCommand.name}`, e);
|
|
1481
1524
|
}
|