Skip to content

Commit

Permalink
Upgraded dependencies (including using Electron 30) and using ES Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohamedin committed May 17, 2024
1 parent d3206b8 commit 3f6b5d8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 37 deletions.
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
"name": "draw.io",
"version": "24.4.0",
"description": "draw.io desktop",
"exports": "./src/main/electron.js",
"type": "module",
"main": "src/main/electron.js",
"engines": {
"node": ">=20"
},
"scripts": {
"start": "electron .",
"sync": "node ./sync.js",
"sync": "node ./sync.cjs",
"release-win": "electron-builder --config electron-builder-win.json --publish always",
"release-win32": "electron-builder --config electron-builder-win32.json --publish always",
"release-appx": "electron-builder --config electron-builder-appx.json --publish always",
Expand All @@ -29,22 +34,22 @@
},
"homepage": "https://github.com/jgraph/drawio",
"dependencies": {
"commander": "^11.1.0",
"commander": "^12.0.0",
"compression": "^1.7.4",
"crc": "^4.3.2",
"electron-context-menu": "^3.6.1",
"electron-log": "^5.0.2",
"electron-progressbar": "^2.1.0",
"electron-store": "^8.1.0",
"electron-updater": "^6.1.7",
"electron-context-menu": "^4.0.0",
"electron-log": "^5.1.4",
"electron-progressbar": "^2.2.1",
"electron-store": "^9.0.0",
"electron-updater": "^6.1.8",
"pdf-lib": "^1.17.1"
},
"devDependencies": {
"@electron/fuses": "^1.7.0",
"@electron/notarize": "^2.2.0",
"dotenv": "^16.3.1",
"electron": "28.1.0",
"@electron/fuses": "^1.8.0",
"@electron/notarize": "^2.3.2",
"dotenv": "^16.4.5",
"electron": "30.0.6",
"electron-builder": "^24.9.1",
"sumchecker": "^3.0.1"
}
}
}
8 changes: 3 additions & 5 deletions src/main/disableUpdate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module.exports = {
disableUpdate: function()
{
return false;
}
export function disableUpdate()
{
return false;
}
41 changes: 22 additions & 19 deletions src/main/electron.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
const fs = require('fs')
const fsProm = require('fs/promises');
const os = require('os');
const path = require('path')
const url = require('url')
const {Menu: menu, shell, dialog, session, screen,
clipboard, nativeImage, ipcMain, app, BrowserWindow} = require('electron')
const crc = require('crc');
const zlib = require('zlib');
const log = require('electron-log')
const program = require('commander')
const {autoUpdater} = require("electron-updater")
const PDFDocument = require('pdf-lib').PDFDocument;
const Store = require('electron-store');
import fs from 'fs';
import { promises as fsProm } from 'fs';
import path from 'path';
import url from 'url';
import {Menu as menu, shell, dialog, session, screen,
clipboard, nativeImage, ipcMain, app, BrowserWindow} from 'electron';
import crc from 'crc';
import zlib from 'zlib';
import log from'electron-log';
import { program } from 'commander';
import elecUpPkg from 'electron-updater';
const {autoUpdater} = elecUpPkg;
import {PDFDocument} from 'pdf-lib';
import Store from 'electron-store';
const store = new Store();
const ProgressBar = require('electron-progressbar');
const contextMenu = require('electron-context-menu');
const spawn = require('child_process').spawn;
const disableUpdate = require('./disableUpdate').disableUpdate() ||
import ProgressBar from 'electron-progressbar';
import contextMenu from 'electron-context-menu';
import {spawn} from 'child_process';
import {disableUpdate as disUpPkg} from './disableUpdate.js';
const disableUpdate = disUpPkg() ||
process.env.DRAWIO_DISABLE_UPDATE === 'true' ||
fs.existsSync('/.flatpak-info'); //This file indicates running in flatpak sandbox
autoUpdater.logger = log
autoUpdater.logger.transports.file.level = 'error'
autoUpdater.logger.transports.console.level = 'error'
autoUpdater.autoDownload = false

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

//Command option to disable hardware acceleration
if (process.argv.indexOf('--disable-acceleration') !== -1)
{
Expand Down Expand Up @@ -336,7 +339,7 @@ function isPluginsEnabled()
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', e =>
app.whenReady().then(() =>
{
// Enforce our CSP on all contents
session.defaultSession.webRequest.onHeadersReceived((details, callback) =>
Expand Down
2 changes: 1 addition & 1 deletion sync.js → sync.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ pj.version = ver

fs.writeFileSync(appjsonpath, JSON.stringify(pj, null, 2), 'utf8')
//Enable/disable updates
fs.writeFileSync(disableUpdatePath, 'module.exports = { disableUpdate: function() { return ' + (process.argv[2] == 'disableUpdate'? 'true' : 'false') + ';}}', 'utf8');
fs.writeFileSync(disableUpdatePath, 'export function disableUpdate() { return ' + (process.argv[2] == 'disableUpdate'? 'true' : 'false') + ';}', 'utf8');

1 comment on commit 3f6b5d8

@davidjgraph
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed.

Please sign in to comment.