@webiny/cli 5.36.1-beta.1 → 5.36.2-beta.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/cli.js +9 -0
- package/commands/about/getNpxVersion.js +10 -0
- package/commands/about/getPulumiVersions.js +41 -0
- package/commands/about/getYarnVersion.js +10 -0
- package/commands/about/index.js +109 -0
- package/commands/index.js +2 -1
- package/package.json +4 -4
package/cli.js
CHANGED
|
@@ -10,6 +10,15 @@ require("./utils/loadEnvVariables");
|
|
|
10
10
|
const { blue, red } = require("chalk");
|
|
11
11
|
const context = require("./context");
|
|
12
12
|
const { createCommands } = require("./commands");
|
|
13
|
+
const { localStorage } = require("./utils");
|
|
14
|
+
|
|
15
|
+
// Save the full command in the history.
|
|
16
|
+
const [, , ...commandParts] = process.argv;
|
|
17
|
+
const fullCommand = "yarn webiny " + commandParts.join(" ");
|
|
18
|
+
|
|
19
|
+
const ls = localStorage();
|
|
20
|
+
const history = ls.get("history") || [];
|
|
21
|
+
ls.set("history", [fullCommand, ...history]);
|
|
13
22
|
|
|
14
23
|
yargs
|
|
15
24
|
.usage("Usage: $0 <command> [options]")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const execa = require("execa");
|
|
2
|
+
|
|
3
|
+
module.exports.getPulumiVersions = async () => {
|
|
4
|
+
let pulumi, pulumiAws;
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
{
|
|
8
|
+
const { stdout } = await execa("yarn", [
|
|
9
|
+
"info",
|
|
10
|
+
"@pulumi/pulumi",
|
|
11
|
+
"-A",
|
|
12
|
+
"--name-only",
|
|
13
|
+
"--json"
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
const match = stdout.match(/npm:(.*?)"/);
|
|
17
|
+
if (match) {
|
|
18
|
+
pulumi = match[1];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
const { stdout } = await execa("yarn", [
|
|
24
|
+
"info",
|
|
25
|
+
"@pulumi/aws",
|
|
26
|
+
"-A",
|
|
27
|
+
"--name-only",
|
|
28
|
+
"--json"
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
const match = stdout.match(/npm:(.*?)"/);
|
|
32
|
+
if (match) {
|
|
33
|
+
pulumiAws = match[1];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return [pulumi, pulumiAws];
|
|
41
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const { bold } = require("chalk");
|
|
2
|
+
const { getNpxVersion } = require("./getNpxVersion");
|
|
3
|
+
const { getPulumiVersions } = require("./getPulumiVersions");
|
|
4
|
+
const { getYarnVersion } = require("./getYarnVersion");
|
|
5
|
+
const { getUser } = require("../wcp/utils");
|
|
6
|
+
const localStorage = require("../../utils/localStorage");
|
|
7
|
+
|
|
8
|
+
const NO_VALUE = "-";
|
|
9
|
+
|
|
10
|
+
const getData = async context => {
|
|
11
|
+
const [pulumiVersion, pulumiAwsVersion] = await getPulumiVersions();
|
|
12
|
+
|
|
13
|
+
const commandsHistory = localStorage().get("history") || [];
|
|
14
|
+
const last10Commands = commandsHistory.slice(1, 11); // We skip the first command, which is the current one.
|
|
15
|
+
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
sectionName: "Webiny Project",
|
|
19
|
+
data: {
|
|
20
|
+
Name: context.project.name,
|
|
21
|
+
Version: context.version,
|
|
22
|
+
Template: context.project.config.template || NO_VALUE,
|
|
23
|
+
"Debug Enabled": process.env.DEBUG === "true" ? "Yes" : "No",
|
|
24
|
+
"Feature Flags": process.env.WEBINY_FEATURE_FLAGS || "N/A"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
sectionName: "Webiny Control Panel (WCP)",
|
|
29
|
+
data: {
|
|
30
|
+
"Project ID": context.project.config.id || process.env.WCP_PROJECT_ID,
|
|
31
|
+
User: await getUser()
|
|
32
|
+
.catch(() => "N/A")
|
|
33
|
+
.then(res => res.email),
|
|
34
|
+
Authentication: process.env.WEBINY_PROJECT_ENVIRONMENT_API_KEY
|
|
35
|
+
? "Project Environment API Key"
|
|
36
|
+
: "Personal Access Token"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
sectionName: "Pulumi",
|
|
41
|
+
data: {
|
|
42
|
+
"@pulumi/pulumi": pulumiVersion,
|
|
43
|
+
"@pulumi/aws": pulumiAwsVersion,
|
|
44
|
+
"Used AWS Region": process.env.AWS_REGION,
|
|
45
|
+
"Secrets Provider": process.env.PULUMI_SECRETS_PROVIDER,
|
|
46
|
+
"Using Password": process.env.PULUMI_CONFIG_PASSPHRASE ? "Yes" : "No"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
sectionName: "Host",
|
|
51
|
+
data: {
|
|
52
|
+
OS: `${process.platform} (${process.arch})`,
|
|
53
|
+
"Node.js": process.version,
|
|
54
|
+
NPX: await getNpxVersion(),
|
|
55
|
+
Yarn: await getYarnVersion()
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
sectionName: "Last 10 Commands Executed",
|
|
60
|
+
data: {
|
|
61
|
+
Commands: last10Commands
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
type: "cli-command",
|
|
69
|
+
name: "cli-command-about",
|
|
70
|
+
create({ yargs, context }) {
|
|
71
|
+
yargs.command(
|
|
72
|
+
"about",
|
|
73
|
+
`Prints out information helpful for debugging purposes.`,
|
|
74
|
+
yargs => {
|
|
75
|
+
yargs.option("json", {
|
|
76
|
+
describe: "Emit output as JSON.",
|
|
77
|
+
type: "boolean",
|
|
78
|
+
default: false
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async yargs => {
|
|
82
|
+
const data = await getData(context);
|
|
83
|
+
|
|
84
|
+
if (yargs.json) {
|
|
85
|
+
console.log(JSON.stringify(data, null, 2));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
data.forEach(({ sectionName, data }, index) => {
|
|
90
|
+
if (index > 0) {
|
|
91
|
+
console.log();
|
|
92
|
+
}
|
|
93
|
+
console.log(bold(sectionName));
|
|
94
|
+
|
|
95
|
+
// Custom rendering for "Last 10 Commands Executed" section.
|
|
96
|
+
Object.keys(data).forEach(key => {
|
|
97
|
+
if (sectionName === "Last 10 Commands Executed") {
|
|
98
|
+
data[key].forEach((command, index) => {
|
|
99
|
+
console.log(` ${index + 1}. ${command}`);
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
console.log(key.padEnd(30), data[key] || NO_VALUE);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
};
|
package/commands/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
const about = require("./about");
|
|
1
2
|
const run = require("./run");
|
|
2
3
|
const telemetry = require("./telemetry");
|
|
3
4
|
const upgrade = require("./upgrade");
|
|
4
5
|
|
|
5
6
|
module.exports.createCommands = async (yargs, context) => {
|
|
6
|
-
context.plugins.register(run, telemetry, upgrade);
|
|
7
|
+
context.plugins.register(about, run, telemetry, upgrade);
|
|
7
8
|
|
|
8
9
|
try {
|
|
9
10
|
const wcp = require("./wcp");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cli",
|
|
3
|
-
"version": "5.36.
|
|
3
|
+
"version": "5.36.2-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"webiny": "./bin.js"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"author": "Pavel Denisjuk <pavel@webiny.com>",
|
|
14
14
|
"description": "A tool to bootstrap a Webiny project.",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/telemetry": "5.36.
|
|
17
|
-
"@webiny/wcp": "5.36.
|
|
16
|
+
"@webiny/telemetry": "5.36.2-beta.0",
|
|
17
|
+
"@webiny/wcp": "5.36.2-beta.0",
|
|
18
18
|
"boolean": "3.2.0",
|
|
19
19
|
"camelcase": "5.3.1",
|
|
20
20
|
"chalk": "4.1.2",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "4db8c2e74ba3e5a7914dd1367467b558172e9087"
|
|
68
68
|
}
|