@open-audio-stack/core 0.1.22 → 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) {
@@ -222,10 +228,10 @@ export class ManagerLocal extends Manager {
222
228
  formatDir = presetFormatDir;
223
229
  if (this.type === RegistryType.Projects)
224
230
  formatDir = projectFormatDir;
225
- archiveExtract(filePath, dirSource);
231
+ await archiveExtract(filePath, dirSource);
226
232
  // Move entire directory, maintaining the same folder structure.
227
233
  if (pkgVersion.type === PluginType.Sampler) {
228
- const dirTarget = path.join(this.typeDir, PluginType.Sampler, dirSub);
234
+ const dirTarget = path.join(this.typeDir, 'Samplers', dirSub);
229
235
  dirCreate(dirTarget);
230
236
  dirMove(dirSource, dirTarget);
231
237
  fileCreateJson(path.join(dirTarget, 'index.json'), pkgVersion);
@@ -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);
@@ -302,7 +324,7 @@ export class ManagerLocal extends Manager {
302
324
  return this.log(`Package ${slug} version ${versionNum} not installed`);
303
325
  // Elevate permissions if not running as admin.
304
326
  if (!isAdmin() && !isTests()) {
305
- let command = `--appDir "${this.config.get('appDir')}" --operation "install" --type "${this.type}" --id "${slug}"`;
327
+ let command = `--appDir "${this.config.get('appDir')}" --operation "uninstall" --type "${this.type}" --id "${slug}"`;
306
328
  if (version)
307
329
  command += ` --ver "${version}"`;
308
330
  if (this.debug)
@@ -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';
@@ -23,8 +23,8 @@ export async function archiveExtract(filePath, dirPath) {
23
23
  const zip = new AdmZip(filePath);
24
24
  return zip.extractAllTo(dirPath);
25
25
  }
26
- else if (ext === '.tar' || ext === '.tar.gz' || ext === '.tgz') {
27
- return await tar.x({
26
+ else if (ext === '.tar' || ext === '.gz' || ext === '.tgz') {
27
+ return await tar.extract({
28
28
  file: filePath,
29
29
  cwd: dirPath,
30
30
  });
@@ -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
  });
@@ -5,7 +5,7 @@ export declare enum FileFormat {
5
5
  DebianPackage = "deb",// Installer
6
6
  ExecutableInstaller = "exe",// Installer
7
7
  RedHatPackage = "rpm",// Installer
8
- Tarball = "tar.gz",// Archive
8
+ Tarball = "gz",// Archive
9
9
  TarballLegacy = "tgz",// Archive
10
10
  WindowsInstaller = "msi",// Installer
11
11
  Zip = "zip",// Archive
@@ -9,7 +9,7 @@ export var FileFormat;
9
9
  FileFormat["DebianPackage"] = "deb";
10
10
  FileFormat["ExecutableInstaller"] = "exe";
11
11
  FileFormat["RedHatPackage"] = "rpm";
12
- FileFormat["Tarball"] = "tar.gz";
12
+ FileFormat["Tarball"] = "gz";
13
13
  FileFormat["TarballLegacy"] = "tgz";
14
14
  FileFormat["WindowsInstaller"] = "msi";
15
15
  FileFormat["Zip"] = "zip";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",