generator-easy-ui5 3.1.1 → 3.1.5
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/generators/app/index.js +46 -21
- package/generators/app/postinstall.js +9 -9
- package/package.json +3 -2
package/generators/app/index.js
CHANGED
|
@@ -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
|
-
|
|
21
|
+
"GitHub authToken to optionally access private generator repositories",
|
|
20
22
|
},
|
|
21
23
|
ghOrg: {
|
|
22
24
|
type: String,
|
|
23
|
-
description:
|
|
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:
|
|
31
|
+
description: "List the available subcommands of the generator",
|
|
30
32
|
},
|
|
31
33
|
verbose: {
|
|
32
34
|
type: Boolean,
|
|
33
|
-
description:
|
|
35
|
+
description: "Enable detailed logging",
|
|
34
36
|
},
|
|
35
37
|
skipUpdate: {
|
|
36
38
|
type: Boolean,
|
|
37
|
-
description:
|
|
39
|
+
description: "Skip the update of the plugin generators",
|
|
38
40
|
},
|
|
39
41
|
plugins: {
|
|
40
42
|
type: Boolean,
|
|
41
43
|
alias: "p",
|
|
42
|
-
description:
|
|
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:
|
|
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:
|
|
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(
|
|
101
|
+
process.stdout.write("\r".padEnd(this._busy.text.length + 3) + (newLine ? "\n" : ""));
|
|
97
102
|
delete this._busy;
|
|
98
103
|
}
|
|
99
104
|
}
|
|
@@ -103,15 +108,14 @@ 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");
|
|
106
|
-
const home = __dirname.slice(0, -14)
|
|
111
|
+
const home = __dirname.slice(0, -14);
|
|
107
112
|
|
|
108
113
|
const components = {
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
"Node.js": process.version,
|
|
115
|
+
"home": home,
|
|
111
116
|
"yeoman-environment": yeoman.version
|
|
112
117
|
};
|
|
113
118
|
glob.sync(path.join(home, "plugin-generators/*/package.json")).forEach(function (plugin) {
|
|
114
|
-
console.log(plugin)
|
|
115
119
|
const name = plugin.match(/plugin-generators\/(.+)\/package\.json/)[1];
|
|
116
120
|
const lib = require(plugin);
|
|
117
121
|
components[name] = lib.version;
|
|
@@ -120,15 +124,36 @@ module.exports = class extends Generator {
|
|
|
120
124
|
const log = this.log;
|
|
121
125
|
return Object.keys(components).forEach(function (component) {
|
|
122
126
|
log(`${chalk.green(component)}: ${components[component]}`);
|
|
123
|
-
})
|
|
127
|
+
});
|
|
128
|
+
;
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
this.log(yosay(`Welcome to the ${chalk.red("easy-ui5")} generator!`));
|
|
127
132
|
|
|
128
133
|
// create the octokit client to retrieve the generators from GH org
|
|
129
|
-
const octokit = new
|
|
134
|
+
const octokit = new MyOctokit({
|
|
130
135
|
userAgent: `${this.rootGeneratorName()}:${this.rootGeneratorVersion()}`,
|
|
131
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
|
+
}
|
|
132
157
|
});
|
|
133
158
|
|
|
134
159
|
// retrieve the available repositories
|
|
@@ -219,7 +244,7 @@ module.exports = class extends Generator {
|
|
|
219
244
|
);
|
|
220
245
|
const shaMarker = path.join(generatorPath, `.${commitSHA}`);
|
|
221
246
|
|
|
222
|
-
if (fs.existsSync(generatorPath) && this.options.skipUpdate) {
|
|
247
|
+
if (fs.existsSync(generatorPath) && !this.options.skipUpdate) {
|
|
223
248
|
// check if the SHA marker exists to know whether the generator is up-to-date or not
|
|
224
249
|
if (!fs.existsSync(shaMarker)) {
|
|
225
250
|
if (this.options.verbose) {
|
|
@@ -273,9 +298,9 @@ module.exports = class extends Generator {
|
|
|
273
298
|
...process.env,
|
|
274
299
|
"NO_UPDATE_NOTIFIER": true
|
|
275
300
|
}
|
|
276
|
-
}).on(
|
|
301
|
+
}).on("exit", function (code) {
|
|
277
302
|
resolve(code);
|
|
278
|
-
}).on(
|
|
303
|
+
}).on("error", function (err) {
|
|
279
304
|
reject(err);
|
|
280
305
|
});
|
|
281
306
|
}.bind(this));
|
|
@@ -350,7 +375,7 @@ module.exports = class extends Generator {
|
|
|
350
375
|
}
|
|
351
376
|
}
|
|
352
377
|
|
|
353
|
-
// transform the list of the subgenerators and identify the
|
|
378
|
+
// transform the list of the subgenerators and identify the
|
|
354
379
|
// default subgenerator for the default selection
|
|
355
380
|
let defaultSubGenerator;
|
|
356
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(
|
|
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(
|
|
66
|
+
console.log("The default generator is outdated...");
|
|
67
67
|
// remove if the SHA marker doesn't exist => outdated!
|
|
68
|
-
showBusy(
|
|
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(
|
|
77
|
-
showBusy(
|
|
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(
|
|
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(
|
|
112
|
+
}).on("exit", function (code) {
|
|
113
113
|
resolve(code);
|
|
114
|
-
}).on(
|
|
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.
|
|
3
|
+
"version": "3.1.5",
|
|
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",
|