Skip to content

Commit 82525a8

Browse files
committed
Merge branch 'improve-cli' of https://github.com/nakrovati/js-framework-benchmark into nakrovati-improve-cli
2 parents d29264e + 44249b7 commit 82525a8

13 files changed

+197
-289
lines changed

cli/check-obsolete.js

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const frameworks = getFrameworks();
2020
*/
2121
function findDuplicateFrameworks(frameworks) {
2222
const names = frameworks.map((framework) => framework.name); // Creates an array with framework names only
23-
const duplicateNames = names.filter(
24-
(name, index) => names.indexOf(name) !== index,
25-
); // Filters out repetitive framework names
23+
const duplicateNames = names.filter((name, index) => names.indexOf(name) !== index); // Filters out repetitive framework names
2624

2725
return duplicateNames;
2826
}
@@ -59,11 +57,7 @@ function maybeObsolete(packageName) {
5957
}
6058

6159
const now = new Date();
62-
const obsoleteDate = new Date(
63-
now.getFullYear() - 1,
64-
now.getMonth(),
65-
now.getDay(),
66-
);
60+
const obsoleteDate = new Date(now.getFullYear() - 1, now.getMonth(), now.getDay());
6761

6862
const modifiedDate = new Date(timeData.modified);
6963
const isObsolete = modifiedDate < obsoleteDate;
@@ -72,7 +66,7 @@ function maybeObsolete(packageName) {
7266
return { isObsolete, lastUpdate: formattedDate, packageName };
7367
} catch (error) {
7468
console.error(
75-
`Failed to execute npm view for ${packageName}. Error Code ${error.status} and message: ${error.message}`,
69+
`Failed to execute npm view for ${packageName}. Error Code ${error.status} and message: ${error.message}`
7670
);
7771
return { isObsolete: false, lastUpdate: null, packageName };
7872
}
@@ -95,15 +89,12 @@ function checkObsoleteFrameworks(options) {
9589
const packageJSONPath = path.join(frameworkPath, "package.json");
9690

9791
if (!fs.existsSync(packageJSONPath)) {
98-
missingPackageWarnings.push(
99-
`WARN: skipping ${type}/${name} since there's no package.json`,
100-
);
92+
missingPackageWarnings.push(`WARN: skipping ${type}/${name} since there's no package.json`);
10193
continue;
10294
}
10395

10496
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf-8"));
105-
const mainPackages =
106-
packageJSON?.["js-framework-benchmark"]?.frameworkVersionFromPackage;
97+
const mainPackages = packageJSON?.["js-framework-benchmark"]?.frameworkVersionFromPackage;
10798

10899
if (!mainPackages) {
109100
manualChecks.push(`${type}/${name} has no frameworkVersionFromPackage`);
@@ -121,35 +112,25 @@ function checkObsoleteFrameworks(options) {
121112
console.log(`Results for ${type}/${name} ${isPackageObsolete}`);
122113
}
123114

124-
const anyPackageObsolete = isPackageObsolete.some(
125-
(packageFramework) => packageFramework.isObsolete,
126-
);
115+
const anyPackageObsolete = isPackageObsolete.some((packageFramework) => packageFramework.isObsolete);
127116

128117
if (anyPackageObsolete) {
129118
const formattedPackages = isPackageObsolete
130119
.map((result) => `${result.packageName}:${result.lastUpdate}`)
131120
.join(", ");
132121

133-
console.log(
134-
`Last npm update for ${type}/${name} - ${mainPackages} is older than a year: ${formattedPackages}`,
135-
);
122+
console.log(`Last npm update for ${type}/${name} - ${mainPackages} is older than a year: ${formattedPackages}`);
136123
continue;
137124
}
138125

139126
if (DEBUG) {
140-
console.log(
141-
`Last npm update for ${type}/${name} ${mainPackages} is newer than a year`,
142-
);
127+
console.log(`Last npm update for ${type}/${name} ${mainPackages} is newer than a year`);
143128
}
144129
}
145130

146-
if (missingPackageWarnings.length > 0)
147-
console.warn("\nWarnings:\n" + missingPackageWarnings.join("\n"));
131+
if (missingPackageWarnings.length > 0) console.warn("\nWarnings:\n" + missingPackageWarnings.join("\n"));
148132
if (manualChecks.length > 0)
149-
console.warn(
150-
"\nThe following frameworks must be checked manually\n" +
151-
manualChecks.join("\n"),
152-
);
133+
console.warn("\nThe following frameworks must be checked manually\n" + manualChecks.join("\n"));
153134
}
154135

155136
export { checkObsoleteFrameworks };

cli/cleanup.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import * as fs from "node:fs";
22
import path from "node:path";
33

4-
const filesToDelete = [
5-
"package-lock.json",
6-
"yarn-lock",
7-
"dist",
8-
"elm-stuff",
9-
"bower_components",
10-
"node_modules",
11-
];
4+
const filesToDelete = ["package-lock.json", "yarn-lock", "dist", "elm-stuff", "bower_components", "node_modules"];
125

136
/**
147
* Delete specified files in the framework directory

cli/configure-styles.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ async function copyAndGenerateSharedStyles(sourceCss, mainCss) {
1212
const sharedStylesContent = `<dom-module id="shared-styles"><template><style>${mainCssContent}</style></template></dom-module>`;
1313

1414
// Write shared-styles.html
15-
await fs.promises.writeFile(
16-
path.join("polymer-v2.0.0-non-keyed", "src", "shared-styles.html"),
17-
sharedStylesContent,
18-
);
15+
await fs.promises.writeFile(path.join("polymer-v2.0.0-non-keyed", "src", "shared-styles.html"), sharedStylesContent);
1916
}
2017

2118
/**
@@ -37,13 +34,10 @@ async function configureStyles(options) {
3734
if (bootstrap) {
3835
await copyAndGenerateSharedStyles(
3936
path.join("css", "useOriginalBootstrap.css"),
40-
path.join("css", "bootstrap", "dist", "css", "bootstrap.min.css"),
37+
path.join("css", "bootstrap", "dist", "css", "bootstrap.min.css")
4138
);
4239
} else {
43-
await copyAndGenerateSharedStyles(
44-
path.join("css", "useMinimalCss.css"),
45-
path.join("css", "useMinimalCss.css"),
46-
);
40+
await copyAndGenerateSharedStyles(path.join("css", "useMinimalCss.css"), path.join("css", "useMinimalCss.css"));
4741
}
4842
} catch (error) {
4943
console.error("An error occurred:", error.message);

cli/copy.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function shouldInclude(name) {
1717
const isTargetWeb = name.includes("/target/web");
1818

1919
console.log(
20-
`File: ${name}\nIs Binding Scala: ${isBindingScala}\nIs Target: ${isTarget}\nIs Target Web: ${isTargetWeb}`,
20+
`File: ${name}\nIs Binding Scala: ${isBindingScala}\nIs Target: ${isTarget}\nIs Target Web: ${isTargetWeb}`
2121
);
2222

2323
if (isTarget) {
@@ -72,15 +72,10 @@ function copyFolderRecursiveSync(sourcePath, destinationPath) {
7272
*/
7373
function processDirectories() {
7474
const directories = fs.readdirSync(".");
75-
const nonHiddenDirectories = directories.filter(
76-
(directory) => !directory.startsWith("."),
77-
);
75+
const nonHiddenDirectories = directories.filter((directory) => !directory.startsWith("."));
7876

7977
for (const directory of nonHiddenDirectories) {
80-
if (
81-
fs.statSync(directory).isDirectory() &&
82-
!rootExclude.includes(directory)
83-
) {
78+
if (fs.statSync(directory).isDirectory() && !rootExclude.includes(directory)) {
8479
const dirPath = path.join("dist", directory);
8580
console.log(dirPath);
8681
fs.mkdirSync(dirPath);
@@ -97,10 +92,7 @@ function copyProjectToDist() {
9792
fs.rmSync("dist", { force: true, recursive: true });
9893
fs.mkdirSync(path.join("dist", "webdriver-ts"), { recursive: true });
9994

100-
fs.copyFileSync(
101-
path.join("webdriver-ts", "table.html"),
102-
path.join("dist", "webdriver-ts", "table.html"),
103-
);
95+
fs.copyFileSync(path.join("webdriver-ts", "table.html"), path.join("dist", "webdriver-ts", "table.html"));
10496
fs.copyFileSync("index.html", path.join("dist", "index.html"));
10597

10698
processDirectories();

cli/update-lockfiles.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ function getPackageLockJSONVersion(packageLockJSONPath) {
4949
* @param {number} latestLockfileVersion
5050
* @param {string} frameworkDirPath
5151
*/
52-
function updateFrameworkLockfile(
53-
framework,
54-
latestLockfileVersion,
55-
frameworkDirPath,
56-
) {
52+
function updateFrameworkLockfile(framework, latestLockfileVersion, frameworkDirPath) {
5753
const { name, type } = framework;
5854

5955
console.log(`Checking ${type} ${name} lockfile`);
@@ -85,11 +81,7 @@ function updateLockfilesOfAllFrameworks(options) {
8581
const frameworks = getFrameworks(frameworksDirPath, frameworksTypes);
8682

8783
for (const framework of frameworks) {
88-
updateFrameworkLockfile(
89-
framework,
90-
latestLockfileVersion,
91-
frameworksDirPath,
92-
);
84+
updateFrameworkLockfile(framework, latestLockfileVersion, frameworksDirPath);
9385
}
9486
}
9587

cli/zip.js

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,26 @@ function addLocalFileIfExists(sourcePath, zipPath) {
3535
* @param {string} frameworkName
3636
*/
3737
function addFrameworksToZip(frameworkType, frameworkDir, frameworkName) {
38-
const zipFrameworkPath = path.join(
39-
"frameworks",
40-
frameworkType,
41-
frameworkName,
42-
);
38+
const zipFrameworkPath = path.join("frameworks", frameworkType, frameworkName);
4339

44-
addLocalFileIfExists(
45-
`${frameworkDir}/package-lock.json`,
46-
`${zipFrameworkPath}`,
47-
);
40+
addLocalFileIfExists(`${frameworkDir}/package-lock.json`, `${zipFrameworkPath}`);
4841

4942
addLocalFolderIfExists(`${frameworkDir}/dist`, `${zipFrameworkPath}/dist`);
50-
addLocalFolderIfExists(
51-
`${frameworkDir}/scripts`,
52-
`${zipFrameworkPath}/scripts`,
53-
);
54-
addLocalFolderIfExists(
55-
`${frameworkDir}/node_modules/slim-js/dist`,
56-
`${zipFrameworkPath}/node_modules/slim-js/dist`,
57-
);
43+
addLocalFolderIfExists(`${frameworkDir}/scripts`, `${zipFrameworkPath}/scripts`);
44+
addLocalFolderIfExists(`${frameworkDir}/node_modules/slim-js/dist`, `${zipFrameworkPath}/node_modules/slim-js/dist`);
5845
addLocalFolderIfExists(
5946
`${frameworkDir}/node_modules/@neow/core/dist`,
60-
`${zipFrameworkPath}/node_modules/@neow/core/dist`,
61-
);
62-
addLocalFolderIfExists(
63-
`${frameworkDir}/target/web/stage`,
64-
`${zipFrameworkPath}/target/web/stage`,
47+
`${zipFrameworkPath}/node_modules/@neow/core/dist`
6548
);
49+
addLocalFolderIfExists(`${frameworkDir}/target/web/stage`, `${zipFrameworkPath}/target/web/stage`);
6650
addLocalFolderIfExists(`${frameworkDir}/build`, `${zipFrameworkPath}/build`);
6751

6852
if (frameworkName !== "ember" && frameworkName !== "glimmer") {
69-
addLocalFolderIfExists(
70-
`${frameworkDir}/public`,
71-
`${zipFrameworkPath}/public`,
72-
);
53+
addLocalFolderIfExists(`${frameworkDir}/public`, `${zipFrameworkPath}/public`);
7354
}
7455

7556
if (frameworkName === "halogen") {
76-
addLocalFileIfExists(
77-
`${frameworkDir}/output/bundle.js`,
78-
`${zipFrameworkPath}/output`,
79-
);
57+
addLocalFileIfExists(`${frameworkDir}/output/bundle.js`, `${zipFrameworkPath}/output`);
8058
} else if (frameworkName === "dojo") {
8159
addLocalFolderIfExists(
8260
`${frameworkDir}/output/dist`,
@@ -90,17 +68,11 @@ function addFrameworksToZip(frameworkType, frameworkDir, frameworkName) {
9068
} else if (frameworkName === "stem") {
9169
addLocalFolderIfExists(
9270
`${frameworkDir}/node_modules/babel-polyfill/dist`,
93-
`${zipFrameworkPath}/node_modules/babel-polyfill/dist`,
94-
);
95-
addLocalFileIfExists(
96-
`${frameworkDir}/src/bundle.js`,
97-
`${zipFrameworkPath}/src`,
71+
`${zipFrameworkPath}/node_modules/babel-polyfill/dist`
9872
);
73+
addLocalFileIfExists(`${frameworkDir}/src/bundle.js`, `${zipFrameworkPath}/src`);
9974
} else {
100-
addLocalFolderIfExists(
101-
`${frameworkDir}/output`,
102-
`${zipFrameworkPath}/output`,
103-
);
75+
addLocalFolderIfExists(`${frameworkDir}/output`, `${zipFrameworkPath}/output`);
10476
}
10577
}
10678

package-lock.json

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
"homepage": "https://github.com/krausest/js-framework-benchmark",
4444
"dependencies": {
4545
"adm-zip": "^0.5.10",
46-
"commander": "^11.0.0",
46+
"commander": "^11.1.0",
4747
"cross-env": "^7.0.3",
48+
"es-main": "^1.3.0",
4849
"eslint-plugin-unicorn": "^49.0.0",
4950
"json5": "^2.2.3",
5051
"rimraf": "^5.0.5",

0 commit comments

Comments
 (0)