seabox 0.1.2 → 0.3.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/.mocharc.json +6 -6
- package/LICENSE.MD +21 -21
- package/README.md +310 -310
- package/bin/seabox-rebuild.mjs +107 -88
- package/bin/seabox.mjs +150 -147
- package/lib/blob.mjs +104 -104
- package/lib/bootstrap.cjs +756 -756
- package/lib/build-cache.mjs +206 -199
- package/lib/build.mjs +77 -77
- package/lib/config.mjs +243 -243
- package/lib/crypto-assets.mjs +125 -125
- package/lib/diagnostics.mjs +203 -203
- package/lib/entry-bundler.mjs +64 -64
- package/lib/fetch-node.mjs +172 -172
- package/lib/index.mjs +26 -26
- package/lib/inject.mjs +106 -106
- package/lib/manifest.mjs +100 -100
- package/lib/multi-target-builder.mjs +701 -697
- package/lib/native-scanner.mjs +203 -203
- package/lib/obfuscate.mjs +51 -51
- package/lib/require-shim.mjs +113 -113
- package/lib/rolldown-bundler.mjs +411 -411
- package/lib/unsign.cjs +197 -169
- package/package.json +61 -61
package/bin/seabox-rebuild.mjs
CHANGED
|
@@ -1,88 +1,107 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* seabox-rebuild.mjs
|
|
4
|
-
* Rebuild native modules for target platform/architecture
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { execSync } from 'child_process';
|
|
8
|
-
import fs from 'fs';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
import { fileURLToPath } from 'url';
|
|
11
|
-
import * as diag from '../lib/diagnostics.mjs';
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = path.dirname(__filename);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Rebuild a native module for a specific target
|
|
18
|
-
* @param {string} modulePath - Path to the native module
|
|
19
|
-
* @param {string}
|
|
20
|
-
* @param {string}
|
|
21
|
-
* @param {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
diag.verbose(`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} catch
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* seabox-rebuild.mjs
|
|
4
|
+
* Rebuild native modules for target platform/architecture
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
import * as diag from '../lib/diagnostics.mjs';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Rebuild a native module for a specific target
|
|
18
|
+
* @param {string} modulePath - Path to the native module
|
|
19
|
+
* @param {string} nodeVersion - Target Node.js version (e.g., "24.13.0")
|
|
20
|
+
* @param {string} platform - Target platform (win32, linux, darwin)
|
|
21
|
+
* @param {string} arch - Target architecture (x64, arm64)
|
|
22
|
+
* @param {boolean} verbose - Enable verbose logging
|
|
23
|
+
*/
|
|
24
|
+
function rebuildNativeModule(modulePath, nodeVersion, platform, arch, verbose = false) {
|
|
25
|
+
diag.setVerbose(verbose);
|
|
26
|
+
|
|
27
|
+
diag.verbose(`Rebuilding native module: ${modulePath}`);
|
|
28
|
+
diag.verbose(`Target: Node.js ${nodeVersion} ${platform}-${arch}`);
|
|
29
|
+
|
|
30
|
+
const packageJsonPath = path.join(modulePath, 'package.json');
|
|
31
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
32
|
+
throw new Error(`No package.json found in ${modulePath}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
36
|
+
const moduleName = pkg.name;
|
|
37
|
+
|
|
38
|
+
// Check if module has native bindings
|
|
39
|
+
const hasBindingGyp = fs.existsSync(path.join(modulePath, 'binding.gyp'));
|
|
40
|
+
if (!hasBindingGyp && !pkg.gypfile) {
|
|
41
|
+
diag.verbose(`Module ${moduleName} does not appear to have native bindings, skipping`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
// Use node-gyp to rebuild for the target Node.js version, platform, and architecture
|
|
47
|
+
// --target specifies the Node.js version (critical for NODE_MODULE_VERSION)
|
|
48
|
+
// --dist-url ensures node-gyp downloads headers from the correct location
|
|
49
|
+
const cmd = `npx node-gyp rebuild --target=${nodeVersion} --arch=${arch} --dist-url=https://nodejs.org/dist`;
|
|
50
|
+
|
|
51
|
+
diag.verbose(`Building for Node.js ${nodeVersion} (${platform}-${arch})`, 2);
|
|
52
|
+
diag.verbose(`Command: ${cmd}`, 2);
|
|
53
|
+
|
|
54
|
+
execSync(cmd, {
|
|
55
|
+
cwd: modulePath,
|
|
56
|
+
stdio: 'pipe', // Hide output unless error occurs
|
|
57
|
+
env: {
|
|
58
|
+
...process.env,
|
|
59
|
+
npm_config_target: nodeVersion,
|
|
60
|
+
npm_config_arch: arch,
|
|
61
|
+
npm_config_target_arch: arch,
|
|
62
|
+
npm_config_disturl: 'https://nodejs.org/dist'
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
diag.verbose(`Successfully built for Node.js ${nodeVersion}`, 2);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
// Show node-gyp output on error
|
|
69
|
+
if (error.stdout) console.error(error.stdout.toString());
|
|
70
|
+
if (error.stderr) console.error(error.stderr.toString());
|
|
71
|
+
diag.verbose(`Failed to rebuild ${moduleName}: ${error.message}`);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// CLI entry point - compare normalized paths for cross-platform compatibility
|
|
77
|
+
const isMainModule = (() => {
|
|
78
|
+
try {
|
|
79
|
+
const scriptPath = fileURLToPath(import.meta.url);
|
|
80
|
+
const argPath = path.resolve(process.argv[1]);
|
|
81
|
+
return scriptPath === argPath;
|
|
82
|
+
} catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
})();
|
|
86
|
+
|
|
87
|
+
if (isMainModule) {
|
|
88
|
+
const args = process.argv.slice(2);
|
|
89
|
+
|
|
90
|
+
if (args.length < 4) {
|
|
91
|
+
diag.error('Usage: seabox-rebuild <module-path> <node-version> <platform> <arch> [--verbose]');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const [modulePath, nodeVersion, platform, arch] = args;
|
|
96
|
+
const verbose = args.includes('--verbose') || args.includes('-v');
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
rebuildNativeModule(modulePath, nodeVersion, platform, arch, verbose);
|
|
100
|
+
process.exit(0);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
diag.error(`Rebuild failed: ${error.message}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { rebuildNativeModule };
|
package/bin/seabox.mjs
CHANGED
|
@@ -1,147 +1,150 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* seabox.mjs
|
|
4
|
-
* CLI entry point for Seabox architecture (testing/development)
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* seabox build [--config path] [--verbose]
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import fs from 'fs';
|
|
12
|
-
import { fileURLToPath } from 'url';
|
|
13
|
-
import Module from 'module';
|
|
14
|
-
import * as diag from '../lib/diagnostics.mjs';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
diag.
|
|
34
|
-
diag.
|
|
35
|
-
diag.
|
|
36
|
-
diag.
|
|
37
|
-
diag.
|
|
38
|
-
diag.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
diag.
|
|
82
|
-
diag.
|
|
83
|
-
diag.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
diag.
|
|
91
|
-
diag.
|
|
92
|
-
diag.info('
|
|
93
|
-
diag.info('
|
|
94
|
-
diag.
|
|
95
|
-
diag.
|
|
96
|
-
diag.info('
|
|
97
|
-
diag.info(' --
|
|
98
|
-
diag.info(' --
|
|
99
|
-
diag.
|
|
100
|
-
diag.
|
|
101
|
-
diag.info('
|
|
102
|
-
diag.info(' seabox
|
|
103
|
-
diag.info(' seabox
|
|
104
|
-
diag.info(' seabox build --verbose');
|
|
105
|
-
diag.
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* seabox.mjs
|
|
4
|
+
* CLI entry point for Seabox architecture (testing/development)
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* seabox build [--config path] [--verbose]
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import Module from 'module';
|
|
14
|
+
import * as diag from '../lib/diagnostics.mjs';
|
|
15
|
+
import { createRequire } from 'module';
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
20
|
+
const pkg = require('../package.json');
|
|
21
|
+
|
|
22
|
+
const commands = {
|
|
23
|
+
build: async (args) => {
|
|
24
|
+
const { loadConfig } = await import('../lib/config.mjs');
|
|
25
|
+
|
|
26
|
+
const configPath = args.includes('--config') ? args[args.indexOf('--config') + 1] : null;
|
|
27
|
+
const projectRoot = process.cwd();
|
|
28
|
+
|
|
29
|
+
// Check if config exists before attempting build
|
|
30
|
+
const config = loadConfig(configPath, projectRoot);
|
|
31
|
+
|
|
32
|
+
if (!config) {
|
|
33
|
+
diag.error('No configuration found');
|
|
34
|
+
diag.separator();
|
|
35
|
+
diag.info('Seabox looks for configuration in this order:');
|
|
36
|
+
diag.numberedItem(1, '--config <path> (command line argument)');
|
|
37
|
+
diag.numberedItem(2, 'seabox.config.json (in current directory)');
|
|
38
|
+
diag.numberedItem(3, '"seabox" field in package.json');
|
|
39
|
+
diag.separator();
|
|
40
|
+
diag.info('To get started, run: npx seabox init');
|
|
41
|
+
diag.separator();
|
|
42
|
+
commands.help();
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { build } = await import('../lib/build.mjs');
|
|
47
|
+
|
|
48
|
+
const options = {
|
|
49
|
+
configPath,
|
|
50
|
+
verbose: args.includes('--verbose') || args.includes('-v'),
|
|
51
|
+
debug: args.includes('--debug'),
|
|
52
|
+
projectRoot
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
await build(options);
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
migrate: async (args) => {
|
|
59
|
+
// Use CommonJS require for the migration tool
|
|
60
|
+
const require = Module.createRequire(import.meta.url);
|
|
61
|
+
const { migrate } = require('./seabox-migrate.js');
|
|
62
|
+
await migrate();
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
init: async (args) => {
|
|
66
|
+
const { generateDefaultConfig } = await import('../lib/config.mjs');
|
|
67
|
+
|
|
68
|
+
const configPath = path.join(process.cwd(), 'seabox.config.json');
|
|
69
|
+
|
|
70
|
+
if (fs.existsSync(configPath)) {
|
|
71
|
+
diag.error('seabox.config.json already exists');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const defaultConfig = generateDefaultConfig({
|
|
76
|
+
entry: './src/index.js'
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + '\n', 'utf8');
|
|
80
|
+
|
|
81
|
+
diag.success('Created seabox.config.json', 0);
|
|
82
|
+
diag.separator();
|
|
83
|
+
diag.info('Next steps:');
|
|
84
|
+
diag.numberedItem(1, 'Edit seabox.config.json to configure your build');
|
|
85
|
+
diag.numberedItem(2, 'Run: npx seabox build');
|
|
86
|
+
diag.separator();
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
help: () => {
|
|
90
|
+
diag.info('Usage: seabox [command] [options]');
|
|
91
|
+
diag.separator();
|
|
92
|
+
diag.info('Commands:');
|
|
93
|
+
diag.info(' build Build executable(s) for configured targets (default)');
|
|
94
|
+
diag.info(' init Create a default seabox.config.json');
|
|
95
|
+
diag.separator();
|
|
96
|
+
diag.info('Build Options:');
|
|
97
|
+
diag.info(' --config Path to config file (default: seabox.config.json)');
|
|
98
|
+
diag.info(' --verbose Enable verbose logging');
|
|
99
|
+
diag.info(' --debug Keep temporary build files');
|
|
100
|
+
diag.separator();
|
|
101
|
+
diag.info('Examples:');
|
|
102
|
+
diag.info(' seabox init');
|
|
103
|
+
diag.info(' seabox build');
|
|
104
|
+
diag.info(' seabox --verbose # Same as: seabox build --verbose');
|
|
105
|
+
diag.info(' seabox build --verbose');
|
|
106
|
+
diag.separator();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
async function main() {
|
|
111
|
+
console.log(`Seabox v${pkg.version}`);
|
|
112
|
+
|
|
113
|
+
const args = process.argv.slice(2);
|
|
114
|
+
|
|
115
|
+
// If no args or first arg is a flag, default to help
|
|
116
|
+
if (args.length === 0) {
|
|
117
|
+
commands.help();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Check if first arg is a flag (starts with --)
|
|
122
|
+
const firstArg = args[0];
|
|
123
|
+
let command = firstArg;
|
|
124
|
+
let commandArgs = args.slice(1);
|
|
125
|
+
|
|
126
|
+
if (firstArg.startsWith('-')) {
|
|
127
|
+
// First arg is a flag, so default to 'build' command
|
|
128
|
+
command = 'build';
|
|
129
|
+
commandArgs = args; // Include all args including the flags
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (commands[command]) {
|
|
133
|
+
try {
|
|
134
|
+
await commands[command](commandArgs);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
diag.error(error.message);
|
|
137
|
+
if (args.includes('--verbose')) {
|
|
138
|
+
console.error(error.stack);
|
|
139
|
+
}
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
diag.error(`Unknown command: ${command}`);
|
|
144
|
+
diag.separator();
|
|
145
|
+
commands.help();
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
main();
|