This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.js
77 lines (64 loc) · 2.11 KB
/
main.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
#!/usr/bin/env node
import chalk from 'chalk';
import clear from 'clear';
import figlet from 'figlet';
import sample from '@feizheng/next-sample';
import AutoUpdate from 'cli-autoupdate';
import * as cli from './lib/cli.js';
import {execute} from './lib/command.js';
import {getPackageJson} from './lib/utils.js';
const packageJson = getPackageJson();
async function run() {
console.log(
chalk.yellow(
figlet.textSync('mtslack', {
font: sample(['Whimsy']),
horizontalLayout: 'default',
verticalLayout: 'default',
width: 80,
whitespaceBreak: true,
})
)
);
console.log(chalk.italic(`version ${packageJson.version} by @mallowigi`));
console.log(chalk.bold.red(`IMPORTANT UPDATE!!!!!`));
console.log('');
console.log(
`Since version 4.22.0 of Slack, it is no longer possible to apply custom tweaks, as they have patched the option to do so.`
);
console.log(
'However, you can still generate the custom code, that you can paste in Slack dev tools while in dev mode (see README).'
);
console.log('');
console.log('');
console.log(chalk.cyan('Welcome to the mtslack CLI!'));
console.log('');
// noinspection JSDeclarationsAtScopeStart
const {ask: answer} = await cli.ask();
await execute(answer);
}
// Start
async function main() {
clear();
await checkForUpdates();
}
async function checkForUpdates() {
// noinspection LocalVariableNamingConventionJS
let shouldUpdate = false;
const update = new AutoUpdate(packageJson);
console.log(chalk.bold('Checking for updates...'));
update.on('update', () => {
console.log(chalk.bold('A new update is available! Starting autoupdate...'));
shouldUpdate = true;
});
update.on('finish', async () => {
console.log(chalk.bold('Finished checking for updates!'));
if (shouldUpdate) {
console.log('Update finished. Please rerun the command.');
process.exit(0);
} else {
await run();
}
});
}
main();