buddy-workbench 0.1.88 → 0.1.90

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": "buddy-workbench",
3
- "version": "0.1.88",
3
+ "version": "0.1.90",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,9 @@
1
1
  import crypto from 'node:crypto';
2
2
  import https from 'node:https';
3
+ import { join } from 'node:path';
3
4
  import axios from 'axios';
4
5
  import { Router } from 'express';
6
+ import { paths } from '../config.js';
5
7
  import { readSettings } from '../repositories/settings.js';
6
8
  import { listMindMaps, saveMindMaps } from '../repositories/mind-maps.js';
7
9
 
@@ -13,6 +15,7 @@ const httpClient = axios.create({
13
15
  });
14
16
 
15
17
  const makeId = () => crypto.randomUUID();
18
+ const getMindMapFilePath = (id) => join(paths.mindMaps, `${encodeURIComponent(String(id))}.json`);
16
19
 
17
20
  function getJiraHost(domain) {
18
21
  const clean = String(domain || '').replace(/^https?:\/\//i, '').replace(/\/+$/, '');
@@ -106,13 +109,13 @@ function normalizeMindMap(input, { id = makeId(), createdAt = new Date().toISOSt
106
109
  }
107
110
 
108
111
  router.get('/', (_req, res) => {
109
- res.json(listMindMaps());
112
+ res.json(listMindMaps().map((mindMap) => ({ ...mindMap, filePath: getMindMapFilePath(mindMap.id) })));
110
113
  });
111
114
 
112
115
  router.get('/:id', (req, res) => {
113
116
  const mindMap = listMindMaps().find((item) => String(item.id) === String(req.params.id));
114
117
  if (!mindMap) return res.status(404).json({ error: 'Mind map not found.' });
115
- res.json(mindMap);
118
+ res.json({ ...mindMap, filePath: getMindMapFilePath(mindMap.id) });
116
119
  });
117
120
 
118
121
  router.post('/jira-issues/resolve', async (req, res) => {
@@ -129,7 +132,7 @@ router.post('/', (req, res) => {
129
132
  const mindMaps = listMindMaps();
130
133
  mindMaps.unshift(mindMap);
131
134
  saveMindMaps(mindMaps);
132
- res.status(201).json(mindMap);
135
+ res.status(201).json({ ...mindMap, filePath: getMindMapFilePath(mindMap.id) });
133
136
  });
134
137
 
135
138
  router.put('/:id', (req, res) => {
@@ -144,7 +147,7 @@ router.put('/:id', (req, res) => {
144
147
  if (!updated) return res.status(400).json({ error: 'A root node is required.' });
145
148
  mindMaps[index] = updated;
146
149
  saveMindMaps(mindMaps);
147
- res.json(updated);
150
+ res.json({ ...updated, filePath: getMindMapFilePath(updated.id) });
148
151
  });
149
152
 
150
153
  router.delete('/:id', (req, res) => {
@@ -1,9 +1,9 @@
1
- import { existsSync, mkdirSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, statSync } from 'node:fs';
2
2
  import { Router } from 'express';
3
3
  import { paths } from '../config.js';
4
4
  import { saveAccessToken, saveAiApiHost, saveClipboardDeduplicateMinutes, saveClipboardEnabled, saveClipboardImageEnabled, saveDefaultBrowser, saveDefaultEditor, saveDomain, saveJiraIssuePrefix, saveTheme, settingsStatus } from '../repositories/settings.js';
5
5
  import { getNpmPackageVersions, installNvmVersion, manageGlobalNpmPackage, readDevConfigurations, readNvmConfiguration, saveDevConfigurations, searchNpmPackages, useSuggestedNpmPrefix } from '../services/dev-configurations.js';
6
- import { openInSystemBrowser, openInSystemEditor, openInSystemFolder } from '../services/browser.js';
6
+ import { openInSystemBrowser, openInSystemEditor, openInSystemFolder, revealInSystemFolder } from '../services/browser.js';
7
7
  import { selectDirectory, selectFile } from '../services/dialog.js';
8
8
 
9
9
  const router = Router();
@@ -91,10 +91,15 @@ router.post('/open-editor', (req, res) => {
91
91
  router.post('/open-folder', (req, res) => {
92
92
  const { path } = req.body || {};
93
93
  const targetPath = (typeof path === 'string' && path.trim()) ? path.trim() : paths.dataDir;
94
- if (!existsSync(targetPath)) {
95
- mkdirSync(targetPath, { recursive: true });
94
+ let folderPath = targetPath;
95
+ if (existsSync(targetPath) && statSync(targetPath).isFile()) {
96
+ revealInSystemFolder(targetPath);
97
+ return res.json({ success: true });
96
98
  }
97
- openInSystemFolder(targetPath);
99
+ if (!existsSync(folderPath)) {
100
+ mkdirSync(folderPath, { recursive: true });
101
+ }
102
+ openInSystemFolder(folderPath);
98
103
  res.json({ success: true });
99
104
  });
100
105
  router.post('/open-data-dir', (req, res) => {
@@ -1,7 +1,7 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
- import { join } from 'node:path';
4
+ import { dirname, join } from 'node:path';
5
5
  import { readSettings } from '../repositories/settings.js';
6
6
  import { openWindowsTerminal } from './windows.js';
7
7
 
@@ -109,6 +109,17 @@ export function openInSystemFolder(targetPath) {
109
109
  }
110
110
  }
111
111
 
112
+ export function revealInSystemFolder(targetPath) {
113
+ if (!targetPath || typeof targetPath !== 'string') return;
114
+ if (process.platform === 'darwin') {
115
+ execFile('open', ['-R', targetPath]);
116
+ } else if (process.platform === 'win32') {
117
+ execFile('explorer.exe', [`/select,${targetPath}`], { windowsHide: true });
118
+ } else {
119
+ openInSystemFolder(dirname(targetPath));
120
+ }
121
+ }
122
+
112
123
  function execFileAsync(command, args) {
113
124
  return new Promise((resolve, reject) => {
114
125
  execFile(command, args, (error) => {