@webiny/cli 6.0.0-alpha.5 → 6.0.0-rc.0
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 +9 -97
- package/files/duplicates.json +1 -1
- package/files/references.json +1 -1
- package/index.js +2 -4
- package/package.json +16 -56
- package/commands/about/getDatabaseSetup.js +0 -45
- package/commands/about/getNpmVersion.js +0 -5
- package/commands/about/getNpxVersion.js +0 -5
- package/commands/about/getPulumiVersions.js +0 -43
- package/commands/about/getYarnVersion.js +0 -5
- package/commands/about/index.js +0 -97
- package/commands/index.js +0 -21
- package/commands/run/index.js +0 -38
- package/commands/telemetry/index.js +0 -31
- 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 -228
- package/commands/wcp/logout.js +0 -28
- package/commands/wcp/project.js +0 -203
- 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 -19
- package/commands/wcp/utils/setProjectId.js +0 -44
- package/commands/wcp/utils/setWcpPat.js +0 -5
- package/commands/wcp/utils/updateUserLastActiveOn.js +0 -28
- package/commands/wcp/whoami.js +0 -43
- package/context.js +0 -137
- package/files/README.md +0 -1
- package/index.d.ts +0 -5
- package/regions.d.ts +0 -6
- package/regions.js +0 -30
- package/types.d.ts +0 -234
- package/utils/PluginsContainer.js +0 -49
- package/utils/createProjectApplicationWorkspace.js +0 -16
- package/utils/getProject.js +0 -48
- package/utils/getProjectApplication.js +0 -83
- package/utils/importModule.js +0 -43
- package/utils/index.d.ts +0 -28
- package/utils/index.js +0 -28
- package/utils/loadEnvVariables.js +0 -63
- package/utils/localStorage.js +0 -44
- package/utils/log.js +0 -67
- package/utils/sendEvent.js +0 -11
- package/utils/sleep.js +0 -3
- package/utils/sleepSync.js +0 -8
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const { dirname, basename, join, relative } = require("path");
|
|
2
|
-
const findUp = require("find-up");
|
|
3
|
-
const getProject = require("./getProject");
|
|
4
|
-
const { importModule } = require("./importModule");
|
|
5
|
-
const glob = require("fast-glob");
|
|
6
|
-
|
|
7
|
-
const appConfigs = ["webiny.application.js", "webiny.application.ts"];
|
|
8
|
-
|
|
9
|
-
module.exports = args => {
|
|
10
|
-
// Using "Pulumi.yaml" for the backwards compatibility.
|
|
11
|
-
const applicationRootFile = findUp.sync(appConfigs.concat("Pulumi.yaml"), { cwd: args.cwd });
|
|
12
|
-
|
|
13
|
-
if (!applicationRootFile) {
|
|
14
|
-
throw new Error(`Could not detect project application in given directory (${args.cwd}).`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const rootFile = applicationRootFile.replace(/\\/g, "/");
|
|
18
|
-
const projectAppRootPath = dirname(rootFile);
|
|
19
|
-
|
|
20
|
-
let applicationConfig;
|
|
21
|
-
if (appConfigs.includes(basename(rootFile))) {
|
|
22
|
-
applicationConfig = importModule(rootFile);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let id, name, description;
|
|
26
|
-
if (applicationConfig) {
|
|
27
|
-
id = applicationConfig.id;
|
|
28
|
-
name = applicationConfig.name;
|
|
29
|
-
description = applicationConfig.description;
|
|
30
|
-
} else {
|
|
31
|
-
name = basename(projectAppRootPath);
|
|
32
|
-
description = name;
|
|
33
|
-
id = name;
|
|
34
|
-
}
|
|
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
|
-
return {
|
|
47
|
-
id,
|
|
48
|
-
name,
|
|
49
|
-
description,
|
|
50
|
-
root: projectAppRootPath,
|
|
51
|
-
paths: {
|
|
52
|
-
relative: projectAppRelativePath,
|
|
53
|
-
absolute: projectAppRootPath,
|
|
54
|
-
workspace: projectAppWorkspacePath
|
|
55
|
-
},
|
|
56
|
-
config: applicationConfig,
|
|
57
|
-
project,
|
|
58
|
-
get packages() {
|
|
59
|
-
const webinyConfigs = glob.sync(
|
|
60
|
-
join(projectAppRootPath, "**/webiny.config*.{ts,js}").replace(/\\/g, "/")
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
return webinyConfigs.map(config => {
|
|
64
|
-
const dirPath = dirname(config);
|
|
65
|
-
const packageJson = require(join(dirPath, "package.json"));
|
|
66
|
-
return {
|
|
67
|
-
name: packageJson.name,
|
|
68
|
-
paths: {
|
|
69
|
-
absolute: dirname(config),
|
|
70
|
-
relative: relative(project.root, dirPath),
|
|
71
|
-
root: dirname(config),
|
|
72
|
-
packageJson: join(dirPath, "package.json"),
|
|
73
|
-
config
|
|
74
|
-
},
|
|
75
|
-
packageJson,
|
|
76
|
-
get config() {
|
|
77
|
-
return require(config).default || require(config);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
};
|
package/utils/importModule.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const { addHook } = require("pirates");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Add support for TS
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
addHook(
|
|
10
|
-
code => {
|
|
11
|
-
const ts = require("typescript");
|
|
12
|
-
const { outputText } = ts.transpileModule(code, {
|
|
13
|
-
compilerOptions: {
|
|
14
|
-
target: "es6",
|
|
15
|
-
allowJs: true,
|
|
16
|
-
allowSyntheticDefaultImports: true,
|
|
17
|
-
esModuleInterop: true,
|
|
18
|
-
outDir: "bin",
|
|
19
|
-
moduleResolution: "node",
|
|
20
|
-
module: "commonjs"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return outputText;
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
exts: [".ts"],
|
|
28
|
-
matcher: () => true
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
module.exports.importModule = configPath => {
|
|
33
|
-
if (!fs.existsSync(configPath)) {
|
|
34
|
-
throw Error(`"${configPath}" does not exist!`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const extension = path.extname(configPath);
|
|
38
|
-
if (extension === ".ts") {
|
|
39
|
-
return require(configPath).default;
|
|
40
|
-
} else {
|
|
41
|
-
return require(configPath);
|
|
42
|
-
}
|
|
43
|
-
};
|
package/utils/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Project, ProjectApplication } from "../types";
|
|
2
|
-
|
|
3
|
-
export interface IGetProjectParams {
|
|
4
|
-
cwd: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export declare function getProject(params?: IGetProjectParams): Project;
|
|
8
|
-
|
|
9
|
-
export interface IGetProjectApplicationParams {
|
|
10
|
-
cwd: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export declare function getProjectApplication(
|
|
14
|
-
params: IGetProjectApplicationParams
|
|
15
|
-
): ProjectApplication;
|
|
16
|
-
|
|
17
|
-
export declare function sendEvent(event: string, properties?: Record<string, any>): Promise<void>;
|
|
18
|
-
|
|
19
|
-
export declare function sleepSync(ms?: number): void;
|
|
20
|
-
|
|
21
|
-
export declare const log: {
|
|
22
|
-
log: ((...args: any[]) => void) & { hl: (message: string) => string };
|
|
23
|
-
info: ((...args: any[]) => void) & { hl: (message: string) => string };
|
|
24
|
-
success: ((...args: any[]) => void) & { hl: (message: string) => string };
|
|
25
|
-
debug: ((...args: any[]) => void) & { hl: (message: string) => string };
|
|
26
|
-
warning: ((...args: any[]) => void) & { hl: (message: string) => string };
|
|
27
|
-
error: ((...args: any[]) => void) & { hl: (message: string) => string };
|
|
28
|
-
};
|
package/utils/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { importModule } = require("./importModule");
|
|
2
|
-
const createProjectApplicationWorkspace = require("./createProjectApplicationWorkspace");
|
|
3
|
-
const getProject = require("./getProject");
|
|
4
|
-
const getProjectApplication = require("./getProjectApplication");
|
|
5
|
-
const localStorage = require("./localStorage");
|
|
6
|
-
const log = require("./log");
|
|
7
|
-
const sendEvent = require("./sendEvent");
|
|
8
|
-
const PluginsContainer = require("./PluginsContainer");
|
|
9
|
-
const sleep = require("./sleep");
|
|
10
|
-
const sleepSync = require("./sleepSync");
|
|
11
|
-
|
|
12
|
-
const noop = () => {
|
|
13
|
-
// Do nothing.
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
createProjectApplicationWorkspace,
|
|
18
|
-
getProject,
|
|
19
|
-
getProjectApplication,
|
|
20
|
-
importModule,
|
|
21
|
-
localStorage,
|
|
22
|
-
log,
|
|
23
|
-
noop,
|
|
24
|
-
sendEvent,
|
|
25
|
-
PluginsContainer,
|
|
26
|
-
sleep,
|
|
27
|
-
sleepSync
|
|
28
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const yargs = require("yargs");
|
|
3
|
-
const log = require("./log");
|
|
4
|
-
const getProject = require("./getProject");
|
|
5
|
-
const { boolean } = require("boolean");
|
|
6
|
-
|
|
7
|
-
// Load environment variables from following sources:
|
|
8
|
-
// - `webiny.project.ts` file
|
|
9
|
-
// - `.env` file
|
|
10
|
-
// - `.env.{PASSED_ENVIRONMENT}` file
|
|
11
|
-
|
|
12
|
-
const project = getProject();
|
|
13
|
-
|
|
14
|
-
// `webiny.project.ts` file.
|
|
15
|
-
// Environment variables defined via the `env` property.
|
|
16
|
-
if (project.config.env) {
|
|
17
|
-
Object.assign(process.env, project.config.env);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// `.env.{PASSED_ENVIRONMENT}` and `.env` files.
|
|
21
|
-
let paths = [path.join(project.root, ".env")];
|
|
22
|
-
|
|
23
|
-
if (yargs.argv.env) {
|
|
24
|
-
paths.push(path.join(project.root, `.env.${yargs.argv.env}`));
|
|
25
|
-
}
|
|
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
|
-
|
|
36
|
-
// Let's load environment variables
|
|
37
|
-
for (let i = 0; i < paths.length; i++) {
|
|
38
|
-
const path = paths[i];
|
|
39
|
-
const { error } = require("dotenv").config({ path });
|
|
40
|
-
if (boolean(yargs.argv.debug)) {
|
|
41
|
-
if (error) {
|
|
42
|
-
log.debug(`No environment file found on ${log.debug.hl(path)}.`);
|
|
43
|
-
} else {
|
|
44
|
-
log.success(`Successfully loaded environment variables from ${log.success.hl(path)}.`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Feature flags defined via the `featureFlags` property.
|
|
50
|
-
// We set twice, to be available for both backend and frontend application code.
|
|
51
|
-
// TODO: one day we might want to sync this up a bit.
|
|
52
|
-
if (project.config.featureFlags) {
|
|
53
|
-
process.env.WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
|
|
54
|
-
process.env.REACT_APP_WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// With 5.38.0, we are hiding the `WEBINY_ELASTICSEARCH_INDEX_LOCALE` env variable and always setting it to `true`.
|
|
58
|
-
// This is because this variable is not something users should be concerned with, nor should they be able to change it.
|
|
59
|
-
// In order to ensure backwards compatibility, we first check if the variable is set, and if it is, we don't override it.
|
|
60
|
-
const esIndexLocaleEnvVarExists = "WEBINY_ELASTICSEARCH_INDEX_LOCALE" in process.env;
|
|
61
|
-
if (!esIndexLocaleEnvVarExists) {
|
|
62
|
-
process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE = "true";
|
|
63
|
-
}
|
package/utils/localStorage.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// This is a small class that enables us to store some useful
|
|
2
|
-
// data into the .webiny folder, located in the project root.
|
|
3
|
-
// For example, we are saving the path entered while creating
|
|
4
|
-
// GraphQL services, so that the user doesn't have to type
|
|
5
|
-
// the same paths over and over.
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const getProject = require("./getProject");
|
|
9
|
-
|
|
10
|
-
module.exports = function (filename = "cli.json") {
|
|
11
|
-
const project = getProject();
|
|
12
|
-
const DOT_WEBINY = path.join(project.root, ".webiny");
|
|
13
|
-
const dataFilePath = path.join(DOT_WEBINY, filename);
|
|
14
|
-
|
|
15
|
-
let data = {};
|
|
16
|
-
if (fs.existsSync(dataFilePath)) {
|
|
17
|
-
try {
|
|
18
|
-
data = JSON.parse(fs.readFileSync(dataFilePath));
|
|
19
|
-
} catch (e) {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`Could not parse Webiny CLI's locale storage data file located at ${dataFilePath}.`
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
set(key, value) {
|
|
28
|
-
data[key] = value;
|
|
29
|
-
|
|
30
|
-
if (!fs.existsSync(DOT_WEBINY)) {
|
|
31
|
-
fs.mkdirSync(DOT_WEBINY);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
fs.writeFileSync(dataFilePath, JSON.stringify(data));
|
|
35
|
-
return data;
|
|
36
|
-
},
|
|
37
|
-
get(key) {
|
|
38
|
-
if (!key) {
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
return data[key];
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
package/utils/log.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const chalk = require("chalk");
|
|
2
|
-
|
|
3
|
-
const logColors = {
|
|
4
|
-
log: v => v,
|
|
5
|
-
info: chalk.blueBright,
|
|
6
|
-
error: chalk.red,
|
|
7
|
-
warning: chalk.yellow,
|
|
8
|
-
debug: chalk.gray,
|
|
9
|
-
success: chalk.green
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const colorizePlaceholders = (type, string) => {
|
|
13
|
-
return string.replace(/\%[a-zA-Z]/g, match => {
|
|
14
|
-
return logColors[type](match);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const webinyLog = (type, ...args) => {
|
|
19
|
-
const prefix = `webiny ${logColors[type](type)}: `;
|
|
20
|
-
|
|
21
|
-
const [first, ...rest] = args;
|
|
22
|
-
if (typeof first === "string") {
|
|
23
|
-
return console.log(prefix + colorizePlaceholders(type, first), ...rest);
|
|
24
|
-
}
|
|
25
|
-
return console.log(prefix, first, ...rest);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const functions = {
|
|
29
|
-
log(...args) {
|
|
30
|
-
webinyLog("log", ...args);
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
info(...args) {
|
|
34
|
-
webinyLog("info", ...args);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
success(...args) {
|
|
38
|
-
webinyLog("success", ...args);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
debug(...args) {
|
|
42
|
-
webinyLog("debug", ...args);
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
warning(...args) {
|
|
46
|
-
webinyLog("warning", ...args);
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
error(...args) {
|
|
50
|
-
webinyLog("error", ...args);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
functions.log.highlight = chalk.highlight;
|
|
55
|
-
functions.log.hl = chalk.highlight;
|
|
56
|
-
functions.info.highlight = chalk.blue;
|
|
57
|
-
functions.info.hl = chalk.blueBright;
|
|
58
|
-
functions.success.highlight = chalk.green;
|
|
59
|
-
functions.success.hl = chalk.green;
|
|
60
|
-
functions.debug.highlight = chalk.gray;
|
|
61
|
-
functions.debug.hl = chalk.gray;
|
|
62
|
-
functions.warning.highlight = chalk.yellow;
|
|
63
|
-
functions.warning.hl = chalk.yellow;
|
|
64
|
-
functions.error.highlight = chalk.red;
|
|
65
|
-
functions.error.hl = chalk.red;
|
|
66
|
-
|
|
67
|
-
module.exports = functions;
|
package/utils/sendEvent.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const { sendEvent } = require("@webiny/telemetry/cli");
|
|
2
|
-
const getProject = require("./getProject");
|
|
3
|
-
|
|
4
|
-
module.exports = (event, properties) => {
|
|
5
|
-
const project = getProject();
|
|
6
|
-
if (project.config.cli && project.config.cli.telemetry === false) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return sendEvent({ event, properties });
|
|
11
|
-
};
|
package/utils/sleep.js
DELETED