Skip to content

Commit 734169d

Browse files
authored
Merge pull request #8 from Hermesiss/develop
Develop
2 parents a38395b + 6a7960f commit 734169d

7 files changed

Lines changed: 299 additions & 132 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 246 additions & 109 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devnullifier",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"description": "DevNullifier: Clean application data, dev caches (node_modules, .cache, Library, Binary, Intermediate, etc) with Electron, Vue 3, and Vuetify 3.",
55
"main": "dist-main/main/main.js",
66
"scripts": {

src/main/__tests__/updateService.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import log from "electron-log";
66

77
// Mock modules
88
vi.mock("electron", () => ({
9-
BrowserWindow: vi.fn()
9+
BrowserWindow: vi.fn(),
10+
ipcMain: {
11+
handle: vi.fn()
12+
}
1013
}));
1114

1215
type UpdaterEvents = {
@@ -24,6 +27,8 @@ vi.mock("electron-updater", () => ({
2427
setFeedURL: vi.fn(),
2528
checkForUpdates: vi.fn(),
2629
quitAndInstall: vi.fn(),
30+
allowPrerelease: false,
31+
allowDowngrade: false,
2732
on: vi.fn(<K extends keyof UpdaterEvents>(event: K, callback: UpdaterEvents[K]) => {
2833
// Store the callback for later use in tests
2934
return callback;
@@ -65,11 +70,9 @@ describe("UpdateService", () => {
6570
it("should configure logging and update source correctly", () => {
6671
expect(log.transports.file.level).toBe("info");
6772
expect(autoUpdater.logger).toBe(log);
68-
expect(autoUpdater.setFeedURL).toHaveBeenCalledWith({
69-
provider: "github",
70-
owner: "Hermesiss",
71-
repo: "DevNullifier"
72-
});
73+
expect(autoUpdater.setFeedURL).toHaveBeenCalledWith(
74+
"https://github.com/Hermesiss/DevNullifier/releases/latest/download/"
75+
);
7376
});
7477

7578
it("should set up all required event listeners", () => {

src/main/preload.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ const api: ElectronAPI = {
117117
},
118118
checkForUpdates: () => ipcRenderer.invoke("check-for-updates"),
119119
quitAndInstall: () => ipcRenderer.invoke("quit-and-install"),
120+
121+
// New handler
122+
setUpdateChannel: (channel: 'latest' | 'latest-dev') => ipcRenderer.invoke('set-update-channel', channel),
120123
};
121124

122125
contextBridge.exposeInMainWorld("electronAPI", api);

src/main/updateService.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserWindow } from "electron";
1+
import { BrowserWindow, ipcMain } from "electron";
22
import { autoUpdater } from "electron-updater";
33
import log from "electron-log";
44

@@ -8,6 +8,27 @@ export class UpdateService {
88
constructor(mainWindow: BrowserWindow) {
99
this.mainWindow = mainWindow;
1010
this.initializeAutoUpdater();
11+
this.setupIpcHandlers();
12+
}
13+
14+
private setupIpcHandlers() {
15+
ipcMain.handle(
16+
"set-update-channel",
17+
(_, channel: "latest" | "latest-dev") => {
18+
this.setUpdateChannel(channel);
19+
}
20+
);
21+
}
22+
23+
private setUpdateChannel(channel: "latest" | "latest-dev") {
24+
autoUpdater.allowPrerelease = channel === "latest-dev";
25+
26+
let baseUrl =
27+
channel === "latest"
28+
? "https://github.com/Hermesiss/DevNullifier/releases/latest/download/"
29+
: "https://github.com/Hermesiss/DevNullifier/releases/download/latest-dev/";
30+
31+
autoUpdater.setFeedURL(baseUrl);
1132
}
1233

1334
private initializeAutoUpdater() {
@@ -16,22 +37,10 @@ export class UpdateService {
1637
autoUpdater.logger = log;
1738

1839
// Configure update source and options
19-
autoUpdater.channel = "latest";
2040
autoUpdater.allowDowngrade = false;
21-
autoUpdater.setFeedURL({
22-
provider: "github",
23-
owner: "Hermesiss",
24-
repo: "DevNullifier"
25-
});
2641

27-
// Platform-specific configurations
28-
if (process.platform === "win32") {
29-
autoUpdater.updateConfigPath = "latest.yml";
30-
} else if (process.platform === "darwin") {
31-
autoUpdater.updateConfigPath = "latest-mac.yml";
32-
} else if (process.platform === "linux") {
33-
autoUpdater.updateConfigPath = "latest-linux.yml";
34-
}
42+
// Set update channel after config path
43+
this.setUpdateChannel("latest");
3544

3645
// Handle events
3746
autoUpdater.on("checking-for-update", () => {

src/renderer/components/UpdateButton.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
</v-card-title>
1414

1515
<v-card-text>
16+
<div class="mb-4">
17+
<v-switch v-model="useBetaChannel" label="Use Beta Channel" color="warning" hide-details
18+
@change="handleBetaChannelChange" />
19+
</div>
20+
1621
<div v-if="checking" class="d-flex align-center">
1722
<v-progress-circular indeterminate size="24" class="mr-2" />
1823
Checking for updates...
@@ -68,6 +73,7 @@ const error = ref<string | null>(null);
6873
const updateAvailable = ref(false);
6974
const updateInfo = ref<any>(null);
7075
const downloadProgress = ref<any>(null);
76+
const useBetaChannel = ref(localStorage.getItem('useBetaChannel') === 'true');
7177
7278
// Format bytes to human readable format
7379
function formatBytes(bytes: number): string {
@@ -123,8 +129,16 @@ function handleUpdateStatus(status: { message: string; data?: any }) {
123129
}
124130
}
125131
126-
onMounted(() => {
132+
async function handleBetaChannelChange() {
133+
localStorage.setItem('useBetaChannel', useBetaChannel.value.toString());
134+
await window.electronAPI.setUpdateChannel(useBetaChannel.value ? 'latest-dev' : 'latest');
135+
checkForUpdates();
136+
}
137+
138+
onMounted(async () => {
127139
window.electronAPI.onUpdateStatus(handleUpdateStatus);
140+
// Set initial update channel
141+
await window.electronAPI.setUpdateChannel(useBetaChannel.value ? 'latest-dev' : 'latest');
128142
});
129143
130144
onUnmounted(() => {

src/renderer/types/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface ElectronAPI {
5757
saveDeveloperProjects: (projects: ProjectInfo[]) => Promise<void>;
5858
loadSavedDeveloperProjects: () => Promise<ProjectInfo[]>;
5959
getSavedDeveloperProjectsCount: () => Promise<number>;
60+
setUpdateChannel: (channel: 'latest' | 'latest-dev') => Promise<void>;
6061
}
6162

6263
// Add global type augmentation for Window interface

0 commit comments

Comments
 (0)