generator-easy-ui5 3.2.1 → 3.4.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,19 @@
1
+ # [3.3.0](https://github.com/SAP/generator-easy-ui5/compare/v3.2.0...v3.3.0) (2022-02-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **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))
7
+ * 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))
8
+ * use the org name of the selected generator for downloading the corresponding repo ([d9ca4dc](https://github.com/SAP/generator-easy-ui5/commit/d9ca4dc3170e0507199799d2e14db327cba4d871))
9
+
10
+
11
+ ### Features
12
+
13
+ * 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))
14
+
15
+
16
+
1
17
  # [3.2.0](https://github.com/SAP/generator-easy-ui5/compare/v3.1.5...v3.2.0) (2022-02-03)
2
18
 
3
19
 
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,7 +7,7 @@ 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");
@@ -31,6 +31,7 @@ const generatorOptions = {
31
31
  type: String,
32
32
  description:
33
33
  "GitHub authToken to optionally access private generator repositories",
34
+ npmConfig: true
34
35
  },
35
36
  ghOrg: {
36
37
  type: String,
@@ -138,7 +139,10 @@ module.exports = class extends Generator {
138
139
 
139
140
  async prompting() {
140
141
 
141
- this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
142
+ // Have Yeoman greet the user.
143
+ if (!this.options.embedded) {
144
+ this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
145
+ }
142
146
 
143
147
  const home = path.join(__dirname, "..", "..");
144
148
 
@@ -321,7 +325,7 @@ module.exports = class extends Generator {
321
325
  branch: generator.branch,
322
326
  });
323
327
  } catch (e) {
324
- console.error(chalk.red(`Failed to retrieve the default branch for repository "${generator.name}" for "${this.options.ghOrg}" organization! Run with --verbose for details!`));
328
+ console.error(chalk.red(`Failed to retrieve the default branch for repository "${generator.name}" for "${generator.org}" organization! Run with --verbose for details!`));
325
329
  if (this.options.verbose) {
326
330
  console.error(chalk.red(e.message));
327
331
  }
@@ -332,7 +336,7 @@ module.exports = class extends Generator {
332
336
 
333
337
  if (this.options.verbose) {
334
338
  this.log(
335
- `Using commit ${commitSHA} from @${this.options.ghOrg}/${generator.name}#${generator.default_branch}...`
339
+ `Using commit ${commitSHA} from @${generator.org}/${generator.name}#${generator.default_branch}...`
336
340
  );
337
341
  }
338
342
  generatorPath = path.join(pluginsHome, generator.name);
@@ -346,7 +350,7 @@ module.exports = class extends Generator {
346
350
  }
347
351
  // remove if the SHA marker doesn't exist => outdated!
348
352
  this._showBusy(` Removing old "${generator.name}" templates`);
349
- await rmdir(generatorPath, { recursive: true });
353
+ await rm(generatorPath, { recursive: true });
350
354
  }
351
355
  }
352
356
 
@@ -385,7 +389,7 @@ module.exports = class extends Generator {
385
389
  }
386
390
  this._showBusy(` Preparing "${generator.name}"`);
387
391
  await new Promise(function (resolve, reject) {
388
- spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
392
+ spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress", "--ignore-engines"], {
389
393
  stdio: this.config.verbose ? "inherit" : "ignore",
390
394
  cwd: generatorPath,
391
395
  env: {
@@ -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.1",
3
+ "version": "3.4.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",