@webiny/cli 0.0.0-unstable.de38392959 → 0.0.0-unstable.df7a8bb475
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/README.md +10 -6
- package/bin.js +10 -33
- package/files/duplicates.json +1 -0
- package/files/references.json +1 -0
- package/index.js +2 -2
- package/package.json +16 -54
- package/utils/ensureSameWebinyPackageVersions.js +99 -0
- package/utils/suppressPunycodeWarnings.js +7 -0
- package/cli.js +0 -86
- package/commands/about/getNpxVersion.js +0 -10
- package/commands/about/getPulumiVersions.js +0 -43
- package/commands/about/getYarnVersion.js +0 -10
- package/commands/about/index.js +0 -93
- package/commands/index.js +0 -21
- package/commands/run/index.js +0 -38
- package/commands/telemetry/index.js +0 -29
- package/commands/upgrade/index.js +0 -108
- package/commands/wcp/hooks.js +0 -133
- package/commands/wcp/index.js +0 -8
- package/commands/wcp/login.js +0 -227
- package/commands/wcp/logout.js +0 -28
- package/commands/wcp/project.js +0 -202
- package/commands/wcp/utils/getProjectEnvironment.js +0 -120
- package/commands/wcp/utils/getUser.js +0 -100
- package/commands/wcp/utils/getWcpOrgProjectId.js +0 -9
- package/commands/wcp/utils/getWcpPat.js +0 -5
- package/commands/wcp/utils/getWcpProjectId.js +0 -3
- package/commands/wcp/utils/index.js +0 -21
- package/commands/wcp/utils/setProjectId.js +0 -44
- package/commands/wcp/utils/setWcpPat.js +0 -5
- package/commands/wcp/utils/sleep.js +0 -1
- package/commands/wcp/utils/updateUserLastActiveOn.js +0 -28
- package/commands/wcp/whoami.js +0 -43
- package/context.js +0 -137
- package/index.d.ts +0 -3
- package/types.d.ts +0 -113
- package/utils/PluginsContainer.js +0 -49
- package/utils/createProjectApplicationWorkspace.js +0 -16
- package/utils/getApiProjectApplicationFolder.js +0 -12
- package/utils/getProject.js +0 -48
- package/utils/getProjectApplication.js +0 -87
- package/utils/importModule.js +0 -43
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -26
- package/utils/loadEnvVariables.js +0 -54
- package/utils/localStorage.js +0 -44
- package/utils/log.js +0 -67
- package/utils/sendEvent.js +0 -15
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { GracefulError } from "@webiny/cli-core";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export { GracefulError };
|
package/package.json
CHANGED
|
@@ -1,68 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cli",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.df7a8bb475",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
|
-
"bin": {
|
|
6
|
-
"webiny": "./bin.js"
|
|
7
|
-
},
|
|
8
6
|
"repository": {
|
|
9
7
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/webiny/webiny-js.git"
|
|
11
|
-
|
|
8
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"webiny": "./bin.js"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"description": "A command line interface (CLI) for managing Webiny projects.",
|
|
14
|
+
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/
|
|
17
|
-
"@webiny/
|
|
18
|
-
"boolean": "3.2.0",
|
|
19
|
-
"camelcase": "5.3.1",
|
|
20
|
-
"chalk": "4.1.2",
|
|
21
|
-
"dotenv": "8.6.0",
|
|
16
|
+
"@webiny/cli-core": "0.0.0-unstable.df7a8bb475",
|
|
17
|
+
"@webiny/system-requirements": "0.0.0-unstable.df7a8bb475",
|
|
22
18
|
"execa": "5.1.1",
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"ncp": "2.0.0",
|
|
29
|
-
"open": "8.4.0",
|
|
30
|
-
"pirates": "4.0.5",
|
|
31
|
-
"semver": "7.5.4",
|
|
32
|
-
"ts-morph": "11.0.3",
|
|
33
|
-
"typescript": "4.7.4",
|
|
34
|
-
"uniqid": "5.4.0",
|
|
35
|
-
"yargs": "17.6.2"
|
|
19
|
+
"tsx": "4.21.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/lodash": "4.17.23",
|
|
23
|
+
"@webiny/build-tools": "0.0.0-unstable.df7a8bb475"
|
|
36
24
|
},
|
|
37
|
-
"license": "MIT",
|
|
38
25
|
"publishConfig": {
|
|
39
26
|
"access": "public",
|
|
40
27
|
"directory": "."
|
|
41
28
|
},
|
|
42
|
-
"
|
|
43
|
-
"ignoreDirs": [
|
|
44
|
-
"/create/template/",
|
|
45
|
-
"/node_modules/",
|
|
46
|
-
"/dist/"
|
|
47
|
-
],
|
|
48
|
-
"ignore": {
|
|
49
|
-
"src": [
|
|
50
|
-
"@webiny/project-utils",
|
|
51
|
-
"@webiny/api-file-manager",
|
|
52
|
-
"@webiny/cli-plugin-deploy-pulumi",
|
|
53
|
-
"@webiny/api",
|
|
54
|
-
"@webiny/handler-client",
|
|
55
|
-
"@webiny/api-elasticsearch",
|
|
56
|
-
"@webiny/api-tenancy",
|
|
57
|
-
"@webiny/api-security",
|
|
58
|
-
"@webiny/api-i18n",
|
|
59
|
-
"@webiny/api-i18n-content",
|
|
60
|
-
"@webiny/api-page-builder",
|
|
61
|
-
"@webiny/api-prerendering-service",
|
|
62
|
-
"@webiny/api-form-builder",
|
|
63
|
-
"@webiny/api-headless-cms"
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"gitHead": "de38392959f2692d1feb08945a3588cd80e4924c"
|
|
29
|
+
"gitHead": "df7a8bb4755a1da047f0af8c56bdb649cc81bf7d"
|
|
68
30
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const execa = require("execa");
|
|
2
|
+
const logger = require("./log");
|
|
3
|
+
|
|
4
|
+
const DEBUG_FLAG = "--debug";
|
|
5
|
+
const usingDebugFlag = process.argv.includes(DEBUG_FLAG);
|
|
6
|
+
|
|
7
|
+
const SKIP_WEBINY_VERSIONS_CHECK_FLAG = "--no-package-versions-check";
|
|
8
|
+
const skippingWebinyVersionsCheck = process.argv.includes(SKIP_WEBINY_VERSIONS_CHECK_FLAG);
|
|
9
|
+
|
|
10
|
+
function listWebinyPackageVersions() {
|
|
11
|
+
const { stdout } = execa.sync("yarn", ["info", "@webiny/*", "--name-only", "--all", "--json"], {
|
|
12
|
+
encoding: "utf-8"
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Each line is a JSON string, so parse them individually
|
|
16
|
+
const lines = stdout
|
|
17
|
+
.trim()
|
|
18
|
+
.split("\n")
|
|
19
|
+
.map(line => JSON.parse(line));
|
|
20
|
+
|
|
21
|
+
const versionMap = new Map();
|
|
22
|
+
|
|
23
|
+
for (const entry of lines) {
|
|
24
|
+
// An example entry: "@webiny/cli@npm:5.42.3"
|
|
25
|
+
const match = entry.match(/^(@webiny\/[^@]+)@npm:(.+)$/);
|
|
26
|
+
if (!match) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const [, pkg, version] = match;
|
|
31
|
+
if (!versionMap.has(pkg)) {
|
|
32
|
+
versionMap.set(pkg, new Set());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
versionMap.get(pkg).add(version);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return versionMap;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function ensureSameWebinyPackageVersions() {
|
|
42
|
+
// Just in case, we want to allow users to skip the check.
|
|
43
|
+
if (skippingWebinyVersionsCheck) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let webinyVersions;
|
|
48
|
+
try {
|
|
49
|
+
webinyVersions = listWebinyPackageVersions();
|
|
50
|
+
} catch (e) {
|
|
51
|
+
const message = ["Failed to inspect Webiny package versions."];
|
|
52
|
+
|
|
53
|
+
if (!usingDebugFlag) {
|
|
54
|
+
message.push(
|
|
55
|
+
`For more information, try running with ${logger.warning.hl(DEBUG_FLAG)}.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
message.push("Learn more: https://webiny.link/webiny-package-versions-check");
|
|
60
|
+
|
|
61
|
+
logger.warning(message.join(" "));
|
|
62
|
+
if (usingDebugFlag) {
|
|
63
|
+
logger.debug(e);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let hasMismatch = false;
|
|
71
|
+
const mismatchedPackages = [];
|
|
72
|
+
for (const [pkg, versions] of webinyVersions.entries()) {
|
|
73
|
+
if (versions.size > 1) {
|
|
74
|
+
hasMismatch = true;
|
|
75
|
+
mismatchedPackages.push([pkg, versions]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (hasMismatch) {
|
|
80
|
+
const message = [
|
|
81
|
+
"The following Webiny packages have mismatched versions:",
|
|
82
|
+
"",
|
|
83
|
+
...mismatchedPackages.map(([pkg, versions]) => {
|
|
84
|
+
return `‣ ${pkg}: ${Array.from(versions).join(", ")}`;
|
|
85
|
+
}),
|
|
86
|
+
"",
|
|
87
|
+
`Please ensure all Webiny packages are using the same version. If you think this is a mistake, you can also skip this check by appending the ${logger.error.hl(
|
|
88
|
+
SKIP_WEBINY_VERSIONS_CHECK_FLAG
|
|
89
|
+
)} flag. Learn more: https://webiny.link/webiny-package-versions-check`
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
logger.error(message.join("\n"));
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
ensureSameWebinyPackageVersions
|
|
99
|
+
};
|
package/cli.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const yargs = require("yargs");
|
|
3
|
-
|
|
4
|
-
// Disable help processing until after plugins are imported.
|
|
5
|
-
yargs.help(false);
|
|
6
|
-
|
|
7
|
-
// Loads environment variables from multiple sources.
|
|
8
|
-
require("./utils/loadEnvVariables");
|
|
9
|
-
|
|
10
|
-
const { blue, red } = require("chalk");
|
|
11
|
-
const context = require("./context");
|
|
12
|
-
const { createCommands } = require("./commands");
|
|
13
|
-
|
|
14
|
-
yargs
|
|
15
|
-
.usage("Usage: $0 <command> [options]")
|
|
16
|
-
.demandCommand(1)
|
|
17
|
-
.recommendCommands()
|
|
18
|
-
.scriptName("webiny")
|
|
19
|
-
.epilogue(
|
|
20
|
-
`To find more information, docs and tutorials, see ${blue("https://www.webiny.com/docs")}.`
|
|
21
|
-
)
|
|
22
|
-
.epilogue(`Want to contribute? ${blue("https://github.com/webiny/webiny-js")}.`)
|
|
23
|
-
.fail(function (msg, error, yargs) {
|
|
24
|
-
if (msg) {
|
|
25
|
-
if (msg.includes("Not enough non-option arguments")) {
|
|
26
|
-
console.log();
|
|
27
|
-
context.error(red("Command was not invoked as expected!"));
|
|
28
|
-
context.info(
|
|
29
|
-
`Some non-optional arguments are missing. See the usage examples printed below.`
|
|
30
|
-
);
|
|
31
|
-
console.log();
|
|
32
|
-
yargs.showHelp();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (msg.includes("Missing required argument")) {
|
|
37
|
-
const args = msg
|
|
38
|
-
.split(":")[1]
|
|
39
|
-
.split(",")
|
|
40
|
-
.map(v => v.trim());
|
|
41
|
-
|
|
42
|
-
console.log();
|
|
43
|
-
context.error(red("Command was not invoked as expected!"));
|
|
44
|
-
context.info(
|
|
45
|
-
`Missing required argument(s): ${args
|
|
46
|
-
.map(arg => red(arg))
|
|
47
|
-
.join(", ")}. See the usage examples printed below.`
|
|
48
|
-
);
|
|
49
|
-
console.log();
|
|
50
|
-
yargs.showHelp();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
console.log();
|
|
54
|
-
context.error(red("Command execution was aborted!"));
|
|
55
|
-
context.error(msg);
|
|
56
|
-
console.log();
|
|
57
|
-
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (error) {
|
|
62
|
-
context.error(error.message);
|
|
63
|
-
// Unfortunately, yargs doesn't provide passed args here, so we had to do it via process.argv.
|
|
64
|
-
if (process.argv.includes("--debug")) {
|
|
65
|
-
context.debug(error);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
console.log();
|
|
69
|
-
const plugins = context.plugins.byType("cli-command-error");
|
|
70
|
-
for (let i = 0; i < plugins.length; i++) {
|
|
71
|
-
const plugin = plugins[i];
|
|
72
|
-
plugin.handle({
|
|
73
|
-
error,
|
|
74
|
-
context
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
process.exit(1);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
(async () => {
|
|
83
|
-
await createCommands(yargs, context);
|
|
84
|
-
// Enable help and run the CLI.
|
|
85
|
-
yargs.help().argv;
|
|
86
|
-
})();
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
};
|
package/commands/about/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const about = require("./about");
|
|
2
|
-
const run = require("./run");
|
|
3
|
-
const telemetry = require("./telemetry");
|
|
4
|
-
const upgrade = require("./upgrade");
|
|
5
|
-
|
|
6
|
-
module.exports.createCommands = async (yargs, context) => {
|
|
7
|
-
context.plugins.register(about, run, telemetry, upgrade);
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
const wcp = require("./wcp");
|
|
11
|
-
context.plugins.register(wcp);
|
|
12
|
-
} catch {
|
|
13
|
-
// Skip WCP command
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
await context.loadUserPlugins();
|
|
17
|
-
|
|
18
|
-
context.plugins.byType("cli-command").forEach(plugin => {
|
|
19
|
-
plugin.create({ yargs, context });
|
|
20
|
-
});
|
|
21
|
-
};
|
package/commands/run/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const camelCase = require("camelcase");
|
|
2
|
-
const findUp = require("find-up");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
type: "cli-command",
|
|
7
|
-
name: "cli-command-run",
|
|
8
|
-
create({ yargs, context }) {
|
|
9
|
-
yargs.command(
|
|
10
|
-
"run <command> [options]",
|
|
11
|
-
`Run command defined in webiny.config.{js,ts}.\nNote: run from folder containing webiny.config.{js,ts} file.`,
|
|
12
|
-
yargs => {
|
|
13
|
-
yargs.positional("command", {
|
|
14
|
-
describe: `Command to run in webiny.config.{js,ts}`,
|
|
15
|
-
type: "string"
|
|
16
|
-
});
|
|
17
|
-
},
|
|
18
|
-
async argv => {
|
|
19
|
-
const configFile = findUp.sync(["webiny.config.ts", "webiny.config.js"]);
|
|
20
|
-
let config = context.import(configFile);
|
|
21
|
-
|
|
22
|
-
const command = camelCase(argv.command);
|
|
23
|
-
if (typeof config === "function") {
|
|
24
|
-
config = config({
|
|
25
|
-
options: { ...argv, cwd: path.dirname(configFile) },
|
|
26
|
-
context
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (config.commands && typeof config.commands[command] === "function") {
|
|
31
|
-
return await config.commands[command]({ ...argv }, context);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
throw Error(`Command "${command}" is not defined in "${configFile}"!`);
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const telemetry = require("@webiny/telemetry/cli");
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
type: "cli-command",
|
|
5
|
-
name: "cli-command-telemetry",
|
|
6
|
-
create({ yargs, context }) {
|
|
7
|
-
yargs.command("enable-telemetry", "Enable anonymous telemetry.", async () => {
|
|
8
|
-
telemetry.enable();
|
|
9
|
-
await telemetry.sendEvent({ event: "enable-telemetry" });
|
|
10
|
-
context.info(
|
|
11
|
-
`Webiny telemetry is now %s! Thank you for helping us in making Webiny better!`,
|
|
12
|
-
"enabled"
|
|
13
|
-
);
|
|
14
|
-
context.info(
|
|
15
|
-
`For more information, please visit the following link: https://www.webiny.com/telemetry.`
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
yargs.command("disable-telemetry", "Disable anonymous telemetry.", async () => {
|
|
20
|
-
await telemetry.sendEvent({ event: "disable-telemetry" });
|
|
21
|
-
telemetry.disable();
|
|
22
|
-
context.info(`Webiny telemetry is now %s!`, "disabled");
|
|
23
|
-
context.info(
|
|
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"
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const { red } = require("chalk");
|
|
2
|
-
const execa = require("execa");
|
|
3
|
-
const semver = require("semver");
|
|
4
|
-
|
|
5
|
-
module.exports = [
|
|
6
|
-
{
|
|
7
|
-
type: "cli-command",
|
|
8
|
-
name: "cli-command-upgrade",
|
|
9
|
-
create({ yargs, context }) {
|
|
10
|
-
yargs.example("$0 upgrade");
|
|
11
|
-
yargs.command(
|
|
12
|
-
"upgrade",
|
|
13
|
-
`Run an upgrade script for currently installed version of Webiny`,
|
|
14
|
-
yargs => {
|
|
15
|
-
yargs.option("skip-checks", {
|
|
16
|
-
describe: "Do not perform CLI version and Git tree checks.",
|
|
17
|
-
type: "boolean",
|
|
18
|
-
default: false
|
|
19
|
-
});
|
|
20
|
-
yargs.option("debug", {
|
|
21
|
-
default: false,
|
|
22
|
-
describe: `Turn on debug logs`,
|
|
23
|
-
type: "boolean"
|
|
24
|
-
});
|
|
25
|
-
yargs.option("use-version", {
|
|
26
|
-
describe:
|
|
27
|
-
"Use upgrade script for a specific version. Should only be used for development/testing purposes.",
|
|
28
|
-
type: "string"
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
async argv => {
|
|
32
|
-
if (!argv.skipChecks) {
|
|
33
|
-
// Before doing any upgrading, there must not be any active changes in the current branch.
|
|
34
|
-
let gitStatus = "";
|
|
35
|
-
try {
|
|
36
|
-
let { stdout } = execa.sync("git", ["status", "--porcelain"]);
|
|
37
|
-
gitStatus = stdout.trim();
|
|
38
|
-
} catch {}
|
|
39
|
-
|
|
40
|
-
if (gitStatus) {
|
|
41
|
-
console.error(
|
|
42
|
-
red(
|
|
43
|
-
"This git repository has untracked files or uncommitted changes:"
|
|
44
|
-
) +
|
|
45
|
-
"\n\n" +
|
|
46
|
-
gitStatus
|
|
47
|
-
.split("\n")
|
|
48
|
-
.map(line => line.match(/ .*/g)[0].trim())
|
|
49
|
-
.join("\n") +
|
|
50
|
-
"\n\n" +
|
|
51
|
-
red(
|
|
52
|
-
"Remove untracked files, stash or commit any changes, and try again."
|
|
53
|
-
)
|
|
54
|
-
);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const defaultUpgradeTargetVersion = semver.coerce(context.version).version;
|
|
60
|
-
|
|
61
|
-
const command = [
|
|
62
|
-
"https://github.com/webiny/webiny-upgrades",
|
|
63
|
-
argv.useVersion || defaultUpgradeTargetVersion
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
if (yargs.argv.debug) {
|
|
67
|
-
context.debug("npx", ...command);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const npx = execa("npx", command, {
|
|
71
|
-
env: {
|
|
72
|
-
FORCE_COLOR: true
|
|
73
|
-
},
|
|
74
|
-
stdin: process.stdin
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
npx.stdout.on("data", data => {
|
|
78
|
-
const lines = data.toString().replace(/\n$/, "").split("\n");
|
|
79
|
-
for (let i = 0; i < lines.length; i++) {
|
|
80
|
-
const line = lines[i];
|
|
81
|
-
try {
|
|
82
|
-
const json = JSON.parse(line);
|
|
83
|
-
if (json.type === "error") {
|
|
84
|
-
context.error(
|
|
85
|
-
"An error occurred while performing the upgrade."
|
|
86
|
-
);
|
|
87
|
-
console.log(json.message);
|
|
88
|
-
if (yargs.argv.debug) {
|
|
89
|
-
context.debug(json.data.stack);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
} catch {
|
|
93
|
-
// Not JSON, let's just print the line then.
|
|
94
|
-
console.log(line);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
npx.stderr.on("data", data => {
|
|
100
|
-
console.log(data.toString());
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
await npx;
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
];
|