forked from sshivaditya2019/chat_client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
executable file
·84 lines (72 loc) · 2.37 KB
/
index.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
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
#!/usr/bin/env ./node_modules/.bin/ts-node
import { program } from 'commander';
import cp from 'child_process';
import i18n from './packages/i18n/node.index';
function exec(commandStr: string) {
const [command, ...args] = commandStr.split(' ');
cp.execFileSync(command, args, { stdio: 'inherit' });
}
program
.command('getUserId <username>')
.description(i18n('getUserIdDescription'))
.action((username: string) => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts getUserId ${username}`,
);
});
program
.command('register <username> <password>')
.description(i18n('registerDescription'))
.action((username: string, password: string) => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts register ${username} ${password}`,
);
});
program
.command('deleteUser <userId>')
.description(i18n('deleteUserDescription'))
.action((userId: string) => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts deleteUser ${userId}`,
);
});
program
.command('fixUsersAvatar [searchValue] [replaceValue]')
.description(i18n('fixUsersAvatarDescription'))
.action((searchValue = '', replaceValue = '') => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts fixUsersAvatar ${searchValue} ${replaceValue}`,
);
});
program
.command('deleteTodayRegisteredUsers')
.description(i18n('deleteTodayRegisteredUsersDescription'))
.action(() => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts deleteTodayRegisteredUsers`,
);
});
program
.command('deleteMessages')
.description(i18n('deleteMessagesDescription'))
.action(() => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts deleteMessages`,
);
});
program
.command('updateDefaultGroupName <newName>')
.description(i18n('updateDefaultGroupNameDescription'))
.action((newName: string) => {
exec(
`npx ts-node --transpile-only packages/bin/index.ts updateDefaultGroupName ${newName}`,
);
});
program
.command('doctor')
.description(i18n('doctorDescription'))
.action(() => {
exec(`npx ts-node --transpile-only packages/bin/index.ts doctor`);
});
program.usage('[command]');
program.parse(process.argv);