-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
47 lines (38 loc) · 1.49 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
import dotenv from 'dotenv'
import figlet from 'figlet';
import gradient from 'gradient-string';
import inquirer, { Answers } from 'inquirer';
import { Subject, toArray } from 'rxjs';
import fs from 'fs'
import { funcs as fileService } from './fileService'
import { chunkFiles, getSuccessFiles } from './utils';
dotenv.config()
const rawdata = fs.readFileSync('locale.json');
const locales = JSON.parse(rawdata.toString()) as { "Language Culture Name": string, "Display Name": string, "Culture Code": string, "ISO 639x Value": string }[];
const successFileJson = getSuccessFiles()
var banner = figlet.textSync('Translate docs');
console.log(gradient.mind.multiline(banner));
const prompts = new Subject<Answers>();
inquirer
.prompt(prompts)
.ui.process.pipe(toArray())
.subscribe(async (answers) => {
const [fileInfo, localeInfo] = answers
const allFiles = fileService.getAllFiles(fileInfo.answer, []).filter(filePath => !successFileJson.includes(filePath))
// await chunkFiles(allFiles, fileInfo.answer, localeInfo.answer)
await chunkFiles([allFiles[0]], fileInfo.answer, localeInfo.answer)
});
prompts.next({
type: 'input',
name: 'Path',
default: "/docs",
message: 'What\'s the doc path?',
});
prompts.next({
type: 'rawlist',
name: 'Locale',
message: 'What\'s the language you want?',
choices: locales.map(locale => ({ name: `${locale['Display Name']} (${locale['Language Culture Name']})`, value: locale['Language Culture Name']})),
default: 29
});
prompts.complete();