generator-easy-ui5 2.4.6 → 3.1.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +66 -168
  3. package/generators/app/index.js +392 -171
  4. package/generators/app/postinstall.js +121 -0
  5. package/package.json +23 -18
  6. package/generators/additionalmodules/index.js +0 -222
  7. package/generators/additionalmodules/templates/approuter/package.json +0 -13
  8. package/generators/additionalmodules/templates/deployer/readme.md +0 -3
  9. package/generators/additionalmodules/templates/xs-security.json +0 -20
  10. package/generators/app/templates/_.editorconfig +0 -8
  11. package/generators/app/templates/_.eslintignore +0 -4
  12. package/generators/app/templates/_.eslintrc +0 -48
  13. package/generators/app/templates/_.gitignore +0 -11
  14. package/generators/app/templates/karma-ci.conf.js +0 -21
  15. package/generators/app/templates/karma.conf.js +0 -17
  16. package/generators/app/templates/readme.md +0 -6
  17. package/generators/newcomponent/index.js +0 -82
  18. package/generators/newcontrol/index.js +0 -81
  19. package/generators/newcontrol/templates/webapp/control/template.js +0 -23
  20. package/generators/newmodel/index.js +0 -142
  21. package/generators/newopa5journey/index.js +0 -99
  22. package/generators/newopa5journey/templates/test/integration/$journey.js +0 -23
  23. package/generators/newopa5po/index.js +0 -107
  24. package/generators/newopa5po/templates/test/integration/pages/$poFile.js +0 -43
  25. package/generators/newuiveri5po/index.js +0 -84
  26. package/generators/newuiveri5po/templates/pages/$poFile.js +0 -20
  27. package/generators/newuiveri5spec/index.js +0 -51
  28. package/generators/newuiveri5spec/templates/$specName.spec.js +0 -22
  29. package/generators/newview/index.js +0 -156
  30. package/generators/newview/templates/webapp/controller/$ViewName.controller.js +0 -7
  31. package/generators/newview/templates/webapp/view/$ViewName.view.$ViewEnding +0 -51
  32. package/generators/newwebapp/index.js +0 -239
  33. package/generators/newwebapp/templates/uimodule/ui5.yaml +0 -73
  34. package/generators/newwebapp/templates/uimodule/webapp/Component.js +0 -30
  35. package/generators/newwebapp/templates/uimodule/webapp/controller/BaseController.js +0 -70
  36. package/generators/newwebapp/templates/uimodule/webapp/css/style.css +0 -1
  37. package/generators/newwebapp/templates/uimodule/webapp/flpSandbox.html +0 -66
  38. package/generators/newwebapp/templates/uimodule/webapp/i18n/i18n.properties +0 -3
  39. package/generators/newwebapp/templates/uimodule/webapp/i18n/i18n_en.properties +0 -3
  40. package/generators/newwebapp/templates/uimodule/webapp/index.html +0 -29
  41. package/generators/newwebapp/templates/uimodule/webapp/manifest.json +0 -92
  42. package/generators/newwebapp/templates/uimodule/webapp/model/formatter.js +0 -4
  43. package/generators/newwebapp/templates/uimodule/webapp/model/models.js +0 -14
  44. package/generators/newwebapp/templates/uimodule/webapp/resources/img/favicon.ico +0 -0
  45. package/generators/newwebapp/templates/uimodule/webapp/xs-app.json +0 -11
  46. package/generators/opa5/index.js +0 -114
  47. package/generators/opa5/templates/test/integration/AllJourneys.js +0 -13
  48. package/generators/opa5/templates/test/integration/arrangements/Startup.js +0 -19
  49. package/generators/opa5/templates/test/integration/opaTests.qunit.html +0 -32
  50. package/generators/opa5/templates/test/integration/opaTests.qunit.js +0 -13
  51. package/generators/opa5/templates/test/testsuite.qunit.html +0 -10
  52. package/generators/opa5/templates/test/testsuite.qunit.js +0 -10
  53. package/generators/uiveri5/index.js +0 -144
  54. package/generators/uiveri5/templates/.gitignore +0 -2
  55. package/generators/uiveri5/templates/README.md +0 -11
  56. package/generators/uiveri5/templates/conf.js +0 -16
  57. package/generators/wdi5/index.js +0 -96
  58. package/generators/wdi5/templates/.gitignore +0 -1
  59. package/generators/wdi5/templates/README-wdi5.md +0 -39
  60. package/generators/wdi5/templates/basic.test.js +0 -17
  61. package/generators/wdi5/templates/wdio-wdi5.conf.js +0 -282
  62. package/helpers/fileaccess.js +0 -90
@@ -1,96 +0,0 @@
1
- const Generator = require("yeoman-generator");
2
- const fileaccess = require("../../helpers/fileaccess");
3
-
4
- module.exports = class extends Generator {
5
- constructor(args, opts) {
6
- super(args, opts);
7
- }
8
-
9
- async prompting() {
10
- let prompts = [];
11
- prompts.push({
12
- type: "input",
13
- name: "wdi5ConfPath",
14
- message: "In what directory do you want the wdi5 config file to live?",
15
- default: "./"
16
- });
17
- prompts.push({
18
- type: "input",
19
- name: "wdi5TestDirName",
20
- message: "In what directory do the wdi5 tests live?",
21
- default: "uimodule/webapp/test/wdi5"
22
- });
23
- prompts.push({
24
- type: "input",
25
- name: "baseUrl",
26
- message: "What's the URL of the app under test?",
27
- default: "http://localhost:8080"
28
- });
29
- prompts.push({
30
- type: "input",
31
- name: "indexFile",
32
- message: "What's the name of the index (\"UI5-bootstrap\"-) file of the app under test?",
33
- default: "index.html"
34
- });
35
-
36
- this.answers = await this.prompt(prompts);
37
- }
38
-
39
- async writing() {
40
- // merging config for convenience
41
- Object.assign(this.answers, this.config.getAll());
42
-
43
- // wdi5 config file
44
- this.fs.copyTpl(
45
- this.templatePath("wdio-wdi5.conf.js"),
46
- this.destinationPath(this.answers.wdi5ConfPath, "wdio-wdi5.conf.js"),
47
- this.answers
48
- );
49
-
50
- // sample test file
51
- this.fs.copyTpl(
52
- this.templatePath("basic.test.js"),
53
- this.destinationPath(this.answers.wdi5TestDirName, "basic.test.js"),
54
- this.answers
55
- );
56
-
57
- // mingle path to where the wdi5 config file should live
58
- let _configPath;
59
- if (this.answers.wdi5ConfPath.endsWith("/")) {
60
- _configPath = this.answers.wdi5ConfPath.slice(0, -1);
61
- } else {
62
- _configPath = this.answers.wdi5ConfPath;
63
- }
64
- this.log("[wdi5] we'll modify /package.json for you for including wdi5");
65
- this.log("[wdi5] so it's safe to allow overwriting the file!");
66
- await fileaccess.manipulateJSON.call(this, "/package.json", function (pkg) {
67
- pkg.scripts.wdi5 = `wdio ${_configPath}/wdio-wdi5.conf.js`;
68
- pkg.devDependencies["wdio-ui5-service"] = "*";
69
- return pkg;
70
- }.bind(this));
71
-
72
- }
73
-
74
- install() {
75
- this.config.set("setupCompleted", true);
76
- this.log("[wdi5] using wdio cli for installing required node modules...");
77
- // do the wdio config boogie for defaults
78
- process.chdir(this.destinationPath());
79
- this.spawnCommandSync("npm", ["i", "@wdio/cli"]); // we need this as a prereq for next npx call
80
- this.spawnCommandSync("npx", ["wdio", "config", "-y"]); // generate a std wdio conf for receiving npm module deps
81
- // delete the shipped wdio.conf.js (from wdio defaults)
82
- // as it doesn't contain wdi5
83
- this.log("[wdi5] it's safe (!) to delete the default wdio.conf.js");
84
- this.log(`[wdi5] a specific wdio-wdi5.conf.js is provided at ${this.answers.wdi5ConfPath} !`);
85
- this.fs.delete(this.destinationPath("wdio.conf.js"));
86
-
87
- // quicker than this.installDependencies()
88
- this.spawnCommandSync("npm", ["i", "wdio-ui5-service"]);
89
- }
90
-
91
- end() {
92
- this.log("[wdi5] good to go!");
93
- this.log("[wdi5] 1. start the ui5 app via 'npm run start'");
94
- this.log("[wdi5] 2. run wdi5 tests via 'npm run wdi5'");
95
- }
96
- };
@@ -1 +0,0 @@
1
- /node_modules
@@ -1,39 +0,0 @@
1
- # wdi5 (sub-)generator and tests
2
-
3
- This subgenerator bootstraps a basic [wdi5](https://github.com/js-soft/wdi5) config for a UI5 application and provides a sample test file.
4
-
5
- ## How to use the wdi5 (sub-)generator
6
-
7
- You need to run the `wdi5`-(sub-)generator inside a UI5 project (generated by `easy-ui5`):
8
-
9
- ```bash
10
- $> cd yourEasyUI5-project
11
- $> yo easy-ui5:wdi5
12
- ```
13
-
14
- Then please answers the questions, marvel at the extensive console output 😊 and enjoy using `wdi5` for your UI5 testing plaisir.
15
-
16
- ## How to run wdi5 tests
17
-
18
- 1. start the ui5 app via `npm run start`
19
- 1. run `wdi5` via `npm run wdi5`
20
- this will start Chrome,
21
- call the ui5 app at `http://localhost:8080`
22
- and validate that the `sap.m.App` control is visible
23
-
24
- Additional options can be triggered via `env` variables `HEADLESS` and `DEBUG`:
25
-
26
- ```bash
27
- # starts Chrome in headles mode (think: ci/cd)
28
- HEADLESS=true npm run wdi5
29
- ```
30
-
31
- ```bash
32
- # increases timeouts and
33
- # per default opens up the dev tools when Chrome is launched
34
- DEBUG=true npm run wdi5
35
- ```
36
-
37
- ## Credits
38
-
39
- This project has been generated with 💙 and [easy-ui5](https://github.com/SAP/generator-easy-ui5)
@@ -1,17 +0,0 @@
1
- // more on wdi5, syntax, and optional page object patterns at
2
- // https://github.com/js-soft/wdi5
3
- // https://blogs.sap.com/2020/11/19/state-of-testing-in-ui5-opa5-uiveri5-and-wdi5/
4
-
5
- describe("basic wdi5 tests", () => {
6
- it("should validate the running app", () => {
7
- const _selector = {
8
- // forceSelect: true, // only use if reselect is necessary after re-rendering of UI
9
- selector: {
10
- viewName: "<%= projectname ? namespace + '.' + projectname : namespace %>.<%= viewname ? 'view.' + viewname : 'view.MainView.xml' %>",
11
- id: "idAppControl"
12
- }
13
- };
14
- const App = browser.asControl(_selector);
15
- expect(App.getVisible() /* UI5 Control API */).toBeTruthy();
16
- });
17
- });
@@ -1,282 +0,0 @@
1
- exports.config = {
2
- //
3
- // ====================
4
- // Runner Configuration
5
- // ====================
6
- //
7
- // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
8
- // on a remote machine).
9
- runner: "local",
10
- //
11
- // ==================
12
- // Specify Test Files
13
- // ==================
14
- // Define which test specs should run. The pattern is relative to the directory
15
- // from which `wdio` was called. Notice that, if you are calling `wdio` from an
16
- // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
17
- // directory is where your package.json resides, so `wdio` will be called from there.
18
- //
19
- specs: ["<%= wdi5TestDirName %>/**/*.test.js"],
20
- // Patterns to exclude.
21
- exclude: [
22
- // 'path/to/excluded/files'
23
- ],
24
- //
25
- // ============
26
- // Capabilities
27
- // ============
28
- // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
29
- // time. Depending on the number of capabilities, WebdriverIO launches several test
30
- // sessions. Within your capabilities you can overwrite the spec and exclude options in
31
- // order to group specific specs to a specific capability.
32
- //
33
- // First, you can define how many instances should be started at the same time. Let's
34
- // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
35
- // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
36
- // files and you set maxInstances to 10, all spec files will get tested at the same time
37
- // and 30 processes will get spawned. The property handles how many capabilities
38
- // from the same test should run tests.
39
- //
40
- maxInstances: 10,
41
- //
42
- // If you have trouble getting all important capabilities together, check out the
43
- // Sauce Labs platform configurator - a great tool to configure your capabilities:
44
- // https://docs.saucelabs.com/reference/platforms-configurator
45
- //
46
- capabilities: [
47
- {
48
- // maxInstances can get overwritten per capability. So if you have an in-house Selenium
49
- // grid with only 5 firefox instances available you can make sure that not more than
50
- // 5 instances get started at a time.
51
- maxInstances: 5,
52
- //
53
- browserName: "chrome",
54
- "goog:chromeOptions": {
55
- w3c: false,
56
- args: process.env.HEADLESS ? ["--headless"] : process.env.DEBUG ? ["window-size=1440,800", "--auto-open-devtools-for-tabs"] : ["window-size=1440,800"],
57
- },
58
- acceptInsecureCerts: true,
59
- // If outputDir is provided WebdriverIO can capture driver session logs
60
- // it is possible to configure which logTypes to include/exclude.
61
- // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
62
- // excludeDriverLogs: ['bugreport', 'server'],
63
- },
64
- ],
65
- //
66
- // ===================
67
- // Test Configurations
68
- // ===================
69
- // Define all options that are relevant for the WebdriverIO instance here
70
- //
71
- // Level of logging verbosity: trace | debug | info | warn | error | silent
72
- logLevel: process.env.HEADLESS ? "silent" : "info",
73
- //
74
- // Set specific log levels per logger
75
- // loggers:
76
- // - webdriver, webdriverio
77
- // - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service
78
- // - @wdio/mocha-framework, @wdio/jasmine-framework
79
- // - @wdio/local-runner
80
- // - @wdio/sumologic-reporter
81
- // - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils
82
- // Level of logging verbosity: trace | debug | info | warn | error | silent
83
- // logLevels: {
84
- // webdriver: 'info',
85
- // '@wdio/applitools-service': 'info'
86
- // },
87
- //
88
- // If you only want to run your tests until a specific amount of tests have failed use
89
- // bail (default is 0 - don't bail, run all tests).
90
- bail: 0,
91
- //
92
- // Set a base URL in order to shorten url command calls. If your `url` parameter starts
93
- // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
94
- // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
95
- // gets prepended directly.
96
- baseUrl: "<%= baseUrl %>",
97
- //
98
- // Default timeout for all waitFor* commands.
99
- waitforTimeout: 10000,
100
- //
101
- // Default timeout in milliseconds for request
102
- // if browser driver or grid doesn't send response
103
- connectionRetryTimeout: 120000,
104
- //
105
- // Default request retries count
106
- connectionRetryCount: 3,
107
- //
108
- // Test runner services
109
- // Services take over a specific job you don't want to take care of. They enhance
110
- // your test setup with almost no effort. Unlike plugins, they don't add new
111
- // commands. Instead, they hook themselves up into the test process.
112
- services: [
113
- "chromedriver", // Webdriver.IO standard
114
- "ui5" // this is all that's required to hook up UI5 with Webdriver.IO via wdi5 :)
115
- ],
116
-
117
- // Framework you want to run your specs with.
118
- // The following are supported: Mocha, Jasmine, and Cucumber
119
- // see also: https://webdriver.io/docs/frameworks.html
120
- //
121
- // Make sure you have the wdio adapter package for the specific framework installed
122
- // before running any tests.
123
- framework: "mocha",
124
- //
125
- // The number of times to retry the entire specfile when it fails as a whole
126
- // specFileRetries: 1,
127
- //
128
- // Delay in seconds between the spec file retry attempts
129
- // specFileRetriesDelay: 0,
130
- //
131
- // Whether or not retried specfiles should be retried immediately or deferred to the end of the queue
132
- // specFileRetriesDeferred: false,
133
- //
134
- // Test reporter for stdout.
135
- // The only one supported by default is 'dot'
136
- // see also: https://webdriver.io/docs/dot-reporter.html
137
- reporters: ["spec"],
138
-
139
- //
140
- // Options to be passed to Mocha.
141
- // See the full list at http://mochajs.org/
142
- mochaOpts: {
143
- ui: "bdd",
144
- timeout: process.env.DEBUG ? (24 * 60 * 60 * 1000) : 60000,
145
- },
146
-
147
- wdi5: {
148
- screenshotPath: require("path").join("test", "e2e-wdi5", "report", "screenshots"),
149
- logLevel: process.env.HEADLESS ? "silent" : "error", // error | verbose | silent
150
- platform: "browser", // browser | (android | ios | electron -> only via wdi5, not wdio-ui5-service)
151
- url: "<%= indexFile %>", // path to your bootstrap html file
152
- deviceType: "web", // web | (native -> only via wdi5, not wdio-ui5-service)
153
- },
154
- //
155
- // =====
156
- // Hooks
157
- // =====
158
- // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
159
- // it and to build services around it. You can either apply a single function or an array of
160
- // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
161
- // resolved to continue.
162
- /**
163
- * Gets executed once before all workers get launched.
164
- * @param {Object} config wdio configuration object
165
- * @param {Array.<Object>} capabilities list of capabilities details
166
- */
167
- // onPrepare: function (config, capabilities) {
168
- // },
169
- /**
170
- * Gets executed before a worker process is spawned and can be used to initialise specific service
171
- * for that worker as well as modify runtime environments in an async fashion.
172
- * @param {String} cid capability id (e.g 0-0)
173
- * @param {[type]} caps object containing capabilities for session that will be spawn in the worker
174
- * @param {[type]} specs specs to be run in the worker process
175
- * @param {[type]} args object that will be merged with the main configuration once worker is initialised
176
- * @param {[type]} execArgv list of string arguments passed to the worker process
177
- */
178
- // onWorkerStart: function (cid, caps, specs, args, execArgv) {
179
- // },
180
- /**
181
- * Gets executed just before initialising the webdriver session and test framework. It allows you
182
- * to manipulate configurations depending on the capability or spec.
183
- * @param {Object} config wdio configuration object
184
- * @param {Array.<Object>} capabilities list of capabilities details
185
- * @param {Array.<String>} specs List of spec file paths that are to be run
186
- */
187
- // beforeSession: function (config, capabilities, specs) {
188
- // },
189
- /**
190
- * Gets executed before test execution begins. At this point you can access to all global
191
- * variables like `browser`. It is the perfect place to define custom commands.
192
- * @param {Array.<Object>} capabilities list of capabilities details
193
- * @param {Array.<String>} specs List of spec file paths that are to be run
194
- */
195
- // before: function (capabilities, specs) {
196
- // },
197
- /**
198
- * Runs before a WebdriverIO command gets executed.
199
- * @param {String} commandName hook command name
200
- * @param {Array} args arguments that command would receive
201
- */
202
- // beforeCommand: function (commandName, args) {
203
- // },
204
- /**
205
- * Hook that gets executed before the suite starts
206
- * @param {Object} suite suite details
207
- */
208
- // beforeSuite: function (suite) {
209
- // },
210
- /**
211
- * Function to be executed before a test (in Mocha/Jasmine) starts.
212
- */
213
- // beforeTest: function (test, context) {
214
- // },
215
- /**
216
- * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
217
- * beforeEach in Mocha)
218
- */
219
- // beforeHook: function (test, context) {
220
- // },
221
- /**
222
- * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
223
- * afterEach in Mocha)
224
- */
225
- // afterHook: function (test, context, { error, result, duration, passed, retries }) {
226
- // },
227
- /**
228
- * Function to be executed after a test (in Mocha/Jasmine).
229
- */
230
- // afterTest: function(test, context, { error, result, duration, passed, retries }) {
231
- // },
232
-
233
- /**
234
- * Hook that gets executed after the suite has ended
235
- * @param {Object} suite suite details
236
- */
237
- // afterSuite: function (suite) {
238
- // },
239
- /**
240
- * Runs after a WebdriverIO command gets executed
241
- * @param {String} commandName hook command name
242
- * @param {Array} args arguments that command would receive
243
- * @param {Number} result 0 - command success, 1 - command error
244
- * @param {Object} error error object if any
245
- */
246
- // afterCommand: function (commandName, args, result, error) {
247
- // },
248
- /**
249
- * Gets executed after all tests are done. You still have access to all global variables from
250
- * the test.
251
- * @param {Number} result 0 - test pass, 1 - test fail
252
- * @param {Array.<Object>} capabilities list of capabilities details
253
- * @param {Array.<String>} specs List of spec file paths that ran
254
- */
255
- // after: function (result, capabilities, specs) {
256
- // },
257
- /**
258
- * Gets executed right after terminating the webdriver session.
259
- * @param {Object} config wdio configuration object
260
- * @param {Array.<Object>} capabilities list of capabilities details
261
- * @param {Array.<String>} specs List of spec file paths that ran
262
- */
263
- // afterSession: function (config, capabilities, specs) {
264
- // },
265
- /**
266
- * Gets executed after all workers got shut down and the process is about to exit. An error
267
- * thrown in the onComplete hook will result in the test run failing.
268
- * @param {Object} exitCode 0 - success, 1 - fail
269
- * @param {Object} config wdio configuration object
270
- * @param {Array.<Object>} capabilities list of capabilities details
271
- * @param {<Object>} results object containing test results
272
- */
273
- // onComplete: function(exitCode, config, capabilities, results) {
274
- // },
275
- /**
276
- * Gets executed when a refresh happens.
277
- * @param {String} oldSessionId session ID of the old session
278
- * @param {String} newSessionId session ID of the new session
279
- */
280
- //onReload: function(oldSessionId, newSessionId) {
281
- //}
282
- };
@@ -1,90 +0,0 @@
1
- const objectAssignDeep = require("object-assign-deep"),
2
- yaml = require("yaml");
3
-
4
-
5
- // overide can be an object or a function that receives the current object
6
- exports.writeJSON = async function (filePath, override) {
7
- try {
8
- const fullFilePath = process.cwd() + filePath;
9
- let oldContent = {};
10
- if (this.fs.exists(fullFilePath)) {
11
- oldContent = this.fs.readJSON(fullFilePath);
12
- }
13
-
14
- const newContent = typeof override === "function" ?
15
- override(oldContent) :
16
- objectAssignDeep.withOptions(oldContent, [override], { arrayBehaviour: "merge" });
17
-
18
- this.fs.writeJSON(fullFilePath, newContent);
19
- if (!this.options.isSubgeneratorCall && this.config.get("setupCompleted")) {
20
- this.log(`Updated file: ${filePath}`);
21
- }
22
- } catch (e) {
23
- this.log(`Error during the manipulation of the ${filePath} file: ${e}`);
24
- throw e;
25
- }
26
- };
27
-
28
-
29
- // overide can be an object or a function that receives the current object
30
- exports.writeYAML = async function (filePath, override) {
31
- try {
32
- const fullFilePath = process.cwd() + filePath;
33
- let oldContent = {};
34
- if (this.fs.exists(fullFilePath)) {
35
- oldContent = yaml.parse(this.fs.read(fullFilePath));
36
- }
37
-
38
- const newContent = typeof override === "function" ?
39
- override(oldContent) :
40
- objectAssignDeep.withOptions(oldContent, [override], { arrayBehaviour: "merge" });
41
-
42
- this.fs.write(fullFilePath, yaml.stringify(newContent));
43
-
44
- if (!this.options.isSubgeneratorCall && this.config.get("setupCompleted")) {
45
- this.log(`Updated file: ${filePath}`);
46
- }
47
- } catch (e) {
48
- this.log(`Error during the manipulation of the ${filePath} file: ${e}`);
49
- throw e;
50
- }
51
- };
52
-
53
- // overide can be an object or a function that receives the current object
54
- exports.manipulateJSON = async function (filePath, override) {
55
- try {
56
- const fullFilePath = process.cwd() + filePath;
57
- const oldContent = this.fs.readJSON(fullFilePath);
58
-
59
- const newContent = typeof override === "function" ?
60
- override(oldContent) :
61
- objectAssignDeep.withOptions(oldContent, [override], { arrayBehaviour: "merge" });
62
-
63
- this.fs.writeJSON(fullFilePath, newContent);
64
- if (!this.options.isSubgeneratorCall && this.config.get("setupCompleted")) {
65
- this.log(`Updated file: ${filePath}`);
66
- }
67
- } catch (e) {
68
- this.log(`Error during the manipulation of the ${filePath} file: ${e}`);
69
- throw e;
70
- }
71
- };
72
-
73
- // overide can be an object or a function that receives the current object
74
- exports.manipulateYAML = async function (filePath, override) {
75
- try {
76
- const fullFilePath = process.cwd() + filePath;
77
- const oldContent = yaml.parse(this.fs.read(fullFilePath));
78
-
79
- const newContent = typeof override === "function" ?
80
- override(oldContent) :
81
- objectAssignDeep.withOptions(oldContent, [override], { arrayBehaviour: "merge" });
82
-
83
- this.fs.write(fullFilePath, yaml.stringify(newContent));
84
-
85
- !this.options.isSubgeneratorCall && this.log(`Updated file: ${filePath}`);
86
- } catch (e) {
87
- this.log(`Error during the manipulation of the ${filePath} file: ${e}`);
88
- throw e;
89
- }
90
- };