fluidcad 0.0.16 → 0.0.17

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/bin/fluidcad.js CHANGED
@@ -5,7 +5,7 @@ import { resolve, dirname } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { parseArgs } from 'util';
7
7
  import { writeFileSync, existsSync } from 'fs';
8
- import { createFileWatcher } from './watcher.js';
8
+ import { createFileWatcher, findFluidFiles } from './watcher.js';
9
9
 
10
10
  const __dirname = dirname(fileURLToPath(import.meta.url));
11
11
 
@@ -88,6 +88,11 @@ server.on('message', (msg) => {
88
88
  if (msg.success) {
89
89
  console.log('FluidCAD initialized successfully.');
90
90
  watcher = createFileWatcher(workspacePath, server);
91
+
92
+ const files = findFluidFiles(workspacePath);
93
+ if (files.length > 0) {
94
+ server.send({ type: 'process-file', filePath: files[0] });
95
+ }
91
96
  } else {
92
97
  console.error(`FluidCAD initialization failed: ${msg.error}`);
93
98
  process.exit(1);
package/bin/watcher.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import chokidar from 'chokidar';
2
- import { readFileSync } from 'fs';
2
+ import { readFileSync, readdirSync } from 'fs';
3
+ import { join } from 'path';
3
4
 
4
5
  /**
5
6
  * Creates a file watcher that monitors .fluid.js files in the workspace
@@ -53,3 +54,20 @@ export function createFileWatcher(workspacePath, server) {
53
54
 
54
55
  return watcher;
55
56
  }
57
+
58
+ /**
59
+ * Finds `.fluid.js` files in the top level of the workspace directory,
60
+ * ignoring node_modules and .git.
61
+ *
62
+ * @param {string} workspacePath - Absolute path to the workspace directory
63
+ * @returns {string[]} Absolute paths to discovered `.fluid.js` files
64
+ */
65
+ export function findFluidFiles(workspacePath) {
66
+ try {
67
+ return readdirSync(workspacePath)
68
+ .filter((f) => f.endsWith('.fluid.js'))
69
+ .map((f) => join(workspacePath, f));
70
+ } catch {
71
+ return [];
72
+ }
73
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluidcad",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "Parametric CAD modeling library using javascript",
5
5
  "author": "Marwan Aouida <contact@marwan.dev>",
6
6
  "homepage": "https://fluidcad.io",