@towles/tool 0.0.18 → 0.0.20

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.
Files changed (2) hide show
  1. package/dist/index.mjs +19 -8
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -40,10 +40,12 @@ const AppInfo = {
40
40
  const USER_SETTINGS_DIR = path.join(homedir(), ".config", AppInfo.toolName);
41
41
  const USER_SETTINGS_PATH = path.join(USER_SETTINGS_DIR, `${AppInfo.toolName}.settings.json`);
42
42
  const JournalSettingsSchema = z.object({
43
+ // Base folder where all journal files are stored
44
+ baseFolder: z.string().default(path.join(homedir())),
43
45
  // https://moment.github.io/luxon/#/formatting?id=table-of-tokens
44
- dailyPathTemplate: z.string().default(path.join(homedir(), "journal", "{monday:yyyy}/{monday:MM}/daily-notes/{monday:yyyy}-{monday:MM}-{monday:dd}-daily-notes.md")),
45
- meetingPathTemplate: z.string().default(path.join(homedir(), "journal", "{yyyy}/{MM}/meetings/{yyyy}-{MM}-{dd}-{title}.md")),
46
- notePathTemplate: z.string().default(path.join(homedir(), "journal", "{yyyy}/{MM}/notes/{yyyy}-{MM}-{dd}-{title}.md"))
46
+ dailyPathTemplate: z.string().default(path.join("journal/{monday:yyyy}/{monday:MM}/daily-notes/{monday:yyyy}-{monday:MM}-{monday:dd}-daily-notes.md")),
47
+ meetingPathTemplate: z.string().default(path.join("journal/{yyyy}/{MM}/meetings/{yyyy}-{MM}-{dd}-{title}.md")),
48
+ notePathTemplate: z.string().default(path.join("journal/{yyyy}/{MM}/notes/{yyyy}-{MM}-{dd}-{title}.md"))
47
49
  });
48
50
  const UserSettingsSchema = z.object({
49
51
  preferredEditor: z.string().default("code"),
@@ -121,7 +123,7 @@ async function loadSettings() {
121
123
  );
122
124
  }
123
125
 
124
- const version = "0.0.18";
126
+ const version = "0.0.20";
125
127
 
126
128
  const JOURNAL_TYPES = {
127
129
  DAILY_NOTES: "daily-notes",
@@ -411,9 +413,13 @@ function createNoteContent({ title, date }) {
411
413
  content.push(``);
412
414
  return content.join("\n");
413
415
  }
414
- async function openInEditor({ editor, filePath }) {
416
+ async function openInEditor({ editor, filePath, folderPath }) {
415
417
  try {
416
- await execAsync(`"${editor}" "${filePath}"`);
418
+ if (folderPath) {
419
+ await execAsync(`"${editor}" "${folderPath}" "${filePath}"`);
420
+ } else {
421
+ await execAsync(`"${editor}" "${filePath}"`);
422
+ }
417
423
  } catch (ex) {
418
424
  consola.warn(`Could not open in editor : '${editor}'. Modify your editor in the config: examples include 'code', 'code-insiders', etc...`, ex);
419
425
  }
@@ -470,9 +476,10 @@ function generateJournalFileInfoByType({ journalSettings, date = /* @__PURE__ */
470
476
  throw new Error(`Unknown JournalType: ${type}`);
471
477
  }
472
478
  const resolvedPath = resolvePathTemplate(templatePath, title, currentDate, mondayDate);
479
+ const fullPath = path__default.join(journalSettings.baseFolder, resolvedPath);
473
480
  return {
474
481
  currentDate,
475
- fullPath: resolvedPath,
482
+ fullPath,
476
483
  mondayDate
477
484
  };
478
485
  }
@@ -511,7 +518,11 @@ async function createJournalFile({ context, type, title }) {
511
518
  consola.info(`Creating new ${type} file: ${colors.cyan(fileInfo.fullPath)}`);
512
519
  writeFileSync(fileInfo.fullPath, content, "utf8");
513
520
  }
514
- await openInEditor({ editor: context.settingsFile.settings.preferredEditor, filePath: fileInfo.fullPath });
521
+ await openInEditor({
522
+ editor: context.settingsFile.settings.preferredEditor,
523
+ filePath: fileInfo.fullPath,
524
+ folderPath: context.settingsFile.settings.journalSettings.baseFolder
525
+ });
515
526
  } catch (error) {
516
527
  consola.warn(`Error creating ${type} file:`, error);
517
528
  process$1.exit(1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@towles/tool",
3
3
  "type": "module",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "description": "One off quality of life scripts that I use on a daily basis.",
6
6
  "author": "Chris Towles <Chris.Towles.Dev@gmail.com>",
7
7
  "license": "MIT",