tering-serieuze-cli 1.2.0 → 1.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/dist/index.mjs CHANGED
@@ -19,6 +19,7 @@ async function initCompletion(api2) {
19
19
  ["clearcache" /* clearcache */]: ["auth", "jingle", "all"],
20
20
  ["login" /* login */]: [],
21
21
  ["play" /* play */]: playCompletion,
22
+ ["recent" /* recent */]: [],
22
23
  ["jingles" /* jingles */]: [],
23
24
  ["p" /* playShort */]: [],
24
25
  ["version" /* version */]: []
@@ -29,7 +30,7 @@ async function initCompletion(api2) {
29
30
  }
30
31
 
31
32
  // package.json
32
- var version = "1.1.1";
33
+ var version = "1.2.0";
33
34
 
34
35
  // src/index.ts
35
36
  var Commands = /* @__PURE__ */ ((Commands2) => {
@@ -37,11 +38,13 @@ var Commands = /* @__PURE__ */ ((Commands2) => {
37
38
  Commands2["clearcache"] = "clearcache";
38
39
  Commands2["login"] = "login";
39
40
  Commands2["play"] = "play";
41
+ Commands2["recent"] = "recent";
40
42
  Commands2["jingles"] = "jingles";
41
43
  Commands2["playShort"] = "p";
42
44
  Commands2["version"] = "version";
43
45
  return Commands2;
44
46
  })(Commands || {});
47
+ var playWhichJingleString = "Which jingle do you want to play?";
45
48
  var api = new TssApi(
46
49
  {
47
50
  API_URL: process.env.API_URL ?? "https://tss.maxserv.dev:8081"
@@ -100,6 +103,8 @@ program.command("clearcache" /* clearcache */).description("Clear the cache").ar
100
103
  await api.auth.removeToken();
101
104
  await api.jingle.getCache().clear();
102
105
  console.log("Cleared all caches");
106
+ } else {
107
+ console.error("Invalid cache type");
103
108
  }
104
109
  });
105
110
  program.command("jingles" /* jingles */).description("Show all jingles").action(async () => {
@@ -119,6 +124,25 @@ program.command("play" /* play */).description("Play a jingle").argument("<folde
119
124
  console.error(`ERROR ${e.status}: ${e.message}`);
120
125
  }
121
126
  });
127
+ program.command("recent" /* recent */).description("Show recently added jingles, select a jingle to play").action(async () => {
128
+ try {
129
+ const jingles = await api.jingle.getAll();
130
+ jingles.sort((a, b) => b.mtime - a.mtime);
131
+ const answers = await inquirer.prompt([
132
+ {
133
+ type: "list",
134
+ name: "jingle",
135
+ message: playWhichJingleString,
136
+ choices: jingles.slice(0, 30).map((jingle2) => jingle2.folder + "/" + jingle2.file)
137
+ }
138
+ ]);
139
+ const [folder, file] = answers.jingle.split("/");
140
+ const jingle = { folder, file };
141
+ await api.jingle.play(jingle);
142
+ } catch (e) {
143
+ console.error(e.status + ": " + e.message);
144
+ }
145
+ });
122
146
  program.command("p" /* playShort */).description("Play a jingle by typing (some) parts of the name").argument("<query...>", "The query to search for").action(async (query) => {
123
147
  let jingles;
124
148
  try {
@@ -144,7 +168,7 @@ program.command("p" /* playShort */).description("Play a jingle by typing (some)
144
168
  {
145
169
  type: "list",
146
170
  name: "jingle",
147
- message: "Which jingle do you want to play?",
171
+ message: playWhichJingleString,
148
172
  choices: sortedMatches.map((jingle2) => jingle2.folder + "/" + jingle2.file)
149
173
  }
150
174
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tering-serieuze-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Teringserieuze CLI",
5
5
  "author": "Frank",
6
6
  "main": "dist/index.mjs",
@@ -27,8 +27,8 @@
27
27
  "figlet": "^1.5.2",
28
28
  "inquirer": "^9.1.4",
29
29
  "omelette": "^0.4.17",
30
- "tering-serieuze-sdk": "^2.0.0",
31
- "tering-serieuze-types": "^1.9.0"
30
+ "tering-serieuze-sdk": "^3.0.0",
31
+ "tering-serieuze-types": "^1.14.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/figlet": "^1.5.5",
package/src/completion.ts CHANGED
@@ -15,6 +15,7 @@ export async function initCompletion(api: TssApi) {
15
15
  [Commands.clearcache]: ["auth", "jingle", "all"],
16
16
  [Commands.login]: [],
17
17
  [Commands.play]: playCompletion,
18
+ [Commands.recent]: [],
18
19
  [Commands.jingles]: [],
19
20
  [Commands.playShort]: [],
20
21
  [Commands.version]: [],
package/src/index.ts CHANGED
@@ -13,11 +13,14 @@ export enum Commands {
13
13
  clearcache = "clearcache",
14
14
  login = "login",
15
15
  play = "play",
16
+ recent = "recent",
16
17
  jingles = "jingles",
17
18
  playShort = "p",
18
19
  version = "version",
19
20
  }
20
21
 
22
+ const playWhichJingleString = "Which jingle do you want to play?";
23
+
21
24
  const api = new TssApi(
22
25
  {
23
26
  API_URL: process.env.API_URL ?? "https://tss.maxserv.dev:8081",
@@ -97,6 +100,8 @@ program
97
100
  await api.auth.removeToken();
98
101
  await api.jingle.getCache().clear();
99
102
  console.log("Cleared all caches");
103
+ } else {
104
+ console.error("Invalid cache type");
100
105
  }
101
106
  });
102
107
 
@@ -127,6 +132,31 @@ program
127
132
  }
128
133
  });
129
134
 
135
+ program
136
+ .command(Commands.recent)
137
+ .description("Show recently added jingles, select a jingle to play")
138
+ .action(async () => {
139
+ try {
140
+ const jingles = await api.jingle.getAll();
141
+ jingles.sort((a, b) => b.mtime - a.mtime);
142
+
143
+ const answers = await inquirer.prompt([
144
+ {
145
+ type: "list",
146
+ name: "jingle",
147
+ message: playWhichJingleString,
148
+ choices: jingles.slice(0, 30).map((jingle) => jingle.folder + "/" + jingle.file),
149
+ },
150
+ ]);
151
+
152
+ const [folder, file]: [folder: string, file: string] = answers.jingle.split("/");
153
+ const jingle = { folder, file };
154
+ await api.jingle.play(jingle);
155
+ } catch (e: any) {
156
+ console.error(e.status + ": " + e.message);
157
+ }
158
+ });
159
+
130
160
  program
131
161
  .command(Commands.playShort)
132
162
  .description("Play a jingle by typing (some) parts of the name")
@@ -160,12 +190,12 @@ program
160
190
  {
161
191
  type: "list",
162
192
  name: "jingle",
163
- message: "Which jingle do you want to play?",
193
+ message: playWhichJingleString,
164
194
  choices: sortedMatches.map((jingle) => jingle.folder + "/" + jingle.file),
165
195
  },
166
196
  ]);
167
197
 
168
- const [folder, file] = answers.jingle.split("/");
198
+ const [folder, file]: [folder: string, file: string] = answers.jingle.split("/");
169
199
  jingle = { folder, file };
170
200
  }
171
201