@webiny/cli 5.33.5 → 5.34.0-beta.1
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/context.js +2 -2
- package/package.json +6 -6
- package/utils/loadEnvVariables.js +46 -0
- package/CHANGELOG.md +0 -3617
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");
|
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": "5.
|
|
3
|
+
"version": "5.34.0-beta.1",
|
|
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.
|
|
17
|
-
"@webiny/wcp": "5.
|
|
16
|
+
"@webiny/telemetry": "5.34.0-beta.1",
|
|
17
|
+
"@webiny/wcp": "5.34.0-beta.1",
|
|
18
18
|
"boolean": "3.1.4",
|
|
19
19
|
"camelcase": "5.3.1",
|
|
20
20
|
"chalk": "4.1.2",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"ncp": "2.0.0",
|
|
29
29
|
"open": "8.4.0",
|
|
30
30
|
"pirates": "4.0.5",
|
|
31
|
-
"semver": "7.3.
|
|
31
|
+
"semver": "7.3.8",
|
|
32
32
|
"ts-morph": "11.0.3",
|
|
33
33
|
"typescript": "4.7.4",
|
|
34
34
|
"uniqid": "5.4.0",
|
|
35
|
-
"yargs": "17.
|
|
35
|
+
"yargs": "17.6.0"
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"publishConfig": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "1ee2a7338a865a67e24eb42d16bf0b6091195286"
|
|
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
|
+
}
|