Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 10 additions & 2 deletions src/classes/ManagerLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
39 changes: 38 additions & 1 deletion tests/helpers/package.test.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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');
});