@open-audio-stack/core 0.1.38 → 0.1.39

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.
@@ -14,7 +14,7 @@ export declare class ManagerLocal extends Manager {
14
14
  installAll(): Promise<Package[]>;
15
15
  installDependency(slug: string, version?: string, filePath?: string, type?: RegistryType): Promise<any>;
16
16
  installDependencies(filePath: string, type?: RegistryType): Promise<any>;
17
- open(filePath: string): void;
17
+ open(slug: string, version?: string, options?: string[]): boolean;
18
18
  uninstall(slug: string, version?: string): Promise<void | PackageVersion>;
19
19
  uninstallDependency(slug: string, version?: string, filePath?: string, type?: RegistryType): Promise<any>;
20
20
  uninstallDependencies(filePath?: string, type?: RegistryType): Promise<any>;
@@ -317,11 +317,47 @@ export class ManagerLocal extends Manager {
317
317
  pkgFile.installed = true;
318
318
  return pkgFile;
319
319
  }
320
- open(filePath) {
321
- const pkgFile = packageLoadFile(filePath);
322
- // If installer, run the installer.
323
- if (pkgFile.open) {
324
- fileOpen(pkgFile.open);
320
+ open(slug, version, options = []) {
321
+ this.log('open', slug, version, options);
322
+ // Get package information
323
+ const pkg = this.getPackage(slug);
324
+ if (!pkg) {
325
+ this.log(`Package ${slug} not found`);
326
+ return false;
327
+ }
328
+ const versionNum = version || pkg.latestVersion();
329
+ const pkgVersion = pkg.getVersion(versionNum);
330
+ if (!pkgVersion) {
331
+ this.log(`Package ${slug} version ${versionNum} not found`);
332
+ return false;
333
+ }
334
+ // Check if package has open field
335
+ if (!pkgVersion.open) {
336
+ this.log(`Package ${slug} has no open command defined`);
337
+ return false;
338
+ }
339
+ // Check if package is installed
340
+ if (!this.isPackageInstalled(slug, versionNum)) {
341
+ this.log(`Package ${slug} version ${versionNum} not installed`);
342
+ return false;
343
+ }
344
+ try {
345
+ const openPath = pkgVersion.open;
346
+ const packageDir = path.join(this.typeDir, slug, versionNum);
347
+ const fullPath = path.isAbsolute(openPath) ? openPath : path.join(packageDir, openPath);
348
+ const command = `"${fullPath}" ${options.join(' ')}`;
349
+ this.log(`Running: ${command}`);
350
+ if (isTests()) {
351
+ this.log(`Would run: ${command}`);
352
+ }
353
+ else {
354
+ fileOpen(fullPath);
355
+ }
356
+ return true;
357
+ }
358
+ catch (error) {
359
+ this.log(`Error opening package ${slug}:`, error);
360
+ return false;
325
361
  }
326
362
  }
327
363
  async uninstall(slug, version) {
@@ -1,9 +1,10 @@
1
1
  import { configDefaults } from './config.js';
2
- import { dirApp, dirPlugins, dirPresets, dirProjects } from './file.js';
2
+ import { dirApp, dirApps, dirPlugins, dirPresets, dirProjects } from './file.js';
3
3
  export function configDefaultsLocal() {
4
4
  return {
5
5
  ...configDefaults(),
6
6
  appDir: dirApp(),
7
+ appsDir: dirApps(),
7
8
  pluginsDir: dirPlugins(),
8
9
  presetsDir: dirPresets(),
9
10
  projectsDir: dirProjects(),
@@ -19,6 +19,7 @@ export declare function dirPackage(pkg: PackageInterface): string;
19
19
  export declare function dirPlugins(): string;
20
20
  export declare function dirPresets(): string;
21
21
  export declare function dirProjects(): string;
22
+ export declare function dirApps(): string;
22
23
  export declare function dirRead(dir: string, options?: GlobOptionsWithFileTypesFalse): string[];
23
24
  export declare function dirRename(dir: string, dirNew: string): void | boolean;
24
25
  export declare function fileCreate(filePath: string, data: string | Buffer): void;
@@ -141,6 +141,13 @@ export function dirProjects() {
141
141
  return path.join(os.homedir(), 'Documents', 'Audio');
142
142
  return path.join(os.homedir(), 'Documents', 'Audio');
143
143
  }
144
+ export function dirApps() {
145
+ if (getSystem() === SystemType.Win)
146
+ return path.join(os.homedir(), 'AppData', 'Local', 'Programs');
147
+ else if (getSystem() === SystemType.Mac)
148
+ return path.join('/Applications');
149
+ return path.join('/usr', 'local', 'bin');
150
+ }
144
151
  export function dirRead(dir, options) {
145
152
  log('⌕', dir);
146
153
  // Glob now expects forward slashes on Windows
@@ -1,5 +1,6 @@
1
1
  export interface ConfigInterface {
2
2
  appDir?: string;
3
+ appsDir?: string;
3
4
  pluginsDir?: string;
4
5
  presetsDir?: string;
5
6
  projectsDir?: string;
@@ -3,11 +3,13 @@ export interface RegistryInterface {
3
3
  name: string;
4
4
  url: string;
5
5
  version: string;
6
+ [RegistryType.Apps]?: RegistryPackages;
6
7
  [RegistryType.Plugins]?: RegistryPackages;
7
8
  [RegistryType.Presets]?: RegistryPackages;
8
9
  [RegistryType.Projects]?: RegistryPackages;
9
10
  }
10
11
  export declare enum RegistryType {
12
+ Apps = "apps",
11
13
  Plugins = "plugins",
12
14
  Presets = "presets",
13
15
  Projects = "projects"
@@ -1,5 +1,6 @@
1
1
  export var RegistryType;
2
2
  (function (RegistryType) {
3
+ RegistryType["Apps"] = "apps";
3
4
  RegistryType["Plugins"] = "plugins";
4
5
  RegistryType["Presets"] = "presets";
5
6
  RegistryType["Projects"] = "projects";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",