ai-heatmap 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/generate-svg.mjs +14 -5
package/package.json
CHANGED
package/scripts/generate-svg.mjs
CHANGED
|
@@ -148,16 +148,25 @@ ${DAY_NAMES.map((name, i) => {
|
|
|
148
148
|
|
|
149
149
|
// --- Main ---
|
|
150
150
|
|
|
151
|
-
const
|
|
151
|
+
const cwd = process.cwd();
|
|
152
|
+
const configPath = resolve(cwd, "public/heatmap.config.json");
|
|
153
|
+
const fallbackConfigPath = resolve(cwd, "heatmap.config.json");
|
|
152
154
|
const defaults = {
|
|
153
155
|
colorScheme: "light", theme: "", blockSize: 16, blockMargin: 4, blockRadius: 3,
|
|
154
156
|
bg: "", textColor: "", start: "", end: "", stats: true, weekday: true,
|
|
155
157
|
};
|
|
156
158
|
const config = existsSync(configPath)
|
|
157
159
|
? { ...defaults, ...JSON.parse(readFileSync(configPath, "utf-8")) }
|
|
158
|
-
:
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
: existsSync(fallbackConfigPath)
|
|
161
|
+
? { ...defaults, ...JSON.parse(readFileSync(fallbackConfigPath, "utf-8")) }
|
|
162
|
+
: defaults;
|
|
163
|
+
|
|
164
|
+
const dataPath = resolve(cwd, "public/data.json");
|
|
165
|
+
if (!existsSync(dataPath)) {
|
|
166
|
+
console.log(`No data.json found at ${dataPath}, skipping SVG generation.`);
|
|
167
|
+
process.exit(0);
|
|
168
|
+
}
|
|
169
|
+
let data = JSON.parse(readFileSync(dataPath, "utf-8"));
|
|
161
170
|
if (config.start) data = data.filter(d => d.date >= config.start);
|
|
162
171
|
if (config.end) data = data.filter(d => d.date <= config.end);
|
|
163
172
|
|
|
@@ -168,6 +177,6 @@ const svg = buildHeatmapSVG(data, {
|
|
|
168
177
|
stats: config.stats, weekday: config.weekday,
|
|
169
178
|
});
|
|
170
179
|
|
|
171
|
-
const outPath = resolve(
|
|
180
|
+
const outPath = resolve(cwd, "public/heatmap.svg");
|
|
172
181
|
writeFileSync(outPath, svg);
|
|
173
182
|
console.log(`Generated ${outPath}`);
|