Skip to content

Commit 05bf297

Browse files
authored
Merge pull request #17 from studiorack/feature/apps
Feature/apps
2 parents d224a40 + 8861678 commit 05bf297

17 files changed

Lines changed: 371 additions & 310 deletions

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ Install a package:
4747
studiorack <registryType> install <slug>@<version>
4848
studiorack plugins install surge-synthesizer/surge
4949

50+
Install and open an app:
51+
52+
studiorack apps install steinberg/validator
53+
studiorack apps open steinberg/validator -- --help
54+
5055
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)
5156

5257
## Developer information

package-lock.json

Lines changed: 132 additions & 167 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@studiorack/cli",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"description": "Audio project manager tool",
55
"type": "module",
66
"main": "./build/index.js",
@@ -39,7 +39,7 @@
3939
"node": ">=18"
4040
},
4141
"dependencies": {
42-
"@open-audio-stack/core": "^0.1.38",
42+
"@open-audio-stack/core": "^0.1.45",
4343
"cli-table3": "^0.6.5",
4444
"commander": "^12.1.0",
4545
"ora": "^9.0.0"

src/commands/install.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export function install(command: Command, manager: ManagerLocal) {
1818
spinner.succeed(`Installed ${slug}${version ? `@${version}` : ''}`);
1919
if (isTests()) console.log(`Installed ${slug}${version ? `@${version}` : ''}`);
2020
} catch (error) {
21-
spinner.fail(`Failed to install ${slug}${version ? `@${version}` : ''}`);
22-
if (isTests()) console.log(`Failed to install ${slug}${version ? `@${version}` : ''}`);
23-
throw error;
21+
const errorMessage = error instanceof Error ? error.message : String(error);
22+
spinner.fail(errorMessage);
23+
if (isTests()) console.log(errorMessage);
2424
}
2525
});
2626
}

src/commands/list.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ import { ManagerLocal } from '@open-audio-stack/core';
44
import { formatOutput } from '../utils.js';
55

66
interface ListOptions extends CliOptions {
7+
incompatible: boolean;
78
installed: boolean;
89
}
910

1011
export function list(command: Command, manager: ManagerLocal) {
1112
command
1213
.command('list')
14+
.option('-c, --incompatible', 'List incompatible packages')
1315
.option('-i, --installed', 'Only list installed packages')
1416
.option('-l, --log', 'Enable logging')
1517
.description('List packages')
1618
.action(async (options: ListOptions) => {
1719
if (options.log) manager.logEnable();
1820
else manager.logDisable();
19-
console.log(formatOutput(manager.listPackages(options.installed)));
21+
console.log(formatOutput(manager.listPackages(options.installed, options.incompatible)));
2022
});
2123
}

src/commands/open.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Command } from 'commander';
2+
import { CliOptions } from '../types/options.js';
3+
import { inputGetParts, ManagerLocal } from '@open-audio-stack/core';
4+
5+
export function open(command: Command, manager: ManagerLocal) {
6+
command
7+
.command('open <input> [options...]')
8+
.option('-l, --log', 'Enable logging')
9+
.description('Open a package by slug/version')
10+
.action(async (input: string, options: string[], cliOptions: CliOptions) => {
11+
if (cliOptions.log) manager.logEnable();
12+
else manager.logDisable();
13+
const [slug, version] = inputGetParts(input);
14+
try {
15+
await manager.open(slug, version, options);
16+
} catch (error: any) {
17+
const errorMessage = error instanceof Error ? error.message : String(error);
18+
console.error(errorMessage);
19+
process.exit(1);
20+
}
21+
});
22+
}

src/commands/sync.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export function sync(command: Command, manager: ManagerLocal) {
1717
spinner.succeed(`${manager.type} sync completed`);
1818
if (isTests()) console.log(`${manager.type} sync completed`);
1919
} catch (error) {
20-
spinner.fail(`${manager.type} sync failed`);
21-
if (isTests()) console.log(`${manager.type} sync failed`);
22-
throw error;
20+
const errorMessage = error instanceof Error ? error.message : String(error);
21+
spinner.fail(errorMessage);
22+
if (isTests()) console.log(errorMessage);
2323
}
2424
});
2525
}

src/commands/uninstall.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export function uninstall(command: Command, manager: ManagerLocal) {
1818
spinner.succeed(`Uninstalled ${slug}${version ? `@${version}` : ''}`);
1919
if (isTests()) console.log(`Uninstalled ${slug}${version ? `@${version}` : ''}`);
2020
} catch (error) {
21-
spinner.fail(`Failed to uninstall ${slug}${version ? `@${version}` : ''}`);
22-
if (isTests()) console.log(`Failed to uninstall ${slug}${version ? `@${version}` : ''}`);
23-
throw error;
21+
const errorMessage = error instanceof Error ? error.message : String(error);
22+
spinner.fail(errorMessage);
23+
if (isTests()) console.log(errorMessage);
2424
}
2525
});
2626
}

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { filter } from './commands/filter.js';
99
import { get } from './commands/get.js';
1010
import { install } from './commands/install.js';
1111
import { list } from './commands/list.js';
12+
import { open } from './commands/open.js';
1213
import { reset } from './commands/reset.js';
1314
import { scan } from './commands/scan.js';
1415
import { search } from './commands/search.js';
@@ -20,7 +21,7 @@ const program = new Command();
2021
program.addCommand(configCmd);
2122

2223
// Dynamically add commands for each registry type.
23-
const types = [RegistryType.Plugins, RegistryType.Presets, RegistryType.Projects];
24+
const types = [RegistryType.Apps, RegistryType.Plugins, RegistryType.Presets, RegistryType.Projects];
2425
for (const type of types) {
2526
const command: Command = program.command(type);
2627
const manager: ManagerLocal = new ManagerLocal(type as RegistryType, isTests() ? CONFIG_LOCAL_TEST : undefined);
@@ -31,11 +32,12 @@ for (const type of types) {
3132
get(command, manager);
3233
install(command, manager);
3334
list(command, manager);
35+
open(command, manager);
3436
reset(command, manager);
3537
scan(command, manager);
3638
search(command, manager);
3739
sync(command, manager);
3840
uninstall(command, manager);
3941
}
4042

41-
program.version('3.0.0').parse(process.argv);
43+
program.version('3.0.1').parse(process.argv);

tests/__snapshots__/index.test.ts.snap

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Options:
99
1010
Commands:
1111
config View/update configuration
12+
apps
1213
plugins
1314
presets
1415
projects
@@ -19,58 +20,67 @@ exports[`Root command plugins 1`] = `
1920
Usage: index plugins [options] [command]
2021
2122
Options:
22-
-h, --help display help for command
23+
-h, --help display help for command
2324
2425
Commands:
25-
create [options] <path> Create a new package locally
26-
filter [options] <field> <value> Filter the by field and matching value
27-
get [options] <input> Get package metadata from registry
28-
install [options] <input> Install a package locally by slug/version
29-
list [options] List packages
30-
reset [options] Reset the synced package cache
31-
scan [options] Scan local packages into cache
32-
search [options] <query> Search using a lazy matching query
33-
sync [options] Sync remote packages into cache
34-
uninstall [options] <input> Uninstall a package locally by slug/version
35-
help [command] display help for command
26+
create [options] <path> Create a new package locally
27+
filter [options] <field> <value> Filter the by field and matching value
28+
get [options] <input> Get package metadata from registry
29+
install [options] <input> Install a package locally by
30+
slug/version
31+
list [options] List packages
32+
open [options] <input> [options...] Open a package by slug/version
33+
reset [options] Reset the synced package cache
34+
scan [options] Scan local packages into cache
35+
search [options] <query> Search using a lazy matching query
36+
sync [options] Sync remote packages into cache
37+
uninstall [options] <input> Uninstall a package locally by
38+
slug/version
39+
help [command] display help for command
3640
`;
3741
3842
exports[`Root command presets 1`] = `
3943
Usage: index presets [options] [command]
4044
4145
Options:
42-
-h, --help display help for command
46+
-h, --help display help for command
4347
4448
Commands:
45-
create [options] <path> Create a new package locally
46-
filter [options] <field> <value> Filter the by field and matching value
47-
get [options] <input> Get package metadata from registry
48-
install [options] <input> Install a package locally by slug/version
49-
list [options] List packages
50-
reset [options] Reset the synced package cache
51-
scan [options] Scan local packages into cache
52-
search [options] <query> Search using a lazy matching query
53-
sync [options] Sync remote packages into cache
54-
uninstall [options] <input> Uninstall a package locally by slug/version
55-
help [command] display help for command
49+
create [options] <path> Create a new package locally
50+
filter [options] <field> <value> Filter the by field and matching value
51+
get [options] <input> Get package metadata from registry
52+
install [options] <input> Install a package locally by
53+
slug/version
54+
list [options] List packages
55+
open [options] <input> [options...] Open a package by slug/version
56+
reset [options] Reset the synced package cache
57+
scan [options] Scan local packages into cache
58+
search [options] <query> Search using a lazy matching query
59+
sync [options] Sync remote packages into cache
60+
uninstall [options] <input> Uninstall a package locally by
61+
slug/version
62+
help [command] display help for command
5663
`;
5764
5865
exports[`Root command projects 1`] = `
5966
Usage: index projects [options] [command]
6067
6168
Options:
62-
-h, --help display help for command
69+
-h, --help display help for command
6370
6471
Commands:
65-
create [options] <path> Create a new package locally
66-
filter [options] <field> <value> Filter the by field and matching value
67-
get [options] <input> Get package metadata from registry
68-
install [options] <input> Install a package locally by slug/version
69-
list [options] List packages
70-
reset [options] Reset the synced package cache
71-
scan [options] Scan local packages into cache
72-
search [options] <query> Search using a lazy matching query
73-
sync [options] Sync remote packages into cache
74-
uninstall [options] <input> Uninstall a package locally by slug/version
75-
help [command] display help for command
72+
create [options] <path> Create a new package locally
73+
filter [options] <field> <value> Filter the by field and matching value
74+
get [options] <input> Get package metadata from registry
75+
install [options] <input> Install a package locally by
76+
slug/version
77+
list [options] List packages
78+
open [options] <input> [options...] Open a package by slug/version
79+
reset [options] Reset the synced package cache
80+
scan [options] Scan local packages into cache
81+
search [options] <query> Search using a lazy matching query
82+
sync [options] Sync remote packages into cache
83+
uninstall [options] <input> Uninstall a package locally by
84+
slug/version
85+
help [command] display help for command
7686
`;

0 commit comments

Comments
 (0)