-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·102 lines (82 loc) · 2.37 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env node
'use strict';
const Bucket = require('./src/bucket');
const program = require('commander');
const pkg = require('./package.json');
const apiKey = process.env.MANDRILL_API_KEY || '';
program
.version(pkg.version);
program
.command('list <dir>')
.description('list available migrations')
.action((dir) => {
const bucket = new Bucket(dir, apiKey);
const migrations = bucket.load();
migrations.forEach((migration) => {
console.log(migration.slug);
});
});
program
.command('generate <dir>')
.description('generate a new migration file from availables drafts on Mandrill')
.action((dir) => {
const bucket = new Bucket(dir, apiKey);
bucket.generate((error, templates) => {
if (error) {
return console.log(error.message);
}
console.log(templates);
});
});
program
.command('publish <name>')
.description('publish a single template')
.action((name) => {
const bucket = new Bucket(dir, apiKey);
bucket.publish(name, (error, templates) => {
if (error) {
return console.log(error.message);
}
console.log(templates);
});
});
program
.command('migrate <dir>')
.description('publish all templates on draft bucket')
.action((dir) => {
const bucket = new Bucket(dir, apiKey);
bucket.migrate((error, templates) => {
if (error) {
return console.log(error.message);
}
});
});
program
.command('drafts')
.description('list available drafts on Mandrill')
.action(() => {
const bucket = new Bucket('', apiKey);
bucket.drafts((error, drafts) => {
if (error) {
return console.log(error.message);
}
console.log(drafts);
});
});
program
.command('templates')
.description('list available templates on Mandrill')
.action(() => {
const bucket = new Bucket('', apiKey);
bucket.all((error, templates) => {
if (error) {
return console.log(error.message);
}
console.log(templates);
});
});
program
.parse(process.argv);
if (!program.args.length) {
program.help();
}