-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathforge.config.js
More file actions
353 lines (312 loc) · 11.4 KB
/
forge.config.js
File metadata and controls
353 lines (312 loc) · 11.4 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
const path = require('path');
const fs = require('fs-extra');
const { execSync } = require('child_process');
const hasRpmbuild = (() => {
try {
execSync('which rpmbuild', { stdio: 'ignore' });
return true;
} catch {
return false;
}
})();
module.exports = {
hooks: {
packageAfterCopy: async (_config, buildPath) => {
console.log('🔧 Copying @libsql native modules...');
// Ruta de node_modules en el proyecto
const projectNodeModules = path.join(__dirname, 'node_modules');
// Ruta de node_modules en el paquete
const packageNodeModules = path.join(buildPath, 'node_modules');
// Crear directorio node_modules si no existe
await fs.ensureDir(packageNodeModules);
// Función recursiva para obtener todas las dependencias de un paquete
const getAllDependencies = async (packageName, visited = new Set()) => {
if (visited.has(packageName)) return visited;
visited.add(packageName);
const pkgJsonPath = path.join(projectNodeModules, packageName, 'package.json');
if (!await fs.pathExists(pkgJsonPath)) return visited;
try {
const pkgJson = await fs.readJson(pkgJsonPath);
const deps = { ...pkgJson.dependencies, ...pkgJson.optionalDependencies };
for (const dep of Object.keys(deps || {})) {
await getAllDependencies(dep, visited);
}
} catch (error) {
console.log(` ⚠ Error reading ${packageName}/package.json`);
}
return visited;
};
// Copiar TODOS los paquetes @libsql/*
const libsqlDir = path.join(projectNodeModules, '@libsql');
const destLibsqlDir = path.join(packageNodeModules, '@libsql');
if (await fs.pathExists(libsqlDir)) {
console.log(' ✓ Copying all @libsql/* packages...');
await fs.copy(libsqlDir, destLibsqlDir, { overwrite: true, dereference: true });
const packages = await fs.readdir(libsqlDir);
packages.forEach(pkg => console.log(` - @libsql/${pkg}`));
} else {
console.log(' ⚠ @libsql directory not found');
}
// Obtener TODAS las dependencias de @libsql/client recursivamente
console.log(' ✓ Finding all @libsql/client dependencies...');
const allDeps = await getAllDependencies('@libsql/client');
console.log(' ✓ Copying dependencies...');
for (const dep of allDeps) {
if (dep.startsWith('@libsql/')) continue; // Ya copiado arriba
const srcPath = path.join(projectNodeModules, dep);
const destPath = path.join(packageNodeModules, dep);
if (await fs.pathExists(srcPath)) {
console.log(` - ${dep}`);
await fs.copy(srcPath, destPath, { overwrite: true, dereference: true });
}
}
// Copiar update-electron-app y sus dependencias (macOS)
console.log(' ✓ Finding update-electron-app dependencies...');
const updateAppDeps = await getAllDependencies('update-electron-app');
for (const dep of updateAppDeps) {
if (allDeps.has(dep)) continue; // Ya copiado
const srcPath = path.join(projectNodeModules, dep);
const destPath = path.join(packageNodeModules, dep);
if (await fs.pathExists(srcPath)) {
console.log(` - ${dep}`);
await fs.copy(srcPath, destPath, { overwrite: true, dereference: true });
}
}
// Copiar electron-updater y sus dependencias (Windows NSIS)
console.log(' ✓ Finding electron-updater dependencies...');
const electronUpdaterDeps = await getAllDependencies('electron-updater');
for (const dep of electronUpdaterDeps) {
if (allDeps.has(dep) || updateAppDeps.has(dep)) continue; // Ya copiado
const srcPath = path.join(projectNodeModules, dep);
const destPath = path.join(packageNodeModules, dep);
if (await fs.pathExists(srcPath)) {
console.log(` - ${dep}`);
await fs.copy(srcPath, destPath, { overwrite: true, dereference: true });
}
}
// Copiar winston (external - requerido por mcp-use Logger en runtime)
console.log(' ✓ Finding winston dependencies...');
const winstonDeps = await getAllDependencies('winston');
for (const dep of winstonDeps) {
if (allDeps.has(dep) || updateAppDeps.has(dep)) continue;
const srcPath = path.join(projectNodeModules, dep);
const destPath = path.join(packageNodeModules, dep);
if (await fs.pathExists(srcPath)) {
console.log(` - ${dep}`);
await fs.copy(srcPath, destPath, { overwrite: true, dereference: true });
}
}
// Copiar winston-daily-rotate-file (external - requerido por logging system)
console.log(' ✓ Finding winston-daily-rotate-file dependencies...');
const winstonRotateDeps = await getAllDependencies('winston-daily-rotate-file');
for (const dep of winstonRotateDeps) {
if (allDeps.has(dep) || updateAppDeps.has(dep) || winstonDeps.has(dep)) continue;
const srcPath = path.join(projectNodeModules, dep);
const destPath = path.join(packageNodeModules, dep);
if (await fs.pathExists(srcPath)) {
console.log(` - ${dep}`);
await fs.copy(srcPath, destPath, { overwrite: true, dereference: true });
}
}
// NOTE: mcp-use bundled by Vite, only winston kept external for Logger
console.log(`✅ Copied external dependencies successfully`);
}
},
packagerConfig: {
extraResource: [
'./resources/default-skills'
],
asar: {
unpack: '**/@libsql/**/*.node'
},
name: 'Levante',
executableName: 'Levante',
appBundleId: 'com.levante.app',
icon: './resources/icons/icon', // Forge will add appropriate extension (.icns/.ico)
// macOS Code Signing
osxSign: process.env.CI ? {
// In CI: import sets up keychain, sign will find the cert automatically
'hardened-runtime': true,
entitlements: 'build/entitlements.mac.plist',
'entitlements-inherit': 'build/entitlements.mac.inherit.plist',
'signature-flags': 'library',
'optionsForFile': (_filePath) => {
// Sign all native modules with same entitlements
return {
hardenedRuntime: true,
entitlements: 'build/entitlements.mac.inherit.plist'
}
}
} : {
// Local: use specific identity
identity: 'Developer ID Application',
'hardened-runtime': true,
entitlements: 'build/entitlements.mac.plist',
'entitlements-inherit': 'build/entitlements.mac.inherit.plist',
'signature-flags': 'library',
'optionsForFile': (_filePath) => {
// Sign all native modules with same entitlements
return {
hardenedRuntime: true,
entitlements: 'build/entitlements.mac.inherit.plist'
}
}
},
// macOS Notarization
osxNotarize: process.env.APPLE_ID ? {
tool: 'notarytool',
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID
} : undefined,
// Windows specific
win32metadata: {
CompanyName: 'Levante Team',
FileDescription: 'Levante - AI Chat Application',
OriginalFilename: 'Levante.exe',
ProductName: 'Levante',
InternalName: 'Levante'
}
},
rebuildConfig: {},
makers: [
// macOS makers
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
config: {}
},
{
name: '@electron-forge/maker-dmg',
config: {
format: 'ULFO',
icon: './resources/icons/icon.icns',
contents: (opts) => {
return [
{
x: 130,
y: 220,
type: 'file',
path: opts.appPath
},
{
x: 410,
y: 220,
type: 'link',
path: '/Applications'
}
];
}
}
},
// Windows makers
{
name: '@felixrieseberg/electron-forge-maker-nsis',
config: {
oneClick: false,
perMachine: false,
allowToChangeInstallationDirectory: true,
installerIcon: './resources/icons/icon.ico',
uninstallerIcon: './resources/icons/icon.ico',
// Disable electron-builder's own publish — Electron Forge handles publishing.
// publish: 'never' is ignored by this maker; getAppBuilderConfig is the correct way.
getAppBuilderConfig: async () => ({ publish: null }),
// Code signing will be added in a future phase
// certificateFile: './cert.pfx',
// certificatePassword: process.env.WIN_CSC_KEY_PASSWORD,
}
},
{
name: '@electron-forge/maker-zip',
platforms: ['win32'],
config: {}
},
// Linux makers
...(process.env.FORGE_TARGET === 'AppImage'
? [
{
name: '@reforged/maker-appimage',
config: {
options: {
name: 'levante',
bin: 'Levante',
productName: 'Levante',
genericName: 'AI Chat Application',
description: 'A friendly, private desktop chat app with AI and MCP integration',
categories: ['Utility', 'Network'],
maintainer: 'Levante Team',
homepage: 'https://www.levanteapp.com',
icon: './resources/icons/icon.png'
}
}
}
]
: [
{
name: '@electron-forge/maker-deb',
config: {
options: {
name: 'levante',
bin: 'Levante',
productName: 'Levante',
genericName: 'AI Chat Application',
description: 'A friendly, private desktop chat app with AI and MCP integration',
categories: ['Utility', 'Network'],
maintainer: 'Levante Team',
homepage: 'https://www.levanteapp.com',
icon: './resources/icons/icon.png'
}
}
},
...(hasRpmbuild ? [{
name: '@electron-forge/maker-rpm',
config: {
options: {
name: 'levante',
bin: 'Levante',
productName: 'Levante',
genericName: 'AI Chat Application',
description: 'A friendly, private desktop chat app with AI and MCP integration',
categories: ['Utility', 'Network'],
homepage: 'https://www.levanteapp.com',
icon: './resources/icons/icon.png'
}
}
}] : []),
{
name: '@electron-forge/maker-zip',
platforms: ['linux'],
config: {}
}
]
),
],
plugins: [
// Removido auto-unpack-natives porque ASAR está desactivado
{
name: '@electron-forge/plugin-vite',
config: {
// Vite config for main process
build: [
{
entry: 'src/main/main.ts',
config: 'vite.main.config.ts',
target: 'main'
},
{
entry: 'src/preload/preload.ts',
config: 'vite.preload.config.ts',
target: 'preload'
}
],
// Vite config for renderer process
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.ts'
}
]
}
}
]
};