@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.
Files changed (48) hide show
  1. package/README.md +10 -6
  2. package/bin.js +10 -33
  3. package/files/duplicates.json +1 -0
  4. package/files/references.json +1 -0
  5. package/index.js +2 -2
  6. package/package.json +16 -54
  7. package/utils/ensureSameWebinyPackageVersions.js +99 -0
  8. package/utils/suppressPunycodeWarnings.js +7 -0
  9. package/cli.js +0 -86
  10. package/commands/about/getNpxVersion.js +0 -10
  11. package/commands/about/getPulumiVersions.js +0 -43
  12. package/commands/about/getYarnVersion.js +0 -10
  13. package/commands/about/index.js +0 -93
  14. package/commands/index.js +0 -21
  15. package/commands/run/index.js +0 -38
  16. package/commands/telemetry/index.js +0 -29
  17. package/commands/upgrade/index.js +0 -108
  18. package/commands/wcp/hooks.js +0 -133
  19. package/commands/wcp/index.js +0 -8
  20. package/commands/wcp/login.js +0 -227
  21. package/commands/wcp/logout.js +0 -28
  22. package/commands/wcp/project.js +0 -202
  23. package/commands/wcp/utils/getProjectEnvironment.js +0 -120
  24. package/commands/wcp/utils/getUser.js +0 -100
  25. package/commands/wcp/utils/getWcpOrgProjectId.js +0 -9
  26. package/commands/wcp/utils/getWcpPat.js +0 -5
  27. package/commands/wcp/utils/getWcpProjectId.js +0 -3
  28. package/commands/wcp/utils/index.js +0 -21
  29. package/commands/wcp/utils/setProjectId.js +0 -44
  30. package/commands/wcp/utils/setWcpPat.js +0 -5
  31. package/commands/wcp/utils/sleep.js +0 -1
  32. package/commands/wcp/utils/updateUserLastActiveOn.js +0 -28
  33. package/commands/wcp/whoami.js +0 -43
  34. package/context.js +0 -137
  35. package/index.d.ts +0 -3
  36. package/types.d.ts +0 -113
  37. package/utils/PluginsContainer.js +0 -49
  38. package/utils/createProjectApplicationWorkspace.js +0 -16
  39. package/utils/getApiProjectApplicationFolder.js +0 -12
  40. package/utils/getProject.js +0 -48
  41. package/utils/getProjectApplication.js +0 -87
  42. package/utils/importModule.js +0 -43
  43. package/utils/index.d.ts +0 -1
  44. package/utils/index.js +0 -26
  45. package/utils/loadEnvVariables.js +0 -54
  46. package/utils/localStorage.js +0 -44
  47. package/utils/log.js +0 -67
  48. package/utils/sendEvent.js +0 -15
@@ -1,16 +0,0 @@
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
- };
@@ -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
- };
@@ -1,48 +0,0 @@
1
- const findUp = require("find-up");
2
- const { dirname } = require("path");
3
- const { importModule } = require("./importModule");
4
-
5
- const projectConfigs = ["webiny.project.js", "webiny.project.ts"];
6
-
7
- function getRoot({ cwd } = {}) {
8
- let root = findUp.sync(projectConfigs, { cwd });
9
- if (root) {
10
- return dirname(root).replace(/\\/g, "/");
11
- }
12
-
13
- // For backwards compatibility
14
- root = findUp.sync("webiny.root.js", { cwd });
15
- if (root) {
16
- return dirname(root).replace(/\\/g, "/");
17
- }
18
-
19
- throw new Error("Couldn't detect Webiny project.");
20
- }
21
-
22
- function getConfig({ cwd } = {}) {
23
- let path = findUp.sync(projectConfigs, { cwd });
24
- if (path) {
25
- return importModule(path);
26
- }
27
-
28
- path = findUp.sync("webiny.root.js", { cwd });
29
- if (path) {
30
- return require(path);
31
- }
32
-
33
- throw new Error("Couldn't detect Webiny project.");
34
- }
35
-
36
- module.exports = args => {
37
- const root = getRoot(args);
38
- return {
39
- get name() {
40
- // Check "projectName" for backwards compatibility.
41
- return process.env.WEBINY_PROJECT_NAME || this.config.projectName || this.config.name;
42
- },
43
- root,
44
- get config() {
45
- return getConfig(args);
46
- }
47
- };
48
- };
@@ -1,87 +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
- // 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
- return {
52
- id,
53
- name,
54
- description,
55
- type,
56
- root: projectAppRootPath,
57
- paths: {
58
- relative: projectAppRelativePath,
59
- absolute: projectAppRootPath,
60
- workspace: projectAppWorkspacePath
61
- },
62
- config: applicationConfig,
63
- project,
64
- get packages() {
65
- const webinyConfigs = glob.sync(
66
- join(projectAppRootPath, "**/webiny.config*.{ts,js}").replace(/\\/g, "/")
67
- );
68
-
69
- return webinyConfigs.map(config => {
70
- const dirPath = dirname(config);
71
- const packageJson = require(join(dirPath, "package.json"));
72
- return {
73
- name: packageJson.name,
74
- paths: {
75
- root: dirname(config),
76
- packageJson: join(dirPath, "package.json"),
77
- config
78
- },
79
- packageJson,
80
- get config() {
81
- return require(config).default || require(config);
82
- }
83
- };
84
- });
85
- }
86
- };
87
- };
@@ -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 +0,0 @@
1
- export function getApiProjectApplicationFolder(project: Record<string, any>): boolean;
package/utils/index.js DELETED
@@ -1,26 +0,0 @@
1
- const { importModule } = require("./importModule");
2
- const createProjectApplicationWorkspace = require("./createProjectApplicationWorkspace");
3
- const getProject = require("./getProject");
4
- const getProjectApplication = require("./getProjectApplication");
5
- const getApiProjectApplicationFolder = require("./getApiProjectApplicationFolder");
6
- const localStorage = require("./localStorage");
7
- const log = require("./log");
8
- const sendEvent = require("./sendEvent");
9
- const PluginsContainer = require("./PluginsContainer");
10
-
11
- const noop = () => {
12
- // Do nothing.
13
- };
14
-
15
- module.exports = {
16
- createProjectApplicationWorkspace,
17
- getApiProjectApplicationFolder,
18
- getProject,
19
- getProjectApplication,
20
- importModule,
21
- localStorage,
22
- log,
23
- noop,
24
- sendEvent,
25
- PluginsContainer
26
- };
@@ -1,54 +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
- // Let's load environment variables
28
- for (let i = 0; i < paths.length; i++) {
29
- const path = paths[i];
30
- const { error } = require("dotenv").config({ path });
31
- if (boolean(yargs.argv.debug)) {
32
- if (error) {
33
- log.debug(`No environment file found on ${log.debug.hl(path)}.`);
34
- } else {
35
- log.success(`Successfully loaded environment variables from ${log.success.hl(path)}.`);
36
- }
37
- }
38
- }
39
-
40
- // Feature flags defined via the `featureFlags` property.
41
- // We set twice, to be available for both backend and frontend application code.
42
- // TODO: one day we might want to sync this up a bit.
43
- if (project.config.featureFlags) {
44
- process.env.WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
45
- process.env.REACT_APP_WEBINY_FEATURE_FLAGS = JSON.stringify(project.config.featureFlags);
46
- }
47
-
48
- // With 5.38.0, we are hiding the `WEBINY_ELASTICSEARCH_INDEX_LOCALE` env variable and always setting it to `true`.
49
- // This is because this variable is not something users should be concerned with, nor should they be able to change it.
50
- // In order to ensure backwards compatibility, we first check if the variable is set, and if it is, we don't override it.
51
- const esIndexLocaleEnvVarExists = "WEBINY_ELASTICSEARCH_INDEX_LOCALE" in process.env;
52
- if (!esIndexLocaleEnvVarExists) {
53
- process.env.WEBINY_ELASTICSEARCH_INDEX_LOCALE = "true";
54
- }
@@ -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;
@@ -1,15 +0,0 @@
1
- const { sendEvent } = require("@webiny/telemetry/cli");
2
- const getProject = require("./getProject");
3
-
4
- module.exports = ({ event, properties, extraPayload }) => {
5
- const project = getProject();
6
- if (project.config.cli && project.config.cli.telemetry === false) {
7
- return;
8
- }
9
-
10
- return sendEvent({
11
- event,
12
- properties,
13
- extraPayload
14
- });
15
- };