@strapi/cloud-cli 0.0.0-next.e9b6852d1c05518ff6e37d599321f7aa7aa0683b → 0.0.0-next.f5312617ca16b870c2bf1adcea2c69b676979e29
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 +150 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +150 -54
- 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/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 +9 -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 +8 -8
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ const cliProgress = require("cli-progress");
|
|
|
43
43
|
const pkgUp = require("pkg-up");
|
|
44
44
|
const yup = require("yup");
|
|
45
45
|
const EventSource = require("eventsource");
|
|
46
|
+
const commander = require("commander");
|
|
46
47
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
47
48
|
function _interopNamespace(e) {
|
|
48
49
|
if (e && e.__esModule)
|
|
@@ -192,7 +193,7 @@ async function saveLocalConfig(data) {
|
|
|
192
193
|
await fse__namespace.default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
|
|
193
194
|
}
|
|
194
195
|
const name = "@strapi/cloud-cli";
|
|
195
|
-
const version = "
|
|
196
|
+
const version = "5.1.1";
|
|
196
197
|
const description = "Commands to interact with the Strapi Cloud";
|
|
197
198
|
const keywords = [
|
|
198
199
|
"strapi",
|
|
@@ -237,14 +238,14 @@ const scripts = {
|
|
|
237
238
|
watch: "pack-up watch"
|
|
238
239
|
};
|
|
239
240
|
const dependencies = {
|
|
240
|
-
"@strapi/utils": "
|
|
241
|
+
"@strapi/utils": "workspace:*",
|
|
241
242
|
axios: "1.7.4",
|
|
242
243
|
chalk: "4.1.2",
|
|
243
244
|
"cli-progress": "3.12.0",
|
|
244
245
|
commander: "8.3.0",
|
|
245
246
|
eventsource: "2.0.2",
|
|
246
247
|
"fast-safe-stringify": "2.1.1",
|
|
247
|
-
"fs-extra": "
|
|
248
|
+
"fs-extra": "11.2.0",
|
|
248
249
|
inquirer: "8.2.5",
|
|
249
250
|
jsonwebtoken: "9.0.0",
|
|
250
251
|
"jwks-rsa": "3.1.0",
|
|
@@ -253,7 +254,7 @@ const dependencies = {
|
|
|
253
254
|
open: "8.4.0",
|
|
254
255
|
ora: "5.4.1",
|
|
255
256
|
"pkg-up": "3.1.0",
|
|
256
|
-
tar: "6.1
|
|
257
|
+
tar: "6.2.1",
|
|
257
258
|
"xdg-app-paths": "8.3.0",
|
|
258
259
|
yup: "0.32.9"
|
|
259
260
|
};
|
|
@@ -262,11 +263,11 @@ const devDependencies = {
|
|
|
262
263
|
"@types/cli-progress": "3.11.5",
|
|
263
264
|
"@types/eventsource": "1.1.15",
|
|
264
265
|
"@types/lodash": "^4.14.191",
|
|
265
|
-
"eslint-config-custom": "
|
|
266
|
-
tsconfig: "
|
|
266
|
+
"eslint-config-custom": "workspace:*",
|
|
267
|
+
tsconfig: "workspace:*"
|
|
267
268
|
};
|
|
268
269
|
const engines = {
|
|
269
|
-
node: ">=18.0.0 <=
|
|
270
|
+
node: ">=18.0.0 <=22.x.x",
|
|
270
271
|
npm: ">=6.0.0"
|
|
271
272
|
};
|
|
272
273
|
const packageJson = {
|
|
@@ -387,6 +388,20 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
387
388
|
throw error;
|
|
388
389
|
}
|
|
389
390
|
},
|
|
391
|
+
async listEnvironments({ name: name2 }) {
|
|
392
|
+
try {
|
|
393
|
+
const response = await axiosCloudAPI.get(`/projects/${name2}/environments`);
|
|
394
|
+
if (response.status !== 200) {
|
|
395
|
+
throw new Error("Error fetching cloud environments from the server.");
|
|
396
|
+
}
|
|
397
|
+
return response;
|
|
398
|
+
} catch (error) {
|
|
399
|
+
logger.debug(
|
|
400
|
+
"🥲 Oops! Couldn't retrieve your project's environments from the server. Please try again."
|
|
401
|
+
);
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
},
|
|
390
405
|
async getProject({ name: name2 }) {
|
|
391
406
|
try {
|
|
392
407
|
const response = await axiosCloudAPI.get(`/projects/${name2}`);
|
|
@@ -674,21 +689,24 @@ yup__namespace.object({
|
|
|
674
689
|
name: yup__namespace.string().required(),
|
|
675
690
|
exports: yup__namespace.lazy(
|
|
676
691
|
(value) => yup__namespace.object(
|
|
677
|
-
typeof value === "object" ? Object.entries(value).reduce(
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
+
typeof value === "object" ? Object.entries(value).reduce(
|
|
693
|
+
(acc, [key, value2]) => {
|
|
694
|
+
if (typeof value2 === "object") {
|
|
695
|
+
acc[key] = yup__namespace.object({
|
|
696
|
+
types: yup__namespace.string().optional(),
|
|
697
|
+
source: yup__namespace.string().required(),
|
|
698
|
+
module: yup__namespace.string().optional(),
|
|
699
|
+
import: yup__namespace.string().required(),
|
|
700
|
+
require: yup__namespace.string().required(),
|
|
701
|
+
default: yup__namespace.string().required()
|
|
702
|
+
}).noUnknown(true);
|
|
703
|
+
} else {
|
|
704
|
+
acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
|
|
705
|
+
}
|
|
706
|
+
return acc;
|
|
707
|
+
},
|
|
708
|
+
{}
|
|
709
|
+
) : void 0
|
|
692
710
|
).optional()
|
|
693
711
|
)
|
|
694
712
|
});
|
|
@@ -956,7 +974,7 @@ async function createProject$1(ctx, cloudApi, projectInput) {
|
|
|
956
974
|
throw e;
|
|
957
975
|
}
|
|
958
976
|
}
|
|
959
|
-
const action$
|
|
977
|
+
const action$5 = async (ctx) => {
|
|
960
978
|
const { logger } = ctx;
|
|
961
979
|
const { getValidToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
962
980
|
const token = await getValidToken(ctx, promptLogin);
|
|
@@ -1163,11 +1181,11 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1163
1181
|
process.exit(1);
|
|
1164
1182
|
}
|
|
1165
1183
|
}
|
|
1166
|
-
async function getProject(ctx) {
|
|
1184
|
+
async function getProject$1(ctx) {
|
|
1167
1185
|
const { project } = await retrieve();
|
|
1168
1186
|
if (!project) {
|
|
1169
1187
|
try {
|
|
1170
|
-
return await action$
|
|
1188
|
+
return await action$5(ctx);
|
|
1171
1189
|
} catch (e) {
|
|
1172
1190
|
ctx.logger.error("An error occurred while deploying the project. Please try again later.");
|
|
1173
1191
|
ctx.logger.debug(e);
|
|
@@ -1188,13 +1206,13 @@ async function getConfig({
|
|
|
1188
1206
|
return null;
|
|
1189
1207
|
}
|
|
1190
1208
|
}
|
|
1191
|
-
const action$
|
|
1209
|
+
const action$4 = async (ctx) => {
|
|
1192
1210
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1193
1211
|
const token = await getValidToken(ctx, promptLogin);
|
|
1194
1212
|
if (!token) {
|
|
1195
1213
|
return;
|
|
1196
1214
|
}
|
|
1197
|
-
const project = await getProject(ctx);
|
|
1215
|
+
const project = await getProject$1(ctx);
|
|
1198
1216
|
if (!project) {
|
|
1199
1217
|
return;
|
|
1200
1218
|
}
|
|
@@ -1299,14 +1317,14 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1299
1317
|
process.exit(1);
|
|
1300
1318
|
});
|
|
1301
1319
|
};
|
|
1302
|
-
const command$
|
|
1303
|
-
|
|
1320
|
+
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));
|
|
1304
1322
|
};
|
|
1305
1323
|
const deployProject = {
|
|
1306
1324
|
name: "deploy-project",
|
|
1307
1325
|
description: "Deploy a Strapi Cloud project",
|
|
1308
|
-
action: action$
|
|
1309
|
-
command: command$
|
|
1326
|
+
action: action$4,
|
|
1327
|
+
command: command$6
|
|
1310
1328
|
};
|
|
1311
1329
|
const QUIT_OPTION = "Quit";
|
|
1312
1330
|
async function getExistingConfig(ctx) {
|
|
@@ -1390,7 +1408,7 @@ async function getUserSelection(ctx, projects) {
|
|
|
1390
1408
|
return null;
|
|
1391
1409
|
}
|
|
1392
1410
|
}
|
|
1393
|
-
const action$
|
|
1411
|
+
const action$3 = async (ctx) => {
|
|
1394
1412
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1395
1413
|
const token = await getValidToken(ctx, promptLogin);
|
|
1396
1414
|
const { logger } = ctx;
|
|
@@ -1445,17 +1463,17 @@ const action$2 = async (ctx) => {
|
|
|
1445
1463
|
});
|
|
1446
1464
|
}
|
|
1447
1465
|
};
|
|
1448
|
-
const command$
|
|
1449
|
-
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$
|
|
1466
|
+
const command$5 = ({ command: command2, ctx }) => {
|
|
1467
|
+
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));
|
|
1450
1468
|
};
|
|
1451
1469
|
const link = {
|
|
1452
1470
|
name: "link-project",
|
|
1453
1471
|
description: "Link a local directory to a Strapi Cloud project",
|
|
1454
|
-
action: action$
|
|
1455
|
-
command: command$
|
|
1472
|
+
action: action$3,
|
|
1473
|
+
command: command$5
|
|
1456
1474
|
};
|
|
1457
|
-
const command$
|
|
1458
|
-
|
|
1475
|
+
const command$4 = ({ ctx }) => {
|
|
1476
|
+
return commander.createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
|
|
1459
1477
|
"after",
|
|
1460
1478
|
"\nAfter running this command, you will be prompted to enter your authentication information."
|
|
1461
1479
|
).option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("login", loginAction)(ctx));
|
|
@@ -1464,10 +1482,10 @@ const login = {
|
|
|
1464
1482
|
name: "login",
|
|
1465
1483
|
description: "Strapi Cloud Login",
|
|
1466
1484
|
action: loginAction,
|
|
1467
|
-
command: command$
|
|
1485
|
+
command: command$4
|
|
1468
1486
|
};
|
|
1469
1487
|
const openModule = import("open");
|
|
1470
|
-
const action$
|
|
1488
|
+
const action$2 = async (ctx) => {
|
|
1471
1489
|
const { logger } = ctx;
|
|
1472
1490
|
const { retrieveToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
1473
1491
|
const token = await retrieveToken();
|
|
@@ -1499,25 +1517,25 @@ const action$1 = async (ctx) => {
|
|
|
1499
1517
|
}
|
|
1500
1518
|
await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
|
|
1501
1519
|
};
|
|
1502
|
-
const command$
|
|
1503
|
-
|
|
1520
|
+
const command$3 = ({ ctx }) => {
|
|
1521
|
+
return commander.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));
|
|
1504
1522
|
};
|
|
1505
1523
|
const logout = {
|
|
1506
1524
|
name: "logout",
|
|
1507
1525
|
description: "Strapi Cloud Logout",
|
|
1508
|
-
action: action$
|
|
1509
|
-
command: command$
|
|
1526
|
+
action: action$2,
|
|
1527
|
+
command: command$3
|
|
1510
1528
|
};
|
|
1511
|
-
const command$
|
|
1512
|
-
|
|
1529
|
+
const command$2 = ({ ctx }) => {
|
|
1530
|
+
return commander.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));
|
|
1513
1531
|
};
|
|
1514
1532
|
const createProject = {
|
|
1515
1533
|
name: "create-project",
|
|
1516
1534
|
description: "Create a new project",
|
|
1517
|
-
action: action$
|
|
1518
|
-
command: command$
|
|
1535
|
+
action: action$5,
|
|
1536
|
+
command: command$2
|
|
1519
1537
|
};
|
|
1520
|
-
const action = async (ctx) => {
|
|
1538
|
+
const action$1 = async (ctx) => {
|
|
1521
1539
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1522
1540
|
const token = await getValidToken(ctx, promptLogin);
|
|
1523
1541
|
const { logger } = ctx;
|
|
@@ -1537,12 +1555,86 @@ const action = async (ctx) => {
|
|
|
1537
1555
|
spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
|
|
1538
1556
|
}
|
|
1539
1557
|
};
|
|
1540
|
-
const command = ({ command: command2, ctx }) => {
|
|
1541
|
-
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));
|
|
1558
|
+
const command$1 = ({ command: command2, ctx }) => {
|
|
1559
|
+
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));
|
|
1542
1560
|
};
|
|
1543
1561
|
const listProjects = {
|
|
1544
1562
|
name: "list-projects",
|
|
1545
1563
|
description: "List Strapi Cloud projects",
|
|
1564
|
+
action: action$1,
|
|
1565
|
+
command: command$1
|
|
1566
|
+
};
|
|
1567
|
+
async function getProject(ctx) {
|
|
1568
|
+
const { project } = await retrieve();
|
|
1569
|
+
if (!project) {
|
|
1570
|
+
ctx.logger.warn(
|
|
1571
|
+
`
|
|
1572
|
+
We couldn't find a valid local project config.
|
|
1573
|
+
Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
|
|
1574
|
+
"link"
|
|
1575
|
+
)} command`
|
|
1576
|
+
);
|
|
1577
|
+
process.exit(1);
|
|
1578
|
+
}
|
|
1579
|
+
return project;
|
|
1580
|
+
}
|
|
1581
|
+
const action = async (ctx) => {
|
|
1582
|
+
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1583
|
+
const token = await getValidToken(ctx, promptLogin);
|
|
1584
|
+
const { logger } = ctx;
|
|
1585
|
+
if (!token) {
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
const project = await getProject(ctx);
|
|
1589
|
+
if (!project) {
|
|
1590
|
+
ctx.logger.debug(`No valid local project configuration was found.`);
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1594
|
+
const spinner = logger.spinner("Fetching environments...").start();
|
|
1595
|
+
await trackEvent(ctx, cloudApiService, "willListEnvironment", {
|
|
1596
|
+
projectInternalName: project.name
|
|
1597
|
+
});
|
|
1598
|
+
try {
|
|
1599
|
+
const {
|
|
1600
|
+
data: { data: environmentsList }
|
|
1601
|
+
} = await cloudApiService.listEnvironments({ name: project.name });
|
|
1602
|
+
spinner.succeed();
|
|
1603
|
+
logger.log(environmentsList);
|
|
1604
|
+
await trackEvent(ctx, cloudApiService, "didListEnvironment", {
|
|
1605
|
+
projectInternalName: project.name
|
|
1606
|
+
});
|
|
1607
|
+
} catch (e) {
|
|
1608
|
+
if (e.response && e.response.status === 404) {
|
|
1609
|
+
spinner.succeed();
|
|
1610
|
+
logger.warn(
|
|
1611
|
+
`
|
|
1612
|
+
The project associated with this folder does not exist in Strapi Cloud.
|
|
1613
|
+
Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
|
|
1614
|
+
"link"
|
|
1615
|
+
)} command`
|
|
1616
|
+
);
|
|
1617
|
+
} else {
|
|
1618
|
+
spinner.fail("An error occurred while fetching environments data from Strapi Cloud.");
|
|
1619
|
+
logger.debug("Failed to list environments", e);
|
|
1620
|
+
}
|
|
1621
|
+
await trackEvent(ctx, cloudApiService, "didNotListEnvironment", {
|
|
1622
|
+
projectInternalName: project.name
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
function defineCloudNamespace(command2) {
|
|
1627
|
+
return command2.command("cloud").description("Manage Strapi Cloud projects");
|
|
1628
|
+
}
|
|
1629
|
+
const command = ({ command: command2, ctx }) => {
|
|
1630
|
+
const cloud = defineCloudNamespace(command2);
|
|
1631
|
+
cloud.command("environments").description("Alias for cloud environment list").action(() => runAction("list", action)(ctx));
|
|
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));
|
|
1634
|
+
};
|
|
1635
|
+
const listEnvironments = {
|
|
1636
|
+
name: "list-environments",
|
|
1637
|
+
description: "List Strapi Cloud environments",
|
|
1546
1638
|
action,
|
|
1547
1639
|
command
|
|
1548
1640
|
};
|
|
@@ -1552,9 +1644,10 @@ const cli = {
|
|
|
1552
1644
|
login,
|
|
1553
1645
|
logout,
|
|
1554
1646
|
createProject,
|
|
1555
|
-
listProjects
|
|
1647
|
+
listProjects,
|
|
1648
|
+
listEnvironments
|
|
1556
1649
|
};
|
|
1557
|
-
const cloudCommands = [deployProject, link, login, logout, listProjects];
|
|
1650
|
+
const cloudCommands = [deployProject, link, login, logout, listProjects, listEnvironments];
|
|
1558
1651
|
async function initCloudCLIConfig() {
|
|
1559
1652
|
const localConfig = await getLocalConfig();
|
|
1560
1653
|
if (!localConfig.deviceId) {
|
|
@@ -1570,7 +1663,10 @@ async function buildStrapiCloudCommands({
|
|
|
1570
1663
|
await initCloudCLIConfig();
|
|
1571
1664
|
for (const cloudCommand of cloudCommands) {
|
|
1572
1665
|
try {
|
|
1573
|
-
await cloudCommand.command({ command: command2, ctx, argv });
|
|
1666
|
+
const subCommand = await cloudCommand.command({ command: command2, ctx, argv });
|
|
1667
|
+
if (subCommand) {
|
|
1668
|
+
command2.addCommand(subCommand);
|
|
1669
|
+
}
|
|
1574
1670
|
} catch (e) {
|
|
1575
1671
|
console.error(`Failed to load command ${cloudCommand.name}`, e);
|
|
1576
1672
|
}
|