Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ npm run storybook
`npx @electron/asar extract app.asar <destfolder>` can be used to determine the contents of asar

`npm run package` followed by `mkdir outAsar` and `npx @electron/asar extract ./out/NiceNode-darwin-arm64/NiceNode.app/Contents/Resources/app.asar outAsar` on macOS

## Debugging update server (macOS and Windows)
`curl https://update.electronjs.org/NiceNode/test-nice-node-updater/darwin-arm64/5.2.0-alpha` returns if there is an update detected by the update server. The end of the URL is <platform>-<arch>/<version>.

Also, NiceNode app auto update logs are in ../NiceNode/logs/autoUpdater*.log.

50 changes: 28 additions & 22 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ const packagerConfig: ForgePackagerOptions = {
// ignore: [ /stories/, /__tests__/, /.storybook/, /storybook/, /storybook-static/ ],
};

const commonLinuxConfig = {
icon: {
scalable: path.resolve(iconDir, 'icon.svg'),
// scalable: './assets/icons/icon.svg',
'1024x1024': path.resolve(iconDir, '1024x1024.png'),
'512x512': path.resolve(iconDir, '512x512.png'),
'256x256': path.resolve(iconDir, '256x256.png'),
'128x128': path.resolve(iconDir, '128x128.png'),
'96x96': path.resolve(iconDir, '96x96.png'),
'64x64': path.resolve(iconDir, '64x64.png'),
'48x48': path.resolve(iconDir, '48x48.png'),
'32x32': path.resolve(iconDir, '32x32.png'),
'16x16': path.resolve(iconDir, '16x16.png'),
},
executableName: 'nice-node',
productName: 'NiceNode',
productDescription: "By running a node you become part of a global movement to decentralize a world of information. Prevent leaking your personal data to third party nodes. Ensure access when you need it, and don't be censored. Decentralization starts with you. Voice your choice, help your peers.",
maintainer: "NiceNode LLC <[email protected]>",
categories: ['Utility', 'System', 'Network', 'Development'],
mimeType: ['application/x-nice-node', 'x-scheme-handler/nice-node'],
}

// skip signing & notarizing on local builds
console.log("process.env.CI: ", process.env.CI);
if(process.env.CI && process.env.NO_CODE_SIGNING !== 'true') {
Expand Down Expand Up @@ -67,31 +89,15 @@ const config: ForgeConfig = {
}),
},
new MakerZIP({}),
new MakerRpm({}, ['linux']),
{
name: '@electron-forge/maker-rpm',
platforms: ['linux'],
config: commonLinuxConfig
},
{
name: '@electron-forge/maker-deb',
platforms: ['linux'],
config: {
icon: {
scalable: path.resolve(iconDir, 'icon.svg'),
// scalable: './assets/icons/icon.svg',
'1024x1024': path.resolve(iconDir, '1024x1024.png'),
'512x512': path.resolve(iconDir, '512x512.png'),
'256x256': path.resolve(iconDir, '256x256.png'),
'128x128': path.resolve(iconDir, '128x128.png'),
'96x96': path.resolve(iconDir, '96x96.png'),
'64x64': path.resolve(iconDir, '64x64.png'),
'48x48': path.resolve(iconDir, '48x48.png'),
'32x32': path.resolve(iconDir, '32x32.png'),
'16x16': path.resolve(iconDir, '16x16.png'),
},
executableName: 'nice-node',
productName: 'NiceNode',
productDescription: "By running a node you become part of a global movement to decentralize a world of information. Prevent leaking your personal data to third party nodes. Ensure access when you need it, and don't be censored. Decentralization starts with you. Voice your choice, help your peers.",
maintainer: "NiceNode LLC <[email protected]>",
categories: ['Utility', 'System', 'Network', 'Development'],
mimeType: ['application/x-nice-node', 'x-scheme-handler/nice-node'],
}
config: commonLinuxConfig
},
new MakerDMG({
background: './assets/dmg-background.tiff',
Expand Down
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nice-node",
"version": "5.1.2-alpha",
"version": "5.5.2-alpha",
"description": "Run a node at home, the easy way.",
"homepage": "https://nicenode.xyz",
"productName": "NiceNode",
Expand Down Expand Up @@ -109,6 +109,7 @@
"react-select": "^5.8.0",
"systeminformation": "^5.21.24",
"throttle-debounce": "^5.0.0",
"tiny-typed-emitter": "^2.1.0",
"update-electron-app": "^3.0.0",
"uuid": "^9.0.0",
"winston": "^3.13.0",
Expand Down
13 changes: 11 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const RESOURCES_PATH = app.isPackaged
: path.join(__dirname, '..', '..', 'assets'); // starting point: .vite/build/main.js

const getAssetPath = (...paths: string[]): string => {
logger.log('RESOURCES_PATH: ', RESOURCES_PATH);
logger.info('RESOURCES_PATH: ', RESOURCES_PATH);
return path.join(RESOURCES_PATH, ...paths);
};

Expand Down Expand Up @@ -158,7 +158,12 @@ export const createWindow = async () => {

// App auto updates
updater.initialize(mainWindow);
// updater.checkForUpdates(false);
// disabled in dev env
if (!isDevelopment) {
updater.checkForUpdates(false);
} else {
logger.info('updater.checkForUpdates() skipped. Disabled in development env');
}

menuBuilder = new MenuBuilder(mainWindow);
menuBuilder.buildMenu();
Expand Down Expand Up @@ -195,6 +200,10 @@ export const fullQuit = () => {
app.quit();
};

export const setFullQuitForNextQuit = (_isNextQuitAFullQuit: boolean) => {
isFullQuit = _isNextQuitAFullQuit;
};

// Emitted on app.quit() after all windows have been closed
app.on('will-quit', (e) => {
// Remove dev env check to test background. This is to prevent
Expand Down
66 changes: 66 additions & 0 deletions src/main/nn-auto-updater/findPackageManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { exec as execCallback } from 'node:child_process';
import { promisify } from 'node:util';

const exec = promisify(execCallback);

export type PackageType = "deb" | "rpm";
export type PackageManager = "dpkg" | "dnf" | "yum" | "zypper";

interface PackageManagerMap {
[key: string]: PackageManager;
}

interface PackageManagerToTypeMap {
[key: string]: PackageType;
}

const packageManagers: PackageManagerMap = {
"apt-get": "dpkg", // "deb (apt)",
dnf: "dnf", // "rpm (dnf)",
yum: "yum", // "rpm (yum)",
// pacman: "pacman",
zypper: "zypper", // "rpm (zypper)"
};

const packageTypes: PackageManagerToTypeMap = {
"apt-get": "deb", // "deb (apt)",
dnf: "rpm", // "rpm (dnf)",
yum: "rpm", // "rpm (yum)",
// pacman: "pacman",
zypper: "rpm", // "rpm (zypper)"
};

export const findPackageManager = async (): Promise<PackageManager | null> => {
for (const pkgManager of Object.keys(packageManagers)) {
try {
const { stdout } = await exec(`command -v ${pkgManager}`);
if (stdout.trim()) {
return packageManagers[pkgManager];
}
} catch (error) {
// Command not found, continue checking the next
}
}
// "Package manager not found.";
return null;
}

export const findPackageType = async (): Promise<PackageType | null> => {
for (const pkgManager of Object.keys(packageManagers)) {
try {
const { stdout } = await exec(`command -v ${pkgManager}`);
if (stdout.trim()) {
return packageTypes[pkgManager];
}
} catch (error) {
// Command not found, continue checking the next
}
}
// "Package manager not found.";
return null;
}

// (async () => {
// const result = await findPackageManager();
// console.log("+++++++++++++++++++++++++", result);
// })();
Loading