Skip to content

Commit f2f7f56

Browse files
committed
List compatible packages by default, prevent installing incompatible packages, alphabetize list, improved success/error output format.
1 parent cbe18da commit f2f7f56

14 files changed

Lines changed: 341 additions & 313 deletions

File tree

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: 130 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"node": ">=18"
4040
},
4141
"dependencies": {
42-
"@open-audio-stack/core": "^0.1.40",
42+
"@open-audio-stack/core": "^0.1.43",
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export function open(command: Command, manager: ManagerLocal) {
1111
if (cliOptions.log) manager.logEnable();
1212
else manager.logDisable();
1313
const [slug, version] = inputGetParts(input);
14-
await manager.open(slug, version, options);
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+
}
1521
});
1622
}

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
}

tests/__snapshots__/index.test.ts.snap

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,58 +20,67 @@ exports[`Root command plugins 1`] = `
2020
Usage: index plugins [options] [command]
2121
2222
Options:
23-
-h, --help display help for command
23+
-h, --help display help for command
2424
2525
Commands:
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 slug/version
30-
list [options] List packages
31-
reset [options] Reset the synced package cache
32-
scan [options] Scan local packages into cache
33-
search [options] <query> Search using a lazy matching query
34-
sync [options] Sync remote packages into cache
35-
uninstall [options] <input> Uninstall a package locally by slug/version
36-
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
3740
`;
3841
3942
exports[`Root command presets 1`] = `
4043
Usage: index presets [options] [command]
4144
4245
Options:
43-
-h, --help display help for command
46+
-h, --help display help for command
4447
4548
Commands:
46-
create [options] <path> Create a new package locally
47-
filter [options] <field> <value> Filter the by field and matching value
48-
get [options] <input> Get package metadata from registry
49-
install [options] <input> Install a package locally by slug/version
50-
list [options] List packages
51-
reset [options] Reset the synced package cache
52-
scan [options] Scan local packages into cache
53-
search [options] <query> Search using a lazy matching query
54-
sync [options] Sync remote packages into cache
55-
uninstall [options] <input> Uninstall a package locally by slug/version
56-
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
5763
`;
5864
5965
exports[`Root command projects 1`] = `
6066
Usage: index projects [options] [command]
6167
6268
Options:
63-
-h, --help display help for command
69+
-h, --help display help for command
6470
6571
Commands:
66-
create [options] <path> Create a new package locally
67-
filter [options] <field> <value> Filter the by field and matching value
68-
get [options] <input> Get package metadata from registry
69-
install [options] <input> Install a package locally by slug/version
70-
list [options] List packages
71-
reset [options] Reset the synced package cache
72-
scan [options] Scan local packages into cache
73-
search [options] <query> Search using a lazy matching query
74-
sync [options] Sync remote packages into cache
75-
uninstall [options] <input> Uninstall a package locally by slug/version
76-
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
7786
`;

tests/commands/__snapshots__/install.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ exports[`Install package 1`] = `Installed surge-synthesizer/surge`;
44

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

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

0 commit comments

Comments
 (0)