@marineyachtradar/signalk-plugin 0.1.2 → 0.1.5

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/build.js +50 -6
  2. package/package.json +1 -1
package/build.js CHANGED
@@ -51,22 +51,54 @@ function copyDir(src, dest) {
51
51
  }
52
52
  }
53
53
 
54
+ /**
55
+ * Find mayara-gui in node_modules (handles npm hoisting)
56
+ */
57
+ function findGuiPackage() {
58
+ // Possible locations for mayara-gui:
59
+ // 1. Nested in plugin's own node_modules (npm nested install)
60
+ // 2. Hoisted to parent node_modules (SignalK App Store installs to ~/.signalk/node_modules/)
61
+ // Structure: ~/.signalk/node_modules/@marineyachtradar/signalk-plugin/
62
+ // ~/.signalk/node_modules/@marineyachtradar/mayara-gui/
63
+ // 3. Local development (sibling directory)
64
+ const candidates = [
65
+ // Nested: <plugin>/node_modules/@marineyachtradar/mayara-gui
66
+ path.join(scriptDir, 'node_modules', '@marineyachtradar', 'mayara-gui'),
67
+ // Hoisted (scoped): <node_modules>/@marineyachtradar/<plugin> -> <node_modules>/@marineyachtradar/mayara-gui
68
+ path.join(scriptDir, '..', 'mayara-gui'),
69
+ // Hoisted (top-level): <node_modules>/@marineyachtradar/<plugin> -> <node_modules>/@marineyachtradar/mayara-gui
70
+ path.join(scriptDir, '..', '..', '@marineyachtradar', 'mayara-gui'),
71
+ ]
72
+
73
+ for (const candidate of candidates) {
74
+ if (fs.existsSync(candidate)) {
75
+ return candidate
76
+ }
77
+ }
78
+ return null
79
+ }
80
+
54
81
  /**
55
82
  * Download GUI from npm and copy to public/
56
83
  */
57
84
  function setupGuiFromNpm() {
58
85
  console.log('Copying GUI from node_modules...\n')
59
86
 
60
- // Dependencies should already be installed by npm install
61
- // (this script runs as postinstall, so node_modules exists)
62
- const guiSource = path.join(scriptDir, 'node_modules', '@marineyachtradar', 'mayara-gui')
87
+ // Find mayara-gui (handles npm hoisting where deps may be in parent node_modules)
88
+ const guiSource = findGuiPackage()
63
89
 
64
- if (!fs.existsSync(guiSource)) {
65
- console.error('Error: @marineyachtradar/mayara-gui not found in node_modules')
66
- console.error('Make sure it is listed in package.json dependencies')
90
+ if (!guiSource) {
91
+ console.error('Error: @marineyachtradar/mayara-gui not found')
92
+ console.error('Searched locations:')
93
+ console.error(' - ' + path.join(scriptDir, 'node_modules', '@marineyachtradar', 'mayara-gui'))
94
+ console.error(' - ' + path.join(scriptDir, '..', 'mayara-gui'))
95
+ console.error(' - ' + path.join(scriptDir, '..', '..', '@marineyachtradar', 'mayara-gui'))
96
+ console.error('Make sure @marineyachtradar/mayara-gui is listed in package.json dependencies')
67
97
  process.exit(1)
68
98
  }
69
99
 
100
+ console.log('Found mayara-gui at: ' + guiSource)
101
+
70
102
  // Remove old public dir
71
103
  if (fs.existsSync(publicDest)) {
72
104
  fs.rmSync(publicDest, { recursive: true })
@@ -157,6 +189,18 @@ function setupGuiFromLocal() {
157
189
  function main() {
158
190
  console.log('=== MaYaRa SignalK Plugin Build ===\n')
159
191
 
192
+ // Skip build if public/ already exists with content (installed from --pack tarball)
193
+ // This prevents postinstall from failing when mayara-gui isn't in node_modules
194
+ if (fs.existsSync(publicDest) && !useLocalGui && !createPack) {
195
+ const files = fs.readdirSync(publicDest)
196
+ if (files.length > 0) {
197
+ console.log(`public/ already exists with ${files.length} files (installed from tarball)`)
198
+ console.log('Skipping build.\n')
199
+ console.log('=== Build complete ===')
200
+ return
201
+ }
202
+ }
203
+
160
204
  // Get GUI assets
161
205
  console.log('Setting up GUI assets...\n')
162
206
  if (useLocalGui) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marineyachtradar/signalk-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "MaYaRa Radar - Connect SignalK to mayara-server",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {