Skip to content

Commit 9abdc5a

Browse files
LevevTibixDev
andcommitted
chore: Migrate Electron scripts and configuration files to TypeScript
chore: Update engine requirement to Node 23 (required for experimental strip types) chore: Update Node version in CI to 24, and actions/checkout & actions/setup-node to v5 Co-authored-by: Tibix <fuloptibi03@gmail.com>
1 parent 106962d commit 9abdc5a

10 files changed

Lines changed: 31 additions & 25 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
(github.event_name == 'workflow_dispatch' && github.event.inputs.build_type != 'guest-server-only')
2727
steps:
2828
- name: Checkout code
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v5
3030
- name: Update USB IDs database
3131
run: |
3232
echo "Removing old usb.ids file..."
@@ -48,7 +48,7 @@ jobs:
4848
- name: Set up Node.js
4949
uses: actions/setup-node@v4
5050
with:
51-
node-version: "22"
51+
node-version: "24"
5252
cache: "npm"
5353
- name: Set up Go
5454
uses: actions/setup-go@v5
@@ -128,7 +128,7 @@ jobs:
128128
if: github.event_name == 'workflow_dispatch' && github.event.inputs.build_type == 'guest-server-only'
129129
steps:
130130
- name: Checkout code
131-
uses: actions/checkout@v4
131+
uses: actions/checkout@v5
132132
- name: Show build type
133133
run: |
134134
echo "Manual workflow triggered with build type: guest-server-only"
@@ -151,7 +151,7 @@ jobs:
151151
(github.event_name == 'workflow_dispatch' && github.event.inputs.build_type == 'all')
152152
steps:
153153
- name: Checkout code
154-
uses: actions/checkout@v4
154+
uses: actions/checkout@v5
155155
- name: Update USB IDs database
156156
run: |
157157
echo "Removing old usb.ids file..."
@@ -173,7 +173,7 @@ jobs:
173173
- name: Set up Node.js
174174
uses: actions/setup-node@v4
175175
with:
176-
node-version: "22"
176+
node-version: "24"
177177
cache: "npm"
178178
- name: Set up Go
179179
uses: actions/setup-go@v5

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
"description": "Windows for Penguins",
55
"type": "module",
66
"main": "main/main.js",
7+
"engines": {
8+
"node": ">=23.6.0"
9+
},
710
"scripts": {
8-
"dev": "node scripts/dev-server.js",
11+
"dev": "node scripts/dev-server.ts",
912
"build-guest-server": "bash build-guest-server.sh",
10-
"build:linux-gs": "bash build-guest-server.sh && node scripts/build.js && electron-builder --linux"
13+
"build:linux-gs": "bash build-guest-server.sh && node scripts/build.ts && electron-builder --linux"
1114
},
1215
"repository": "https://github.com/TibixDev/winboat",
1316
"author": {
File renamed without changes.

scripts/build.js renamed to scripts/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import Path from 'path';
22
import Chalk from 'chalk';
33
import FileSystem from 'fs';
44
import * as Vite from 'vite';
5-
import compileTs from './private/tsc.js';
6-
import { EOL } from 'os';
5+
import compileTs from './private/tsc.ts';
6+
// ^ Extension can't be omitted because Node expects it
77
import { fileURLToPath } from 'url';
88

99
const __filename = fileURLToPath(import.meta.url);
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
process.env.NODE_ENV = 'development';
22

33
import * as Vite from 'vite';
4-
import ChildProcess from 'child_process';
4+
import ChildProcess, { type ChildProcessWithoutNullStreams } from 'child_process';
55
import Path from 'path';
66
import Chalk from 'chalk';
77
import Chokidar from 'chokidar';
88
import Electron from 'electron';
9-
import compileTs from './private/tsc.js';
9+
import compileTs from './private/tsc.ts';
10+
// ^ Extension needed because no TSConfig in the root
1011
import FileSystem from 'fs';
1112
import { EOL } from 'os';
1213
import { fileURLToPath } from 'url';
1314

1415
const __filename = fileURLToPath(import.meta.url);
1516
const __dirname = Path.dirname(__filename);
1617

17-
let viteServer = null;
18-
let electronProcess = null;
18+
let viteServer: Vite.ViteDevServer | null = null;
19+
let electronProcess: ChildProcessWithoutNullStreams | null = null;
1920
let electronProcessLocker = false;
2021
let rendererPort = 0;
2122

@@ -44,24 +45,25 @@ async function startElectron() {
4445

4546
const args = [
4647
Path.join(__dirname, '..', 'build', 'main', 'main.js'),
47-
rendererPort,
48+
String(rendererPort),
4849
];
49-
electronProcess = ChildProcess.spawn(Electron, args);
50+
51+
electronProcess = ChildProcess.spawn(String(Electron), args);
5052
electronProcessLocker = false;
5153

52-
electronProcess.stdout.on('data', data => {
54+
electronProcess!.stdout.on('data', data => {
5355
if (data == EOL) {
5456
return;
5557
}
5658

5759
process.stdout.write(Chalk.blueBright(`[electron] `) + Chalk.white(data.toString()))
5860
});
5961

60-
electronProcess.stderr.on('data', data =>
62+
electronProcess!.stderr.on('data', data =>
6163
process.stderr.write(Chalk.blueBright(`[electron] `) + Chalk.white(data.toString()))
6264
);
6365

64-
electronProcess.on('exit', () => stop());
66+
electronProcess!.on('exit', () => stop());
6567
}
6668

6769
function restartElectron() {
@@ -94,7 +96,7 @@ function copy(path) {
9496
}
9597

9698
function stop() {
97-
viteServer.close();
99+
viteServer!.close();
98100
process.exit();
99101
}
100102

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import ChildProcess from 'child_process';
22
import Chalk from 'chalk';
33

44
export default function compile(directory) {
5-
return new Promise((resolve, reject) => {
5+
return new Promise<void>((resolve, reject) => {
66
const tscProcess = ChildProcess.exec('tsc', {
77
cwd: directory,
88
});
99

10-
tscProcess.stdout.on('data', data =>
10+
tscProcess.stdout!.on('data', data =>
1111
process.stdout.write(Chalk.yellowBright(`[tsc] `) + Chalk.white(data.toString()))
1212
);
1313

1414
tscProcess.on('exit', exitCode => {
15-
if (exitCode > 0) {
15+
if (exitCode ?? 1 > 0) {
1616
reject(exitCode);
1717
} else {
1818
resolve();

src/renderer/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"compilerOptions": {
33
"target": "esnext",
44
"useDefineForClassFields": true,
5-
"module": "nodenext",
6-
"moduleResolution": "nodenext",
5+
"module": "esnext",
6+
"moduleResolution": "bundler",
77
"strict": true,
88
"jsx": "preserve",
99
"sourceMap": true,

src/renderer/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const wallpaper = ref("");
126126
127127
onMounted(async () => {
128128
compose.value = winboat.parseCompose();
129-
wallpaper.value = compose.value.services.windows.environment.VERSION.includes("11")
129+
wallpaper.value = compose.value?.services.windows.environment.VERSION.includes("11")
130130
? "./img/wallpaper/win11.webp"
131131
: "./img/wallpaper/win10.webp";
132132
File renamed without changes.

0 commit comments

Comments
 (0)