@webiny/cli 0.0.0-unstable.da99e0b846 → 0.0.0-unstable.de38392959

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/bin.js CHANGED
@@ -22,12 +22,12 @@ const currentNodeVersion = process.versions.node;
22
22
 
23
23
  try {
24
24
  const { stdout } = await execa("yarn", ["--version"]);
25
- if (!semver.satisfies(stdout, ">=2")) {
26
- console.error(chalk.red(`"@webiny/cli" requires yarn >=2!`));
25
+ if (!semver.satisfies(stdout, ">=3")) {
26
+ console.error(chalk.red(`"@webiny/cli" requires yarn 3 or 4!`));
27
27
  process.exit(1);
28
28
  }
29
29
  } catch (err) {
30
- console.error(chalk.red(`"@webiny/cli" requires yarn >=2!`));
30
+ console.error(chalk.red(`"@webiny/cli" requires yarn 3 or 4!`));
31
31
  console.log(
32
32
  `Run ${chalk.blue("yarn set version berry")} to install a compatible version of yarn.`
33
33
  );
@@ -0,0 +1,10 @@
1
+ const execa = require("execa");
2
+
3
+ module.exports.getNpxVersion = async () => {
4
+ try {
5
+ const { stdout } = await execa("npx", ["--version"]);
6
+ return stdout;
7
+ } catch (err) {
8
+ return "";
9
+ }
10
+ };
@@ -0,0 +1,43 @@
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
+ "-R",
13
+ "--name-only",
14
+ "--json"
15
+ ]);
16
+
17
+ const match = stdout.match(/npm:(.*?)"/);
18
+ if (match) {
19
+ pulumi = match[1];
20
+ }
21
+ }
22
+
23
+ {
24
+ const { stdout } = await execa("yarn", [
25
+ "info",
26
+ "@pulumi/aws",
27
+ "-A",
28
+ "-R",
29
+ "--name-only",
30
+ "--json"
31
+ ]);
32
+
33
+ const match = stdout.match(/npm:(.*?)"/);
34
+ if (match) {
35
+ pulumiAws = match[1];
36
+ }
37
+ }
38
+ } catch (err) {
39
+ return "";
40
+ }
41
+
42
+ return [pulumi, pulumiAws];
43
+ };
@@ -0,0 +1,10 @@
1
+ const execa = require("execa");
2
+
3
+ module.exports.getYarnVersion = async () => {
4
+ try {
5
+ const { stdout } = await execa("yarn", ["--version"]);
6
+ return stdout;
7
+ } catch (err) {
8
+ return "";
9
+ }
10
+ };
@@ -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");
@@ -8,9 +8,8 @@ module.exports = {
8
8
  telemetry.enable();
9
9
  await telemetry.sendEvent({ event: "enable-telemetry" });
10
10
  context.info(
11
- `Webiny telemetry is now ${context.info.hl(
12
- "enabled"
13
- )}! Thank you for helping us in making Webiny better!`
11
+ `Webiny telemetry is now %s! Thank you for helping us in making Webiny better!`,
12
+ "enabled"
14
13
  );
15
14
  context.info(
16
15
  `For more information, please visit the following link: https://www.webiny.com/telemetry.`
@@ -20,11 +19,10 @@ module.exports = {
20
19
  yargs.command("disable-telemetry", "Disable anonymous telemetry.", async () => {
21
20
  await telemetry.sendEvent({ event: "disable-telemetry" });
22
21
  telemetry.disable();
23
- context.info(`Webiny telemetry is now ${context.info.hl("disabled")}!`);
22
+ context.info(`Webiny telemetry is now %s!`, "disabled");
24
23
  context.info(
25
- `Note that, in order to complete the process, you will also need to re-deploy your project, using the ${context.info.hl(
26
- "yarn webiny deploy"
27
- )} command.`
24
+ `Note that, in order to complete the process, you will also need to re-deploy your project, using the %s command.`,
25
+ "yarn webiny deploy"
28
26
  );
29
27
  });
30
28
  }
@@ -70,7 +70,8 @@ module.exports = [
70
70
  const npx = execa("npx", command, {
71
71
  env: {
72
72
  FORCE_COLOR: true
73
- }
73
+ },
74
+ stdin: process.stdin
74
75
  });
75
76
 
76
77
  npx.stdout.on("data", data => {
@@ -95,9 +95,8 @@ module.exports.command = () => ({
95
95
  } catch (e) {
96
96
  if (debug) {
97
97
  context.debug(
98
- `Could not use the provided ${context.debug.hl(
99
- patFromParams
100
- )} PAT because of the following error:`
98
+ `Could not use the provided %s PAT because of the following error:`,
99
+ patFromParams
101
100
  );
102
101
  console.debug(e);
103
102
  }
@@ -118,7 +117,7 @@ module.exports.command = () => ({
118
117
  )}&ref=cli`;
119
118
  const openUrl = `${getWcpAppUrl()}/login/cli?${queryParams}`;
120
119
 
121
- debug && context.debug(`Opening ${context.debug.hl(openUrl)}...`);
120
+ debug && context.debug(`Opening %s...`, openUrl);
122
121
  await open(openUrl);
123
122
 
124
123
  const graphql = {
@@ -0,0 +1,9 @@
1
+ const { getWcpProjectId } = require("./getWcpProjectId");
2
+
3
+ module.exports.getWcpOrgProjectId = context => {
4
+ const id = getWcpProjectId(context);
5
+ if (typeof id === "string") {
6
+ return id.split("/");
7
+ }
8
+ return [];
9
+ };
@@ -0,0 +1,3 @@
1
+ module.exports.getWcpProjectId = context => {
2
+ return context?.project?.config?.id || process.env.WCP_PROJECT_ID || "";
3
+ };
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/cli",
3
- "version": "0.0.0-unstable.da99e0b846",
3
+ "version": "0.0.0-unstable.de38392959",
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": "0.0.0-unstable.da99e0b846",
17
- "@webiny/wcp": "0.0.0-unstable.da99e0b846",
16
+ "@webiny/telemetry": "0.0.0-unstable.de38392959",
17
+ "@webiny/wcp": "0.0.0-unstable.de38392959",
18
18
  "boolean": "3.2.0",
19
19
  "camelcase": "5.3.1",
20
20
  "chalk": "4.1.2",
@@ -28,7 +28,7 @@
28
28
  "ncp": "2.0.0",
29
29
  "open": "8.4.0",
30
30
  "pirates": "4.0.5",
31
- "semver": "7.3.8",
31
+ "semver": "7.5.4",
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": "da99e0b8461741d3ae57fdb9d4b2fc7646c1d754"
67
+ "gitHead": "de38392959f2692d1feb08945a3588cd80e4924c"
68
68
  }
@@ -44,3 +44,11 @@ if (project.config.featureFlags) {
44
44
  process.env.WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
45
45
  process.env.REACT_APP_WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
46
46
  }
47
+
48
+ // With 5.38.0, we are hiding the `WEBINY_ELASTICSEARCH_INDEX_LOCALE` env variable and always setting it to `true`.
49
+ // This is because this variable is not something users should be concerned with, nor should they be able to change it.
50
+ // In order to ensure backwards compatibility, we first check if the variable is set, and if it is, we don't override it.
51
+ const esIndexLocaleEnvVarExists = "WEBINY_ELASTICSEARCH_INDEX_LOCALE" in process.env;
52
+ if (!esIndexLocaleEnvVarExists) {
53
+ process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE = "true";
54
+ }