seabox 0.1.0-beta.4 → 0.1.0
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/README.md +60 -233
- package/bin/seabox-rebuild.mjs +11 -18
- package/bin/seabox.mjs +39 -27
- package/lib/blob.mjs +2 -1
- package/lib/build.mjs +8 -6
- package/lib/config.mjs +11 -2
- package/lib/diagnostics.mjs +203 -0
- package/lib/fetch-node.mjs +5 -4
- package/lib/inject.mjs +19 -35
- package/lib/multi-target-builder.mjs +188 -103
- package/lib/native-scanner.mjs +7 -14
- package/lib/require-shim.mjs +7 -5
- package/lib/rolldown-bundler.mjs +13 -17
- package/lib/unsign.cjs +26 -16
- package/package.json +2 -1
package/lib/rolldown-bundler.mjs
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
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
|
-
|
|
358
|
-
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
124
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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
|
-
|
|
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
|
-
|
|
151
|
+
logVerbose(`[!] Warning: Unsupported platform for signature removal: ${platform}`);
|
|
143
152
|
return;
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
if (result.success) {
|
|
147
|
-
|
|
156
|
+
logVerbose(`[✓] ${result.message}`);
|
|
148
157
|
} else {
|
|
149
|
-
|
|
150
|
-
|
|
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
|
|
3
|
+
"version": "0.1.0",
|
|
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",
|