fix: restore update command helpers (#1857)

Exported package-manager helpers used by openchamber update
Added regression coverage for the update-available path
This commit is contained in:
Bohdan Triapitsyn
2026-06-28 09:58:45 +03:00
parent 5034ad27a8
commit b72230bc24
3 changed files with 65 additions and 3 deletions
+2 -2
View File
@@ -483,7 +483,7 @@ export function detectPackageManagerDetails() {
};
}
function detectPackageManager() {
export function detectPackageManager() {
return detectPackageManagerDetails().packageManager;
}
@@ -769,7 +769,7 @@ export async function checkForUpdates(options = {}) {
/**
* Execute the update (used by CLI)
*/
function executeUpdate(pm = detectPackageManager(), options = {}) {
export function executeUpdate(pm = detectPackageManager(), options = {}) {
const command = getUpdateCommand(pm);
if (!options?.silent) {
console.log(`Updating ${PACKAGE_NAME} using ${pm}...`);
@@ -6,7 +6,12 @@ vi.mock('node:child_process', () => ({
spawnSync: vi.fn(() => ({ status: 0, stdout: '/usr/local/bin', stderr: '' })),
}));
const { checkForUpdates, getCurrentVersion } = await import('./package-manager.js');
const {
checkForUpdates,
detectPackageManager,
executeUpdate,
getCurrentVersion,
} = await import('./package-manager.js');
/** Helper: create a fetch mock that routes by URL pattern */
function createFetchMock() {
@@ -251,3 +256,10 @@ describe('getCurrentVersion', () => {
expect(getCurrentVersion()).toMatch(/^\d+\.\d+\.\d+|unknown$/);
});
});
describe('CLI update exports', () => {
it('exports package-manager helpers used by the update command', () => {
expect(typeof detectPackageManager).toBe('function');
expect(typeof executeUpdate).toBe('function');
});
});