@@ -25814,7 +25814,8 @@ var numberOfCommitsAccessor = (d2) => {
25814
25814
var _a;
25815
25815
return ((_a = d2 == null ? void 0 : d2.commits) == null ? void 0 : _a.length) || 0;
25816
25816
};
25817
- var Tree = ({ data, filesChanged = [], maxDepth = 9, colorEncoding = "type" }) => {
25817
+ var Tree = ({ data, filesChanged = [], maxDepth = 9, colorEncoding = "type", customizeFileColors }) => {
25818
+ const fileColors = { ...language_colors_default, ...customizeFileColors };
25818
25819
const [selectedNodeId, setSelectedNodeId] = (0, import_react2.useState)(null);
25819
25820
const cachedPositions = (0, import_react2.useRef)({});
25820
25821
const cachedOrders = (0, import_react2.useRef)({});
@@ -25845,9 +25846,9 @@ var Tree = ({ data, filesChanged = [], maxDepth = 9, colorEncoding = "type" }) =
25845
25846
if (isParent) {
25846
25847
const extensions = (0, import_countBy.default)(d2.children, (c3) => c3.extension);
25847
25848
const mainExtension = (_a = (0, import_maxBy.default)((0, import_entries.default)(extensions), ([k, v2]) => v2)) == null ? void 0 : _a[0];
25848
- returnlanguage_colors_default [mainExtension] || "#CED6E0";
25849
+ returnfileColors [mainExtension] || "#CED6E0";
25849
25850
}
25850
- returnlanguage_colors_default [d2.extension] || "#CED6E0";
25851
+ returnfileColors [d2.extension] || "#CED6E0";
25851
25852
} else if (colorEncoding === "number-of-changes") {
25852
25853
return colorScale(numberOfCommitsAccessor(d2)) || "#f4f4f4";
25853
25854
} else if (colorEncoding === "last-change") {
@@ -25857,7 +25858,7 @@ var Tree = ({ data, filesChanged = [], maxDepth = 9, colorEncoding = "type" }) =
25857
25858
const packedData = (0, import_react2.useMemo)(() => {
25858
25859
if (!data)
25859
25860
return [];
25860
- const hierarchicalData = hierarchy(processChild(data, getColor, cachedOrders.current)).sum((d2) => d2.value).sort((a2, b) => {
25861
+ const hierarchicalData = hierarchy(processChild(data, getColor, cachedOrders.current, 0, fileColors )).sum((d2) => d2.value).sort((a2, b) => {
25861
25862
if (b.data.path.startsWith("src/fonts")) {
25862
25863
}
25863
25864
return b.data.sortOrder - a2.data.sortOrder || (b.data.name > a2.data.name ? 1 : -1);
@@ -25888,9 +25889,9 @@ var Tree = ({ data, filesChanged = [], maxDepth = 9, colorEncoding = "type" }) =
25888
25889
cachedPositions.current[d2.data.path] = [d2.x, d2.y];
25889
25890
});
25890
25891
return children2.slice(0, maxChildren);
25891
- }, [data]);
25892
+ }, [data, fileColors ]);
25892
25893
const selectedNode = selectedNodeId && packedData.find((d2) => d2.data.path === selectedNodeId);
25893
- const fileTypes = (0, import_uniqBy.default)(packedData.map((d2) =>language_colors_default [d2.data.extension] && d2.data.extension)).sort().filter(Boolean);
25894
+ const fileTypes = (0, import_uniqBy.default)(packedData.map((d2) =>fileColors [d2.data.extension] && d2.data.extension)).sort().filter(Boolean);
25894
25895
return /* @__PURE__ */ import_react2.default.createElement("svg", {
25895
25896
width,
25896
25897
height,
@@ -26047,7 +26048,8 @@ var Tree = ({ data, filesChanged = [], maxDepth = 9, colorEncoding = "type" }) =
26047
26048
dominantBaseline: "middle"
26048
26049
}, label));
26049
26050
}), !filesChanged.length && colorEncoding === "type" && /* @__PURE__ */ import_react2.default.createElement(Legend, {
26050
- fileTypes
26051
+ fileTypes,
26052
+ fileColors
26051
26053
}), !filesChanged.length && colorEncoding !== "type" && /* @__PURE__ */ import_react2.default.createElement(ColorLegend, {
26052
26054
scale: colorScale,
26053
26055
extent: colorExtent,
@@ -26088,15 +26090,15 @@ var ColorLegend = ({ scale, extent, colorEncoding }) => {
26088
26090
textAnchor: i ? "end" : "start"
26089
26091
}, formatD(d2))));
26090
26092
};
26091
- var Legend = ({ fileTypes = [] }) => {
26093
+ var Legend = ({ fileTypes = [], fileColors }) => {
26092
26094
return /* @__PURE__ */ import_react2.default.createElement("g", {
26093
26095
transform: `translate(${width - 60}, ${height - fileTypes.length * 15 - 20})`
26094
26096
}, fileTypes.map((extension, i) => /* @__PURE__ */ import_react2.default.createElement("g", {
26095
26097
key: i,
26096
26098
transform: `translate(0, ${i * 15})`
26097
26099
}, /* @__PURE__ */ import_react2.default.createElement("circle", {
26098
26100
r: "5",
26099
- fill:language_colors_default [extension]
26101
+ fill:fileColors [extension]
26100
26102
}), /* @__PURE__ */ import_react2.default.createElement("text", {
26101
26103
x: "10",
26102
26104
style: { fontSize: "14px", fontWeight: 300 },
@@ -26110,22 +26112,22 @@ var Legend = ({ fileTypes = [] }) => {
26110
26112
}
26111
26113
}, "each dot sized by file size"));
26112
26114
};
26113
- var processChild = (child, getColor, cachedOrders, i = 0) => {
26115
+ var processChild = (child, getColor, cachedOrders, i = 0, fileColors ) => {
26114
26116
var _a;
26115
26117
if (!child)
26116
26118
return;
26117
26119
const isRoot = !child.path;
26118
26120
let name = child.name;
26119
26121
let path = child.path;
26120
- let children2 = (_a = child == null ? void 0 : child.children) == null ? void 0 : _a.map((c3, i2) => processChild(c3, getColor, cachedOrders, i2));
26122
+ let children2 = (_a = child == null ? void 0 : child.children) == null ? void 0 : _a.map((c3, i2) => processChild(c3, getColor, cachedOrders, i2, fileColors ));
26121
26123
if ((children2 == null ? void 0 : children2.length) === 1) {
26122
26124
name = `${name}/${children2[0].name}`;
26123
26125
path = children2[0].path;
26124
26126
children2 = children2[0].children;
26125
26127
}
26126
26128
const pathWithoutExtension = path == null ? void 0 : path.split(".").slice(0, -1).join(".");
26127
26129
const extension = name == null ? void 0 : name.split(".").slice(-1)[0];
26128
- const hasExtension = !!language_colors_default [extension];
26130
+ const hasExtension = !!fileColors [extension];
26129
26131
if (isRoot && children2) {
26130
26132
const looseChildren = children2 == null ? void 0 : children2.filter((d2) => {
26131
26133
var _a2;
@@ -26271,6 +26273,7 @@ var main = async () => {
26271
26273
core.endGroup();
26272
26274
const rootPath = core.getInput("root_path") || "";
26273
26275
const maxDepth = core.getInput("max_depth") || 9;
26276
+ const customizeFileColors = JSON.parse(core.getInput("customize_file_colors") || "{}");
26274
26277
const colorEncoding = core.getInput("color_encoding") || "type";
26275
26278
const commitMessage = core.getInput("commit_message") || "Repo visualizer: updated diagram";
26276
26279
const excludedPathsString = core.getInput("excluded_paths") || "node_modules,bower_components,dist,out,build,eject,.next,.netlify,.yarn,.git,.vscode,package-lock.json,yarn.lock";
@@ -26282,7 +26285,8 @@ var main = async () => {
26282
26285
const componentCodeString = import_server.default.renderToStaticMarkup(/* @__PURE__ */ import_react3.default.createElement(Tree, {
26283
26286
data,
26284
26287
maxDepth: +maxDepth,
26285
- colorEncoding
26288
+ colorEncoding,
26289
+ customizeFileColors
26286
26290
}));
26287
26291
const outputFile = core.getInput("output_file") || "./diagram.svg";
26288
26292
core.setOutput("svg", componentCodeString);