diff --git a/package-lock.json b/package-lock.json index 9adb844..392425b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@open-audio-stack/core", - "version": "0.1.43", + "version": "0.1.44", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@open-audio-stack/core", - "version": "0.1.43", + "version": "0.1.44", "license": "cc0-1.0", "dependencies": { "@vscode/sudo-prompt": "^9.3.1", diff --git a/package.json b/package.json index 53d4b54..1a8c6bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@open-audio-stack/core", - "version": "0.1.43", + "version": "0.1.44", "description": "Open-source audio plugin management software", "type": "module", "main": "./build/index.js", diff --git a/src/classes/ManagerLocal.ts b/src/classes/ManagerLocal.ts index 9901438..81f514e 100644 --- a/src/classes/ManagerLocal.ts +++ b/src/classes/ManagerLocal.ts @@ -206,8 +206,16 @@ export class ManagerLocal extends Manager { const excludedFormats: FileFormat[] = []; const system = getSystem(); if (system === SystemType.Linux) { - if (!(await commandExists('dpkg'))) excludedFormats.push(FileFormat.DebianPackage); - if (!(await commandExists('rpm'))) excludedFormats.push(FileFormat.RedHatPackage); + const hasDpkg = await commandExists('dpkg'); + const hasRpm = await commandExists('rpm'); + // If both exist, prefer DEB over RPM + if (hasDpkg && hasRpm) { + excludedFormats.push(FileFormat.RedHatPackage); + } else if (!hasDpkg) { + excludedFormats.push(FileFormat.DebianPackage); + } else if (!hasRpm) { + excludedFormats.push(FileFormat.RedHatPackage); + } } const files: FileInterface[] = packageCompatibleFiles( pkgVersion, diff --git a/tests/helpers/package.test.ts b/tests/helpers/package.test.ts index cb40510..341bc16 100644 --- a/tests/helpers/package.test.ts +++ b/tests/helpers/package.test.ts @@ -1,7 +1,15 @@ import { expect, test } from 'vitest'; -import { packageRecommendations, packageVersionLatest, PackageVersionValidator } from '../../src/helpers/package.js'; +import { + packageCompatibleFiles, + packageRecommendations, + packageVersionLatest, + PackageVersionValidator, +} from '../../src/helpers/package.js'; import { PLUGIN, PLUGIN_PACKAGE_MULTIPLE } from '../data/Plugin'; import { PackageVersion } from '../../src/types/Package'; +import { Architecture } from '../../src/types/Architecture.js'; +import { SystemType } from '../../src/types/SystemType.js'; +import { FileFormat } from '../../src/types/FileFormat.js'; test('Package version latest', () => { expect(packageVersionLatest(PLUGIN_PACKAGE_MULTIPLE)).toEqual('1.3.2'); @@ -64,3 +72,32 @@ test('Package validate invalid type', () => { }, ]); }); + +test('Package compatible files returns empty when only unsupported formats exist', () => { + const rpmOnlyPackage: PackageVersion = { + ...PLUGIN, + files: [PLUGIN.files[1]], // Only the RPM file + }; + const excludedResult = packageCompatibleFiles( + rpmOnlyPackage, + [Architecture.X64], + [SystemType.Linux], + [FileFormat.RedHatPackage], + ); + expect(excludedResult).toHaveLength(0); +}); + +test('Package compatible files respects exclusions when alternatives exist', () => { + const bothFormatsPackage: PackageVersion = { + ...PLUGIN, + files: [PLUGIN.files[0], PLUGIN.files[1]], // DEB and RPM files + }; + const result = packageCompatibleFiles( + bothFormatsPackage, + [Architecture.X64], + [SystemType.Linux], + [FileFormat.RedHatPackage], + ); + expect(result).toHaveLength(1); + expect(result[0].url).toContain('.deb'); +});