@webiny/cli 5.32.0 → 5.33.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/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.33.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.33.0-beta.0...v5.33.0-beta.1) (2022-10-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * deprecate `init` method and introduce `link` ([2fe6bf1](https://github.com/webiny/webiny-js/commit/2fe6bf17fdd0554af6130accb1b88fc0996a0370))
12
+ * replace word `init` with `link` ([8309a57](https://github.com/webiny/webiny-js/commit/8309a57ec98c672382f600c82ca7af2c212caff2))
13
+ * switch the order of commands ([1e37a6a](https://github.com/webiny/webiny-js/commit/1e37a6af290e50366fe625e587c2372f382cb4f5))
14
+
15
+
16
+
17
+
18
+
19
+ # [5.33.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.32.0...v5.33.0-beta.0) (2022-10-11)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * do not continue if there's no WCP project ID present ([faf54da](https://github.com/webiny/webiny-js/commit/faf54da5d8028c1658ba15429e2c366482727c3a))
25
+ * replace verb "activated" with "linked" ([a4634eb](https://github.com/webiny/webiny-js/commit/a4634eb6b0cf5d05edf9b0ca45e742731af21924))
26
+ * skip PAT auth if the environment is being retrieved via API key ([99214e3](https://github.com/webiny/webiny-js/commit/99214e3b124884eafdc94ba8df03bc9345837b92))
27
+
28
+
29
+
30
+
31
+
6
32
  # [5.32.0](https://github.com/webiny/webiny-js/compare/v5.32.0-beta.0...v5.32.0) (2022-09-07)
7
33
 
8
34
  **Note:** Version bump only for package @webiny/cli
@@ -22,6 +22,12 @@ const { getUser, getProjectEnvironment, updateUserLastActiveOn } = require("./ut
22
22
  let projectEnvironment;
23
23
 
24
24
  const getEnvironmentHookHandler = async (args, context) => {
25
+ // If the project isn't linked with WCP, do nothing.
26
+ const wcpProjectId = context.project.config.id || process.env.WCP_PROJECT_ID;
27
+ if (!wcpProjectId) {
28
+ return;
29
+ }
30
+
25
31
  // For development purposes, we allow setting the WCP_PROJECT_ENVIRONMENT env var directly.
26
32
  if (process.env.WCP_PROJECT_ENVIRONMENT) {
27
33
  // If we have WCP_PROJECT_ENVIRONMENT env var, we set the WCP_PROJECT_ENVIRONMENT_API_KEY too.
@@ -30,12 +36,6 @@ const getEnvironmentHookHandler = async (args, context) => {
30
36
  return;
31
37
  }
32
38
 
33
- // If the project isn't activated, do nothing.
34
- const wcpProjectId = context.project.config.id || process.env.WCP_PROJECT_ID;
35
- if (!wcpProjectId) {
36
- return;
37
- }
38
-
39
39
  // The `id` has the orgId/projectId structure, for example `my-org-x/my-project-y`.
40
40
  const [orgId, projectId] = wcpProjectId.split("/");
41
41
 
@@ -183,7 +183,7 @@ module.exports.command = () => ({
183
183
  context.project.config.id || process.env.WCP_PROJECT_ID
184
184
  );
185
185
 
186
- // If we have `orgId` and `projectId` in PAT's meta data, let's immediately activate the project.
186
+ // If we have `orgId` and `projectId` in PAT's metadata, let's immediately link the project.
187
187
  if (pat.meta && pat.meta.orgId && pat.meta.projectId) {
188
188
  await sleep();
189
189
 
@@ -192,7 +192,7 @@ module.exports.command = () => ({
192
192
  const { orgId, projectId } = pat.meta;
193
193
 
194
194
  const id = `${orgId}/${projectId}`;
195
- console.log(`Project ${chalk.green(id)} detected. Initializing...`);
195
+ console.log(`Project ${chalk.green(id)} detected. Linking...`);
196
196
 
197
197
  await sleep();
198
198
 
@@ -202,7 +202,7 @@ module.exports.command = () => ({
202
202
  projectId
203
203
  });
204
204
 
205
- console.log(`Project ${context.success.hl(id)} initialized successfully.`);
205
+ console.log(`Project ${context.success.hl(id)} linked successfully.`);
206
206
  projectInitialized = true;
207
207
  }
208
208
 
@@ -213,8 +213,8 @@ module.exports.command = () => ({
213
213
 
214
214
  if (!projectInitialized) {
215
215
  console.log(
216
- `‣ initialize your project via the ${chalk.green(
217
- "yarn webiny project init"
216
+ `‣ link your project via the ${chalk.green(
217
+ "yarn webiny project link"
218
218
  )} command`
219
219
  );
220
220
  }
@@ -12,9 +12,27 @@ module.exports.command = () => [
12
12
  ["project <command>"],
13
13
  `Webiny project-related commands`,
14
14
  projectCommand => {
15
+ projectCommand.command(
16
+ "link",
17
+ `Link a Webiny project with Webiny Control Panel (WCP)`,
18
+ command => {
19
+ yargs.option("debug", {
20
+ describe: `Turn on debug logs`,
21
+ type: "boolean"
22
+ });
23
+ yargs.option("debug-level", {
24
+ default: 1,
25
+ describe: `Set the debug logs verbosity level`,
26
+ type: "number"
27
+ });
28
+ command.example("$0 project link");
29
+ },
30
+ () => handler({ context })
31
+ );
32
+
15
33
  projectCommand.command(
16
34
  "init",
17
- `Initialize a Webiny project`,
35
+ `Initialize a Webiny project (deprecated, please use the link command instead)`,
18
36
  command => {
19
37
  yargs.option("debug", {
20
38
  describe: `Turn on debug logs`,
@@ -39,13 +57,13 @@ const handler = async ({ context }) => {
39
57
  // Check login.
40
58
  const user = await getUser();
41
59
 
42
- // User already initialized a project?
60
+ // User already linked a project?
43
61
  const { id: orgProjectId } = context.project.config;
44
62
  if (orgProjectId) {
45
63
  const [, projectId] = orgProjectId.split("/");
46
64
  const project = user.projects.find(item => item.id === projectId);
47
65
  if (project) {
48
- console.log(`Your ${chalk.green(orgProjectId)} project has already been initialized.`);
66
+ console.log(`Your ${chalk.green(orgProjectId)} project has already been linked.`);
49
67
 
50
68
  const prompt = inquirer.createPromptModule();
51
69
  const { proceed } = await prompt({
@@ -170,7 +188,7 @@ const handler = async ({ context }) => {
170
188
  console.log(
171
189
  `${chalk.green("✔")} Project ${context.success.hl(
172
190
  selectedProject.name
173
- )} initialized successfully.`
191
+ )} linked successfully.`
174
192
  );
175
193
 
176
194
  await sleep();
@@ -69,6 +69,16 @@ module.exports.getProjectEnvironment = async ({
69
69
  environmentId,
70
70
  apiKey
71
71
  }) => {
72
+ if (apiKey) {
73
+ return request(getWcpGqlApiUrl(), GET_ENVIRONMENT, { apiKey })
74
+ .then(response => response.projects.getEnvironment)
75
+ .catch(() => {
76
+ throw new Error(
77
+ `It seems the API key you provided is incorrect or disabled. Please double check the API key and try again.`
78
+ );
79
+ });
80
+ }
81
+
72
82
  const pat = localStorage().get("wcpPat");
73
83
  if (!pat) {
74
84
  throw new Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/cli",
3
- "version": "5.32.0",
3
+ "version": "5.33.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.32.0",
17
- "@webiny/wcp": "5.32.0",
16
+ "@webiny/telemetry": "5.33.0-beta.1",
17
+ "@webiny/wcp": "5.33.0-beta.1",
18
18
  "boolean": "3.1.4",
19
19
  "camelcase": "5.3.1",
20
20
  "chalk": "4.1.2",
@@ -64,5 +64,5 @@
64
64
  ]
65
65
  }
66
66
  },
67
- "gitHead": "1227aa53c68afa4ccd518c8a4344195a2b8e354b"
67
+ "gitHead": "537fe39e2309315f01aa41b1e4cacddccee9a10b"
68
68
  }