@webiny/cli 5.40.0-beta.2 → 5.40.0-beta.4
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 +21 -14
- package/commands/about/getDatabaseSetup.js +45 -0
- package/commands/about/getNpmVersion.js +10 -0
- package/commands/about/index.js +23 -19
- package/commands/run/index.js +4 -4
- package/commands/telemetry/index.js +4 -2
- package/commands/upgrade/index.js +4 -4
- package/package.json +5 -4
- package/types.d.ts +59 -0
- package/utils/getProjectApplication.js +2 -6
- package/utils/index.js +0 -2
- package/utils/loadEnvVariables.js +9 -0
- package/utils/sendEvent.js +2 -6
- package/utils/getApiProjectApplicationFolder.js +0 -12
- package/utils/index.d.ts +0 -1
package/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ yargs.help(false);
|
|
|
7
7
|
// Loads environment variables from multiple sources.
|
|
8
8
|
require("./utils/loadEnvVariables");
|
|
9
9
|
|
|
10
|
-
const { blue, red } = require("chalk");
|
|
10
|
+
const { blue, red, bold, bgYellow } = require("chalk");
|
|
11
11
|
const context = require("./context");
|
|
12
12
|
const { createCommands } = require("./commands");
|
|
13
13
|
|
|
@@ -58,22 +58,29 @@ yargs
|
|
|
58
58
|
process.exit(1);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
console.log();
|
|
62
|
+
// Unfortunately, yargs doesn't provide passed args here, so we had to do it via process.argv.
|
|
63
|
+
const debugEnabled = process.argv.includes("--debug");
|
|
64
|
+
if (debugEnabled) {
|
|
65
|
+
context.debug(error);
|
|
66
|
+
} else {
|
|
62
67
|
context.error(error.message);
|
|
63
|
-
|
|
64
|
-
if (process.argv.includes("--debug")) {
|
|
65
|
-
context.debug(error);
|
|
66
|
-
}
|
|
68
|
+
}
|
|
67
69
|
|
|
70
|
+
const gracefulError = error.cause?.gracefulError;
|
|
71
|
+
if (gracefulError instanceof Error) {
|
|
68
72
|
console.log();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
console.log(bgYellow(bold("💡 How can I resolve this?")));
|
|
74
|
+
console.log(gracefulError.message);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const plugins = context.plugins.byType("cli-command-error");
|
|
78
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
79
|
+
const plugin = plugins[i];
|
|
80
|
+
plugin.handle({
|
|
81
|
+
error,
|
|
82
|
+
context
|
|
83
|
+
});
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
process.exit(1);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { getProject } = require("@webiny/cli/utils");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
const DATABASE_SETUPS = {
|
|
6
|
+
DDB: "ddb",
|
|
7
|
+
DDB_ES: "ddb-es",
|
|
8
|
+
DDB_OS: "ddb-os"
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const DATABASE_SETUPS_LABELS = {
|
|
12
|
+
[DATABASE_SETUPS.DDB]: "Amazon DynamoDB",
|
|
13
|
+
[DATABASE_SETUPS.DDB_ES]: "Amazon DynamoDB + Amazon Elasticsearch Service",
|
|
14
|
+
[DATABASE_SETUPS.DDB_OS]: "Amazon DynamoDB + Amazon OpenSearch Service"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// In order to get the database setup, we check for existence of `elasticSearch`
|
|
18
|
+
// or `openSearch` strings within the `apps/core/webiny.application.ts` file.
|
|
19
|
+
const getDatabaseSetup = () => {
|
|
20
|
+
const project = getProject();
|
|
21
|
+
const webinyAppTsPath = path.join(project.root, "apps", "core", "webiny.application.ts");
|
|
22
|
+
|
|
23
|
+
const webinyAppTs = fs.readFileSync(webinyAppTsPath, "utf8");
|
|
24
|
+
if (webinyAppTs.includes("elasticSearch")) {
|
|
25
|
+
return "ddb-es";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (webinyAppTs.includes("openSearch")) {
|
|
29
|
+
return "ddb-os";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return "ddb";
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getDatabaseSetupLabel = () => {
|
|
36
|
+
const setup = getDatabaseSetup();
|
|
37
|
+
return DATABASE_SETUPS_LABELS[setup];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
getDatabaseSetup,
|
|
42
|
+
getDatabaseSetupLabel,
|
|
43
|
+
DATABASE_SETUPS,
|
|
44
|
+
DATABASE_SETUPS_LABELS
|
|
45
|
+
};
|
package/commands/about/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
const NO_VALUE = "-";
|
|
2
|
+
const isCI = require("is-ci");
|
|
2
3
|
|
|
3
4
|
const getData = async context => {
|
|
4
5
|
const { getUser } = require("../wcp/utils");
|
|
5
6
|
const { getNpxVersion } = require("./getNpxVersion");
|
|
7
|
+
const { getNpmVersion } = require("./getNpmVersion");
|
|
6
8
|
const { getPulumiVersions } = require("./getPulumiVersions");
|
|
7
9
|
const { getYarnVersion } = require("./getYarnVersion");
|
|
10
|
+
const { getDatabaseSetupLabel } = require("./getDatabaseSetup");
|
|
8
11
|
|
|
9
12
|
const [pulumiVersion, pulumiAwsVersion] = await getPulumiVersions();
|
|
10
13
|
|
|
14
|
+
const wcpProjectId = process.env.WCP_PROJECT_ID;
|
|
15
|
+
const wcpUser = await getUser().catch(() => null);
|
|
16
|
+
const wcpUsingProjectEnvironmentApiKey = Boolean(process.env.WCP_ENVIRONMENT_API_KEY);
|
|
17
|
+
|
|
11
18
|
return [
|
|
12
19
|
{
|
|
13
20
|
sectionName: "Webiny Project",
|
|
14
21
|
data: {
|
|
15
22
|
Name: context.project.name,
|
|
16
23
|
Version: context.version,
|
|
17
|
-
|
|
24
|
+
"Database Setup": getDatabaseSetupLabel(),
|
|
18
25
|
"Debug Enabled": process.env.DEBUG === "true" ? "Yes" : "No",
|
|
19
26
|
"Feature Flags": process.env.WEBINY_FEATURE_FLAGS || "N/A"
|
|
20
27
|
}
|
|
@@ -22,13 +29,20 @@ const getData = async context => {
|
|
|
22
29
|
{
|
|
23
30
|
sectionName: "Webiny Control Panel (WCP)",
|
|
24
31
|
data: {
|
|
25
|
-
"Project ID":
|
|
26
|
-
User:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
"Project ID": wcpProjectId,
|
|
33
|
+
User: wcpUser?.email || "N/A",
|
|
34
|
+
"Using Project Environment API Key": wcpUsingProjectEnvironmentApiKey ? "Yes" : "No"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
sectionName: "Host",
|
|
39
|
+
data: {
|
|
40
|
+
OS: `${process.platform} (${process.arch})`,
|
|
41
|
+
"Node.js": process.version,
|
|
42
|
+
NPM: await getNpmVersion(),
|
|
43
|
+
NPX: await getNpxVersion(),
|
|
44
|
+
Yarn: await getYarnVersion(),
|
|
45
|
+
"Is CI": isCI ? "Yes" : "No"
|
|
32
46
|
}
|
|
33
47
|
},
|
|
34
48
|
{
|
|
@@ -36,19 +50,9 @@ const getData = async context => {
|
|
|
36
50
|
data: {
|
|
37
51
|
"@pulumi/pulumi": pulumiVersion,
|
|
38
52
|
"@pulumi/aws": pulumiAwsVersion,
|
|
39
|
-
"Used AWS Region": process.env.AWS_REGION,
|
|
40
53
|
"Secrets Provider": process.env.PULUMI_SECRETS_PROVIDER,
|
|
41
54
|
"Using Password": process.env.PULUMI_CONFIG_PASSPHRASE ? "Yes" : "No"
|
|
42
55
|
}
|
|
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
56
|
}
|
|
53
57
|
];
|
|
54
58
|
};
|
|
@@ -84,7 +88,7 @@ module.exports = {
|
|
|
84
88
|
console.log(bold(sectionName));
|
|
85
89
|
|
|
86
90
|
Object.keys(data).forEach(key => {
|
|
87
|
-
console.log(key.padEnd(
|
|
91
|
+
console.log(key.padEnd(36), data[key] || NO_VALUE);
|
|
88
92
|
});
|
|
89
93
|
});
|
|
90
94
|
}
|
package/commands/run/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
const camelCase = require("camelcase");
|
|
2
|
-
const findUp = require("find-up");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
1
|
module.exports = {
|
|
6
2
|
type: "cli-command",
|
|
7
3
|
name: "cli-command-run",
|
|
@@ -16,6 +12,10 @@ module.exports = {
|
|
|
16
12
|
});
|
|
17
13
|
},
|
|
18
14
|
async argv => {
|
|
15
|
+
const camelCase = require("camelcase");
|
|
16
|
+
const findUp = require("find-up");
|
|
17
|
+
const path = require("path");
|
|
18
|
+
|
|
19
19
|
const configFile = findUp.sync(["webiny.config.ts", "webiny.config.js"]);
|
|
20
20
|
let config = context.import(configFile);
|
|
21
21
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const telemetry = require("@webiny/telemetry/cli");
|
|
2
|
-
|
|
3
1
|
module.exports = {
|
|
4
2
|
type: "cli-command",
|
|
5
3
|
name: "cli-command-telemetry",
|
|
6
4
|
create({ yargs, context }) {
|
|
7
5
|
yargs.command("enable-telemetry", "Enable anonymous telemetry.", async () => {
|
|
6
|
+
const telemetry = require("@webiny/telemetry/cli");
|
|
7
|
+
|
|
8
8
|
telemetry.enable();
|
|
9
9
|
await telemetry.sendEvent({ event: "enable-telemetry" });
|
|
10
10
|
context.info(
|
|
@@ -17,6 +17,8 @@ module.exports = {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
yargs.command("disable-telemetry", "Disable anonymous telemetry.", async () => {
|
|
20
|
+
const telemetry = require("@webiny/telemetry/cli");
|
|
21
|
+
|
|
20
22
|
await telemetry.sendEvent({ event: "disable-telemetry" });
|
|
21
23
|
telemetry.disable();
|
|
22
24
|
context.info(`Webiny telemetry is now %s!`, "disabled");
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
const { red } = require("chalk");
|
|
2
|
-
const execa = require("execa");
|
|
3
|
-
const semver = require("semver");
|
|
4
|
-
|
|
5
1
|
module.exports = [
|
|
6
2
|
{
|
|
7
3
|
type: "cli-command",
|
|
@@ -29,6 +25,10 @@ module.exports = [
|
|
|
29
25
|
});
|
|
30
26
|
},
|
|
31
27
|
async argv => {
|
|
28
|
+
const { red } = require("chalk");
|
|
29
|
+
const execa = require("execa");
|
|
30
|
+
const semver = require("semver");
|
|
31
|
+
|
|
32
32
|
if (!argv.skipChecks) {
|
|
33
33
|
// Before doing any upgrading, there must not be any active changes in the current branch.
|
|
34
34
|
let gitStatus = "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cli",
|
|
3
|
-
"version": "5.40.0-beta.
|
|
3
|
+
"version": "5.40.0-beta.4",
|
|
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.40.0-beta.
|
|
17
|
-
"@webiny/wcp": "5.40.0-beta.
|
|
16
|
+
"@webiny/telemetry": "5.40.0-beta.4",
|
|
17
|
+
"@webiny/wcp": "5.40.0-beta.4",
|
|
18
18
|
"boolean": "3.2.0",
|
|
19
19
|
"camelcase": "5.3.1",
|
|
20
20
|
"chalk": "4.1.2",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"fs-extra": "9.1.0",
|
|
26
26
|
"graphql-request": "3.7.0",
|
|
27
27
|
"inquirer": "7.3.3",
|
|
28
|
+
"is-ci": "3.0.1",
|
|
28
29
|
"ncp": "2.0.0",
|
|
29
30
|
"open": "8.4.0",
|
|
30
31
|
"pirates": "4.0.5",
|
|
@@ -64,5 +65,5 @@
|
|
|
64
65
|
]
|
|
65
66
|
}
|
|
66
67
|
},
|
|
67
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "42f3b1c985d6f8317d5c1084838b43a270c79f01"
|
|
68
69
|
}
|
package/types.d.ts
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
* Rename file to types.ts when switching the package to Typescript.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import glob from "fast-glob";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* A simplified plugins container interface, used specifically within the Webiny CLI.
|
|
7
10
|
* Not in relation with "@webiny/plugins" package.
|
|
8
11
|
*/
|
|
9
12
|
export interface PluginsContainer {
|
|
10
13
|
byType<T extends Plugin>(type: T["type"]): T[];
|
|
14
|
+
|
|
11
15
|
byName<T extends Plugin>(name: T["name"]): T;
|
|
12
16
|
}
|
|
13
17
|
|
|
@@ -18,6 +22,7 @@ export interface PluginsContainer {
|
|
|
18
22
|
export interface Plugin {
|
|
19
23
|
type: string;
|
|
20
24
|
name?: string;
|
|
25
|
+
|
|
21
26
|
[key: string]: any;
|
|
22
27
|
}
|
|
23
28
|
|
|
@@ -36,11 +41,65 @@ interface Project {
|
|
|
36
41
|
root: string;
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
export interface ProjectApplication {
|
|
45
|
+
/**
|
|
46
|
+
* Unique ID of the project application.
|
|
47
|
+
*/
|
|
48
|
+
id: string;
|
|
49
|
+
/**
|
|
50
|
+
* Name of the project application.
|
|
51
|
+
*/
|
|
52
|
+
name: string;
|
|
53
|
+
/**
|
|
54
|
+
* Description of the project application.
|
|
55
|
+
*/
|
|
56
|
+
description: string;
|
|
57
|
+
/**
|
|
58
|
+
* Type of the project application.
|
|
59
|
+
*/
|
|
60
|
+
type: string;
|
|
61
|
+
/**
|
|
62
|
+
* Root path of the project application.
|
|
63
|
+
*/
|
|
64
|
+
root: string;
|
|
65
|
+
/**
|
|
66
|
+
* Commonly used paths.
|
|
67
|
+
*/
|
|
68
|
+
paths: {
|
|
69
|
+
relative: string;
|
|
70
|
+
absolute: string;
|
|
71
|
+
workspace: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Project application config (exported via `webiny.application.ts` file).
|
|
75
|
+
*/
|
|
76
|
+
config: Record<string, any>;
|
|
77
|
+
/**
|
|
78
|
+
* Project application package.json.
|
|
79
|
+
*/
|
|
80
|
+
project: Project;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A list of all the packages in the project application.
|
|
84
|
+
*/
|
|
85
|
+
get packages(): Array<{
|
|
86
|
+
name: string;
|
|
87
|
+
paths: {
|
|
88
|
+
root: string;
|
|
89
|
+
packageJson: string;
|
|
90
|
+
config: string;
|
|
91
|
+
};
|
|
92
|
+
packageJson: Record<string, any>;
|
|
93
|
+
get config(): any;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
|
|
39
97
|
/**
|
|
40
98
|
* A type that represents the logging method.
|
|
41
99
|
*/
|
|
42
100
|
interface Log {
|
|
43
101
|
(...args: any): string;
|
|
102
|
+
|
|
44
103
|
hl: (...args: any) => string;
|
|
45
104
|
highlight: (...args: any) => string;
|
|
46
105
|
}
|
|
@@ -43,16 +43,10 @@ module.exports = args => {
|
|
|
43
43
|
projectAppRelativePath
|
|
44
44
|
);
|
|
45
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
|
-
|
|
51
46
|
return {
|
|
52
47
|
id,
|
|
53
48
|
name,
|
|
54
49
|
description,
|
|
55
|
-
type,
|
|
56
50
|
root: projectAppRootPath,
|
|
57
51
|
paths: {
|
|
58
52
|
relative: projectAppRelativePath,
|
|
@@ -72,6 +66,8 @@ module.exports = args => {
|
|
|
72
66
|
return {
|
|
73
67
|
name: packageJson.name,
|
|
74
68
|
paths: {
|
|
69
|
+
absolute: dirname(config),
|
|
70
|
+
relative: relative(project.root, dirPath),
|
|
75
71
|
root: dirname(config),
|
|
76
72
|
packageJson: join(dirPath, "package.json"),
|
|
77
73
|
config
|
package/utils/index.js
CHANGED
|
@@ -2,7 +2,6 @@ const { importModule } = require("./importModule");
|
|
|
2
2
|
const createProjectApplicationWorkspace = require("./createProjectApplicationWorkspace");
|
|
3
3
|
const getProject = require("./getProject");
|
|
4
4
|
const getProjectApplication = require("./getProjectApplication");
|
|
5
|
-
const getApiProjectApplicationFolder = require("./getApiProjectApplicationFolder");
|
|
6
5
|
const localStorage = require("./localStorage");
|
|
7
6
|
const log = require("./log");
|
|
8
7
|
const sendEvent = require("./sendEvent");
|
|
@@ -14,7 +13,6 @@ const noop = () => {
|
|
|
14
13
|
|
|
15
14
|
module.exports = {
|
|
16
15
|
createProjectApplicationWorkspace,
|
|
17
|
-
getApiProjectApplicationFolder,
|
|
18
16
|
getProject,
|
|
19
17
|
getProjectApplication,
|
|
20
18
|
importModule,
|
|
@@ -24,6 +24,15 @@ if (yargs.argv.env) {
|
|
|
24
24
|
paths.push(path.join(project.root, `.env.${yargs.argv.env}`));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// If the `WCP_PROJECT_ID` environment variable is not set already, we check if there's
|
|
28
|
+
// a WCP project ID set via the `webiny.project.ts` config file. If so, we assign it
|
|
29
|
+
// to the `WCP_PROJECT_ID` environment variable.
|
|
30
|
+
if (!process.env.WCP_PROJECT_ID) {
|
|
31
|
+
if (project.config.id) {
|
|
32
|
+
process.env.WCP_PROJECT_ID = project.config.id;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
// Let's load environment variables
|
|
28
37
|
for (let i = 0; i < paths.length; i++) {
|
|
29
38
|
const path = paths[i];
|
package/utils/sendEvent.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
const { sendEvent } = require("@webiny/telemetry/cli");
|
|
2
2
|
const getProject = require("./getProject");
|
|
3
3
|
|
|
4
|
-
module.exports = (
|
|
4
|
+
module.exports = (event, properties) => {
|
|
5
5
|
const project = getProject();
|
|
6
6
|
if (project.config.cli && project.config.cli.telemetry === false) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
return sendEvent({
|
|
11
|
-
event,
|
|
12
|
-
properties,
|
|
13
|
-
extraPayload
|
|
14
|
-
});
|
|
10
|
+
return sendEvent({ event, properties });
|
|
15
11
|
};
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
package/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function getApiProjectApplicationFolder(project: Record<string, any>): boolean;
|