generator-easy-ui5 3.1.5 → 3.3.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.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,263 @@
1
- ## 3.0.0 (2021-04-08)
1
+ ## [3.2.2](https://github.com/SAP/generator-easy-ui5/compare/v3.2.0...v3.2.2) (2022-02-08)
2
2
 
3
- ### New Features
4
3
 
5
- Starting with easy-ui5 v3, all templates will be outsource to repositories in the [UI5 Community](https://github.com/ui5-community/). This project is from now on a shell that will offer all generators hosted on that GitHub org. Easy-ui5 will download and install these repositories when needed.
4
+ ### Bug Fixes
5
+
6
+ * usage of proper gh org for logging and download ([#94](https://github.com/SAP/generator-easy-ui5/issues/94)) ([a88d4db](https://github.com/SAP/generator-easy-ui5/commit/a88d4dbb0a1f5ed3cf60f7ed0297c651222a83fb))
7
+ * use the org name of the selected generator for downloading the corresponding repo ([d9ca4dc](https://github.com/SAP/generator-easy-ui5/commit/d9ca4dc3170e0507199799d2e14db327cba4d871))
8
+
9
+
10
+
11
+ # [3.2.0](https://github.com/SAP/generator-easy-ui5/compare/v3.1.5...v3.2.0) (2022-02-03)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * freeze version of colors.js in package.json ([#85](https://github.com/SAP/generator-easy-ui5/issues/85)) ([6b497b6](https://github.com/SAP/generator-easy-ui5/commit/6b497b6c05748b8f67617c6399a11f8e8d850d48))
17
+ * use homedir for plugin-generators avoid EACCESS ([e326676](https://github.com/SAP/generator-easy-ui5/commit/e326676458f439f9ac01498381059229a897fa61)), closes [#84](https://github.com/SAP/generator-easy-ui5/issues/84)
18
+
19
+
20
+ ### Features
21
+
22
+ * Add support for user repositories ([6b7efa6](https://github.com/SAP/generator-easy-ui5/commit/6b7efa63414c31d76a53ee1b069557c527077f39))
23
+ * support additional GH org via NPM config ([0d33197](https://github.com/SAP/generator-easy-ui5/commit/0d33197098e010858d1ea7a0e4b172d5d6a5aa22))
6
24
 
7
- By default, it will download the repository [generator-ui5-project](https://github.com/ui5-community/generator-ui5-project/) which contains the templates that were previously integrated in easy-ui5 < 3.
8
25
 
9
26
 
27
+ ## [3.1.5](https://github.com/SAP/generator-easy-ui5/compare/v3.1.4...v3.1.5) (2022-01-10)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * re-enable sub-generator update check ([c464bd1](https://github.com/SAP/generator-easy-ui5/commit/c464bd11d2cf32006fd7f42ea8f15a736cb10271))
33
+
34
+
35
+
36
+ ## [3.1.4](https://github.com/SAP/generator-easy-ui5/compare/v3.1.3...v3.1.4) (2021-12-07)
37
+
10
38
 
11
39
  ### Bug Fixes
12
40
 
13
- NA
41
+ * disable autoinstall of Yeoman 5.x ([de6fcaf](https://github.com/SAP/generator-easy-ui5/commit/de6fcafd164734a9e3fbbab599b7376a49fffe89))
42
+
43
+
44
+
45
+ ## [3.1.3](https://github.com/SAP/generator-easy-ui5/compare/v3.1.2...v3.1.3) (2021-11-25)
46
+
47
+
48
+
49
+ ## [3.1.2](https://github.com/SAP/generator-easy-ui5/compare/v3.1.1...v3.1.2) (2021-11-23)
50
+
51
+
52
+
53
+ ## [3.1.1](https://github.com/SAP/generator-easy-ui5/compare/v3.1.0...v3.1.1) (2021-11-23)
54
+
55
+
56
+
57
+ # [3.1.0](https://github.com/SAP/generator-easy-ui5/compare/v3.0.3...v3.1.0) (2021-11-23)
58
+
59
+
60
+
61
+ ## [3.0.3](https://github.com/SAP/generator-easy-ui5/compare/v3.0.2...v3.0.3) (2021-11-15)
62
+
63
+
64
+
65
+ ## [3.0.2](https://github.com/SAP/generator-easy-ui5/compare/v3.0.1...v3.0.2) (2021-11-15)
66
+
67
+
68
+
69
+ ## [3.0.1](https://github.com/SAP/generator-easy-ui5/compare/v2.4.6...v3.0.1) (2021-05-10)
70
+
71
+
72
+
73
+ ## [2.4.6](https://github.com/SAP/generator-easy-ui5/compare/2.4.6...v2.4.6) (2021-02-10)
74
+
75
+
76
+ ### Bug Fixes
77
+
78
+ * uiveri5 reporters ([f2e2d6d](https://github.com/SAP/generator-easy-ui5/commit/f2e2d6dae71dc580ee0d15c42baafe06ae983d4e))
79
+
80
+
81
+
82
+ ## [2.4.5](https://github.com/SAP/generator-easy-ui5/compare/2.4.5...v2.4.5) (2021-01-29)
83
+
84
+
85
+ ### Bug Fixes
86
+
87
+ * opa test namespace and folder ([fb166b7](https://github.com/SAP/generator-easy-ui5/commit/fb166b7df06b7cd465366726ed484890ad389d96))
88
+
89
+
90
+
91
+ ## [2.4.4](https://github.com/SAP/generator-easy-ui5/compare/2.4.4...v2.4.4) (2021-01-25)
92
+
93
+
94
+
95
+ ## [2.4.3](https://github.com/SAP/generator-easy-ui5/compare/2.4.3...v2.4.3) (2021-01-08)
96
+
97
+
98
+
99
+ ## [2.4.2](https://github.com/SAP/generator-easy-ui5/compare/2.4.2...v2.4.2) (2020-12-18)
100
+
101
+
102
+
103
+ ## [2.4.1](https://github.com/SAP/generator-easy-ui5/compare/v2.4.0...v2.4.1) (2020-12-18)
104
+
105
+
106
+
107
+ # [2.4.0](https://github.com/SAP/generator-easy-ui5/compare/v2.3.0...v2.4.0) (2020-12-10)
108
+
109
+
110
+ ### Features
111
+
112
+ * add wdi5 as test framework ([e63ce2e](https://github.com/SAP/generator-easy-ui5/commit/e63ce2eb2ed9cc23840cb303d01fc4e7d23f2c11))
113
+
114
+
115
+
116
+ # [2.3.0](https://github.com/SAP/generator-easy-ui5/compare/v2.2.4...v2.3.0) (2020-11-25)
117
+
118
+
119
+
120
+ ## [2.2.4](https://github.com/SAP/generator-easy-ui5/compare/v2.2.3...v2.2.4) (2020-11-10)
121
+
122
+
123
+
124
+ ## [2.2.3](https://github.com/SAP/generator-easy-ui5/compare/v2.2.2...v2.2.3) (2020-11-05)
125
+
126
+
127
+
128
+ ## [2.2.2](https://github.com/SAP/generator-easy-ui5/compare/v2.2.1...v2.2.2) (2020-10-28)
129
+
130
+
131
+
132
+ ## [2.2.1](https://github.com/SAP/generator-easy-ui5/compare/v2.2.0...v2.2.1) (2020-10-23)
133
+
134
+
135
+
136
+ # [2.2.0](https://github.com/SAP/generator-easy-ui5/compare/v2.1.7...v2.2.0) (2020-10-16)
137
+
138
+
139
+
140
+ ## [2.1.7](https://github.com/SAP/generator-easy-ui5/compare/v2.1.6...v2.1.7) (2020-09-10)
141
+
142
+
143
+
144
+ ## [2.1.6](https://github.com/SAP/generator-easy-ui5/compare/v2.1.5...v2.1.6) (2020-08-24)
145
+
146
+
147
+
148
+ ## [2.1.5](https://github.com/SAP/generator-easy-ui5/compare/v2.1.4...v2.1.5) (2020-08-24)
149
+
150
+
151
+
152
+ ## [2.1.4](https://github.com/SAP/generator-easy-ui5/compare/v2.1.3...v2.1.4) (2020-08-06)
153
+
154
+
155
+
156
+ ## [2.1.3](https://github.com/SAP/generator-easy-ui5/compare/v2.1.2...v2.1.3) (2020-08-03)
157
+
158
+
159
+
160
+ ## [2.1.2](https://github.com/SAP/generator-easy-ui5/compare/v2.1.1...v2.1.2) (2020-06-29)
161
+
162
+
163
+
164
+ ## [2.1.1](https://github.com/SAP/generator-easy-ui5/compare/v2.1.0...v2.1.1) (2020-06-18)
165
+
166
+
167
+
168
+ # [2.1.0](https://github.com/SAP/generator-easy-ui5/compare/v2.0.1...v2.1.0) (2020-06-15)
169
+
170
+
171
+
172
+ ## [2.0.1](https://github.com/SAP/generator-easy-ui5/compare/v2.0.0...v2.0.1) (2020-06-09)
173
+
174
+
175
+
176
+ # [2.0.0](https://github.com/SAP/generator-easy-ui5/compare/v1.3.7...v2.0.0) (2020-06-08)
177
+
178
+
179
+
180
+ ## [1.3.7](https://github.com/SAP/generator-easy-ui5/compare/v1.3.6...v1.3.7) (2020-05-06)
181
+
182
+
183
+
184
+ ## [1.3.6](https://github.com/SAP/generator-easy-ui5/compare/v1.3.5...v1.3.6) (2020-05-06)
185
+
186
+
187
+
188
+ ## [1.3.5](https://github.com/SAP/generator-easy-ui5/compare/v1.3.4...v1.3.5) (2020-04-30)
189
+
190
+
191
+
192
+ ## [1.3.4](https://github.com/SAP/generator-easy-ui5/compare/v1.3.3...v1.3.4) (2020-04-29)
193
+
194
+
195
+
196
+ ## [1.3.3](https://github.com/SAP/generator-easy-ui5/compare/v1.3.2...v1.3.3) (2020-04-14)
197
+
198
+
199
+
200
+ ## [1.3.2](https://github.com/SAP/generator-easy-ui5/compare/v1.3.1...v1.3.2) (2020-04-02)
201
+
202
+
203
+ ### Bug Fixes
204
+
205
+ * **app:** Fix lint errors ([c4df165](https://github.com/SAP/generator-easy-ui5/commit/c4df165e35b319aedfc932ac37d2593c0fa5e526))
206
+ * **formatter:** Fix formatter ([4f637c8](https://github.com/SAP/generator-easy-ui5/commit/4f637c81e2a916a0067d36f8d214a447a7a62212))
207
+
208
+
209
+ ### Features
210
+
211
+ * **BaseController:** Adding the BaseController and formatter ([e51a66b](https://github.com/SAP/generator-easy-ui5/commit/e51a66bfcd8dea90fd27c7684264e1202bde3e47))
212
+ * **BaseController:** Fix lint and activate install again after creation ([8697b1b](https://github.com/SAP/generator-easy-ui5/commit/8697b1bdbcc3f82bb8eb5f0e9e750b37f0d44d8f))
213
+
214
+
215
+
216
+ ## [1.3.1](https://github.com/SAP/generator-easy-ui5/compare/v1.3.0...v1.3.1) (2020-03-20)
217
+
218
+
219
+
220
+ # [1.3.0](https://github.com/SAP/generator-easy-ui5/compare/v1.2.0...v1.3.0) (2020-03-11)
221
+
222
+
223
+
224
+ # [1.2.0](https://github.com/SAP/generator-easy-ui5/compare/v1.1.1...v1.2.0) (2020-02-13)
225
+
226
+
227
+
228
+ ## [1.1.1](https://github.com/SAP/generator-easy-ui5/compare/v1.0.3...v1.1.1) (2019-12-13)
229
+
230
+
231
+
232
+ ## [1.0.3](https://github.com/SAP/generator-easy-ui5/compare/v1.0.2...v1.0.3) (2019-12-04)
233
+
234
+
235
+
236
+ ## [1.0.2](https://github.com/SAP/generator-easy-ui5/compare/v1.0.1...v1.0.2) (2019-11-08)
237
+
238
+
239
+
240
+ ## [1.0.1](https://github.com/SAP/generator-easy-ui5/compare/v1.0.0...v1.0.1) (2019-11-06)
241
+
242
+
243
+
244
+ # [1.0.0](https://github.com/SAP/generator-easy-ui5/compare/v0.3.4...v1.0.0) (2019-10-30)
245
+
246
+
247
+
248
+ ## [0.3.4](https://github.com/SAP/generator-easy-ui5/compare/v0.3.3...v0.3.4) (2019-10-24)
249
+
250
+
251
+
252
+ ## [0.3.3](https://github.com/SAP/generator-easy-ui5/compare/v0.3.2...v0.3.3) (2019-10-23)
253
+
254
+
255
+
256
+ ## [0.3.2](https://github.com/SAP/generator-easy-ui5/compare/v0.3.1...v0.3.2) (2019-10-23)
257
+
258
+
259
+
260
+ ## [0.3.1](https://github.com/SAP/generator-easy-ui5/compare/v2.0.2...v0.3.1) (2019-10-23)
261
+
262
+
263
+
package/README.md CHANGED
@@ -8,15 +8,19 @@
8
8
 
9
9
  ## Description
10
10
 
11
- Easy-ui5 is a [Yeoman](http://yeoman.io/) generator which enables you to create simple [SAPUI5](https://sapui5.hana.ondemand.com/)/[OpenUI5](https://openui5.hana.ondemand.com/)-based web-apps and other UI5-related projects within seconds.
11
+ Easy-ui5 💙 is a [Yeoman](http://yeoman.io/) generator which enables you to create simple [SAPUI5](https://sapui5.hana.ondemand.com/)/[OpenUI5](https://openui5.hana.ondemand.com/)-based web-apps and other UI5-related projects within seconds.
12
12
 
13
13
  This generator has been created to simplify the creation of your UI5 prototypes. Now you can scaffold simple UI5 projects from the shell/terminal of your choice. The current best practices (such as [async](https://blogs.sap.com/2018/12/18/ui5ers-buzz-41-best-practices-for-async-loading-in-ui5/)) are already baked into our templates so you don't have to worry about the definition of the metadata files.
14
14
 
15
15
  The purpose of this generator is to guide you on your first steps with [SAPUI5](https://sapui5.hana.ondemand.com/) and [SAP BTP](https://www.sap.com/products/business-technology-platform.html) deployments. Once you are familiar with those technologies, you might want to tweak the projects to adapt them for productive use-cases (such as continuous deployment pipelines and full i18n).
16
16
 
17
+ > Starting with easy-ui5 v3, all templates will be outsource to repositories in the [UI5 Community](https://github.com/ui5-community/). This project is from now on a shell that will offer all generators hosted on that GitHub org. Easy-ui5 will download and install these repositories when needed.
18
+ >
19
+ > By default, it will download the repository [generator-ui5-project](https://github.com/ui5-community/generator-ui5-project/) which contains the templates that were previously integrated in easy-ui5 < 3.
20
+
17
21
  ## Requirements
18
22
 
19
- - Get [Node.js](https://nodejs.org/en/download/) (**version 12 or higher** ⚠️)
23
+ - Get [Node.js](https://nodejs.org/en/download/) (**version 14 or higher** ⚠️)
20
24
 
21
25
  ## Download and Installation
22
26
 
@@ -7,13 +7,25 @@ const { hasYarn } = require("yarn-or-npm");
7
7
 
8
8
  const path = require("path");
9
9
  const fs = require("fs");
10
- const { rmdir } = require("fs").promises;
10
+ const { rm } = require("fs").promises;
11
11
 
12
12
  const { Octokit } = require("@octokit/rest");
13
13
  const { throttling } = require("@octokit/plugin-throttling");
14
14
  const MyOctokit = Octokit.plugin(throttling);
15
15
  const AdmZip = require("adm-zip");
16
16
 
17
+ // helper to retrieve config entries from npm
18
+ // --> npm config set easy-ui5_addGhOrg XYZ
19
+ const NPM_CONFIG_PREFIX = "easy-ui5_";
20
+ let npmConfig;
21
+ const getNPMConfig = (configName) => {
22
+ if (!npmConfig) {
23
+ npmConfig = require("libnpmconfig").read();
24
+ }
25
+ return npmConfig && npmConfig[`${NPM_CONFIG_PREFIX}${configName}`]
26
+ }
27
+
28
+ // the command line options of the generator
17
29
  const generatorOptions = {
18
30
  ghAuthToken: {
19
31
  type: String,
@@ -24,7 +36,26 @@ const generatorOptions = {
24
36
  type: String,
25
37
  description: "GitHub organization to lookup for available generators",
26
38
  default: "ui5-community",
27
- hidden: true // we don't want to recommend to use this option
39
+ hide: true // we don't want to recommend to use this option
40
+ },
41
+ subGeneratorPrefix: {
42
+ type: String,
43
+ description: "Prefix used for the lookup of the available generators",
44
+ default: "generator-ui5-",
45
+ hide: true // we don't want to recommend to use this option
46
+ },
47
+ addGhOrg: {
48
+ type: String,
49
+ description: `GitHub organization to lookup for additional available generators`,
50
+ hide: true, // we don't want to recommend to use this option
51
+ npmConfig: true
52
+ },
53
+ addSubGeneratorPrefix: {
54
+ type: String,
55
+ description: `Prefix used for the lookup of the additional available generators`,
56
+ default: "generator-",
57
+ hide: true, // we don't want to recommend to use this option
58
+ npmConfig: true
28
59
  },
29
60
  list: {
30
61
  type: Boolean,
@@ -71,12 +102,14 @@ module.exports = class extends Generator {
71
102
  });
72
103
 
73
104
  Object.keys(generatorOptions).forEach((optionName) => {
74
- if (!generatorOptions[optionName].hidden) {
75
- // register the option for being displayed in the help
76
- this.option(optionName, generatorOptions[optionName]);
77
- } else {
78
- // apply the default value for hidden options if needed
79
- this.options[optionName] = this.options[optionName] || generatorOptions[optionName].default;
105
+ const initialValue = this.options[optionName];
106
+ // register the option for being displayed in the help
107
+ this.option(optionName, generatorOptions[optionName]);
108
+ const defaultedValue = this.options[optionName];
109
+ if (generatorOptions[optionName].npmConfig) {
110
+ // if a value is set, use the set value (parameter has higher precedence than npm config)
111
+ // => this.option(...) applies the default value to this.options[...] used as last resort
112
+ this.options[optionName] = initialValue || getNPMConfig(optionName) || defaultedValue;
80
113
  }
81
114
  });
82
115
  }
@@ -105,30 +138,53 @@ module.exports = class extends Generator {
105
138
 
106
139
  async prompting() {
107
140
 
141
+ // Have Yeoman greet the user.
142
+ if (!this.options.embedded) {
143
+ this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
144
+ }
145
+
146
+ const home = path.join(__dirname, "..", "..");
147
+
148
+ // check the permissions to Easy UI5s plugin directory which must
149
+ // allow read/write to install additional plugin generators
150
+ let pluginsHome = path.join(home, "plugin-generators");
151
+ try {
152
+ fs.accessSync(pluginsHome, fs.constants.R_OK | fs.constants.W_OK);
153
+ } catch (e) {
154
+ pluginsHome = path.join(require("os").homedir(), ".npm", "_generator-easy-ui5", "plugin-generators");
155
+ if (this.options.verbose) {
156
+ console.error(`Plugin directory: ${chalk.green(pluginsHome)}`);
157
+ console.error(chalk.red(e.message));
158
+ }
159
+ fs.mkdirSync(pluginsHome, { recursive: true });
160
+ }
161
+
162
+ // log the plugins and configuration
108
163
  if (this.options.plugins) {
109
164
  const glob = require("glob");
110
165
  const yeoman = require("yeoman-environment/package.json");
111
- const home = __dirname.slice(0, -14);
112
166
 
113
167
  const components = {
114
168
  "Node.js": process.version,
169
+ "yeoman-environment": yeoman.version,
170
+ "generator-easy-ui5": require(path.join(home, "package.json")).version,
115
171
  "home": home,
116
- "yeoman-environment": yeoman.version
172
+ "pluginsHome": pluginsHome,
117
173
  };
118
- glob.sync(path.join(home, "plugin-generators/*/package.json")).forEach(function (plugin) {
119
- const name = plugin.match(/plugin-generators\/(.+)\/package\.json/)[1];
120
- const lib = require(plugin);
121
- components[name] = lib.version;
174
+
175
+ Object.keys(components).forEach((component) => {
176
+ this.log(`${chalk.green(component)}: ${components[component]}`);
122
177
  });
123
178
 
124
- const log = this.log;
125
- return Object.keys(components).forEach(function (component) {
126
- log(`${chalk.green(component)}: ${components[component]}`);
179
+ this.log(chalk.green("\nAvailable generators:"));
180
+ glob.sync(`${pluginsHome}/*/package.json`).forEach((plugin) => {
181
+ const name = plugin.match(/.*\/(.+)\/package\.json/)[1];
182
+ const lib = require(plugin);
183
+ this.log(` - ${chalk.green(name)}: ${lib.version}`);
127
184
  });
128
- ;
129
- }
130
185
 
131
- this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
186
+ return;
187
+ }
132
188
 
133
189
  // create the octokit client to retrieve the generators from GH org
134
190
  const octokit = new MyOctokit({
@@ -156,19 +212,68 @@ module.exports = class extends Generator {
156
212
  }
157
213
  });
158
214
 
215
+ // helper for filtering repos with corresponding subGenerator prefix
216
+ const filterReposWithSubGeneratorPrefix = (repos, subGeneratorPrefix) => {
217
+ if (!Array.isArray(repos)) {
218
+ return [];
219
+ }
220
+ return repos.filter((repo) =>
221
+ repo.name.startsWith(`${subGeneratorPrefix}`)
222
+ ).map((repo) => {
223
+ return {
224
+ org: repo.owner?.login,
225
+ name: repo.name,
226
+ branch: repo.default_branch,
227
+ subGeneratorName: repo.name.substring(subGeneratorPrefix.length),
228
+ };
229
+ });
230
+ }
231
+
232
+ // helper to retrieve the available repositories for a GH org
233
+ const listGeneratorsForOrg = async (ghOrg, subGeneratorPrefix) => {
234
+ const response = await octokit.repos.listForOrg({
235
+ org: ghOrg,
236
+ });
237
+ return filterReposWithSubGeneratorPrefix(response?.data, subGeneratorPrefix);
238
+ }
239
+
240
+ // helper to retrieve the available repositories for a GH user
241
+ const listGeneratorsForUser = async (ghUser, subGeneratorPrefix) => {
242
+ const response = await octokit.repos.listForUser({
243
+ username: ghUser,
244
+ });
245
+ return filterReposWithSubGeneratorPrefix(response?.data, subGeneratorPrefix);
246
+ }
247
+
159
248
  // retrieve the available repositories
160
- let reqRepos;
249
+ let availGenerators;
161
250
  try {
162
- reqRepos = await octokit.repos.listForOrg({
163
- org: this.options.ghOrg,
164
- });
251
+ availGenerators = await listGeneratorsForOrg(this.options.ghOrg, this.options.subGeneratorPrefix);
165
252
  } catch (e) {
166
- console.error(`Failed to connect to GitHub to retrieve available repository for "${this.options.ghOrg}" organization! Run with --verbose for details!`);
253
+ console.error(`Failed to connect to GitHub to retrieve available generators for "${this.options.ghOrg}" organization! Run with --verbose for details!`);
167
254
  if (this.options.verbose) {
168
255
  console.error(e);
169
256
  }
170
257
  return;
171
258
  }
259
+ try {
260
+ if (this.options.addGhOrg && this.options.addSubGeneratorPrefix) {
261
+ availGenerators = availGenerators.concat(await listGeneratorsForOrg(this.options.addGhOrg, this.options.addSubGeneratorPrefix));
262
+ }
263
+ } catch (e) {
264
+ if (this.options.verbose) {
265
+ this.log(`Failed to connect to GitHub retrieve additional generators for "${this.options.addGhOrg}" organization! Try to retrieve for user...`);
266
+ }
267
+ try {
268
+ availGenerators = availGenerators.concat(await listGeneratorsForUser(this.options.addGhOrg, this.options.addSubGeneratorPrefix));
269
+ } catch (e) {
270
+ console.error(`Failed to connect to GitHub to retrieve additional generators for organization or user "${this.options.addGhOrg}"! Run with --verbose for details!`);
271
+ if (this.options.verbose) {
272
+ console.error(e);
273
+ }
274
+ return;
275
+ }
276
+ }
172
277
 
173
278
  // download the generator from GH (or the test generator)
174
279
  let generatorPath;
@@ -180,11 +285,9 @@ module.exports = class extends Generator {
180
285
  } else {
181
286
 
182
287
  // check for provided generator being available on GH
183
- let generator =
184
- this.options.generator &&
185
- reqRepos.data.find(
186
- (repo) => repo.name === `generator-ui5-${this.options.generator}`
187
- );
288
+ let generator = this.options.generator && availGenerators.find((repo) =>
289
+ repo.subGeneratorName === this.options.generator
290
+ );
188
291
 
189
292
  // if no generator is provided and doesn't exist, ask for generator name
190
293
  if (!generator) {
@@ -195,37 +298,35 @@ module.exports = class extends Generator {
195
298
  )} was not found. Please select an existing generator!`
196
299
  );
197
300
  }
198
- const generatorRepos = reqRepos.data.filter((repo) =>
199
- /^generator-ui5-.+/.test(repo.name)
200
- );
301
+
201
302
  const generatorIdx = (
202
303
  await this.prompt([
203
304
  {
204
305
  type: "list",
205
306
  name: "generator",
206
307
  message: "Select your generator?",
207
- choices: generatorRepos.map((repo, idx) => ({
208
- name: repo.name,
308
+ choices: availGenerators.map((availGenerator, idx) => ({
309
+ name: `${availGenerator.subGeneratorName}${this.options.addGhOrg ? ` [${availGenerator.org}]` : ""}`,
209
310
  value: idx,
210
311
  })),
211
312
  },
212
313
  ])
213
314
  ).generator;
214
- generator = generatorRepos[generatorIdx];
315
+ generator = availGenerators[generatorIdx];
215
316
  }
216
317
 
217
318
  // fetch the available branches to retrieve the latest commit SHA
218
319
  let reqBranch;
219
320
  try {
220
321
  reqBranch = await octokit.repos.getBranch({
221
- owner: this.options.ghOrg,
322
+ owner: generator.org,
222
323
  repo: generator.name,
223
- branch: generator.default_branch,
324
+ branch: generator.branch,
224
325
  });
225
326
  } catch (e) {
226
- console.error(`Failed to retrieve the default branch for repository "${generator.name}" for "${this.options.ghOrg}" organization! Run with --verbose for details!`);
327
+ console.error(chalk.red(`Failed to retrieve the default branch for repository "${generator.name}" for "${generator.org}" organization! Run with --verbose for details!`));
227
328
  if (this.options.verbose) {
228
- console.error(e);
329
+ console.error(chalk.red(e.message));
229
330
  }
230
331
  return;
231
332
  }
@@ -234,14 +335,10 @@ module.exports = class extends Generator {
234
335
 
235
336
  if (this.options.verbose) {
236
337
  this.log(
237
- `Using commit ${commitSHA} from @${this.options.ghOrg}/${generator.name}#${generator.default_branch}...`
338
+ `Using commit ${commitSHA} from @${generator.org}/${generator.name}#${generator.default_branch}...`
238
339
  );
239
340
  }
240
- generatorPath = path.join(
241
- __dirname,
242
- "../../plugin-generators",
243
- generator.name
244
- );
341
+ generatorPath = path.join(pluginsHome, generator.name);
245
342
  const shaMarker = path.join(generatorPath, `.${commitSHA}`);
246
343
 
247
344
  if (fs.existsSync(generatorPath) && !this.options.skipUpdate) {
@@ -252,7 +349,7 @@ module.exports = class extends Generator {
252
349
  }
253
350
  // remove if the SHA marker doesn't exist => outdated!
254
351
  this._showBusy(` Removing old "${generator.name}" templates`);
255
- await rmdir(generatorPath, { recursive: true });
352
+ await rm(generatorPath, { recursive: true });
256
353
  }
257
354
  }
258
355
 
@@ -263,7 +360,7 @@ module.exports = class extends Generator {
263
360
  }
264
361
  this._showBusy(` Downloading and extracting "${generator.name}" templates`);
265
362
  const reqZIPArchive = await octokit.repos.downloadZipballArchive({
266
- owner: this.options.ghOrg,
363
+ owner: generator.org,
267
364
  repo: generator.name,
268
365
  ref: commitSHA,
269
366
  });
@@ -291,7 +388,7 @@ module.exports = class extends Generator {
291
388
  }
292
389
  this._showBusy(` Preparing "${generator.name}"`);
293
390
  await new Promise(function (resolve, reject) {
294
- spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
391
+ spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress", "--ignore-engines"], {
295
392
  stdio: this.config.verbose ? "inherit" : "ignore",
296
393
  cwd: generatorPath,
297
394
  env: {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const spawn = require("cross-spawn");
3
3
  const fs = require("fs");
4
- const { rmdir } = require("fs").promises;
4
+ const { rm } = require("fs").promises;
5
5
  const path = require("path");
6
6
  const { hasYarn } = require("yarn-or-npm");
7
7
  const { Octokit } = require("@octokit/rest");
@@ -66,7 +66,7 @@ const ghOrg = "ui5-community",
66
66
  console.log("The default generator is outdated...");
67
67
  // remove if the SHA marker doesn't exist => outdated!
68
68
  showBusy(" Removing old default templates");
69
- await rmdir(generatorPath, { recursive: true });
69
+ await rm(generatorPath, { recursive: true });
70
70
  }
71
71
  }
72
72
 
@@ -102,7 +102,7 @@ const ghOrg = "ui5-community",
102
102
  console.log("Installing the plugin dependencies...");
103
103
  showBusy(" Preparing the default templates");
104
104
  await new Promise(function (resolve, reject) {
105
- spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
105
+ spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress", "--ignore-engines"], {
106
106
  stdio: "inherit",
107
107
  cwd: generatorPath,
108
108
  env: {
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "generator-easy-ui5",
3
- "version": "3.1.5",
3
+ "version": "3.3.0",
4
4
  "description": "Generator for UI5-based project",
5
5
  "main": "generators/app/index.js",
6
6
  "files": [
7
7
  "generators"
8
8
  ],
9
+ "engines": {
10
+ "node": ">=14.0.0"
11
+ },
9
12
  "scripts": {
10
13
  "test": "mocha",
11
14
  "postinstall": "node generators/app/postinstall",
@@ -14,7 +17,10 @@
14
17
  "start": "yo easy-ui5 project",
15
18
  "listSubGen": "yo easy-ui5 project --list",
16
19
  "startSubGen": "yo easy-ui5 project app",
17
- "workaround": "find . -name '.DS_Store' -delete"
20
+ "workaround": "find . -name '.DS_Store' -delete",
21
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
22
+ "prepare": "husky install",
23
+ "hooks:commit-msg": "commitlint -e"
18
24
  },
19
25
  "repository": {
20
26
  "type": "git",
@@ -40,18 +46,34 @@
40
46
  "@octokit/rest": "^18.12.0",
41
47
  "adm-zip": "^0.5.9",
42
48
  "chalk": "^4.1.2",
43
- "colors": "^1.4.0",
49
+ "colors": "1.4.0",
44
50
  "glob": "^7.2.0",
45
- "mocha": "^9.1.3",
51
+ "libnpmconfig": "^1.2.1",
52
+ "mocha": "^9.2.0",
46
53
  "rimraf": "^3.0.2",
47
54
  "yarn-or-npm": "^3.0.1",
48
55
  "yeoman-assert": "^3.1.1",
49
- "yeoman-environment": "^3.8.0",
50
- "yeoman-generator": "^5.4.2",
51
- "yeoman-test": "^6.2.0",
56
+ "yeoman-environment": "^3.9.1",
57
+ "yeoman-generator": "^5.6.1",
58
+ "yeoman-test": "^6.3.0",
52
59
  "yosay": "^2.0.2"
53
60
  },
54
61
  "devDependencies": {
55
- "prettier": "2.4.1"
62
+ "@commitlint/cli": "16.1.0",
63
+ "@commitlint/config-conventional": "16.0.0",
64
+ "conventional-changelog-cli": "^2.2.2",
65
+ "cz-conventional-changelog": "3.3.0",
66
+ "husky": "^7.0.4",
67
+ "prettier": "2.5.1"
68
+ },
69
+ "config": {
70
+ "commitizen": {
71
+ "path": "cz-conventional-changelog"
72
+ }
73
+ },
74
+ "commitlint": {
75
+ "extends": [
76
+ "@commitlint/config-conventional"
77
+ ]
56
78
  }
57
79
  }