@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.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto$1 from "crypto";
|
|
2
2
|
import * as fse from "fs-extra";
|
|
3
3
|
import fse__default from "fs-extra";
|
|
4
|
+
import inquirer from "inquirer";
|
|
4
5
|
import * as path from "path";
|
|
5
6
|
import path__default from "path";
|
|
6
7
|
import chalk from "chalk";
|
|
@@ -9,7 +10,6 @@ import * as crypto from "node:crypto";
|
|
|
9
10
|
import { env } from "@strapi/utils";
|
|
10
11
|
import * as tar from "tar";
|
|
11
12
|
import { minimatch } from "minimatch";
|
|
12
|
-
import inquirer from "inquirer";
|
|
13
13
|
import { defaults, has } from "lodash/fp";
|
|
14
14
|
import os from "os";
|
|
15
15
|
import XDGAppPaths from "xdg-app-paths";
|
|
@@ -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.2.0";
|
|
138
138
|
const description = "Commands to interact with the Strapi Cloud";
|
|
139
139
|
const keywords = [
|
|
140
140
|
"strapi",
|
|
@@ -258,7 +258,7 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
258
258
|
deploy({ filePath, project }, { onUploadProgress }) {
|
|
259
259
|
return axiosCloudAPI.post(
|
|
260
260
|
`/deploy/${project.name}`,
|
|
261
|
-
{ file: fse__default.createReadStream(filePath) },
|
|
261
|
+
{ file: fse__default.createReadStream(filePath), targetEnvironment: project.targetEnvironment },
|
|
262
262
|
{
|
|
263
263
|
headers: {
|
|
264
264
|
"Content-Type": "multipart/form-data"
|
|
@@ -1044,6 +1044,32 @@ const buildLogsServiceFactory = ({ logger }) => {
|
|
|
1044
1044
|
});
|
|
1045
1045
|
};
|
|
1046
1046
|
};
|
|
1047
|
+
const QUIT_OPTION$1 = "Quit";
|
|
1048
|
+
async function promptForEnvironment(environments) {
|
|
1049
|
+
const choices = environments.map((env2) => ({ name: env2, value: env2 }));
|
|
1050
|
+
const { selectedEnvironment } = await inquirer.prompt([
|
|
1051
|
+
{
|
|
1052
|
+
type: "list",
|
|
1053
|
+
name: "selectedEnvironment",
|
|
1054
|
+
message: "Select the environment to deploy:",
|
|
1055
|
+
choices: [...choices, { name: chalk.grey(`(${QUIT_OPTION$1})`), value: null }]
|
|
1056
|
+
}
|
|
1057
|
+
]);
|
|
1058
|
+
if (selectedEnvironment === null) {
|
|
1059
|
+
process.exit(1);
|
|
1060
|
+
}
|
|
1061
|
+
const { confirm } = await inquirer.prompt([
|
|
1062
|
+
{
|
|
1063
|
+
type: "confirm",
|
|
1064
|
+
name: "confirm",
|
|
1065
|
+
message: `Do you want to proceed with deployment to ${chalk.cyan(selectedEnvironment)}?`
|
|
1066
|
+
}
|
|
1067
|
+
]);
|
|
1068
|
+
if (!confirm) {
|
|
1069
|
+
process.exit(1);
|
|
1070
|
+
}
|
|
1071
|
+
return selectedEnvironment;
|
|
1072
|
+
}
|
|
1047
1073
|
async function upload(ctx, project, token, maxProjectFileSize) {
|
|
1048
1074
|
const cloudApi = await cloudApiFactory(ctx, token);
|
|
1049
1075
|
try {
|
|
@@ -1147,7 +1173,7 @@ async function getConfig({
|
|
|
1147
1173
|
return null;
|
|
1148
1174
|
}
|
|
1149
1175
|
}
|
|
1150
|
-
const action$4 = async (ctx) => {
|
|
1176
|
+
const action$4 = async (ctx, opts) => {
|
|
1151
1177
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1152
1178
|
const token = await getValidToken(ctx, promptLogin);
|
|
1153
1179
|
if (!token) {
|
|
@@ -1158,11 +1184,13 @@ const action$4 = async (ctx) => {
|
|
|
1158
1184
|
return;
|
|
1159
1185
|
}
|
|
1160
1186
|
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1187
|
+
let environments;
|
|
1161
1188
|
try {
|
|
1162
1189
|
const {
|
|
1163
1190
|
data: { data: projectData, metadata }
|
|
1164
1191
|
} = await cloudApiService.getProject({ name: project.name });
|
|
1165
1192
|
const isProjectSuspended = projectData.suspendedAt;
|
|
1193
|
+
environments = projectData.environments;
|
|
1166
1194
|
if (isProjectSuspended) {
|
|
1167
1195
|
ctx.logger.log(
|
|
1168
1196
|
"\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
|
|
@@ -1209,6 +1237,17 @@ Please link your local project to an existing Strapi Cloud project using the ${c
|
|
|
1209
1237
|
);
|
|
1210
1238
|
maxSize = 1e8;
|
|
1211
1239
|
}
|
|
1240
|
+
let targetEnvironment;
|
|
1241
|
+
if (opts.environment) {
|
|
1242
|
+
if (!environments.includes(opts.environment)) {
|
|
1243
|
+
ctx.logger.error(`Environment ${opts.environment} does not exist.`);
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
targetEnvironment = opts.environment;
|
|
1247
|
+
} else {
|
|
1248
|
+
targetEnvironment = environments.length > 1 ? await promptForEnvironment(environments) : environments[0];
|
|
1249
|
+
}
|
|
1250
|
+
project.targetEnvironment = targetEnvironment;
|
|
1212
1251
|
const buildId = await upload(ctx, project, token, maxSize);
|
|
1213
1252
|
if (!buildId) {
|
|
1214
1253
|
return;
|
|
@@ -1259,7 +1298,7 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1259
1298
|
});
|
|
1260
1299
|
};
|
|
1261
1300
|
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));
|
|
1301
|
+
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").option("-e, --environment <name>", "Specify the environment to deploy").action((opts) => runAction("deploy", action$4)(ctx, opts));
|
|
1263
1302
|
};
|
|
1264
1303
|
const deployProject = {
|
|
1265
1304
|
name: "deploy-project",
|
|
@@ -1564,14 +1603,22 @@ Please link your local project to an existing Strapi Cloud project using the ${c
|
|
|
1564
1603
|
});
|
|
1565
1604
|
}
|
|
1566
1605
|
};
|
|
1567
|
-
function defineCloudNamespace(command2) {
|
|
1568
|
-
|
|
1606
|
+
function defineCloudNamespace(command2, ctx) {
|
|
1607
|
+
const cloud = command2.command("cloud").description("Manage Strapi Cloud projects");
|
|
1608
|
+
cloud.command("environments").description("Alias for cloud environment list").action(() => runAction("list", action)(ctx));
|
|
1609
|
+
return cloud;
|
|
1569
1610
|
}
|
|
1611
|
+
let environmentCmd = null;
|
|
1612
|
+
const initializeEnvironmentCommand = (command2, ctx) => {
|
|
1613
|
+
if (!environmentCmd) {
|
|
1614
|
+
const cloud = defineCloudNamespace(command2, ctx);
|
|
1615
|
+
environmentCmd = cloud.command("environment").description("Manage environments");
|
|
1616
|
+
}
|
|
1617
|
+
return environmentCmd;
|
|
1618
|
+
};
|
|
1570
1619
|
const command = ({ command: command2, ctx }) => {
|
|
1571
|
-
const
|
|
1572
|
-
|
|
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));
|
|
1620
|
+
const environmentCmd2 = initializeEnvironmentCommand(command2, ctx);
|
|
1621
|
+
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));
|
|
1575
1622
|
};
|
|
1576
1623
|
const listEnvironments = {
|
|
1577
1624
|
name: "list-environments",
|