fix: isolate FlowPilot release cache
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
const GITHUB_REPO = 'FlowPilot';
|
const GITHUB_REPO = 'FlowPilot';
|
||||||
const RELEASES_PAGE_URL = `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/releases`;
|
const RELEASES_PAGE_URL = `https://github.com/${GITHUB_OWNER}/${GITHUB_REPO}/releases`;
|
||||||
const RELEASES_API_URL = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases?per_page=10`;
|
const RELEASES_API_URL = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases?per_page=10`;
|
||||||
const CACHE_KEY = 'multipage-release-snapshot-v1';
|
const CACHE_KEY = 'flowpilot-release-snapshot-v1';
|
||||||
const IGNORED_UPDATE_VERSION_KEY = 'multipage-ignored-release-version-v1';
|
const IGNORED_UPDATE_VERSION_KEY = 'flowpilot-ignored-release-version-v1';
|
||||||
const CACHE_TTL_MS = 60 * 60 * 1000;
|
const CACHE_TTL_MS = 60 * 60 * 1000;
|
||||||
const FETCH_TIMEOUT_MS = 8000;
|
const FETCH_TIMEOUT_MS = 8000;
|
||||||
const MAX_RELEASES = 10;
|
const MAX_RELEASES = 10;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ const assert = require('node:assert/strict');
|
|||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
|
|
||||||
const source = fs.readFileSync('sidepanel/update-service.js', 'utf8');
|
const source = fs.readFileSync('sidepanel/update-service.js', 'utf8');
|
||||||
|
const CACHE_KEY = 'flowpilot-release-snapshot-v1';
|
||||||
|
const LEGACY_CACHE_KEY = 'multipage-release-snapshot-v1';
|
||||||
|
|
||||||
function createUpdateService(options = {}) {
|
function createUpdateService(options = {}) {
|
||||||
const manifest = options.manifest || {
|
const manifest = options.manifest || {
|
||||||
@@ -27,10 +29,16 @@ function createUpdateService(options = {}) {
|
|||||||
|
|
||||||
if (options.cachedSnapshot) {
|
if (options.cachedSnapshot) {
|
||||||
cache.set(
|
cache.set(
|
||||||
'multipage-release-snapshot-v1',
|
CACHE_KEY,
|
||||||
JSON.stringify(options.cachedSnapshot)
|
JSON.stringify(options.cachedSnapshot)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (options.legacyCachedSnapshot) {
|
||||||
|
cache.set(
|
||||||
|
LEGACY_CACHE_KEY,
|
||||||
|
JSON.stringify(options.legacyCachedSnapshot)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const fetchImpl = options.fetchImpl || (async () => ({
|
const fetchImpl = options.fetchImpl || (async () => ({
|
||||||
ok: true,
|
ok: true,
|
||||||
@@ -202,6 +210,48 @@ test('getReleaseSnapshot reorders cached releases before choosing latest version
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getReleaseSnapshot ignores legacy repository cache after FlowPilot rename', async () => {
|
||||||
|
const { api, getFetchCalls } = createUpdateService({
|
||||||
|
legacyCachedSnapshot: {
|
||||||
|
fetchedAt: Date.now(),
|
||||||
|
releases: [
|
||||||
|
{
|
||||||
|
version: '1.1',
|
||||||
|
displayVersion: 'Ultra1.1',
|
||||||
|
family: 'ultra',
|
||||||
|
title: '',
|
||||||
|
url: 'https://github.com/QLHazyCoder/codex-oauth-automation-extension/releases/tag/Ultra1.1',
|
||||||
|
publishedAt: '2026-04-19T00:00:00.000Z',
|
||||||
|
notes: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fetchImpl: async () => ({
|
||||||
|
ok: true,
|
||||||
|
async json() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
tag_name: 'FlowPilot1.1',
|
||||||
|
name: 'FlowPilot1.1',
|
||||||
|
html_url: 'https://github.com/QLHazyCoder/FlowPilot/releases/tag/FlowPilot1.1',
|
||||||
|
published_at: '2026-04-20T00:00:00.000Z',
|
||||||
|
body: '- current release',
|
||||||
|
draft: false,
|
||||||
|
prerelease: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const snapshot = await api.getReleaseSnapshot();
|
||||||
|
|
||||||
|
assert.equal(getFetchCalls(), 1);
|
||||||
|
assert.equal(snapshot.logUrl, 'https://github.com/QLHazyCoder/FlowPilot/releases/tag/FlowPilot1.1');
|
||||||
|
assert.equal(api.releasesPageUrl, 'https://github.com/QLHazyCoder/FlowPilot/releases');
|
||||||
|
assert.equal(api.repositoryUrl, 'https://github.com/QLHazyCoder/FlowPilot');
|
||||||
|
});
|
||||||
|
|
||||||
test('getReleaseSnapshot suppresses an ignored latest update until a newer release appears', async () => {
|
test('getReleaseSnapshot suppresses an ignored latest update until a newer release appears', async () => {
|
||||||
let releases = [
|
let releases = [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user