Add possibility to specify port when running dep graph (#3938)

* feat(misc): add possibility to specify port when running dep graph

* feat(docs): documentation was updated with the exposed port

Co-authored-by: adrian.etter <adrian.etter@dswiss.com>
This commit is contained in:
Adrian 2020-10-30 19:09:35 +01:00 committed by GitHub
parent da4fe07c47
commit 992013ca0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 5 deletions

View File

@ -102,6 +102,10 @@ Default: `false`
Isolate projects which previously failed
### port
Bind the dep graph server to a specific port.
### runner
This is the name of the tasks runner configured in nx.json

View File

@ -80,6 +80,10 @@ Show help
Bind the dep graph server to a specific ip address.
### port
Bind the dep graph server to a specific port.
### version
Show version number

View File

@ -102,6 +102,10 @@ Default: `false`
Isolate projects which previously failed
### port
Bind the dep graph server to a specific port.
### runner
This is the name of the tasks runner configured in nx.json

View File

@ -80,6 +80,10 @@ Show help
Bind the dep graph server to a specific ip address.
### port
Bind the dep graph server to a specific port.
### version
Show version number

View File

@ -102,6 +102,10 @@ Default: `false`
Isolate projects which previously failed
### port
Bind the dep graph server to a specific port.
### runner
This is the name of the tasks runner configured in nx.json

View File

@ -80,6 +80,10 @@ Show help
Bind the dep graph server to a specific ip address.
### port
Bind the dep graph server to a specific port.
### version
Show version number

View File

@ -143,6 +143,7 @@ export function generateGraph(
args: {
file?: string;
host?: string;
port?: number;
focus?: string;
exclude?: string[];
groupByFolder?: boolean;
@ -265,11 +266,11 @@ export function generateGraph(
process.exit(1);
}
} else {
startServer(html, args.host || '127.0.0.1');
startServer(html, args.host || '127.0.0.1', args.port || 4211);
}
}
function startServer(html: string, host: string) {
function startServer(html: string, host: string, port = 4211) {
const app = http.createServer((req, res) => {
// parse URL
const parsedUrl = url.parse(req.url);
@ -316,13 +317,13 @@ function startServer(html: string, host: string) {
});
});
app.listen(4211, host);
app.listen(port, host);
output.note({
title: `Dep graph started at http://${host}:4211`,
title: `Dep graph started at http://${host}:${port}`,
});
opn(`http://${host}:4211`, {
opn(`http://${host}:${port}`, {
wait: false,
});
}

View File

@ -361,6 +361,10 @@ function withDepGraphOptions(yargs: yargs.Argv): yargs.Argv {
.option('host', {
describe: 'Bind the dep graph server to a specific ip address.',
type: 'string',
})
.option('port', {
describe: 'Bind the dep graph server to a specific port.',
type: 'number',
});
}