seabox 0.1.0-beta.2 → 0.1.0-beta.4
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 +353 -110
- package/bin/seabox-rebuild.mjs +95 -0
- package/bin/seabox.mjs +135 -0
- package/lib/{blob.js → blob.mjs} +12 -18
- package/lib/bootstrap.cjs +753 -0
- package/lib/build-cache.mjs +199 -0
- package/lib/build.mjs +75 -0
- package/lib/config.mjs +234 -0
- package/lib/{crypto-assets.js → crypto-assets.mjs} +12 -47
- package/lib/entry-bundler.mjs +64 -0
- package/lib/{fetch-node.js → fetch-node.mjs} +10 -16
- package/lib/index.mjs +26 -0
- package/lib/inject.mjs +111 -0
- package/lib/{manifest.js → manifest.mjs} +5 -11
- package/lib/multi-target-builder.mjs +620 -0
- package/lib/native-scanner.mjs +210 -0
- package/lib/{obfuscate.js → obfuscate.mjs} +9 -31
- package/lib/require-shim.mjs +111 -0
- package/lib/rolldown-bundler.mjs +415 -0
- package/lib/{unsign.js → unsign.cjs} +7 -32
- package/package.json +10 -5
- package/bin/seabox-rebuild.js +0 -395
- package/bin/seabox.js +0 -81
- package/lib/bindings.js +0 -31
- package/lib/bootstrap.js +0 -697
- package/lib/build.js +0 -283
- package/lib/bytenode-hack.js +0 -56
- package/lib/config.js +0 -118
- package/lib/index.js +0 -27
- package/lib/inject.js +0 -81
- package/lib/scanner.js +0 -153
package/bin/seabox.mjs
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = path.dirname(__filename);
|
|
17
|
+
|
|
18
|
+
const commands = {
|
|
19
|
+
build: async (args) => {
|
|
20
|
+
const { loadConfig } = await import('../lib/config.mjs');
|
|
21
|
+
|
|
22
|
+
const configPath = args.includes('--config') ? args[args.indexOf('--config') + 1] : null;
|
|
23
|
+
const projectRoot = process.cwd();
|
|
24
|
+
|
|
25
|
+
// Check if config exists before attempting build
|
|
26
|
+
const config = loadConfig(configPath, projectRoot);
|
|
27
|
+
|
|
28
|
+
if (!config) {
|
|
29
|
+
console.log('❌ No configuration found\n');
|
|
30
|
+
console.log('Seabox looks for configuration in this order:');
|
|
31
|
+
console.log(' 1. --config <path> (command line argument)');
|
|
32
|
+
console.log(' 2. seabox.config.json (in current directory)');
|
|
33
|
+
console.log(' 3. "seabox" field in package.json\n');
|
|
34
|
+
console.log('To get started, run: npx seabox init\n');
|
|
35
|
+
commands.help();
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { build } = await import('../lib/build.mjs');
|
|
40
|
+
|
|
41
|
+
const options = {
|
|
42
|
+
configPath,
|
|
43
|
+
verbose: args.includes('--verbose') || args.includes('-v'),
|
|
44
|
+
debug: args.includes('--debug'),
|
|
45
|
+
projectRoot
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
await build(options);
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
migrate: async (args) => {
|
|
52
|
+
// Use CommonJS require for the migration tool
|
|
53
|
+
const require = Module.createRequire(import.meta.url);
|
|
54
|
+
const { migrate } = require('./seabox-migrate.js');
|
|
55
|
+
await migrate();
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
init: async (args) => {
|
|
59
|
+
const { generateDefaultConfig } = await import('../lib/config.mjs');
|
|
60
|
+
|
|
61
|
+
const configPath = path.join(process.cwd(), 'seabox.config.json');
|
|
62
|
+
|
|
63
|
+
if (fs.existsSync(configPath)) {
|
|
64
|
+
console.error('❌ Error: seabox.config.json already exists');
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const defaultConfig = generateDefaultConfig({
|
|
69
|
+
entry: './src/index.js'
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + '\n', 'utf8');
|
|
73
|
+
|
|
74
|
+
console.log('✅ Created seabox.config.json');
|
|
75
|
+
console.log('\n📝 Next steps:');
|
|
76
|
+
console.log(' 1. Edit seabox.config.json to configure your build');
|
|
77
|
+
console.log(' 2. Run: npx seabox build\n');
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
help: () => {
|
|
81
|
+
console.log('Seabox v2 - Node.js Single Executable Application Builder\n');
|
|
82
|
+
console.log('Usage: seabox [command] [options]\n');
|
|
83
|
+
console.log('Commands:');
|
|
84
|
+
console.log(' build Build executable(s) for configured targets (default)');
|
|
85
|
+
console.log(' init Create a default seabox.config.json\n');
|
|
86
|
+
console.log('Build Options:');
|
|
87
|
+
console.log(' --config Path to config file (default: seabox.config.json)');
|
|
88
|
+
console.log(' --verbose Enable verbose logging');
|
|
89
|
+
console.log(' --debug Keep temporary build files\n');
|
|
90
|
+
console.log('Examples:');
|
|
91
|
+
console.log(' seabox init');
|
|
92
|
+
console.log(' seabox build');
|
|
93
|
+
console.log(' seabox --verbose # Same as: seabox build --verbose');
|
|
94
|
+
console.log(' seabox build --verbose\n');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
async function main() {
|
|
99
|
+
const args = process.argv.slice(2);
|
|
100
|
+
|
|
101
|
+
// If no args or first arg is a flag, default to help
|
|
102
|
+
if (args.length === 0) {
|
|
103
|
+
commands.help();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Check if first arg is a flag (starts with --)
|
|
108
|
+
const firstArg = args[0];
|
|
109
|
+
let command = firstArg;
|
|
110
|
+
let commandArgs = args.slice(1);
|
|
111
|
+
|
|
112
|
+
if (firstArg.startsWith('-')) {
|
|
113
|
+
// First arg is a flag, so default to 'build' command
|
|
114
|
+
command = 'build';
|
|
115
|
+
commandArgs = args; // Include all args including the flags
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (commands[command]) {
|
|
119
|
+
try {
|
|
120
|
+
await commands[command](commandArgs);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error('Error:', error.message);
|
|
123
|
+
if (args.includes('--verbose')) {
|
|
124
|
+
console.error(error.stack);
|
|
125
|
+
}
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
console.error(`Unknown command: ${command}\n`);
|
|
130
|
+
commands.help();
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
main();
|
package/lib/{blob.js → blob.mjs}
RENAMED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* blob.
|
|
2
|
+
* blob.mjs
|
|
3
3
|
* Create SEA configuration JSON and prepare blob for injection.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { execFile } from 'child_process';
|
|
9
|
+
import { promisify } from 'util';
|
|
10
|
+
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* @typedef {Object} SeaBlobConfig
|
|
@@ -20,11 +24,11 @@ const path = require('path');
|
|
|
20
24
|
* Create the SEA configuration object for Node.js SEA tooling.
|
|
21
25
|
* @param {string} entryScript - Path to the bundled entry script
|
|
22
26
|
* @param {string} outputBlob - Output blob filename
|
|
23
|
-
* @param {
|
|
27
|
+
* @param {Array} assets - All assets to embed
|
|
24
28
|
* @param {Object} config - SEA configuration
|
|
25
29
|
* @returns {SeaBlobConfig}
|
|
26
30
|
*/
|
|
27
|
-
function createSeaConfig(entryScript, outputBlob, assets, config) {
|
|
31
|
+
export function createSeaConfig(entryScript, outputBlob, assets, config) {
|
|
28
32
|
const seaConfig = {
|
|
29
33
|
main: entryScript,
|
|
30
34
|
output: outputBlob,
|
|
@@ -51,10 +55,10 @@ function createSeaConfig(entryScript, outputBlob, assets, config) {
|
|
|
51
55
|
* This config file is consumed by `node --experimental-sea-config`.
|
|
52
56
|
* @param {SeaBlobConfig} seaConfig
|
|
53
57
|
* @param {string} outputPath - Path to write the config JSON
|
|
54
|
-
* @param {
|
|
58
|
+
* @param {Array} assets - Original asset entries
|
|
55
59
|
* @param {string} tempDir - Temporary directory for inline assets
|
|
56
60
|
*/
|
|
57
|
-
function writeSeaConfigJson(seaConfig, outputPath, assets, tempDir) {
|
|
61
|
+
export function writeSeaConfigJson(seaConfig, outputPath, assets, tempDir) {
|
|
58
62
|
// Node's SEA config expects asset values to be file paths (raw assets)
|
|
59
63
|
const jsonConfig = {
|
|
60
64
|
main: seaConfig.main,
|
|
@@ -89,11 +93,7 @@ function writeSeaConfigJson(seaConfig, outputPath, assets, tempDir) {
|
|
|
89
93
|
* @param {string} nodeBinary - Path to the Node.js binary to use
|
|
90
94
|
* @returns {Promise<void>}
|
|
91
95
|
*/
|
|
92
|
-
async function generateBlob(seaConfigPath, nodeBinary = process.execPath) {
|
|
93
|
-
const { execFile } = require('child_process');
|
|
94
|
-
const { promisify } = require('util');
|
|
95
|
-
const execFileAsync = promisify(execFile);
|
|
96
|
-
|
|
96
|
+
export async function generateBlob(seaConfigPath, nodeBinary = process.execPath) {
|
|
97
97
|
try {
|
|
98
98
|
await execFileAsync(nodeBinary, ['--experimental-sea-config', seaConfigPath]);
|
|
99
99
|
console.log('✓ SEA blob generated successfully');
|
|
@@ -101,9 +101,3 @@ async function generateBlob(seaConfigPath, nodeBinary = process.execPath) {
|
|
|
101
101
|
throw new Error(`Failed to generate SEA blob: ${error.message}`);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
module.exports = {
|
|
106
|
-
createSeaConfig,
|
|
107
|
-
writeSeaConfigJson,
|
|
108
|
-
generateBlob
|
|
109
|
-
};
|