@strapi/cloud-cli 5.2.0 → 5.3.0
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 +59 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -11
- package/dist/index.mjs.map +1 -1
- package/dist/src/cloud/command.d.ts +1 -1
- package/dist/src/cloud/command.d.ts.map +1 -1
- package/dist/src/deploy-project/action.d.ts +4 -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 +1 -1
- package/dist/src/environment/command.d.ts.map +1 -1
- package/dist/src/environment/list/command.d.ts.map +1 -1
- package/dist/src/services/cli-api.d.ts +3 -0
- package/dist/src/services/cli-api.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
25
|
const crypto$1 = require("crypto");
|
|
26
26
|
const fse = require("fs-extra");
|
|
27
|
+
const inquirer = require("inquirer");
|
|
27
28
|
const path = require("path");
|
|
28
29
|
const chalk = require("chalk");
|
|
29
30
|
const axios = require("axios");
|
|
@@ -31,7 +32,6 @@ const crypto = require("node:crypto");
|
|
|
31
32
|
const utils = require("@strapi/utils");
|
|
32
33
|
const tar = require("tar");
|
|
33
34
|
const minimatch = require("minimatch");
|
|
34
|
-
const inquirer = require("inquirer");
|
|
35
35
|
const fp = require("lodash/fp");
|
|
36
36
|
const os = require("os");
|
|
37
37
|
const XDGAppPaths = require("xdg-app-paths");
|
|
@@ -65,12 +65,12 @@ function _interopNamespace(e) {
|
|
|
65
65
|
}
|
|
66
66
|
const crypto__default = /* @__PURE__ */ _interopDefault(crypto$1);
|
|
67
67
|
const fse__namespace = /* @__PURE__ */ _interopNamespace(fse);
|
|
68
|
+
const inquirer__default = /* @__PURE__ */ _interopDefault(inquirer);
|
|
68
69
|
const path__namespace = /* @__PURE__ */ _interopNamespace(path);
|
|
69
70
|
const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
|
|
70
71
|
const axios__default = /* @__PURE__ */ _interopDefault(axios);
|
|
71
72
|
const crypto__namespace = /* @__PURE__ */ _interopNamespace(crypto);
|
|
72
73
|
const tar__namespace = /* @__PURE__ */ _interopNamespace(tar);
|
|
73
|
-
const inquirer__default = /* @__PURE__ */ _interopDefault(inquirer);
|
|
74
74
|
const os__default = /* @__PURE__ */ _interopDefault(os);
|
|
75
75
|
const XDGAppPaths__default = /* @__PURE__ */ _interopDefault(XDGAppPaths);
|
|
76
76
|
const jwksClient__default = /* @__PURE__ */ _interopDefault(jwksClient);
|
|
@@ -193,7 +193,7 @@ async function saveLocalConfig(data) {
|
|
|
193
193
|
await fse__namespace.default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
|
|
194
194
|
}
|
|
195
195
|
const name = "@strapi/cloud-cli";
|
|
196
|
-
const version = "5.
|
|
196
|
+
const version = "5.2.0";
|
|
197
197
|
const description = "Commands to interact with the Strapi Cloud";
|
|
198
198
|
const keywords = [
|
|
199
199
|
"strapi",
|
|
@@ -317,7 +317,7 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
317
317
|
deploy({ filePath, project }, { onUploadProgress }) {
|
|
318
318
|
return axiosCloudAPI.post(
|
|
319
319
|
`/deploy/${project.name}`,
|
|
320
|
-
{ file: fse__namespace.default.createReadStream(filePath) },
|
|
320
|
+
{ file: fse__namespace.default.createReadStream(filePath), targetEnvironment: project.targetEnvironment },
|
|
321
321
|
{
|
|
322
322
|
headers: {
|
|
323
323
|
"Content-Type": "multipart/form-data"
|
|
@@ -1103,6 +1103,32 @@ const buildLogsServiceFactory = ({ logger }) => {
|
|
|
1103
1103
|
});
|
|
1104
1104
|
};
|
|
1105
1105
|
};
|
|
1106
|
+
const QUIT_OPTION$1 = "Quit";
|
|
1107
|
+
async function promptForEnvironment(environments) {
|
|
1108
|
+
const choices = environments.map((env) => ({ name: env, value: env }));
|
|
1109
|
+
const { selectedEnvironment } = await inquirer__default.default.prompt([
|
|
1110
|
+
{
|
|
1111
|
+
type: "list",
|
|
1112
|
+
name: "selectedEnvironment",
|
|
1113
|
+
message: "Select the environment to deploy:",
|
|
1114
|
+
choices: [...choices, { name: chalk__default.default.grey(`(${QUIT_OPTION$1})`), value: null }]
|
|
1115
|
+
}
|
|
1116
|
+
]);
|
|
1117
|
+
if (selectedEnvironment === null) {
|
|
1118
|
+
process.exit(1);
|
|
1119
|
+
}
|
|
1120
|
+
const { confirm } = await inquirer__default.default.prompt([
|
|
1121
|
+
{
|
|
1122
|
+
type: "confirm",
|
|
1123
|
+
name: "confirm",
|
|
1124
|
+
message: `Do you want to proceed with deployment to ${chalk__default.default.cyan(selectedEnvironment)}?`
|
|
1125
|
+
}
|
|
1126
|
+
]);
|
|
1127
|
+
if (!confirm) {
|
|
1128
|
+
process.exit(1);
|
|
1129
|
+
}
|
|
1130
|
+
return selectedEnvironment;
|
|
1131
|
+
}
|
|
1106
1132
|
async function upload(ctx, project, token, maxProjectFileSize) {
|
|
1107
1133
|
const cloudApi = await cloudApiFactory(ctx, token);
|
|
1108
1134
|
try {
|
|
@@ -1206,7 +1232,7 @@ async function getConfig({
|
|
|
1206
1232
|
return null;
|
|
1207
1233
|
}
|
|
1208
1234
|
}
|
|
1209
|
-
const action$4 = async (ctx) => {
|
|
1235
|
+
const action$4 = async (ctx, opts) => {
|
|
1210
1236
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1211
1237
|
const token = await getValidToken(ctx, promptLogin);
|
|
1212
1238
|
if (!token) {
|
|
@@ -1217,11 +1243,13 @@ const action$4 = async (ctx) => {
|
|
|
1217
1243
|
return;
|
|
1218
1244
|
}
|
|
1219
1245
|
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1246
|
+
let environments;
|
|
1220
1247
|
try {
|
|
1221
1248
|
const {
|
|
1222
1249
|
data: { data: projectData, metadata }
|
|
1223
1250
|
} = await cloudApiService.getProject({ name: project.name });
|
|
1224
1251
|
const isProjectSuspended = projectData.suspendedAt;
|
|
1252
|
+
environments = projectData.environments;
|
|
1225
1253
|
if (isProjectSuspended) {
|
|
1226
1254
|
ctx.logger.log(
|
|
1227
1255
|
"\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
|
|
@@ -1268,6 +1296,17 @@ Please link your local project to an existing Strapi Cloud project using the ${c
|
|
|
1268
1296
|
);
|
|
1269
1297
|
maxSize = 1e8;
|
|
1270
1298
|
}
|
|
1299
|
+
let targetEnvironment;
|
|
1300
|
+
if (opts.environment) {
|
|
1301
|
+
if (!environments.includes(opts.environment)) {
|
|
1302
|
+
ctx.logger.error(`Environment ${opts.environment} does not exist.`);
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
targetEnvironment = opts.environment;
|
|
1306
|
+
} else {
|
|
1307
|
+
targetEnvironment = environments.length > 1 ? await promptForEnvironment(environments) : environments[0];
|
|
1308
|
+
}
|
|
1309
|
+
project.targetEnvironment = targetEnvironment;
|
|
1271
1310
|
const buildId = await upload(ctx, project, token, maxSize);
|
|
1272
1311
|
if (!buildId) {
|
|
1273
1312
|
return;
|
|
@@ -1318,7 +1357,7 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1318
1357
|
});
|
|
1319
1358
|
};
|
|
1320
1359
|
const command$6 = ({ ctx }) => {
|
|
1321
|
-
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$4)(ctx));
|
|
1360
|
+
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").option("-e, --environment <name>", "Specify the environment to deploy").action((opts) => runAction("deploy", action$4)(ctx, opts));
|
|
1322
1361
|
};
|
|
1323
1362
|
const deployProject = {
|
|
1324
1363
|
name: "deploy-project",
|
|
@@ -1623,14 +1662,22 @@ Please link your local project to an existing Strapi Cloud project using the ${c
|
|
|
1623
1662
|
});
|
|
1624
1663
|
}
|
|
1625
1664
|
};
|
|
1626
|
-
function defineCloudNamespace(command2) {
|
|
1627
|
-
|
|
1665
|
+
function defineCloudNamespace(command2, ctx) {
|
|
1666
|
+
const cloud = command2.command("cloud").description("Manage Strapi Cloud projects");
|
|
1667
|
+
cloud.command("environments").description("Alias for cloud environment list").action(() => runAction("list", action)(ctx));
|
|
1668
|
+
return cloud;
|
|
1628
1669
|
}
|
|
1670
|
+
let environmentCmd = null;
|
|
1671
|
+
const initializeEnvironmentCommand = (command2, ctx) => {
|
|
1672
|
+
if (!environmentCmd) {
|
|
1673
|
+
const cloud = defineCloudNamespace(command2, ctx);
|
|
1674
|
+
environmentCmd = cloud.command("environment").description("Manage environments");
|
|
1675
|
+
}
|
|
1676
|
+
return environmentCmd;
|
|
1677
|
+
};
|
|
1629
1678
|
const command = ({ command: command2, ctx }) => {
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
const environment = cloud.command("environment").description("Manage environments for a Strapi Cloud project");
|
|
1633
|
-
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));
|
|
1679
|
+
const environmentCmd2 = initializeEnvironmentCommand(command2, ctx);
|
|
1680
|
+
environmentCmd2.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));
|
|
1634
1681
|
};
|
|
1635
1682
|
const listEnvironments = {
|
|
1636
1683
|
name: "list-environments",
|