-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (71 loc) · 2.31 KB
/
index.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
78
import 'babel-core/register';
import 'babel-polyfill';
import * as Sentry from '@sentry/node';
import { start } from './start';
import { runTests } from './tests/RunTests';
import { startStatsGeneration } from './StatsGeneration';
import { runMigration } from './migration1/Migration1';
import {
devMode,
performingMigration062019, performingMigration062119,
performingMigration0621192,
performingMigration1,
performingMigration2,
regenTestDBMode,
} from './constants';
import { runMigration2 } from './migration2/Migration2';
import { addMatchCounts } from './migration062119-2/Migration062119-2';
import { addProfileCompletedTime } from './migration062119/AddProfileCompletedTime';
import { addNotificationsEnabled } from './migrations-small/AddNotificationsEnabled';
const debug = require('debug')('dev:Index');
const testsLog = require('debug')('tests:Index');
const errorLog = require('debug')('error:Index');
const fs = require('fs').promises;
const init = async () => {
debug('Starting...');
testsLog('Starting...');
if (!devMode) {
const release = await fs
.readFile('./release')
.then(buf => (buf.toString()))
.catch((err) => {
debug(`error occurred getting release number: ${err}`);
return undefined;
});
Sentry.init({
dsn: 'https://[email protected]/1444442',
release,
});
debug('sentry initialized');
}
if (regenTestDBMode) {
if (process.env.DB_NAME === 'prod2') {
errorLog('ERROR: CAN\'T REGENDB PROD DATABASE');
} else {
testsLog('Prepared to run tests in 3 second');
setTimeout(async () => {
testsLog('Running Tests');
await runTests();
}, 3000);
}
} else if (process.env.TASK === 'stats-generation') {
debug('starting stats generation');
startStatsGeneration();
} else if (performingMigration1) {
debug('performing migration 1');
runMigration();
} else if (performingMigration2) {
debug('performing migration 2');
runMigration2();
} else if (performingMigration062019) {
debug('performing migratin 06-20-19');
addNotificationsEnabled();
} else if (!process.env.TASK) {
start();
} else if (performingMigration0621192) {
addMatchCounts();
} else if (performingMigration062119) {
addProfileCompletedTime();
}
};
init();