@irfanshadikrishad/anilist 1.9.8 → 2.0.0-forbidden.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/bin/index.js CHANGED
@@ -8,22 +8,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var _a;
12
11
  import { Command } from 'commander';
13
12
  import process from 'process';
14
13
  import { Auth, Social } from './helpers/auth.js';
15
- import { AniList, MoveTo } from './helpers/lists.js';
14
+ import { AniList } from './helpers/lists.js';
16
15
  import { getCurrentPackageVersion } from './helpers/workers.js';
17
16
  const cli = new Command();
17
+ /**
18
+ * Dispatch to exactly one handler out of a set of mutually-exclusive options
19
+ * (eg: --anime/--manga, --follow/--unfollow/--inactive), optionally requiring login.
20
+ */
21
+ function dispatchOneOf(options_1) {
22
+ return __awaiter(this, arguments, void 0, function* (options, { requireLogin = false } = {}) {
23
+ const selected = options.filter(({ flag }) => flag);
24
+ if (selected.length !== 1) {
25
+ const names = options.map(({ name }) => `--${name}`);
26
+ const optionList = names.length <= 2
27
+ ? names.join(' or ')
28
+ : `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`;
29
+ console.error(`\nMust select an option, either ${optionList}`);
30
+ return;
31
+ }
32
+ if (requireLogin && !(yield Auth.isLoggedIn())) {
33
+ console.error(`\nPlease login to use this feature.`);
34
+ return;
35
+ }
36
+ yield selected[0].handler();
37
+ });
38
+ }
18
39
  cli
19
40
  .name('anilist')
20
41
  .description('Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.')
21
- .version((_a = getCurrentPackageVersion()) !== null && _a !== void 0 ? _a : '');
42
+ .version(getCurrentPackageVersion());
22
43
  cli
23
44
  .command('login')
24
45
  .description('Login with AniList')
25
- .requiredOption('-i, --id <number>', '')
26
- .requiredOption('-s, --secret <string>', '')
46
+ .requiredOption('-i, --id <number>', null)
47
+ .requiredOption('-s, --secret <string>', null)
27
48
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ id, secret }) {
28
49
  if (id && secret) {
29
50
  yield Auth.Login(id, secret);
@@ -73,15 +94,10 @@ cli
73
94
  .option('-a, --anime', 'For anime list of authenticated user', false)
74
95
  .option('-m, --manga', 'For manga list of authenticated user', false)
75
96
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga }) {
76
- if ((!anime && !manga) || (anime && manga)) {
77
- console.error(`\nMust select an option, either --anime or --manga`);
78
- }
79
- else if (anime) {
80
- yield AniList.MyAnime();
81
- }
82
- else if (manga) {
83
- yield AniList.MyManga();
84
- }
97
+ return dispatchOneOf([
98
+ { flag: anime, name: 'anime', handler: AniList.MyAnime },
99
+ { flag: manga, name: 'manga', handler: AniList.MyManga },
100
+ ]);
85
101
  }));
86
102
  cli
87
103
  .command('delete')
@@ -132,6 +148,7 @@ cli
132
148
  cli
133
149
  .command('manga <id>')
134
150
  .description('Get manga details by their ID')
151
+ .option('-c, --count <number>', 'Number of items to get', '10')
135
152
  .action((id) => __awaiter(void 0, void 0, void 0, function* () {
136
153
  yield AniList.getMangaDetailsByID(id);
137
154
  }));
@@ -144,20 +161,18 @@ cli
144
161
  .option('-m, --manga', 'To get the manga search results.', false)
145
162
  .option('-c, --count <number>', 'Number of search results to show.', '10')
146
163
  .action((query_1, _a) => __awaiter(void 0, [query_1, _a], void 0, function* (query, { anime, manga, count }) {
147
- if ((!anime && !manga) || (anime && manga)) {
148
- console.error(`\nMust select an option, either --anime or --manga`);
149
- }
150
- else {
151
- if (anime) {
152
- yield AniList.searchAnime(query, Number(count));
153
- }
154
- else if (manga) {
155
- yield AniList.searchManga(query, Number(count));
156
- }
157
- else {
158
- console.error(`\nMust select an option, either --anime or --manga`);
159
- }
160
- }
164
+ return dispatchOneOf([
165
+ {
166
+ flag: anime,
167
+ name: 'anime',
168
+ handler: () => AniList.searchAnime(query, Number(count)),
169
+ },
170
+ {
171
+ flag: manga,
172
+ name: 'manga',
173
+ handler: () => AniList.searchManga(query, Number(count)),
174
+ },
175
+ ]);
161
176
  }));
162
177
  cli
163
178
  .command('status <status>')
@@ -174,17 +189,10 @@ cli
174
189
  .option('-a, --anime', 'To get the anime search results.', false)
175
190
  .option('-m, --manga', 'To get the manga search results.', false)
176
191
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga }) {
177
- if ((!anime && !manga) || (anime && manga)) {
178
- console.error(`\nMust select an option, either --anime or --manga`);
179
- }
180
- else {
181
- if (anime) {
182
- yield AniList.exportAnime();
183
- }
184
- else if (manga) {
185
- yield AniList.exportManga();
186
- }
187
- }
192
+ return dispatchOneOf([
193
+ { flag: anime, name: 'anime', handler: AniList.exportAnime },
194
+ { flag: manga, name: 'manga', handler: AniList.exportManga },
195
+ ]);
188
196
  }));
189
197
  cli
190
198
  .command('import')
@@ -193,22 +201,17 @@ cli
193
201
  .option('-a, --anime', 'To get the anime search results.', false)
194
202
  .option('-m, --manga', 'To get the manga search results.', false)
195
203
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga }) {
196
- if ((!anime && !manga) || (anime && manga)) {
197
- console.error(`\nMust select an option, either --anime or --manga`);
198
- }
199
- else {
200
- if (yield Auth.isLoggedIn()) {
201
- if (anime) {
202
- yield Auth.callAnimeImporter();
203
- }
204
- else if (manga) {
205
- yield Auth.callMangaImporter();
206
- }
207
- }
208
- else {
209
- console.error(`\nPlease login to use this feature.`);
210
- }
211
- }
204
+ return dispatchOneOf([
205
+ { flag: anime, name: 'anime', handler: Auth.callAnimeImporter },
206
+ { flag: manga, name: 'manga', handler: Auth.callMangaImporter },
207
+ ], { requireLogin: true });
208
+ }));
209
+ cli
210
+ .command('autolike')
211
+ .alias('al')
212
+ .description('Autolike following or global activities.')
213
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
214
+ yield Auth.AutoLike();
212
215
  }));
213
216
  cli
214
217
  .command('social')
@@ -216,43 +219,16 @@ cli
216
219
  .description('Automate your process')
217
220
  .option('-f, --follow', 'Follow the user whos following you.', false)
218
221
  .option('-u, --unfollow', 'Unfollow the user whos not following you.', false)
219
- .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ follow, unfollow }) {
220
- if (!follow && !unfollow) {
221
- console.error(`\nMust select an option, either --follow or --unfollow`);
222
- }
223
- else {
224
- if (yield Auth.isLoggedIn()) {
225
- if (follow) {
226
- yield Social.follow();
227
- }
228
- else if (unfollow) {
229
- yield Social.unfollow();
230
- }
231
- }
232
- else {
233
- console.error(`\nPlease login to use this feature.`);
234
- }
235
- }
236
- }));
237
- cli
238
- .command('move')
239
- .alias('mv')
240
- .description('Move anime or manga from one list to another')
241
- .option('-a, --anime', 'To move anime lists.', false)
242
- .option('-m, --manga', 'To move manga lists.', false)
243
- .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga }) {
244
- if (!(yield Auth.isLoggedIn())) {
245
- console.error(`\nPlease login to use this feature.`);
246
- process.exit(1);
247
- }
248
- if ((!anime && !manga) || (anime && manga)) {
249
- console.error(`\nMust select an option, either --anime or --manga`);
250
- }
251
- if (anime) {
252
- yield MoveTo.AnimeList();
253
- }
254
- else if (manga) {
255
- yield MoveTo.MangaList();
256
- }
222
+ .option('-i, --inactive <months>', 'Unfollow users you follow with no activity in this many months')
223
+ .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ follow, unfollow, inactive }) {
224
+ return dispatchOneOf([
225
+ { flag: follow, name: 'follow', handler: Social.follow },
226
+ { flag: unfollow, name: 'unfollow', handler: Social.unfollow },
227
+ {
228
+ flag: inactive !== undefined,
229
+ name: 'inactive <months>',
230
+ handler: () => Social.unfollowInactive(Number(inactive)),
231
+ },
232
+ ], { requireLogin: true });
257
233
  }));
258
234
  cli.parse(process.argv);
package/package.json CHANGED
@@ -1,94 +1,91 @@
1
1
  {
2
- "name": "@irfanshadikrishad/anilist",
3
- "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
- "version": "1.9.8",
5
- "author": "Irfan Shadik Rishad",
6
- "license": "MPL-2.0",
7
- "scripts": {
8
- "all": "npm run build && npm run lint && npm run lint:fix && npm run format && npm test",
9
- "build": "rm -rf ./bin && tsc",
10
- "build:watch": "rm -rf ./bin && tsc -w",
11
- "format": "prettier . --write",
12
- "format:check": "prettier . --check",
13
- "lint": "eslint ./dist",
14
- "lint:fix": "eslint ./dist --fix",
15
- "prepare": "husky",
16
- "pretest": "npm run build",
17
- "test": "NODE_OPTIONS='--experimental-vm-modules' jest ./tests --runInBand"
18
- },
19
- "keywords": [
20
- "anilist",
21
- "CLI",
22
- "anime",
23
- "manga",
24
- "anime list",
25
- "manga list",
26
- "anime tracker",
27
- "manga tracker",
28
- "anilist API",
29
- "anime progress",
30
- "manga progress",
31
- "media list",
32
- "export anime",
33
- "import anime",
34
- "export manga",
35
- "import manga",
36
- "status tracker",
37
- "watchlist",
38
- "reading list",
39
- "graphql"
40
- ],
41
- "homepage": "https://github.com/irfanshadikrishad/anilist",
42
- "bugs": {
43
- "url": "https://github.com/irfanshadikrishad/anilist/issues"
44
- },
45
- "repository": {
46
- "type": "git",
47
- "url": "https://github.com/irfanshadikrishad/anilist"
48
- },
49
- "type": "module",
50
- "main": "./bin/index.js",
51
- "types": "./bin/index.d.ts",
52
- "bin": {
53
- "anilist": "./bin/index.js"
54
- },
55
- "prettier": "@irfanshadikrishad/prettier",
56
- "dependencies": {
57
- "@irfanshadikrishad/cipher": "^1.7.1",
58
- "chalk": "^6.0.0",
59
- "cli-truncate": "^6.1.1",
60
- "commander": "^14.0.3",
61
- "fast-xml-parser": "^5.10.1",
62
- "inquirer": "^13.4.3",
63
- "jsonrepair": "^3.15.0",
64
- "open": "^11.0.0",
65
- "papaparse": "^5.5.4",
66
- "tiny-spinner": "^2.0.5"
67
- },
68
- "devDependencies": {
69
- "@babel/preset-env": "^7.29.7",
70
- "@eslint/js": "^10.0.1",
71
- "@irfanshadikrishad/prettier": "^1.3.7",
72
- "@types/jest": "^30.0.0",
73
- "@types/node": "^25.9.1",
74
- "@types/papaparse": "^5.5.2",
75
- "@typescript-eslint/eslint-plugin": "^8.66.0",
76
- "@typescript-eslint/parser": "^8.66.0",
77
- "eslint": "^10.8.0",
78
- "globals": "^17.9.0",
79
- "husky": "^9.1.7",
80
- "jest": "^30.4.2",
81
- "prettier": "^3.9.6",
82
- "prettier-plugin-organize-imports": "^4.3.0",
83
- "ts-jest": "^29.4.12",
84
- "ts-node": "^10.9.2",
85
- "typescript": "^6.0.3"
86
- },
87
- "engines": {
88
- "node": ">=24.0.0",
89
- "npm": ">=10.0.0"
90
- },
91
- "publishConfig": {
92
- "access": "public"
93
- }
2
+ "name": "@irfanshadikrishad/anilist",
3
+ "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
+ "author": "Irfan Shadik Rishad",
5
+ "version": "2.0.0-forbidden.0",
6
+ "main": "./bin/index.js",
7
+ "type": "module",
8
+ "types": "./bin/index.d.ts",
9
+ "bin": {
10
+ "anilist": "./bin/index.js"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "build": "rm -rf ./bin && tsc",
17
+ "build:watch": "rm -rf ./bin && tsc -w",
18
+ "format": "prettier . --write",
19
+ "format:check": "prettier . --check",
20
+ "lint": "eslint ./dist",
21
+ "lint:fix": "eslint ./dist --fix",
22
+ "all": "npm run build && npm run lint && npm run lint:fix && npm run format && npm test",
23
+ "test": "jest ./tests",
24
+ "prepare": "husky"
25
+ },
26
+ "keywords": [
27
+ "anilist",
28
+ "CLI",
29
+ "anime",
30
+ "manga",
31
+ "anime list",
32
+ "manga list",
33
+ "anime tracker",
34
+ "manga tracker",
35
+ "anilist API",
36
+ "anime progress",
37
+ "manga progress",
38
+ "media list",
39
+ "export anime",
40
+ "import anime",
41
+ "export manga",
42
+ "import manga",
43
+ "status tracker",
44
+ "watchlist",
45
+ "reading list",
46
+ "graphql"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/irfanshadikrishad/anilist"
51
+ },
52
+ "homepage": "https://github.com/irfanshadikrishad/anilist",
53
+ "bugs": {
54
+ "url": "https://github.com/irfanshadikrishad/anilist/issues"
55
+ },
56
+ "license": "MPL-2.0",
57
+ "prettier": "@irfanshadikrishad/prettier",
58
+ "devDependencies": {
59
+ "@babel/preset-env": "^7.28.0",
60
+ "@eslint/js": "^9.31.0",
61
+ "@irfanshadikrishad/prettier": "^1.1.0",
62
+ "@types/jest": "^30.0.0",
63
+ "@types/node": "^24.0.14",
64
+ "@types/papaparse": "^5.3.16",
65
+ "@types/xml2js": "^0.4.14",
66
+ "@typescript-eslint/eslint-plugin": "^8.37.0",
67
+ "eslint": "^9.31.0",
68
+ "globals": "^16.3.0",
69
+ "husky": "^9.1.7",
70
+ "jest": "^30.0.4",
71
+ "prettier": "^3.6.2",
72
+ "prettier-plugin-organize-imports": "^4.1.0",
73
+ "ts-jest": "^29.4.0",
74
+ "ts-node": "^10.9.2",
75
+ "typescript": "^5.8.3"
76
+ },
77
+ "dependencies": {
78
+ "@irfanshadikrishad/cipher": "^1.3.0",
79
+ "chalk": "^5.4.1",
80
+ "cli-truncate": "^4.0.0",
81
+ "commander": "^14.0.0",
82
+ "fast-xml-parser": "^5.2.5",
83
+ "inquirer": "^12.7.0",
84
+ "jsonrepair": "^3.13.0",
85
+ "node-fetch": "^3.3.2",
86
+ "open": "^10.2.0",
87
+ "papaparse": "^5.5.3",
88
+ "tiny-spinner": "^2.0.5",
89
+ "xml2js": "^0.6.2"
90
+ }
94
91
  }
package/CITATION.cff DELETED
@@ -1,8 +0,0 @@
1
- cff-version: 1.2.0
2
- message: 'If you use this software, please cite it as below.'
3
- title: '@irfanshadikrishad/anilist'
4
- authors:
5
- - name: 'Irfan Shadik Rishad'
6
- orcid: '0009-0001-6745-5291'
7
- date-released: '2024-10-12'
8
- repository-code: 'https://github.com/irfanshadikrishad/anilist'
File without changes
File without changes