@webiny/cli 5.33.5-beta.0 → 5.34.0-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 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
- // Immediately load .env.{PASSED_ENVIRONMENT} and .env files.
11
- // This way we ensure all of the environment variables are not loaded too late.
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.includes("--debug") ? log.debug : noop;
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 ${this.debug.hl(filePath)}.`);
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.33.5-beta.0",
3
+ "version": "5.34.0-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.33.5-beta.0",
17
- "@webiny/wcp": "5.33.5-beta.0",
16
+ "@webiny/telemetry": "5.34.0-beta.0",
17
+ "@webiny/wcp": "5.34.0-beta.0",
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.7",
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.5.1"
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": "2d8919d669aefd7df32749e6a4b365a50e1d7be1"
67
+ "gitHead": "9648454619a1bfb35040eb00f27a64ed75194e61"
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
+ }