Skip to content

Commit 9c9d369

Browse files
authored
chore: cleaning + major versions upgrade (#147)
* chore: cleaning + major versions upgrade (typescript, vite, jest, eslint, electron-chromedriver, prettier) * chore: converted to ESM imports + get-port v5 to v7 + cleaned some imports * fix: better ESM __dirname * fix: eslint migrate from .eslintrc to eslint.config.js * wip: jest typescript esm + update electron context menu * wip: jest typescript esm + update electron-store * wip: jest electron mock * chore: upgrade electron to v32 * fix: preload has to end with .mjs in ESM mode + update deps + cleaning unused imports + more ESM conversion * fix: convert notarize.js to ESM modules * fix: rebased on main * wip: why?? * fix: node v20 minimum dependency * Revert "wip: why??" This reverts commit 3193381. * fix: node v20 minimum dependency
1 parent 66af0fe commit 9c9d369

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+7182
-5794
lines changed

.github/workflows/run-plugin-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Use Node.js
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: 18.x
17+
node-version: 20.x
1818
- name: Install dependencies
1919
working-directory: ./resources/js/
2020
run: npm install

.github/workflows/run-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
- name: Checkout code
3838
uses: actions/checkout@v4
3939

40+
- name: Use Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: 20.x
44+
4045
- name: Setup PHP
4146
uses: shivammathur/setup-php@v2
4247
with:

resources/js/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.idea
22
node_modules
3-
out
3+
out

resources/js/build/notarize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const {notarize} = require('@electron/notarize')
1+
import { notarize } from '@electron/notarize';
22

3-
module.exports = async (context) => {
3+
export default async (context) => {
44
if (process.platform !== 'darwin') return
55

66
console.log('aftersign hook triggered, start to notarize app.')

resources/js/electron-builder.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
const os = require('os');
2-
const { join } = require("path");
3-
const { mkdtempSync } = require("fs");
4-
const { copySync, removeSync, writeJsonSync } = require("fs-extra");
1+
import os from 'os';
2+
import { join } from 'path';
3+
import { mkdtempSync } from 'fs';
4+
5+
// Workaround for CommonJS module
6+
import fs_extra from 'fs-extra';
7+
const { copySync, removeSync, writeJsonSync } = fs_extra;
58

69
const isBuilding = process.env.NATIVEPHP_BUILDING;
710
const appId = process.env.NATIVEPHP_APP_ID;
@@ -54,7 +57,7 @@ if (isBuilding) {
5457
console.log();
5558

5659
try {
57-
const appPath = join(__dirname, 'resources', 'app');
60+
const appPath = join(import.meta.dirname, 'resources', 'app');
5861

5962
removeSync(appPath);
6063

@@ -122,7 +125,7 @@ if (isBuilding) {
122125

123126
}
124127

125-
module.exports = {
128+
export default {
126129
appId: appId,
127130
productName: appName,
128131
directories: {

resources/js/electron-plugin/.eslintrc

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
module.exports = {
1+
export default {
22
presets: [
3-
'@babel/preset-typescript',
3+
['@babel/preset-env', {targets: {node: 'current'}}],
4+
'@babel/preset-typescript',
45
],
56
};

resources/js/electron-plugin/dist/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
88
});
99
};
1010
import { app } from "electron";
11-
import { autoUpdater } from "electron-updater";
12-
import state from "./server/state";
11+
import { initialize } from "@electron/remote/main/index.js";
12+
import state from "./server/state.js";
1313
import { electronApp, optimizer } from "@electron-toolkit/utils";
14-
import { retrieveNativePHPConfig, retrievePhpIniSettings, runScheduler, startAPI, startPhpApp, } from "./server";
15-
import { notifyLaravel } from "./server/utils";
14+
import { retrieveNativePHPConfig, retrievePhpIniSettings, runScheduler, startAPI, startPhpApp, } from "./server/index.js";
15+
import { notifyLaravel } from "./server/utils.js";
1616
import { resolve } from "path";
17-
import { stopAllProcesses } from "./server/api/childProcess";
17+
import { stopAllProcesses } from "./server/api/childProcess.js";
1818
import ps from "ps-node";
19+
import electronUpdater from 'electron-updater';
20+
const { autoUpdater } = electronUpdater;
1921
class NativePHP {
2022
constructor() {
2123
this.processes = [];
2224
this.schedulerInterval = undefined;
2325
}
2426
bootstrap(app, icon, phpBinary, cert) {
25-
require("@electron/remote/main").initialize();
27+
initialize();
2628
state.icon = icon;
2729
state.php = phpBinary;
2830
state.caCert = cert;

resources/js/electron-plugin/dist/preload/index.js renamed to resources/js/electron-plugin/dist/preload/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { contextBridge, ipcRenderer } = require('electron');
2-
const remote = require('@electron/remote');
1+
import remote from "@electron/remote";
2+
import { ipcRenderer } from "electron";
33
const Native = {
44
on: (event, callback) => {
55
ipcRenderer.on('native-event', (_, data) => {

resources/js/electron-plugin/dist/preload/native.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)