-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
248 lines (214 loc) · 6.96 KB
/
index.d.ts
File metadata and controls
248 lines (214 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/**
* TypeScript definitions for node-package-builder
*/
export interface BuildOptions {
/** Main JavaScript file to build (default: 'index.js') */
main?: string;
/** Output executable name (default: 'app') */
output?: string;
/** Disable experimental SEA warning (default: true) */
disableExperimentalSEAWarning?: boolean;
/** Enable snapshot support (default: false) */
useSnapshot?: boolean;
/** Enable code cache (default: false) */
useCodeCache?: boolean;
/** Assets to include in the executable */
assets?: Record<string, string>;
/** Target platforms to build for (default: ['linux', 'darwin', 'win32']) */
platforms?: Platform[];
/** Temporary directory for build files */
tempDir?: string;
}
export type Platform = 'linux' | 'darwin' | 'win32';
export interface BuildResult {
/** Target platform */
platform: Platform;
/** Whether the build was successful */
success: boolean;
/** Name of the generated executable (if successful) */
executable?: string;
/** Full path to the generated executable (if successful) */
path?: string;
/** Unique build identifier (if successful) */
buildId?: string;
/** Error message (if failed) */
error?: string;
}
/**
* Main class for building Node.js applications into single executable files
*/
export declare class NodePackageBuilder {
/** Build configuration options */
readonly options: Required<BuildOptions>;
/** Unique identifier for this build session */
readonly buildId: string;
/** Temporary build directory path */
readonly tempBuildDir: string;
/**
* Create a new NodePackageBuilder instance
* @param options - Build configuration options
*/
constructor(options?: BuildOptions);
/**
* Build executables for all configured platforms
* @returns Promise that resolves to an array of build results
*/
build(): Promise<BuildResult[]>;
/**
* Build executable for a specific platform
* @param platform - Target platform
* @returns Promise that resolves to build result
*/
buildForPlatform(platform: Platform): Promise<BuildResult>;
/**
* Generate a unique build identifier
* @returns Unique build ID string
*/
generateBuildId(): string;
/**
* Ensure temporary directories exist
*/
ensureTempDir(): void;
/**
* Check if current Node.js version meets requirements
* @throws Error if Node.js version is too old
*/
checkNodeVersion(): void;
/**
* Compare version strings
* @param current - Current version
* @param required - Required version
* @returns True if current version is greater than or equal to required
*/
isVersionGreaterOrEqual(current: string, required: string): boolean;
/**
* Create SEA configuration file for a platform
* @param platform - Target platform
* @returns Path to the created configuration file
*/
createSeaConfig(platform: Platform): string;
/**
* Generate blob file from configuration
* @param configPath - Path to SEA configuration file
* @throws Error if blob generation fails
*/
generateBlob(configPath: string): void;
/**
* Create executable file for target platform
* @param platform - Target platform
* @param executableName - Name of the executable
*/
createExecutable(platform: Platform, executableName: string): Promise<void>;
/**
* Inject blob into executable
* @param platform - Target platform
* @param executableName - Name of the executable
* @param blobPath - Path to the blob file
*/
injectBlob(platform: Platform, executableName: string, blobPath: string): Promise<void>;
/**
* Verify Windows executable is working correctly
* @param executableName - Name of the executable
*/
verifyWindowsExecutable(executableName: string): Promise<void>;
/**
* Sign executable for distribution
* @param platform - Target platform
* @param executableName - Name of the executable
*/
signExecutable(platform: Platform, executableName: string): Promise<void>;
/**
* Get executable name for platform
* @param platform - Target platform
* @returns Executable name with appropriate extension
*/
getExecutableName(platform: Platform): string;
/**
* Download Node.js binary for target platform
* @param platform - Target platform
* @returns Path to downloaded Node.js binary
*/
downloadNodeBinary(platform: Platform): Promise<string>;
/**
* Get recommended Node.js version
* @returns Promise that resolves to version string
*/
getRecommendedNodeVersion(): Promise<string>;
/**
* Get download URL for Node.js binary
* @param version - Node.js version
* @param platform - Target platform
* @returns Download URL
*/
getNodeDownloadUrl(version: string, platform: Platform): string;
/**
* Download file from URL
* @param url - File URL
* @param filePath - Destination file path
*/
downloadFile(url: string, filePath: string): Promise<void>;
/**
* Extract Node.js binary from archive
* @param archivePath - Path to archive file
* @param extractDir - Extraction directory
* @param platform - Target platform
* @param version - Node.js version
*/
extractNodeBinary(archivePath: string, extractDir: string, platform: Platform, version: string): Promise<void>;
/**
* Extract Node.js binary from ZIP archive (Windows)
* @param zipPath - Path to ZIP file
* @param extractDir - Extraction directory
* @param version - Node.js version
* @param platform - Target platform
*/
extractZip(zipPath: string, extractDir: string, version: string, platform: Platform): Promise<void>;
/**
* Extract Node.js binary from tar.gz archive (Unix)
* @param tarPath - Path to tar.gz file
* @param extractDir - Extraction directory
* @param version - Node.js version
* @param platform - Target platform
*/
extractTarGz(tarPath: string, extractDir: string, version: string, platform: Platform): Promise<void>;
/**
* Clean up temporary files
* @param files - Array of file paths to clean up
*/
cleanup(files: string[]): void;
/**
* Clean up temporary build directory
*/
cleanupTempDir(): void;
/**
* Clean up all temporary build directories
*/
static cleanupAllTempDirs(): void;
/**
* Get list of supported platforms
* @returns Array of supported platform names
*/
static getSupportedPlatforms(): Platform[];
/**
* Validate that main file exists and is accessible
* @param mainFile - Path to main file
* @throws Error if main file is invalid
*/
static validateMainFile(mainFile: string): void;
}
export default NodePackageBuilder;
/**
* Get list of supported platforms
* @returns Array of supported platform names
*/
export declare function getSupportedPlatforms(): Platform[];
/**
* Validate that main file exists and is accessible
* @param mainFile - Path to main file
* @throws Error if main file is invalid
*/
export declare function validateMainFile(mainFile: string): void;
/**
* Clean up all temporary build directories
*/
export declare function cleanupAllTempDirs(): void;