tering-serieuze-cli 1.5.2 → 1.6.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/package.json +2 -2
- package/src/index.ts +6 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tering-serieuze-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Teringserieuze CLI",
|
|
5
5
|
"author": "Frank",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"figlet": "^1.5.2",
|
|
28
28
|
"inquirer": "^9.1.4",
|
|
29
29
|
"omelette": "^0.4.17",
|
|
30
|
-
"tering-serieuze-sdk": "^3.
|
|
30
|
+
"tering-serieuze-sdk": "^3.5.0",
|
|
31
31
|
"tering-serieuze-types": "^1.14.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -142,8 +142,7 @@ program
|
|
|
142
142
|
.description("Show recently added jingles, select a jingle to play")
|
|
143
143
|
.action(async () => {
|
|
144
144
|
try {
|
|
145
|
-
const jingles = await api.jingle.
|
|
146
|
-
jingles.sort((a, b) => b.mtime - a.mtime);
|
|
145
|
+
const jingles = await api.jingle.getRecentlyAdded();
|
|
147
146
|
|
|
148
147
|
const answers = await inquirer.prompt([
|
|
149
148
|
{
|
|
@@ -167,36 +166,21 @@ program
|
|
|
167
166
|
.description("Play a jingle by typing (some) parts of the name")
|
|
168
167
|
.argument("<query...>", "The query to search for")
|
|
169
168
|
.action(async (query: string[]) => {
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
jingles = await api.jingle.getAll();
|
|
173
|
-
} catch (e: any) {
|
|
174
|
-
console.error(e.status + ": " + e.message);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const matches = jingles.filter((jingle) => query.every((q) => (jingle.folder + "/" + jingle.file).includes(q)));
|
|
169
|
+
const items = await api.jingle.find(query.join(" "));
|
|
179
170
|
|
|
180
171
|
let jingle;
|
|
181
|
-
if (
|
|
172
|
+
if (items.length === 0) {
|
|
182
173
|
console.log("No matches found");
|
|
183
174
|
return;
|
|
184
|
-
} else if (
|
|
185
|
-
jingle =
|
|
175
|
+
} else if (items.length === 1) {
|
|
176
|
+
jingle = items[0];
|
|
186
177
|
} else {
|
|
187
|
-
const sortedMatches = matches.sort((a, b) => {
|
|
188
|
-
const aScore = a.keywords.filter((k) => query.includes(k)).length;
|
|
189
|
-
const bScore = b.keywords.filter((k) => query.includes(k)).length;
|
|
190
|
-
|
|
191
|
-
return bScore - aScore;
|
|
192
|
-
});
|
|
193
|
-
|
|
194
178
|
const answers = await inquirer.prompt([
|
|
195
179
|
{
|
|
196
180
|
type: "list",
|
|
197
181
|
name: "jingle",
|
|
198
182
|
message: playWhichJingleString,
|
|
199
|
-
choices:
|
|
183
|
+
choices: items.map((jingle) => jingle.folder + "/" + jingle.file),
|
|
200
184
|
},
|
|
201
185
|
]);
|
|
202
186
|
|