Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ Install a package:
studiorack <registryType> install <slug>@<version>
studiorack plugins install surge-synthesizer/surge

Install and open an app:

studiorack apps install steinberg/validator
studiorack apps open steinberg/validator -- --help

For a full list of commands, please refer to the [Open Audio Stack - Manager specification](https://github.com/open-audio-stack/open-audio-stack-core/blob/main/specification.md)

## Developer information
Expand Down
299 changes: 132 additions & 167 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studiorack/cli",
"version": "3.0.4",
"version": "3.0.5",
"description": "Audio project manager tool",
"type": "module",
"main": "./build/index.js",
Expand Down Expand Up @@ -39,7 +39,7 @@
"node": ">=18"
},
"dependencies": {
"@open-audio-stack/core": "^0.1.38",
"@open-audio-stack/core": "^0.1.45",
"cli-table3": "^0.6.5",
"commander": "^12.1.0",
"ora": "^9.0.0"
Expand Down
6 changes: 3 additions & 3 deletions src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export function install(command: Command, manager: ManagerLocal) {
spinner.succeed(`Installed ${slug}${version ? `@${version}` : ''}`);
if (isTests()) console.log(`Installed ${slug}${version ? `@${version}` : ''}`);
} catch (error) {
spinner.fail(`Failed to install ${slug}${version ? `@${version}` : ''}`);
if (isTests()) console.log(`Failed to install ${slug}${version ? `@${version}` : ''}`);
throw error;
const errorMessage = error instanceof Error ? error.message : String(error);
spinner.fail(errorMessage);
if (isTests()) console.log(errorMessage);
}
});
}
4 changes: 3 additions & 1 deletion src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import { ManagerLocal } from '@open-audio-stack/core';
import { formatOutput } from '../utils.js';

interface ListOptions extends CliOptions {
incompatible: boolean;
installed: boolean;
}

export function list(command: Command, manager: ManagerLocal) {
command
.command('list')
.option('-c, --incompatible', 'List incompatible packages')
.option('-i, --installed', 'Only list installed packages')
.option('-l, --log', 'Enable logging')
.description('List packages')
.action(async (options: ListOptions) => {
if (options.log) manager.logEnable();
else manager.logDisable();
console.log(formatOutput(manager.listPackages(options.installed)));
console.log(formatOutput(manager.listPackages(options.installed, options.incompatible)));
});
}
22 changes: 22 additions & 0 deletions src/commands/open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Command } from 'commander';
import { CliOptions } from '../types/options.js';
import { inputGetParts, ManagerLocal } from '@open-audio-stack/core';

export function open(command: Command, manager: ManagerLocal) {
command
.command('open <input> [options...]')
.option('-l, --log', 'Enable logging')
.description('Open a package by slug/version')
.action(async (input: string, options: string[], cliOptions: CliOptions) => {
if (cliOptions.log) manager.logEnable();
else manager.logDisable();
const [slug, version] = inputGetParts(input);
try {
await manager.open(slug, version, options);
} catch (error: any) {
const errorMessage = error instanceof Error ? error.message : String(error);
console.error(errorMessage);
process.exit(1);
}
});
}
6 changes: 3 additions & 3 deletions src/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function sync(command: Command, manager: ManagerLocal) {
spinner.succeed(`${manager.type} sync completed`);
if (isTests()) console.log(`${manager.type} sync completed`);
} catch (error) {
spinner.fail(`${manager.type} sync failed`);
if (isTests()) console.log(`${manager.type} sync failed`);
throw error;
const errorMessage = error instanceof Error ? error.message : String(error);
spinner.fail(errorMessage);
if (isTests()) console.log(errorMessage);
}
});
}
6 changes: 3 additions & 3 deletions src/commands/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export function uninstall(command: Command, manager: ManagerLocal) {
spinner.succeed(`Uninstalled ${slug}${version ? `@${version}` : ''}`);
if (isTests()) console.log(`Uninstalled ${slug}${version ? `@${version}` : ''}`);
} catch (error) {
spinner.fail(`Failed to uninstall ${slug}${version ? `@${version}` : ''}`);
if (isTests()) console.log(`Failed to uninstall ${slug}${version ? `@${version}` : ''}`);
throw error;
const errorMessage = error instanceof Error ? error.message : String(error);
spinner.fail(errorMessage);
if (isTests()) console.log(errorMessage);
}
});
}
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { filter } from './commands/filter.js';
import { get } from './commands/get.js';
import { install } from './commands/install.js';
import { list } from './commands/list.js';
import { open } from './commands/open.js';
import { reset } from './commands/reset.js';
import { scan } from './commands/scan.js';
import { search } from './commands/search.js';
Expand All @@ -20,7 +21,7 @@ const program = new Command();
program.addCommand(configCmd);

// Dynamically add commands for each registry type.
const types = [RegistryType.Plugins, RegistryType.Presets, RegistryType.Projects];
const types = [RegistryType.Apps, RegistryType.Plugins, RegistryType.Presets, RegistryType.Projects];
for (const type of types) {
const command: Command = program.command(type);
const manager: ManagerLocal = new ManagerLocal(type as RegistryType, isTests() ? CONFIG_LOCAL_TEST : undefined);
Expand All @@ -31,11 +32,12 @@ for (const type of types) {
get(command, manager);
install(command, manager);
list(command, manager);
open(command, manager);
reset(command, manager);
scan(command, manager);
search(command, manager);
sync(command, manager);
uninstall(command, manager);
}

program.version('3.0.0').parse(process.argv);
program.version('3.0.1').parse(process.argv);
82 changes: 46 additions & 36 deletions tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Options:

Commands:
config View/update configuration
apps
plugins
presets
projects
Expand All @@ -19,58 +20,67 @@ exports[`Root command plugins 1`] = `
Usage: index plugins [options] [command]

Options:
-h, --help display help for command
-h, --help display help for command

Commands:
create [options] <path> Create a new package locally
filter [options] <field> <value> Filter the by field and matching value
get [options] <input> Get package metadata from registry
install [options] <input> Install a package locally by slug/version
list [options] List packages
reset [options] Reset the synced package cache
scan [options] Scan local packages into cache
search [options] <query> Search using a lazy matching query
sync [options] Sync remote packages into cache
uninstall [options] <input> Uninstall a package locally by slug/version
help [command] display help for command
create [options] <path> Create a new package locally
filter [options] <field> <value> Filter the by field and matching value
get [options] <input> Get package metadata from registry
install [options] <input> Install a package locally by
slug/version
list [options] List packages
open [options] <input> [options...] Open a package by slug/version
reset [options] Reset the synced package cache
scan [options] Scan local packages into cache
search [options] <query> Search using a lazy matching query
sync [options] Sync remote packages into cache
uninstall [options] <input> Uninstall a package locally by
slug/version
help [command] display help for command
`;

exports[`Root command presets 1`] = `
Usage: index presets [options] [command]

Options:
-h, --help display help for command
-h, --help display help for command

Commands:
create [options] <path> Create a new package locally
filter [options] <field> <value> Filter the by field and matching value
get [options] <input> Get package metadata from registry
install [options] <input> Install a package locally by slug/version
list [options] List packages
reset [options] Reset the synced package cache
scan [options] Scan local packages into cache
search [options] <query> Search using a lazy matching query
sync [options] Sync remote packages into cache
uninstall [options] <input> Uninstall a package locally by slug/version
help [command] display help for command
create [options] <path> Create a new package locally
filter [options] <field> <value> Filter the by field and matching value
get [options] <input> Get package metadata from registry
install [options] <input> Install a package locally by
slug/version
list [options] List packages
open [options] <input> [options...] Open a package by slug/version
reset [options] Reset the synced package cache
scan [options] Scan local packages into cache
search [options] <query> Search using a lazy matching query
sync [options] Sync remote packages into cache
uninstall [options] <input> Uninstall a package locally by
slug/version
help [command] display help for command
`;

exports[`Root command projects 1`] = `
Usage: index projects [options] [command]

Options:
-h, --help display help for command
-h, --help display help for command

Commands:
create [options] <path> Create a new package locally
filter [options] <field> <value> Filter the by field and matching value
get [options] <input> Get package metadata from registry
install [options] <input> Install a package locally by slug/version
list [options] List packages
reset [options] Reset the synced package cache
scan [options] Scan local packages into cache
search [options] <query> Search using a lazy matching query
sync [options] Sync remote packages into cache
uninstall [options] <input> Uninstall a package locally by slug/version
help [command] display help for command
create [options] <path> Create a new package locally
filter [options] <field> <value> Filter the by field and matching value
get [options] <input> Get package metadata from registry
install [options] <input> Install a package locally by
slug/version
list [options] List packages
open [options] <input> [options...] Open a package by slug/version
reset [options] Reset the synced package cache
scan [options] Scan local packages into cache
search [options] <query> Search using a lazy matching query
sync [options] Sync remote packages into cache
uninstall [options] <input> Uninstall a package locally by
slug/version
help [command] display help for command
`;
2 changes: 1 addition & 1 deletion tests/commands/__snapshots__/install.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ exports[`Install package 1`] = `Installed surge-synthesizer/surge`;

exports[`Install package 2`] = `Installed surge-synthesizer/surge@1.3.1`;

exports[`Install package 3`] = `Installed surge-synthesizer/surge@0.0.0`;
exports[`Install package 3`] = `Package surge-synthesizer/surge version 0.0.0 not found in registry`;
Loading
Loading