generator-easy-ui5 3.2.2 → 3.5.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,3 +1,21 @@
1
+ # [3.4.0](https://github.com/SAP/generator-easy-ui5/compare/v3.2.0...v3.4.0) (2022-06-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **postinstall:** allow usage of NPM config for ghAuthToken to avoid rate limit ([#104](https://github.com/SAP/generator-easy-ui5/issues/104)) ([371d7fb](https://github.com/SAP/generator-easy-ui5/commit/371d7fbc82b8a59cef896197b99239b505b3cd90)), closes [#100](https://github.com/SAP/generator-easy-ui5/issues/100)
7
+ * **postinstall:** avoid non-existing node_modules ([#98](https://github.com/SAP/generator-easy-ui5/issues/98)) ([f93c7c9](https://github.com/SAP/generator-easy-ui5/commit/f93c7c99b9e5df7af801a085afe72be85e462007))
8
+ * 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))
9
+ * use the org name of the selected generator for downloading the corresponding repo ([d9ca4dc](https://github.com/SAP/generator-easy-ui5/commit/d9ca4dc3170e0507199799d2e14db327cba4d871))
10
+
11
+
12
+ ### Features
13
+
14
+ * allow ghAuthToken as NPM configuration ([#103](https://github.com/SAP/generator-easy-ui5/issues/103)) ([5e3d928](https://github.com/SAP/generator-easy-ui5/commit/5e3d92807e881d0ade80251bc8cc1bdde85142be))
15
+ * allow to run easy-ui5 embedded ([#99](https://github.com/SAP/generator-easy-ui5/issues/99)) ([f4952c4](https://github.com/SAP/generator-easy-ui5/commit/f4952c442c9563a51c48b8edc25843f097fce4c4))
16
+
17
+
18
+
1
19
  # [3.2.0](https://github.com/SAP/generator-easy-ui5/compare/v3.1.5...v3.2.0) (2022-02-03)
2
20
 
3
21
 
package/README.md CHANGED
@@ -20,7 +20,7 @@ The purpose of this generator is to guide you on your first steps with [SAPUI5](
20
20
 
21
21
  ## Requirements
22
22
 
23
- - 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** ⚠️)
24
24
 
25
25
  ## Download and Installation
26
26
 
@@ -7,8 +7,10 @@ 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
+ const glob = require("glob");
11
12
 
13
+ const { request } = require("@octokit/request");
12
14
  const { Octokit } = require("@octokit/rest");
13
15
  const { throttling } = require("@octokit/plugin-throttling");
14
16
  const MyOctokit = Octokit.plugin(throttling);
@@ -31,6 +33,7 @@ const generatorOptions = {
31
33
  type: String,
32
34
  description:
33
35
  "GitHub authToken to optionally access private generator repositories",
36
+ npmConfig: true
34
37
  },
35
38
  ghOrg: {
36
39
  type: String,
@@ -61,19 +64,32 @@ const generatorOptions = {
61
64
  type: Boolean,
62
65
  description: "List the available subcommands of the generator",
63
66
  },
64
- verbose: {
67
+ skipUpdate: {
65
68
  type: Boolean,
66
- description: "Enable detailed logging",
69
+ description: "Skip the update of the plugin generator",
67
70
  },
68
- skipUpdate: {
71
+ forceUpdate: {
72
+ type: Boolean,
73
+ description: "Force the update of the plugin generator",
74
+ },
75
+ offline: {
69
76
  type: Boolean,
70
- description: "Skip the update of the plugin generators",
77
+ alias: "o",
78
+ description: "Running easy-ui5 in offline mode",
79
+ },
80
+ verbose: {
81
+ type: Boolean,
82
+ description: "Enable detailed logging",
71
83
  },
72
84
  plugins: {
73
85
  type: Boolean,
74
86
  alias: "p",
75
87
  description: "Get detailed version information",
76
- }
88
+ },
89
+ next: {
90
+ type: Boolean,
91
+ description: "Preview the next mode to consume templates from bestofui5.org",
92
+ },
77
93
  };
78
94
 
79
95
  const generatorArgs = {
@@ -138,7 +154,10 @@ module.exports = class extends Generator {
138
154
 
139
155
  async prompting() {
140
156
 
141
- this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
157
+ // Have Yeoman greet the user.
158
+ if (!this.options.embedded) {
159
+ this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
160
+ }
142
161
 
143
162
  const home = path.join(__dirname, "..", "..");
144
163
 
@@ -158,7 +177,6 @@ module.exports = class extends Generator {
158
177
 
159
178
  // log the plugins and configuration
160
179
  if (this.options.plugins) {
161
- const glob = require("glob");
162
180
  const yeoman = require("yeoman-environment/package.json");
163
181
 
164
182
  const components = {
@@ -175,7 +193,7 @@ module.exports = class extends Generator {
175
193
 
176
194
  this.log(chalk.green("\nAvailable generators:"));
177
195
  glob.sync(`${pluginsHome}/*/package.json`).forEach((plugin) => {
178
- const name = plugin.match(/.*\/(.+)\/package\.json/)[1];
196
+ const name = plugin.match(/.*\/generator-(.+)\/package\.json/)[1];
179
197
  const lib = require(plugin);
180
198
  this.log(` - ${chalk.green(name)}: ${lib.version}`);
181
199
  });
@@ -184,30 +202,38 @@ module.exports = class extends Generator {
184
202
  }
185
203
 
186
204
  // create the octokit client to retrieve the generators from GH org
187
- const octokit = new MyOctokit({
188
- userAgent: `${this.rootGeneratorName()}:${this.rootGeneratorVersion()}`,
189
- auth: this.options.ghAuthToken,
190
- throttle: {
191
- onRateLimit: (retryAfter, options) => {
192
- this.log(
193
- `${chalk.yellow("Hit the GitHub API limit!")} Request quota exhausted for this request.`
194
- );
195
-
196
- if (options.request.retryCount === 0) {
197
- // only retries once
198
- this.log(`Retrying after ${retryAfter} seconds. Alternatively, you can cancel this operation and supply an auth token with the \`--ghAuthToken\` option. For more details, run \`yo easy-ui5 --help\`. `);
199
- return true;
200
- }
201
- },
202
- onAbuseLimit: () => {
203
- // does not retry, only logs a warning
204
- this.log(
205
- `${chalk.red("Hit the GitHub API limit again!")} Please supply an auth token with the \`--ghAuthToken\` option. For more details, run \`yo easy-ui5 --help\` `
206
- );
207
-
208
- },
209
- }
210
- });
205
+ // when not running in offline mode!
206
+ let octokit;
207
+ if (this.options.offline) {
208
+ this.log(
209
+ `Running in ${chalk.yellow(
210
+ "offline"
211
+ )} mode!`
212
+ );
213
+ } else {
214
+ octokit = new MyOctokit({
215
+ userAgent: `${this.rootGeneratorName()}:${this.rootGeneratorVersion()}`,
216
+ auth: this.options.ghAuthToken,
217
+ throttle: {
218
+ onRateLimit: (retryAfter, options) => {
219
+ this.log(
220
+ `${chalk.yellow("Hit the GitHub API limit!")} Request quota exhausted for this request.`
221
+ );
222
+ if (options.request.retryCount === 0) {
223
+ // only retries once
224
+ this.log(`Retrying after ${retryAfter} seconds. Alternatively, you can cancel this operation and supply an auth token with the \`--ghAuthToken\` option. For more details, run \`yo easy-ui5 --help\`. `);
225
+ return true;
226
+ }
227
+ },
228
+ onAbuseLimit: () => {
229
+ // does not retry, only logs a warning
230
+ this.log(
231
+ `${chalk.red("Hit the GitHub API limit again!")} Please supply an auth token with the \`--ghAuthToken\` option. For more details, run \`yo easy-ui5 --help\` `
232
+ );
233
+ },
234
+ }
235
+ });
236
+ }
211
237
 
212
238
  // helper for filtering repos with corresponding subGenerator prefix
213
239
  const filterReposWithSubGeneratorPrefix = (repos, subGeneratorPrefix) => {
@@ -224,7 +250,7 @@ module.exports = class extends Generator {
224
250
  subGeneratorName: repo.name.substring(subGeneratorPrefix.length),
225
251
  };
226
252
  });
227
- }
253
+ };
228
254
 
229
255
  // helper to retrieve the available repositories for a GH org
230
256
  const listGeneratorsForOrg = async (ghOrg, subGeneratorPrefix) => {
@@ -232,7 +258,7 @@ module.exports = class extends Generator {
232
258
  org: ghOrg,
233
259
  });
234
260
  return filterReposWithSubGeneratorPrefix(response?.data, subGeneratorPrefix);
235
- }
261
+ };
236
262
 
237
263
  // helper to retrieve the available repositories for a GH user
238
264
  const listGeneratorsForUser = async (ghUser, subGeneratorPrefix) => {
@@ -240,62 +266,133 @@ module.exports = class extends Generator {
240
266
  username: ghUser,
241
267
  });
242
268
  return filterReposWithSubGeneratorPrefix(response?.data, subGeneratorPrefix);
243
- }
269
+ };
244
270
 
245
- // retrieve the available repositories
246
- let availGenerators;
247
- try {
248
- availGenerators = await listGeneratorsForOrg(this.options.ghOrg, this.options.subGeneratorPrefix);
249
- } catch (e) {
250
- console.error(`Failed to connect to GitHub to retrieve available generators for "${this.options.ghOrg}" organization! Run with --verbose for details!`);
251
- if (this.options.verbose) {
252
- console.error(e);
253
- }
254
- return;
255
- }
256
- try {
257
- if (this.options.addGhOrg && this.options.addSubGeneratorPrefix) {
258
- availGenerators = availGenerators.concat(await listGeneratorsForOrg(this.options.addGhOrg, this.options.addSubGeneratorPrefix));
259
- }
260
- } catch (e) {
261
- if (this.options.verbose) {
262
- this.log(`Failed to connect to GitHub retrieve additional generators for "${this.options.addGhOrg}" organization! Try to retrieve for user...`);
263
- }
264
- try {
265
- availGenerators = availGenerators.concat(await listGeneratorsForUser(this.options.addGhOrg, this.options.addSubGeneratorPrefix));
266
- } catch (e) {
267
- console.error(`Failed to connect to GitHub to retrieve additional generators for organization or user "${this.options.addGhOrg}"! Run with --verbose for details!`);
271
+ // determine the generator to be used
272
+ let generator;
273
+
274
+ // try to identify whether concrete generator is defined
275
+ if (!generator) {
276
+ // determine generator by ${owner}/${repo}(!${dir})? syntax, e.g.:
277
+ // > yo easy-ui5 SAP-samples/ui5-typescript-tutorial
278
+ // > yo easy-ui5 SAP-samples/ui5-typescript-tutorial#1.0
279
+ // > yo easy-ui5 SAP-samples/ui5-typescript-tutorial\!/generator
280
+ // > yo easy-ui5 SAP-samples/ui5-typescript-tutorial\!/generator#1.0
281
+ const reGenerator = /([^\/]+)\/([^\!\#]+)(?:\!([^\#]+))?(?:\#(.+))?/;
282
+ const matchGenerator = reGenerator.exec(this.options.generator);
283
+ if (matchGenerator) {
284
+ // derive and path the generator information from command line
285
+ const [owner, repo, dir = "/generator", branch] = matchGenerator.slice(1);
286
+ generator = {
287
+ org: owner,
288
+ name: repo,
289
+ branch,
290
+ dir,
291
+ pluginPath: `_/${owner}/${repo}`,
292
+ };
293
+ // log which generator is being used!
268
294
  if (this.options.verbose) {
269
- console.error(e);
295
+ this.log(
296
+ `Using generator ${chalk.green(
297
+ `${owner}/${repo}!${dir}${branch ? "#" + branch : ""}`
298
+ )}`
299
+ );
270
300
  }
271
- return;
272
301
  }
273
302
  }
274
303
 
275
- // download the generator from GH (or the test generator)
276
- let generatorPath;
277
- if (this.options.generator === "test") {
278
- generatorPath = path.join(
279
- __dirname,
280
- "../../plugin-generators/generator-ui5-test"
281
- );
282
- } else {
304
+ // retrieve the available repositories (if no generator is specified specified directly)
305
+ let availGenerators;
306
+ if (!generator) {
307
+ if (this.options.offline) {
308
+ availGenerators = glob.sync(`${pluginsHome}/generator-*/package.json`).map((plugin) => {
309
+ const match = plugin.match(/.*\/(generator-(.+))\/package\.json/);
310
+ return {
311
+ org: "local",
312
+ name: match[1],
313
+ subGeneratorName: match[2].match(/(?:ui5-)?(.*)/)?.[1] || match[2],
314
+ local: true,
315
+ }
316
+ });
317
+ } else {
318
+ if (this.options.next) {
319
+ // check bestofui5.org for generators
320
+ try {
321
+ const response = await request({
322
+ method: "GET",
323
+ url: "https://raw.githubusercontent.com/ui5-community/bestofui5-data/live-data/data/data.json",
324
+ });
325
+ const data = JSON.parse(response.data);
326
+
327
+ availGenerators = data?.packages?.filter(entry => {
328
+ return entry.type === "generator";
329
+ }).map(entry => {
330
+ return {
331
+ org: entry.gitHubOwner,
332
+ name: entry.gitHubRepo,
333
+ subGeneratorName: entry.gitHubRepo.match(/(?:generator-(?:ui5-)?)(.*)/)?.[1] || entry.gitHubRepo,
334
+ };
335
+ });
336
+ } catch (e) {
337
+ console.error(`Failed to connect to bestofui5.org to retrieve all available generators! Run with --verbose for details!`);
338
+ if (this.options.verbose) {
339
+ console.error(e);
340
+ }
341
+ return;
342
+ }
343
+ } else {
344
+ // check the main GH org for generators
345
+ try {
346
+ availGenerators = await listGeneratorsForOrg(this.options.ghOrg, this.options.subGeneratorPrefix);
347
+ } catch (e) {
348
+ console.error(`Failed to connect to GitHub to retrieve all available generators for "${this.options.ghOrg}" organization! Run with --verbose for details!`);
349
+ if (this.options.verbose) {
350
+ console.error(e);
351
+ }
352
+ return;
353
+ }
283
354
 
355
+ // check the additional GH org for generators with a different prefix
356
+ try {
357
+ if (this.options.addGhOrg && this.options.addSubGeneratorPrefix) {
358
+ availGenerators = availGenerators.concat(await listGeneratorsForOrg(this.options.addGhOrg, this.options.addSubGeneratorPrefix));
359
+ }
360
+ } catch (e) {
361
+ if (this.options.verbose) {
362
+ this.log(`Failed to connect to GitHub retrieve additional generators for "${this.options.addGhOrg}" organization! Try to retrieve for user...`);
363
+ }
364
+ try {
365
+ availGenerators = availGenerators.concat(await listGeneratorsForUser(this.options.addGhOrg, this.options.addSubGeneratorPrefix));
366
+ } catch (e) {
367
+ console.error(`Failed to connect to GitHub to retrieve additional generators for organization or user "${this.options.addGhOrg}"! Run with --verbose for details!`);
368
+ if (this.options.verbose) {
369
+ console.error(e);
370
+ }
371
+ return;
372
+ }
373
+ }
374
+ }
375
+ }
376
+ }
377
+
378
+ // if no generator is provided and doesn't exist, ask for generator name
379
+ if (!generator) {
284
380
  // check for provided generator being available on GH
285
- let generator = this.options.generator && availGenerators.find((repo) =>
381
+ generator = this.options.generator && availGenerators.find((repo) =>
286
382
  repo.subGeneratorName === this.options.generator
287
383
  );
288
384
 
289
385
  // if no generator is provided and doesn't exist, ask for generator name
290
- if (!generator) {
291
- if (this.options.generator) {
292
- this.log(
293
- `The generator ${chalk.red(
294
- this.options.generator
295
- )} was not found. Please select an existing generator!`
296
- );
297
- }
386
+ if (this.options.generator && !generator) {
387
+ this.log(
388
+ `The generator ${chalk.red(
389
+ this.options.generator
390
+ )} was not found. Please select an existing generator!`
391
+ );
392
+ }
298
393
 
394
+ // still not found, select a generator
395
+ if (!generator) {
299
396
  const generatorIdx = (
300
397
  await this.prompt([
301
398
  {
@@ -311,45 +408,63 @@ module.exports = class extends Generator {
311
408
  ).generator;
312
409
  generator = availGenerators[generatorIdx];
313
410
  }
411
+ }
314
412
 
315
- // fetch the available branches to retrieve the latest commit SHA
316
- let reqBranch;
413
+ let generatorPath = path.join(pluginsHome, generator.pluginPath || generator.name);
414
+ if (!this.options.offline) {
415
+ // lookup the default path of the generator if not set
416
+ if (!generator.branch) {
417
+ try {
418
+ const repoInfo = await octokit.repos.get({
419
+ owner: generator.org,
420
+ repo: generator.name,
421
+ });
422
+ generator.branch = repoInfo.data.default_branch;
423
+ } catch (e) {
424
+ console.error(`Generator "${owner}/${repo}!${dir}${branch ? "#" + branch : ""}" not found! Run with --verbose for details!`);
425
+ if (this.options.verbose) {
426
+ console.error(e);
427
+ }
428
+ return;
429
+ }
430
+ }
431
+ // fetch the branch to retrieve the latest commit SHA
432
+ let commitSHA;
317
433
  try {
318
- reqBranch = await octokit.repos.getBranch({
434
+ // determine the commitSHA
435
+ const reqBranch = await octokit.repos.getBranch({
319
436
  owner: generator.org,
320
437
  repo: generator.name,
321
438
  branch: generator.branch,
322
439
  });
440
+ commitSHA = reqBranch.data.commit.sha;
323
441
  } catch (e) {
324
- console.error(chalk.red(`Failed to retrieve the default branch for repository "${generator.name}" for "${generator.org}" organization! Run with --verbose for details!`));
442
+ console.error(chalk.red(`Failed to retrieve the branch "${generator.branch}" for repository "${generator.name}" for "${generator.org}" organization! Run with --verbose for details!`));
325
443
  if (this.options.verbose) {
326
444
  console.error(chalk.red(e.message));
327
445
  }
328
446
  return;
329
447
  }
330
-
331
- const commitSHA = reqBranch.data.commit.sha;
332
-
448
+
333
449
  if (this.options.verbose) {
334
450
  this.log(
335
- `Using commit ${commitSHA} from @${generator.org}/${generator.name}#${generator.default_branch}...`
451
+ `Using commit ${commitSHA} from @${generator.org}/${generator.name}#${generator.branch}...`
336
452
  );
337
453
  }
338
- generatorPath = path.join(pluginsHome, generator.name);
339
454
  const shaMarker = path.join(generatorPath, `.${commitSHA}`);
340
-
455
+
341
456
  if (fs.existsSync(generatorPath) && !this.options.skipUpdate) {
342
457
  // check if the SHA marker exists to know whether the generator is up-to-date or not
343
- if (!fs.existsSync(shaMarker)) {
458
+ if (this.options.forceUpdate || !fs.existsSync(shaMarker)) {
344
459
  if (this.options.verbose) {
345
460
  this.log(`Generator "${generator.name}" in "${generatorPath}" is outdated...`);
346
461
  }
347
462
  // remove if the SHA marker doesn't exist => outdated!
348
463
  this._showBusy(` Removing old "${generator.name}" templates`);
349
- await rmdir(generatorPath, { recursive: true });
464
+ await rm(generatorPath, { recursive: true });
350
465
  }
351
466
  }
352
-
467
+
353
468
  // re-fetch the generator and extract into local plugin folder
354
469
  if (!fs.existsSync(generatorPath)) {
355
470
  if (this.options.verbose) {
@@ -366,9 +481,14 @@ module.exports = class extends Generator {
366
481
  const zipEntries = zip.getEntries();
367
482
  zipEntries.forEach((entry) => {
368
483
  const match =
369
- !entry.isDirectory && entry.entryName.match(/[^\/]+\/(.+)/);
370
- if (match) {
371
- const entryPath = match[1].slice(0, entry.name.length * -1);
484
+ !entry.isDirectory && entry.entryName.match(/[^\/]+(\/.+)/);
485
+ let entryPath;
486
+ if (generator.dir && match && match[1].startsWith(generator.dir)) {
487
+ entryPath = path.dirname(match[1].substring(generator.dir.length));
488
+ } else if (!generator.dir && match) {
489
+ entryPath = path.dirname(match[1]);
490
+ }
491
+ if (entryPath) {
372
492
  zip.extractEntryTo(
373
493
  entry,
374
494
  path.join(generatorPath, entryPath),
@@ -376,16 +496,16 @@ module.exports = class extends Generator {
376
496
  true
377
497
  );
378
498
  }
379
- });
499
+ });
380
500
  fs.writeFileSync(shaMarker, commitSHA);
381
-
501
+
382
502
  // run yarn/npm install
383
503
  if (this.options.verbose) {
384
504
  this.log("Installing the plugin dependencies...");
385
505
  }
386
506
  this._showBusy(` Preparing "${generator.name}"`);
387
507
  await new Promise(function (resolve, reject) {
388
- spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
508
+ spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress", "--ignore-engines"], {
389
509
  stdio: this.config.verbose ? "inherit" : "ignore",
390
510
  cwd: generatorPath,
391
511
  env: {
@@ -399,9 +519,10 @@ module.exports = class extends Generator {
399
519
  });
400
520
  }.bind(this));
401
521
  }
402
- }
522
+
523
+ this._clearBusy(true);
403
524
 
404
- this._clearBusy(true);
525
+ }
405
526
 
406
527
  // filter the local options and the help command
407
528
  const opts = Object.keys(this._options).filter(
@@ -519,7 +640,7 @@ module.exports = class extends Generator {
519
640
  }
520
641
 
521
642
  if (this.options.verbose) {
522
- this.log(`Calling ${chalk.red(subGenerator)}...`);
643
+ this.log(`Calling ${chalk.red(subGenerator)}...\n \\_ in: ${generatorPath}`);
523
644
  }
524
645
 
525
646
  // finally, run the subgenerator
@@ -1,15 +1,29 @@
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");
8
+ const { throttling } = require("@octokit/plugin-throttling");
9
+ const MyOctokit = Octokit.plugin(throttling);
8
10
  const AdmZip = require("adm-zip");
9
11
 
12
+ // helper to retrieve config entries from npm
13
+ // --> npm config set easy-ui5_addGhOrg XYZ
14
+ const NPM_CONFIG_PREFIX = "easy-ui5_";
15
+ let npmConfig;
16
+ const getNPMConfig = (configName) => {
17
+ if (!npmConfig) {
18
+ npmConfig = require("libnpmconfig").read();
19
+ }
20
+ return npmConfig && npmConfig[`${NPM_CONFIG_PREFIX}${configName}`]
21
+ }
22
+
10
23
  const ghOrg = "ui5-community",
11
24
  repoName = "generator-ui5-project",
12
- branch = "main";
25
+ branch = "main",
26
+ ghAuthToken = getNPMConfig("ghAuthToken");
13
27
 
14
28
  (async () => {
15
29
 
@@ -37,8 +51,25 @@ const ghOrg = "ui5-community",
37
51
  }
38
52
  }
39
53
 
40
- const octokit = new Octokit({
41
- userAgent: "generator-easy-ui5",
54
+ const pkg = require(path.join(__dirname, "../../package.json"));
55
+ console.log(`${pkg.name}:${pkg.version} - ${ghAuthToken}`);
56
+ const octokit = new MyOctokit({
57
+ userAgent: `${pkg.name}:${pkg.version}`,
58
+ auth: ghAuthToken,
59
+ throttle: {
60
+ onRateLimit: (retryAfter, options) => {
61
+ console.log(`Hit the GitHub API limit! Request quota exhausted for this request.`);
62
+ if (options.request.retryCount === 0) {
63
+ // only retries once
64
+ this.log(`Retrying after ${retryAfter} seconds. Alternatively, you can cancel this operation and supply an auth token with "npm config set easy-ui5_ghAuthToken ghp_xxxx".`);
65
+ return true;
66
+ }
67
+ },
68
+ onAbuseLimit: () => {
69
+ // does not retry, only logs a warning
70
+ console.error(`Hit the GitHub API limit again! Please supply an auth token with with "npm config set easy-ui5_ghAuthToken ghp_xxxx".`);
71
+ },
72
+ }
42
73
  });
43
74
 
44
75
  const reqBranch = await octokit.repos.getBranch({
@@ -51,7 +82,7 @@ const ghOrg = "ui5-community",
51
82
 
52
83
  // eslint-disable-next-line
53
84
  console.log(
54
- `Fetching ZIP for commit ${commitSHA} from @${ghOrg}/${repoName}#${branch}...`
85
+ `Using commit ${commitSHA} from @${ghOrg}/${repoName}#${branch}...`
55
86
  );
56
87
  const generatorPath = path.join(
57
88
  __dirname,
@@ -63,10 +94,13 @@ const ghOrg = "ui5-community",
63
94
  if (fs.existsSync(generatorPath)) {
64
95
  // check if the SHA marker exists to know whether the generator is up-to-date or not
65
96
  if (!fs.existsSync(shaMarker)) {
66
- console.log("The default generator is outdated...");
97
+ // eslint-disable-next-line
98
+ console.log(
99
+ `Fetching new ZIP as the default generator is outdated...`
100
+ );
67
101
  // remove if the SHA marker doesn't exist => outdated!
68
102
  showBusy(" Removing old default templates");
69
- await rmdir(generatorPath, { recursive: true });
103
+ await rm(generatorPath, { recursive: true });
70
104
  }
71
105
  }
72
106
 
@@ -102,7 +136,7 @@ const ghOrg = "ui5-community",
102
136
  console.log("Installing the plugin dependencies...");
103
137
  showBusy(" Preparing the default templates");
104
138
  await new Promise(function (resolve, reject) {
105
- spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
139
+ spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress", "--ignore-engines"], {
106
140
  stdio: "inherit",
107
141
  cwd: generatorPath,
108
142
  env: {
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "generator-easy-ui5",
3
- "version": "3.2.2",
3
+ "version": "3.5.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",
@@ -16,6 +19,7 @@
16
19
  "startSubGen": "yo easy-ui5 project app",
17
20
  "workaround": "find . -name '.DS_Store' -delete",
18
21
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
22
+ "postversion": "npm run changelog && git commit --all --amend --no-edit",
19
23
  "prepare": "husky install",
20
24
  "hooks:commit-msg": "commitlint -e"
21
25
  },
@@ -39,14 +43,14 @@
39
43
  },
40
44
  "homepage": "https://github.com/SAP/generator-easy-ui5#readme",
41
45
  "dependencies": {
42
- "@octokit/plugin-throttling": "^3.5.2",
43
- "@octokit/rest": "^18.12.0",
46
+ "@octokit/plugin-throttling": "^4.1.0",
47
+ "@octokit/rest": "^19.0.3",
44
48
  "adm-zip": "^0.5.9",
45
49
  "chalk": "^4.1.2",
46
50
  "colors": "1.4.0",
47
51
  "glob": "^7.2.0",
48
52
  "libnpmconfig": "^1.2.1",
49
- "mocha": "^9.2.0",
53
+ "mocha": "^10.0.0",
50
54
  "rimraf": "^3.0.2",
51
55
  "yarn-or-npm": "^3.0.1",
52
56
  "yeoman-assert": "^3.1.1",
@@ -56,12 +60,12 @@
56
60
  "yosay": "^2.0.2"
57
61
  },
58
62
  "devDependencies": {
59
- "@commitlint/cli": "16.1.0",
60
- "@commitlint/config-conventional": "16.0.0",
63
+ "@commitlint/cli": "17.0.3",
64
+ "@commitlint/config-conventional": "17.0.3",
61
65
  "conventional-changelog-cli": "^2.2.2",
62
66
  "cz-conventional-changelog": "3.3.0",
63
- "husky": "^7.0.4",
64
- "prettier": "2.5.1"
67
+ "husky": "^8.0.1",
68
+ "prettier": "2.7.1"
65
69
  },
66
70
  "config": {
67
71
  "commitizen": {
@@ -72,5 +76,8 @@
72
76
  "extends": [
73
77
  "@commitlint/config-conventional"
74
78
  ]
79
+ },
80
+ "overrides": {
81
+ "minimist": "^1.2.6"
75
82
  }
76
83
  }