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