new NodePackageBuilder()
Main class for building Node.js applications into single executable files using SEA (Single Executable Applications)
Supports cross-platform builds for Linux, macOS, and Windows
Methods
(async) build() → {Promise.<Array.<{platform: string, success: boolean, executable: string, path: string, buildId: string, error: string}>>}
Build executables for all configured platforms
Returns:
Promise that resolves to an array of build results
- Type
- Promise.<Array.<{platform: string, success: boolean, executable: string, path: string, buildId: string, error: string}>>
(async) buildForPlatform(platform) → {Promise.<{platform: string, success: boolean, executable: string, path: string, buildId: string}>}
Build executable for a specific platform
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform ('linux', 'darwin', or 'win32') |
Throws:
-
If build process fails
- Type
- Error
Returns:
Promise that resolves to build result
- Type
- Promise.<{platform: string, success: boolean, executable: string, path: string, buildId: string}>
checkNodeVersion()
Check if current Node.js version meets minimum requirements
Throws:
-
If Node.js version is too old
- Type
- Error
cleanup(files)
Clean up temporary files
Parameters:
Name | Type | Description |
---|---|---|
files |
Array.<string> | Array of file paths to clean up |
cleanupTempDir()
Clean up temporary build directory for this instance
(async) createExecutable(platform, executableName)
Create executable file for target platform by copying Node.js binary
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform |
executableName |
string | Name of the executable to create |
Throws:
-
If executable creation fails
- Type
- Error
createSeaConfig(platform) → {string}
Create SEA (Single Executable Application) configuration file for a platform
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform |
Returns:
Path to the created configuration file
- Type
- string
(async) downloadFile(url, filePath) → {Promise.<void>}
Download file from URL to local path using streaming
Parameters:
Name | Type | Description |
---|---|---|
url |
string | File URL to download |
filePath |
string | Destination file path |
Returns:
Promise that resolves when download completes
- Type
- Promise.<void>
(async) downloadNodeBinary(platform) → {Promise.<string>}
Download Node.js binary for target platform with caching support
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform |
Throws:
-
If download or extraction fails
- Type
- Error
Returns:
Promise that resolves to path of downloaded Node.js binary
- Type
- Promise.<string>
ensureTempDir()
Ensure temporary directories exist, creating them if necessary
(async) extractNodeBinary(archivePath, extractDir, platform, version) → {Promise.<void>}
Extract Node.js binary from archive file (ZIP for Windows, tar.gz for Unix)
Parameters:
Name | Type | Description |
---|---|---|
archivePath |
string | Path to archive file |
extractDir |
string | Directory to extract to |
platform |
string | Target platform |
version |
string | Node.js version |
Returns:
Promise that resolves when extraction completes
- Type
- Promise.<void>
(async) extractTarGz(tarPath, extractDir, version, platform) → {Promise.<void>}
Extract Node.js binary from tar.gz archive (Unix systems)
Parameters:
Name | Type | Description |
---|---|---|
tarPath |
string | Path to tar.gz file |
extractDir |
string | Directory to extract to |
version |
string | Node.js version |
platform |
string | Target platform |
Returns:
Promise that resolves when extraction completes
- Type
- Promise.<void>
(async) extractZip(zipPath, extractDir, version, platform) → {Promise.<void>}
Extract Node.js binary from ZIP archive (Windows)
Parameters:
Name | Type | Description |
---|---|---|
zipPath |
string | Path to ZIP file |
extractDir |
string | Directory to extract to |
version |
string | Node.js version |
platform |
string | Target platform |
Returns:
Promise that resolves when extraction completes
- Type
- Promise.<void>
generateBlob(configPath)
Generate blob file from SEA configuration using Node.js
Parameters:
Name | Type | Description |
---|---|---|
configPath |
string | Path to SEA configuration file |
Throws:
-
If blob generation fails
- Type
- Error
generateBuildId() → {string}
Generate a unique build identifier using timestamp and random bytes
Returns:
Unique build ID string
- Type
- string
getExecutableName(platform) → {string}
Get executable name for platform with appropriate extension
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform |
Returns:
Executable name with platform-specific extension
- Type
- string
getNodeDownloadUrl(version, platform) → {string}
Get download URL for Node.js binary for specific version and platform
Parameters:
Name | Type | Description |
---|---|---|
version |
string | Node.js version |
platform |
string | Target platform |
Throws:
-
If platform is unsupported
- Type
- Error
Returns:
Download URL for Node.js binary
- Type
- string
(async) getRecommendedNodeVersion() → {Promise.<string>}
Get recommended Node.js version from official registry with fallback
Returns:
Promise that resolves to recommended Node.js version string
- Type
- Promise.<string>
(async) injectBlob(platform, executableName, blobPath)
Inject blob into executable using postject tool
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform |
executableName |
string | Name of the executable |
blobPath |
string | Path to the blob file to inject |
Throws:
-
If blob injection fails
- Type
- Error
isVersionGreaterOrEqual(current, required) → {boolean}
Compare version strings to determine if current version meets requirements
Parameters:
Name | Type | Description |
---|---|---|
current |
string | Current version string |
required |
string | Required minimum version string |
Returns:
True if current version is greater than or equal to required
- Type
- boolean
(async) signExecutable(platform, executableName)
Sign executable for distribution (macOS and Windows)
Parameters:
Name | Type | Description |
---|---|---|
platform |
string | Target platform |
executableName |
string | Name of the executable to sign |
(async) verifyWindowsExecutable(executableName)
Verify Windows executable is working correctly and not in REPL mode
Parameters:
Name | Type | Description |
---|---|---|
executableName |
string | Name of the executable to verify |
Throws:
-
If executable is still in REPL mode
- Type
- Error
(static) cleanupAllTempDirs()
Clean up all temporary build directories from previous builds
(static) getSupportedPlatforms() → {Array.<string>}
Get list of supported target platforms
Returns:
Array of supported platform names
- Type
- Array.<string>
(static) validateMainFile(mainFile)
Validate that main file exists and is accessible
Parameters:
Name | Type | Description |
---|---|---|
mainFile |
string | Path to main file to validate |
Throws:
-
If main file is invalid or doesn't exist
- Type
- Error