mrmd-server 0.1.10 → 0.1.12

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": "mrmd-server",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "HTTP server for mrmd - run mrmd in any browser, access from anywhere",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -145,6 +145,11 @@ export function createProjectRoutes(ctx) {
145
145
  * POST /api/project
146
146
  * Create a new mrmd project
147
147
  * Mirrors: electronAPI.project.create(targetPath)
148
+ *
149
+ * Uses ProjectService.createProject() which:
150
+ * 1. Creates scaffold files (mrmd.md, index files)
151
+ * 2. Creates venv
152
+ * 3. Installs mrmd-python
148
153
  */
149
154
  router.post('/', async (req, res) => {
150
155
  try {
@@ -155,23 +160,8 @@ export function createProjectRoutes(ctx) {
155
160
 
156
161
  const resolvedPath = path.resolve(ctx.projectDir, targetPath);
157
162
 
158
- // Create directory if it doesn't exist
159
- await fs.mkdir(resolvedPath, { recursive: true });
160
-
161
- // Create mrmd.md config file
162
- const mrmdPath = path.join(resolvedPath, 'mrmd.md');
163
- const mrmdContent = `# ${path.basename(resolvedPath)}
164
-
165
- A new mrmd project.
166
-
167
- ---
168
- venv: .venv
169
- ---
170
- `;
171
- await fs.writeFile(mrmdPath, mrmdContent);
172
-
173
- // Get and return project info
174
- const projectInfo = await getProjectInfo(mrmdPath, ctx.projectDir);
163
+ // Use ProjectService to create full project (same as Electron)
164
+ const projectInfo = await projectService.createProject(resolvedPath);
175
165
  res.json(projectInfo);
176
166
  } catch (err) {
177
167
  console.error('[project:create]', err);
@@ -215,7 +215,26 @@
215
215
  // File scanning
216
216
  // ========================================================================
217
217
 
218
- scanFiles: (searchDir) => GET(`/api/file/scan?root=${encodeURIComponent(searchDir || '')}`),
218
+ scanFiles: (searchDir) => {
219
+ // Trigger scan and emit results via onFilesUpdate (matches electron behavior)
220
+ GET(`/api/file/scan?root=${encodeURIComponent(searchDir || '')}`)
221
+ .then(files => {
222
+ // Emit files-update event with the results
223
+ const handlers = eventHandlers['files-update'];
224
+ if (handlers) {
225
+ handlers.forEach(cb => {
226
+ try {
227
+ cb({ files });
228
+ } catch (err) {
229
+ console.error('[http-shim] files-update handler error:', err);
230
+ }
231
+ });
232
+ }
233
+ })
234
+ .catch(err => {
235
+ console.error('[http-shim] scanFiles error:', err);
236
+ });
237
+ },
219
238
 
220
239
  onFilesUpdate: (callback) => {
221
240
  eventHandlers['files-update'].push(callback);