generator-easy-ui5 3.3.0 → 3.5.1
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 +27 -128
- package/README.md +7 -3
- package/generators/app/index.js +597 -512
- package/generators/app/postinstall.js +120 -98
- package/package.json +32 -21
|
@@ -5,117 +5,139 @@ 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
|
-
|
|
12
|
-
|
|
24
|
+
repoName = "generator-ui5-project",
|
|
25
|
+
branch = "main",
|
|
26
|
+
ghAuthToken = getNPMConfig("ghAuthToken");
|
|
13
27
|
|
|
14
28
|
(async () => {
|
|
29
|
+
let _busy;
|
|
15
30
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function clearBusy(newLine) {
|
|
33
|
-
if (_busy) {
|
|
34
|
-
clearInterval(_busy.timer);
|
|
35
|
-
process.stdout.write("\r".padEnd(_busy.text.length + 3) + (newLine ? "\n" : ""));
|
|
36
|
-
_busy = null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
31
|
+
function showBusy(statusText) {
|
|
32
|
+
clearBusy();
|
|
33
|
+
const progressChars = ["\\", "|", "/", "-"];
|
|
34
|
+
let i = 0;
|
|
35
|
+
process.stdout.write(`\r${statusText} `);
|
|
36
|
+
_busy = {
|
|
37
|
+
text: statusText,
|
|
38
|
+
timer: setInterval(() => {
|
|
39
|
+
process.stdout.write(`\r${statusText} ${progressChars[i++]}`);
|
|
40
|
+
i %= progressChars.length;
|
|
41
|
+
}, 250),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
function clearBusy(newLine) {
|
|
46
|
+
if (_busy) {
|
|
47
|
+
clearInterval(_busy.timer);
|
|
48
|
+
process.stdout.write("\r".padEnd(_busy.text.length + 3) + (newLine ? "\n" : ""));
|
|
49
|
+
_busy = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
const pkg = require(path.join(__dirname, "../../package.json"));
|
|
54
|
+
console.log(`${pkg.name}:${pkg.version} - ${ghAuthToken}`);
|
|
55
|
+
const octokit = new MyOctokit({
|
|
56
|
+
userAgent: `${pkg.name}:${pkg.version}`,
|
|
57
|
+
auth: ghAuthToken,
|
|
58
|
+
throttle: {
|
|
59
|
+
onRateLimit: (retryAfter, options) => {
|
|
60
|
+
console.log("Hit the GitHub API limit! Request quota exhausted for this request.");
|
|
61
|
+
if (options.request.retryCount === 0) {
|
|
62
|
+
// only retries once
|
|
63
|
+
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".`);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onAbuseLimit: () => {
|
|
68
|
+
// does not retry, only logs a warning
|
|
69
|
+
console.error('Hit the GitHub API limit again! Please supply an auth token with with "npm config set easy-ui5_ghAuthToken ghp_xxxx".');
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
49
73
|
|
|
50
|
-
|
|
74
|
+
const reqBranch = await octokit.repos.getBranch({
|
|
75
|
+
owner: ghOrg,
|
|
76
|
+
repo: repoName,
|
|
77
|
+
branch,
|
|
78
|
+
});
|
|
51
79
|
|
|
52
|
-
|
|
53
|
-
console.log(
|
|
54
|
-
`Fetching ZIP for commit ${commitSHA} from @${ghOrg}/${repoName}#${branch}...`
|
|
55
|
-
);
|
|
56
|
-
const generatorPath = path.join(
|
|
57
|
-
__dirname,
|
|
58
|
-
"../../plugin-generators",
|
|
59
|
-
repoName
|
|
60
|
-
);
|
|
61
|
-
const shaMarker = path.join(generatorPath, `.${commitSHA}`);
|
|
80
|
+
const commitSHA = reqBranch.data.commit.sha;
|
|
62
81
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// remove if the SHA marker doesn't exist => outdated!
|
|
68
|
-
showBusy(" Removing old default templates");
|
|
69
|
-
await rm(generatorPath, { recursive: true });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
82
|
+
// eslint-disable-next-line
|
|
83
|
+
console.log(`Using commit ${commitSHA} from @${ghOrg}/${repoName}#${branch}...`);
|
|
84
|
+
const generatorPath = path.join(__dirname, "../../plugin-generators", repoName);
|
|
85
|
+
const shaMarker = path.join(generatorPath, `.${commitSHA}`);
|
|
72
86
|
|
|
87
|
+
if (fs.existsSync(generatorPath)) {
|
|
88
|
+
// check if the SHA marker exists to know whether the generator is up-to-date or not
|
|
89
|
+
if (!fs.existsSync(shaMarker)) {
|
|
90
|
+
// eslint-disable-next-line
|
|
91
|
+
console.log(`Fetching new ZIP as the default generator is outdated...`);
|
|
92
|
+
// remove if the SHA marker doesn't exist => outdated!
|
|
93
|
+
showBusy(" Removing old default templates");
|
|
94
|
+
await rm(generatorPath, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
73
97
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
false,
|
|
95
|
-
true
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
fs.writeFileSync(shaMarker, commitSHA);
|
|
98
|
+
// re-fetch the generator and extract into local plugin folder
|
|
99
|
+
if (!fs.existsSync(generatorPath)) {
|
|
100
|
+
console.log("Extracting default templates...");
|
|
101
|
+
showBusy(" Downloading and extracting default templates");
|
|
102
|
+
const reqZIPArchive = await octokit.repos.downloadZipballArchive({
|
|
103
|
+
owner: ghOrg,
|
|
104
|
+
repo: repoName,
|
|
105
|
+
ref: commitSHA,
|
|
106
|
+
});
|
|
107
|
+
const buffer = Buffer.from(new Uint8Array(reqZIPArchive.data));
|
|
108
|
+
const zip = new AdmZip(buffer);
|
|
109
|
+
const zipEntries = zip.getEntries();
|
|
110
|
+
zipEntries.forEach((entry) => {
|
|
111
|
+
const match = !entry.isDirectory && entry.entryName.match(/[^\/]+\/(.+)/);
|
|
112
|
+
if (match) {
|
|
113
|
+
const entryPath = match[1].slice(0, entry.name.length * -1);
|
|
114
|
+
zip.extractEntryTo(entry, path.join(generatorPath, entryPath), false, true);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
fs.writeFileSync(shaMarker, commitSHA);
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
// run yarn/npm install
|
|
120
|
+
console.log("Installing the plugin dependencies...");
|
|
121
|
+
showBusy(" Preparing the default templates");
|
|
122
|
+
await new Promise(
|
|
123
|
+
function (resolve, reject) {
|
|
124
|
+
spawn(hasYarn() ? "yarn" : "npm", ["install", "--no-progress", "--ignore-engines"], {
|
|
125
|
+
stdio: "inherit",
|
|
126
|
+
cwd: generatorPath,
|
|
127
|
+
env: {
|
|
128
|
+
...process.env,
|
|
129
|
+
NO_UPDATE_NOTIFIER: true,
|
|
130
|
+
},
|
|
131
|
+
})
|
|
132
|
+
.on("exit", function (code) {
|
|
133
|
+
resolve(code);
|
|
134
|
+
})
|
|
135
|
+
.on("error", function (err) {
|
|
136
|
+
reject(err);
|
|
137
|
+
});
|
|
138
|
+
}.bind(this)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
119
141
|
|
|
120
|
-
|
|
142
|
+
clearBusy(true);
|
|
121
143
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-easy-ui5",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Generator for UI5-based project",
|
|
5
5
|
"main": "generators/app/index.js",
|
|
6
6
|
"files": [
|
|
@@ -10,17 +10,21 @@
|
|
|
10
10
|
"node": ">=14.0.0"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "mocha",
|
|
14
13
|
"postinstall": "node generators/app/postinstall",
|
|
15
|
-
"lint": "eslint . --fix",
|
|
16
|
-
"prettier": "prettier --write .",
|
|
17
14
|
"start": "yo easy-ui5 project",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
15
|
+
"test": "mocha",
|
|
16
|
+
"test:subgen:list": "yo easy-ui5 project --list",
|
|
17
|
+
"test:subgen:start": "yo easy-ui5 project app",
|
|
18
|
+
"release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
19
|
+
"postversion": "npm run release:changelog && git commit --all --amend --no-edit",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"lint:fix": "eslint . --fix",
|
|
22
|
+
"lint:staged": "lint-staged",
|
|
23
|
+
"format": "prettier --write .",
|
|
24
|
+
"format:staged": "pretty-quick --staged --verbose",
|
|
25
|
+
"prepare": "node ./.husky/skip.js || husky install",
|
|
26
|
+
"hooks:commit-msg": "commitlint -e",
|
|
27
|
+
"hooks:pre-commit": "npm-run-all --sequential format:staged lint:staged"
|
|
24
28
|
},
|
|
25
29
|
"repository": {
|
|
26
30
|
"type": "git",
|
|
@@ -42,29 +46,33 @@
|
|
|
42
46
|
},
|
|
43
47
|
"homepage": "https://github.com/SAP/generator-easy-ui5#readme",
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@octokit/plugin-throttling": "^
|
|
46
|
-
"@octokit/rest": "^
|
|
49
|
+
"@octokit/plugin-throttling": "^4.2.0",
|
|
50
|
+
"@octokit/rest": "^19.0.4",
|
|
47
51
|
"adm-zip": "^0.5.9",
|
|
48
52
|
"chalk": "^4.1.2",
|
|
49
53
|
"colors": "1.4.0",
|
|
50
54
|
"glob": "^7.2.0",
|
|
51
55
|
"libnpmconfig": "^1.2.1",
|
|
52
|
-
"mocha": "^9.2.0",
|
|
53
56
|
"rimraf": "^3.0.2",
|
|
54
57
|
"yarn-or-npm": "^3.0.1",
|
|
55
|
-
"yeoman-
|
|
56
|
-
"yeoman-
|
|
57
|
-
"yeoman-generator": "^5.6.1",
|
|
58
|
-
"yeoman-test": "^6.3.0",
|
|
58
|
+
"yeoman-environment": "^3.10.0",
|
|
59
|
+
"yeoman-generator": "^5.7.0",
|
|
59
60
|
"yosay": "^2.0.2"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@commitlint/cli": "
|
|
63
|
-
"@commitlint/config-conventional": "
|
|
63
|
+
"@commitlint/cli": "17.0.3",
|
|
64
|
+
"@commitlint/config-conventional": "17.0.3",
|
|
64
65
|
"conventional-changelog-cli": "^2.2.2",
|
|
65
66
|
"cz-conventional-changelog": "3.3.0",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
67
|
+
"eslint": "^8.18.0",
|
|
68
|
+
"husky": "^8.0.1",
|
|
69
|
+
"lint-staged": "^13.0.3",
|
|
70
|
+
"mocha": "^10.0.0",
|
|
71
|
+
"npm-run-all": "^4.1.5",
|
|
72
|
+
"prettier": "2.7.1",
|
|
73
|
+
"pretty-quick": "^3.1.3",
|
|
74
|
+
"yeoman-assert": "^3.1.1",
|
|
75
|
+
"yeoman-test": "^6.3.0"
|
|
68
76
|
},
|
|
69
77
|
"config": {
|
|
70
78
|
"commitizen": {
|
|
@@ -75,5 +83,8 @@
|
|
|
75
83
|
"extends": [
|
|
76
84
|
"@commitlint/config-conventional"
|
|
77
85
|
]
|
|
86
|
+
},
|
|
87
|
+
"overrides": {
|
|
88
|
+
"minimist": "^1.2.6"
|
|
78
89
|
}
|
|
79
90
|
}
|