lscontests 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +22 -0
  2. package/bin/cli.js +51 -0
  3. package/package.json +13 -2
package/README.md CHANGED
@@ -1 +1,23 @@
1
1
  # lscontests
2
+
3
+ ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/StableAgOH/lscontests)
4
+ ![GitHub](https://img.shields.io/github/license/StableAgOH/lscontests)
5
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
6
+ ![npm](https://img.shields.io/npm/v/lscontests)
7
+
8
+ A CLI tool to get information about the contests on each OJ
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ lsct [options]
14
+
15
+ Options:
16
+ -V, --version output the version number
17
+ -a, --all List all contests
18
+ -d, --days Only list contests within a given number of days
19
+ ```
20
+
21
+ ## License
22
+
23
+ [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.html)
package/bin/cli.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var commander = require('commander');
5
+ var axios = require('axios');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
+
11
+ var version = "1.0.1";
12
+
13
+ async function get() {
14
+ const result = (await axios__default["default"].get("https://codeforces.com/api/contest.list")).data.result;
15
+ return result.map(contest => {
16
+ return {
17
+ oj: "Codeforces",
18
+ name: contest.name,
19
+ rule: contest.type,
20
+ startTime: new Date(contest.startTimeSeconds * 1000),
21
+ durationHours: contest.durationSeconds / 60 / 60,
22
+ url: `https://codeforces.com/contests/${contest.id}`
23
+ };
24
+ }).filter(contest => contest.startTime >= new Date());
25
+ }
26
+
27
+ const getters = {
28
+ "codeforces": get
29
+ };
30
+
31
+ async function list(getters, days) {
32
+ const cts = [];
33
+
34
+ for (const get of getters) {
35
+ const res = await get();
36
+ cts.push(...res.filter(ct => ct.startTime <= new Date(Date.now() + days * 86400000)));
37
+ }
38
+
39
+ return cts;
40
+ }
41
+
42
+ commander.program.name("lsct").version(version).option("-a, --all", "List all contests").option("-d, --days", "Only list contests within a given number of days", "3").parse();
43
+ const opts = commander.program.opts();
44
+
45
+ async function main() {
46
+ const cts = [];
47
+ if (commander.program.args.length === 0 || opts.all) cts.push(...(await list(Object.values(getters), opts.days)));
48
+ console.log(cts);
49
+ }
50
+
51
+ main();
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "lscontests",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A CLI tool to get information about the contests on each OJ",
5
+ "keywords": [
6
+ "cli",
7
+ "competitive-programming"
8
+ ],
5
9
  "repository": "https://github.com/StableAgOH/lscontests",
6
10
  "author": "StableAgOH <stagoh17@gmail.com>",
7
11
  "license": "GPL-3.0",
@@ -15,7 +19,8 @@
15
19
  ],
16
20
  "scripts": {
17
21
  "build": "rollup -c",
18
- "watch": "rollup -c --watch"
22
+ "watch": "rollup -c --watch",
23
+ "prepack": "yarn build"
19
24
  },
20
25
  "dependencies": {
21
26
  "axios": "^0.27.2",
@@ -33,9 +38,15 @@
33
38
  "@types/node": "^17.0.31",
34
39
  "@typescript-eslint/eslint-plugin": "^5.22.0",
35
40
  "@typescript-eslint/parser": "^5.22.0",
41
+ "cz-conventional-changelog": "3.3.0",
36
42
  "eslint": "^8.14.0",
37
43
  "rollup": "^2.72.0",
38
44
  "semantic-release": "^19.0.2",
39
45
  "typescript": "^4.6.4"
46
+ },
47
+ "config": {
48
+ "commitizen": {
49
+ "path": "./node_modules/cz-conventional-changelog"
50
+ }
40
51
  }
41
52
  }