Skip to content

Commit 2534762

Browse files
committed
merge
2 parents 4726684 + 9b56f99 commit 2534762

19 files changed

+1944
-1875
lines changed

bin/URLWatcher.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# difference in speed if stream = True vs. False; Most
1414
# time spent on d/l.
1515
stream = True
16-
1716
ROOT = 'https://hapi-server.org/urlwatcher/'
1817
#ROOT = 'http://localhost:4444/'
1918

etc/hapi-server-dev.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ APPDIR=.
99
$APPDIR/server.js \
1010
--port 8998 \
1111
--ignore \
12-
--server-ui-include https://hapi-server.org/all_.txt \
12+
--server-ui-include https://hapi-server.org/dev.txt \
1313
--proxy-whitelist etc/proxy-whitelist.txt \
1414
-f $APPDIR/metadata/TestData2.0.json \
1515
-f $APPDIR/metadata/TestData2.1.json \

lib/cli.js

+105-100
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,177 @@
1-
const fs = require('fs');
1+
const fs = require('fs')
2+
const path = require('path')
23

3-
let usage = "node server.js";
4+
let usage = 'node server.js'
45
if (/server$/.test(process.execPath)) {
56
// Binary executable called.
6-
usage = "server";
7+
usage = 'server'
78
}
89

9-
checkNodeJSVersion();
10+
checkNodeJSVersion()
1011

11-
module.exports.argv = readCommandLine();
12+
module.exports.argv = readCommandLine()
1213

13-
function readCommandLine() {
14-
15-
let argv = require('yargs')
14+
function readCommandLine () {
15+
const argv = require('yargs')
1616
.strict()
1717
.help()
1818
.option('file', {
19-
'description': 'Catalog configuration file or file pattern',
20-
'type': 'string',
21-
'default': require("path").normalize(__dirname + '/../metadata/TestData2.0.json'),
22-
'alias': 'f'
19+
description: 'Catalog configuration file or file pattern',
20+
type: 'string',
21+
default: path.normalize(path.join(__dirname, '..', 'metadata', 'TestData2.0.json')),
22+
alias: 'f'
2323
})
2424
.option('port', {
25-
'description': 'Server port',
26-
'default': 8999,
27-
'type': 'number',
28-
'alias': 'p'
25+
description: 'Server port',
26+
default: 8999,
27+
type: 'number',
28+
alias: 'p'
2929
})
3030
.option('conf', {
31-
'description': 'Server configuration file',
32-
'default': require("path").normalize(__dirname + '/../conf/server.json'),
33-
'type': 'string',
34-
'alias': 'c'
31+
description: 'Server configuration file',
32+
default: path.normalize(path.join(__dirname, '..', 'conf', 'server.json')),
33+
type: 'string',
34+
alias: 'c'
35+
})
36+
.option('force', {
37+
description: 'Start server even if test or metadata generation fails.',
38+
type: 'boolean',
39+
alias: 'i'
3540
})
3641
.option('ignore', {
37-
'description': 'Start server even if metadata validation errors',
38-
'type': 'boolean',
39-
'alias': 'i'
42+
description: 'Start server even if metadata validation errors',
43+
type: 'boolean',
44+
alias: 'i'
4045
})
4146
.option('skipchecks', {
42-
'description': 'Skip startup metadata validation and command line tests',
43-
'default': false,
44-
'type': 'boolean',
45-
'alias': 's'
47+
description: 'Skip startup metadata validation and command line tests',
48+
default: false,
49+
type: 'boolean',
50+
alias: 's'
4651
})
4752
.option('logdir', {
48-
'description': 'Log directory',
49-
'default': require("path").normalize(__dirname + "/../log"),
50-
'type': 'string',
51-
'alias': 'l'
53+
description: 'Log directory',
54+
default: path.normalize(path.join(__dirname, '..', 'log')),
55+
type: 'string',
56+
alias: 'l'
5257
})
5358
.option('open', {
54-
'description': 'Open web page on start',
55-
'default': false,
56-
'type': 'boolean',
57-
'alias': 'o'
59+
description: 'Open web page on start',
60+
default: false,
61+
type: 'boolean',
62+
alias: 'o'
5863
})
5964
.option('test', {
60-
'description': 'Run URL tests and exit',
61-
'default': false,
62-
'type': 'boolean',
63-
'alias': 't'
65+
description: 'Run URL tests and exit',
66+
default: false,
67+
type: 'boolean',
68+
alias: 't'
6469
})
6570
.option('verify', {
66-
'description': 'Run verification tests on command line and exit',
67-
'default': false,
68-
'type': 'boolean'
71+
description: 'Run verification tests on command line and exit',
72+
default: false,
73+
type: 'boolean'
6974
})
7075
.option('loglevel', {
71-
'description': 'none, info, or debug',
72-
'default': 'info',
73-
'type': 'string'
76+
description: 'none, info, or debug',
77+
default: 'info',
78+
type: 'string'
7479
})
7580
.option('debug', {
76-
'description': "set loglevel to 'debug'",
77-
'default': false,
78-
'type': 'boolean'
81+
description: "set loglevel to 'debug'",
82+
default: false,
83+
type: 'boolean'
7984
})
8085
.option('server-ui-include', {
81-
'description': 'Also include these servers in server-ui server drop-down. Use multiple times for more than one list.',
82-
'default': null,
83-
'type': 'string'
86+
description: 'Also include these servers in server-ui server drop-down. Use multiple times for more than one list.',
87+
default: null,
88+
type: 'string'
8489
})
8590
.option('proxy-whitelist', {
86-
'description': 'Allow proxying of servers in this file (so one can use server=http://... in address bar of server-ui).',
87-
'default': '',
88-
'type': 'string'
91+
description: 'Allow proxying of servers in this file (so one can use server=http://... in address bar of server-ui).',
92+
default: '',
93+
type: 'string'
8994
})
9095
.option('verifier', {
91-
'description': 'Verifier server URL on landing page (__VERIFIER__ in html is replaced with this value)',
92-
'default': 'http://hapi-server.org/verify/',
93-
'type': 'string'
96+
description: 'Verifier server URL on landing page (__VERIFIER__ in html is replaced with this value)',
97+
default: 'http://hapi-server.org/verify/',
98+
type: 'string'
9499
})
95100
.option('plotserver', {
96-
'description': 'Plot server URL on landing page (__PLOTSERVER__ in html is replaced with this value)',
97-
'default': 'http://hapi-server.org/plot/',
98-
'type': 'string'
101+
description: 'Plot server URL on landing page (__PLOTSERVER__ in html is replaced with this value)',
102+
default: 'http://hapi-server.org/plot/',
103+
type: 'string'
99104
})
100105
.option('hapiserverpath', {
101-
'description': 'Absolute path to use for $HAPISERVERPATH in server metadata files',
102-
'default': require("path").normalize(__dirname + "/.."),
103-
'type': 'string'
106+
description: 'Absolute path to use for $HAPISERVERPATH in server metadata files',
107+
default: path.normalize(path.join(__dirname, '..')),
108+
type: 'string'
104109
})
105110
.option('nodejs', {
106-
'description': 'Location of NodeJS binary to use for $NODEJSEXE in server metadata files (if needed for command line calls).',
107-
'default': process.execPath,
108-
'type': 'string'
111+
description: 'Location of NodeJS binary to use for $NODEJSEXE in server metadata files (if needed for command line calls).',
112+
default: process.execPath,
113+
type: 'string'
109114
})
110115
.option('python', {
111-
'description': 'Location of Python binary to use for $PYTHONEXE in server metadata files (if needed for command line calls).',
112-
'type': 'string'
116+
description: 'Location of Python binary to use for $PYTHONEXE in server metadata files (if needed for command line calls).',
117+
type: 'string'
113118
})
114119
.option('https', {
115-
'description': 'Start https server',
116-
'type': 'boolean'
120+
description: 'Start https server',
121+
type: 'boolean'
117122
})
118123
.option('cert', {
119-
'description': 'https certificate file path',
120-
'type': 'string'
124+
description: 'https certificate file path',
125+
type: 'string'
121126
})
122127
.option('key', {
123-
'description': 'https key file path',
124-
'type': 'string'
128+
description: 'https key file path',
129+
type: 'string'
125130
})
126-
.epilog("For more details, see README at https://github.com/hapi-server/server-nodejs/")
131+
.epilog('For more details, see README at https://github.com/hapi-server/server-nodejs/')
127132
.usage('Usage: ' + usage + ' [options]')
128-
.argv;
133+
.argv
129134

130-
if (typeof(argv.file) == 'string') {
131-
argv.file = [argv.file];
135+
if (typeof (argv.file) === 'string') {
136+
argv.file = [argv.file]
132137
}
133138

134139
// TODO: yargs does not allow specifying that no option can be repeated with
135140
// some exception. https://github.com/yargs/yargs/issues/1318
136141
// So a check should be made here.
137142

138-
if (argv["debug"] === true) {
139-
argv["loglevel"] = "debug";
140-
delete argv["debug"];
143+
if (argv.debug === true) {
144+
argv.loglevel = 'debug'
145+
delete argv.debug
141146
}
142147

143-
if (argv["proxy-whitelist"] !== '') {
144-
if (!fs.existsSync(argv["proxy-whitelist"])) {
145-
console.error("Error: --proxy-whitelist file '" + argv["proxy-whitelist"] + "' does not exist.");
146-
process.exit(1);
148+
if (argv['proxy-whitelist'] !== '') {
149+
if (!fs.existsSync(argv['proxy-whitelist'])) {
150+
console.error("Error: --proxy-whitelist file '" + argv['proxy-whitelist'] + "' does not exist.")
151+
process.exit(1)
147152
}
148153
}
149154

150-
if (typeof argv["server-ui-include"] === 'string') {
151-
if (argv["server-ui-include"].trim() === '') {
152-
console.error("Error: --server-ui-include must be followed by a non-empty string.");
153-
process.exit(0);
155+
if (typeof argv['server-ui-include'] === 'string') {
156+
if (argv['server-ui-include'].trim() === '') {
157+
console.error('Error: --server-ui-include must be followed by a non-empty string.')
158+
process.exit(0)
154159
}
155-
argv["server-ui-include"] = [argv["server-ui-include"]];
160+
argv['server-ui-include'] = [argv['server-ui-include']]
156161
}
157162

158-
return argv;
163+
return argv
159164
}
160165

161-
function checkNodeJSVersion() {
162-
const semver = require('semver');
163-
const versionConstraint = require("../package.json").engines.node;
166+
function checkNodeJSVersion () {
167+
const semver = require('semver')
168+
const versionConstraint = require('../package.json').engines.node
164169
if (!semver.satisfies(process.version, versionConstraint)) {
165-
let msg = `Error: Node.js semantic version constraint ${versionConstraint} `
166-
+ `not satisfied. node.js -v returns ${process.version}. `
167-
+ "Consider installing https://github.com/creationix/nvm"
168-
+ ` and then 'nvm install VERSION', where VERSION satisfies constraint.\n`;
169-
console.log(msg);
170-
process.exit(1);
170+
const msg = `Error: Node.js semantic version constraint ${versionConstraint} ` +
171+
`not satisfied. node.js -v returns ${process.version}. ` +
172+
'Consider installing https://github.com/creationix/nvm' +
173+
' and then \'nvm install VERSION\', where VERSION satisfies constraint.\n'
174+
console.log(msg)
175+
process.exit(1)
171176
}
172177
}

0 commit comments

Comments
 (0)