@webiny/cli 5.17.4-beta.1 → 5.18.0-beta.2
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/CHANGELOG.md +53 -0
- package/commands/upgrade/index.js +60 -11
- package/context.js +1 -2
- package/package.json +4 -15
- package/utils/getProjectApplication.js +25 -2
- package/utils/log.js +2 -2
- package/commands/upgrade/upgrades/5.10.0/index.js +0 -123
- package/commands/upgrade/upgrades/5.10.0/upgradeApiFileManager.js +0 -111
- package/commands/upgrade/upgrades/5.10.0/upgradeApolloCachePlugins.js +0 -114
- package/commands/upgrade/upgrades/5.10.0/upgradeDeliveryPath.js +0 -19
- package/commands/upgrade/upgrades/5.10.0/upgradeLambdaConfig.js +0 -30
- package/commands/upgrade/upgrades/5.11.0/index.js +0 -109
- package/commands/upgrade/upgrades/5.11.0/upgradeApiI18n.js +0 -59
- package/commands/upgrade/upgrades/5.11.0/upgradeObjectField.js +0 -59
- package/commands/upgrade/upgrades/5.11.0/upgradeWebsite.js +0 -21
- package/commands/upgrade/upgrades/5.12.0/index.js +0 -106
- package/commands/upgrade/upgrades/5.12.0/upgradeApiSecurity.js +0 -53
- package/commands/upgrade/upgrades/5.12.0/upgradeElasticsearch.js +0 -111
- package/commands/upgrade/upgrades/5.13.0/addDotWebinyToGitIgnore.js +0 -25
- package/commands/upgrade/upgrades/5.13.0/addNewScaffolds.js +0 -75
- package/commands/upgrade/upgrades/5.13.0/createTypesTsFiles.js +0 -101
- package/commands/upgrade/upgrades/5.13.0/files/types/graphql.ts +0 -34
- package/commands/upgrade/upgrades/5.13.0/files/types/headlessCMS.ts +0 -28
- package/commands/upgrade/upgrades/5.13.0/index.js +0 -49
- package/commands/upgrade/upgrades/5.15.0/index.js +0 -97
- package/commands/upgrade/upgrades/5.15.0/upgradeApiPageBuilder.js +0 -121
- package/commands/upgrade/upgrades/5.16.0/index.js +0 -207
- package/commands/upgrade/upgrades/5.17.0/apiPrerenderingService.js +0 -182
- package/commands/upgrade/upgrades/5.17.0/index.js +0 -93
- package/commands/upgrade/upgrades/5.17.0/security.js +0 -611
- package/commands/upgrade/upgrades/5.5.0/index.js +0 -426
- package/commands/upgrade/upgrades/5.5.0/templates/api/default.webiny.config.js +0 -8
- package/commands/upgrade/upgrades/5.5.0/templates/api/fileManagerTransform.webiny.config.js +0 -9
- package/commands/upgrade/upgrades/5.5.0/templates/api/prerenderingService.webiny.config.js +0 -30
- package/commands/upgrade/upgrades/5.5.0/templates/customPackages/webiny.config.js +0 -8
- package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/api/webiny.application.js +0 -9
- package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/apps/admin/webiny.application.js +0 -15
- package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/apps/site/webiny.application.js +0 -16
- package/commands/upgrade/upgrades/5.5.0/templates/webinyApplication/apps/website/webiny.application.js +0 -16
- package/commands/upgrade/upgrades/5.8.0/index.js +0 -137
- package/commands/upgrade/upgrades/5.9.0/index.js +0 -144
- package/commands/upgrade/upgrades/5.9.0/upgradeScaffolding/babelrc.js +0 -1
- package/commands/upgrade/upgrades/5.9.0/upgradeScaffolding/jestConfig.js +0 -40
- package/commands/upgrade/upgrades/5.9.0/upgradeScaffolding.js +0 -337
- package/commands/upgrade/upgrades/5.9.0/upgradeSecurity.js +0 -280
- package/commands/upgrade/upgrades/5.9.0/upgradeTelemetry.js +0 -30
- package/commands/upgrade/upgrades/fileUtils.js +0 -152
- package/commands/upgrade/upgrades/upgrade.js +0 -1
- package/commands/upgrade/upgrades/utils.js +0 -792
|
@@ -1,611 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line
|
|
2
|
-
const tsMorph = require("ts-morph");
|
|
3
|
-
|
|
4
|
-
const { copyFiles, deleteFiles } = require("../fileUtils");
|
|
5
|
-
const {
|
|
6
|
-
addPackagesToDependencies,
|
|
7
|
-
addPluginArgumentValueInCreateHandler,
|
|
8
|
-
removeImportFromSourceFile,
|
|
9
|
-
insertImportToSourceFile,
|
|
10
|
-
removePluginFromCreateHandler,
|
|
11
|
-
addDynamoDbDocumentClient,
|
|
12
|
-
findNodeInSource,
|
|
13
|
-
findDefaultExport,
|
|
14
|
-
findReturnStatement
|
|
15
|
-
} = require("../utils");
|
|
16
|
-
|
|
17
|
-
const paths = {
|
|
18
|
-
apiGraphQL: "api/code/graphql",
|
|
19
|
-
apiHeadlessCms: "api/code/headlessCMS",
|
|
20
|
-
apiPageBuilderExport: "api/code/pageBuilder/exportPages",
|
|
21
|
-
apiPageBuilderImport: "api/code/pageBuilder/importPages",
|
|
22
|
-
appsAdminCode: "apps/admin/code",
|
|
23
|
-
apiPulumiDev: "api/pulumi/dev",
|
|
24
|
-
apiPulumiProd: "api/pulumi/prod"
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const files = {
|
|
28
|
-
apiGraphQL: `${paths.apiGraphQL}/src/index.ts`,
|
|
29
|
-
apiHeadlessCms: `${paths.apiHeadlessCms}/src/index.ts`,
|
|
30
|
-
appAdminPluginsIndex: `${paths.appsAdminCode}/src/plugins/index.ts`,
|
|
31
|
-
appAdminPluginsSecurity: `${paths.appsAdminCode}/src/plugins/security.ts`,
|
|
32
|
-
appAdminApp: `${paths.appsAdminCode}/src/App.tsx`,
|
|
33
|
-
appAdminWebinyConfig: `${paths.appsAdminCode}/webiny.config.ts`,
|
|
34
|
-
apiPageImportCreateIndex: `${paths.apiPageBuilderImport}/create/src/index.ts`,
|
|
35
|
-
apiPageImportCreateSecurity: `${paths.apiPageBuilderImport}/create/src/security.ts`,
|
|
36
|
-
apiPageImportProcessIndex: `${paths.apiPageBuilderImport}/process/src/index.ts`,
|
|
37
|
-
apiPageImportProcessSecurity: `${paths.apiPageBuilderImport}/process/src/security.ts`,
|
|
38
|
-
apiPageExportCombineIndex: `${paths.apiPageBuilderExport}/combine/src/index.ts`,
|
|
39
|
-
apiPageExportCombineSecurity: `${paths.apiPageBuilderExport}/combine/src/security.ts`,
|
|
40
|
-
apiPageExportProcessIndex: `${paths.apiPageBuilderExport}/process/src/index.ts`,
|
|
41
|
-
apiPageExportProcessSecurity: `${paths.apiPageBuilderExport}/process/src/security.ts`,
|
|
42
|
-
apiPulumiDevIndex: `${paths.apiPulumiDev}/index.ts`,
|
|
43
|
-
apiPulumiProdIndex: `${paths.apiPulumiProd}/index.ts`
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @param project {tsMorph.Project}
|
|
48
|
-
* @param context {CliContext}
|
|
49
|
-
*/
|
|
50
|
-
const upgradeGraphQLIndex = (project, context) => {
|
|
51
|
-
const { info } = context;
|
|
52
|
-
info(`Upgrading ${info.hl(paths.apiGraphQL)}`);
|
|
53
|
-
|
|
54
|
-
const source = project.getSourceFile(files.apiGraphQL);
|
|
55
|
-
/**
|
|
56
|
-
* Just copy new security.ts file.
|
|
57
|
-
*/
|
|
58
|
-
const copyFileTargets = [
|
|
59
|
-
{
|
|
60
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiGraphQL}/src/security.ts`,
|
|
61
|
-
destination: `${paths.apiGraphQL}/src/security.ts`
|
|
62
|
-
}
|
|
63
|
-
];
|
|
64
|
-
copyFiles(context, copyFileTargets);
|
|
65
|
-
/**
|
|
66
|
-
* API GraphQL package.json
|
|
67
|
-
*/
|
|
68
|
-
const packages = {
|
|
69
|
-
/**
|
|
70
|
-
* To be added
|
|
71
|
-
*/
|
|
72
|
-
"@webiny/api-admin-users-cognito": context.version,
|
|
73
|
-
"@webiny/api-admin-users-cognito-so-ddb": context.version,
|
|
74
|
-
"@webiny/api-tenancy-so-ddb": context.version,
|
|
75
|
-
"@webiny/api-security-cognito": context.version,
|
|
76
|
-
"@webiny/api-security-so-ddb": context.version,
|
|
77
|
-
/**
|
|
78
|
-
* To be removed
|
|
79
|
-
*/
|
|
80
|
-
"@webiny/api-security-admin-users": null,
|
|
81
|
-
"@webiny/api-security-admin-users-cognito": null,
|
|
82
|
-
"@webiny/api-security-admin-users-so-ddb": null,
|
|
83
|
-
"@webiny/api-security-cognito-authentication": null
|
|
84
|
-
};
|
|
85
|
-
addPackagesToDependencies(context, paths.apiGraphQL, packages);
|
|
86
|
-
/**
|
|
87
|
-
* Remove imports that are no longer required.
|
|
88
|
-
*/
|
|
89
|
-
for (const key in packages) {
|
|
90
|
-
if (packages[key]) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
removeImportFromSourceFile(source, key);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Find securityPlugins() in createHandler({plugins:[]}) and add the documentClient variable into it: {documentClient}
|
|
97
|
-
*/
|
|
98
|
-
addPluginArgumentValueInCreateHandler(source, "handler", "securityPlugins", {
|
|
99
|
-
documentClient: "documentClient"
|
|
100
|
-
});
|
|
101
|
-
/**
|
|
102
|
-
* Remove existing import "@webiny/api-page-builder-import-export-so-ddb"
|
|
103
|
-
*/
|
|
104
|
-
removeImportFromSourceFile(source, "@webiny/api-page-builder-import-export-so-ddb");
|
|
105
|
-
/**
|
|
106
|
-
* And then add a new one that will have alias.
|
|
107
|
-
*/
|
|
108
|
-
insertImportToSourceFile({
|
|
109
|
-
source,
|
|
110
|
-
moduleSpecifier: "@webiny/api-page-builder-import-export-so-ddb",
|
|
111
|
-
name: {
|
|
112
|
-
createStorageOperations: "createPageImportExportStorageOperations"
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
/**
|
|
116
|
-
* Find pageBuilderImportExportPlugins() in createHandler({plugins:[]}) and assign storageOperations alias
|
|
117
|
-
*/
|
|
118
|
-
addPluginArgumentValueInCreateHandler(source, "handler", "pageBuilderImportExportPlugins", {
|
|
119
|
-
storageOperations: "createPageImportExportStorageOperations({ documentClient })"
|
|
120
|
-
});
|
|
121
|
-
/**
|
|
122
|
-
* Remove adminUsersPlugins() and securityAdminUsersDynamoDbStorageOperations() from handler plugins
|
|
123
|
-
*/
|
|
124
|
-
removePluginFromCreateHandler(source, "handler", "adminUsersPlugins()");
|
|
125
|
-
removePluginFromCreateHandler(
|
|
126
|
-
source,
|
|
127
|
-
"handler",
|
|
128
|
-
"securityAdminUsersDynamoDbStorageOperations()"
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @param project {tsMorph.Project}
|
|
134
|
-
* @param context {CliContext}
|
|
135
|
-
*/
|
|
136
|
-
const upgradeHeadlessCMSIndex = (project, context) => {
|
|
137
|
-
const { info } = context;
|
|
138
|
-
info(`Upgrading ${info.hl(paths.apiHeadlessCms)}`);
|
|
139
|
-
|
|
140
|
-
const source = project.getSourceFile(files.apiHeadlessCms);
|
|
141
|
-
/**
|
|
142
|
-
* Just copy new security.ts file.
|
|
143
|
-
*/
|
|
144
|
-
const copyFileTargets = [
|
|
145
|
-
{
|
|
146
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiHeadlessCms}/src/security.ts`,
|
|
147
|
-
destination: `${paths.apiHeadlessCms}/src/security.ts`
|
|
148
|
-
}
|
|
149
|
-
];
|
|
150
|
-
copyFiles(context, copyFileTargets);
|
|
151
|
-
|
|
152
|
-
const packages = {
|
|
153
|
-
/**
|
|
154
|
-
* To be added
|
|
155
|
-
*/
|
|
156
|
-
"@webiny/api-security-cognito": context.version,
|
|
157
|
-
"@webiny/api-security-so-ddb": context.version,
|
|
158
|
-
"@webiny/api-tenancy-so-ddb": context.version,
|
|
159
|
-
/**
|
|
160
|
-
* To be removed
|
|
161
|
-
*/
|
|
162
|
-
"@webiny/api-security-admin-users": null,
|
|
163
|
-
"@webiny/api-security-admin-users-so-ddb": null,
|
|
164
|
-
"@webiny/api-security-cognito-authentication": null
|
|
165
|
-
};
|
|
166
|
-
addPackagesToDependencies(context, paths.apiHeadlessCms, packages);
|
|
167
|
-
/**
|
|
168
|
-
* Remove imports that are no longer required.
|
|
169
|
-
*/
|
|
170
|
-
for (const key in packages) {
|
|
171
|
-
if (packages[key]) {
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
removeImportFromSourceFile(source, key);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* We need to add the documentClient to the file so it can be used later on.
|
|
178
|
-
*/
|
|
179
|
-
addDynamoDbDocumentClient(source);
|
|
180
|
-
/**
|
|
181
|
-
* Find securityPlugins() in createHandler({plugins:[]}) and add the documentClient variable into it: {documentClient}
|
|
182
|
-
*/
|
|
183
|
-
addPluginArgumentValueInCreateHandler(source, "handler", "securityPlugins", {
|
|
184
|
-
documentClient: "documentClient"
|
|
185
|
-
});
|
|
186
|
-
/**
|
|
187
|
-
* Find dbPlugins() in in createHandler({plugins:[]}) and add the driver initialization with the existing document client.
|
|
188
|
-
*/
|
|
189
|
-
addPluginArgumentValueInCreateHandler(source, "handler", "dbPlugins", {
|
|
190
|
-
driver: "new DynamoDbDriver({ documentClient })"
|
|
191
|
-
});
|
|
192
|
-
/**
|
|
193
|
-
* Remove the securityAdminUsersDynamoDbStorageOperations() plugin from the handler.
|
|
194
|
-
*/
|
|
195
|
-
removePluginFromCreateHandler(
|
|
196
|
-
source,
|
|
197
|
-
"handler",
|
|
198
|
-
"securityAdminUsersDynamoDbStorageOperations()"
|
|
199
|
-
);
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* @param project {tsMorph.Project}
|
|
204
|
-
* @param context {CliContext}
|
|
205
|
-
*/
|
|
206
|
-
const upgradePageImportExport = (project, context) => {
|
|
207
|
-
const { info } = context;
|
|
208
|
-
info(`Upgrading api/code/pageBuilder`);
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Just copy new index.ts and security.ts files.
|
|
212
|
-
*/
|
|
213
|
-
const copyFileTargets = [
|
|
214
|
-
{
|
|
215
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderImport}/create/src/index.ts`,
|
|
216
|
-
destination: `${paths.apiPageBuilderImport}/create/src/index.ts`
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderImport}/create/src/security.ts`,
|
|
220
|
-
destination: `${paths.apiPageBuilderImport}/create/src/security.ts`
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderImport}/process/src/index.ts`,
|
|
224
|
-
destination: `${paths.apiPageBuilderImport}/process/src/index.ts`
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderImport}/process/src/security.ts`,
|
|
228
|
-
destination: `${paths.apiPageBuilderImport}/process/src/security.ts`
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderExport}/combine/src/index.ts`,
|
|
232
|
-
destination: `${paths.apiPageBuilderExport}/combine/src/index.ts`
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderExport}/combine/src/security.ts`,
|
|
236
|
-
destination: `${paths.apiPageBuilderExport}/combine/src/security.ts`
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderExport}/process/src/index.ts`,
|
|
240
|
-
destination: `${paths.apiPageBuilderExport}/process/src/index.ts`
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
source: `node_modules/@webiny/cwp-template-aws/template/ddb-es/${paths.apiPageBuilderExport}/process/src/security.ts`,
|
|
244
|
-
destination: `${paths.apiPageBuilderExport}/process/src/security.ts`
|
|
245
|
-
}
|
|
246
|
-
];
|
|
247
|
-
copyFiles(context, copyFileTargets, false);
|
|
248
|
-
/**
|
|
249
|
-
* API GraphQL package.json
|
|
250
|
-
*/
|
|
251
|
-
const packages = {
|
|
252
|
-
/**
|
|
253
|
-
* To be added
|
|
254
|
-
*/
|
|
255
|
-
"@webiny/api-tenancy-so-ddb": context.version,
|
|
256
|
-
"@webiny/api-security-so-ddb": context.version,
|
|
257
|
-
/**
|
|
258
|
-
* To be removed
|
|
259
|
-
*/
|
|
260
|
-
"@webiny/api-security-admin-users": null,
|
|
261
|
-
"@webiny/api-security-admin-users-cognito": null,
|
|
262
|
-
"@webiny/api-security-admin-users-so-ddb": null,
|
|
263
|
-
"@webiny/api-security-cognito-authentication": null
|
|
264
|
-
};
|
|
265
|
-
addPackagesToDependencies(context, `${paths.apiPageBuilderExport}/combine`, packages);
|
|
266
|
-
addPackagesToDependencies(context, `${paths.apiPageBuilderExport}/process`, packages);
|
|
267
|
-
addPackagesToDependencies(context, `${paths.apiPageBuilderImport}/create`, packages);
|
|
268
|
-
addPackagesToDependencies(context, `${paths.apiPageBuilderImport}/process`, packages);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* @param project {tsMorph.Project}
|
|
273
|
-
* @param context {CliContext}
|
|
274
|
-
*/
|
|
275
|
-
const upgradeAdminComponents = (project, context) => {
|
|
276
|
-
const { info } = context;
|
|
277
|
-
info(`Upgrading ${info.hl(paths.appsAdminCode)}/src/components`);
|
|
278
|
-
|
|
279
|
-
const file = `${paths.appsAdminCode}/src/components/getIdentityData.ts`;
|
|
280
|
-
/**
|
|
281
|
-
* Remove the getIdentityFile
|
|
282
|
-
*/
|
|
283
|
-
deleteFiles(context, [file]);
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @param project {tsMorph.Project}
|
|
288
|
-
* @param context {CliContext}
|
|
289
|
-
*/
|
|
290
|
-
const upgradeAdminPlugins = (project, context) => {
|
|
291
|
-
const { info, error } = context;
|
|
292
|
-
info(`Upgrading ${info.hl(files.appAdminPluginsIndex)}`);
|
|
293
|
-
|
|
294
|
-
const source = project.getSourceFile(files.appAdminPluginsIndex);
|
|
295
|
-
/**
|
|
296
|
-
* Remove the @webiny/app/types import
|
|
297
|
-
*/
|
|
298
|
-
removeImportFromSourceFile(source, "@webiny/app/types");
|
|
299
|
-
/**
|
|
300
|
-
* Import tenancy plugins
|
|
301
|
-
*/
|
|
302
|
-
insertImportToSourceFile({
|
|
303
|
-
source,
|
|
304
|
-
name: {
|
|
305
|
-
plugins: "tenancyPlugins"
|
|
306
|
-
},
|
|
307
|
-
moduleSpecifier: "@webiny/app-tenancy",
|
|
308
|
-
after: "@webiny/plugins"
|
|
309
|
-
});
|
|
310
|
-
/**
|
|
311
|
-
* remove the plugins.byType<WebinyInitPlugin>("webiny-init")....
|
|
312
|
-
*/
|
|
313
|
-
const pluginsByTypeExpression = source.getFirstDescendant(node => {
|
|
314
|
-
if (tsMorph.Node.isExpressionStatement(node) === false) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
const text = node.getText();
|
|
318
|
-
return text.match("plugins.byType<WebinyInitPlugin>") !== null;
|
|
319
|
-
});
|
|
320
|
-
if (pluginsByTypeExpression) {
|
|
321
|
-
pluginsByTypeExpression.remove();
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Then we need to add new tenancy plugins into plugins.register([])
|
|
325
|
-
* And we need to find array expression that represents plugins first.
|
|
326
|
-
*/
|
|
327
|
-
const arrayExpression = findNodeInSource(source, [
|
|
328
|
-
{
|
|
329
|
-
matcher: tsMorph.Node.isExpressionStatement,
|
|
330
|
-
error: `Missing "plugins with registering".`
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
matcher: tsMorph.Node.isCallExpression,
|
|
334
|
-
info: `Missing "plugins.register" expression.`
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
matcher: tsMorph.Node.isArrayLiteralExpression,
|
|
338
|
-
info: `Missing "plugins.register([])" array expression .`
|
|
339
|
-
}
|
|
340
|
-
]);
|
|
341
|
-
if (!arrayExpression) {
|
|
342
|
-
error(
|
|
343
|
-
`Could not find "plugins.register([])" array expression in given source file "${files.appAdminPluginsIndex}".`
|
|
344
|
-
);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Find i18nContentPlugins in arrayExpression and add tenancyPlugins()
|
|
350
|
-
*/
|
|
351
|
-
let index = 0;
|
|
352
|
-
const i18nContentPlugins = arrayExpression.getElements().some(el => {
|
|
353
|
-
if (tsMorph.Node.isIdentifier(el) === false) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
index++;
|
|
357
|
-
return el.getText() === "i18nContentPlugins";
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
if (!i18nContentPlugins) {
|
|
361
|
-
error(
|
|
362
|
-
`Could not find "plugins.register([i18nContentPlugins])" in the array expression in given source file "${files.appAdminPluginsIndex}".`
|
|
363
|
-
);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
arrayExpression.insertElement(
|
|
368
|
-
index + 1,
|
|
369
|
-
`
|
|
370
|
-
/**
|
|
371
|
-
* Tenant installation.
|
|
372
|
-
*/
|
|
373
|
-
tenancyPlugins(),
|
|
374
|
-
/**
|
|
375
|
-
* Security app and authentication plugins.
|
|
376
|
-
*/`
|
|
377
|
-
);
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* @param project {tsMorph.Project}
|
|
381
|
-
* @param context {CliContext}
|
|
382
|
-
*/
|
|
383
|
-
const upgradeAdminSecurity = (project, context) => {
|
|
384
|
-
const { info } = context;
|
|
385
|
-
info(`Upgrading ${info.hl(files.appAdminPluginsSecurity)}`);
|
|
386
|
-
|
|
387
|
-
const packages = {
|
|
388
|
-
/**
|
|
389
|
-
* To add
|
|
390
|
-
*/
|
|
391
|
-
"@webiny/app-security-access-management": context.version,
|
|
392
|
-
"@webiny/app-admin-users-cognito": context.version,
|
|
393
|
-
/**
|
|
394
|
-
* To remove
|
|
395
|
-
*/
|
|
396
|
-
"@webiny/app-security-admin-users-cognito": null,
|
|
397
|
-
"@webiny/app-security-admin-users/plugins": null
|
|
398
|
-
};
|
|
399
|
-
addPackagesToDependencies(context, `${paths.appsAdminCode}`, packages);
|
|
400
|
-
|
|
401
|
-
const copyFileTargets = [
|
|
402
|
-
{
|
|
403
|
-
source: `node_modules/@webiny/cwp-template-aws/template/common/${files.appAdminPluginsSecurity}`,
|
|
404
|
-
destination: files.appAdminPluginsSecurity
|
|
405
|
-
}
|
|
406
|
-
];
|
|
407
|
-
copyFiles(context, copyFileTargets);
|
|
408
|
-
};
|
|
409
|
-
/**
|
|
410
|
-
* @param project {tsMorph.Project}
|
|
411
|
-
* @param context {CliContext}
|
|
412
|
-
*/
|
|
413
|
-
const upgradeApp = (project, context) => {
|
|
414
|
-
const { info } = context;
|
|
415
|
-
info(`Upgrading ${info.hl(files.appAdminApp)}`);
|
|
416
|
-
|
|
417
|
-
const copyFileTargets = [
|
|
418
|
-
{
|
|
419
|
-
source: `node_modules/@webiny/cwp-template-aws/template/common/${files.appAdminApp}`,
|
|
420
|
-
destination: files.appAdminApp
|
|
421
|
-
}
|
|
422
|
-
];
|
|
423
|
-
copyFiles(context, copyFileTargets);
|
|
424
|
-
|
|
425
|
-
addPackagesToDependencies(context, paths.appsAdminCode, {
|
|
426
|
-
/**
|
|
427
|
-
* To be added.
|
|
428
|
-
*/
|
|
429
|
-
"@webiny/app-admin-users-cognito": context.version,
|
|
430
|
-
"@webiny/app-page-builder-elements": context.version,
|
|
431
|
-
"@webiny/app-security-access-management": context.version,
|
|
432
|
-
/**
|
|
433
|
-
* To be removed.
|
|
434
|
-
*/
|
|
435
|
-
"@webiny/app-security-admin-users": null,
|
|
436
|
-
"@webiny/app-security-admin-users-cognito": null
|
|
437
|
-
});
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* @param source {tsMorph.SourceFile}
|
|
442
|
-
* @param target {string}
|
|
443
|
-
*/
|
|
444
|
-
const insertReactAppUserCanChangeEmail = (source, target) => {
|
|
445
|
-
const commandProperty = source.getFirstDescendant(node => {
|
|
446
|
-
if (tsMorph.Node.isMethodDeclaration(node) === false) {
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
const identifier = node.getFirstDescendant(ident => {
|
|
450
|
-
return tsMorph.Node.isIdentifier(ident) && ident.getText() === target;
|
|
451
|
-
});
|
|
452
|
-
return !!identifier;
|
|
453
|
-
});
|
|
454
|
-
if (!commandProperty) {
|
|
455
|
-
error(`Missing "command.${target}" property in "${files.appAdminWebinyConfig}".`);
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
*
|
|
460
|
-
* @type {tsMorph.ExpressionStatement}
|
|
461
|
-
*/
|
|
462
|
-
const commandExpr = commandProperty.getFirstDescendant(node => {
|
|
463
|
-
if (tsMorph.Node.isExpressionStatement(node) === false) {
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
return node.getText() === "Object.assign(process.env, output);";
|
|
467
|
-
});
|
|
468
|
-
if (!commandExpr) {
|
|
469
|
-
error(
|
|
470
|
-
`Missing "command.${target}" "Object.assign" expression in "${files.appAdminWebinyConfig}".`
|
|
471
|
-
);
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
source.insertText(
|
|
476
|
-
commandExpr.getEnd() + 1,
|
|
477
|
-
`
|
|
478
|
-
process.env.REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL = "false";
|
|
479
|
-
`
|
|
480
|
-
);
|
|
481
|
-
};
|
|
482
|
-
/**
|
|
483
|
-
* @param project {tsMorph.Project}
|
|
484
|
-
* @param context {CliContext}
|
|
485
|
-
*/
|
|
486
|
-
const upgradeAppWebinyConfig = (project, context) => {
|
|
487
|
-
const { info } = context;
|
|
488
|
-
info(`Upgrading ${info.hl(files.appAdminWebinyConfig)}`);
|
|
489
|
-
|
|
490
|
-
const source = project.getSourceFile(files.appAdminWebinyConfig);
|
|
491
|
-
/**
|
|
492
|
-
* First we need to add the REACT_APP_USER_POOL_PASSWORD_POLICY
|
|
493
|
-
*/
|
|
494
|
-
const apiMapDeclaration = source.getFirstDescendant(node => {
|
|
495
|
-
if (tsMorph.Node.isVariableDeclaration(node) === false) {
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
const apiMapIdentifier = node.getFirstDescendant(identifier => {
|
|
499
|
-
if (tsMorph.Node.isIdentifier(identifier) === false) {
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
return identifier.getText() === "API_MAP";
|
|
503
|
-
});
|
|
504
|
-
return !!apiMapIdentifier;
|
|
505
|
-
});
|
|
506
|
-
if (!apiMapDeclaration) {
|
|
507
|
-
error(`Missing "API_MAP" declaration in "${files.appAdminWebinyConfig}".`);
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
const expr = apiMapDeclaration.getFirstDescendant(node => {
|
|
511
|
-
return tsMorph.Node.isObjectLiteralExpression(node);
|
|
512
|
-
});
|
|
513
|
-
if (!expr) {
|
|
514
|
-
error(
|
|
515
|
-
`Missing "API_MAP" "ObjectLiteralExpression" declaration in "${files.appAdminWebinyConfig}".`
|
|
516
|
-
);
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
const assigmentExists = expr.getProperty("REACT_APP_USER_POOL_PASSWORD_POLICY");
|
|
520
|
-
if (!assigmentExists) {
|
|
521
|
-
expr.addPropertyAssignment({
|
|
522
|
-
name: "REACT_APP_USER_POOL_PASSWORD_POLICY",
|
|
523
|
-
initializer: '"${cognitoUserPoolPasswordPolicy}"'
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* And then new env variable in both build and start commands: REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL = false
|
|
528
|
-
*/
|
|
529
|
-
insertReactAppUserCanChangeEmail(source, "start");
|
|
530
|
-
insertReactAppUserCanChangeEmail(source, "build");
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* @param project {tsMorph.Project}
|
|
534
|
-
* @param context {CliContext}
|
|
535
|
-
* @param file {string}
|
|
536
|
-
*/
|
|
537
|
-
const upgradePulumi = (project, context, file) => {
|
|
538
|
-
const { info, error } = context;
|
|
539
|
-
info(`Upgrading ${info.hl(file)}`);
|
|
540
|
-
|
|
541
|
-
const source = project.getSourceFile(file);
|
|
542
|
-
if (!source) {
|
|
543
|
-
error(`Could not locate file "${file}".`);
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* We need to find the default export return statement
|
|
548
|
-
*/
|
|
549
|
-
const defaultExport = findDefaultExport(source);
|
|
550
|
-
if (!defaultExport) {
|
|
551
|
-
error(`Could not locate default export in file "${file}".`);
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const returnStatement = findReturnStatement(defaultExport);
|
|
556
|
-
if (!returnStatement) {
|
|
557
|
-
error(`Could not locate return statement in default export in file "${file}".`);
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* @type {ObjectLiteralExpression}
|
|
562
|
-
*/
|
|
563
|
-
const obj = returnStatement.getFirstDescendant(node =>
|
|
564
|
-
tsMorph.Node.isObjectLiteralExpression(node)
|
|
565
|
-
);
|
|
566
|
-
if (!obj) {
|
|
567
|
-
error(
|
|
568
|
-
`Could not locate object expression return statement in default export in file "${file}".`
|
|
569
|
-
);
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
const prop = obj.getProperty("cognitoUserPoolPasswordPolicy");
|
|
574
|
-
if (!prop) {
|
|
575
|
-
obj.addPropertyAssignment({
|
|
576
|
-
name: "cognitoUserPoolPasswordPolicy",
|
|
577
|
-
initializer: "cognito.userPool.passwordPolicy"
|
|
578
|
-
});
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
prop.setInitializer("cognito.userPool.passwordPolicy");
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* @param project {tsMorph.Project}
|
|
586
|
-
* @param context {CliContext}
|
|
587
|
-
*/
|
|
588
|
-
const upgradePulumiDev = (project, context) => {
|
|
589
|
-
return upgradePulumi(project, context, files.apiPulumiDevIndex);
|
|
590
|
-
};
|
|
591
|
-
/**
|
|
592
|
-
* @param project {tsMorph.Project}
|
|
593
|
-
* @param context {CliContext}
|
|
594
|
-
*/
|
|
595
|
-
const upgradePulumiProd = (project, context) => {
|
|
596
|
-
return upgradePulumi(project, context, files.apiPulumiProdIndex);
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
module.exports = {
|
|
600
|
-
files,
|
|
601
|
-
upgradeGraphQLIndex,
|
|
602
|
-
upgradeHeadlessCMSIndex,
|
|
603
|
-
upgradePageImportExport,
|
|
604
|
-
upgradeAdminComponents,
|
|
605
|
-
upgradeAdminPlugins,
|
|
606
|
-
upgradeAdminSecurity,
|
|
607
|
-
upgradeApp,
|
|
608
|
-
upgradeAppWebinyConfig,
|
|
609
|
-
upgradePulumiDev,
|
|
610
|
-
upgradePulumiProd
|
|
611
|
-
};
|