@towles/tool 0.0.72 → 0.0.73

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": "@towles/tool",
3
- "version": "0.0.72",
3
+ "version": "0.0.73",
4
4
  "description": "One off quality of life scripts that I use on a daily basis.",
5
5
  "homepage": "https://github.com/ChrisTowles/towles-tool#readme",
6
6
  "bugs": {
@@ -141,7 +141,7 @@ function isReviewPass(ctx: IssueContext): boolean {
141
141
 
142
142
  async function handleFailure(
143
143
  ctx: IssueContext,
144
- stepName: string,
144
+ stepName: StepName,
145
145
  comment?: string,
146
146
  exec?: ExecSafeFn,
147
147
  ): Promise<void> {
@@ -6,6 +6,11 @@ import type { BarChartData, TreemapNode } from "./types.js";
6
6
  // Load HTML template from file (resolved relative to this module)
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
  const TEMPLATE_PATH = path.join(__dirname, "..", "graph-template.html");
9
+ let _cachedTemplate: string | undefined;
10
+ function getTemplate(): string {
11
+ _cachedTemplate ??= fs.readFileSync(TEMPLATE_PATH, "utf-8");
12
+ return _cachedTemplate;
13
+ }
9
14
 
10
15
  /**
11
16
  * Generate HTML from treemap data and bar chart data using the template.
@@ -13,11 +18,8 @@ const TEMPLATE_PATH = path.join(__dirname, "..", "graph-template.html");
13
18
  export function generateTreemapHtml(data: TreemapNode, barChartData: BarChartData): string {
14
19
  const width = 1200;
15
20
  const height = 800;
16
-
17
- // Read template from file and replace placeholders
18
21
  // Use function replacement to avoid special $& $' $` patterns in data being interpreted
19
- const template = fs.readFileSync(TEMPLATE_PATH, "utf-8");
20
- return template
22
+ return getTemplate()
21
23
  .replace(/\{\{WIDTH\}\}/g, String(width))
22
24
  .replace(/\{\{HEIGHT\}\}/g, String(height))
23
25
  .replace(/\{\{DATA\}\}/g, () => JSON.stringify(data))
@@ -1,6 +1,7 @@
1
1
  import * as fs from "node:fs";
2
- import * as path from "node:path";
3
2
  import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { writeFile } from "../../utils/fs.js";
4
5
 
5
6
  export interface ClaudeSettings {
6
7
  cleanupPeriodDays?: number;
@@ -9,7 +10,7 @@ export interface ClaudeSettings {
9
10
  [key: string]: unknown;
10
11
  }
11
12
 
12
- export const CLAUDE_SETTINGS_PATH = path.join(homedir(), ".claude", "settings.json");
13
+ export const CLAUDE_SETTINGS_PATH = join(homedir(), ".claude", "settings.json");
13
14
 
14
15
  /**
15
16
  * Load Claude settings from the given path.
@@ -56,9 +57,5 @@ export function applyRecommendedSettings(settings: ClaudeSettings): {
56
57
  * creating parent directories if needed.
57
58
  */
58
59
  export function saveClaudeSettings(settingsPath: string, settings: ClaudeSettings): void {
59
- const dir = path.dirname(settingsPath);
60
- if (!fs.existsSync(dir)) {
61
- fs.mkdirSync(dir, { recursive: true });
62
- }
63
- fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
60
+ writeFile(settingsPath, JSON.stringify(settings, null, 2));
64
61
  }
@@ -1,6 +1,7 @@
1
- import { existsSync, mkdirSync } from "node:fs";
1
+ import { existsSync } from "node:fs";
2
2
  import consola from "consola";
3
3
  import { colors } from "consola/utils";
4
+ import { ensureDir } from "../../utils/fs.js";
4
5
 
5
6
  /**
6
7
  * Create journal directory if it doesn't exist
@@ -8,6 +9,6 @@ import { colors } from "consola/utils";
8
9
  export function ensureDirectoryExists(folderPath: string): void {
9
10
  if (!existsSync(folderPath)) {
10
11
  consola.info(`Creating journal directory: ${colors.cyan(folderPath)}`);
11
- mkdirSync(folderPath, { recursive: true });
12
+ ensureDir(folderPath);
12
13
  }
13
14
  }
@@ -25,7 +25,7 @@ export function resolvePathTemplate(
25
25
  date: Date,
26
26
  mondayDate: Date,
27
27
  ): string {
28
- const dateTime = DateTime.fromJSDate(date, { zone: "utc" });
28
+ const dateTime = DateTime.fromJSDate(date, { zone: "local" });
29
29
 
30
30
  // Replace Luxon format tokens wrapped in curly braces
31
31
  return template.replace(/\{([^}]+)\}/g, (match, token) => {
@@ -36,7 +36,7 @@ export function resolvePathTemplate(
36
36
 
37
37
  if (token.startsWith("monday:")) {
38
38
  const mondayToken = token.substring(7); // Remove 'monday:' prefix
39
- const mondayDateTime = DateTime.fromJSDate(mondayDate, { zone: "utc" });
39
+ const mondayDateTime = DateTime.fromJSDate(mondayDate, { zone: "local" });
40
40
  return mondayDateTime.toFormat(mondayToken);
41
41
  }
42
42