generator-easy-ui5 3.1.0 → 3.1.4

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.
@@ -10,36 +10,38 @@ const fs = require("fs");
10
10
  const { rmdir } = require("fs").promises;
11
11
 
12
12
  const { Octokit } = require("@octokit/rest");
13
+ const { throttling } = require("@octokit/plugin-throttling");
14
+ const MyOctokit = Octokit.plugin(throttling);
13
15
  const AdmZip = require("adm-zip");
14
16
 
15
17
  const generatorOptions = {
16
18
  ghAuthToken: {
17
19
  type: String,
18
20
  description:
19
- `GitHub authToken to optionally access private generator repositories`,
21
+ "GitHub authToken to optionally access private generator repositories",
20
22
  },
21
23
  ghOrg: {
22
24
  type: String,
23
- description: `GitHub organization to lookup for available generators`,
25
+ description: "GitHub organization to lookup for available generators",
24
26
  default: "ui5-community",
25
27
  hidden: true // we don't want to recommend to use this option
26
28
  },
27
29
  list: {
28
30
  type: Boolean,
29
- description: `List the available subcommands of the generator`,
31
+ description: "List the available subcommands of the generator",
30
32
  },
31
33
  verbose: {
32
34
  type: Boolean,
33
- description: `Enable detailed logging`,
35
+ description: "Enable detailed logging",
34
36
  },
35
37
  skipUpdate: {
36
38
  type: Boolean,
37
- description: `Skip the update of the plugin generators`,
39
+ description: "Skip the update of the plugin generators",
38
40
  },
39
41
  plugins: {
40
42
  type: Boolean,
41
43
  alias: "p",
42
- description: `Get detailed version information`,
44
+ description: "Get detailed version information",
43
45
  }
44
46
  };
45
47
 
@@ -47,18 +49,21 @@ const generatorArgs = {
47
49
  generator: {
48
50
  type: String,
49
51
  required: false,
50
- description: `Name of the generator to invoke (without the "generator-ui5-" prefix)`,
52
+ description: "Name of the generator to invoke (without the \"generator-ui5-\" prefix)",
51
53
  },
52
54
  subcommand: {
53
55
  type: String,
54
56
  required: false,
55
- description: `Name of the subcommand to invoke (without the "generator:" prefix)`,
57
+ description: "Name of the subcommand to invoke (without the \"generator:\" prefix)",
56
58
  },
57
59
  };
58
60
 
59
61
  module.exports = class extends Generator {
60
62
  constructor(args, opts) {
61
- super(args, opts);
63
+ super(args, opts, {
64
+ // disable the Yeoman 5 package-manager logic (auto install)!
65
+ customInstallTask: "disabled"
66
+ });
62
67
 
63
68
  Object.keys(generatorArgs).forEach((argName) => {
64
69
  // register the argument for being displayed in the help
@@ -78,7 +83,7 @@ module.exports = class extends Generator {
78
83
 
79
84
  _showBusy(statusText) {
80
85
  this._clearBusy();
81
- const progressChars = ['\\', '|', '/', '-'];
86
+ const progressChars = ["\\", "|", "/", "-"];
82
87
  let i = 0;
83
88
  process.stdout.write(`\r${statusText} `);
84
89
  this._busy = {
@@ -93,7 +98,7 @@ module.exports = class extends Generator {
93
98
  _clearBusy(newLine) {
94
99
  if (this._busy) {
95
100
  clearInterval(this._busy.timer);
96
- process.stdout.write(`\r`.padEnd(this._busy.text.length + 3) + (newLine ? "\n" : ""));
101
+ process.stdout.write("\r".padEnd(this._busy.text.length + 3) + (newLine ? "\n" : ""));
97
102
  delete this._busy;
98
103
  }
99
104
  }
@@ -103,30 +108,52 @@ module.exports = class extends Generator {
103
108
  if (this.options.plugins) {
104
109
  const glob = require("glob");
105
110
  const yeoman = require("yeoman-environment/package.json");
111
+ const home = __dirname.slice(0, -14);
106
112
 
107
113
  const components = {
108
- 'Node.js': process.version,
109
- 'home': __dirname.slice(0, -4),
114
+ "Node.js": process.version,
115
+ "home": home,
110
116
  "yeoman-environment": yeoman.version
111
117
  };
112
- glob.sync("./plugin-generators/*/package.json").forEach(function (plugin) {
113
- const name = plugin.replace("./plugin-generators/", "").replace("/package.json", "");
114
- const lib = require(path.join("../../", plugin));
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);
115
121
  components[name] = lib.version;
116
122
  });
117
123
 
118
124
  const log = this.log;
119
125
  return Object.keys(components).forEach(function (component) {
120
126
  log(`${chalk.green(component)}: ${components[component]}`);
121
- })
127
+ });
128
+ ;
122
129
  }
123
130
 
124
131
  this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
125
132
 
126
133
  // create the octokit client to retrieve the generators from GH org
127
- const octokit = new Octokit({
134
+ const octokit = new MyOctokit({
128
135
  userAgent: `${this.rootGeneratorName()}:${this.rootGeneratorVersion()}`,
129
136
  auth: this.options.ghAuthToken,
137
+ throttle: {
138
+ onRateLimit: (retryAfter, options) => {
139
+ this.log(
140
+ `${chalk.yellow("Hit the GitHub API limit!")} Request quota exhausted for this request.`
141
+ );
142
+
143
+ if (options.request.retryCount === 0) {
144
+ // only retries once
145
+ 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\`. `);
146
+ return true;
147
+ }
148
+ },
149
+ onAbuseLimit: () => {
150
+ // does not retry, only logs a warning
151
+ this.log(
152
+ `${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\` `
153
+ );
154
+
155
+ },
156
+ }
130
157
  });
131
158
 
132
159
  // retrieve the available repositories
@@ -271,9 +298,9 @@ module.exports = class extends Generator {
271
298
  ...process.env,
272
299
  "NO_UPDATE_NOTIFIER": true
273
300
  }
274
- }).on('exit', function (code) {
301
+ }).on("exit", function (code) {
275
302
  resolve(code);
276
- }).on('error', function (err) {
303
+ }).on("error", function (err) {
277
304
  reject(err);
278
305
  });
279
306
  }.bind(this));
@@ -348,7 +375,7 @@ module.exports = class extends Generator {
348
375
  }
349
376
  }
350
377
 
351
- // transform the list of the subgenerators and identify the
378
+ // transform the list of the subgenerators and identify the
352
379
  // default subgenerator for the default selection
353
380
  let defaultSubGenerator;
354
381
  let maxLength = 0;
@@ -17,7 +17,7 @@ const ghOrg = "ui5-community",
17
17
 
18
18
  function showBusy(statusText) {
19
19
  clearBusy();
20
- const progressChars = ['\\', '|', '/', '-'];
20
+ const progressChars = ["\\", "|", "/", "-"];
21
21
  let i = 0;
22
22
  process.stdout.write(`\r${statusText} `);
23
23
  _busy = {
@@ -32,7 +32,7 @@ const ghOrg = "ui5-community",
32
32
  function clearBusy(newLine) {
33
33
  if (_busy) {
34
34
  clearInterval(_busy.timer);
35
- process.stdout.write(`\r`.padEnd(_busy.text.length + 3) + (newLine ? "\n" : ""));
35
+ process.stdout.write("\r".padEnd(_busy.text.length + 3) + (newLine ? "\n" : ""));
36
36
  _busy = null;
37
37
  }
38
38
  }
@@ -63,9 +63,9 @@ const ghOrg = "ui5-community",
63
63
  if (fs.existsSync(generatorPath)) {
64
64
  // check if the SHA marker exists to know whether the generator is up-to-date or not
65
65
  if (!fs.existsSync(shaMarker)) {
66
- console.log(`The default generator is outdated...`);
66
+ console.log("The default generator is outdated...");
67
67
  // remove if the SHA marker doesn't exist => outdated!
68
- showBusy(` Removing old default templates`);
68
+ showBusy(" Removing old default templates");
69
69
  await rmdir(generatorPath, { recursive: true });
70
70
  }
71
71
  }
@@ -73,8 +73,8 @@ const ghOrg = "ui5-community",
73
73
 
74
74
  // re-fetch the generator and extract into local plugin folder
75
75
  if (!fs.existsSync(generatorPath)) {
76
- console.log(`Extracting default templates...`);
77
- showBusy(` Downloading and extracting default templates`);
76
+ console.log("Extracting default templates...");
77
+ showBusy(" Downloading and extracting default templates");
78
78
  const reqZIPArchive = await octokit.repos.downloadZipballArchive({
79
79
  owner: ghOrg,
80
80
  repo: repoName,
@@ -100,7 +100,7 @@ const ghOrg = "ui5-community",
100
100
 
101
101
  // run yarn/npm install
102
102
  console.log("Installing the plugin dependencies...");
103
- showBusy(` Preparing the default templates`);
103
+ showBusy(" Preparing the default templates");
104
104
  await new Promise(function (resolve, reject) {
105
105
  spawn((hasYarn() ? "yarn" : "npm"), ["install", "--no-progress"], {
106
106
  stdio: "inherit",
@@ -109,9 +109,9 @@ const ghOrg = "ui5-community",
109
109
  ...process.env,
110
110
  "NO_UPDATE_NOTIFIER": true
111
111
  }
112
- }).on('exit', function (code) {
112
+ }).on("exit", function (code) {
113
113
  resolve(code);
114
- }).on('error', function (err) {
114
+ }).on("error", function (err) {
115
115
  reject(err);
116
116
  });
117
117
  }.bind(this));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-easy-ui5",
3
- "version": "3.1.0",
3
+ "version": "3.1.4",
4
4
  "description": "Generator for UI5-based project",
5
5
  "main": "generators/app/index.js",
6
6
  "files": [
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "test": "mocha",
11
11
  "postinstall": "node generators/app/postinstall",
12
- "lint": "eslint .",
12
+ "lint": "eslint . --fix",
13
13
  "prettier": "prettier --write .",
14
14
  "start": "yo easy-ui5 project",
15
15
  "listSubGen": "yo easy-ui5 project --list",
@@ -36,6 +36,7 @@
36
36
  },
37
37
  "homepage": "https://github.com/SAP/generator-easy-ui5#readme",
38
38
  "dependencies": {
39
+ "@octokit/plugin-throttling": "^3.5.2",
39
40
  "@octokit/rest": "^18.12.0",
40
41
  "adm-zip": "^0.5.9",
41
42
  "chalk": "^4.1.2",