@open-audio-stack/core 0.1.38 → 0.1.40

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>;
@@ -105,9 +105,6 @@ export class ManagerLocal extends Manager {
105
105
  { name: 'date', type: 'input', message: 'Date released', default: new Date().toISOString() },
106
106
  { name: 'changes', type: 'input', message: 'List of changes' },
107
107
  ];
108
- if (this.type === RegistryType.Projects) {
109
- pkgVersionQuestions.push({ name: 'open', type: 'input', message: 'File to open' });
110
- }
111
108
  const pkgVersionAnswers = await inquirer.prompt(pkgVersionQuestions);
112
109
  // TODO prompt for each file.
113
110
  pkgVersionAnswers.files = [];
@@ -317,11 +314,49 @@ export class ManagerLocal extends Manager {
317
314
  pkgFile.installed = true;
318
315
  return pkgFile;
319
316
  }
320
- open(filePath) {
321
- const pkgFile = packageLoadFile(filePath);
322
- // If installer, run the installer.
323
- if (pkgFile.open) {
324
- fileOpen(pkgFile.open);
317
+ open(slug, version, options = []) {
318
+ this.log('open', slug, version, options);
319
+ // Get package information
320
+ const pkg = this.getPackage(slug);
321
+ if (!pkg) {
322
+ this.log(`Package ${slug} not found`);
323
+ return false;
324
+ }
325
+ const versionNum = version || pkg.latestVersion();
326
+ const pkgVersion = pkg.getVersion(versionNum);
327
+ if (!pkgVersion) {
328
+ this.log(`Package ${slug} version ${versionNum} not found`);
329
+ return false;
330
+ }
331
+ // Check if package is installed
332
+ if (!this.isPackageInstalled(slug, versionNum)) {
333
+ this.log(`Package ${slug} version ${versionNum} not installed`);
334
+ return false;
335
+ }
336
+ // Filter compatible files and find one with open field
337
+ const files = packageCompatibleFiles(pkgVersion, [getArchitecture()], [getSystem()], []);
338
+ const openableFile = files.find(file => file.open);
339
+ if (!openableFile) {
340
+ this.log(`Package ${slug} has no compatible file with open command defined`);
341
+ return false;
342
+ }
343
+ try {
344
+ const openPath = openableFile.open;
345
+ const packageDir = path.join(this.typeDir, slug, versionNum);
346
+ const fullPath = path.isAbsolute(openPath) ? openPath : path.join(packageDir, openPath);
347
+ const command = `"${fullPath}" ${options.join(' ')}`;
348
+ this.log(`Running: ${command}`);
349
+ if (isTests()) {
350
+ this.log(`Would run: ${command}`);
351
+ }
352
+ else {
353
+ fileOpen(fullPath);
354
+ }
355
+ return true;
356
+ }
357
+ catch (error) {
358
+ this.log(`Error opening package ${slug}:`, error);
359
+ return false;
325
360
  }
326
361
  }
327
362
  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
@@ -91,7 +91,7 @@ export declare const PackageTypeObj: {
91
91
  Tool: PluginType.Tool;
92
92
  };
93
93
  export declare const PackageVersionValidator: z.ZodObject<{
94
- audio: z.ZodString;
94
+ audio: z.ZodOptional<z.ZodString>;
95
95
  author: z.ZodString;
96
96
  changes: z.ZodString;
97
97
  date: z.ZodString;
@@ -166,11 +166,10 @@ export declare const PackageVersionValidator: z.ZodObject<{
166
166
  url: z.ZodString;
167
167
  }, "strip", z.ZodTypeAny, {
168
168
  date: string;
169
- audio: string;
169
+ type: PluginType | PresetType | ProjectType;
170
170
  author: string;
171
171
  changes: string;
172
172
  description: string;
173
- type: PluginType | PresetType | ProjectType;
174
173
  url: string;
175
174
  files: {
176
175
  type: FileType;
@@ -188,14 +187,14 @@ export declare const PackageVersionValidator: z.ZodObject<{
188
187
  license: License;
189
188
  name: string;
190
189
  tags: string[];
190
+ audio?: string | undefined;
191
191
  donate?: string | undefined;
192
192
  }, {
193
193
  date: string;
194
- audio: string;
194
+ type: PluginType | PresetType | ProjectType;
195
195
  author: string;
196
196
  changes: string;
197
197
  description: string;
198
- type: PluginType | PresetType | ProjectType;
199
198
  url: string;
200
199
  files: {
201
200
  type: FileType;
@@ -213,6 +212,7 @@ export declare const PackageVersionValidator: z.ZodObject<{
213
212
  license: License;
214
213
  name: string;
215
214
  tags: string[];
215
+ audio?: string | undefined;
216
216
  donate?: string | undefined;
217
217
  }>;
218
218
  export declare const SemverValidator: z.ZodString;
@@ -57,7 +57,7 @@ export const PackageFileValidator = z.object({
57
57
  });
58
58
  export const PackageTypeObj = { ...PluginType, ...PresetType, ...ProjectType };
59
59
  export const PackageVersionValidator = z.object({
60
- audio: z.string().min(8).max(256).startsWith('https://'),
60
+ audio: z.optional(z.string().min(8).max(256).startsWith('https://')),
61
61
  author: z.string().min(1).max(256),
62
62
  changes: z.string().min(1).max(256),
63
63
  date: z.string().datetime(),
@@ -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,6 +3,7 @@ import { FileType } from './FileType.js';
3
3
  import { System } from './System.js';
4
4
  export interface FileInterface {
5
5
  architectures: Architecture[];
6
+ open?: string;
6
7
  sha256: string;
7
8
  size: number;
8
9
  systems: System[];
@@ -12,7 +12,7 @@ export interface PackageVersions {
12
12
  [version: string]: PackageVersion;
13
13
  }
14
14
  export interface PackageBase {
15
- audio: string;
15
+ audio?: string;
16
16
  author: string;
17
17
  changes: string;
18
18
  date: string;
@@ -5,7 +5,6 @@ import { ProjectType } from './ProjectType.js';
5
5
  import { RegistryType } from './Registry.js';
6
6
  export interface ProjectInterface extends PackageBase {
7
7
  files: ProjectFile[];
8
- open: string;
9
8
  [RegistryType.Plugins]: ProjectPlugins;
10
9
  type: ProjectType;
11
10
  }
@@ -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.40",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",