-
Notifications
You must be signed in to change notification settings - Fork 0
/
airtable.js
47 lines (35 loc) · 1.5 KB
/
airtable.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
const {Command, flags} = require('@oclif/command'),
ora = require('ora'),
{read, addAirtable} = require("../../lib/json_utility"),
{promptUser} = require("../../lib/prompt");
class InitAirtable extends Command {
async run() {
let spinner = await ora(),
{flags} = this.parse(InitAirtable),
name = flags.name || false;
try{
const profiles = await read(),
found = await profiles.find(p => p.profileName == name);
if(!found)
throw Error(`Cann't add "Airtable" credetial. Must have to add "YouTube" credential first as follow
"ytb init:profile --name ${name}" and then
"ytb init:airtable --name ${name}"`);
const api_key = await promptUser(`AIRTABLE API KEY : `, true, `"API KEY" cannot empty`),
base_id = await promptUser(`AIRTABLE BASE ID : `, true, `"BASE ID" cannot empty`),
table_name = await promptUser(`AIRTABLE TABLE NAME : `, true, `"TABLE NAME" cannot empty`);
await addAirtable(name, api_key, base_id, table_name);
spinner.succeed(`Airtable configured to profile "${name}"`);
}catch(err){
spinner.fail(`Error : ${err.message}`);
}
}
}
InitAirtable.description = `Update profile with Airtable credential`;
InitAirtable.flags = {
name: flags.string(
{
char: 'n',
description: 'name of the profile'
})
}
module.exports = InitAirtable