forked from skygragon/leetcode-cli
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathconfig.js
169 lines (157 loc) · 4.61 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
'use strict';
var _ = require('underscore');
var nconf = require('nconf');
var file = require('./file');
const DEFAULT_CONFIG = {
// usually you don't wanna change those
sys: {
categories: [
'algorithms',
'database',
'shell',
'concurrency'
],
langs: [
'bash',
'c',
'cpp',
'csharp',
'golang',
'java',
'javascript',
'kotlin',
'mysql',
'php',
'python',
'python3',
'ruby',
'rust',
'scala',
'swift',
'typescript'
],
tags: [
'array',
'backtracking',
'binary-indexed-tree',
'binary-search',
'binary-search-tree',
'bit-manipulation',
'brainteaser',
'breadth-first-search',
'depth-first-search',
'design',
'divide-and-conquer',
'dynamic-programming',
'geometry',
'graph',
'greedy',
'hash-table',
'heap',
'line-sweep',
'linked-list',
'math',
'memoization',
'minimax',
'ordered-map',
'queue',
'random',
'recursion',
'rejection-sampling',
'reservoir-sampling',
'segment-tree',
'sliding-window',
'sort',
'stack',
'string',
'topological-sort',
'tree',
'trie',
'two-pointers',
'union-find',
// TODO: these two tags below are included on leetcode.com but not on leetcode-cn.com
// Currently comment out for simplicity
// 'rolling-hash',
// 'suffix-array',
],
urls: {
// base urls
base: 'https://leetcode.com',
graphql: 'https://leetcode.com/graphql',
login: 'https://leetcode.com/accounts/login/',
// third part login base urls. TODO facebook google
github_login: 'https://leetcode.com/accounts/github/login/?next=%2F',
facebook_login: 'https://leetcode.com/accounts/facebook/login/?next=%2F',
linkedin_login: 'https://leetcode.com/accounts/linkedin_oauth2/login/?next=%2F',
// redirect urls
leetcode_redirect: 'https://leetcode.com/',
github_tf_redirect: 'https://github.com/sessions/two-factor',
// simulate login urls
github_login_request: 'https://github.com/login',
github_session_request: 'https://github.com/session',
github_tf_session_request: 'https://github.com/sessions/two-factor',
linkedin_login_request: 'https://www.linkedin.com/login',
linkedin_session_request: 'https://www.linkedin.com/checkpoint/lg/login-submit',
// questions urls
tag: 'https://leetcode.com/tag/$tag/',
problems: 'https://leetcode.com/api/problems/$category/',
problem: 'https://leetcode.com/problems/$slug/description/',
test: 'https://leetcode.com/problems/$slug/interpret_solution/',
session: 'https://leetcode.com/session/',
submit: 'https://leetcode.com/problems/$slug/submit/',
submissions: 'https://leetcode.com/api/submissions/$slug',
submission: 'https://leetcode.com/submissions/detail/$id/',
verify: 'https://leetcode.com/submissions/detail/$id/check/',
favorites: 'https://leetcode.com/list/api/questions',
favorite_delete: 'https://leetcode.com/list/api/questions/$hash/$id',
plugin: 'https://raw.githubusercontent.com/leetcode-tools/leetcode-cli/master/lib/plugins/$name.js'
},
},
// but you will want change these
autologin: {
enable: false,
retry: 2
},
code: {
editor: 'vim',
lang: 'cpp'
},
file: {
show: '${fid}.${slug}',
submission: '${fid}.${slug}.${sid}.${ac}'
},
color: {
enable: true,
theme: 'default'
},
icon: {
theme: ''
},
network: {
concurrency: 10,
delay: 1
},
plugins: {}
};
function Config() {}
Config.prototype.init = function() {
nconf.file('local', file.configFile())
.add('global', {type: 'literal', store: DEFAULT_CONFIG})
.defaults({});
const cfg = nconf.get();
nconf.remove('local');
nconf.remove('global');
// HACK: remove old style configs
for (const x in cfg) {
if (x === x.toUpperCase()) delete cfg[x];
}
delete DEFAULT_CONFIG.type;
delete cfg.type;
_.extendOwn(this, cfg);
};
Config.prototype.getAll = function(useronly) {
const cfg = _.extendOwn({}, this);
if (useronly) delete cfg.sys;
return cfg;
};
module.exports = new Config();