@open-audio-stack/core 0.1.23 → 0.1.24

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.
@@ -1,3 +1,4 @@
1
+ import { Package } from './Package.js';
1
2
  import { PackageVersion } from '../types/Package.js';
2
3
  import { Manager } from './Manager.js';
3
4
  import { RegistryType } from '../types/Registry.js';
@@ -9,6 +10,7 @@ export declare class ManagerLocal extends Manager {
9
10
  scan(ext?: string, installable?: boolean): void;
10
11
  export(dir: string, ext?: string): boolean;
11
12
  install(slug: string, version?: string): Promise<void | PackageVersion>;
13
+ installAll(): Promise<Package[]>;
12
14
  installDependency(slug: string, version?: string, filePath?: string, type?: RegistryType): Promise<any>;
13
15
  installDependencies(filePath?: string, type?: RegistryType): Promise<any>;
14
16
  open(filePath?: string): void;
@@ -212,6 +212,12 @@ export class ManagerLocal extends Manager {
212
212
  fileOpen(filePath);
213
213
  else
214
214
  fileInstall(filePath);
215
+ // Currently we don't get a list of paths from the installer.
216
+ // Create empty directory and save package version information.
217
+ // Installers have to be manually uninstalled for now.
218
+ const dirTarget = path.join(this.typeDir, 'Installers', slug, versionNum);
219
+ dirCreate(dirTarget);
220
+ fileCreateJson(path.join(dirTarget, 'index.json'), pkgVersion);
215
221
  }
216
222
  // If archive, extract the archive to temporary directory, then move individual files.
217
223
  if (file.type === FileType.Archive) {
@@ -243,6 +249,22 @@ export class ManagerLocal extends Manager {
243
249
  pkgVersion.installed = true;
244
250
  return pkgVersion;
245
251
  }
252
+ async installAll() {
253
+ // Elevate permissions if not running as admin.
254
+ if (!isAdmin() && !isTests()) {
255
+ let command = `--appDir "${this.config.get('appDir')}" --operation "installAll" --type "${this.type}"`;
256
+ if (this.debug)
257
+ command += ` --log`;
258
+ await runCliAsAdmin(command);
259
+ return this.listPackages();
260
+ }
261
+ // Loop through all packages and install each one.
262
+ for (const [slug, pkg] of this.packages) {
263
+ const versionNum = pkg.latestVersion();
264
+ await this.install(slug, versionNum);
265
+ }
266
+ return this.listPackages();
267
+ }
246
268
  async installDependency(slug, version, filePath, type = RegistryType.Plugins) {
247
269
  // Get dependency package information from registry.
248
270
  const manager = new ManagerLocal(type, this.config.config);
@@ -48,5 +48,8 @@ export async function adminInit() {
48
48
  else if (args.operation === 'uninstall') {
49
49
  await manager.uninstall(args.id, args.version);
50
50
  }
51
+ else if (args.operation === 'installAll') {
52
+ await manager.installAll();
53
+ }
51
54
  }
52
55
  adminInit();
@@ -40,5 +40,5 @@ export declare function fileSize(filePath: string): number;
40
40
  export declare function isAdmin(): boolean;
41
41
  export declare function fileValidateMetadata(filePath: string, fileMetadata: PluginFile | PresetFile | ProjectFile): Promise<ZodIssue[]>;
42
42
  export declare function getPlatform(): SystemType;
43
- export declare function runCliAsAdmin(args: string): Promise<string>;
43
+ export declare function runCliAsAdmin(args: string): Promise<void>;
44
44
  export declare function zipCreate(filesPath: string, zipPath: string): void;
@@ -1,5 +1,5 @@
1
1
  import AdmZip from 'adm-zip';
2
- import { execFileSync, execSync } from 'child_process';
2
+ import { execFileSync, execSync, spawn } from 'child_process';
3
3
  import { createReadStream, chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
4
4
  import { createHash } from 'crypto';
5
5
  import { unpack } from '7zip-min';
@@ -175,7 +175,7 @@ export function fileInstall(filePath) {
175
175
  let command = null;
176
176
  switch (ext) {
177
177
  case '.dmg':
178
- command = `hdiutil attach -nobrowse "${filePath}" && sudo installer -pkg "$(find /Volumes -name '*.pkg' -maxdepth 2 | head -n 1)" -target / && hdiutil detach "$(find /Volumes -type d -maxdepth 1 -mindepth 1 | grep -v 'Macintosh HD')"`;
178
+ command = `hdiutil attach -nobrowse "${filePath}" && sudo installer -pkg "$(find /Volumes -name '*.pkg' -maxdepth 2 | head -n 1)" -target / && hdiutil detach "$(dirname "$(find /Volumes -name '*.pkg' -maxdepth 2 | head -n 1)")"`;
179
179
  break;
180
180
  case '.pkg':
181
181
  command = `sudo installer -pkg "${filePath}" -target /`;
@@ -312,19 +312,25 @@ export function runCliAsAdmin(args) {
312
312
  const filename = fileURLToPath(import.meta.url).replace('src/', 'build/');
313
313
  const dirPathClean = dirname(filename).replace('app.asar', 'app.asar.unpacked');
314
314
  const script = path.join(dirPathClean, 'admin.js');
315
- log(`node "${script}" ${args}`);
316
- sudoPrompt.exec(`node "${script}" ${args}`, { name: 'Open Audio Stack' }, (error, stdout, stderr) => {
317
- if (stdout) {
318
- log('runCliAsAdmin', stdout);
319
- }
320
- if (stderr) {
321
- log('runCliAsAdmin', stderr);
322
- }
315
+ // Temp file for logging
316
+ const logFile = path.join(dirPathClean, 'admin.log');
317
+ writeFileSync(logFile, ''); // Clear previous logs
318
+ log(`Running as admin: node "${script}" ${args}`);
319
+ // Tail the log file in real-time
320
+ const tail = spawn('tail', ['-f', logFile]);
321
+ const grep = spawn('grep', ['.']);
322
+ tail.stdout.pipe(grep.stdin);
323
+ grep.stdout.on('data', data => {
324
+ log(data.toString());
325
+ });
326
+ // Run the script with sudoPrompt
327
+ sudoPrompt.exec(`node "${script}" ${args} >> "${logFile}" 2>&1`, { name: 'Open Audio Stack' }, error => {
328
+ tail.kill();
323
329
  if (error) {
324
330
  reject(error);
325
331
  }
326
332
  else {
327
- resolve(stdout?.toString() || '');
333
+ resolve();
328
334
  }
329
335
  });
330
336
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",