mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 10:44:23 +00:00
feat(plugins): TREK_PLUGINS_IGNORE_TREK_RANGE turns the version gate into a warning (#2226)
* feat(plugins): TREK_PLUGINS_IGNORE_TREK_RANGE turns the version gate into a warning A plugin whose author has not updated its `trek` range for the running TREK can now be installed, updated and activated when the operator sets TREK_PLUGINS_IGNORE_TREK_RANGE to a truthy value. Every gate (registry picker, post-extraction re-check, sideload, dev-link, activation) warns instead of refusing; a missing range is tolerated the same way; "install latest" takes the newest published version. The plugin-API version gate is not lifted and the Discover compatibility verdict stays truthful. The admin is warned at every step: each bypass is logged, install/upload/link/ update responses carry a `trekRangeBypassed` marker, and both admin panels show a "Version checks off" pill, an "Install anyway" confirm dialog before a registry install, the same notice after a path that could not ask first, and a persistent chip on the row while the plugin runs outside its range. Nine new i18n keys in every locale; wiki pages updated (Environment-Variables, Admin-Plugins, Plugin-Development, Security-Hardening). * refactor(plugins): one useRangeBypass hook behind both admin shells SonarQube flagged PR 2226 at 10.8% duplicated new code: the range-bypass logic had been added to the desktop and phone plugin panels as identical copies. The marker/warning types, the row chip, the "Install anyway" offer, the dialog copy and the confirm-or-notice state now live in useRangeBypass (next to useInstanceSettings, the existing shared-logic precedent); each panel keeps only its own dialog/sheet markup. * docs(claude): record the SonarQube gate rules and the no-English-placeholder i18n rule The CI SonarCloud gate (Sonar way, on new code: >=80% coverage, <=3% duplication, A ratings, hotspots reviewed) was only discoverable by waiting 20-25 minutes for the workflow. The root CLAUDE.md now states the conditions, the desktop/mobile shell-mirror duplication trap and its shared-hook fix, and how to check a PR with the sonarqube MCP first; client and server CLAUDE.md point at it. shared/CLAUDE.md says every locale needs a real translation — parity cannot tell an English placeholder from a translation. * docs(claude): keep CLAUDE.md to commands, invariants, gates and philosophy Verified every concrete claim in the five CLAUDE.md files against the code and fixed the stale ones: the websocket server is the Nest realtime gateway, MCP tools live in <domain>.mcp.ts files, the client "native shell" section described code that was never written, offline maps also prefetch vector basemaps, plus several renamed files and wrong table names. Then trimmed everything that drifts on its own: dates, migration history, counts, and inventories of stores, slices, domains, sync files and CLI commands. What stays is the commands, the invariants with the file that enforces each one, what CI actually runs, the reference implementations to copy, and the rules for new code. Each file now opens with that rule.
This commit is contained in:
@@ -1724,3 +1724,78 @@ describe('MAdminPluginsPanel — instance settings', () => {
|
||||
expect(screen.getByText('Activate the plugin to run its actions')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* TREK_PLUGINS_IGNORE_TREK_RANGE on the phone shell — the same three surfaces as the
|
||||
* desktop panel: the header pill, the confirm-before-install sheet, and the notice after a
|
||||
* sideload that could not ask first, plus the persistent warning chip on the row.
|
||||
*/
|
||||
describe('MAdminPluginsPanel — TREK-range bypass (TREK_PLUGINS_IGNORE_TREK_RANGE)', () => {
|
||||
const incompatibleEntry = () => registryEntry({ trek: '>=4.0.0', hostVersion: '3.3.0', compatible: false, latestCompatible: null });
|
||||
|
||||
it('FE-MOB-PLUGP-BYPASS-001: says so in the header', async () => {
|
||||
mockPanel([plugin()], [], { ignoreTrekRange: true });
|
||||
render(<MAdminPluginsPanel />);
|
||||
expect(await screen.findByText('Version checks off')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-PLUGP-BYPASS-002: offers "Install anyway" and asks before installing', async () => {
|
||||
let body: unknown = null;
|
||||
mockPanel([], [incompatibleEntry()], { ignoreTrekRange: true });
|
||||
server.use(http.post('*/api/admin/plugins/install', async ({ request }) => {
|
||||
body = await request.json();
|
||||
return HttpResponse.json({ id: 'trek-gotify', version: '2.0.0', trekRangeBypassed: { trekRange: '>=4.0.0', hostVersion: '3.3.0' } });
|
||||
}));
|
||||
render(<MAdminPluginsPanel />);
|
||||
fireEvent.click(await screen.findByRole('tab', { name: /Discover/ }));
|
||||
|
||||
const btn = await screen.findByRole('button', { name: 'Install anyway' });
|
||||
expect(btn).toBeEnabled();
|
||||
fireEvent.click(btn);
|
||||
|
||||
const sheet = await screen.findByRole('dialog', { name: 'Outside its supported TREK versions' });
|
||||
expect(within(sheet).getByText(/no guarantee/i)).toBeInTheDocument();
|
||||
expect(body).toBeNull();
|
||||
|
||||
fireEvent.click(within(sheet).getByRole('button', { name: 'Install anyway' }));
|
||||
await waitFor(() => expect(body).toEqual({ id: 'trek-gotify' }));
|
||||
});
|
||||
|
||||
it('FE-MOB-PLUGP-BYPASS-003: cancelling the warning installs nothing', async () => {
|
||||
let posted = false;
|
||||
mockPanel([], [incompatibleEntry()], { ignoreTrekRange: true });
|
||||
server.use(http.post('*/api/admin/plugins/install', () => { posted = true; return HttpResponse.json({ id: 'trek-gotify', version: '2.0.0', trekRangeBypassed: null }); }));
|
||||
render(<MAdminPluginsPanel />);
|
||||
fireEvent.click(await screen.findByRole('tab', { name: /Discover/ }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Install anyway' }));
|
||||
|
||||
const sheet = await screen.findByRole('dialog', { name: 'Outside its supported TREK versions' });
|
||||
fireEvent.click(within(sheet).getByRole('button', { name: 'Cancel' }));
|
||||
await waitFor(() => expect(screen.queryByRole('dialog', { name: 'Outside its supported TREK versions' })).not.toBeInTheDocument());
|
||||
expect(posted).toBe(false);
|
||||
});
|
||||
|
||||
it('FE-MOB-PLUGP-BYPASS-004: a sideload that landed outside its range is warned about afterwards', async () => {
|
||||
mockPanel([plugin()], [], { ignoreTrekRange: true });
|
||||
server.use(http.post('*/api/admin/plugins/upload', () =>
|
||||
HttpResponse.json({ id: 'trek-new', version: '1.0.0', replaced: false, trekRangeBypassed: { trekRange: null, hostVersion: '3.3.0' } })));
|
||||
const { container } = render(<MAdminPluginsPanel />);
|
||||
await screen.findByText('Gotify');
|
||||
|
||||
const input = container.querySelector('input[type="file"]') as HTMLInputElement;
|
||||
fireEvent.change(input, { target: { files: [new File(['zip'], 'plugin.zip', { type: 'application/zip' })] } });
|
||||
|
||||
const sheet = await screen.findByRole('dialog', { name: 'Installed outside its supported TREK versions' });
|
||||
expect(within(sheet).getByText(/no guarantee/i)).toBeInTheDocument();
|
||||
expect(within(sheet).getByText(/trek-new/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-PLUGP-BYPASS-005: a plugin running outside its range keeps a warning chip on its row', async () => {
|
||||
mockPanel([plugin({
|
||||
dependencyStatus: 'ok', trekRange: '>=3.2.0 <4.0.0', hostVersion: '4.0.0',
|
||||
trekRangeBypassed: { trekRange: '>=3.2.0 <4.0.0', hostVersion: '4.0.0' },
|
||||
})], [], { ignoreTrekRange: true });
|
||||
render(<MAdminPluginsPanel />);
|
||||
expect(await screen.findByText('Outside its TREK range (>=3.2.0 <4.0.0) — version checks off')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user