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.48",
"version": "0.1.49",
"description": "Open-source audio plugin management software",
"type": "module",
"main": "./build/index.js",
Expand Down
10 changes: 6 additions & 4 deletions src/classes/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ManagerReport, PackageVersion } from '../types/Package.js';
import { RegistryInterface, RegistryPackages, RegistryType } from '../types/Registry.js';
import { Base } from './Base.js';
import { packageCompatibleFiles } from '../helpers/package.js';
import { getArchitecture, getSystem } from '../helpers/utilsLocal.js';
import { Architecture, SystemType } from '../index-browser.js';

export class Manager extends Base {
protected config: Config;
Expand Down Expand Up @@ -64,7 +64,7 @@ export class Manager extends Base {
}
}

listPackages(installed?: boolean, showAll = false) {
listPackages(installed?: boolean, architecture?: Architecture, system?: SystemType) {
let packages = Array.from(this.packages.values());

if (installed !== undefined) {
Expand All @@ -75,11 +75,13 @@ export class Manager extends Base {
);
}

if (!showAll) {
if (architecture || system) {
packages = packages.filter(pkg => {
const pkgVersion = pkg.getVersionLatest();
if (!pkgVersion) return false;
const files = packageCompatibleFiles(pkgVersion, [getArchitecture()], [getSystem()], []);
const archArr = architecture ? [architecture] : [];
const sysArr = system ? [system] : [];
const files = packageCompatibleFiles(pkgVersion, archArr, sysArr, []);
return files.length > 0;
});
}
Expand Down
18 changes: 17 additions & 1 deletion tests/classes/Manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { expect, test } from 'vitest';
import { PLUGIN, PLUGIN_PACKAGE, PLUGIN_PACKAGE_EMPTY, PLUGIN_PACKAGE_MULTIPLE } from '../data/Plugin';
import {
PLUGIN,
PLUGIN_INCOMPATIBLE,
PLUGIN_PACKAGE,
PLUGIN_PACKAGE_EMPTY,
PLUGIN_PACKAGE_INCOMPATIBLE,
PLUGIN_PACKAGE_MULTIPLE,
} from '../data/Plugin';
import { Manager } from '../../src/classes/Manager';
import { RegistryType } from '../../src/types/Registry';
import { Package } from '../../src/classes/Package';
Expand Down Expand Up @@ -110,6 +117,15 @@ test('Manager list packages', () => {
expect(manager.listPackages(false)).toEqual([pkg]);
});

test('Manager list packages incompatible', () => {
const manager = new Manager(RegistryType.Plugins);
const pkgNoWin = new Package(PLUGIN_PACKAGE_INCOMPATIBLE.slug);
pkgNoWin.addVersion(PLUGIN_PACKAGE_INCOMPATIBLE.version, PLUGIN_INCOMPATIBLE);
manager.addPackage(pkgNoWin);
expect(manager.listPackages(undefined, Architecture.X64, SystemType.Win)).toEqual([]);
expect(manager.listPackages(undefined, Architecture.X64, SystemType.Linux)).toEqual([pkgNoWin]);
});

test('Manager filter packages', () => {
const manager = new Manager(RegistryType.Plugins);
const pkg = new Package(PLUGIN_PACKAGE.slug);
Expand Down
12 changes: 12 additions & 0 deletions tests/data/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export const PLUGIN: PluginInterface = {
export const PLUGIN_INSTALLED: PluginInterface = structuredClone(PLUGIN);
PLUGIN_INSTALLED.installed = true;

export const PLUGIN_INCOMPATIBLE: PluginInterface = structuredClone(PLUGIN);
// Remove the Windows-compatible file entry so this package is incompatible with Win.
PLUGIN_INCOMPATIBLE.files.splice(4, 1);

export const PLUGIN_PACKAGE: PackageInterface = {
slug,
version,
Expand Down Expand Up @@ -121,3 +125,11 @@ export const PLUGIN_PACKAGE_MULTIPLE: PackageInterface = {
'1.3.2': PLUGIN,
},
};

export const PLUGIN_PACKAGE_INCOMPATIBLE: PackageInterface = {
slug,
version,
versions: {
[version]: PLUGIN_INCOMPATIBLE,
},
};