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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-heatmap",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "AI usage cost heatmap powered by ccusage + react-activity-calendar",
5
5
  "type": "module",
6
6
  "bin": {
@@ -148,16 +148,25 @@ ${DAY_NAMES.map((name, i) => {
148
148
 
149
149
  // --- Main ---
150
150
 
151
- const configPath = resolve(root, "heatmap.config.json");
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
- : defaults;
159
-
160
- let data = JSON.parse(readFileSync(resolve(root, "public/data.json"), "utf-8"));
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(root, "public/heatmap.svg");
180
+ const outPath = resolve(cwd, "public/heatmap.svg");
172
181
  writeFileSync(outPath, svg);
173
182
  console.log(`Generated ${outPath}`);