@webiny/cli 0.0.0-unstable.990c3ab1b6 → 0.0.0-unstable.99666aeb00
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 +2 -23
- 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 +93 -0
- package/commands/index.js +2 -1
- package/commands/wcp/utils/getWcpOrgProjectId.js +9 -0
- package/commands/wcp/utils/getWcpProjectId.js +3 -0
- package/commands/wcp/utils/index.js +4 -0
- package/context.js +2 -2
- package/package.json +8 -8
- package/utils/loadEnvVariables.js +46 -0
- package/CHANGELOG.md +0 -3569
package/cli.js
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const path = require("path");
|
|
3
2
|
const yargs = require("yargs");
|
|
4
|
-
const { log, getProject } = require("./utils");
|
|
5
|
-
const { boolean } = require("boolean");
|
|
6
3
|
|
|
7
4
|
// Disable help processing until after plugins are imported.
|
|
8
5
|
yargs.help(false);
|
|
9
6
|
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
const project = getProject();
|
|
13
|
-
let paths = [path.join(project.root, ".env")];
|
|
14
|
-
|
|
15
|
-
if (yargs.argv.env) {
|
|
16
|
-
paths.push(path.join(project.root, `.env.${yargs.argv.env}`));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < paths.length; i++) {
|
|
20
|
-
const path = paths[i];
|
|
21
|
-
const { error } = require("dotenv").config({ path });
|
|
22
|
-
if (boolean(yargs.argv.debug)) {
|
|
23
|
-
if (error) {
|
|
24
|
-
log.debug(`No environment file found on ${log.debug.hl(path)}.`);
|
|
25
|
-
} else {
|
|
26
|
-
log.success(`Successfully loaded environment variables from ${log.success.hl(path)}.`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
7
|
+
// Loads environment variables from multiple sources.
|
|
8
|
+
require("./utils/loadEnvVariables");
|
|
30
9
|
|
|
31
10
|
const { blue, red } = require("chalk");
|
|
32
11
|
const context = require("./context");
|
|
@@ -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,93 @@
|
|
|
1
|
+
const NO_VALUE = "-";
|
|
2
|
+
|
|
3
|
+
const getData = async context => {
|
|
4
|
+
const { getUser } = require("../wcp/utils");
|
|
5
|
+
const { getNpxVersion } = require("./getNpxVersion");
|
|
6
|
+
const { getPulumiVersions } = require("./getPulumiVersions");
|
|
7
|
+
const { getYarnVersion } = require("./getYarnVersion");
|
|
8
|
+
|
|
9
|
+
const [pulumiVersion, pulumiAwsVersion] = await getPulumiVersions();
|
|
10
|
+
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
sectionName: "Webiny Project",
|
|
14
|
+
data: {
|
|
15
|
+
Name: context.project.name,
|
|
16
|
+
Version: context.version,
|
|
17
|
+
Template: context.project.config.template || NO_VALUE,
|
|
18
|
+
"Debug Enabled": process.env.DEBUG === "true" ? "Yes" : "No",
|
|
19
|
+
"Feature Flags": process.env.WEBINY_FEATURE_FLAGS || "N/A"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
sectionName: "Webiny Control Panel (WCP)",
|
|
24
|
+
data: {
|
|
25
|
+
"Project ID": context.project.config.id || process.env.WCP_PROJECT_ID,
|
|
26
|
+
User: await getUser()
|
|
27
|
+
.catch(() => "N/A")
|
|
28
|
+
.then(res => res.email),
|
|
29
|
+
Authentication: process.env.WEBINY_PROJECT_ENVIRONMENT_API_KEY
|
|
30
|
+
? "Project Environment API Key"
|
|
31
|
+
: "Personal Access Token"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
sectionName: "Pulumi",
|
|
36
|
+
data: {
|
|
37
|
+
"@pulumi/pulumi": pulumiVersion,
|
|
38
|
+
"@pulumi/aws": pulumiAwsVersion,
|
|
39
|
+
"Used AWS Region": process.env.AWS_REGION,
|
|
40
|
+
"Secrets Provider": process.env.PULUMI_SECRETS_PROVIDER,
|
|
41
|
+
"Using Password": process.env.PULUMI_CONFIG_PASSPHRASE ? "Yes" : "No"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
sectionName: "Host",
|
|
46
|
+
data: {
|
|
47
|
+
OS: `${process.platform} (${process.arch})`,
|
|
48
|
+
"Node.js": process.version,
|
|
49
|
+
NPX: await getNpxVersion(),
|
|
50
|
+
Yarn: await getYarnVersion()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
type: "cli-command",
|
|
58
|
+
name: "cli-command-about",
|
|
59
|
+
create({ yargs, context }) {
|
|
60
|
+
yargs.command(
|
|
61
|
+
"about",
|
|
62
|
+
`Prints out information helpful for debugging purposes.`,
|
|
63
|
+
yargs => {
|
|
64
|
+
yargs.option("json", {
|
|
65
|
+
describe: "Emit output as JSON.",
|
|
66
|
+
type: "boolean",
|
|
67
|
+
default: false
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
async yargs => {
|
|
71
|
+
const data = await getData(context);
|
|
72
|
+
|
|
73
|
+
if (yargs.json) {
|
|
74
|
+
console.log(JSON.stringify(data, null, 2));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
data.forEach(({ sectionName, data }, index) => {
|
|
79
|
+
if (index > 0) {
|
|
80
|
+
console.log();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { bold } = require("chalk");
|
|
84
|
+
console.log(bold(sectionName));
|
|
85
|
+
|
|
86
|
+
Object.keys(data).forEach(key => {
|
|
87
|
+
console.log(key.padEnd(30), data[key] || NO_VALUE);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
};
|
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");
|
|
@@ -4,6 +4,8 @@ const { updateUserLastActiveOn } = require("./updateUserLastActiveOn");
|
|
|
4
4
|
const { setProjectId } = require("./setProjectId");
|
|
5
5
|
const { setWcpPat } = require("./setWcpPat");
|
|
6
6
|
const { getWcpPat } = require("./getWcpPat");
|
|
7
|
+
const { getWcpProjectId } = require("./getWcpProjectId");
|
|
8
|
+
const { getWcpOrgProjectId } = require("./getWcpOrgProjectId");
|
|
7
9
|
const { sleep } = require("./sleep");
|
|
8
10
|
|
|
9
11
|
module.exports = {
|
|
@@ -13,5 +15,7 @@ module.exports = {
|
|
|
13
15
|
setProjectId,
|
|
14
16
|
setWcpPat,
|
|
15
17
|
getWcpPat,
|
|
18
|
+
getWcpProjectId,
|
|
19
|
+
getWcpOrgProjectId,
|
|
16
20
|
sleep
|
|
17
21
|
};
|
package/context.js
CHANGED
|
@@ -92,7 +92,7 @@ class Context {
|
|
|
92
92
|
log = log.log;
|
|
93
93
|
info = log.info;
|
|
94
94
|
success = log.success;
|
|
95
|
-
debug = process.argv.
|
|
95
|
+
debug = process.argv.some(v => v.match("--debug")) ? log.debug : noop;
|
|
96
96
|
warning = log.warning;
|
|
97
97
|
error = log.error;
|
|
98
98
|
|
|
@@ -116,7 +116,7 @@ class Context {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
if (!fs.existsSync(filePath)) {
|
|
119
|
-
debug && this.debug(`No environment file found on
|
|
119
|
+
debug && this.debug(`No environment file found on %s.`, filePath);
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cli",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.99666aeb00",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"webiny": "./bin.js"
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"author": "Pavel Denisjuk <pavel@webiny.com>",
|
|
14
14
|
"description": "A tool to bootstrap a Webiny project.",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/telemetry": "0.0.0-unstable.
|
|
17
|
-
"@webiny/wcp": "0.0.0-unstable.
|
|
18
|
-
"boolean": "3.
|
|
16
|
+
"@webiny/telemetry": "0.0.0-unstable.99666aeb00",
|
|
17
|
+
"@webiny/wcp": "0.0.0-unstable.99666aeb00",
|
|
18
|
+
"boolean": "3.2.0",
|
|
19
19
|
"camelcase": "5.3.1",
|
|
20
20
|
"chalk": "4.1.2",
|
|
21
|
-
"dotenv": "8.
|
|
21
|
+
"dotenv": "8.6.0",
|
|
22
22
|
"execa": "5.1.1",
|
|
23
|
-
"fast-glob": "3.2.
|
|
23
|
+
"fast-glob": "3.2.12",
|
|
24
24
|
"find-up": "5.0.0",
|
|
25
25
|
"fs-extra": "9.1.0",
|
|
26
26
|
"graphql-request": "3.7.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"ncp": "2.0.0",
|
|
29
29
|
"open": "8.4.0",
|
|
30
30
|
"pirates": "4.0.5",
|
|
31
|
-
"semver": "
|
|
31
|
+
"semver": "6.3.0",
|
|
32
32
|
"ts-morph": "11.0.3",
|
|
33
33
|
"typescript": "4.7.4",
|
|
34
34
|
"uniqid": "5.4.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "99666aeb00056c56292eeb5dbb6aba7fda2439e2"
|
|
68
68
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const yargs = require("yargs");
|
|
3
|
+
const log = require("./log");
|
|
4
|
+
const getProject = require("./getProject");
|
|
5
|
+
const { boolean } = require("boolean");
|
|
6
|
+
|
|
7
|
+
// Load environment variables from following sources:
|
|
8
|
+
// - `webiny.project.ts` file
|
|
9
|
+
// - `.env` file
|
|
10
|
+
// - `.env.{PASSED_ENVIRONMENT}` file
|
|
11
|
+
|
|
12
|
+
const project = getProject();
|
|
13
|
+
|
|
14
|
+
// `webiny.project.ts` file.
|
|
15
|
+
// Environment variables defined via the `env` property.
|
|
16
|
+
if (project.config.env) {
|
|
17
|
+
Object.assign(process.env, project.config.env);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// `.env.{PASSED_ENVIRONMENT}` and `.env` files.
|
|
21
|
+
let paths = [path.join(project.root, ".env")];
|
|
22
|
+
|
|
23
|
+
if (yargs.argv.env) {
|
|
24
|
+
paths.push(path.join(project.root, `.env.${yargs.argv.env}`));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Let's load environment variables
|
|
28
|
+
for (let i = 0; i < paths.length; i++) {
|
|
29
|
+
const path = paths[i];
|
|
30
|
+
const { error } = require("dotenv").config({ path });
|
|
31
|
+
if (boolean(yargs.argv.debug)) {
|
|
32
|
+
if (error) {
|
|
33
|
+
log.debug(`No environment file found on ${log.debug.hl(path)}.`);
|
|
34
|
+
} else {
|
|
35
|
+
log.success(`Successfully loaded environment variables from ${log.success.hl(path)}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Feature flags defined via the `featureFlags` property.
|
|
41
|
+
// We set twice, to be available for both backend and frontend application code.
|
|
42
|
+
// TODO: one day we might want to sync this up a bit.
|
|
43
|
+
if (project.config.featureFlags) {
|
|
44
|
+
process.env.WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
|
|
45
|
+
process.env.REACT_APP_WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
|
|
46
|
+
}
|