-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs
More file actions
executable file
·104 lines (90 loc) · 2.27 KB
/
Copy pathindex.mjs
File metadata and controls
executable file
·104 lines (90 loc) · 2.27 KB
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
#!/usr/bin/env node
const args = process.argv.slice(2);
import fs from 'fs/promises';
import { auth } from './auth.mjs';
import { vault, vaultCache } from './vault.mjs';
import { detail } from './detail.mjs';
import { manifest, manifestCache } from './manifest.mjs';
import { download } from './download.mjs';
import { archive } from './archive.mjs';
import { server } from './server.mjs';
import config from '../config.mjs';
export {
auth,
vault,
vaultCache,
detail,
manifest,
manifestCache,
download,
archive
};
async function mochi(args) {
switch (args[0]) {
case 'auth':
await auth();
break;
case 'vault':
await vault();
break;
case 'detail':
await detail();
break;
case 'manifest':
await manifest();
break;
case 'download':
await download(args[1]);
break;
case 'archive':
await archive(args[1]);
break;
case 'server':
await server();
break;
default:
help();
};
}
function help() {
const message = `
Usage:
mochi auth
Login and authorize your Epic Account.
mochi vault
Download current vault data and save to disk.
mochi manifest
Download manifest for all assets in vault library.
mochi download <identifier>
Download asset according to identifier.
Identifier can be:
- catalogItemId
- AppNameString
- Manifest file (with or without extension)
- "all" to download all assets available.
mochi archive <AppNameString>
Archive downloaded <AppNameString> asset to a ZIP file.
`;
console.log(message);
}
for (const d of [
'asset',
'archive',
'chunk',
'manifest',
'public',
'public/status',
'public/detail'
]) {
try {
await fs.access(`${config.DATA_DIR}/${d}`);
} catch (err) {
if (err.code === 'ENOENT') {
console.log(`Creating data directory at ${config.DATA_DIR}/${d}`);
await fs.mkdir(`${config.DATA_DIR}/${d}`, {recursive: true});
} else {
console.error(`Error accessing ${config.DATA_DIR}/${d}`);
}
}
}
await mochi(args);