Skip to content

Commit 80cfde4

Browse files
committed
Update Electron build configuration and dependencies
This commit introduces several updates to the Electron build configuration and dependencies. Key changes include: ### Key Updates - Added `warningsAsErrors` option in `electron-builder.json` to prevent warnings from being treated as errors during the build process. - Included `unbzip2-stream` as a new dependency in `package.json` and `package-lock.json` for handling bzip2 file extraction. - Modified the `after-pack.cjs` script to use `unbzip2-stream` for extracting archives instead of `gunzip-maybe`. - Cleaned up the uninstall script in `installer.nsh` to improve the removal of Conda environments and user-level configurations. These changes enhance the build process and improve the handling of compressed files in the Electron application.
1 parent 53e1658 commit 80cfde4

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

electron/electron-builder.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"allowToChangeInstallationDirectory": true,
110110
"createDesktopShortcut": true,
111111
"runAfterFinish": true,
112+
"warningsAsErrors": false,
112113
"include": "resources/installer.nsh",
113114
"artifactName": "${productName}-Setup-${version}.${ext}"
114115
},

electron/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

electron/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"ts-node": "^10.9.2",
5050
"typescript": "^5.3.3",
5151
"vite": "^6.3.5",
52-
"vite-plugin-electron": "^0.29.0"
52+
"vite-plugin-electron": "^0.29.0",
53+
"unbzip2-stream": "^1.4.3"
5354
},
5455
"optionalDependencies": {
5556
"dmg-license": "^1.0.11"
@@ -77,4 +78,4 @@
7778
"type": "git",
7879
"url": "https://github.com/nodetool-ai/nodetool.git"
7980
}
80-
}
81+
}

electron/resources/installer.nsh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
!include "LogicLib.nsh"
22

3-
Var NtTempPath
4-
53
!macro _RemoveDirIfExists DIR_PATH
64
IfFileExists "${DIR_PATH}\*.*" 0 +4
75
DetailPrint "Removing ${DIR_PATH}"
@@ -18,28 +16,35 @@ Var NtTempPath
1816
!macro customUnInstall
1917
DetailPrint "Removing Nodetool Conda environment and settings"
2018

19+
; Resolve machine-wide ProgramData path, if available
20+
ExpandEnvStrings $R0 "%PROGRAMDATA%"
21+
StrCmp $R0 "" skipCommonConda
22+
!insertmacro _RemoveDirIfExists "$R0\nodetool\conda_env"
23+
skipCommonConda:
24+
2125
; Remove Conda environments in common locations
22-
!insertmacro _RemoveDirIfExists "$COMMON_APPDATA\nodetool\conda_env"
2326
!insertmacro _RemoveDirIfExists "$APPDATA\nodetool\conda_env"
2427
!insertmacro _RemoveDirIfExists "$LOCALAPPDATA\nodetool\conda_env"
2528

2629
; Clean up paths relative to the current user profile if available
27-
ExpandEnvStrings $NtTempPath "%USERPROFILE%"
28-
StrCmp $NtTempPath "" skipUserPaths
29-
!insertmacro _RemoveDirIfExists "$NtTempPath\.nodetool\conda_env"
30-
!insertmacro _RemoveDirIfExists "$NtTempPath\.local\share\nodetool\conda_env"
31-
!insertmacro _RemoveDirIfExists "$NtTempPath\.config\nodetool"
30+
ExpandEnvStrings $R1 "%USERPROFILE%"
31+
StrCmp $R1 "" skipUserPaths
32+
!insertmacro _RemoveDirIfExists "$R1\.nodetool\conda_env"
33+
!insertmacro _RemoveDirIfExists "$R1\.local\share\nodetool\conda_env"
34+
!insertmacro _RemoveDirIfExists "$R1\.config\nodetool"
3235
skipUserPaths:
3336

3437
; Clean up user-level configuration and caches
3538
!insertmacro _RemoveFileIfExists "$APPDATA\nodetool\settings.yaml"
3639
!insertmacro _RemoveDirIfExists "$APPDATA\nodetool\logs"
3740

3841
; Remove remaining Nodetool directories if empty
39-
!insertmacro _RemoveDirIfExists "$COMMON_APPDATA\nodetool"
42+
StrCmp $R0 "" skipCommonRoot
43+
!insertmacro _RemoveDirIfExists "$R0\nodetool"
44+
skipCommonRoot:
4045
!insertmacro _RemoveDirIfExists "$APPDATA\nodetool"
4146
!insertmacro _RemoveDirIfExists "$LOCALAPPDATA\nodetool"
42-
StrCmp $NtTempPath "" doneUserHome
43-
!insertmacro _RemoveDirIfExists "$NtTempPath\.nodetool"
47+
StrCmp $R1 "" doneUserHome
48+
!insertmacro _RemoveDirIfExists "$R1\.nodetool"
4449
doneUserHome:
4550
!macroend

electron/scripts/after-pack.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const os = require("os");
55
const https = require("https");
66
const { pipeline } = require("stream/promises");
77
const tar = require("tar-fs");
8-
const gunzip = require("gunzip-maybe");
8+
const bz2 = require("unbzip2-stream");
99

1010
const MICROMAMBA_API_BASE = "https://micro.mamba.pm/api/micromamba";
1111
const MICROMAMBA_DIR_NAME = "micromamba";
@@ -15,8 +15,8 @@ const MICROMAMBA_BINARY_NAME = {
1515
};
1616

1717
const ARCH_MAPPING = {
18-
0: "x64",
19-
1: "ia32",
18+
0: "ia32",
19+
1: "x64",
2020
2: "armv7l",
2121
3: "arm64",
2222
4: "universal",
@@ -102,7 +102,7 @@ function downloadFile(url, destinationPath) {
102102
async function extractArchive(archivePath, destinationDir) {
103103
await fsp.mkdir(destinationDir, { recursive: true });
104104
const extractStream = tar.extract(destinationDir);
105-
await pipeline(fs.createReadStream(archivePath), gunzip(), extractStream);
105+
await pipeline(fs.createReadStream(archivePath), bz2(), extractStream);
106106
}
107107

108108
async function findBinary(startDir, binaryName) {

0 commit comments

Comments
 (0)