feat(core): adds host binding option to dep-graph command

This commit is contained in:
Bradley Zeggelaar 2020-02-13 11:00:16 +01:00 committed by Victor Savkin
parent 413dce9e6f
commit 4d8b38b7ce
8 changed files with 41 additions and 6 deletions

View File

@ -76,6 +76,10 @@ Latest commit of the current branch (usually HEAD)
Show help
### host
Bind the dep graph server to a specific ip address.
### only-failed
Default: `false`

View File

@ -54,6 +54,10 @@ Use to limit the dependency graph to only show specific projects, list of projec
Show help
### host
Bind the dep graph server to a specific ip address.
### version
Show version number

View File

@ -76,6 +76,10 @@ Latest commit of the current branch (usually HEAD)
Show help
### host
Bind the dep graph server to a specific ip address.
### only-failed
Default: `false`

View File

@ -54,6 +54,10 @@ Use to limit the dependency graph to only show specific projects, list of projec
Show help
### host
Bind the dep graph server to a specific ip address.
### version
Show version number

View File

@ -76,6 +76,10 @@ Latest commit of the current branch (usually HEAD)
Show help
### host
Bind the dep graph server to a specific ip address.
### only-failed
Default: `false`

View File

@ -54,6 +54,10 @@ Use to limit the dependency graph to only show specific projects, list of projec
Show help
### host
Bind the dep graph server to a specific ip address.
### version
Show version number

View File

@ -30,7 +30,7 @@ const mimeType = {
};
export function generateGraph(
args: { file?: string; filter?: string[]; exclude?: string[] },
args: { file?: string; filter?: string[]; exclude?: string[]; host?: string },
affectedProjects: string[]
): void {
const graph = onlyWorkspaceProjects(createProjectGraph());
@ -55,14 +55,20 @@ export function generateGraph(
)
);
} else {
startServer(renderProjects, graph, affectedProjects);
startServer(
renderProjects,
graph,
affectedProjects,
args.host || '127.0.0.1'
);
}
}
function startServer(
projects: ProjectGraphNode[],
graph: ProjectGraph,
affected: string[]
affected: string[],
host: string
) {
const f = readFileSync(
join(__dirname, '../core/dep-graph/dep-graph.html')
@ -124,12 +130,13 @@ function startServer(
});
});
app.listen(4211, '127.0.0.1');
app.listen(4211, host);
output.note({
title: 'Dep graph started at http://localhost:4211'
title: `Dep graph started at http://${host}:4211`
});
opn('http://localhost:4211', {
opn(`http://${host}:4211`, {
wait: false
});
}

View File

@ -332,6 +332,10 @@ function withDepGraphOptions(yargs: yargs.Argv): yargs.Argv {
'List of projects delimited by commas to exclude from the dependency graph.',
type: 'array',
coerce: parseCSV
})
.option('host', {
describe: 'Bind the dep graph server to a specific ip address.',
type: 'string'
});
}