-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·77 lines (62 loc) · 1.98 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
const { EOL } = require("os");
const path = require("path");
const config = require("./config");
const CLI = require("./lib/cli");
const { SUCCESS, ERROR, INFO } = require("./lib/cli/status");
const npm = require("./lib/npm");
const sourceFiles = require("./lib/source-files");
const checks = require("./lib/checks");
const docs = require("./lib/docs");
const targetList = require("./lib/target-list");
const cli = new CLI();
// Clear terminal and display the banner.
cli.clear();
cli.displayBanner();
const run = async () => {
const checkRepoMessage = `Checking if you are in a ${
config.repositoryName
} benchmark repository...`;
cli.startSpinner(checkRepoMessage);
if (!checks.isWebToolingBenchmark()) {
cli.persist(
"It seems that you are not in the correct repository. " +
`Please, go to your ${config.repositoryName} clone.${EOL}`,
ERROR
);
process.exit(1);
}
cli.persist(checkRepoMessage, SUCCESS);
const { library } = await cli.ask();
const checkBenchmarkMessage =
"Checking if a benchmark for this library doesn't exist...";
cli.startSpinner(checkBenchmarkMessage);
if (checks.isAlreadyABenchmark(library)) {
cli.persist(
"It seems that there is already a benchmark for this library.",
ERROR
);
process.exit(1);
}
cli.persist(checkBenchmarkMessage, SUCCESS);
// Install dependency.
npm.install(library, cli);
// Create source files.
await sourceFiles.createBenchmarkFile(library, cli);
await sourceFiles.createBenchmarkTestFile(library, cli);
// Update docs.
await docs.createNewSection(library, cli);
// Update target list.
await targetList.addLibrary(library, cli);
// Info about third_party assets.
cli.write(
`Don't forget to put any assets used by the benchmark into the ${
config.thirdPartyFolder
} folder and hook them up with the virtual file system in ${path.join(
config.sourcePath,
config.vfsFilename
)}.`,
INFO
);
};
run();