libroadcast-cli 2.4.0 → 2.4.2
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/cmd/delay.js +19 -26
- package/dist/cmd/fixSchedule.js +22 -29
- package/dist/cmd/login.js +30 -37
- package/dist/cmd/period.js +17 -24
- package/dist/cmd/push.js +26 -33
- package/dist/cmd/pushFilterID.js +35 -39
- package/dist/cmd/score.js +19 -26
- package/dist/cmd/setLichessGames.js +13 -20
- package/dist/cmd/setPGN.js +19 -26
- package/dist/cmd/setPGNMulti.js +23 -30
- package/dist/cmd/startsPrevious.js +14 -21
- package/dist/index.js +23 -28
- package/dist/utils/colors.js +12 -14
- package/dist/utils/commandHandler.js +55 -65
- package/dist/utils/credentials.js +16 -23
- package/dist/utils/getInfoBroadcast.js +6 -14
- package/dist/utils/help.js +104 -112
- package/package.json +2 -2
package/dist/cmd/score.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.scoreCommand = void 0;
|
|
7
|
-
const node_process_1 = require("node:process");
|
|
8
|
-
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
|
-
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
|
-
const colors_1 = __importDefault(require("../utils/colors"));
|
|
1
|
+
import { exit } from "node:process";
|
|
2
|
+
import { client, msgCommonErrorHelp, sleep, handleApiResponse, translateRoundsToFix, checkTokenScopes, } from "../utils/commandHandler.js";
|
|
3
|
+
import { getBroadcast } from "../utils/getInfoBroadcast.js";
|
|
4
|
+
import cl from "../utils/colors.js";
|
|
11
5
|
const setScoreRounds = async (rounds, blackWin, blackDraw, whiteWin, whiteDraw, roundsToFix) => {
|
|
12
6
|
let filteredRounds = rounds.filter((_, i) => !roundsToFix?.length || roundsToFix.includes(i + 1));
|
|
13
7
|
if (filteredRounds.length === 0)
|
|
14
8
|
filteredRounds = rounds;
|
|
15
9
|
for (const round of filteredRounds) {
|
|
16
|
-
await
|
|
10
|
+
await handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
|
|
17
11
|
params: {
|
|
18
12
|
path: { broadcastRoundId: round.id },
|
|
19
13
|
query: { patch: 1 },
|
|
@@ -24,20 +18,20 @@ const setScoreRounds = async (rounds, blackWin, blackDraw, whiteWin, whiteDraw,
|
|
|
24
18
|
"customScoring.white.draw": whiteDraw,
|
|
25
19
|
"customScoring.white.win": whiteWin,
|
|
26
20
|
},
|
|
27
|
-
}), `Successfully set score for round ${
|
|
28
|
-
await
|
|
21
|
+
}), `Successfully set score for round ${cl.whiteBold(round.id)}: Black win=${cl.whiteBold(blackWin.toString())}, Black draw=${cl.whiteBold(blackDraw.toString())}, White win=${cl.whiteBold(whiteWin.toString())}, White draw=${cl.whiteBold(whiteDraw.toString())}.`, `Error setting score for round ${cl.whiteBold(round.id)}`);
|
|
22
|
+
await sleep(200);
|
|
29
23
|
}
|
|
30
24
|
};
|
|
31
|
-
const scoreCommand = async (args) => {
|
|
32
|
-
await
|
|
25
|
+
export const scoreCommand = async (args) => {
|
|
26
|
+
await checkTokenScopes();
|
|
33
27
|
const [broadcastId, whiteWinStr, whiteDrawStr, blackWinStr, blackDrawStr] = args.slice(0, 5);
|
|
34
28
|
if (!broadcastId ||
|
|
35
29
|
!whiteWinStr ||
|
|
36
30
|
!whiteDrawStr ||
|
|
37
31
|
!blackWinStr ||
|
|
38
32
|
!blackDrawStr) {
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
msgCommonErrorHelp("Broadcast ID, white win, white draw, black win, and black draw scores are required.");
|
|
34
|
+
exit(1);
|
|
41
35
|
}
|
|
42
36
|
const [whiteWin, whiteDraw, blackWin, blackDraw] = [
|
|
43
37
|
whiteWinStr,
|
|
@@ -46,24 +40,23 @@ const scoreCommand = async (args) => {
|
|
|
46
40
|
blackDrawStr,
|
|
47
41
|
].map((scoreStr) => parseFloat(scoreStr));
|
|
48
42
|
if ([whiteWin, whiteDraw, blackWin, blackDraw].some(isNaN)) {
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
msgCommonErrorHelp("Scores for white win, white draw, black win, and black draw must be valid numbers.");
|
|
44
|
+
exit(1);
|
|
51
45
|
}
|
|
52
46
|
if ([whiteWin, whiteDraw, blackWin, blackDraw].some((score) => score < 0 || score > 10)) {
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
msgCommonErrorHelp("Scores for white win, white draw, black win, and black draw must be between 0 and 10.");
|
|
48
|
+
exit(1);
|
|
55
49
|
}
|
|
56
50
|
const roundsArgIndex = args.findIndex((arg) => arg === "--rounds");
|
|
57
51
|
let roundsToFix = undefined;
|
|
58
52
|
if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
|
|
59
53
|
const roundsArg = args[roundsArgIndex + 1];
|
|
60
|
-
roundsToFix = roundsArg ?
|
|
54
|
+
roundsToFix = roundsArg ? translateRoundsToFix(roundsArg) : undefined;
|
|
61
55
|
}
|
|
62
|
-
const broadcast = await
|
|
56
|
+
const broadcast = await getBroadcast(broadcastId);
|
|
63
57
|
if (!broadcast?.rounds || broadcast.rounds.length === 0) {
|
|
64
|
-
console.error(
|
|
65
|
-
|
|
58
|
+
console.error(cl.red("No rounds found for the specified broadcast."));
|
|
59
|
+
exit(1);
|
|
66
60
|
}
|
|
67
61
|
await setScoreRounds(broadcast.rounds, blackWin, blackDraw, whiteWin, whiteDraw, roundsToFix);
|
|
68
62
|
};
|
|
69
|
-
exports.scoreCommand = scoreCommand;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.setLichessGamesCommand = void 0;
|
|
7
|
-
const node_process_1 = require("node:process");
|
|
8
|
-
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
|
-
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
|
-
const colors_1 = __importDefault(require("../utils/colors"));
|
|
11
|
-
const setLichessGames = (round, games) => (0, commandHandler_1.handleApiResponse)(commandHandler_1.client.POST("/broadcast/round/{broadcastRoundId}/edit", {
|
|
1
|
+
import { exit } from "node:process";
|
|
2
|
+
import { client, msgCommonErrorHelp, handleApiResponse, checkTokenScopes, } 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", {
|
|
12
6
|
params: {
|
|
13
7
|
path: { broadcastRoundId: round.id },
|
|
14
8
|
query: { patch: 1 },
|
|
@@ -17,20 +11,19 @@ const setLichessGames = (round, games) => (0, commandHandler_1.handleApiResponse
|
|
|
17
11
|
syncSource: "ids",
|
|
18
12
|
syncIds: games,
|
|
19
13
|
},
|
|
20
|
-
}), `Successfully set games for round ${
|
|
21
|
-
const setLichessGamesCommand = async (args) => {
|
|
22
|
-
await
|
|
14
|
+
}), `Successfully set games for round ${cl.whiteBold(round.id)} to ${cl.whiteBold(games)}.`, `Error setting games for round ${cl.whiteBold(round.id)}`);
|
|
15
|
+
export const setLichessGamesCommand = async (args) => {
|
|
16
|
+
await checkTokenScopes();
|
|
23
17
|
const bId = args.shift();
|
|
24
18
|
const games = args.slice(0, 64).join(" ");
|
|
25
19
|
if (!bId || !games) {
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
msgCommonErrorHelp("Broadcast ID and games IDs are required.");
|
|
21
|
+
exit(1);
|
|
28
22
|
}
|
|
29
|
-
const round = await
|
|
23
|
+
const round = await getBroadcastRound(bId);
|
|
30
24
|
if (!round) {
|
|
31
|
-
console.error(
|
|
32
|
-
|
|
25
|
+
console.error(cl.red(`Broadcast round with ID ${cl.whiteBold(bId)} not found or has no rounds.`));
|
|
26
|
+
exit(1);
|
|
33
27
|
}
|
|
34
28
|
await setLichessGames(round, games);
|
|
35
29
|
};
|
|
36
|
-
exports.setLichessGamesCommand = setLichessGamesCommand;
|
package/dist/cmd/setPGN.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setPGNCommand = void 0;
|
|
7
|
-
const node_process_1 = require("node:process");
|
|
8
|
-
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
|
-
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
|
-
const colors_1 = __importDefault(require("../utils/colors"));
|
|
1
|
+
import { exit } from "node:process";
|
|
2
|
+
import { client, msgCommonErrorHelp, sleep, handleApiResponse, translateRoundsToFix, checkTokenScopes, } from "../utils/commandHandler.js";
|
|
3
|
+
import { getBroadcast } from "../utils/getInfoBroadcast.js";
|
|
4
|
+
import cl from "../utils/colors.js";
|
|
11
5
|
const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null, roundsToFix) => {
|
|
12
6
|
const roundsWithIndex = rounds.map((el, i) => ({ ...el, index: i }));
|
|
13
7
|
let filteredRounds = roundsWithIndex.filter((_, i) => !roundsToFix?.length || roundsToFix.includes(i + 1));
|
|
@@ -16,7 +10,7 @@ const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null, r
|
|
|
16
10
|
for (const [_, round] of filteredRounds.entries()) {
|
|
17
11
|
const rN = round.index + 1;
|
|
18
12
|
const url = urlRound(rN);
|
|
19
|
-
await
|
|
13
|
+
await handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
|
|
20
14
|
params: {
|
|
21
15
|
path: { broadcastRoundId: round.id },
|
|
22
16
|
query: { patch: 1 },
|
|
@@ -27,21 +21,21 @@ const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null, r
|
|
|
27
21
|
onlyRound: setRoundFilter ? rN : undefined,
|
|
28
22
|
slices: setSliceFilter || undefined,
|
|
29
23
|
},
|
|
30
|
-
}), `Successfully set source for round ${
|
|
31
|
-
await
|
|
24
|
+
}), `Successfully set source for round ${cl.whiteBold(round.id)} to ${cl.whiteBold(url)}.`, `Error setting source for round ${cl.whiteBold(round.id)}`);
|
|
25
|
+
await sleep(200);
|
|
32
26
|
}
|
|
33
27
|
};
|
|
34
|
-
const setPGNCommand = async (args) => {
|
|
35
|
-
await
|
|
28
|
+
export const setPGNCommand = async (args) => {
|
|
29
|
+
await checkTokenScopes();
|
|
36
30
|
const [bId, sourcePGN] = args.slice(0, 2);
|
|
37
31
|
if (!bId || !sourcePGN) {
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
msgCommonErrorHelp("Broadcast ID and source PGN URL are required.");
|
|
33
|
+
exit(1);
|
|
40
34
|
}
|
|
41
|
-
const bcast = await
|
|
35
|
+
const bcast = await getBroadcast(bId);
|
|
42
36
|
if (!bcast?.rounds || bcast.rounds.length === 0) {
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
msgCommonErrorHelp("No rounds found for the specified broadcast.");
|
|
38
|
+
exit(1);
|
|
45
39
|
}
|
|
46
40
|
const urlRound = (roundNum) => roundNum ? sourcePGN.replaceAll("{}", roundNum.toString()) : sourcePGN;
|
|
47
41
|
try {
|
|
@@ -51,23 +45,22 @@ const setPGNCommand = async (args) => {
|
|
|
51
45
|
}
|
|
52
46
|
const isLCC = url.hostname === "view.livechesscloud.com";
|
|
53
47
|
if (isLCC && url.hash.length > 1 && !url.hash.endsWith("/{}")) {
|
|
54
|
-
console.error(
|
|
55
|
-
|
|
48
|
+
console.error(cl.red('Invalid URL. For livechesscloud URLs, please ensure it ends with "/{}".'));
|
|
49
|
+
exit(1);
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
52
|
catch (error) {
|
|
59
|
-
console.error(
|
|
60
|
-
|
|
53
|
+
console.error(cl.red('Invalid URL. Must be http/https with "{}" as round placeholder.'));
|
|
54
|
+
exit(1);
|
|
61
55
|
}
|
|
62
56
|
const roundsArgIndex = args.findIndex((arg) => arg === "--rounds");
|
|
63
57
|
let roundsToFix = undefined;
|
|
64
58
|
if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
|
|
65
59
|
const roundsArg = args[roundsArgIndex + 1];
|
|
66
|
-
roundsToFix = roundsArg ?
|
|
60
|
+
roundsToFix = roundsArg ? translateRoundsToFix(roundsArg) : undefined;
|
|
67
61
|
}
|
|
68
62
|
const setRoundFilter = args.includes("--withFilter");
|
|
69
63
|
const sliceIndex = args.indexOf("--slice");
|
|
70
64
|
const setSliceFilter = sliceIndex !== -1 ? args[sliceIndex + 1] || null : null;
|
|
71
65
|
await setPGN(bcast.rounds, urlRound, setRoundFilter, setSliceFilter, roundsToFix);
|
|
72
66
|
};
|
|
73
|
-
exports.setPGNCommand = setPGNCommand;
|
package/dist/cmd/setPGNMulti.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setPGNMultiCommand = void 0;
|
|
7
|
-
const node_process_1 = require("node:process");
|
|
8
|
-
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
|
-
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
|
-
const colors_1 = __importDefault(require("../utils/colors"));
|
|
1
|
+
import { exit } from "node:process";
|
|
2
|
+
import { client, msgCommonErrorHelp, sleep, handleApiResponse, translateRoundsToFix, checkTokenScopes, } from "../utils/commandHandler.js";
|
|
3
|
+
import { getBroadcast } from "../utils/getInfoBroadcast.js";
|
|
4
|
+
import cl from "../utils/colors.js";
|
|
11
5
|
const setPGN = async (rounds, urlsRound, gamesNum, setRoundFilter, setSliceFilter = null, roundsToFix) => {
|
|
12
6
|
const roundsWithIndex = rounds.map((el, i) => ({ ...el, index: i }));
|
|
13
7
|
let filteredRounds = roundsWithIndex.filter((_, i) => !roundsToFix?.length || roundsToFix.includes(i + 1));
|
|
@@ -18,7 +12,7 @@ const setPGN = async (rounds, urlsRound, gamesNum, setRoundFilter, setSliceFilte
|
|
|
18
12
|
const urls = urlsRound(gamesNum, rN)
|
|
19
13
|
.filter((_, i) => setSliceFilter ? setSliceFilter.includes(i + 1) : true)
|
|
20
14
|
.join("\n");
|
|
21
|
-
await
|
|
15
|
+
await handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
|
|
22
16
|
params: {
|
|
23
17
|
path: { broadcastRoundId: round.id },
|
|
24
18
|
query: { patch: 1 },
|
|
@@ -28,8 +22,8 @@ const setPGN = async (rounds, urlsRound, gamesNum, setRoundFilter, setSliceFilte
|
|
|
28
22
|
syncUrls: urls,
|
|
29
23
|
onlyRound: setRoundFilter ? rN : undefined,
|
|
30
24
|
},
|
|
31
|
-
}), `Successfully set source for round ${
|
|
32
|
-
await
|
|
25
|
+
}), `Successfully set source for round ${cl.whiteBold(round.id)} to\n${cl.whiteBold(urls)}`, `Error setting source for round ${cl.whiteBold(round.id)}`);
|
|
26
|
+
await sleep(200);
|
|
33
27
|
}
|
|
34
28
|
};
|
|
35
29
|
const translateGamesToAdd = (arg, gamesN) => {
|
|
@@ -65,26 +59,26 @@ const translateGamesToAdd = (arg, gamesN) => {
|
|
|
65
59
|
}
|
|
66
60
|
return [...new Set(rounds)];
|
|
67
61
|
};
|
|
68
|
-
const setPGNMultiCommand = async (args) => {
|
|
69
|
-
await
|
|
62
|
+
export const setPGNMultiCommand = async (args) => {
|
|
63
|
+
await checkTokenScopes();
|
|
70
64
|
const [bId, sourcePGNs, gamesN] = args.slice(0, 3);
|
|
71
65
|
if (!bId || !sourcePGNs || !gamesN) {
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
msgCommonErrorHelp("Broadcast ID, source PGN URLs, and number of games are required.");
|
|
67
|
+
exit(1);
|
|
74
68
|
}
|
|
75
|
-
const bcast = await
|
|
69
|
+
const bcast = await getBroadcast(bId);
|
|
76
70
|
if (!bcast?.rounds || bcast.rounds.length === 0) {
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
msgCommonErrorHelp("No rounds found for the specified broadcast.");
|
|
72
|
+
exit(1);
|
|
79
73
|
}
|
|
80
74
|
let gamesNum = parseInt(gamesN, 10);
|
|
81
75
|
if (isNaN(gamesNum) || gamesNum <= 0) {
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
msgCommonErrorHelp("Number of games must be a positive integer.");
|
|
77
|
+
exit(1);
|
|
84
78
|
}
|
|
85
79
|
if (bcast.rounds.length > 1 && !sourcePGNs.includes("{g}")) {
|
|
86
|
-
console.error(
|
|
87
|
-
|
|
80
|
+
console.error(cl.red('For broadcasts with multiple rounds, the source PGN URLs must include the "{g}" placeholder for round numbers.'));
|
|
81
|
+
exit(1);
|
|
88
82
|
}
|
|
89
83
|
const urlRound = (gamesN, roundNum) => {
|
|
90
84
|
let rN = roundNum
|
|
@@ -103,20 +97,20 @@ const setPGNMultiCommand = async (args) => {
|
|
|
103
97
|
}
|
|
104
98
|
const isLCC = url.hostname === "view.livechesscloud.com";
|
|
105
99
|
if (isLCC) {
|
|
106
|
-
console.error(
|
|
107
|
-
|
|
100
|
+
console.error(cl.red("Invalid URL."));
|
|
101
|
+
exit(1);
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
104
|
catch (error) {
|
|
111
|
-
console.error(
|
|
112
|
-
|
|
105
|
+
console.error(cl.red('Invalid URL. Must be http/https with "{}" as round placeholder.'));
|
|
106
|
+
exit(1);
|
|
113
107
|
}
|
|
114
108
|
const setRoundFilter = args.includes("--withFilter");
|
|
115
109
|
const roundsArgIndex = args.findIndex((arg) => arg === "--rounds");
|
|
116
110
|
let roundsToFix = undefined;
|
|
117
111
|
if (roundsArgIndex !== -1 && roundsArgIndex + 1 < args.length) {
|
|
118
112
|
const roundsArg = args[roundsArgIndex + 1];
|
|
119
|
-
roundsToFix = roundsArg ?
|
|
113
|
+
roundsToFix = roundsArg ? translateRoundsToFix(roundsArg) : undefined;
|
|
120
114
|
}
|
|
121
115
|
const sliceIndex = args.indexOf("--onlyGames");
|
|
122
116
|
const setSliceFilter = sliceIndex !== -1
|
|
@@ -124,4 +118,3 @@ const setPGNMultiCommand = async (args) => {
|
|
|
124
118
|
: null;
|
|
125
119
|
await setPGN(bcast.rounds, urlRound, gamesNum, setRoundFilter, setSliceFilter, roundsToFix);
|
|
126
120
|
};
|
|
127
|
-
exports.setPGNMultiCommand = setPGNMultiCommand;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.startsPreviousCommand = void 0;
|
|
7
|
-
const node_process_1 = require("node:process");
|
|
8
|
-
const commandHandler_1 = require("../utils/commandHandler");
|
|
9
|
-
const getInfoBroadcast_1 = require("../utils/getInfoBroadcast");
|
|
10
|
-
const colors_1 = __importDefault(require("../utils/colors"));
|
|
1
|
+
import { exit } from "node:process";
|
|
2
|
+
import { client, msgCommonErrorHelp, sleep, handleApiResponse, checkTokenScopes, } from "../utils/commandHandler.js";
|
|
3
|
+
import { getBroadcast } from "../utils/getInfoBroadcast.js";
|
|
4
|
+
import cl from "../utils/colors.js";
|
|
11
5
|
const setStartsPrevious = async (rounds, startsPrevious) => {
|
|
12
6
|
const roundfilter = rounds.filter((r) => r.startsAfterPrevious !== startsPrevious && !r.startsAt);
|
|
13
7
|
for (const round of roundfilter) {
|
|
14
|
-
await
|
|
8
|
+
await handleApiResponse(client.POST("/broadcast/round/{broadcastRoundId}/edit", {
|
|
15
9
|
params: {
|
|
16
10
|
path: { broadcastRoundId: round.id },
|
|
17
11
|
query: { patch: 1 },
|
|
@@ -19,25 +13,24 @@ const setStartsPrevious = async (rounds, startsPrevious) => {
|
|
|
19
13
|
body: {
|
|
20
14
|
startsAfterPrevious: startsPrevious,
|
|
21
15
|
},
|
|
22
|
-
}), `Successfully set startsAfterPrevious for round ${
|
|
23
|
-
await
|
|
16
|
+
}), `Successfully set startsAfterPrevious for round ${cl.whiteBold(round.id)} to ${cl.whiteBold(startsPrevious.toString())}.`, `Error setting startsAfterPrevious for round ${cl.whiteBold(round.id)}`);
|
|
17
|
+
await sleep(200);
|
|
24
18
|
}
|
|
25
19
|
};
|
|
26
|
-
const startsPreviousCommand = async (args) => {
|
|
27
|
-
await
|
|
20
|
+
export const startsPreviousCommand = async (args) => {
|
|
21
|
+
await checkTokenScopes();
|
|
28
22
|
const [broadcastId, startsPrevious] = args.slice(0, 2);
|
|
29
23
|
if (!broadcastId || !startsPrevious) {
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
msgCommonErrorHelp("Broadcast ID and startsPrevious are required.");
|
|
25
|
+
exit(1);
|
|
32
26
|
}
|
|
33
27
|
const startsPreviousBool = startsPrevious.toLowerCase() === "true" ||
|
|
34
28
|
startsPrevious === "1" ||
|
|
35
29
|
startsPrevious.toLowerCase() === "yes";
|
|
36
|
-
const broadcast = await
|
|
30
|
+
const broadcast = await getBroadcast(broadcastId);
|
|
37
31
|
if (!broadcast?.rounds || broadcast.rounds.length === 0) {
|
|
38
|
-
console.error(
|
|
39
|
-
|
|
32
|
+
console.error(cl.red("No rounds found for the specified broadcast."));
|
|
33
|
+
exit(1);
|
|
40
34
|
}
|
|
41
35
|
await setStartsPrevious(broadcast.rounds, startsPreviousBool);
|
|
42
36
|
};
|
|
43
|
-
exports.startsPreviousCommand = startsPreviousCommand;
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const node_process_1 = require("node:process");
|
|
8
|
-
const commandHandler_1 = require("./utils/commandHandler");
|
|
9
|
-
const help_1 = require("./utils/help");
|
|
10
|
-
const colors_1 = __importDefault(require("./utils/colors"));
|
|
2
|
+
import { exit } from "node:process";
|
|
3
|
+
import { LICHESS_TOKEN, args, Command, commands, packageJson, } from "./utils/commandHandler.js";
|
|
4
|
+
import { showHelp, includeHelp } from "./utils/help.js";
|
|
5
|
+
import cl from "./utils/colors.js";
|
|
11
6
|
(async () => {
|
|
12
|
-
if (
|
|
13
|
-
console.log(`${
|
|
14
|
-
|
|
7
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
8
|
+
console.log(`${cl.whiteBold(packageJson.name)} ${cl.underItalic(`v${packageJson.version}`)}`);
|
|
9
|
+
exit(0);
|
|
15
10
|
}
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
if (args.length === 0 || includeHelp(args[0])) {
|
|
12
|
+
showHelp();
|
|
13
|
+
exit(0);
|
|
19
14
|
}
|
|
20
|
-
const cmd =
|
|
21
|
-
const handler =
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const cmd = args.shift();
|
|
16
|
+
const handler = commands.get(cmd);
|
|
17
|
+
if (args.find(includeHelp)) {
|
|
18
|
+
showHelp(cmd);
|
|
19
|
+
exit(0);
|
|
25
20
|
}
|
|
26
21
|
if (!handler) {
|
|
27
|
-
console.error(`${
|
|
28
|
-
|
|
22
|
+
console.error(`${cl.red("Error:")} Command handler not found.`);
|
|
23
|
+
exit(1);
|
|
29
24
|
}
|
|
30
|
-
if (cmd ===
|
|
31
|
-
await handler(
|
|
25
|
+
if (cmd === Command.Login) {
|
|
26
|
+
await handler(args);
|
|
32
27
|
return;
|
|
33
28
|
}
|
|
34
|
-
if (!
|
|
35
|
-
console.error(`${
|
|
36
|
-
|
|
29
|
+
if (!LICHESS_TOKEN?.trim() || !LICHESS_TOKEN.startsWith("lip_")) {
|
|
30
|
+
console.error(`${cl.blue("Use the 'login' command to save your credentials: ")}${cl.whiteBold("libroadcast login")}`);
|
|
31
|
+
exit(1);
|
|
37
32
|
}
|
|
38
|
-
await handler(
|
|
33
|
+
await handler(args);
|
|
39
34
|
})();
|
package/dist/utils/colors.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
green: (text) => (0, node_util_1.styleText)("green", text),
|
|
14
|
-
whiteBold: (text) => (0, node_util_1.styleText)(["white", "bold"], text),
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
export default {
|
|
3
|
+
red: (text) => styleText("red", text),
|
|
4
|
+
redBold: (text) => styleText(["red", "bold"], text),
|
|
5
|
+
blue: (text) => styleText("blue", text),
|
|
6
|
+
boldYellow: (text) => styleText(["bold", "yellow"], text),
|
|
7
|
+
underItalic: (text) => styleText(["underline", "italic"], text),
|
|
8
|
+
bold: (text) => styleText("bold", text),
|
|
9
|
+
italic: (text) => styleText("italic", text),
|
|
10
|
+
gray: (text) => styleText("gray", text),
|
|
11
|
+
green: (text) => styleText("green", text),
|
|
12
|
+
whiteBold: (text) => styleText(["white", "bold"], text),
|
|
15
13
|
};
|