seabox 0.1.0-beta.4 → 0.1.1

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.
@@ -7,11 +7,9 @@
7
7
  import fs from 'fs';
8
8
  import path from 'path';
9
9
  import { rolldown as rolldown } from 'rolldown';
10
- import commonjs from '@rollup/plugin-commonjs';
11
- import { nodeResolve } from '@rollup/plugin-node-resolve';
12
- import json from '@rollup/plugin-json';
13
10
  import Module from 'module';
14
11
  import { fileURLToPath } from 'url';
12
+ import * as diag from './diagnostics.mjs';
15
13
 
16
14
  const __filename = fileURLToPath(import.meta.url);
17
15
  const __dirname = path.dirname(__filename);
@@ -71,21 +69,24 @@ class NativeModuleDetectorPlugin {
71
69
  /**
72
70
  * Register a native module
73
71
  */
74
- registerNativeModule(nativePath) {
72
+ registerNativeModule(nativePath, isPrebuild = false) {
75
73
  if (this.nativeModules.has(nativePath)) {
76
74
  return this.nativeModules.get(nativePath);
77
75
  }
78
76
 
79
77
  const packageRoot = this.findPackageRoot(nativePath);
80
78
  const moduleName = packageRoot ? path.basename(packageRoot) : path.basename(nativePath, '.node');
81
- const fileName = path.basename(nativePath);
79
+
80
+ // Use relative path from project root to avoid conflicts and preserve structure
81
+ const relativeFromProject = path.relative(this.projectRoot, nativePath).replace(/\\/g, '/');
82
82
 
83
83
  const info = {
84
84
  binaryPath: nativePath,
85
85
  packageRoot: packageRoot || path.dirname(nativePath),
86
86
  moduleName: moduleName,
87
87
  buildPath: path.dirname(nativePath),
88
- assetKey: `native/${moduleName}/${fileName}`
88
+ assetKey: relativeFromProject,
89
+ isPrebuild: isPrebuild // Track if this is a prebuild (don't rebuild)
89
90
  };
90
91
 
91
92
  this.nativeModules.set(nativePath, info);
@@ -176,7 +177,7 @@ class NativeModuleDetectorPlugin {
176
177
  // Pick best match (prefer napi builds)
177
178
  const napiFile = nodeFiles.find(f => f.includes('napi')) || nodeFiles[0];
178
179
  const nativePath = path.join(platformArchDir, napiFile);
179
- const info = self.registerNativeModule(nativePath);
180
+ const info = self.registerNativeModule(nativePath, true); // Mark as prebuild
180
181
  hasChanges = true;
181
182
  return `__requireSeabox('${info.assetKey}')`;
182
183
  }
@@ -354,10 +355,8 @@ export async function bundleWithRollup(entryPath, outputPath, config = {}, targe
354
355
  projectRoot
355
356
  });
356
357
 
357
- if (verbose) {
358
- console.log('[Bundler] Bundling entry:', entryPath);
359
- console.log('[Bundler] Target:', `${targetPlatform}-${targetArch}`);
360
- }
358
+ diag.verbose(`Bundling entry: ${entryPath}`);
359
+ diag.verbose(`Target: ${diag.formatTarget(targetPlatform, targetArch)}`);
361
360
 
362
361
  // Get Node.js built-in modules to mark as external
363
362
  const builtinModules = Module.builtinModules || [];
@@ -367,7 +366,6 @@ export async function bundleWithRollup(entryPath, outputPath, config = {}, targe
367
366
  platform: "node",
368
367
  plugins: [
369
368
  nativeDetector,
370
- json(),
371
369
  ...(config.bundler?.plugins || [])
372
370
  ],
373
371
  external: [
@@ -399,11 +397,9 @@ export async function bundleWithRollup(entryPath, outputPath, config = {}, targe
399
397
 
400
398
  await bundle.close();
401
399
 
402
- if (verbose) {
403
- console.log('[Bundler] Bundle complete:', outputPath);
404
- console.log('[Bundler] Native modules detected:', nativeDetector.nativeModules.size);
405
- console.log('[Bundler] Assets detected:', nativeDetector.detectedAssets.size);
406
- }
400
+ diag.verbose(`Bundle complete: ${outputPath}`);
401
+ diag.verbose(`Native modules detected: ${nativeDetector.nativeModules.size}`);
402
+ diag.verbose(`Assets detected: ${nativeDetector.detectedAssets.size}`);
407
403
 
408
404
  return {
409
405
  bundledPath: outputPath,
package/lib/unsign.cjs CHANGED
@@ -9,6 +9,18 @@ const { promisify } = require('util');
9
9
 
10
10
  const execFileAsync = promisify(execFile);
11
11
 
12
+ // Simple verbose logging flag (set by inject.mjs)
13
+ let verboseMode = false;
14
+ function setVerbose(enabled) {
15
+ verboseMode = enabled;
16
+ }
17
+
18
+ function logVerbose(message, indent = 2) {
19
+ if (verboseMode) {
20
+ console.log(' '.repeat(indent) + message);
21
+ }
22
+ }
23
+
12
24
  /**
13
25
  * Check if a signing tool is available on the system.
14
26
  * @param {string} platform - Target platform (win32, linux, darwin)
@@ -106,32 +118,29 @@ async function removeMacSignature(exePath) {
106
118
  async function removeSignature(exePath, platform) {
107
119
  // Linux binaries are typically not signed, so skip signature removal
108
120
  if (platform === 'linux') {
109
- console.log('Skipping signature removal (Linux binaries are typically unsigned)');
121
+ logVerbose('Skipping signature removal (Linux binaries are typically unsigned)');
110
122
  return;
111
123
  }
112
124
 
113
- //console.log('Checking for code signature removal tools...');
114
-
115
125
  const { available, tool } = await checkSignToolAvailability(platform);
116
126
 
117
127
  if (!available) {
118
- console.warn(`⚠️ Warning: Signature removal tool not found for ${platform}`);
119
- console.warn(` Tool needed: ${tool || 'unknown'}`);
120
- console.warn(` The binary may have an existing signature that will be corrupted during injection.`);
128
+ logVerbose(`[!] Warning: Signature removal tool not found for ${platform}`);
129
+ logVerbose(`Tool needed: ${tool || 'unknown'}`, 2);
130
+ logVerbose(`The binary may have an existing signature that will be corrupted during injection.`, 2);
121
131
 
122
132
  if (platform === 'win32') {
123
- console.warn(` Install Windows SDK to get signtool.exe`);
124
- console.warn(` Download from: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/`);
133
+ logVerbose(`Install Windows SDK to get signtool.exe`, 2);
134
+ logVerbose(`Download from: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/`, 2);
125
135
  } else if (platform === 'darwin') {
126
- console.warn(` Install Xcode Command Line Tools to get codesign`);
127
- console.warn(` Run: xcode-select --install`);
136
+ logVerbose(`Install Xcode Command Line Tools to get codesign`, 2);
137
+ logVerbose(`Run: xcode-select --install`, 2);
128
138
  }
129
139
 
130
- console.warn('');
131
140
  return;
132
141
  }
133
142
 
134
- console.log(`Found ${tool}, attempting to remove signature...`);
143
+ logVerbose(`Found ${tool}, attempting to remove signature...`);
135
144
 
136
145
  let result;
137
146
  if (platform === 'win32') {
@@ -139,15 +148,15 @@ async function removeSignature(exePath, platform) {
139
148
  } else if (platform === 'darwin') {
140
149
  result = await removeMacSignature(exePath);
141
150
  } else {
142
- console.warn(`⚠️ Warning: Unsupported platform for signature removal: ${platform}`);
151
+ logVerbose(`[!] Warning: Unsupported platform for signature removal: ${platform}`);
143
152
  return;
144
153
  }
145
154
 
146
155
  if (result.success) {
147
- console.log(`✓ ${result.message}`);
156
+ logVerbose(`[✓] ${result.message}`);
148
157
  } else {
149
- console.warn(`⚠️ Warning: ${result.message}`);
150
- console.warn(` Continuing anyway, but the executable may have signature issues.`);
158
+ logVerbose(`[!] Warning: ${result.message}`);
159
+ logVerbose(`Continuing anyway, but the executable may have signature issues.`, 2);
151
160
  }
152
161
  }
153
162
 
@@ -156,4 +165,5 @@ module.exports = {
156
165
  checkSignToolAvailability,
157
166
  removeWindowsSignature,
158
167
  removeMacSignature,
168
+ setVerbose,
159
169
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seabox",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.1",
4
4
  "description": "Node.js Single Executable Application (SEA) builder tool with native and library extraction",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -20,6 +20,7 @@
20
20
  "SEA",
21
21
  "native",
22
22
  "module",
23
+ "pkg",
23
24
  "dll",
24
25
  "packaging",
25
26
  "node",
@@ -33,17 +34,20 @@
33
34
  },
34
35
  "homepage": "https://github.com/MeirionHughes/seabox",
35
36
  "dependencies": {
36
- "@rollup/plugin-commonjs": "^28.0.2",
37
- "@rollup/plugin-json": "^6.1.0",
38
- "@rollup/plugin-node-resolve": "^15.3.0",
39
37
  "adm-zip": "^0.5.16",
40
38
  "glob": "^10.0.0",
41
39
  "postject": "^1.0.0-alpha.6",
42
- "rcedit": "^4.0.1",
43
40
  "rolldown": "^1.0.0-beta.50",
44
- "rollup": "^4.28.1",
45
41
  "tar": "^6.2.1"
46
42
  },
43
+ "peerDependencies": {
44
+ "rcedit": "^4.0.1"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "rcedit": {
48
+ "optional": true
49
+ }
50
+ },
47
51
  "devDependencies": {
48
52
  "chai": "^6.2.1",
49
53
  "javascript-obfuscator": "^4.1.1",