pingthings 0.2.1 → 0.3.0
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.
- package/README.md +1 -0
- package/bin/pingthings.js +2 -0
- package/package.json +1 -1
- package/src/cli/uninstall.js +48 -0
- package/src/packs.js +7 -2
- package/src/player.js +7 -3
package/README.md
CHANGED
|
@@ -135,6 +135,7 @@ For different sounds based on what Claude is doing, set up multiple hooks:
|
|
|
135
135
|
| `pingthings init` | Set up Claude Code hooks automatically |
|
|
136
136
|
| `pingthings create <dir>` | Create a pack from audio files |
|
|
137
137
|
| `pingthings install <source>` | Install a pack from GitHub or local path |
|
|
138
|
+
| `pingthings uninstall <pack>` | Remove a user-installed pack |
|
|
138
139
|
|
|
139
140
|
## Configuration
|
|
140
141
|
|
package/bin/pingthings.js
CHANGED
|
@@ -18,6 +18,7 @@ const commands = {
|
|
|
18
18
|
preview: () => import('../src/cli/preview.js'),
|
|
19
19
|
config: () => import('../src/cli/config.js'),
|
|
20
20
|
install: () => import('../src/cli/install.js'),
|
|
21
|
+
uninstall: () => import('../src/cli/uninstall.js'),
|
|
21
22
|
init: () => import('../src/cli/init.js'),
|
|
22
23
|
create: () => import('../src/cli/create.js'),
|
|
23
24
|
theme: () => import('../src/cli/theme.js'),
|
|
@@ -42,6 +43,7 @@ Commands:
|
|
|
42
43
|
init Set up Claude Code hooks automatically
|
|
43
44
|
create <dir> Create a new pack from a folder of audio files
|
|
44
45
|
install <source> Install a pack from GitHub or URL
|
|
46
|
+
uninstall <pack> Remove a user-installed pack
|
|
45
47
|
|
|
46
48
|
Options:
|
|
47
49
|
--help, -h Show this help message
|
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { existsSync, rmSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { getConfigDir, readConfig, writeConfig } from '../config.js';
|
|
4
|
+
|
|
5
|
+
function showHelp() {
|
|
6
|
+
console.log(`
|
|
7
|
+
Usage: pingthings uninstall <pack>
|
|
8
|
+
|
|
9
|
+
Remove a user-installed sound pack.
|
|
10
|
+
|
|
11
|
+
Built-in packs cannot be uninstalled. Only packs in
|
|
12
|
+
~/.config/pingthings/packs/ can be removed.
|
|
13
|
+
|
|
14
|
+
Arguments:
|
|
15
|
+
pack Name of the pack to remove
|
|
16
|
+
`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function uninstall(args) {
|
|
20
|
+
const packName = args[0];
|
|
21
|
+
|
|
22
|
+
if (!packName || packName === '--help' || packName === '-h') {
|
|
23
|
+
showHelp();
|
|
24
|
+
if (!packName) process.exit(1);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const userPackDir = join(getConfigDir(), 'packs', packName);
|
|
29
|
+
|
|
30
|
+
if (!existsSync(userPackDir)) {
|
|
31
|
+
console.error(`Pack not found in user packs: ${packName}`);
|
|
32
|
+
console.error('Only user-installed packs can be uninstalled.');
|
|
33
|
+
console.error('Run "pingthings list" to see all packs.');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
rmSync(userPackDir, { recursive: true });
|
|
38
|
+
|
|
39
|
+
// If this was the active pack, reset to default
|
|
40
|
+
const config = readConfig();
|
|
41
|
+
if (config.activePack === packName) {
|
|
42
|
+
config.activePack = '7kaa-soldiers';
|
|
43
|
+
writeConfig(config);
|
|
44
|
+
console.log(`Active pack reset to: 7kaa-soldiers`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`Uninstalled: ${packName}`);
|
|
48
|
+
}
|
package/src/packs.js
CHANGED
|
@@ -16,8 +16,13 @@ function readManifest(packDir) {
|
|
|
16
16
|
const manifestPath = join(packDir, 'manifest.json');
|
|
17
17
|
if (!existsSync(manifestPath)) return null;
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
20
|
+
if (!manifest.name) {
|
|
21
|
+
console.error(`Warning: manifest.json in ${packDir} is missing "name" field`);
|
|
22
|
+
}
|
|
23
|
+
return manifest;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error(`Warning: Failed to parse ${manifestPath}: ${err.message}`);
|
|
21
26
|
return null;
|
|
22
27
|
}
|
|
23
28
|
}
|
package/src/player.js
CHANGED
|
@@ -81,8 +81,12 @@ export function playSoundSync(filePath, volume) {
|
|
|
81
81
|
const args = buildArgs(cmd, filePath, volume);
|
|
82
82
|
|
|
83
83
|
try {
|
|
84
|
-
execFileSync(cmd, args, { stdio: 'ignore', timeout:
|
|
85
|
-
} catch {
|
|
86
|
-
|
|
84
|
+
execFileSync(cmd, args, { stdio: ['ignore', 'ignore', 'pipe'], timeout: 5000 });
|
|
85
|
+
} catch (err) {
|
|
86
|
+
if (err.killed) {
|
|
87
|
+
console.error(`Warning: Sound playback timed out for ${filePath}`);
|
|
88
|
+
} else if (err.stderr?.length) {
|
|
89
|
+
console.error(`Warning: Playback error: ${err.stderr.toString().trim()}`);
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
}
|