feat(updater): migrate Windows updates to full release packages
- add a v0.2.10 legacy updater bridge - support both legacy and full update archives - stop publishing dedicated update packages after v0.2.10 - preserve user data during full-package upgrades
This commit is contained in:
1 parent
88baeab512
commit
365356969e
9 files changed
+595
-80
No files matched your search
@@ -3,19 +3,22 @@ import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { generatePortableUpdateManifest } from '../scripts/generate-portable-update-manifest.mjs';
|
||||
import {
|
||||
generatePortableUpdateManifest,
|
||||
LEGACY_UPDATE_BRIDGE_VERSION,
|
||||
} from '../scripts/generate-portable-update-manifest.mjs';
|
||||
|
||||
describe('Windows 便携更新清单', () => {
|
||||
test('URL、大小和哈希与实际上传资产一致', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'easycli-manifest-test-'));
|
||||
try {
|
||||
const payloads = {
|
||||
amd64: Buffer.from('amd64 portable updater'),
|
||||
aarch64: Buffer.from('aarch64 portable updater'),
|
||||
amd64: Buffer.from('amd64 full portable package'),
|
||||
aarch64: Buffer.from('aarch64 full portable package'),
|
||||
};
|
||||
for (const [arch, contents] of Object.entries(payloads)) {
|
||||
await writeFile(
|
||||
join(root, `EasyCLIProxyAPI-update-v1.2.3-Windows-${arch}.zip`),
|
||||
join(root, `EasyCLIProxyAPI-v1.2.3-Windows-${arch}.zip`),
|
||||
contents,
|
||||
);
|
||||
}
|
||||
@@ -34,7 +37,7 @@ describe('Windows 便携更新清单', () => {
|
||||
for (const arch of ['amd64', 'aarch64'] as const) {
|
||||
const asset = manifest.assets[`windows-${arch}`];
|
||||
expect(asset.url).toBe(
|
||||
`https://github.com/router-for-me/EasyCLIProxyAPI/releases/download/v1.2.3/EasyCLIProxyAPI-update-v1.2.3-Windows-${arch}.zip`,
|
||||
`https://github.com/router-for-me/EasyCLIProxyAPI/releases/download/v1.2.3/EasyCLIProxyAPI-v1.2.3-Windows-${arch}.zip`,
|
||||
);
|
||||
expect(asset.sizeBytes).toBe(payloads[arch].byteLength);
|
||||
expect(asset.sha256).toBe(createHash('sha256').update(payloads[arch]).digest('hex'));
|
||||
@@ -48,7 +51,7 @@ describe('Windows 便携更新清单', () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'easycli-manifest-missing-'));
|
||||
try {
|
||||
await writeFile(
|
||||
join(root, 'EasyCLIProxyAPI-update-v1.2.3-Windows-amd64.zip'),
|
||||
join(root, 'EasyCLIProxyAPI-v1.2.3-Windows-amd64.zip'),
|
||||
'amd64',
|
||||
);
|
||||
await expect(generatePortableUpdateManifest({
|
||||
@@ -61,4 +64,32 @@ describe('Windows 便携更新清单', () => {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('v0.2.10 使用一次性旧版桥接资产,后续版本恢复完整包', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'easycli-manifest-bridge-'));
|
||||
try {
|
||||
for (const arch of ['amd64', 'aarch64']) {
|
||||
await writeFile(
|
||||
join(root, `EasyCLIProxyAPI-update-v${LEGACY_UPDATE_BRIDGE_VERSION}-Windows-${arch}.zip`),
|
||||
`legacy bridge ${arch}`,
|
||||
);
|
||||
}
|
||||
const manifest = await generatePortableUpdateManifest({
|
||||
directory: root,
|
||||
output: join(root, 'portable-update-windows.json'),
|
||||
repository: 'router-for-me/EasyCLIProxyAPI',
|
||||
tag: `v${LEGACY_UPDATE_BRIDGE_VERSION}`,
|
||||
publishedAt: '2026-08-02T00:00:00.000Z',
|
||||
});
|
||||
|
||||
expect(manifest.assets['windows-amd64'].url).toEndWith(
|
||||
'/EasyCLIProxyAPI-update-v0.2.10-Windows-amd64.zip',
|
||||
);
|
||||
expect(manifest.assets['windows-aarch64'].url).toEndWith(
|
||||
'/EasyCLIProxyAPI-update-v0.2.10-Windows-aarch64.zip',
|
||||
);
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user