libroadcast-cli 1.3.0 → 1.3.1

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 CHANGED
@@ -2,30 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.delayCommand = void 0;
4
4
  const utils_1 = require("../utils");
5
- const setDelayRounds = (rounds, delay, onlyDelay, noDelay) => rounds.forEach((round) => {
6
- utils_1.client
7
- .POST("/broadcast/round/{broadcastRoundId}/edit", {
8
- params: {
9
- path: { broadcastRoundId: round.id },
10
- query: { patch: 1 },
11
- },
12
- body: {
13
- delay: noDelay ? undefined : delay,
14
- startsAt: round.startsAt && !onlyDelay
15
- ? round.startsAt + delay * 1000
16
- : undefined,
17
- },
18
- })
19
- .then((response) => {
20
- if (response.response.ok)
21
- console.log(`Successfully set delay for round ${round.id} to ${delay} seconds.`);
22
- else
23
- console.error(`Failed to set delay for round ${round.id}: ${response.response.statusText}`);
24
- })
25
- .catch((error) => {
26
- console.error(`Error setting delay for round ${round.id}:`, error);
27
- });
28
- });
5
+ const setDelayRounds = async (rounds, delay, onlyDelay, noDelay) => {
6
+ for (const round of rounds) {
7
+ await utils_1.client
8
+ .POST("/broadcast/round/{broadcastRoundId}/edit", {
9
+ params: {
10
+ path: { broadcastRoundId: round.id },
11
+ query: { patch: 1 },
12
+ },
13
+ body: {
14
+ delay: noDelay ? undefined : delay,
15
+ startsAt: round.startsAt && !onlyDelay
16
+ ? round.startsAt + delay * 1000
17
+ : undefined,
18
+ },
19
+ })
20
+ .then((response) => {
21
+ if (response.response.ok)
22
+ console.log(`Successfully set delay for round ${round.id} to ${delay} seconds.`);
23
+ else
24
+ console.error(`Failed to set delay for round ${round.id}: ${response.response.statusText}`);
25
+ })
26
+ .catch((error) => {
27
+ console.error(`Error setting delay for round ${round.id}:`, error);
28
+ });
29
+ await (0, utils_1.sleep)(200);
30
+ }
31
+ };
29
32
  const delayCommand = async (args) => {
30
33
  const [broadcastId, delay] = args.slice(0, 2);
31
34
  if (args.includes("--help") || args.includes("-h")) {
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setPGNCommand = void 0;
4
4
  const utils_1 = require("../utils");
5
- const setPGN = (rounds, urlRound, setRoundFilter, setSliceFilter = null) => {
6
- let rN = 1;
7
- rounds.forEach((round) => {
5
+ const setPGN = async (rounds, urlRound, setRoundFilter, setSliceFilter = null) => {
6
+ for (let rN = 1; rN <= rounds.length; rN++) {
7
+ const round = rounds[rN];
8
8
  const url = urlRound(rN);
9
- utils_1.client
9
+ await utils_1.client
10
10
  .POST("/broadcast/round/{broadcastRoundId}/edit", {
11
11
  params: {
12
12
  path: { broadcastRoundId: round.id },
@@ -28,8 +28,8 @@ const setPGN = (rounds, urlRound, setRoundFilter, setSliceFilter = null) => {
28
28
  .catch((error) => {
29
29
  console.error(`Error setting source LCC for round ${round.id}:`, error);
30
30
  });
31
- rN += 1;
32
- });
31
+ await (0, utils_1.sleep)(200);
32
+ }
33
33
  };
34
34
  const setPGNCommand = async (args) => {
35
35
  const [bId, sourcePGN] = args.slice(0, 2);
package/dist/utils.js CHANGED
@@ -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.getBroadcast = exports.showHelp = exports.Command = exports.client = exports.LICHESS_TOKEN = void 0;
6
+ exports.sleep = exports.getBroadcast = exports.showHelp = exports.Command = exports.client = exports.LICHESS_TOKEN = void 0;
7
7
  const process_1 = require("process");
8
8
  const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
9
9
  exports.LICHESS_TOKEN = process_1.env.LICHESS_TOKEN;
@@ -67,3 +67,5 @@ const getBroadcast = (broadcastId) => exports.client
67
67
  return null;
68
68
  });
69
69
  exports.getBroadcast = getBroadcast;
70
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
71
+ exports.sleep = sleep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libroadcast-cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "CLI to help with broadcast maintenance on Lichess",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [