Skip to content

Commit

Permalink
feat(skott): add JSON static file generation
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-coulon committed Oct 21, 2022
1 parent ee57cf6 commit 490fb9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -26,12 +26,10 @@

✅ Node.js binary and JSON modules are excluded by default

✅ Generate [mermaid-js](https://github.com/mermaid-js/mermaid) diagrams (.svg, .png, .md) representing your project's graph directly from the CLI.
✅ Generate static files including raw JSON, [mermaid-js](https://github.com/mermaid-js/mermaid) diagrams (.svg, .png, .md) representing your project's graph directly generated from the CLI.

Work in progress includes:

🛠 Allow JSX/TSX to be supported

🛠 Expose graph metrics for file nodes such as _how many times_ this dependency is used through the project

🛠 Monorepos/Workspaces support to build cross project graphs
Expand Down
11 changes: 10 additions & 1 deletion packages/skott/bin/main.ts
@@ -1,3 +1,4 @@
import { writeFile } from "node:fs/promises";
import path from "node:path";
import { performance } from "node:perf_hooks";

Expand Down Expand Up @@ -119,12 +120,20 @@ async function generateStaticFile(
[key]: val.adjacentTo
};
}, {});
const spinner = ora("Generating static file").start();

if (staticFile === "json") {
await writeFile(
path.join(process.cwd(), "skott.json"),
JSON.stringify(graph, null, 2),
"utf-8"
);
}

const mermaid = generateMermaid(rawGraph, process.cwd(), {
orientation: "TB"
});

const spinner = ora("Generating static file").start();
spinner.color = "magenta";

if (staticFile === "svg") {
Expand Down

0 comments on commit 490fb9d

Please sign in to comment.