@webiny/cli 5.17.4 → 5.18.0-beta.3

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 (49) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/commands/upgrade/index.js +52 -11
  3. package/context.js +1 -2
  4. package/package.json +4 -15
  5. package/utils/getProjectApplication.js +25 -2
  6. package/utils/log.js +2 -2
  7. package/commands/upgrade/upgrades/5.10.0/index.js +0 -123
  8. package/commands/upgrade/upgrades/5.10.0/upgradeApiFileManager.js +0 -111
  9. package/commands/upgrade/upgrades/5.10.0/upgradeApolloCachePlugins.js +0 -114
  10. package/commands/upgrade/upgrades/5.10.0/upgradeDeliveryPath.js +0 -19
  11. package/commands/upgrade/upgrades/5.10.0/upgradeLambdaConfig.js +0 -30
  12. package/commands/upgrade/upgrades/5.11.0/index.js +0 -109
  13. package/commands/upgrade/upgrades/5.11.0/upgradeApiI18n.js +0 -59
  14. package/commands/upgrade/upgrades/5.11.0/upgradeObjectField.js +0 -59
  15. package/commands/upgrade/upgrades/5.11.0/upgradeWebsite.js +0 -21
  16. package/commands/upgrade/upgrades/5.12.0/index.js +0 -106
  17. package/commands/upgrade/upgrades/5.12.0/upgradeApiSecurity.js +0 -53
  18. package/commands/upgrade/upgrades/5.12.0/upgradeElasticsearch.js +0 -111
  19. package/commands/upgrade/upgrades/5.13.0/addDotWebinyToGitIgnore.js +0 -25
  20. package/commands/upgrade/upgrades/5.13.0/addNewScaffolds.js +0 -75
  21. package/commands/upgrade/upgrades/5.13.0/createTypesTsFiles.js +0 -101
  22. package/commands/upgrade/upgrades/5.13.0/files/types/graphql.ts +0 -34
  23. package/commands/upgrade/upgrades/5.13.0/files/types/headlessCMS.ts +0 -28
  24. package/commands/upgrade/upgrades/5.13.0/index.js +0 -49
  25. package/commands/upgrade/upgrades/5.15.0/index.js +0 -97
  26. package/commands/upgrade/upgrades/5.15.0/upgradeApiPageBuilder.js +0 -121
  27. package/commands/upgrade/upgrades/5.16.0/index.js +0 -207
  28. package/commands/upgrade/upgrades/5.17.0/apiPrerenderingService.js +0 -182
  29. package/commands/upgrade/upgrades/5.17.0/index.js +0 -93
  30. package/commands/upgrade/upgrades/5.17.0/security.js +0 -611
  31. package/commands/upgrade/upgrades/5.5.0/index.js +0 -426
  32. package/commands/upgrade/upgrades/5.5.0/templates/api/default.webiny.config.js +0 -8
  33. package/commands/upgrade/upgrades/5.5.0/templates/api/fileManagerTransform.webiny.config.js +0 -9
  34. package/commands/upgrade/upgrades/5.5.0/templates/api/prerenderingService.webiny.config.js +0 -30
  35. package/commands/upgrade/upgrades/5.5.0/templates/customPackages/webiny.config.js +0 -8
  36. package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/api/webiny.application.js +0 -9
  37. package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/apps/admin/webiny.application.js +0 -15
  38. package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/apps/site/webiny.application.js +0 -16
  39. package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/apps/website/webiny.application.js +0 -16
  40. package/commands/upgrade/upgrades/5.8.0/index.js +0 -137
  41. package/commands/upgrade/upgrades/5.9.0/index.js +0 -144
  42. package/commands/upgrade/upgrades/5.9.0/upgradeScaffolding/babelrc.js +0 -1
  43. package/commands/upgrade/upgrades/5.9.0/upgradeScaffolding/jestConfig.js +0 -40
  44. package/commands/upgrade/upgrades/5.9.0/upgradeScaffolding.js +0 -337
  45. package/commands/upgrade/upgrades/5.9.0/upgradeSecurity.js +0 -280
  46. package/commands/upgrade/upgrades/5.9.0/upgradeTelemetry.js +0 -30
  47. package/commands/upgrade/upgrades/fileUtils.js +0 -152
  48. package/commands/upgrade/upgrades/upgrade.js +0 -1
  49. package/commands/upgrade/upgrades/utils.js +0 -792
@@ -1,109 +0,0 @@
1
- const path = require("path");
2
- const i18nUpgrade = require("./upgradeApiI18n");
3
- const objectFieldUpgrade = require("./upgradeObjectField");
4
- const websiteUpgrade = require("./upgradeWebsite");
5
-
6
- const targetVersion = "5.11.0";
7
-
8
- /**
9
- * @type {CliUpgradePlugin}
10
- */
11
- module.exports = {
12
- name: `upgrade-${targetVersion}`,
13
- type: "cli-upgrade",
14
- version: targetVersion,
15
- /**
16
- * @param options {CliUpgradePluginOptions}
17
- * @param context {CliContext}
18
- * @returns {Promise<boolean>}
19
- */
20
- async canUpgrade(options, context) {
21
- if (context.version === targetVersion) {
22
- return true;
23
- } else if (
24
- context.version.match(
25
- new RegExp(
26
- /**
27
- * This is for beta testing.
28
- */
29
- `^${targetVersion}-`
30
- )
31
- )
32
- ) {
33
- return true;
34
- }
35
- throw new Error(
36
- `Upgrade must be on Webiny CLI version "${targetVersion}". Current CLI version is "${context.version}".`
37
- );
38
- },
39
-
40
- /**
41
- * @param options {CliUpgradePluginOptions}
42
- * @param context {CliContext}
43
- * @returns {Promise<void>}
44
- */
45
- async upgrade(options, context) {
46
- const { info } = context;
47
- const glob = require("fast-glob");
48
-
49
- const {
50
- createMorphProject,
51
- addPackagesToDependencies,
52
- yarnInstall,
53
- prettierFormat
54
- } = require("../utils");
55
-
56
- const files = await glob(
57
- [
58
- ...Object.values(i18nUpgrade.files),
59
- ...Object.values(objectFieldUpgrade.files),
60
- ...Object.values(websiteUpgrade.files)
61
- ],
62
- {
63
- cwd: context.project.root,
64
- onlyFiles: true,
65
- ignore: ["**/node_modules/**"]
66
- }
67
- );
68
-
69
- const project = createMorphProject(files);
70
- /**
71
- * Upgrade the graphql with new packages.
72
- */
73
- await i18nUpgrade.upgradeGraphQLIndex(project, context);
74
- /**
75
- * Upgrade the api headless cms with new packages.
76
- */
77
- await i18nUpgrade.upgradeHeadlessCMSIndex(project, context);
78
- /**
79
- * Upgrade the app headless cms with new packages.
80
- */
81
- await objectFieldUpgrade.upgradeAppHeadlessCMS(project, context);
82
-
83
- info("Adding dependencies...");
84
-
85
- addPackagesToDependencies(path.resolve(process.cwd(), "api/code/graphql"), {
86
- "@webiny/api-i18n-ddb": context.version
87
- });
88
- addPackagesToDependencies(path.resolve(process.cwd(), "api/code/headlessCMS"), {
89
- "@webiny/api-i18n-ddb": context.version
90
- });
91
-
92
- /**
93
- * Fix form builder validator imports in website app.
94
- */
95
- websiteUpgrade.upgradeFormBuilderImports(project, context);
96
-
97
- info("Writing changes...");
98
- await project.save();
99
-
100
- await prettierFormat(files, context);
101
-
102
- /**
103
- * Install new packages.
104
- */
105
- await yarnInstall({
106
- context
107
- });
108
- }
109
- };
@@ -1,59 +0,0 @@
1
- const { addImportsToSource } = require("../utils");
2
- const FILES = {
3
- graphql: "api/code/graphql/src/index.ts",
4
- headlessCMS: "api/code/headlessCMS/src/index.ts"
5
- };
6
-
7
- const upgradeGraphQLIndex = async (project, context) => {
8
- const { info } = context;
9
- const file = FILES.graphql;
10
- info(`Upgrading ${info.hl(file)}`);
11
-
12
- const source = project.getSourceFile(file);
13
-
14
- addImportsToSource({
15
- context,
16
- source,
17
- imports: [
18
- {
19
- elementName: "i18nDynamoDbStorageOperations",
20
- importPath: "@webiny/api-i18n-ddb"
21
- },
22
- {
23
- elementName: "dynamoDbPlugins",
24
- importPath: "@webiny/db-dynamodb/plugins"
25
- }
26
- ],
27
- file
28
- });
29
- };
30
-
31
- const upgradeHeadlessCMSIndex = async (project, context) => {
32
- const { info } = context;
33
- const file = FILES.headlessCMS;
34
- info(`Upgrading ${info.hl(file)}`);
35
-
36
- const source = project.getSourceFile(file);
37
-
38
- addImportsToSource({
39
- context,
40
- source,
41
- imports: [
42
- {
43
- elementName: "i18nDynamoDbStorageOperations",
44
- importPath: "@webiny/api-i18n-ddb"
45
- },
46
- {
47
- elementName: "dynamoDbPlugins",
48
- importPath: "@webiny/db-dynamodb/plugins"
49
- }
50
- ],
51
- file
52
- });
53
- };
54
-
55
- module.exports = {
56
- upgradeGraphQLIndex,
57
- upgradeHeadlessCMSIndex,
58
- files: FILES
59
- };
@@ -1,59 +0,0 @@
1
- const tsMorph = require("ts-morph");
2
- const { addImportsToSource } = require("../utils");
3
-
4
- const FILES = {
5
- headlessCMS: "apps/admin/code/src/plugins/headlessCms.ts"
6
- };
7
-
8
- const upgradeAppHeadlessCMS = async (project, context) => {
9
- const { info, error } = context;
10
- const file = FILES.headlessCMS;
11
- info(`Upgrading ${info.hl(file)}`);
12
-
13
- const source = project.getSourceFile(file);
14
-
15
- const imports = [
16
- {
17
- elementName: "objectField",
18
- importPath: "@webiny/app-headless-cms/admin/plugins/fields/object",
19
- addToPlugins: false
20
- },
21
- {
22
- elementName: "objectFieldRenderer",
23
- importPath: "@webiny/app-headless-cms/admin/plugins/fieldRenderers/object",
24
- addToPlugins: false
25
- }
26
- ];
27
-
28
- addImportsToSource({
29
- context,
30
- source,
31
- imports,
32
- file
33
- });
34
- /**
35
- * We need to add plugins to the export default array.
36
- * That is why we need to get the default export first.
37
- */
38
- const exportDefaultExpression = source.getFirstDescendant(node => {
39
- return tsMorph.Node.isExportAssignment(node);
40
- });
41
- if (!exportDefaultExpression) {
42
- error(`Could not find default export in the ${error.hl(file)}.`);
43
- return;
44
- }
45
- /**
46
- * Then find the array expression and add new elements into it.
47
- */
48
- const arrayExpression = exportDefaultExpression.getFirstDescendant(node => {
49
- return tsMorph.Node.isArrayLiteralExpression(node);
50
- });
51
- for (const i of imports) {
52
- arrayExpression.addElement(i.elementName);
53
- }
54
- };
55
-
56
- module.exports = {
57
- upgradeAppHeadlessCMS,
58
- files: FILES
59
- };
@@ -1,21 +0,0 @@
1
- const FILES = {
2
- formBuilder: "apps/website/code/src/plugins/formBuilder.ts"
3
- };
4
-
5
- const upgradeFormBuilderImports = async (project, context) => {
6
- const { info } = context;
7
- const file = FILES.formBuilder;
8
- info(`Upgrading ${info.hl(file)}`);
9
-
10
- const source = project.getSourceFile(file);
11
- const text = source.getFullText();
12
-
13
- source.set({
14
- statements: text.replace(/\/\//g, "").replace(new RegExp(`\\b/site/\\b`, "g"), "/render/")
15
- });
16
- };
17
-
18
- module.exports = {
19
- upgradeFormBuilderImports,
20
- files: FILES
21
- };
@@ -1,106 +0,0 @@
1
- const path = require("path");
2
- const securityUpgrade = require("./upgradeApiSecurity");
3
- const elasticsearchUpgrade = require("./upgradeElasticsearch");
4
-
5
- const targetVersion = "5.12.0";
6
-
7
- /**
8
- * @type {CliUpgradePlugin}
9
- */
10
- module.exports = {
11
- name: `upgrade-${targetVersion}`,
12
- type: "cli-upgrade",
13
- version: targetVersion,
14
- /**
15
- * @param options {CliUpgradePluginOptions}
16
- * @param context {CliContext}
17
- * @returns {Promise<boolean>}
18
- */
19
- async canUpgrade(options, context) {
20
- if (context.version === targetVersion) {
21
- return true;
22
- } else if (
23
- context.version.match(
24
- new RegExp(
25
- /**
26
- * This is for beta testing.
27
- */
28
- `^${targetVersion}-`
29
- )
30
- )
31
- ) {
32
- return true;
33
- }
34
- throw new Error(
35
- `Upgrade must be on Webiny CLI version "${targetVersion}". Current CLI version is "${context.version}".`
36
- );
37
- },
38
-
39
- /**
40
- * @param options {CliUpgradePluginOptions}
41
- * @param context {CliContext}
42
- * @returns {Promise<void>}
43
- */
44
- async upgrade(options, context) {
45
- const { info } = context;
46
- const glob = require("fast-glob");
47
-
48
- const {
49
- createMorphProject,
50
- addPackagesToDependencies,
51
- yarnInstall,
52
- prettierFormat
53
- } = require("../utils");
54
-
55
- const files = await glob(
56
- [...Object.values(securityUpgrade.files), ...Object.values(elasticsearchUpgrade.files)],
57
- {
58
- cwd: context.project.root,
59
- onlyFiles: true,
60
- ignore: ["**/node_modules/**"]
61
- }
62
- );
63
-
64
- const project = createMorphProject(files);
65
- /**
66
- * Upgrade the graphql with new security packages.
67
- */
68
- await securityUpgrade.upgradeGraphQLIndex(project, context);
69
- /**
70
- * Upgrade the api headless cms with new security packages.
71
- */
72
- await securityUpgrade.upgradeHeadlessCMSIndex(project, context);
73
- /**
74
- * Upgrade the dynamodb to elasticsearch with new compression package.
75
- */
76
- await elasticsearchUpgrade.upgradeDynamoDbToElasticIndex(project, context);
77
- /**
78
- * Upgrade the graphql with new compression package.
79
- */
80
- await elasticsearchUpgrade.upgradeGraphQLIndex(project, context);
81
- /**
82
- * Upgrade the api headless cms to elasticsearch with new compression package.
83
- */
84
- await elasticsearchUpgrade.upgradeHeadlessCMSIndex(project, context);
85
- info("Adding dependencies...");
86
-
87
- addPackagesToDependencies(path.resolve(process.cwd(), "api/code/graphql"), {
88
- "@webiny/api-security-admin-users-so-ddb": context.version
89
- });
90
- addPackagesToDependencies(path.resolve(process.cwd(), "api/code/headlessCMS"), {
91
- "@webiny/api-security-admin-users-so-ddb": context.version
92
- });
93
-
94
- info("Writing changes...");
95
- await project.save();
96
-
97
- await prettierFormat(files, context);
98
-
99
- /**
100
- * Install new packages.
101
- */
102
- await yarnInstall({
103
- context
104
- });
105
- }
106
- };
@@ -1,53 +0,0 @@
1
- const { addImportsToSource } = require("../utils");
2
- const FILES = {
3
- graphql: "api/code/graphql/src/index.ts",
4
- headlessCMS: "api/code/headlessCMS/src/index.ts"
5
- };
6
-
7
- const importName = "securityAdminUsersDynamoDbStorageOperations";
8
-
9
- const upgradeGraphQLIndex = async (project, context) => {
10
- const { info } = context;
11
- const file = FILES.graphql;
12
- info(`Upgrading ${info.hl(file)}`);
13
-
14
- const source = project.getSourceFile(file);
15
-
16
- addImportsToSource({
17
- context,
18
- source,
19
- imports: [
20
- {
21
- elementName: importName,
22
- importPath: "@webiny/api-security-admin-users-so-ddb"
23
- }
24
- ],
25
- file
26
- });
27
- };
28
-
29
- const upgradeHeadlessCMSIndex = async (project, context) => {
30
- const { info } = context;
31
- const file = FILES.headlessCMS;
32
- info(`Upgrading ${info.hl(file)}`);
33
-
34
- const source = project.getSourceFile(file);
35
-
36
- addImportsToSource({
37
- context,
38
- source,
39
- imports: [
40
- {
41
- elementName: importName,
42
- importPath: "@webiny/api-security-admin-users-so-ddb"
43
- }
44
- ],
45
- file
46
- });
47
- };
48
-
49
- module.exports = {
50
- upgradeGraphQLIndex,
51
- upgradeHeadlessCMSIndex,
52
- files: FILES
53
- };
@@ -1,111 +0,0 @@
1
- const tsMorph = require("ts-morph");
2
- const { addImportsToSource } = require("../utils");
3
- const FILES = {
4
- dynamodbToElastic: "api/code/dynamoToElastic/src/index.ts",
5
- graphql: "api/code/graphql/src/index.ts",
6
- headlessCMS: "api/code/headlessCMS/src/index.ts"
7
- };
8
-
9
- const elementName = "elasticsearchDataGzipCompression";
10
- const importPath = "@webiny/api-elasticsearch/plugins/GzipCompression";
11
-
12
- const upgradeDynamoDbToElasticIndex = (project, context) => {
13
- const { info } = context;
14
- const file = FILES.dynamodbToElastic;
15
- info(`Upgrading ${info.hl(file)}`);
16
-
17
- const source = project.getSourceFile(file);
18
- /**
19
- * First we need to check if there are plugins in the createHandler because user might have added it.
20
- */
21
- const plugins = source.getFirstDescendant(
22
- node =>
23
- tsMorph.Node.isPropertyAssignment(node) &&
24
- tsMorph.Node.isArrayLiteralExpression(node) &&
25
- node.getName() === "plugins"
26
- );
27
- /**
28
- * We need to upgrade the old createHandler if plugins do not exist.
29
- */
30
- if (!plugins) {
31
- const createHandler = source.getFirstDescendant(
32
- node =>
33
- tsMorph.Node.isCallExpression(node) &&
34
- node.getExpression().getText() === "createHandler"
35
- );
36
-
37
- const createHandlerPlugins = createHandler.getArguments();
38
- const pluginsList = createHandlerPlugins.map(plugin => plugin.getFullText());
39
- /**
40
- * Remove existing arguments.
41
- */
42
- for (const plugin of createHandlerPlugins) {
43
- createHandler.removeArgument(plugin);
44
- }
45
- /**
46
- * Add new way of creating the handler.
47
- */
48
- createHandler.addArgument(`{plugins: [${pluginsList.join(",")}]}`);
49
- }
50
- /**
51
- * Then add whats required to the plugins.
52
- */
53
- addImportsToSource({
54
- context,
55
- source,
56
- imports: [
57
- {
58
- elementName,
59
- importPath
60
- }
61
- ],
62
- file
63
- });
64
- };
65
-
66
- const upgradeGraphQLIndex = (project, context) => {
67
- const { info } = context;
68
- const file = FILES.graphql;
69
- info(`Upgrading ${info.hl(file)}`);
70
-
71
- const source = project.getSourceFile(file);
72
-
73
- addImportsToSource({
74
- context,
75
- source,
76
- imports: [
77
- {
78
- elementName,
79
- importPath
80
- }
81
- ],
82
- file
83
- });
84
- };
85
-
86
- const upgradeHeadlessCMSIndex = (project, context) => {
87
- const { info } = context;
88
- const file = FILES.headlessCMS;
89
- info(`Upgrading ${info.hl(file)}`);
90
-
91
- const source = project.getSourceFile(file);
92
-
93
- addImportsToSource({
94
- context,
95
- source,
96
- imports: [
97
- {
98
- elementName,
99
- importPath
100
- }
101
- ],
102
- file
103
- });
104
- };
105
-
106
- module.exports = {
107
- upgradeDynamoDbToElasticIndex,
108
- upgradeGraphQLIndex,
109
- upgradeHeadlessCMSIndex,
110
- files: FILES
111
- };
@@ -1,25 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const addDotWebinyToGitIgnore = async context => {
5
- const { info, project } = context;
6
-
7
- info(`Adding ${info.hl(".webiny")} to the ${info.hl(".gitignore")} file...`);
8
-
9
- const gitIgnorePath = path.join(project.root, ".gitignore");
10
- const content = fs.readFileSync(gitIgnorePath).toString("utf8");
11
-
12
- if (content.match("\\.webiny")) {
13
- info(
14
- `Skipping - ${info.hl(".webiny")} already exists in the ${info.hl(".gitignore")} file.`
15
- );
16
- return [];
17
- }
18
-
19
- fs.appendFileSync(gitIgnorePath, ".webiny");
20
- info(`${info.hl(".webiny")} added to the ${info.hl(".gitignore")} file.`);
21
- };
22
-
23
- module.exports = {
24
- addDotWebinyToGitIgnore
25
- };
@@ -1,75 +0,0 @@
1
- const fs = require("fs");
2
- const tsMorph = require("ts-morph");
3
-
4
- const addNewScaffolds = async context => {
5
- const { info, project, version } = context;
6
-
7
- const { addPackagesToDependencies, createMorphProject, insertImport } = require("../utils");
8
-
9
- info(
10
- `Adding new scaffolds as ${info.hl("dependencies")} in ${info.hl("package.json")} file...`
11
- );
12
-
13
- addPackagesToDependencies(project.root, {
14
- "@webiny/cli-plugin-scaffold-graphql-api": version,
15
- "@webiny/cli-plugin-scaffold-react-app": version,
16
- "@webiny/cli-plugin-scaffold-full-stack-app": version
17
- });
18
-
19
- info(`Added new scaffolds as ${info.hl("dependencies")} in ${info.hl("package.json")} file.`);
20
-
21
- const webinyProjectTsPath = "webiny.project.ts";
22
- info(`Adding new scaffolds in the ${info.hl(webinyProjectTsPath)} file...`);
23
- if (!fs.existsSync(webinyProjectTsPath)) {
24
- info(`Skipping - could not find ${info.hl(webinyProjectTsPath)} file.`);
25
- return;
26
- }
27
-
28
- const graphQlProject = createMorphProject([webinyProjectTsPath]);
29
- const webinyProjectTs = graphQlProject.getSourceFileOrThrow(webinyProjectTsPath);
30
- info(`Adding new scaffolds to the ${webinyProjectTsPath} file...`);
31
-
32
- insertImport(
33
- webinyProjectTs,
34
- "cliScaffoldGraphQlApi",
35
- "@webiny/cli-plugin-scaffold-graphql-api"
36
- );
37
-
38
- insertImport(webinyProjectTs, "cliScaffoldReactApp", "@webiny/cli-plugin-scaffold-react-app");
39
-
40
- insertImport(
41
- webinyProjectTs,
42
- "cliScaffoldFullStackApp",
43
- "@webiny/cli-plugin-scaffold-full-stack-app"
44
- );
45
-
46
- webinyProjectTs.forEachDescendant((node, traversal) => {
47
- const kind = node.getKind();
48
- if (kind === tsMorph.SyntaxKind.ArrayLiteralExpression) {
49
- const parent = node.getParent();
50
- if (!parent.compilerNode || !parent.compilerNode.name) {
51
- traversal.skip();
52
- return;
53
- }
54
- const compilerNode = parent.compilerNode || {};
55
- const name = compilerNode.name || {};
56
- const escapedText = name.escapedText;
57
- if (escapedText !== "plugins") {
58
- traversal.skip();
59
- return;
60
- }
61
- node.addElement("cliScaffoldGraphQlApi()");
62
- node.addElement("cliScaffoldReactApp()");
63
- node.addElement("cliScaffoldFullStackApp()");
64
- traversal.stop();
65
- }
66
- });
67
-
68
- info(`New scaffolds added to the ${webinyProjectTsPath} file.`);
69
-
70
- await webinyProjectTs.save();
71
- };
72
-
73
- module.exports = {
74
- addNewScaffolds
75
- };