forked from icgc-argo/argo-dictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.js
50 lines (44 loc) · 1.23 KB
/
compile.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
const inquirer = require('inquirer');
const chalk = require('chalk');
const fs = require('fs');
const whitespace = 4;
const defaultName = 'ICGC-ARGO Data Dictionary';
const defaultVersion = '0.0';
const schemas = require('./schemas');
const references = require('./references');
async function promptName(versions) {
console.log('\n');
return new Promise(resolve =>
inquirer
.prompt([
{
message: `Dictionary Name [${chalk.yellow(defaultName)}]:`,
name: 'name',
type: 'string',
},
])
.then(answers => resolve(answers.name || defaultName)),
);
}
async function promptVersion(versions) {
console.log('\n');
return new Promise(resolve =>
inquirer
.prompt([
{
message: `Dictionary Version [${chalk.yellow(defaultVersion)}]:`,
name: 'version',
type: 'string',
},
])
.then(answers => resolve(answers.version || defaultVersion)),
);
}
async function run() {
const name = await promptName();
const version = await promptVersion();
const dictionary = { name, version, references, schemas };
fs.writeFileSync('./dictionary.json', JSON.stringify(dictionary,null,whitespace));
console.log(dictionary);
}
run();