@webiny/cli 5.29.0-beta.2 → 5.30.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 +29 -0
- package/commands/wcp/hooks.js +43 -34
- package/commands/wcp/login.js +3 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
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.30.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.30.0-beta.0...v5.30.0-beta.1) (2022-07-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @webiny/cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [5.30.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.29.0...v5.30.0-beta.0) (2022-07-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* assign WCP project ID via WCP_PROJECT_ID ([ef55575](https://github.com/webiny/webiny-js/commit/ef55575323737151a0f6675471e6964703ac7513))
|
|
20
|
+
* reorganize code and add support for WCP_PROJECT_ID env var ([6e77c52](https://github.com/webiny/webiny-js/commit/6e77c520068d66547f4dd0bbf9b4d3b11a470179))
|
|
21
|
+
* typescript to 4.7.4 ([#2527](https://github.com/webiny/webiny-js/issues/2527)) ([ee24a3a](https://github.com/webiny/webiny-js/commit/ee24a3a995942ee2588e615e42f604ed7418390a))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# [5.29.0](https://github.com/webiny/webiny-js/compare/v5.29.0-beta.2...v5.29.0) (2022-06-28)
|
|
28
|
+
|
|
29
|
+
**Note:** Version bump only for package @webiny/cli
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
6
35
|
# [5.29.0-beta.2](https://github.com/webiny/webiny-js/compare/v5.29.0-beta.1...v5.29.0-beta.2) (2022-06-27)
|
|
7
36
|
|
|
8
37
|
**Note:** Version bump only for package @webiny/cli
|
package/commands/wcp/hooks.js
CHANGED
|
@@ -7,6 +7,18 @@ const { getUser, getProjectEnvironment, updateUserLastActiveOn } = require("./ut
|
|
|
7
7
|
* - WCP_PROJECT_ENVIRONMENT_API_KEY - for easier access, we also set the API key
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* There are multiple ways the hooks below prepare the WCP-enabled project for deployment.
|
|
12
|
+
* 1. If `WCP_PROJECT_ENVIRONMENT` metadata env var is defined, we decrypt it, retrieve the
|
|
13
|
+
* API key from it, and assign it as the `WCP_PROJECT_ENVIRONMENT_API_KEY` env var.
|
|
14
|
+
* 2. If `WCP_PROJECT_ENVIRONMENT_API_KEY` env var is defined, then we use that as the
|
|
15
|
+
* project environment API key. We use that to load the project environment data
|
|
16
|
+
* and to also assign the `WCP_PROJECT_ENVIRONMENT` metadata env var.
|
|
17
|
+
* 3. If none of the above is defined, we retrieve (or create) the project environment,
|
|
18
|
+
* retrieve its API key and again assign it as `WCP_PROJECT_ENVIRONMENT_API_KEY` env var.
|
|
19
|
+
* As in 2), we also assign the `WCP_PROJECT_ENVIRONMENT` metadata env var.
|
|
20
|
+
*/
|
|
21
|
+
|
|
10
22
|
let projectEnvironment;
|
|
11
23
|
|
|
12
24
|
module.exports = () => [
|
|
@@ -14,39 +26,36 @@ module.exports = () => [
|
|
|
14
26
|
type: "hook-before-deploy",
|
|
15
27
|
name: "hook-before-deploy-environment-get-environment",
|
|
16
28
|
async hook(args, context) {
|
|
17
|
-
//
|
|
18
|
-
if (!context.project.config.id) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
29
|
+
// For development purposes, we allow setting the WCP_PROJECT_ENVIRONMENT env var directly.
|
|
22
30
|
if (process.env.WCP_PROJECT_ENVIRONMENT) {
|
|
23
31
|
// If we have WCP_PROJECT_ENVIRONMENT env var, we set the WCP_PROJECT_ENVIRONMENT_API_KEY too.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
process.env.WCP_PROJECT_ENVIRONMENT_API_KEY =
|
|
29
|
-
decryptedProjectEnvironment.apiKey;
|
|
30
|
-
}
|
|
32
|
+
const decryptedProjectEnvironment = decrypt(process.env.WCP_PROJECT_ENVIRONMENT);
|
|
33
|
+
process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = decryptedProjectEnvironment.apiKey;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
31
36
|
|
|
37
|
+
// If the project isn't activated, do nothing.
|
|
38
|
+
const wcpProjectId = context.project.config.id || process.env.WCP_PROJECT_ID;
|
|
39
|
+
if (!wcpProjectId) {
|
|
32
40
|
return;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
// The `id` has the orgId/projectId structure, for example `my-org-x/my-project-y`.
|
|
36
|
-
const
|
|
37
|
-
const [orgId, projectId] = orgProject.split("/");
|
|
38
|
-
|
|
39
|
-
const isValidId = orgId && projectId;
|
|
40
|
-
if (!isValidId) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
`It seems the project ID, specified in "webiny.project.ts" file, is invalid.`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
44
|
+
const [orgId, projectId] = wcpProjectId.split("/");
|
|
45
45
|
|
|
46
46
|
const apiKey = process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
|
|
47
|
+
|
|
48
|
+
let projectEnvironment;
|
|
47
49
|
if (apiKey) {
|
|
48
50
|
projectEnvironment = await getProjectEnvironment({ apiKey });
|
|
49
51
|
} else {
|
|
52
|
+
const isValidId = orgId && projectId;
|
|
53
|
+
if (!isValidId) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`It seems the project ID, specified in "webiny.project.ts" file, is invalid.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
// If there is no API key, that means we need to retrieve the currently logged-in user.
|
|
51
60
|
const user = await getUser();
|
|
52
61
|
const project = user.projects.find(item => item.id === projectId);
|
|
@@ -64,24 +73,25 @@ module.exports = () => [
|
|
|
64
73
|
});
|
|
65
74
|
}
|
|
66
75
|
|
|
76
|
+
if (projectEnvironment.org.id !== orgId) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Cannot proceed with the deployment because the "${projectEnvironment.name}" project environment doesn't belong to the "${orgId}" organization. Please check your WCP project ID (currently set to "${wcpProjectId}").`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (projectEnvironment.project.id !== projectId) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Cannot proceed with the deployment because the "${projectEnvironment.name}" project environment doesn't belong to the "${wcpProjectId}" project. Please check your WCP project ID (currently set to "${wcpProjectId}").`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
67
88
|
if (projectEnvironment && projectEnvironment.status !== "enabled") {
|
|
68
89
|
throw new Error(
|
|
69
90
|
`Cannot proceed with the deployment because the "${projectEnvironment.name}" project environment has been disabled.`
|
|
70
91
|
);
|
|
71
92
|
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
// Within this hook, we're setting the `WCP_PROJECT_ENVIRONMENT` env variable, which can then be used in
|
|
75
|
-
// build / deploy steps. For example, we pass it to GraphQL and Headless CMS Lambda functions.
|
|
76
|
-
{
|
|
77
|
-
type: "hook-before-deploy",
|
|
78
|
-
name: "hook-before-deploy-project-environment",
|
|
79
|
-
async hook() {
|
|
80
|
-
if (!projectEnvironment) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
93
|
|
|
84
|
-
//
|
|
94
|
+
// Assign `WCP_PROJECT_ENVIRONMENT` and `WCP_PROJECT_ENVIRONMENT_API_KEY`
|
|
85
95
|
const wcpProjectEnvironment = {
|
|
86
96
|
id: projectEnvironment.id,
|
|
87
97
|
apiKey: projectEnvironment.apiKey,
|
|
@@ -93,7 +103,6 @@ module.exports = () => [
|
|
|
93
103
|
process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = projectEnvironment.apiKey;
|
|
94
104
|
}
|
|
95
105
|
},
|
|
96
|
-
// Within this hook, we're updating user's "last active" field.
|
|
97
106
|
{
|
|
98
107
|
type: "hook-before-deploy",
|
|
99
108
|
name: "hook-before-deploy-update-last-active-on",
|
package/commands/wcp/login.js
CHANGED
|
@@ -179,7 +179,9 @@ module.exports.command = () => ({
|
|
|
179
179
|
`${chalk.green("✔")} You've successfully logged in to Webiny Control Panel.`
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
-
let projectInitialized = Boolean(
|
|
182
|
+
let projectInitialized = Boolean(
|
|
183
|
+
context.project.config.id || process.env.WCP_PROJECT_ID
|
|
184
|
+
);
|
|
183
185
|
|
|
184
186
|
// If we have `orgId` and `projectId` in PAT's meta data, let's immediately activate the project.
|
|
185
187
|
if (pat.meta && pat.meta.orgId && pat.meta.projectId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.30.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.30.0-beta.1",
|
|
17
|
+
"@webiny/wcp": "5.30.0-beta.1",
|
|
18
18
|
"boolean": "3.1.4",
|
|
19
19
|
"camelcase": "5.3.1",
|
|
20
20
|
"chalk": "4.1.2",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"pirates": "4.0.5",
|
|
31
31
|
"semver": "7.3.7",
|
|
32
32
|
"ts-morph": "11.0.3",
|
|
33
|
-
"typescript": "4.
|
|
33
|
+
"typescript": "4.7.4",
|
|
34
34
|
"uniqid": "5.4.0",
|
|
35
35
|
"yargs": "17.5.1"
|
|
36
36
|
},
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
]
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "d3b1e74ec1077a608fe40dfd3aba237b1b29a458"
|
|
70
70
|
}
|