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
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ const spawn = require("cross-spawn");
3
+ const fs = require("fs");
4
+ const { rmdir } = require("fs").promises;
5
+ const path = require("path");
6
+ const { hasYarn } = require("yarn-or-npm");
7
+ const { Octokit } = require("@octokit/rest");
8
+ const AdmZip = require("adm-zip");
9
+
10
+ const ghOrg = "ui5-community",
11
+ repoName = "generator-ui5-project",
12
+ branch = "main";
13
+
14
+ (async () => {
15
+
16
+ let _busy;
17
+
18
+ function showBusy(statusText) {
19
+ clearBusy();
20
+ const progressChars = ['\\', '|', '/', '-'];
21
+ let i = 0;
22
+ process.stdout.write(`\r${statusText} `);
23
+ _busy = {
24
+ text: statusText,
25
+ timer: setInterval(() => {
26
+ process.stdout.write(`\r${statusText} ${progressChars[i++]}`);
27
+ i %= progressChars.length;
28
+ }, 250),
29
+ };
30
+ }
31
+
32
+ function clearBusy(newLine) {
33
+ if (_busy) {
34
+ clearInterval(_busy.timer);
35
+ process.stdout.write(`\r`.padEnd(_busy.text.length + 3) + (newLine ? "\n" : ""));
36
+ _busy = null;
37
+ }
38
+ }
39
+
40
+ const octokit = new Octokit({
41
+ userAgent: "generator-easy-ui5",
42
+ });
43
+
44
+ const reqBranch = await octokit.repos.getBranch({
45
+ owner: ghOrg,
46
+ repo: repoName,
47
+ branch,
48
+ });
49
+
50
+ const commitSHA = reqBranch.data.commit.sha;
51
+
52
+ // eslint-disable-next-line
53
+ console.log(
54
+ `Fetching ZIP for commit ${commitSHA} from @${ghOrg}/${repoName}#${branch}...`
55
+ );
56
+ const generatorPath = path.join(
57
+ __dirname,
58
+ "../../plugin-generators",
59
+ repoName
60
+ );
61
+ const shaMarker = path.join(generatorPath, `.${commitSHA}`);
62
+
63
+ if (fs.existsSync(generatorPath)) {
64
+ // check if the SHA marker exists to know whether the generator is up-to-date or not
65
+ if (!fs.existsSync(shaMarker)) {
66
+ console.log(`The default generator is outdated...`);
67
+ // remove if the SHA marker doesn't exist => outdated!
68
+ showBusy(` Removing old default templates`);
69
+ await rmdir(generatorPath, { recursive: true });
70
+ }
71
+ }
72
+
73
+
74
+ // re-fetch the generator and extract into local plugin folder
75
+ if (!fs.existsSync(generatorPath)) {
76
+ console.log(`Extracting default templates...`);
77
+ showBusy(` Downloading and extracting default templates`);
78
+ const reqZIPArchive = await octokit.repos.downloadZipballArchive({
79
+ owner: ghOrg,
80
+ repo: repoName,
81
+ ref: commitSHA,
82
+ });
83
+ const buffer = Buffer.from(new Uint8Array(reqZIPArchive.data));
84
+ const zip = new AdmZip(buffer);
85
+ const zipEntries = zip.getEntries();
86
+ zipEntries.forEach((entry) => {
87
+ const match =
88
+ !entry.isDirectory && entry.entryName.match(/[^\/]+\/(.+)/);
89
+ if (match) {
90
+ const entryPath = match[1].slice(0, entry.name.length * -1);
91
+ zip.extractEntryTo(
92
+ entry,
93
+ path.join(generatorPath, entryPath),
94
+ false,
95
+ true
96
+ );
97
+ }
98
+ });
99
+ fs.writeFileSync(shaMarker, commitSHA);
100
+
101
+ // run yarn/npm install
102
+ console.log("Installing the plugin dependencies...");
103
+ showBusy(` Preparing the default templates`);
104
+ await new Promise(function (resolve, reject) {
105
+ spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
106
+ stdio: "inherit",
107
+ cwd: generatorPath,
108
+ env: {
109
+ ...process.env,
110
+ "NO_UPDATE_NOTIFIER": true
111
+ }
112
+ }).on('exit', function (code) {
113
+ resolve(code);
114
+ }).on('error', function (err) {
115
+ reject(err);
116
+ });
117
+ }.bind(this));
118
+ }
119
+
120
+ clearBusy(true);
121
+ })();
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "generator-easy-ui5",
3
- "version": "2.4.6",
4
- "description": "Generator for OpenUI5-based web-apps which use the official UI5 tooling and support deployment targets such as SAP BTP",
3
+ "version": "3.1.0",
4
+ "description": "Generator for UI5-based project",
5
5
  "main": "generators/app/index.js",
6
6
  "files": [
7
- "generators",
8
- "helpers"
7
+ "generators"
9
8
  ],
10
9
  "scripts": {
11
10
  "test": "mocha",
11
+ "postinstall": "node generators/app/postinstall",
12
12
  "lint": "eslint .",
13
- "circleci": "circleci local execute",
13
+ "prettier": "prettier --write .",
14
+ "start": "yo easy-ui5 project",
15
+ "listSubGen": "yo easy-ui5 project --list",
16
+ "startSubGen": "yo easy-ui5 project app",
14
17
  "workaround": "find . -name '.DS_Store' -delete"
15
18
  },
16
19
  "repository": {
@@ -22,8 +25,7 @@
22
25
  "sap",
23
26
  "sapui5",
24
27
  "openui5",
25
- "sapcloudplatform",
26
- "cloudplatform",
28
+ "sapbtp",
27
29
  "generator",
28
30
  "scaffold"
29
31
  ],
@@ -34,18 +36,21 @@
34
36
  },
35
37
  "homepage": "https://github.com/SAP/generator-easy-ui5#readme",
36
38
  "dependencies": {
37
- "glob": "^7.1.6",
38
- "object-assign-deep": "^0.4.0",
39
- "valid-filename": "^3.1.0",
40
- "valid-url": "^1.0.9",
41
- "yaml": "^1.10.0",
42
- "yeoman-generator": "^4.12.0"
39
+ "@octokit/rest": "^18.12.0",
40
+ "adm-zip": "^0.5.9",
41
+ "chalk": "^4.1.2",
42
+ "colors": "^1.4.0",
43
+ "glob": "^7.2.0",
44
+ "mocha": "^9.1.3",
45
+ "rimraf": "^3.0.2",
46
+ "yarn-or-npm": "^3.0.1",
47
+ "yeoman-assert": "^3.1.1",
48
+ "yeoman-environment": "^3.8.0",
49
+ "yeoman-generator": "^5.4.2",
50
+ "yeoman-test": "^6.2.0",
51
+ "yosay": "^2.0.2"
43
52
  },
44
53
  "devDependencies": {
45
- "eslint": "^7.15.0",
46
- "execa": "^5.0.0",
47
- "mocha": "^8.2.1",
48
- "yeoman-assert": "^3.1.1",
49
- "yeoman-test": "^3.0.0"
54
+ "prettier": "2.4.1"
50
55
  }
51
56
  }
@@ -1,222 +0,0 @@
1
- const Generator = require("yeoman-generator"),
2
- fileaccess = require("../../helpers/fileaccess"),
3
- path = require("path"),
4
- glob = require("glob");
5
-
6
- module.exports = class extends Generator {
7
-
8
- prompting() {
9
- if (this.options.isSubgeneratorCall) {
10
- this.destinationRoot(this.options.cwd);
11
- this.options.oneTimeConfig = this.config.getAll();
12
- this.options.oneTimeConfig.modulename = this.options.modulename;
13
- return;
14
- }
15
- throw ("This subgenerator is only intended for internal use. Please don\"t call it directly.");
16
- }
17
-
18
- async writing() {
19
- this.sourceRoot(path.join(__dirname, "templates"));
20
-
21
- const oConfig = this.options.oneTimeConfig;
22
- const platformIsAppRouter = this.options.oneTimeConfig.platform.includes("Application Router"); // aka no destination service etc needed
23
-
24
- // Copy approuter module
25
- if (oConfig.platform !== "SAP Launchpad service") {
26
- glob.sync("**", {
27
- cwd: this.sourceRoot() + "/approuter",
28
- nodir: true
29
- }).forEach(file => {
30
- this.fs.copyTpl(this.templatePath("approuter/" + file), this.destinationPath("approuter/" + file.replace(/^_/, "").replace(/\/_/, "/")), oConfig);
31
- });
32
-
33
- const welcomeRoute = platformIsAppRouter ? "uimodule/index.html" : (oConfig.namespace + oConfig.projectname + "/").replace(/\./g, "");
34
-
35
- await fileaccess.manipulateJSON.call(this, "/approuter/xs-app.json", {
36
- "welcomeFile": welcomeRoute,
37
- "authenticationMethod": "none",
38
- "logout": {
39
- "logoutEndpoint": "/do/logout"
40
- },
41
- "routes": []
42
- });
43
- }
44
-
45
- if (oConfig.platform !== "Application Router @ SAP HANA XS Advanced") {
46
- // Copy deployer module
47
- glob.sync("**", {
48
- cwd: this.sourceRoot() + "/deployer",
49
- nodir: true
50
- }).forEach(file => {
51
- this.fs.copyTpl(this.templatePath("deployer/" + file), this.destinationPath("deployer/" + file.replace(/^_/, "").replace(/\/_/, "/")), oConfig);
52
- });
53
- }
54
- }
55
-
56
- async addMTA() {
57
- const oConfig = this.config.getAll();
58
-
59
- let mta = {
60
- "ID": oConfig.projectname,
61
- "_schema-version": "3.2.0",
62
- "version": "0.0.1",
63
- "parameters": {
64
- "enable-parallel-deployments": true
65
- },
66
- "modules": [],
67
- "resources": []
68
- };
69
-
70
- let approuter;
71
- if (oConfig.platform !== "SAP Launchpad service") {
72
- approuter = {
73
- "name": oConfig.projectname,
74
- "type": "nodejs",
75
- "path": "approuter",
76
- "parameters": {
77
- "disk-quota": "512M",
78
- "memory": "512M"
79
- },
80
- "requires": []
81
- };
82
- mta.modules.push(approuter);
83
-
84
- if (oConfig.platform.includes("Application Router")) {
85
- approuter["build-parameters"] = {
86
- builder: "custom",
87
- commands: ["npm install", "npm run build:ui --prefix .."]
88
- };
89
- }
90
- }
91
-
92
- if (oConfig.platform !== "Application Router @ SAP HANA XS Advanced") {
93
- mta.resources.push({
94
- "name": oConfig.projectname + "_destination",
95
- "type": "org.cloudfoundry.managed-service",
96
- "parameters": {
97
- "service-plan": "lite",
98
- "service": "destination"
99
- }
100
- });
101
- if (approuter) {
102
- approuter.requires.push({ name: oConfig.projectname + "_destination" });
103
- }
104
-
105
- if (oConfig.platform === "SAP HTML5 Application Repository service for SAP BTP" || oConfig.platform === "SAP Launchpad service") {
106
-
107
-
108
- mta.modules.push({
109
- "name": "webapp_deployer",
110
- "type": "com.sap.application.content",
111
- "path": "deployer",
112
- "requires": [{
113
- "name": oConfig.projectname + "_html5_repo_host",
114
- "parameters": {
115
- "content-target": true
116
- }
117
- }],
118
- "build-parameters": {
119
- ["build-result"]: "resources",
120
- ["requires"]: []
121
- }
122
- });
123
-
124
- mta.resources.push({
125
- "name": oConfig.projectname + "_html5_repo_host",
126
- "type": "org.cloudfoundry.managed-service",
127
- "parameters": {
128
- "service-plan": "app-host",
129
- "service": "html5-apps-repo",
130
- "config": {
131
- "sizeLimit": oConfig.ui5libs.indexOf("Local resources") >= 0 ? 100 : 2
132
- }
133
- }
134
- });
135
-
136
- if (approuter) {
137
- mta.resources.push({
138
- "name": oConfig.projectname + "_html5_repo_runtime",
139
- "type": "org.cloudfoundry.managed-service",
140
- "parameters": {
141
- "service-plan": "app-runtime",
142
- "service": "html5-apps-repo"
143
- }
144
- });
145
- approuter.requires.push({ name: oConfig.projectname + "_html5_repo_runtime" });
146
- }
147
-
148
- mta.resources.push({
149
- "name": oConfig.projectname + "_uaa",
150
- "type": "org.cloudfoundry.managed-service",
151
- "parameters": {
152
- "path": "./xs-security.json",
153
- "service-plan": "application",
154
- "service": "xsuaa"
155
- }
156
- });
157
- this.fs.copyTpl(this.templatePath("xs-security.json"), this.destinationPath("xs-security.json"), oConfig);
158
- if (approuter) {
159
- approuter.requires.push({ name: oConfig.projectname + "_uaa" });
160
- }
161
-
162
- if (oConfig.platform === "SAP Launchpad service") {
163
- mta.modules.push({
164
- "name": oConfig.projectname + "destination-content",
165
- "type": "com.sap.application.content",
166
- "build-parameters": {
167
- "no-source": true
168
- },
169
- "requires": [
170
- {
171
- "name": oConfig.projectname + "_uaa",
172
- "parameters": {
173
- "service-key": {
174
- "name": oConfig.projectname + "_uaa-key"
175
- }
176
- }
177
- },
178
- {
179
- "name": oConfig.projectname + "_html5_repo_host",
180
- "parameters": {
181
- "service-key": {
182
- "name": oConfig.projectname + "_html5_repo_host-key"
183
- }
184
- }
185
- },
186
- {
187
- "name": oConfig.projectname + "_destination",
188
- "parameters": {
189
- "content-target": true
190
- }
191
- }
192
- ],
193
- "parameters": {
194
- "content": {
195
- "subaccount": {
196
- "existing_destinations_policy": "update",
197
- "destinations": [
198
- {
199
- "Name": oConfig.projectname + "_html5_repo_host",
200
- "ServiceInstanceName": oConfig.projectname + "_html5_repo_host",
201
- "ServiceKeyName": oConfig.projectname + "_html5_repo_host-key",
202
- "sap.cloud.service": oConfig.projectname + ".service"
203
- },
204
- {
205
- "Name": oConfig.projectname + "_uaa",
206
- "Authentication": "OAuth2UserTokenExchange",
207
- "ServiceInstanceName": oConfig.projectname + "_uaa",
208
- "ServiceKeyName": oConfig.projectname + "_uaa-key",
209
- "sap.cloud.service": oConfig.projectname + ".service"
210
- }
211
- ]
212
- }
213
- }
214
- }
215
- });
216
- }
217
- }
218
- }
219
-
220
- await fileaccess.writeYAML.call(this, "/mta.yaml", mta);
221
- }
222
- };
@@ -1,13 +0,0 @@
1
- {
2
- "name": "<%= projectname %>",
3
- "version": "0.0.1",
4
- "engines": {
5
- "node": "12.X"
6
- },
7
- "scripts": {
8
- "start": "node node_modules/@sap/approuter/approuter.js"
9
- },
10
- "dependencies": {
11
- "@sap/approuter": "^9.0.0"
12
- }
13
- }
@@ -1,3 +0,0 @@
1
- # Deployer module
2
-
3
- The build process will move the zipped web apps in here.
@@ -1,20 +0,0 @@
1
- {
2
- "xsappname": "<%= projectname %>",
3
- "tenant-mode": "dedicated",
4
- "description": "Security profile of called application",
5
- "scopes": [
6
- {
7
- "name": "uaa.user",
8
- "description": "UAA"
9
- }
10
- ],
11
- "role-templates": [
12
- {
13
- "name": "Token_Exchange",
14
- "description": "UAA",
15
- "scope-references": [
16
- "uaa.user"
17
- ]
18
- }
19
- ]
20
- }
@@ -1,8 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = space
5
- indent_size = 2
6
- charset = utf-8
7
- # editorconfig-tools is unable to ignore longs strings or urls
8
- max_line_length = off
@@ -1,4 +0,0 @@
1
- templates/
2
- deployer/resources/
3
- node_modules/
4
- approuter/webapp/
@@ -1,48 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true
4
- },
5
- "parserOptions": {
6
- "ecmaVersion": 2019
7
- },
8
- "globals": {
9
- "sap": true,
10
- "jQuery": true
11
- },
12
- "rules": {
13
- "block-scoped-var": 1,
14
- "keyword-spacing": 2,
15
- "space-unary-ops": 2,
16
- "camelcase": 1,
17
- "consistent-return": 1,
18
- "no-warning-comments": 1,
19
- "default-case": 1,
20
- "no-console": 2,
21
- "no-unused-vars": 2,
22
- "no-trailing-spaces": 2,
23
- "no-debugger": 2,
24
- "semi": [
25
- 1,
26
- "always"
27
- ],
28
- "quotes": [
29
- 1,
30
- "double"
31
- ],
32
- "key-spacing": [
33
- 1,
34
- {
35
- "beforeColon": false
36
- }
37
- ],
38
- "comma-spacing": [
39
- 1,
40
- {
41
- "before": false,
42
- "after": true
43
- }
44
- ],
45
- "no-shadow": 2,
46
- "no-irregular-whitespace": 2
47
- }
48
- }
@@ -1,11 +0,0 @@
1
- node_modules/
2
- .idea/
3
- .mta/
4
- *.mtar
5
- dist/
6
- package-lock.json
7
- mta_archives/
8
- deployer/resources/
9
- Makefile*
10
- mta-*
11
- approuter/*/webapp/
@@ -1,21 +0,0 @@
1
- module.exports = function (config) {
2
- "use strict";
3
-
4
- require("./karma.conf")(config);
5
- config.set({
6
-
7
- // test results reporter to use
8
- // possible values: "dots", "progress", "coverage"
9
- // available reporters: https://npmjs.org/browse/keyword/karma-reporter
10
- reporters: ["progress"],
11
-
12
- // start these browsers
13
- // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
14
- browsers: ["ChromeHeadless"],
15
-
16
- // Continuous Integration mode
17
- // if true, Karma captures browsers, runs the tests and exits
18
- singleRun: true
19
-
20
- });
21
- };
@@ -1,17 +0,0 @@
1
- module.exports = function (config) {
2
- "use strict";
3
-
4
- config.set({
5
- frameworks: ["ui5"], ui5: {
6
- type: "application",
7
- configPath: "uimodule/ui5.yaml",
8
- paths: {
9
- webapp: "uimodule/webapp"
10
- }
11
- },
12
- browsers: ["Chrome"],
13
- browserConsoleLogOptions: {
14
- level: "error"
15
- }
16
- });
17
- };
@@ -1,6 +0,0 @@
1
- # <%= projectname %>
2
- Insert the purpose of this project and some interesting infos here
3
-
4
-
5
- ## Credits
6
- This project has been generated with 💙 and [easy-ui5](https://github.com/SAP)
@@ -1,82 +0,0 @@
1
- const Generator = require("yeoman-generator"),
2
- fileaccess = require("../../helpers/fileaccess");
3
-
4
- module.exports = class extends Generator {
5
-
6
- prompting() {
7
- const modules = this.config.get("uimodules");
8
- var aPrompt = [{
9
- type: "list",
10
- name: "modulename",
11
- message: "To which module do you want to add a component?",
12
- choices: modules || [],
13
- when: modules && modules.length > 1
14
- }, {
15
- type: "input",
16
- name: "usagesName",
17
- message: "What is the name of your usage?",
18
- validate: (s) => {
19
- if (/^\d*[a-zA-Z][a-zA-Z0-9]*$/g.test(s)) {
20
- return true;
21
- }
22
- return "Please use alpha numeric characters only for the view name.";
23
- }
24
- },
25
- {
26
- type: "input",
27
- name: "componentName",
28
- message: "What is the name of the component you want to reference?",
29
- validate: (s) => {
30
- if (/^\d*[a-zA-Z][a-zA-Z0-9]*$/g.test(s)) {
31
- return true;
32
- }
33
- return "Please use alpha numeric characters only for the view name.";
34
- }
35
- },
36
- {
37
- type: "input",
38
- name: "componentData",
39
- message: "Write your component data as a json object"
40
-
41
- }, {
42
- type: "confirm",
43
- name: "lazy",
44
- message: "Should the component be lazy loaded?"
45
- }];
46
-
47
- return this.prompt(aPrompt).then((answers) => {
48
- this.options.oneTimeConfig = this.config.getAll();
49
- this.options.oneTimeConfig.usagesName = answers.usagesName;
50
- this.options.oneTimeConfig.componentName = answers.componentName;
51
- this.options.oneTimeConfig.componentData = answers.componentData;
52
- this.options.oneTimeConfig.lazy = answers.lazy;
53
- this.options.oneTimeConfig.modulename = answers.modulename || modules[0];
54
-
55
- });
56
- }
57
-
58
- async writing() {
59
- const sUsageName = this.options.oneTimeConfig.usagesName;
60
- const sComponentName = this.options.oneTimeConfig.componentName;
61
- const sComponentData = this.options.oneTimeConfig.componentData || {};
62
- const sLazy = this.options.oneTimeConfig.lazy;
63
- const sModuleName = this.options.oneTimeConfig.modulename;
64
-
65
- await fileaccess.manipulateJSON.call(this, "/" + sModuleName + "/webapp/manifest.json", {
66
- sap: {
67
- ui5: {
68
- componentUsages: {
69
- [sUsageName]: {
70
- name: sComponentName,
71
- settings: {},
72
- componentData: (sComponentData.length > 0) ? JSON.parse(sComponentData) : {},
73
- lazy: sLazy
74
- }
75
- }
76
- }
77
- }
78
- });
79
-
80
- this.log("Add the new usage in your view with the following code: \n '<core:ComponentContainer width='100%' usage='" + sUsageName + "' propagateModel='true' lifecycle='Container'></core:ComponentContainer>'");
81
- }
82
- };