@open-audio-stack/core 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,27 @@
1
- # open-audio-stack-core
1
+ <div align="center">
2
+ <h1>
3
+ <img src="https://raw.githubusercontent.com/open-audio-stack/open-audio-stack-registry/refs/heads/main/src/assets/open-audio-stack-logo.svg" alt="Open Audio Stack Logo"><br />
4
+ Open Audio Stack
5
+ </h1>
6
+ <p>Audio registry specification and API with searchable list of packages</p>
7
+ <p>
8
+ <a href="https://github.com/open-audio-stack/open-audio-stack-core/wiki/Open-Audio-Stack-%E2%80%90-Registry-%E2%80%90-Specification-1.0.0">Registry Specification</a>
9
+ ⦁︎
10
+ <a href="https://open-audio-stack.github.io/open-audio-stack-registry">Registry API</a>
11
+ ⦁︎
12
+ <a href="https://github.com/orgs/open-audio-stack/projects">Roadmap</a>
13
+ </p>
14
+ <p>
2
15
 
3
16
  ![Test](https://github.com/open-audio-stack/open-audio-stack-core/workflows/Test/badge.svg)
4
17
  ![Release](https://github.com/open-audio-stack/open-audio-stack-core/workflows/Release/badge.svg)
18
+ <a href="https://discord.com/invite/9D94f98PxP" target="_blank"><img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Join the chat at Discord"></a>
19
+
20
+ ![Open Audio Stack - Registry - Specification 1.0.0](https://raw.githubusercontent.com/open-audio-stack/open-audio-stack-registry/refs/heads/main/src/assets/open-audio-stack-diagram.svg)
21
+
22
+ </div>
23
+
24
+ # open-audio-stack-core
5
25
 
6
26
  Common package shared across Open Audio Stack compatible registries, command-line tools, apps and websites for handling installing DAW VST plugin dependencies.
7
27
 
@@ -12,9 +32,10 @@ High-level classes enable use without writing business-logic:
12
32
  - Config - Set and get common configuration types, formats, values, paths and urls.
13
33
  - ConfigLocal - All the Config functionality including ability to load and save configuration to a json file.
14
34
  - Manager - Search, filter and get packages from a registry.
15
- - ManagerLocal - Install/uninstall packages locally and scan directories for existing packages.
35
+ - ManagerLocal - Scan directories for existing packages locally and install/uninstall packages.
16
36
  - Package - Create a new package to add to a registry.
17
37
  - Registry - Create an audio package registry with packages and files.
38
+ - RegistryLocal - Scan directories for existing packages locally.
18
39
 
19
40
  Low-level methods/utilities for more custom/advanced implementations:
20
41
 
@@ -37,6 +58,18 @@ Import the package using:
37
58
 
38
59
  Then use the available methods as normal.
39
60
 
61
+ ## Badges
62
+
63
+ If your project utilizes the Open Stack Audio specification or API, we encourage linking back to this project using a badge:
64
+
65
+ ```
66
+ <a href="https://github.com/open-audio-stack" target="_blank"><img src="https://raw.githubusercontent.com/open-audio-stack/open-audio-stack-registry/refs/heads/main/src/assets/powered-by-open-audio-stack.svg" alt="Powered by Open Audio Stack"></a>
67
+ ```
68
+
69
+ Example:
70
+
71
+ <a href="https://github.com/open-audio-stack" target="_blank"><img src="https://raw.githubusercontent.com/open-audio-stack/open-audio-stack-registry/refs/heads/main/src/assets/powered-by-open-audio-stack.svg" alt="Powered by Open Audio Stack"></a>
72
+
40
73
  ## Developer information
41
74
 
42
75
  Open Audio Stack Core was built using:
@@ -9,7 +9,7 @@ export declare class Manager {
9
9
  type: RegistryType;
10
10
  constructor(type: RegistryType, config?: ConfigInterface);
11
11
  addPackage(pkg: Package): void;
12
- filter(query: string | number | object, field: keyof PackageVersion): Package[];
12
+ filter(method: (pkgVersion: PackageVersion, pkg: Package) => boolean): Package[];
13
13
  getPackage(slug: string): Package | undefined;
14
14
  listPackages(): Package[];
15
15
  removePackage(slug: string): void;
@@ -21,13 +21,11 @@ export class Manager {
21
21
  this.packages.set(pkg.slug, pkg);
22
22
  }
23
23
  }
24
- filter(query, field) {
24
+ filter(method) {
25
25
  const results = [];
26
26
  for (const [, pkg] of this.packages) {
27
27
  const pkgVersion = pkg.getVersionLatest();
28
- if (!pkgVersion)
29
- continue;
30
- if (pkgVersion[field] === query) {
28
+ if (pkgVersion && method(pkgVersion, pkg)) {
31
29
  results.push(pkg);
32
30
  }
33
31
  }
@@ -5,7 +5,7 @@ import { ConfigInterface } from '../types/Config.js';
5
5
  export declare class ManagerLocal extends Manager {
6
6
  protected typeDir: string;
7
7
  constructor(type: RegistryType, config: ConfigInterface);
8
- scan(): void;
8
+ scan(ext?: string): void;
9
9
  install(slug: string, version?: string): Promise<void | PackageVersion>;
10
10
  uninstall(slug: string, version?: string): Promise<void | PackageVersion>;
11
11
  }
@@ -2,7 +2,8 @@ import path from 'path';
2
2
  import { Package } from './Package.js';
3
3
  import { Manager } from './Manager.js';
4
4
  import { archiveExtract, dirCreate, dirDelete, dirEmpty, dirRead, fileCreate, fileCreateJson, fileExists, fileHash, fileOpen, fileReadJson, filesMove, isAdmin, runCliAsAdmin, } from '../helpers/file.js';
5
- import { isTests, pathGetSlug, pathGetVersion } from '../helpers/utils.js';
5
+ import { pathGetSlug, pathGetVersion } from '../helpers/utils.js';
6
+ import { getArchitecture, getSystem, isTests } from '../helpers/utilsLocal.js';
6
7
  import { apiBuffer } from '../helpers/api.js';
7
8
  import { FileType } from '../types/FileType.js';
8
9
  import { RegistryType } from '../types/Registry.js';
@@ -19,8 +20,8 @@ export class ManagerLocal extends Manager {
19
20
  this.config = new ConfigLocal(configPath, config);
20
21
  this.typeDir = this.config.get(`${type}Dir`);
21
22
  }
22
- scan() {
23
- const filePaths = dirRead(`${this.typeDir}/**/index.json`);
23
+ scan(ext = 'json') {
24
+ const filePaths = dirRead(`${this.typeDir}/**/index.${ext}`);
24
25
  filePaths.forEach((filePath) => {
25
26
  const subPath = filePath.replace(`${this.typeDir}/`, '');
26
27
  const pkgJson = fileReadJson(filePath);
@@ -53,7 +54,7 @@ export class ManagerLocal extends Manager {
53
54
  const dirDownloads = path.join(this.config.get('appDir'), 'downloads', this.type, slug, versionNum);
54
55
  dirCreate(dirDownloads);
55
56
  // Filter for compatible files and download.
56
- const files = packageCompatibleFiles(pkgVersion);
57
+ const files = packageCompatibleFiles(pkgVersion, [getArchitecture()], [getSystem()]);
57
58
  if (!files.length)
58
59
  return console.error(`Error: No compatible files found for ${slug}`);
59
60
  for (const key in files) {
@@ -4,7 +4,7 @@ export declare class Registry {
4
4
  name: string;
5
5
  url: string;
6
6
  version: string;
7
- private managers;
7
+ protected managers: Record<string, Manager>;
8
8
  constructor(name: string, url: string, version: string);
9
9
  addManager(manager: Manager): void;
10
10
  getManager(type: RegistryType): Manager;
@@ -0,0 +1,7 @@
1
+ import { ManagerLocal } from './ManagerLocal.js';
2
+ import { Registry } from './Registry.js';
3
+ export declare class RegistryLocal extends Registry {
4
+ protected managers: Record<string, ManagerLocal>;
5
+ constructor(name: string, url: string, version: string);
6
+ scan(ext?: string): void;
7
+ }
@@ -0,0 +1,13 @@
1
+ import { Registry } from './Registry.js';
2
+ export class RegistryLocal extends Registry {
3
+ managers;
4
+ constructor(name, url, version) {
5
+ super(name, url, version);
6
+ this.managers = {};
7
+ }
8
+ scan(ext = 'json') {
9
+ for (const [, manager] of Object.entries(this.managers)) {
10
+ manager.scan(ext);
11
+ }
12
+ }
13
+ }
@@ -14,7 +14,8 @@ import { ZodIssueCode } from 'zod';
14
14
  import { SystemType } from '../types/SystemType.js';
15
15
  import { fileURLToPath } from 'url';
16
16
  import sudoPrompt from '@vscode/sudo-prompt';
17
- import { getSystem, log } from './utils.js';
17
+ import { log } from './utils.js';
18
+ import { getSystem } from './utilsLocal.js';
18
19
  export async function archiveExtract(filePath, dirPath) {
19
20
  console.log('⎋', dirPath);
20
21
  const ext = path.extname(filePath).trim().toLowerCase();
@@ -11,7 +11,7 @@ import { ProjectFile } from '../types/Project.js';
11
11
  import { ProjectType } from '../types/ProjectType.js';
12
12
  import { SystemType } from '../types/SystemType.js';
13
13
  import { PackageInterface, PackageValidationRec, PackageVersion } from '../types/Package.js';
14
- export declare function packageCompatibleFiles(pkg: PackageVersion): (PluginFile | PresetFile | ProjectFile)[];
14
+ export declare function packageCompatibleFiles(pkg: PackageVersion, arch: Architecture[], sys: SystemType[]): (PluginFile | PresetFile | ProjectFile)[];
15
15
  export declare function packageVersionLatest(pkg: PackageInterface): string;
16
16
  export declare const PackageSystemValidator: z.ZodObject<{
17
17
  max: z.ZodOptional<z.ZodNumber>;
@@ -170,8 +170,8 @@ export declare const PackageVersionValidator: z.ZodObject<{
170
170
  }>;
171
171
  url: z.ZodString;
172
172
  }, "strip", z.ZodTypeAny, {
173
- date: string;
174
173
  type: PluginType | PresetType | ProjectType;
174
+ date: string;
175
175
  url: string;
176
176
  audio: string;
177
177
  author: string;
@@ -195,8 +195,8 @@ export declare const PackageVersionValidator: z.ZodObject<{
195
195
  name: string;
196
196
  tags: string[];
197
197
  }, {
198
- date: string;
199
198
  type: PluginType | PresetType | ProjectType;
199
+ date: string;
200
200
  url: string;
201
201
  audio: string;
202
202
  author: string;
@@ -8,14 +8,13 @@ import { PluginType } from '../types/PluginType.js';
8
8
  import { PresetType } from '../types/PresetType.js';
9
9
  import { ProjectType } from '../types/ProjectType.js';
10
10
  import { SystemType } from '../types/SystemType.js';
11
- import { getArchitecture, getSystem } from './utils.js';
12
- export function packageCompatibleFiles(pkg) {
11
+ export function packageCompatibleFiles(pkg, arch, sys) {
13
12
  return pkg.files.filter((file) => {
14
13
  const archMatches = file.architectures.filter(architecture => {
15
- return architecture === getArchitecture();
14
+ return arch.includes(architecture);
16
15
  });
17
16
  const sysMatches = file.systems.filter(system => {
18
- return system.type === getSystem();
17
+ return sys.includes(system.type);
19
18
  });
20
19
  return archMatches.length && sysMatches.length;
21
20
  });
@@ -1,11 +1,6 @@
1
1
  import { PackageValidationRec } from '../types/Package.js';
2
2
  import { ZodIssue } from 'zod';
3
- import { SystemType } from '../types/SystemType.js';
4
- import { Architecture } from '../types/Architecture.js';
5
- export declare function getArchitecture(): Architecture;
6
- export declare function getSystem(): SystemType;
7
3
  export declare function inputGetParts(input: string): string[];
8
- export declare function isTests(): boolean;
9
4
  export declare function log(...args: any): boolean;
10
5
  export declare function logEnable(): boolean;
11
6
  export declare function logDisable(): boolean;
@@ -1,31 +1,8 @@
1
1
  import chalk from 'chalk';
2
- import { SystemType } from '../types/SystemType.js';
3
- import { Architecture } from '../types/Architecture.js';
4
2
  let LOGGING_ENABLED = false;
5
- export function getArchitecture() {
6
- if (process.arch === 'arm')
7
- return Architecture.Arm32;
8
- if (process.arch === 'arm64')
9
- return Architecture.Arm64;
10
- if (process.arch === 'ia32')
11
- return Architecture.X32;
12
- return Architecture.X64;
13
- }
14
- export function getSystem() {
15
- if (process.platform === 'win32')
16
- return SystemType.Windows;
17
- else if (process.platform === 'darwin')
18
- return SystemType.Macintosh;
19
- return SystemType.Linux;
20
- }
21
3
  export function inputGetParts(input) {
22
4
  return input.split('@');
23
5
  }
24
- export function isTests() {
25
- const jest = process.env.JEST_WORKER_ID !== undefined;
26
- const vitest = process.env.VITEST_WORKER_ID !== undefined;
27
- return jest || vitest;
28
- }
29
6
  export function log(...args) {
30
7
  if (LOGGING_ENABLED) {
31
8
  console.log(...args);
@@ -0,0 +1,5 @@
1
+ import { SystemType } from '../types/SystemType.js';
2
+ import { Architecture } from '../types/Architecture.js';
3
+ export declare function getArchitecture(): Architecture;
4
+ export declare function getSystem(): SystemType;
5
+ export declare function isTests(): boolean;
@@ -0,0 +1,23 @@
1
+ import { SystemType } from '../types/SystemType.js';
2
+ import { Architecture } from '../types/Architecture.js';
3
+ export function getArchitecture() {
4
+ if (process.arch === 'arm')
5
+ return Architecture.Arm32;
6
+ if (process.arch === 'arm64')
7
+ return Architecture.Arm64;
8
+ if (process.arch === 'ia32')
9
+ return Architecture.X32;
10
+ return Architecture.X64;
11
+ }
12
+ export function getSystem() {
13
+ if (process.platform === 'win32')
14
+ return SystemType.Windows;
15
+ else if (process.platform === 'darwin')
16
+ return SystemType.Macintosh;
17
+ return SystemType.Linux;
18
+ }
19
+ export function isTests() {
20
+ const jest = process.env.JEST_WORKER_ID !== undefined;
21
+ const vitest = process.env.VITEST_WORKER_ID !== undefined;
22
+ return jest || vitest;
23
+ }
@@ -18,6 +18,7 @@ export * from './helpers/config.js';
18
18
  export * from './helpers/package.js';
19
19
  export * from './helpers/registry.js';
20
20
  export * from './helpers/utils.js';
21
+ // export * from './helpers/utilsLocal.js';
21
22
  // Types
22
23
  export * from './types/Architecture.js';
23
24
  export * from './types/Config.js';
package/build/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './helpers/file.js';
11
11
  export * from './helpers/package.js';
12
12
  export * from './helpers/registry.js';
13
13
  export * from './helpers/utils.js';
14
+ export * from './helpers/utilsLocal.js';
14
15
  export * from './types/Architecture.js';
15
16
  export * from './types/Config.js';
16
17
  export * from './types/File.js';
package/build/index.js CHANGED
@@ -18,6 +18,7 @@ export * from './helpers/file.js';
18
18
  export * from './helpers/package.js';
19
19
  export * from './helpers/registry.js';
20
20
  export * from './helpers/utils.js';
21
+ export * from './helpers/utilsLocal.js';
21
22
  // Types
22
23
  export * from './types/Architecture.js';
23
24
  export * from './types/Config.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",