-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.cjs
169 lines (148 loc) · 5.84 KB
/
start.cjs
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
#!/usr/bin/env node
const argv = require('yargs').argv;
const chalk = require('chalk');
// const spinner = require('./libs/commons/spinner');
const { strPaddingLength, strPaddingStr } = require('./libs/vars.cjs');
const isKC2Transition = true;
// const logWIP = str => console.log('\x1b[31m' + '× \x1b[91m[WIP] \x1b[0m' + str);
const run = async () => {
let isOnlyDownload = false;
let isDist = false;
let isDistHash = false;
const argvs = Array.isArray(argv._)
? argv._.filter((arg) => {
if (arg === 'only-download') {
isOnlyDownload = true;
return false;
}
if (arg === 'dist') {
isDist = true;
return false;
}
if (arg === 'dist-hash') {
isDistHash = true;
return false;
}
return true;
})
: [];
console.log(''.padEnd(strPaddingLength, strPaddingStr));
console.log('');
console.log(chalk.cyanBright('Ooyodo'));
console.log('');
await (async () => {
if (isDist) {
await require('./steps/dist/index.cjs')();
return;
}
const token = await require('./steps/get-token.cjs')(argvs);
await require('./steps/ensure-directories.cjs')();
await require('./steps/fetch-api-start2.cjs')(token);
// if (!isOnlyDownload) {
await require('./steps/prepare-repositories.cjs')();
// }
if (isDistHash) {
console.log(' ');
await require('./steps/dist-hash.cjs')();
return;
}
const versionsShipsOld =
await require('./steps/get-versions-ships.cjs')();
await require('./steps/download-pics-ships.cjs')();
await require('./steps/download-pics-equipments.cjs')();
if (!token) {
await require('./steps/initialize-database.cjs')();
await require('./steps/select-pics-ships.cjs')(versionsShipsOld);
if (!isOnlyDownload) {
if (isKC2Transition) {
await require('./steps/kc2-transition.cjs')();
}
}
}
return;
})();
console.log('');
console.log(chalk.greenBright('完成'));
console.log('');
console.log(''.padEnd(strPaddingLength, strPaddingStr));
return;
/************************************************
* 查找新的装备图片
***********************************************/
// {
// const step = '查找新的装备图片';
// const waiting = spinner(step);
// const run = require('./libs/select-pics/equipments');
// await run(newpics)
// .then(newlist => {
// if (Array.isArray(newlist) && newlist.length) {
// waiting.finish();
// newpics = newpics.concat(newlist);
// console.log(
// newlist
// .map(obj => {
// let msg =
// ' \x1b[92m' +
// '✦ NEW!✦ ' +
// '\x1b[0m' +
// (obj.id + '').padStart(3, ' ') +
// ' - ';
// if (obj.equipment === true) {
// msg += '新装备';
// } else if (typeof obj.equipment === 'string') {
// msg += obj.equipment;
// }
// return msg;
// })
// .join('\n')
// );
// } else {
// waiting.finish(step + ': 无新图');
// }
// })
// .catch(err => waiting.fail(step + '\n ' + (err.message || err)));
// }
/************************************************
* 复制新的图片
***********************************************/
// if (Array.isArray(newpics) && newpics.length) {
// // logWIP('复制新的图片')
// const step = '复制新的图片';
// const waiting = spinner(step);
// const run = require('./libs/commons/copy-selected-pics');
// await run(newpics)
// .then(() => waiting.finish())
// .catch(err => waiting.fail(step + '\n ' + (err.message || err)));
// }
/************************************************
* 操作pics代码库
***********************************************/
// if (Array.isArray(newpics) && newpics.length) {
// // logWIP('操作pics代码库')
// const step = '操作pics代码库';
// const waiting = spinner(step);
// const run = require('./libs/commons/process-repo-pics');
// await run(newpics)
// .then(() => waiting.finish())
// .catch(err => waiting.fail(step + '\n ' + (err.message || err)));
// }
/************************************************
* 复制处理完毕的新图片
***********************************************/
// if (Array.isArray(newpics) && newpics.length) {
// // logWIP('复制新的图片')
// const step = '复制处理完毕的新图片';
// const waiting = spinner(step);
// const run = require('./libs/commons/copy-selected-pics-post');
// await run(newpics)
// .then(() => waiting.finish())
// .catch(err => waiting.fail(step + '\n ' + (err.message || err)));
// }
/************************************************
* 更新database
***********************************************/
// {
// logWIP('更新database');
// }
};
run();