mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
fix: rename Windows ZIPs and fix macOS manual update checks (#81)
This commit is contained in:
+2
-2
@@ -5227,8 +5227,8 @@ function getUpdateService() {
|
||||
readState: () => updateStateStore.readState(),
|
||||
writeState: (state) => updateStateStore.writeState(state),
|
||||
checkAppUpdate: (channel) => appUpdater.checkForUpdates(channel),
|
||||
shouldFetchReleaseMetadata: ({ appUpdate }) =>
|
||||
shouldFetchReleaseMetadataForPlatform(process.platform, appUpdate),
|
||||
shouldFetchReleaseMetadata: ({ request, appUpdate }) =>
|
||||
shouldFetchReleaseMetadataForPlatform(process.platform, appUpdate, request),
|
||||
fetchLatestStableRelease: (channel) =>
|
||||
fetchLatestStableRelease({ fetch: getFetchForUpdater(), channel }),
|
||||
updateLauncher: (launcherPath, channel, release) =>
|
||||
|
||||
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { shouldFetchReleaseMetadataForPlatform } from './release-metadata-policy';
|
||||
|
||||
test('macOS release metadata fetch is skipped only when native updater is unsupported', () => {
|
||||
test('macOS automatic release metadata fetch is skipped when native updater is unsupported', () => {
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', {
|
||||
available: false,
|
||||
@@ -28,6 +28,33 @@ test('macOS release metadata fetch is skipped only when native updater is unsupp
|
||||
);
|
||||
});
|
||||
|
||||
test('macOS manual checks fetch release metadata when native updater is unsupported', () => {
|
||||
const unsupportedUpdate = {
|
||||
available: false,
|
||||
version: '0.15.0-beta.4',
|
||||
canUpdate: false,
|
||||
};
|
||||
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', unsupportedUpdate, {
|
||||
source: 'manual',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', unsupportedUpdate, {
|
||||
source: 'launcher',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', unsupportedUpdate, {
|
||||
source: 'automatic',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('non-macOS release metadata fetch is not gated by native updater support', () => {
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('linux', {
|
||||
|
||||
@@ -4,12 +4,20 @@ type AppUpdateMetadata = {
|
||||
canUpdate?: boolean;
|
||||
};
|
||||
|
||||
type UpdateMetadataRequest = {
|
||||
source?: 'manual' | 'automatic' | 'launcher';
|
||||
};
|
||||
|
||||
export function shouldFetchReleaseMetadataForPlatform(
|
||||
platform: NodeJS.Platform,
|
||||
appUpdate: AppUpdateMetadata,
|
||||
request: UpdateMetadataRequest = {},
|
||||
): boolean {
|
||||
if (platform !== 'darwin') {
|
||||
return true;
|
||||
}
|
||||
return appUpdate.canUpdate !== false;
|
||||
if (appUpdate.canUpdate !== false) {
|
||||
return true;
|
||||
}
|
||||
return request.source === 'manual' || request.source === 'launcher';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { shouldFetchReleaseMetadataForPlatform } from './release-metadata-policy';
|
||||
import { createUpdateService, type UpdateServiceDeps, type UpdateState } from './update-service';
|
||||
|
||||
function createDeps(overrides: Partial<UpdateServiceDeps> = {}) {
|
||||
@@ -362,6 +363,57 @@ test('manual prerelease update check uses prerelease release and launcher channe
|
||||
]);
|
||||
});
|
||||
|
||||
test('manual macOS prerelease check reports GitHub update when native updater is unsupported', async () => {
|
||||
const { deps, calls } = createDeps({
|
||||
getConfig: () => ({
|
||||
enabled: true,
|
||||
checkIntervalHours: 24,
|
||||
notificationType: 'system',
|
||||
channel: 'prerelease',
|
||||
}),
|
||||
getCurrentVersion: () => '0.15.0-beta.4',
|
||||
checkAppUpdate: async (channel) => {
|
||||
calls.push(`app:${channel}`);
|
||||
return {
|
||||
available: false,
|
||||
version: '0.15.0-beta.4',
|
||||
canUpdate: false,
|
||||
};
|
||||
},
|
||||
shouldFetchReleaseMetadata: ({ request, appUpdate }) =>
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', appUpdate, request),
|
||||
fetchLatestStableRelease: async (channel) => {
|
||||
calls.push(`fetch:${channel}`);
|
||||
return {
|
||||
tag_name: 'v0.15.0-beta.5',
|
||||
prerelease: true,
|
||||
draft: false,
|
||||
assets: [],
|
||||
};
|
||||
},
|
||||
showUpdateAvailableDialog: async (version) => {
|
||||
calls.push(`available-dialog:${version}`);
|
||||
return 'update';
|
||||
},
|
||||
updateLauncher: async (_launcherPath, channel, release) => {
|
||||
calls.push(`launcher:${channel}:${release?.tag_name ?? 'none'}`);
|
||||
return { status: 'skipped' };
|
||||
},
|
||||
});
|
||||
const service = createUpdateService(deps);
|
||||
|
||||
const result = await service.checkForUpdates({ source: 'manual' });
|
||||
|
||||
assert.equal(result.status, 'update-available');
|
||||
assert.deepEqual(calls, [
|
||||
'app:prerelease',
|
||||
'fetch:prerelease',
|
||||
'available-dialog:0.15.0-beta.5',
|
||||
'launcher:prerelease:v0.15.0-beta.5',
|
||||
'manual-install:0.15.0-beta.5',
|
||||
]);
|
||||
});
|
||||
|
||||
test('manual update check keeps current prerelease builds on configured stable channel', async () => {
|
||||
const { deps, calls } = createDeps({
|
||||
getCurrentVersion: () => '0.15.0-beta.3',
|
||||
|
||||
@@ -87,6 +87,11 @@ test('prerelease workflow writes checksum entries using release asset basenames'
|
||||
);
|
||||
});
|
||||
|
||||
test('prerelease workflow relies on builder artifact names without post-build zip renames', () => {
|
||||
assert.doesNotMatch(prereleaseWorkflow, /Rename Windows ZIP artifacts/);
|
||||
assert.doesNotMatch(prereleaseWorkflow, /Rename-Item[\s\S]*-win\.zip/);
|
||||
});
|
||||
|
||||
test('prerelease workflow validates artifacts before publishing the release and only undrafts after upload', () => {
|
||||
const artifactsIndex = prereleaseWorkflow.indexOf('artifacts=(');
|
||||
const createIndex = prereleaseWorkflow.indexOf('gh release create');
|
||||
|
||||
@@ -18,15 +18,28 @@ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
|
||||
afterPack?: string;
|
||||
electronUpdaterCompatibility?: string;
|
||||
files?: string[];
|
||||
artifactName?: string;
|
||||
dmg?: {
|
||||
artifactName?: string;
|
||||
};
|
||||
extraResources?: Array<{
|
||||
from?: string;
|
||||
to?: string;
|
||||
}>;
|
||||
mac?: {
|
||||
artifactName?: string;
|
||||
};
|
||||
nsis?: {
|
||||
artifactName?: string;
|
||||
};
|
||||
publish?: Array<{
|
||||
provider?: string;
|
||||
owner?: string;
|
||||
repo?: string;
|
||||
}>;
|
||||
win?: {
|
||||
artifactName?: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -199,6 +212,15 @@ test('windows release workflow publishes unsigned artifacts directly without Sig
|
||||
assert.ok(!releaseWorkflow.includes('SIGNPATH_'));
|
||||
});
|
||||
|
||||
test('release artifact names are distinct before upload', () => {
|
||||
assert.equal(packageJson.build?.mac?.artifactName, 'SubMiner-${version}-mac.${ext}');
|
||||
assert.equal(packageJson.build?.dmg?.artifactName, 'SubMiner-${version}.${ext}');
|
||||
assert.equal(packageJson.build?.win?.artifactName, 'SubMiner-${version}-win.${ext}');
|
||||
assert.equal(packageJson.build?.nsis?.artifactName, 'SubMiner-${version}.${ext}');
|
||||
assert.doesNotMatch(releaseWorkflow, /Rename Windows ZIP artifacts/);
|
||||
assert.doesNotMatch(releaseWorkflow, /Rename-Item[\s\S]*-win\.zip/);
|
||||
});
|
||||
|
||||
test('release workflow publishes subminer-bin to AUR from tagged release artifacts', () => {
|
||||
assert.match(releaseWorkflow, /aur-publish:/);
|
||||
assert.match(releaseWorkflow, /needs:\s*\[release\]/);
|
||||
|
||||
Reference in New Issue
Block a user