@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,144 +0,0 @@
1
- const path = require("path");
2
- const execa = require("execa");
3
- const { createMorphProject, addPackagesToDependencies } = require("../utils");
4
- const {
5
- upgradeGraphQLIndex,
6
- upgradeGraphQLSecurity,
7
- upgradeHeadlessSecurity,
8
- upgradeAdminApp,
9
- upgradeAdminGetIdentityData,
10
- upgradeAdminSecurity
11
- } = require("./upgradeSecurity");
12
-
13
- const { upgradeTelemetry } = require("./upgradeTelemetry");
14
- const { upgradeScaffolding } = require("./upgradeScaffolding");
15
-
16
- const targetVersion = "5.9.0";
17
-
18
- /**
19
- * @type {CliUpgradePlugin}
20
- */
21
- module.exports = {
22
- name: "upgrade-5.9.0",
23
- type: "cli-upgrade",
24
- version: targetVersion,
25
- /**
26
- * @param options {CliUpgradePluginOptions}
27
- * @param context {CliContext}
28
- * @returns {Promise<boolean>}
29
- */
30
- async canUpgrade(options, context) {
31
- if (context.version === targetVersion) {
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, error } = context;
46
-
47
- const files = [
48
- "api/code/graphql/src/index.ts",
49
- "api/code/graphql/src/security.ts",
50
- "api/code/headlessCMS/src/security.ts",
51
- "apps/admin/code/src/App.tsx",
52
- "apps/admin/code/src/components/getIdentityData.ts",
53
- "apps/admin/code/src/plugins/security.ts",
54
- "apps/admin/code/src/components/Telemetry.tsx"
55
- ];
56
-
57
- const upgrade = createMorphProject(files.map(f => path.resolve(process.cwd(), f)));
58
-
59
- // api/code/graphql/src/index.ts
60
- await upgradeGraphQLIndex(upgrade.getSourceFile(files[0]), files[0], context);
61
-
62
- // api/code/graphql/src/security.ts
63
- await upgradeGraphQLSecurity(upgrade.getSourceFile(files[1]), files[1], context);
64
-
65
- // api/code/headlessCMS/src/security.ts
66
- await upgradeHeadlessSecurity(upgrade.getSourceFile(files[2]), files[2], context);
67
-
68
- // apps/admin/code/src/App.tsx
69
- await upgradeAdminApp(upgrade.getSourceFile(files[3]), files[3], context);
70
-
71
- // apps/admin/code/src/components/getIdentityData.ts
72
- await upgradeAdminGetIdentityData(upgrade.getSourceFile(files[4]), files[4], context);
73
-
74
- // apps/admin/code/src/plugins/security.ts
75
- await upgradeAdminSecurity(upgrade.getSourceFile(files[5]), files[5], context);
76
-
77
- // apps/admin/code/src/components/Telemetry.tsx
78
- await upgradeTelemetry(upgrade.getSourceFile(files[6]), files[6], context);
79
-
80
- context.info("Adding dependencies...");
81
-
82
- addPackagesToDependencies(path.resolve(process.cwd(), "api/code/graphql"), {
83
- "@webiny/api-security-tenancy": null,
84
- "@webiny/api-security-admin-users": targetVersion,
85
- "@webiny/api-admin-users-cognito": targetVersion,
86
- "@webiny/api-security-cognito-authentication": targetVersion,
87
- "@webiny/api-tenancy": targetVersion
88
- });
89
-
90
- addPackagesToDependencies(path.resolve(process.cwd(), "api/code/headlessCMS"), {
91
- "@webiny/api-plugin-security-cognito": null,
92
- "@webiny/api-security-tenancy": null,
93
- "@webiny/api-security-admin-users": targetVersion,
94
- "@webiny/api-security-cognito-authentication": targetVersion,
95
- "@webiny/api-tenancy": targetVersion
96
- });
97
-
98
- addPackagesToDependencies(path.resolve(process.cwd(), "apps/admin/code"), {
99
- "@webiny/app-plugin-security-cognito": null,
100
- "@webiny/app-security-tenancy": null,
101
- "@webiny/app-security-admin-users": targetVersion,
102
- "@webiny/app-security-admin-users-cognito": targetVersion,
103
- "@webiny/app-tenancy": targetVersion,
104
- "@webiny/tracking": null,
105
- "@webiny/telemetry": targetVersion
106
- });
107
-
108
- context.info("Writing changes...");
109
- await upgrade.save();
110
-
111
- // Perform scaffolding and DX related upgrades.
112
- await upgradeScaffolding(context, targetVersion);
113
-
114
- try {
115
- info("Running prettier...");
116
- const config = context.resolve(".prettierrc.js");
117
- const { stdout: prettierBin } = await execa("yarn", ["bin", "prettier"]);
118
- const source = files.map(f => path.resolve(process.cwd(), f));
119
- await execa("node", [prettierBin, "--write", "--config", config, ...source]);
120
- info("Finished formatting files.");
121
- } catch (ex) {
122
- console.log(error.hl("Prettier failed."));
123
- console.log(error(ex.message));
124
- if (ex.stdout) {
125
- console.log(ex.stdout);
126
- }
127
- }
128
-
129
- /**
130
- * Run yarn to install new package
131
- */
132
- try {
133
- info("Installing new packages...");
134
- await execa("yarn");
135
- info("Finished installing new packages.");
136
- } catch (ex) {
137
- error("Installation of new packages failed.");
138
- console.log(error(ex.message));
139
- if (ex.stdout) {
140
- console.log(ex.stdout);
141
- }
142
- }
143
- }
144
- };
@@ -1 +0,0 @@
1
- module.exports = require("../../../.babel.node")({ path: __dirname });
@@ -1,40 +0,0 @@
1
- const base = require("../../../jest.config.base");
2
- const { log } = require("@webiny/cli/utils");
3
- const { getStackOutput } = require("@webiny/cli-plugin-deploy-pulumi/utils");
4
-
5
- /**
6
- * `getStackOutput` retrieves all values that were exported from `api/pulumi/dev/index.ts`.
7
- * Note that this means the project needs to be already deployed into the "dev" environment.
8
- * If you want to use a different environment for testing purposes, change the `env` argument.
9
- * Finally, note that usually we don't need to perform this step if we're running unit tests.
10
- */
11
-
12
- const TEST_TYPE = process.env.TEST_TYPE;
13
- const DEPLOY_ENVIRONMENT = "dev";
14
-
15
- if (TEST_TYPE !== "unit") {
16
- log.info(`${__dirname} Assigning environment variables...`);
17
- const stackOutput = getStackOutput({ folder: "api", env: DEPLOY_ENVIRONMENT });
18
-
19
- if (stackOutput) {
20
- // Assign received values as environment variables.
21
- Object.assign(process.env, {
22
- // We assign `region`, `dynamoDbTable`, and `apiUrl` as AWS_REGION, DB_TABLE, and API_URL
23
- // environment variables. If needed, you can export additional values from the mentioned
24
- // `api/pulumi/dev/index.ts` file and assign them here.
25
- AWS_REGION: stackOutput.region,
26
- DB_TABLE: stackOutput.dynamoDbTable,
27
- API_URL: stackOutput.apiUrl,
28
-
29
- // Can be of use while writing tests, for example to distinguish test data from non-test data.
30
- TEST_RUN_ID: new Date().getTime()
31
- });
32
- log.success("Environment variables successfully assigned.");
33
- } else {
34
- log.warning(`Could not assign environment variables.`);
35
- }
36
- console.log();
37
- }
38
-
39
- // Finally, export Jest config to be used while tests are being run.
40
- module.exports = { ...base({ path: __dirname }) };
@@ -1,337 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const loadJsonFile = require("load-json-file");
4
- const writeJsonFile = require("write-json-file");
5
- const { addPackagesToDevDependencies } = require("../utils");
6
- const { Project, Node } = require("ts-morph");
7
- const { log } = require("@webiny/cli/utils");
8
-
9
- /**
10
- * Applies a couple of changes related to new scaffolds and DX improvements.
11
- * @param context
12
- * @param targetVersion
13
- * @returns {Promise<void>}
14
- */
15
- const upgradeScaffolding = async (context, targetVersion) => {
16
- // Base paths.
17
- const gqlPath = path.join(context.project.root, "api", "code", "graphql");
18
- const cmsPath = path.join(context.project.root, "api", "code", "headlessCMS");
19
-
20
- // GraphQL & Headless CMS - create ".babelrc.js" and "jest.config.js" files.
21
- [gqlPath, cmsPath].forEach(appPath => cpBabelRcJestConfig(appPath));
22
-
23
- // Add support for importing packages via "~".
24
- updateTsConfigWithSupportForTildeImports(path.join(gqlPath, "tsconfig.json"));
25
- updateTsConfigWithSupportForTildeImports(path.join(cmsPath, "tsconfig.json"));
26
-
27
- // Edit jest.config.base.js - enable running tests from any folder by adding "**".
28
- updateJestConfigBase(path.join(context.project.root, "jest.config.base.js"));
29
-
30
- // Add @webiny/cli-plugin-deploy-pulumi to "devDependencies".
31
- addCliPluginDeployPulumiToDevDeps(gqlPath, targetVersion);
32
- addCliPluginDeployPulumiToDevDeps(cmsPath, targetVersion);
33
-
34
- addCrossEnvToRootDevDeps(context.project.root);
35
-
36
- // Create new scaffolds folder and index.ts file.
37
- createScaffoldsFolder(path.join(gqlPath, "src", "plugins", "scaffolds"));
38
- createScaffoldsFolder(path.join(cmsPath, "src", "plugins", "scaffolds"));
39
-
40
- // Import "scaffoldsPlugins" in "index.ts" file.
41
- await addScaffoldsPlugins(path.join(gqlPath, "src/index.ts"));
42
- await addScaffoldsPlugins(path.join(cmsPath, "src/index.ts"));
43
-
44
- // Make sure "dynamoDbTable: dynamoDb.table.name" is exported in the exported object.
45
- await addDynamoDbTableExport(
46
- path.join(context.project.root, "api", "pulumi", "dev", "index.ts")
47
- );
48
-
49
- await addDynamoDbTableExport(
50
- path.join(context.project.root, "api", "pulumi", "prod", "index.ts")
51
- );
52
- };
53
-
54
- /**
55
- * Add @webiny/cli-plugin-deploy-pulumi to "devDependencies".
56
- * @param appPath
57
- * @param targetVersion
58
- */
59
- const addCliPluginDeployPulumiToDevDeps = (appPath, targetVersion) => {
60
- const { info, error } = log;
61
-
62
- const name = "@webiny/cli-plugin-deploy-pulumi";
63
- const packageJsonPath = path.join(appPath, "package.json");
64
-
65
- try {
66
- info(`Adding ${info.hl(name)} to ${info.hl(packageJsonPath)}...`);
67
- addPackagesToDevDependencies(appPath, {
68
- "@webiny/cli-plugin-deploy-pulumi": `^${targetVersion}`
69
- });
70
- } catch (e) {
71
- error(`Failed adding ${info.hl(name)} to ${info.hl(packageJsonPath)}:`);
72
- console.log(e);
73
- }
74
- };
75
-
76
- /**
77
- * Add `"cross-env": "^5.0.2"` to root package.json.
78
- * @param projectRootPath
79
- */
80
- const addCrossEnvToRootDevDeps = projectRootPath => {
81
- const { info, error } = log;
82
-
83
- const name = "cross-env";
84
- const targetVersion = "^5.0.2";
85
-
86
- const packageJsonPath = path.join(projectRootPath, "package.json");
87
-
88
- try {
89
- info(`Adding ${info.hl(name)} to ${info.hl(packageJsonPath)}...`);
90
- addPackagesToDevDependencies(projectRootPath, {
91
- [name]: targetVersion
92
- });
93
- } catch (e) {
94
- error(`Failed adding ${info.hl(name)} to ${info.hl(packageJsonPath)}:`);
95
- console.log(e);
96
- }
97
- };
98
-
99
- /**
100
- * Edit jest.config.base.js - enable running tests from any folder by adding "**".
101
- * @param jestConfigBasePath
102
- */
103
- const updateJestConfigBase = jestConfigBasePath => {
104
- const { info, error, warning } = log;
105
-
106
- try {
107
- let jestConfigBase = fs.readFileSync(jestConfigBasePath).toString("utf8");
108
-
109
- if (jestConfigBase.includes("testMatch: [`${path}/**/__tests__")) {
110
- warning(
111
- `Skipping updating ${warning.hl(jestConfigBasePath)} - changes already applied.`
112
- );
113
- return;
114
- }
115
-
116
- info(`Updating ${info.hl(jestConfigBasePath)}...`);
117
- jestConfigBase = jestConfigBase.replace(
118
- `const name = basename(path);`,
119
- "const name = basename(path);\n" +
120
- ` // Enables us to run tests of only a specific type (for example "integration" or "e2e").
121
- let type = "";
122
- if (process.env.TEST_TYPE) {
123
- type = \`.${process.env.TEST_TYPE}\`;
124
- }`
125
- );
126
-
127
- jestConfigBase = jestConfigBase.replace(
128
- "testMatch: [`${path}/__tests__/**/*.test.[jt]s?(x)`],",
129
- "testMatch: [`${path}/**/__tests__/**/*${type}.test.[jt]s?(x)`],"
130
- );
131
-
132
- fs.writeFileSync(jestConfigBasePath, jestConfigBase);
133
- } catch (e) {
134
- error(`Failed updating ${error.hl(jestConfigBasePath)}:`);
135
- console.log(e);
136
- }
137
- };
138
-
139
- /**
140
- * Copy/paste new ".babelrc.js" and "jest.config.js" files.
141
- * @param appPath
142
- */
143
- const cpBabelRcJestConfig = appPath => {
144
- const filesFolder = path.join(__dirname, "upgradeScaffolding");
145
- const { info, error, warning } = log;
146
-
147
- const babelRcPath = path.join(appPath, ".babelrc.js");
148
- try {
149
- if (fs.existsSync(babelRcPath)) {
150
- warning(`Skipping creation of ${warning.hl(babelRcPath)} - already exists.`);
151
- } else {
152
- info(`Creating ${info.hl(babelRcPath)}...`);
153
- fs.copyFileSync(path.join(filesFolder, "babelrc.js"), babelRcPath);
154
- }
155
- } catch (e) {
156
- error(`Failed creating ${error.hl(babelRcPath)}:`);
157
- console.log(e);
158
- }
159
-
160
- const jestConfigPath = path.join(appPath, "jest.config.js");
161
- try {
162
- if (fs.existsSync(jestConfigPath)) {
163
- warning(`Skipping creation of ${warning.hl(jestConfigPath)} - already exists.`);
164
- } else {
165
- info(`Creating ${info.hl(jestConfigPath)}...`);
166
- fs.copyFileSync(path.join(filesFolder, "jestConfig.js"), jestConfigPath);
167
- }
168
- } catch (e) {
169
- error(`Failed creating ${error.hl(jestConfigPath)}:`);
170
- console.log(e);
171
- }
172
- };
173
-
174
- /**
175
- * Add support for importing packages via "~".
176
- * @param tsConfigPath
177
- */
178
- const updateTsConfigWithSupportForTildeImports = tsConfigPath => {
179
- const { info, error } = log;
180
-
181
- // Add support for importing packages via "~".
182
- try {
183
- info(`Updating ${info.hl(tsConfigPath)}...`);
184
- let tsConfig = loadJsonFile.sync(tsConfigPath);
185
- if (!tsConfig) {
186
- tsConfig = {};
187
- }
188
-
189
- if (!tsConfig.compilerOptions) {
190
- tsConfig.compilerOptions = {};
191
- }
192
-
193
- if (!tsConfig.compilerOptions.baseUrl) {
194
- tsConfig.compilerOptions.baseUrl = ".";
195
- }
196
-
197
- if (!tsConfig.compilerOptions.paths) {
198
- tsConfig.compilerOptions.paths = {};
199
- }
200
-
201
- if (!tsConfig.compilerOptions.paths["~/*"]) {
202
- tsConfig.compilerOptions.paths["~/*"] = ["./src/*"];
203
- }
204
-
205
- writeJsonFile.sync(tsConfigPath, tsConfig);
206
- } catch (e) {
207
- error(`Failed updating ${error.hl(tsConfigPath)}:`);
208
- console.log(e);
209
- }
210
- };
211
-
212
- /**
213
- * Make sure "dynamoDbTable: dynamoDb.table.name" is exported in the exported object.
214
- * @param filePath
215
- * @returns {Promise<*>}
216
- */
217
- const addDynamoDbTableExport = async filePath => {
218
- const { info, error, warning } = log;
219
-
220
- try {
221
- const content = fs.readFileSync(filePath).toString("utf8");
222
- if (content.includes("dynamoDbTable: dynamoDb.table.name")) {
223
- warning(
224
- `Skipping adding ${warning.hl(
225
- "dynamoDbTable: dynamoDb.table.name"
226
- )} to ${warning.hl(filePath)} - changes already applied.`
227
- );
228
-
229
- return;
230
- }
231
-
232
- info(`Adding ${info.hl("dynamoDbTable: dynamoDb.table.name")} to ${info.hl(filePath)}...`);
233
-
234
- const project = new Project();
235
- project.addSourceFileAtPath(filePath);
236
-
237
- const source = project.getSourceFileOrThrow(filePath);
238
-
239
- const defaultExport = source.getFirstDescendant(node => Node.isExportAssignment(node));
240
- const arrowFunction = defaultExport.getFirstDescendant(node => Node.isArrowFunction(node));
241
- const returnStatement = arrowFunction.getFirstDescendant(node =>
242
- Node.isReturnStatement(node)
243
- );
244
- const returnObjectLiteral = returnStatement.getFirstChild(node =>
245
- Node.isObjectLiteralExpression(node)
246
- );
247
-
248
- returnObjectLiteral.insertProperty(0, "dynamoDbTable: dynamoDb.table.name");
249
-
250
- return source.save();
251
- } catch (e) {
252
- error(
253
- `Failed adding ${error.hl("dynamoDbTable: dynamoDb.table.name")} to ${error.hl(
254
- filePath
255
- )}:`
256
- );
257
- console.log(e);
258
- }
259
- };
260
-
261
- /**
262
- * Import "scaffoldsPlugins" in "index.ts" file.
263
- * @param indexPath
264
- * @returns {Promise<*>}
265
- */
266
- const addScaffoldsPlugins = async indexPath => {
267
- const { info, error, warning } = log;
268
-
269
- try {
270
- const content = fs.readFileSync(indexPath).toString("utf8");
271
- if (content.includes("scaffoldsPlugins")) {
272
- warning(
273
- `Skipping importing and adding ${warning.hl("scaffoldsPlugins")} in ${warning.hl(
274
- indexPath
275
- )} - changes already applied.`
276
- );
277
- return;
278
- }
279
-
280
- info(`Importing and adding ${info.hl("scaffoldsPlugins")} in ${info.hl(indexPath)}...`);
281
-
282
- const project = new Project();
283
- project.addSourceFileAtPath(indexPath);
284
-
285
- const source = project.getSourceFileOrThrow(indexPath);
286
-
287
- // If import declaration exists, exit.
288
- if (source.getImportDeclaration("./plugins/scaffolds")) {
289
- return;
290
- }
291
-
292
- let index = 1;
293
-
294
- const importDeclarations = source.getImportDeclarations();
295
- const lastImportDeclaration = importDeclarations[importDeclarations.length - 1];
296
- index = lastImportDeclaration.getChildIndex() + 1;
297
-
298
- source.insertImportDeclaration(index, {
299
- defaultImport: "scaffoldsPlugins",
300
- moduleSpecifier: "./plugins/scaffolds"
301
- });
302
-
303
- const pluginsObject = source.getFirstDescendant(node => {
304
- if (Node.isPropertyAssignment(node) && node.getName() === "plugins") {
305
- return node;
306
- }
307
- });
308
-
309
- const pluginsArray = pluginsObject.getInitializer();
310
- pluginsArray.addElement("scaffoldsPlugins()");
311
-
312
- return source.save();
313
- } catch (e) {
314
- error(
315
- `Failed importing and adding ${error.hl("scaffoldsPlugins")} in ${error.hl(indexPath)}:`
316
- );
317
- console.log(e);
318
- }
319
- };
320
-
321
- const content = `// This file is automatically updated via various scaffolding utilities.
322
-
323
- export default () => [];`;
324
-
325
- const createScaffoldsFolder = folder => {
326
- fs.mkdirSync(folder, { recursive: true });
327
- const indexPath = path.join(folder, "index.ts");
328
- if (fs.existsSync(indexPath)) {
329
- return;
330
- }
331
-
332
- fs.writeFileSync(indexPath, content);
333
- };
334
-
335
- module.exports = {
336
- upgradeScaffolding
337
- };