-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
124 lines (106 loc) · 3.04 KB
/
app.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env node
import 'dotenv/config';
import inquirer from 'inquirer';
import { init } from './init.js';
import { choices } from './choices.js';
import { fullProcess } from './fullProcess.js';
import { parityCheck } from './parityCheck.js';
import {
singleBackup,
singleCleanSource,
singleVideoCompression,
} from './singleSteps.js';
global.globals = init();
// check if sourceisEmpty
if (globals.sourceIsEmpty) {
async function emptySourceQuestions() {
const answer = await inquirer.prompt({
type: 'list',
name: 'emptySourceQuestions',
message: 'What do want to do?',
choices: choices.emptySource,
});
return handleEmptySourceAnswers(answer.emptySourceQuestions);
}
await emptySourceQuestions();
} else {
async function mainQuestion() {
const answer = await inquirer.prompt({
type: 'list',
name: 'mainQuestion',
message: 'What do want to do?',
choices: choices.main,
});
return handleMainAnswers(answer.mainQuestion);
}
await mainQuestion();
}
async function singleSteps() {
const answer = await inquirer.prompt({
type: 'list',
name: 'singleSteps',
message: 'Which single step?',
choices: choices.single,
});
return handleSingleAnswers(answer.singleSteps);
}
async function handleMainAnswers(response) {
if (response === choices.main[0]) {
await fullProcess();
}
if (response === choices.main[1]) {
await singleSteps();
}
if (response === choices.main[2]) {
const missingCloudFiles = parityCheck();
if (missingCloudFiles.length > 0) {
console.log(
'Following files are missing in the cloud which are present in the target:'
);
console.table(missingCloudFiles);
console.log('Consider running video compression from menu');
} else {
console.log('No missing files');
}
}
}
async function handleSingleAnswers(response) {
if (response === choices.single[0]) {
await singleBackup();
}
if (response === choices.single[1]) {
const missingCloudFiles = parityCheck();
if (missingCloudFiles.length > 0) {
console.log(
'Following files are missing in the cloud which are present in the target:'
);
console.table(missingCloudFiles);
console.log('Consider running video compression from menu');
} else {
console.log('No missing files');
}
}
if (response === choices.single[2]) {
await singleVideoCompression();
}
if (response === choices.single[3]) {
await singleCleanSource();
}
}
async function handleEmptySourceAnswers(response) {
if (response === choices.emptySource[0]) {
const missingCloudFiles = parityCheck();
if (missingCloudFiles.length > 0) {
console.log(
'Following files are missing in the cloud which are present in the target:'
);
console.table(missingCloudFiles);
console.log('Consider running video compression from menu');
} else {
console.log('No missing files');
}
}
if (response === choices.emptySource[1]) {
await singleVideoCompression();
}
}