libroadcast-cli 2.10.0 → 2.11.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 CHANGED
@@ -48,6 +48,12 @@ Commands:
48
48
  Sets the games for the specified broadcast round using Lichess game IDs.
49
49
  Note: Maximum of 64 game IDs can be provided.
50
50
 
51
+ setLichessGamesMulti "<broadcastRoundIds...>" "<gameIds...>"
52
+ Sets the games for multiple broadcast rounds using Lichess game IDs.
53
+ The first argument is a space-separated list of broadcast round IDs, and the second argument is a space-separated list of game IDs.
54
+ The command will distribute the provided game IDs across the specified broadcast round IDs.
55
+ Note: Maximum of 64 game IDs can be provided. The number of game IDs should ideally be a multiple of the number of broadcast round IDs for even distribution.
56
+
51
57
  fixSchedule <broadcastId> <timeDiff> [--rounds <roundsToFix>]
52
58
  Fixes the schedule of rounds in the specified broadcast by applying a time difference.
53
59
  Note: The time difference should be in a format like "1h", "30m", "15s", etc.
@@ -112,6 +118,8 @@ Examples:
112
118
  $ setPGNMulti bcast123 https://example.com/pgns/round-{r}/game-{g}.pgn 12 --withFilter --onlyGames "1-5,7,9-12"
113
119
  # Set Lichess games for a broadcast round
114
120
  $ setLichessGames round456 gameId1 gameId2 gameId3
121
+ # Set Lichess games for multiple broadcast rounds
122
+ $ setLichessGamesMulti "roundId1 roundId2 roundId3" "gameId1 gameId2 gameId3"
115
123
  # Fix schedule of rounds 1 to 4 and all rounds after 8 by adding 15 minutes
116
124
  $ fixSchedule bcast123 15m --rounds 1-4,8+
117
125
  # Set startsAfterPrevious to true for all rounds in a broadcast
@@ -0,0 +1,38 @@
1
+ import { exit } from "node:process";
2
+ import { client, msgCommonErrorHelp, handleApiResponse, checkTokenScopes, sleep, } from "../utils/commandHandler.js";
3
+ import { getBroadcastRound } from "../utils/getInfoBroadcast.js";
4
+ import cl from "../utils/colors.js";
5
+ const setLichessGames = (round, games) => handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
6
+ params: {
7
+ path: { broadcastRoundId: round.id },
8
+ query: { patch: 1 },
9
+ },
10
+ body: {
11
+ syncSource: "ids",
12
+ syncIds: games,
13
+ },
14
+ }), `Successfully set games for round ${cl.whiteBold(round.id)} to ${cl.whiteBold(games)}.`, `Error setting games for round ${cl.whiteBold(round.id)}`);
15
+ const splitIdsIntoGroups = (broadcastsIds, gameIds) => gameIds.reduce((groups, id, index) => {
16
+ groups[index % broadcastsIds.length].push(id);
17
+ return groups;
18
+ }, broadcastsIds.map(() => []));
19
+ export const setLichessGamesMultiCommand = async (args) => {
20
+ await checkTokenScopes();
21
+ const bIds = args.shift()?.split(" ");
22
+ const gamesIDs = args.shift()?.split(" ");
23
+ if (!bIds || !gamesIDs) {
24
+ msgCommonErrorHelp("Broadcast ID and games IDs are required.");
25
+ exit(1);
26
+ }
27
+ const groups = splitIdsIntoGroups(bIds, gamesIDs);
28
+ for (let [index, group] of groups.entries()) {
29
+ const roundId = bIds[index];
30
+ const round = await getBroadcastRound(roundId);
31
+ if (!round) {
32
+ console.error(cl.red(`Broadcast round with ID ${cl.whiteBold(roundId)} not found or has no rounds.`));
33
+ continue;
34
+ }
35
+ await setLichessGames(round, group.join(" "));
36
+ await sleep(500);
37
+ }
38
+ };
@@ -19,6 +19,7 @@ import { getStoredCredentials } from "./credentials.js";
19
19
  import { convertNamesToIDCommand } from "../cmd/convertNamesToID.js";
20
20
  import { pushReorderCommand } from "../cmd/pushReorder.js";
21
21
  import { bulkIDsMultiCommand } from "../cmd/bulkIDsMulti.js";
22
+ import { setLichessGamesMultiCommand } from "../cmd/setLichessGamesMulti.js";
22
23
  const getToken = () => {
23
24
  const stored = getStoredCredentials();
24
25
  const envToken = process.env.LICHESS_TOKEN;
@@ -42,6 +43,7 @@ export var Command;
42
43
  Command["SetPGN"] = "setPGN";
43
44
  Command["SetPGNMulti"] = "setPGNMulti";
44
45
  Command["SetLichessGames"] = "setLichessGames";
46
+ Command["SetLichessGamesMulti"] = "setLichessGamesMulti";
45
47
  Command["FixSchedule"] = "fixSchedule";
46
48
  Command["StartsPrevious"] = "startsPrevious";
47
49
  Command["Period"] = "period";
@@ -58,6 +60,7 @@ export const commands = new Map([
58
60
  [Command.SetPGN, setPGNCommand],
59
61
  [Command.SetPGNMulti, setPGNMultiCommand],
60
62
  [Command.SetLichessGames, setLichessGamesCommand],
63
+ [Command.SetLichessGamesMulti, setLichessGamesMultiCommand],
61
64
  [Command.FixSchedule, fixScheduleCommand],
62
65
  [Command.StartsPrevious, startsPreviousCommand],
63
66
  [Command.Period, periodCommand],
@@ -42,6 +42,13 @@ const helpSetLichessGames = [
42
42
  ` ${cl.gray("Sets the games for the specified broadcast round using Lichess game IDs.")}`,
43
43
  ` ${cl.bold("Note:")} ${cl.gray("Maximum of 64 game IDs can be provided.")}`,
44
44
  ].join("\n");
45
+ const helpSetLichessGamesMulti = [
46
+ ` ${cl.underItalic('setLichessGamesMulti "<broadcastRoundIds...>" "<gameIds...>"')}`,
47
+ ` ${cl.gray("Sets the games for multiple broadcast rounds using Lichess game IDs.")}`,
48
+ ` ${cl.gray("The first argument is a space-separated list of broadcast round IDs, and the second argument is a space-separated list of game IDs.")}`,
49
+ ` ${cl.gray("The command will distribute the provided game IDs across the specified broadcast round IDs.")}`,
50
+ ` ${cl.bold("Note:")} ${cl.gray("Maximum of 64 game IDs can be provided. The number of game IDs should ideally be a multiple of the number of broadcast round IDs for even distribution.")}`,
51
+ ].join("\n");
45
52
  const helpFixSchedule = [
46
53
  ` ${cl.underItalic("fixSchedule <broadcastId> <timeDiff> [--rounds <roundsToFix>]")}`,
47
54
  ` ${cl.gray("Fixes the schedule of rounds in the specified broadcast by applying a time difference.")}`,
@@ -114,6 +121,8 @@ const msg = [
114
121
  ``,
115
122
  helpSetLichessGames,
116
123
  ``,
124
+ helpSetLichessGamesMulti,
125
+ ``,
117
126
  helpFixSchedule,
118
127
  ``,
119
128
  helpStartsPrevious,
@@ -148,6 +157,8 @@ const msg = [
148
157
  ` $ ${cl.underItalic("setPGNMulti")} ${cl.italic('bcast123 https://example.com/pgns/round-{r}/game-{g}.pgn 12 --withFilter --onlyGames "1-5,7,9-12"')}`,
149
158
  ` ${cl.gray("# Set Lichess games for a broadcast round")}`,
150
159
  ` $ ${cl.underItalic("setLichessGames")} ${cl.italic("round456 gameId1 gameId2 gameId3")}`,
160
+ ` ${cl.gray("# Set Lichess games for multiple broadcast rounds")}`,
161
+ ` $ ${cl.underItalic("setLichessGamesMulti")} ${cl.italic('"roundId1 roundId2 roundId3" "gameId1 gameId2 gameId3"')}`,
151
162
  ` ${cl.gray("# Fix schedule of rounds 1 to 4 and all rounds after 8 by adding 15 minutes")}`,
152
163
  ` $ ${cl.underItalic("fixSchedule")} ${cl.italic("bcast123 15m --rounds 1-4,8+")}`,
153
164
  ` ${cl.gray("# Set startsAfterPrevious to true for all rounds in a broadcast")}`,
@@ -172,6 +183,7 @@ export const showHelp = (cmd) => {
172
183
  [Command.SetPGN]: helpSetPGN,
173
184
  [Command.SetPGNMulti]: helpSetPGNMulti,
174
185
  [Command.SetLichessGames]: helpSetLichessGames,
186
+ [Command.SetLichessGamesMulti]: helpSetLichessGamesMulti,
175
187
  [Command.FixSchedule]: helpFixSchedule,
176
188
  [Command.StartsPrevious]: helpStartsPrevious,
177
189
  [Command.Period]: helpSetPeriod,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libroadcast-cli",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "CLI to help with broadcast maintenance on Lichess",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "type": "module",
14
14
  "dependencies": {
15
15
  "@lichess-org/types": "^2.0.109",
16
- "@types/node": "~24.11.0",
16
+ "@types/node": "~24.12.0",
17
17
  "chessops": "^0.15.0",
18
18
  "ms": "3.0.0-canary.202508261828",
19
19
  "openapi-fetch": "^0.17.0"