Skip to content

Commit

Permalink
feat(schematics): make dep-graph export to svg
Browse files Browse the repository at this point in the history
This enables to export the dependency graph into a `svg` file. It was shown in the documentation but
not quite ready yet.

fix #811
  • Loading branch information
bcabanes authored and vsavkin committed Oct 18, 2018
1 parent 0295996 commit 15b8e4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/schematics/src/command-line/dep-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export type CriticalPathMap = {
export enum OutputType {
'json' = 'json',
'html' = 'html',
'dot' = 'dot'
'dot' = 'dot',
'svg' = 'svg'
}

export interface UserOptions extends yargs.Arguments {
Expand Down Expand Up @@ -339,6 +340,8 @@ function extractDataFromJson(json, type) {
return getDot(json);
case OutputType.html:
return applyHTMLTemplate(viz(getDot(json)));
case OutputType.svg:
return viz(getDot(json));
default:
throw new Error(
'Unrecognized file extension. Supported extensions are "json", "html", and "dot"'
Expand Down
7 changes: 6 additions & 1 deletion packages/schematics/src/command-line/nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ function withAffectedOptions(yargs: yargs.Argv): yargs.Argv {
function withDepGraphOptions(yargs: yargs.Argv): yargs.Argv {
return yargs
.describe('file', 'output file (e.g. --file=.vis/output.json)')
.choices('output', [OutputType.json, OutputType.dot, OutputType.html]);
.choices('output', [
OutputType.json,
OutputType.dot,
OutputType.html,
OutputType.svg
]);
}

function parseCSV(args: string[]) {
Expand Down

0 comments on commit 15b8e4b

Please sign in to comment.