Skip to content

Commit 7e5083d

Browse files
author
repo-visualizer
committed
add max_depth parameter
1 parent c65c4d0 commit 7e5083d

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ For example: dist,node_modules
2424

2525
Default: node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.vscode,package-lock.json,yarn.lock
2626

27+
## `max_depth`
28+
29+
The maximum number of nested folders to show files within. A higher number will take longer to render.
30+
31+
Default: 5
32+
2733
## Example usage
2834

2935
You'll need to run the `actions/checkout` Action beforehand, to check out the code.
@@ -34,6 +40,7 @@ You'll need to run the `actions/checkout` Action beforehand, to check out the co
3440
- name: Update diagram
3541
uses: githubocto/repo-visualizer@main
3642
with:
37-
output_file: 'images/diagram.svg'
38-
excluded_paths: 'dist,node_modules'
43+
output_file: "images/diagram.svg"
44+
excluded_paths: "dist,node_modules"
45+
max_depth: 9
3946
```

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
excluded_paths:
99
description: "A list of paths to exclude from the diagram, separated by commas. For example: dist,node_modules"
1010
required: false
11+
max_depth:
12+
description: "The maximum number of nested folders to show files within. Default: 9"
13+
required: false
1114
runs:
1215
using: "node12"
1316
main: "index.js"

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16678,8 +16678,7 @@ var colorTheme = "file";
1667816678
var looseFilesId = "__structure_loose_file__";
1667916679
var width = 1e3;
1668016680
var height = 1e3;
16681-
var maxDepth = 9;
16682-
var Tree = ({ data, filesChanged = [] }) => {
16681+
var Tree = ({ data, filesChanged = [], maxDepth = 9 }) => {
1668316682
const [selectedNodeId, setSelectedNodeId] = (0, import_react2.useState)(null);
1668416683
const cachedPositions = (0, import_react2.useRef)({});
1668516684
const cachedOrders = (0, import_react2.useRef)({});
@@ -17170,11 +17169,13 @@ var main = async () => {
1717017169
`${username}@users.noreply.github.com`
1717117170
]);
1717217171
core.endGroup();
17172+
const maxDepth = core.getInput("max_depth") || 9;
1717317173
const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock";
1717417174
const excludedPaths = excludedPathsString.split(",").map((str) => str.trim());
1717517175
const data = await processDir(`./`, excludedPaths);
1717617176
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
17177-
data
17177+
data,
17178+
maxDepth: +maxDepth
1717817179
}));
1717917180
const outputFile = core.getInput("output_file") || "./diagram.svg";
1718017181
await import_fs2.default.writeFileSync(outputFile, componentCodeString);

src/Tree.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ const colorTheme = "file";
5151
const looseFilesId = "__structure_loose_file__";
5252
const width = 1000;
5353
const height = 1000;
54-
const maxDepth = 9;
55-
export const Tree = ({ data, filesChanged = [] }: Props) => {
54+
export const Tree = ({ data, filesChanged = [], maxDepth = 9 }: Props) => {
5655
const [selectedNodeId, setSelectedNodeId] = useState(null);
5756
const cachedPositions = useRef<{ [key: string]: [number, number] }>({});
5857
const cachedOrders = useRef<{ [key: string]: string[] }>({});

src/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ const main = async () => {
2222
core.endGroup()
2323

2424

25+
const maxDepth = core.getInput("max_depth") || 9
2526
const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock"
2627
const excludedPaths = excludedPathsString.split(",").map(str => str.trim())
2728
const data = await processDir(`./`, excludedPaths);
2829

2930
const componentCodeString = ReactDOMServer.renderToStaticMarkup(
30-
<Tree data={data} />
31+
<Tree data={data} maxDepth={+maxDepth} />
3132
);
3233

3334
const outputFile = core.getInput("output_file") || "./diagram.svg"

0 commit comments

Comments
 (0)