-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,258 additions
and
558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../lib/cli.js'); | ||
require('../lib/cli.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,91 @@ | ||
const program = require('caporal'); | ||
const semver = require('semver'); | ||
const config = require('./config'); | ||
const { version: packageVersion, engines } = require('./../package'); | ||
const program = require("caporal"); | ||
const semver = require("semver"); | ||
const config = require("./config"); | ||
const { version: packageVersion, engines } = require("./../package"); | ||
|
||
const appToServeMap = new Map([ | ||
['tr', 'test-runner'], | ||
['bv', 'benchmark-viewer'], | ||
["tr", "test-runner"], | ||
["bv", "benchmark-viewer"], | ||
]); | ||
const hotVersionRegExp = /^(\d{1,3}\.\d{1,3}\.\d{1,3}|latest)$/; | ||
|
||
function parseArgs() { | ||
program | ||
.version(packageVersion) | ||
.description('JavaScript performance tests for Handsontable') | ||
.command('local-server', 'Run a local server ("test-runner", "tr" or "benchmark-viewer", "bv").') | ||
.alias('ls') | ||
.argument('<app_to_serve>', 'Type of the application to serve ("test-runner" or "benchmark-viewer")', /^(test\-runner|tr|benchmark\-viewer|bv)$/, 'test-runner') | ||
.option('--hot-version <version>', 'The Handsontable <version> which will be used for running a benchmark.', hotVersionRegExp) | ||
.option('--hot-server <url>', 'The server <url> which will be used to serve Handsontable assets from.') | ||
.description("JavaScript performance tests for Handsontable") | ||
.command( | ||
"local-server", | ||
'Run a local server ("test-runner", "tr" or "benchmark-viewer", "bv").', | ||
) | ||
.alias("ls") | ||
.argument( | ||
"<app_to_serve>", | ||
'Type of the application to serve ("test-runner" or "benchmark-viewer")', | ||
/^(test\-runner|tr|benchmark\-viewer|bv)$/, | ||
"test-runner", | ||
) | ||
.option( | ||
"--hot-version <version>", | ||
"The Handsontable <version> which will be used for running a benchmark.", | ||
hotVersionRegExp, | ||
) | ||
.option( | ||
"--hot-server <url>", | ||
"The server <url> which will be used to serve Handsontable assets from.", | ||
) | ||
.action((args, options) => { | ||
require('./commands/local-server')( | ||
require("./commands/local-server")( | ||
appToServeMap.get(args.appToServe) ?? args.appToServe, | ||
parseInt(config.SERVER_PORT, 10) + 1, | ||
options | ||
options, | ||
); | ||
}) | ||
.command('run', 'Run a benchmark.') | ||
.alias('r') | ||
.option('--hot-version <version>', 'The Handsontable <version> which will be used for running a benchmark.', hotVersionRegExp) | ||
.option('--hot-server <url>', 'The server <url> which will be used to serve Handsontable assets from.') | ||
.option('--test-name <name>', 'The <name> name under which the test will be saved.') | ||
.option('--cpu-throttle-rate <number>', 'The <number> CPU throttle rate.') | ||
.command("run", "Run a benchmark.") | ||
.alias("r") | ||
.option( | ||
"--hot-version <version>", | ||
"The Handsontable <version> which will be used for running a benchmark.", | ||
hotVersionRegExp, | ||
) | ||
.option( | ||
"--hot-server <url>", | ||
"The server <url> which will be used to serve Handsontable assets from.", | ||
) | ||
.option( | ||
"--test-name <name>", | ||
"The <name> name under which the test will be saved.", | ||
) | ||
.option("--cpu-throttle-rate <number>", "The <number> CPU throttle rate.") | ||
.action(async (args, options) => { | ||
await require('./commands/local-server')('test-runner', config.SERVER_PORT, options); | ||
await require("./commands/local-server")( | ||
"test-runner", | ||
config.SERVER_PORT, | ||
options, | ||
); | ||
|
||
const statsGenerator = require('./commands/protractor')(options); | ||
const statsGenerator = require("./commands/protractor")(options); | ||
|
||
await require('./storage').saveByReplace(statsGenerator); | ||
await require("./storage").saveByReplace(statsGenerator); | ||
|
||
process.exit(0); | ||
}) | ||
; | ||
}); | ||
|
||
program.parse(process.argv); | ||
} | ||
|
||
(function main() { | ||
try { | ||
if (!semver.satisfies(process.versions.node, engines.node)) { | ||
throw Error(`The project requires Node.js${engines.node} for running. You've currently installed version ${process.versions.node}.`); | ||
throw Error( | ||
`The project requires Node.js${engines.node} for running. You've currently installed version ${process.versions.node}.`, | ||
); | ||
} | ||
|
||
parseArgs(); | ||
} catch (ex) { | ||
/* eslint-disable no-console */ | ||
console.log(ex.message); | ||
console.log(''); | ||
console.log(""); | ||
process.exit(2); | ||
} | ||
}()); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.