libroadcast-cli 1.9.0 → 1.10.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 +5 -3
- package/cmdhelp.txt +57 -0
- package/dist/cmd/fixSchedule.js +1 -32
- package/dist/cmd/setPGN.js +11 -2
- package/dist/cmd/setPGNMulti.js +11 -2
- package/dist/utils/commandHandler.js +33 -1
- package/dist/utils/help.js +5 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,8 +30,9 @@ Commands:
|
|
|
30
30
|
(optional) Use "{}" in the URL as a placeholder for the round number.
|
|
31
31
|
Note: For livechesscloud URLs, please ensure it ends with "/{}".
|
|
32
32
|
Options:
|
|
33
|
-
--withFilter
|
|
34
|
-
--slice <sliceFilter>
|
|
33
|
+
--withFilter Apply round number filtering based on round number.
|
|
34
|
+
--slice <sliceFilter> Apply slice filtering using the provided filter string.
|
|
35
|
+
--rounds <roundsToFix> Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.
|
|
35
36
|
|
|
36
37
|
setPGNMulti <broadcastId> <sourcePGNUrl> <gamesNum> [--withFilter] [--onlyGames <sliceFilter>]
|
|
37
38
|
Sets the source PGN URLs for all rounds in the specified broadcast.
|
|
@@ -39,8 +40,9 @@ Commands:
|
|
|
39
40
|
Use the gamesNum parameter to specify how many games per round.
|
|
40
41
|
Note: For broadcasts with multiple rounds, the source PGN URLs must include the "{g}" placeholder for round numbers.
|
|
41
42
|
Options:
|
|
42
|
-
--withFilter
|
|
43
|
+
--withFilter Apply round number filtering based on round number.
|
|
43
44
|
--onlyGames <sliceFilter> Apply slice filtering using the provided filter string.
|
|
45
|
+
--rounds <roundsToFix> Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.
|
|
44
46
|
|
|
45
47
|
setLichessGames <broadcastRoundId> <gameIds...>
|
|
46
48
|
Sets the games for the specified broadcast round using Lichess game IDs.
|
package/cmdhelp.txt
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Usage: <command> [options]
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Commands:
|
|
5
|
+
delay <broadcastId> <delayInSeconds> [--onlyDelay] [--noDelay]
|
|
6
|
+
Sets the delay for all rounds in the specified broadcast.
|
|
7
|
+
Note: The delay is specified in seconds. (max 3600 seconds = 1 hour)
|
|
8
|
+
Options:
|
|
9
|
+
--onlyDelay Set only the delay without changing the start time.
|
|
10
|
+
--noDelay Do not modify the delay, only adjust the start time.
|
|
11
|
+
|
|
12
|
+
setPGN <broadcastId> <sourcePGNUrl> [--withFilter] [--slice <sliceFilter>]
|
|
13
|
+
Sets the source PGN URL for all rounds in the specified broadcast.
|
|
14
|
+
(optional) Use "{}" in the URL as a placeholder for the round number.
|
|
15
|
+
Note: For livechesscloud URLs, please ensure it ends with "/{}".
|
|
16
|
+
Options:
|
|
17
|
+
--withFilter Apply round number filtering based on round number.
|
|
18
|
+
--slice <sliceFilter> Apply slice filtering using the provided filter string.
|
|
19
|
+
--rounds <roundsToFix> Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.
|
|
20
|
+
|
|
21
|
+
setPGNMulti <broadcastId> <sourcePGNUrl> <gamesNum> [--withFilter] [--onlyGames <sliceFilter>]
|
|
22
|
+
Sets the source PGN URLs for all rounds in the specified broadcast.
|
|
23
|
+
Use {r} in the URL as a placeholder for the round number and {g} for the game number.
|
|
24
|
+
Use the gamesNum parameter to specify how many games per round.
|
|
25
|
+
Note: For broadcasts with multiple rounds, the source PGN URLs must include the "{g}" placeholder for round numbers.
|
|
26
|
+
Options:
|
|
27
|
+
--withFilter Apply round number filtering based on round number.
|
|
28
|
+
--onlyGames <sliceFilter> Apply slice filtering using the provided filter string.
|
|
29
|
+
--rounds <roundsToFix> Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.
|
|
30
|
+
|
|
31
|
+
setLichessGames <broadcastRoundId> <gameIds...>
|
|
32
|
+
Sets the games for the specified broadcast round using Lichess game IDs.
|
|
33
|
+
Note: Maximum of 64 game IDs can be provided.
|
|
34
|
+
|
|
35
|
+
fixSchedule <broadcastId> <timeDiff> [--rounds <roundsToFix>]
|
|
36
|
+
Fixes the schedule of rounds in the specified broadcast by applying a time difference.
|
|
37
|
+
Note: The time difference should be in a format like "1h", "30m", "15s", etc.
|
|
38
|
+
Options:
|
|
39
|
+
--rounds <roundsToFix> Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.
|
|
40
|
+
|
|
41
|
+
startsPrevious <broadcastId> <startsPrevious>
|
|
42
|
+
Sets the startsAfterPrevious flag for all rounds in the specified broadcast.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
# Set a 5-minute delay without changing start time
|
|
47
|
+
$ delay bcast123 300 --onlyDelay
|
|
48
|
+
# Set source PGN URL with round and slice filters
|
|
49
|
+
$ setPGN bcast123 https://example.com/pgns/round-{}/game.pgn --withFilter --slice "1-5,7,9-12"
|
|
50
|
+
# Set source PGN URLs for multiple games per round
|
|
51
|
+
$ setPGNMulti bcast123 https://example.com/pgns/round-{r}/game-{g}.pgn 12 --withFilter --onlyGames "1-5,7,9-12"
|
|
52
|
+
# Set Lichess games for a broadcast round
|
|
53
|
+
$ setLichessGames round456 gameId1 gameId2 gameId3
|
|
54
|
+
# Fix schedule of rounds 1 to 4 and all rounds after 8 by adding 15 minutes
|
|
55
|
+
$ fixSchedule bcast123 15m --rounds 1-4,8+
|
|
56
|
+
# Set startsAfterPrevious to true for all rounds in a broadcast
|
|
57
|
+
$ startsPrevious bcast123 true
|
package/dist/cmd/fixSchedule.js
CHANGED
|
@@ -30,37 +30,6 @@ const fixScheduleRounds = async (rounds, timeDiff, roundsToFix) => {
|
|
|
30
30
|
await (0, commandHandler_1.sleep)(200);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
const translateRoundsToFix = (arg) => {
|
|
34
|
-
const rounds = [];
|
|
35
|
-
const parts = arg.split(",");
|
|
36
|
-
for (const part of parts) {
|
|
37
|
-
if (part.endsWith("+")) {
|
|
38
|
-
const start = parseInt(part.slice(0, -1), 10);
|
|
39
|
-
if (isNaN(start))
|
|
40
|
-
continue;
|
|
41
|
-
for (let i = start; i <= 64; i++) {
|
|
42
|
-
rounds.push(i);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else if (part.includes("-")) {
|
|
46
|
-
const [startStr, endStr] = part.split("-");
|
|
47
|
-
const start = parseInt(startStr, 10);
|
|
48
|
-
const end = parseInt(endStr, 10);
|
|
49
|
-
if (isNaN(start) || isNaN(end))
|
|
50
|
-
continue;
|
|
51
|
-
for (let i = start; i <= end; i++) {
|
|
52
|
-
rounds.push(i);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const roundNum = parseInt(part, 10);
|
|
57
|
-
if (isNaN(roundNum))
|
|
58
|
-
continue;
|
|
59
|
-
rounds.push(roundNum);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return [...new Set(rounds)];
|
|
63
|
-
};
|
|
64
33
|
const fixScheduleCommand = async (args) => {
|
|
65
34
|
const [broadcastId, timeDiffStr] = args.slice(0, 2);
|
|
66
35
|
if (!broadcastId || !timeDiffStr) {
|
|
@@ -77,7 +46,7 @@ const fixScheduleCommand = async (args) => {
|
|
|
77
46
|
let roundsToFix = undefined;
|
|
78
47
|
if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
|
|
79
48
|
const roundsArg = args[roundsArgIndex + 1];
|
|
80
|
-
roundsToFix = roundsArg ? translateRoundsToFix(roundsArg) : undefined;
|
|
49
|
+
roundsToFix = roundsArg ? (0, commandHandler_1.translateRoundsToFix)(roundsArg) : undefined;
|
|
81
50
|
}
|
|
82
51
|
const broadcast = await (0, getInfoBroadcast_1.getBroadcast)(broadcastId);
|
|
83
52
|
if (!broadcast?.rounds || broadcast.rounds.length === 0) {
|
package/dist/cmd/setPGN.js
CHANGED
|
@@ -8,7 +8,10 @@ const node_process_1 = require("node:process");
|
|
|
8
8
|
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
9
|
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
10
|
const colors_1 = __importDefault(require("../utils/colors"));
|
|
11
|
-
const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null) => {
|
|
11
|
+
const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null, roundsToFix) => {
|
|
12
|
+
rounds = rounds
|
|
13
|
+
.filter((_, i) => !roundsToFix?.length || roundsToFix.includes(i + 1))
|
|
14
|
+
.filter((el) => el.startsAt !== undefined);
|
|
12
15
|
for (const [index, round] of rounds.entries()) {
|
|
13
16
|
const rN = index + 1;
|
|
14
17
|
const url = urlRound(rN);
|
|
@@ -54,9 +57,15 @@ const setPGNCommand = async (args) => {
|
|
|
54
57
|
console.error(colors_1.default.red('Invalid URL. Must be http/https with "{}" as round placeholder.'));
|
|
55
58
|
(0, node_process_1.exit)(1);
|
|
56
59
|
}
|
|
60
|
+
const roundsArgIndex = args.findIndex((arg) => arg === "--rounds");
|
|
61
|
+
let roundsToFix = undefined;
|
|
62
|
+
if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
|
|
63
|
+
const roundsArg = args[roundsArgIndex + 1];
|
|
64
|
+
roundsToFix = roundsArg ? (0, commandHandler_1.translateRoundsToFix)(roundsArg) : undefined;
|
|
65
|
+
}
|
|
57
66
|
const setRoundFilter = args.includes("--withFilter");
|
|
58
67
|
const sliceIndex = args.indexOf("--slice");
|
|
59
68
|
const setSliceFilter = sliceIndex !== -1 ? args[sliceIndex + 1] || null : null;
|
|
60
|
-
await setPGN(bcast.rounds, urlRound, setRoundFilter, setSliceFilter);
|
|
69
|
+
await setPGN(bcast.rounds, urlRound, setRoundFilter, setSliceFilter, roundsToFix);
|
|
61
70
|
};
|
|
62
71
|
exports.setPGNCommand = setPGNCommand;
|
package/dist/cmd/setPGNMulti.js
CHANGED
|
@@ -8,7 +8,10 @@ const node_process_1 = require("node:process");
|
|
|
8
8
|
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
9
|
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
10
|
const colors_1 = __importDefault(require("../utils/colors"));
|
|
11
|
-
const setPGN = async (rounds, urlsRound, gamesNum, setRoundFilter, setSliceFilter = null) => {
|
|
11
|
+
const setPGN = async (rounds, urlsRound, gamesNum, setRoundFilter, setSliceFilter = null, roundsToFix) => {
|
|
12
|
+
rounds = rounds
|
|
13
|
+
.filter((_, i) => !roundsToFix?.length || roundsToFix.includes(i + 1))
|
|
14
|
+
.filter((el) => el.startsAt !== undefined);
|
|
12
15
|
for (const [index, round] of rounds.entries()) {
|
|
13
16
|
const rN = index + 1;
|
|
14
17
|
const urls = urlsRound(gamesNum, rN)
|
|
@@ -107,10 +110,16 @@ const setPGNMultiCommand = async (args) => {
|
|
|
107
110
|
(0, node_process_1.exit)(1);
|
|
108
111
|
}
|
|
109
112
|
const setRoundFilter = args.includes("--withFilter");
|
|
113
|
+
const roundsArgIndex = args.findIndex((arg) => arg === "--rounds");
|
|
114
|
+
let roundsToFix = undefined;
|
|
115
|
+
if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
|
|
116
|
+
const roundsArg = args[roundsArgIndex + 1];
|
|
117
|
+
roundsToFix = roundsArg ? (0, commandHandler_1.translateRoundsToFix)(roundsArg) : undefined;
|
|
118
|
+
}
|
|
110
119
|
const sliceIndex = args.indexOf("--onlyGames");
|
|
111
120
|
const setSliceFilter = sliceIndex !== -1
|
|
112
121
|
? translateGamesToAdd(args[sliceIndex + 1] || "", gamesNum)
|
|
113
122
|
: null;
|
|
114
|
-
await setPGN(bcast.rounds, urlRound, gamesNum, setRoundFilter, setSliceFilter);
|
|
123
|
+
await setPGN(bcast.rounds, urlRound, gamesNum, setRoundFilter, setSliceFilter, roundsToFix);
|
|
115
124
|
};
|
|
116
125
|
exports.setPGNMultiCommand = setPGNMultiCommand;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.handleApiResponse = exports.msgCommonErrorHelp = exports.sleep = exports.client = exports.commands = exports.Command = exports.args = exports.LICHESS_TOKEN = void 0;
|
|
6
|
+
exports.translateRoundsToFix = exports.handleApiResponse = exports.msgCommonErrorHelp = exports.sleep = exports.client = exports.commands = exports.Command = exports.args = exports.LICHESS_TOKEN = void 0;
|
|
7
7
|
const node_process_1 = require("node:process");
|
|
8
8
|
const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
|
|
9
9
|
const colors_1 = __importDefault(require("./colors"));
|
|
@@ -62,3 +62,35 @@ const handleApiResponse = async (promise, successMsg, errorContext) => {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
exports.handleApiResponse = handleApiResponse;
|
|
65
|
+
const translateRoundsToFix = (arg) => {
|
|
66
|
+
const rounds = [];
|
|
67
|
+
const parts = arg.split(",");
|
|
68
|
+
for (const part of parts) {
|
|
69
|
+
if (part.endsWith("+")) {
|
|
70
|
+
const start = parseInt(part.slice(0, -1), 10);
|
|
71
|
+
if (isNaN(start))
|
|
72
|
+
continue;
|
|
73
|
+
for (let i = start; i <= 64; i++) {
|
|
74
|
+
rounds.push(i);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (part.includes("-")) {
|
|
78
|
+
const [startStr, endStr] = part.split("-");
|
|
79
|
+
const start = parseInt(startStr, 10);
|
|
80
|
+
const end = parseInt(endStr, 10);
|
|
81
|
+
if (isNaN(start) || isNaN(end))
|
|
82
|
+
continue;
|
|
83
|
+
for (let i = start; i <= end; i++) {
|
|
84
|
+
rounds.push(i);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const roundNum = parseInt(part, 10);
|
|
89
|
+
if (isNaN(roundNum))
|
|
90
|
+
continue;
|
|
91
|
+
rounds.push(roundNum);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return [...new Set(rounds)];
|
|
95
|
+
};
|
|
96
|
+
exports.translateRoundsToFix = translateRoundsToFix;
|
package/dist/utils/help.js
CHANGED
|
@@ -20,8 +20,9 @@ const helpSetPGN = [
|
|
|
20
20
|
` ${colors_1.default.italic("(optional)")} ${colors_1.default.gray('Use "{}" in the URL as a placeholder for the round number.')}`,
|
|
21
21
|
` ${colors_1.default.bold("Note:")} ${colors_1.default.gray('For livechesscloud URLs, please ensure it ends with "/{}".')}`,
|
|
22
22
|
` ${colors_1.default.bold("Options:")}`,
|
|
23
|
-
` --withFilter
|
|
24
|
-
` --slice <sliceFilter>
|
|
23
|
+
` --withFilter ${colors_1.default.gray("Apply round number filtering based on round number.")}`,
|
|
24
|
+
` --slice <sliceFilter> ${colors_1.default.gray("Apply slice filtering using the provided filter string.")}`,
|
|
25
|
+
` --rounds <roundsToFix> ${colors_1.default.gray("Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.")}`,
|
|
25
26
|
].join("\n");
|
|
26
27
|
const helpSetPGNMulti = [
|
|
27
28
|
` ${colors_1.default.underItalic("setPGNMulti <broadcastId> <sourcePGNUrl> <gamesNum> [--withFilter] [--onlyGames <sliceFilter>]")}`,
|
|
@@ -30,8 +31,9 @@ const helpSetPGNMulti = [
|
|
|
30
31
|
` ${colors_1.default.gray("Use the gamesNum parameter to specify how many games per round.")}`,
|
|
31
32
|
` ${colors_1.default.bold("Note:")} ${colors_1.default.gray('For broadcasts with multiple rounds, the source PGN URLs must include the "{g}" placeholder for round numbers.')}`,
|
|
32
33
|
` ${colors_1.default.bold("Options:")}`,
|
|
33
|
-
` --withFilter
|
|
34
|
+
` --withFilter ${colors_1.default.gray("Apply round number filtering based on round number.")}`,
|
|
34
35
|
` --onlyGames <sliceFilter> ${colors_1.default.gray("Apply slice filtering using the provided filter string.")}`,
|
|
36
|
+
` --rounds <roundsToFix> ${colors_1.default.gray("Specify which rounds to fix using formats like '1-4', '8+', '3,5,7', etc.")}`,
|
|
35
37
|
].join("\n");
|
|
36
38
|
const helpSetLichessGames = [
|
|
37
39
|
` ${colors_1.default.underItalic("setLichessGames <broadcastRoundId> <gameIds...>")}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libroadcast-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "CLI to help with broadcast maintenance on Lichess",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"openapi-fetch": "^0.15.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"prettier": "3.
|
|
21
|
+
"prettier": "3.7.4",
|
|
22
22
|
"typescript": "^5.9.3"
|
|
23
23
|
},
|
|
24
24
|
"bin": {
|