@webiny/cli 5.28.0-beta.0 → 5.29.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,51 @@
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.29.0-beta.1](https://github.com/webiny/webiny-js/compare/v5.29.0-beta.0...v5.29.0-beta.1) (2022-06-25)
7
+
8
+ **Note:** Version bump only for package @webiny/cli
9
+
10
+
11
+
12
+
13
+
14
+ # [5.29.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.28.0...v5.29.0-beta.0) (2022-06-25)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add comment ([c135622](https://github.com/webiny/webiny-js/commit/c135622f8b57c11099003a6cdd46df0a2143c82b))
20
+ * ensure `WCP_PROJECT_ENVIRONMENT_API_KEY` env var ([857a9fd](https://github.com/webiny/webiny-js/commit/857a9fd1994e7723f2265b46ea14c61cbfc8d253))
21
+ * if `WCP_PROJECT_ENVIRONMENT` is present, do not load env ([8c16540](https://github.com/webiny/webiny-js/commit/8c165407fcaf681c9bd99c8d42b6cfecf4c7ce99))
22
+ * move `api` into `apps` folder ([0e9da03](https://github.com/webiny/webiny-js/commit/0e9da03426f5743e88273f6831dd5ba1fd6807aa))
23
+ * only retrieve user if needed ([af4605d](https://github.com/webiny/webiny-js/commit/af4605d3cd24ac44bfb28951ce844b797c7f6b6d))
24
+ * project must be activated in order for WCP interaction to happen ([10d3da5](https://github.com/webiny/webiny-js/commit/10d3da5766a1bf063ccc73f6a33e0b29658d74bc))
25
+ * remove JSON.stringify ([ec44664](https://github.com/webiny/webiny-js/commit/ec446648e1972916769476baf72d5aa6ba004a0a))
26
+ * remove unused code ([d64de94](https://github.com/webiny/webiny-js/commit/d64de94f38dd1f4e4b4df43defa27011b554fc96))
27
+ * rename `getWcpGraphQlApiUrl` to `getWcpGqlApiUrl` ([d18bfad](https://github.com/webiny/webiny-js/commit/d18bfada9a6b512781fbbdb55f95f6e518f9ff7f))
28
+ * rename name of hook ([0ff7b91](https://github.com/webiny/webiny-js/commit/0ff7b91f4cb5321ac9d64b6bc8412a70b8a435c7))
29
+ * update dependencies ([9c28fe9](https://github.com/webiny/webiny-js/commit/9c28fe9625b4d61fbe4137124c36f15022c79db3))
30
+ * update execa across all packages ([01189c5](https://github.com/webiny/webiny-js/commit/01189c595521c69f31aba85692d15622d842b231))
31
+ * use fs-extra and synchronize dep version ([48a0605](https://github.com/webiny/webiny-js/commit/48a0605f8cc8487c81bd52f7b7db7308e5cbda04))
32
+
33
+
34
+ ### Features
35
+
36
+ * introduce `createProjectApplicationWorkspace` function ([1cb7279](https://github.com/webiny/webiny-js/commit/1cb7279dab83f91a960484d7d1b1f012c9629026))
37
+ * introduce licensing functionality and updates ([f314b00](https://github.com/webiny/webiny-js/commit/f314b007882c21a9808581de6bc8e55d3b7ed448))
38
+
39
+
40
+
41
+
42
+
43
+ # [5.28.0](https://github.com/webiny/webiny-js/compare/v5.28.0-beta.0...v5.28.0) (2022-06-07)
44
+
45
+ **Note:** Version bump only for package @webiny/cli
46
+
47
+
48
+
49
+
50
+
6
51
  # [5.28.0-beta.0](https://github.com/webiny/webiny-js/compare/v5.27.0...v5.28.0-beta.0) (2022-06-07)
7
52
 
8
53
  **Note:** Version bump only for package @webiny/cli
package/README.md CHANGED
@@ -4,4 +4,4 @@
4
4
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
5
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
6
 
7
- A pluggable tool to run commands within a Webiny project.
7
+ A pluggable tool to run commands within a Webiny project.
package/commands/index.js CHANGED
@@ -4,13 +4,8 @@ const wcp = require("./wcp");
4
4
  const upgrade = require("./upgrade");
5
5
 
6
6
  module.exports.createCommands = async (yargs, context) => {
7
- context.plugins.register(run, telemetry, upgrade);
7
+ context.plugins.register(run, telemetry, upgrade, wcp);
8
8
 
9
- // For now, only register WCP related commands if
10
- // `WCP_APP_URL` and `WCP_API_URL` env vars are defined.
11
- if (process.env.WCP_APP_URL && process.env.WCP_API_URL) {
12
- context.plugins.register(wcp);
13
- }
14
9
  await context.loadUserPlugins();
15
10
 
16
11
  context.plugins.byType("cli-command").forEach(plugin => {
@@ -1,67 +1,111 @@
1
- const { getUser, getProjectEnvironmentBySlug, updateUserLastActiveOn } = require("./utils");
1
+ const { encrypt, decrypt } = require("@webiny/wcp");
2
+ const { getUser, getProjectEnvironment, updateUserLastActiveOn } = require("./utils");
3
+
4
+ /**
5
+ * The two environment variables we set via these hooks are the following:
6
+ * - WCP_PROJECT_ENVIRONMENT - contains encrypted data about the deployed project environment
7
+ * - WCP_PROJECT_ENVIRONMENT_API_KEY - for easier access, we also set the API key
8
+ */
9
+
10
+ let projectEnvironment;
2
11
 
3
12
  module.exports = () => [
4
- // Within this hook, we're setting the `WCP_ENVIRONMENT_API_KEY` env variable, which can then be used in
5
- // build / deploy steps. For example, we pass it to GraphQL and Headless CMS Lambda functions.
6
13
  {
7
14
  type: "hook-before-deploy",
8
- name: "hook-before-deploy-environment-api-key",
15
+ name: "hook-before-deploy-environment-get-environment",
9
16
  async hook(args, context) {
10
- // If the `WCP_ENVIRONMENT_API_KEY` has already been assigned, no need to do anything.
11
- if (process.env.WCP_ENVIRONMENT_API_KEY) {
17
+ // If the project isn't activated, do nothing.
18
+ if (!context.project.config.id) {
12
19
  return;
13
20
  }
14
21
 
15
- const environment = await getProjectEnvironment(args, context);
16
- if (environment) {
17
- process.env.WCP_ENVIRONMENT_API_KEY = environment.apiKey;
22
+ if (process.env.WCP_PROJECT_ENVIRONMENT) {
23
+ // If we have WCP_PROJECT_ENVIRONMENT env var, we set the WCP_PROJECT_ENVIRONMENT_API_KEY too.
24
+ if (!process.env.WCP_PROJECT_ENVIRONMENT_API_KEY) {
25
+ const decryptedProjectEnvironment = decrypt(
26
+ process.env.WCP_PROJECT_ENVIRONMENT
27
+ );
28
+ process.env.WCP_PROJECT_ENVIRONMENT_API_KEY =
29
+ decryptedProjectEnvironment.apiKey;
30
+ }
31
+
32
+ return;
33
+ }
34
+
35
+ // The `id` has the orgId/projectId structure, for example `my-org-x/my-project-y`.
36
+ const orgProject = context.project.config.id;
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
+ }
45
+
46
+ const apiKey = process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
47
+ if (apiKey) {
48
+ projectEnvironment = await getProjectEnvironment({ apiKey });
49
+ } else {
50
+ // If there is no API key, that means we need to retrieve the currently logged-in user.
51
+ const user = await getUser();
52
+ const project = user.projects.find(item => item.id === projectId);
53
+ if (!project) {
54
+ throw new Error(
55
+ `It seems you don't belong to the current project or the current project has been deleted.`
56
+ );
57
+ }
58
+
59
+ projectEnvironment = await getProjectEnvironment({
60
+ orgId,
61
+ projectId,
62
+ userId: user.id,
63
+ environmentId: args.env
64
+ });
65
+ }
66
+
67
+ if (projectEnvironment && projectEnvironment.status !== "enabled") {
68
+ throw new Error(
69
+ `Cannot proceed with the deployment because the "${projectEnvironment.name}" project environment has been disabled.`
70
+ );
71
+ }
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;
18
82
  }
83
+
84
+ // Ensure the correct API key is set into environment variable.
85
+ const wcpProjectEnvironment = {
86
+ id: projectEnvironment.id,
87
+ apiKey: projectEnvironment.apiKey,
88
+ org: { id: projectEnvironment.org.id },
89
+ project: { id: projectEnvironment.project.id }
90
+ };
91
+
92
+ process.env.WCP_PROJECT_ENVIRONMENT = encrypt(wcpProjectEnvironment);
93
+ process.env.WCP_PROJECT_ENVIRONMENT_API_KEY = projectEnvironment.apiKey;
19
94
  }
20
95
  },
21
96
  // Within this hook, we're updating user's "last active" field.
22
97
  {
23
98
  type: "hook-before-deploy",
24
99
  name: "hook-before-deploy-update-last-active-on",
25
- async hook(args, context) {
100
+ async hook() {
101
+ if (!projectEnvironment) {
102
+ return;
103
+ }
104
+
26
105
  // Is this a user environment? If so, let's update his "last active" field.
27
- const environment = await getProjectEnvironment(args, context);
28
- if (environment && environment.user) {
106
+ if (projectEnvironment.user) {
29
107
  await updateUserLastActiveOn();
30
108
  }
31
109
  }
32
110
  }
33
111
  ];
34
-
35
- const getProjectEnvironment = async (args, context) => {
36
- // If the project isn't activated, also do nothing.
37
- if (!context.project.config.id) {
38
- return;
39
- }
40
-
41
- // The `id` has the orgId/projectId structure, for example `my-org-x/my-project-y`.
42
- const orgProject = context.project.config.id;
43
- const [orgId, projectId] = orgProject.split("/");
44
-
45
- const isValidId = orgId && projectId;
46
- if (!isValidId) {
47
- throw new Error(
48
- `It seems the project ID, specified in "webiny.project.ts" file, is invalid.`
49
- );
50
- }
51
-
52
- // Check login.
53
- const user = await getUser();
54
- const project = user.projects.find(item => item.id === projectId);
55
- if (!project) {
56
- throw new Error(
57
- `It seems you don't belong to the current project or the current project has been deleted.`
58
- );
59
- }
60
-
61
- return getProjectEnvironmentBySlug({
62
- orgId,
63
- projectId,
64
- environmentSlug: args.env,
65
- userId: user.id
66
- });
67
- };
@@ -1,7 +1,8 @@
1
1
  const open = require("open");
2
2
  const { GraphQLClient } = require("graphql-request");
3
- const { WCP_GRAPHQL_API_URL, WCP_APP_URL, setProjectId, setWcpPat, sleep } = require("./utils");
3
+ const { setProjectId, setWcpPat, sleep } = require("./utils");
4
4
  const chalk = require("chalk");
5
+ const { getWcpGqlApiUrl, getWcpAppUrl } = require("@webiny/wcp");
5
6
 
6
7
  // 120 retries * 2000ms interval = 4 minutes until the command returns an error.
7
8
  const LOGIN_RETRIES_COUNT = 30;
@@ -73,7 +74,7 @@ module.exports.command = () => ({
73
74
  });
74
75
  },
75
76
  async ({ debug, debugLevel, pat: patFromParams }) => {
76
- const graphQLClient = new GraphQLClient(WCP_GRAPHQL_API_URL);
77
+ const graphQLClient = new GraphQLClient(getWcpGqlApiUrl());
77
78
 
78
79
  let pat;
79
80
 
@@ -115,7 +116,7 @@ module.exports.command = () => ({
115
116
  const queryParams = `pat=${generatedPat}&pat_name=${encodeURIComponent(
116
117
  "Webiny CLI"
117
118
  )}&ref=cli`;
118
- const openUrl = `${WCP_APP_URL}/login/cli?${queryParams}`;
119
+ const openUrl = `${getWcpAppUrl()}/login/cli?${queryParams}`;
119
120
 
120
121
  debug && context.debug(`Opening ${context.debug.hl(openUrl)}...`);
121
122
  await open(openUrl);
@@ -165,7 +166,7 @@ module.exports.command = () => ({
165
166
 
166
167
  if (!result) {
167
168
  throw new Error(
168
- `Could not login. Did you complete the sign in / sign up process at ${WCP_APP_URL}?`
169
+ `Could not login. Did you complete the sign in / sign up process at ${getWcpAppUrl()}?`
169
170
  );
170
171
  }
171
172
 
@@ -1,5 +1,6 @@
1
1
  const { localStorage, log } = require("@webiny/cli/utils");
2
2
  const { request } = require("graphql-request");
3
+ const { getWcpGqlApiUrl } = require("@webiny/wcp");
3
4
 
4
5
  const ENVIRONMENT_FIELDS = /* GraphQL */ `
5
6
  fragment EnvironmentFields on Environment {
@@ -61,11 +62,12 @@ const GET_ENVIRONMENT = /* GraphQL */ `
61
62
  }
62
63
  `;
63
64
 
64
- module.exports.getProjectEnvironmentBySlug = async ({
65
+ module.exports.getProjectEnvironment = async ({
65
66
  orgId,
66
67
  projectId,
67
68
  userId,
68
- environmentSlug
69
+ environmentId,
70
+ apiKey
69
71
  }) => {
70
72
  const pat = localStorage().get("wcpPat");
71
73
  if (!pat) {
@@ -76,30 +78,30 @@ module.exports.getProjectEnvironmentBySlug = async ({
76
78
  );
77
79
  }
78
80
 
79
- const { WCP_GRAPHQL_API_URL } = require(".");
80
81
  const headers = { authorization: pat };
81
82
  return request(
82
- WCP_GRAPHQL_API_URL,
83
+ getWcpGqlApiUrl(),
83
84
  GET_ENVIRONMENT,
84
85
  {
85
86
  orgId,
86
87
  projectId,
87
88
  userId,
88
- environmentId: environmentSlug
89
+ environmentId,
90
+ apiKey
89
91
  },
90
92
  headers
91
93
  )
92
94
  .then(async response => response.projects.getEnvironment)
93
95
  .catch(() => {
94
96
  return request(
95
- WCP_GRAPHQL_API_URL,
97
+ getWcpGqlApiUrl(),
96
98
  CREATE_ENVIRONMENT,
97
99
  {
98
100
  orgId,
99
101
  projectId,
100
102
  userId,
101
103
  data: {
102
- name: environmentSlug
104
+ name: environmentId
103
105
  }
104
106
  },
105
107
  headers
@@ -1,6 +1,7 @@
1
1
  const { log } = require("@webiny/cli/utils");
2
2
  const { request } = require("graphql-request");
3
3
  const { getWcpPat } = require("./getWcpPat");
4
+ const { getWcpGqlApiUrl } = require("@webiny/wcp");
4
5
 
5
6
  const GET_CURRENT_USER = /* GraphQL */ `
6
7
  query GetUser {
@@ -54,26 +55,25 @@ module.exports.getUser = async () => {
54
55
  const pat = getWcpPat();
55
56
  if (!pat) {
56
57
  throw new Error(
57
- `It seems you are not logged in. Please login using the ${log.error.hl(
58
+ `It seems you are not logged into your WCP project. Please log in using the ${log.error.hl(
58
59
  "yarn webiny login"
59
- )} command.`
60
+ )} command. If you are not using WCP, make sure you don't have an "id" property in your "webiny.project.ts" file.`
60
61
  );
61
62
  }
62
63
 
63
64
  try {
64
- const { WCP_GRAPHQL_API_URL } = require(".");
65
65
  const headers = { authorization: pat };
66
- user = await request(WCP_GRAPHQL_API_URL, GET_CURRENT_USER, {}, headers).then(
66
+ user = await request(getWcpGqlApiUrl(), GET_CURRENT_USER, {}, headers).then(
67
67
  async response => {
68
68
  const user = response.users.getCurrentUser;
69
69
 
70
- const orgs = await request(WCP_GRAPHQL_API_URL, LIST_ORGS, {}, headers).then(
70
+ const orgs = await request(getWcpGqlApiUrl(), LIST_ORGS, {}, headers).then(
71
71
  async response => {
72
72
  const orgs = response.orgs.listOrgs.data;
73
73
  for (let i = 0; i < orgs.length; i++) {
74
74
  const org = orgs[i];
75
75
  org.projects = await request(
76
- WCP_GRAPHQL_API_URL,
76
+ getWcpGqlApiUrl(),
77
77
  LIST_PROJECTS,
78
78
  { orgId: org.id },
79
79
  headers
@@ -90,7 +90,7 @@ module.exports.getUser = async () => {
90
90
  );
91
91
  } catch {
92
92
  throw new Error(
93
- `It seems the personal access token is incorrect or does not exist. Please log out and again log in using the ${log.error.hl(
93
+ `It seems the personal access token is incorrect or does not exist. Please log out and log in again using the ${log.error.hl(
94
94
  "yarn webiny login"
95
95
  )} command.`
96
96
  );
@@ -1,9 +1,5 @@
1
- const WCP_APP_URL = process.env.WCP_APP_URL || "https://wcp.webiny.com";
2
- const WCP_API_URL = process.env.WCP_API_URL || "https://api.wcp.webiny.com/graphql";
3
- const WCP_GRAPHQL_API_URL = WCP_API_URL + "/graphql";
4
-
5
1
  const { getUser } = require("./getUser");
6
- const { getProjectEnvironmentBySlug } = require("./getProjectEnvironmentBySlug");
2
+ const { getProjectEnvironment } = require("./getProjectEnvironment");
7
3
  const { updateUserLastActiveOn } = require("./updateUserLastActiveOn");
8
4
  const { setProjectId } = require("./setProjectId");
9
5
  const { setWcpPat } = require("./setWcpPat");
@@ -12,13 +8,10 @@ const { sleep } = require("./sleep");
12
8
 
13
9
  module.exports = {
14
10
  getUser,
15
- getProjectEnvironmentBySlug,
11
+ getProjectEnvironment,
16
12
  updateUserLastActiveOn,
17
13
  setProjectId,
18
14
  setWcpPat,
19
15
  getWcpPat,
20
- sleep,
21
- WCP_APP_URL,
22
- WCP_API_URL,
23
- WCP_GRAPHQL_API_URL
16
+ sleep
24
17
  };
@@ -1,5 +1,6 @@
1
1
  const { request } = require("graphql-request");
2
2
  const { localStorage, log } = require("@webiny/cli/utils");
3
+ const { getWcpGqlApiUrl } = require("@webiny/wcp");
3
4
 
4
5
  const UPDATE_LAST_ACTIVE_TO_NOW = /* GraphQL */ `
5
6
  mutation UpdateLastActiveToNow {
@@ -22,7 +23,6 @@ module.exports.updateUserLastActiveOn = async () => {
22
23
  );
23
24
  }
24
25
 
25
- const { WCP_GRAPHQL_API_URL } = require(".");
26
26
  const headers = { authorization: pat };
27
- return request(WCP_GRAPHQL_API_URL, UPDATE_LAST_ACTIVE_TO_NOW, {}, headers);
27
+ return request(getWcpGqlApiUrl(), UPDATE_LAST_ACTIVE_TO_NOW, {}, headers);
28
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/cli",
3
- "version": "5.28.0-beta.0",
3
+ "version": "5.29.0-beta.1",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "webiny": "./bin.js"
@@ -13,16 +13,19 @@
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.28.0-beta.0",
16
+ "@webiny/telemetry": "5.29.0-beta.1",
17
+ "@webiny/wcp": "5.29.0-beta.1",
17
18
  "boolean": "3.1.4",
18
19
  "camelcase": "5.3.1",
19
20
  "chalk": "4.1.2",
20
21
  "dotenv": "8.2.0",
21
- "execa": "2.1.0",
22
+ "execa": "5.1.1",
22
23
  "fast-glob": "3.2.7",
23
24
  "find-up": "5.0.0",
25
+ "fs-extra": "9.1.0",
24
26
  "graphql-request": "3.7.0",
25
27
  "inquirer": "7.3.3",
28
+ "ncp": "2.0.0",
26
29
  "open": "8.4.0",
27
30
  "pirates": "4.0.5",
28
31
  "semver": "7.3.7",
@@ -63,5 +66,5 @@
63
66
  ]
64
67
  }
65
68
  },
66
- "gitHead": "6503c7f86cfc90660f005acf72049505bfd4fb76"
69
+ "gitHead": "e4393aa7faa07c7a465ff320d8b4dc51f2f38315"
67
70
  }
@@ -0,0 +1,16 @@
1
+ const util = require("util");
2
+ const fs = require("fs-extra");
3
+ const ncpBase = require("ncp");
4
+ const ncp = util.promisify(ncpBase.ncp);
5
+
6
+ module.exports = async projectApplication => {
7
+ if (await fs.pathExists(projectApplication.paths.workspace)) {
8
+ await fs.remove(projectApplication.paths.workspace);
9
+ }
10
+
11
+ await fs.ensureDir(projectApplication.paths.workspace);
12
+ await ncp(projectApplication.paths.absolute, projectApplication.paths.workspace);
13
+
14
+ // Wait a bit and make sure the files are ready to have its content replaced.
15
+ return new Promise(resolve => setTimeout(resolve, 10));
16
+ };
@@ -0,0 +1,12 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ // This function has been created in order to help preserve backwards compatibility
5
+ // (from 5.29.0, the `api` app has been moved into the `apps/api` directory).
6
+ module.exports = project => {
7
+ if (fs.existsSync(path.join(project.root, "api"))) {
8
+ return "api";
9
+ }
10
+
11
+ return "apps/api";
12
+ };
@@ -1,4 +1,4 @@
1
- const { dirname, basename, join } = require("path");
1
+ const { dirname, basename, join, relative } = require("path");
2
2
  const findUp = require("find-up");
3
3
  const getProject = require("./getProject");
4
4
  const { importModule } = require("./importModule");
@@ -15,31 +15,55 @@ module.exports = args => {
15
15
  }
16
16
 
17
17
  const rootFile = applicationRootFile.replace(/\\/g, "/");
18
- const applicationRoot = dirname(rootFile);
18
+ const projectAppRootPath = dirname(rootFile);
19
19
 
20
20
  let applicationConfig;
21
21
  if (appConfigs.includes(basename(rootFile))) {
22
22
  applicationConfig = importModule(rootFile);
23
23
  }
24
24
 
25
- let name, id;
25
+ let id, name, description;
26
26
  if (applicationConfig) {
27
27
  id = applicationConfig.id;
28
28
  name = applicationConfig.name;
29
+ description = applicationConfig.description;
29
30
  } else {
30
- name = basename(applicationRoot);
31
+ name = basename(projectAppRootPath);
32
+ description = name;
31
33
  id = name;
32
34
  }
33
35
 
36
+ const project = getProject(args);
37
+
38
+ const projectAppRelativePath = relative(project.root, projectAppRootPath);
39
+ const projectAppWorkspacePath = join(
40
+ project.root,
41
+ ".webiny",
42
+ "workspaces",
43
+ projectAppRelativePath
44
+ );
45
+
46
+ // If we're missing the `pulumi` property in the `applicationConfig` object, that
47
+ // means we're dealing with an old project application where all of the Pulumi code is
48
+ // located in user's project. New projects applications have this code abstracted away.
49
+ const type = applicationConfig.pulumi ? "v5-workspaces" : "v5";
50
+
34
51
  return {
35
52
  id,
36
53
  name,
37
- root: applicationRoot,
54
+ description,
55
+ type,
56
+ root: projectAppRootPath,
57
+ paths: {
58
+ relative: projectAppRelativePath,
59
+ absolute: projectAppRootPath,
60
+ workspace: projectAppWorkspacePath
61
+ },
38
62
  config: applicationConfig,
39
- project: getProject(args),
63
+ project,
40
64
  get packages() {
41
65
  const webinyConfigs = glob.sync(
42
- join(applicationRoot, "**/webiny.config*.{ts,js}").replace(/\\/g, "/")
66
+ join(projectAppRootPath, "**/webiny.config*.{ts,js}").replace(/\\/g, "/")
43
67
  );
44
68
 
45
69
  return webinyConfigs.map(config => {
@@ -0,0 +1 @@
1
+ export function getApiProjectApplicationFolder(project: Record<string, any>): boolean;
package/utils/index.js CHANGED
@@ -1,15 +1,19 @@
1
1
  const { importModule } = require("./importModule");
2
+ const createProjectApplicationWorkspace = require("./createProjectApplicationWorkspace");
2
3
  const getProject = require("./getProject");
3
4
  const getProjectApplication = require("./getProjectApplication");
5
+ const getApiProjectApplicationFolder = require("./getApiProjectApplicationFolder");
4
6
  const localStorage = require("./localStorage");
5
7
  const log = require("./log");
6
8
  const sendEvent = require("./sendEvent");
7
9
  const PluginsContainer = require("./PluginsContainer");
8
10
 
9
11
  module.exports = {
10
- importModule,
12
+ createProjectApplicationWorkspace,
13
+ getApiProjectApplicationFolder,
11
14
  getProject,
12
15
  getProjectApplication,
16
+ importModule,
13
17
  localStorage,
14
18
  log,
15
19
  sendEvent,