@strapi/cloud-cli 5.2.0 → 5.4.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 +65 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -15
- 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.4.0";
|
|
197
197
|
const description = "Commands to interact with the Strapi Cloud";
|
|
198
198
|
const keywords = [
|
|
199
199
|
"strapi",
|
|
@@ -238,7 +238,7 @@ const scripts = {
|
|
|
238
238
|
watch: "pack-up watch"
|
|
239
239
|
};
|
|
240
240
|
const dependencies = {
|
|
241
|
-
"@strapi/utils": "
|
|
241
|
+
"@strapi/utils": "5.4.0",
|
|
242
242
|
axios: "1.7.4",
|
|
243
243
|
chalk: "4.1.2",
|
|
244
244
|
"cli-progress": "3.12.0",
|
|
@@ -263,13 +263,14 @@ const devDependencies = {
|
|
|
263
263
|
"@types/cli-progress": "3.11.5",
|
|
264
264
|
"@types/eventsource": "1.1.15",
|
|
265
265
|
"@types/lodash": "^4.14.191",
|
|
266
|
-
"eslint-config-custom": "
|
|
267
|
-
tsconfig: "
|
|
266
|
+
"eslint-config-custom": "5.4.0",
|
|
267
|
+
tsconfig: "5.4.0"
|
|
268
268
|
};
|
|
269
269
|
const engines = {
|
|
270
270
|
node: ">=18.0.0 <=22.x.x",
|
|
271
271
|
npm: ">=6.0.0"
|
|
272
272
|
};
|
|
273
|
+
const gitHead = "7d785703f52464577d077c4618cbe68b44f8a9cd";
|
|
273
274
|
const packageJson = {
|
|
274
275
|
name,
|
|
275
276
|
version,
|
|
@@ -290,7 +291,8 @@ const packageJson = {
|
|
|
290
291
|
scripts,
|
|
291
292
|
dependencies,
|
|
292
293
|
devDependencies,
|
|
293
|
-
engines
|
|
294
|
+
engines,
|
|
295
|
+
gitHead
|
|
294
296
|
};
|
|
295
297
|
const VERSION = "v1";
|
|
296
298
|
async function cloudApiFactory({ logger }, token) {
|
|
@@ -317,7 +319,7 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
317
319
|
deploy({ filePath, project }, { onUploadProgress }) {
|
|
318
320
|
return axiosCloudAPI.post(
|
|
319
321
|
`/deploy/${project.name}`,
|
|
320
|
-
{ file: fse__namespace.default.createReadStream(filePath) },
|
|
322
|
+
{ file: fse__namespace.default.createReadStream(filePath), targetEnvironment: project.targetEnvironment },
|
|
321
323
|
{
|
|
322
324
|
headers: {
|
|
323
325
|
"Content-Type": "multipart/form-data"
|
|
@@ -1103,6 +1105,32 @@ const buildLogsServiceFactory = ({ logger }) => {
|
|
|
1103
1105
|
});
|
|
1104
1106
|
};
|
|
1105
1107
|
};
|
|
1108
|
+
const QUIT_OPTION$1 = "Quit";
|
|
1109
|
+
async function promptForEnvironment(environments) {
|
|
1110
|
+
const choices = environments.map((env) => ({ name: env, value: env }));
|
|
1111
|
+
const { selectedEnvironment } = await inquirer__default.default.prompt([
|
|
1112
|
+
{
|
|
1113
|
+
type: "list",
|
|
1114
|
+
name: "selectedEnvironment",
|
|
1115
|
+
message: "Select the environment to deploy:",
|
|
1116
|
+
choices: [...choices, { name: chalk__default.default.grey(`(${QUIT_OPTION$1})`), value: null }]
|
|
1117
|
+
}
|
|
1118
|
+
]);
|
|
1119
|
+
if (selectedEnvironment === null) {
|
|
1120
|
+
process.exit(1);
|
|
1121
|
+
}
|
|
1122
|
+
const { confirm } = await inquirer__default.default.prompt([
|
|
1123
|
+
{
|
|
1124
|
+
type: "confirm",
|
|
1125
|
+
name: "confirm",
|
|
1126
|
+
message: `Do you want to proceed with deployment to ${chalk__default.default.cyan(selectedEnvironment)}?`
|
|
1127
|
+
}
|
|
1128
|
+
]);
|
|
1129
|
+
if (!confirm) {
|
|
1130
|
+
process.exit(1);
|
|
1131
|
+
}
|
|
1132
|
+
return selectedEnvironment;
|
|
1133
|
+
}
|
|
1106
1134
|
async function upload(ctx, project, token, maxProjectFileSize) {
|
|
1107
1135
|
const cloudApi = await cloudApiFactory(ctx, token);
|
|
1108
1136
|
try {
|
|
@@ -1206,7 +1234,7 @@ async function getConfig({
|
|
|
1206
1234
|
return null;
|
|
1207
1235
|
}
|
|
1208
1236
|
}
|
|
1209
|
-
const action$4 = async (ctx) => {
|
|
1237
|
+
const action$4 = async (ctx, opts) => {
|
|
1210
1238
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1211
1239
|
const token = await getValidToken(ctx, promptLogin);
|
|
1212
1240
|
if (!token) {
|
|
@@ -1217,11 +1245,13 @@ const action$4 = async (ctx) => {
|
|
|
1217
1245
|
return;
|
|
1218
1246
|
}
|
|
1219
1247
|
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1248
|
+
let environments;
|
|
1220
1249
|
try {
|
|
1221
1250
|
const {
|
|
1222
1251
|
data: { data: projectData, metadata }
|
|
1223
1252
|
} = await cloudApiService.getProject({ name: project.name });
|
|
1224
1253
|
const isProjectSuspended = projectData.suspendedAt;
|
|
1254
|
+
environments = projectData.environments;
|
|
1225
1255
|
if (isProjectSuspended) {
|
|
1226
1256
|
ctx.logger.log(
|
|
1227
1257
|
"\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
|
|
@@ -1268,6 +1298,17 @@ Please link your local project to an existing Strapi Cloud project using the ${c
|
|
|
1268
1298
|
);
|
|
1269
1299
|
maxSize = 1e8;
|
|
1270
1300
|
}
|
|
1301
|
+
let targetEnvironment;
|
|
1302
|
+
if (opts.environment) {
|
|
1303
|
+
if (!environments.includes(opts.environment)) {
|
|
1304
|
+
ctx.logger.error(`Environment ${opts.environment} does not exist.`);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
targetEnvironment = opts.environment;
|
|
1308
|
+
} else {
|
|
1309
|
+
targetEnvironment = environments.length > 1 ? await promptForEnvironment(environments) : environments[0];
|
|
1310
|
+
}
|
|
1311
|
+
project.targetEnvironment = targetEnvironment;
|
|
1271
1312
|
const buildId = await upload(ctx, project, token, maxSize);
|
|
1272
1313
|
if (!buildId) {
|
|
1273
1314
|
return;
|
|
@@ -1318,7 +1359,7 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1318
1359
|
});
|
|
1319
1360
|
};
|
|
1320
1361
|
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));
|
|
1362
|
+
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
1363
|
};
|
|
1323
1364
|
const deployProject = {
|
|
1324
1365
|
name: "deploy-project",
|
|
@@ -1623,14 +1664,22 @@ Please link your local project to an existing Strapi Cloud project using the ${c
|
|
|
1623
1664
|
});
|
|
1624
1665
|
}
|
|
1625
1666
|
};
|
|
1626
|
-
function defineCloudNamespace(command2) {
|
|
1627
|
-
|
|
1667
|
+
function defineCloudNamespace(command2, ctx) {
|
|
1668
|
+
const cloud = command2.command("cloud").description("Manage Strapi Cloud projects");
|
|
1669
|
+
cloud.command("environments").description("Alias for cloud environment list").action(() => runAction("list", action)(ctx));
|
|
1670
|
+
return cloud;
|
|
1628
1671
|
}
|
|
1672
|
+
let environmentCmd = null;
|
|
1673
|
+
const initializeEnvironmentCommand = (command2, ctx) => {
|
|
1674
|
+
if (!environmentCmd) {
|
|
1675
|
+
const cloud = defineCloudNamespace(command2, ctx);
|
|
1676
|
+
environmentCmd = cloud.command("environment").description("Manage environments");
|
|
1677
|
+
}
|
|
1678
|
+
return environmentCmd;
|
|
1679
|
+
};
|
|
1629
1680
|
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));
|
|
1681
|
+
const environmentCmd2 = initializeEnvironmentCommand(command2, ctx);
|
|
1682
|
+
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
1683
|
};
|
|
1635
1684
|
const listEnvironments = {
|
|
1636
1685
|
name: "list-environments",
|