-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.ts
53 lines (46 loc) · 1.44 KB
/
main.ts
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
import { join } from 'node:path';
import { cancel, confirm, intro, isCancel, outro, select } from '@clack/prompts';
import { extract } from './scripts/extract';
import { patch } from './scripts/patch';
import { unpatch } from './scripts/unpatch';
import {
existsInDefaultPath,
getAppDirName,
isAppRunning,
isWindowsPlatform,
tidalPath,
waitForTimeout,
} from './utils';
const scripts = { patch, unpatch, extract };
async function main() {
intro('TIDAL Enhanced Patcher - https://github.com/nekusu/tidal-enhanced-patcher');
if (!isWindowsPlatform() || (await isAppRunning()) || !(await existsInDefaultPath())) return;
const appDirName = await getAppDirName();
if (!appDirName) return;
const appResourcesPath = join(tidalPath, appDirName, 'resources');
while (true) {
const script = await select({
message: 'What do you want to do?',
options: [
{ value: 'patch', label: 'Patch' },
{ value: 'unpatch', label: 'Unpatch' },
{
value: 'extract',
label: 'Extract source files',
hint: 'Run only if you know what you are doing',
},
],
});
if (isCancel(script)) {
cancel('Exiting...');
break;
}
await scripts[script as keyof typeof scripts](appResourcesPath);
if (await confirm({ message: 'Exit?' })) {
outro('✨ Thank you for using TIDAL Enhanced Patcher!');
await waitForTimeout(1000);
break;
}
}
}
main();