-
Notifications
You must be signed in to change notification settings - Fork 4
/
.bannerfile.js
59 lines (55 loc) · 2.22 KB
/
.bannerfile.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
const { exec } = require('child_process')
exports = {
actions: {
publish: function () {
console.log('this state:', this.Reader)
const publish = (type, notif) => {
console.log('gonna publish a new version', type, 'for this project')
exec(`apm publish ${type}`, {
cwd: this.Reader.projectPath
}, (err, stdout, stderr) => {
console.log('execution result:', stdout)
})
notif.dismiss()
}
const types = {major: 'Major', minor: 'Minor', patch: 'Patch'}
const ask = (type, notif) => {
const big = types[type]
if (!big) throw new Error('Unknown publish type')
const confirm = atom.notifications.addWarning(`Publish ${big}`, {
description: `Are you sure you want to publish a "${type}" update for Project Banner at this time?\nPlease make sure that the directory is clean and there are no unstaged files before proceeding.`,
dismissable: true,
buttons: [
{text: 'Cancel', onDidClick: () => confirm.dismiss(), className: 'btn btn-primary'},
{text: 'Upgrade and Publish', onDidClick: () => publish(type, confirm), className: 'btn btn-success'},
]
})
notif.dismiss()
}
const major = notif => ask('major', notif)
const minor = notif => ask('minor', notif)
const patch = notif => ask('patch', notif)
const cancel = () => { notification.dismiss() }
const notification = atom.notifications.addInfo('Publish Version', {
description: 'You want to publish a version?',
dismissable: true,
buttons: [
{text: 'Cancel', onDidClick: cancel, className: 'btn btn-lg btn-primary btn-block'},
{text: 'Patch', onDidClick: () => patch(notification), className: 'btn btn-sm'},
{text: 'Minor', onDidClick: () => minor(notification), className: 'btn btn-sm'},
{text: 'Major', onDidClick: () => major(notification), className: 'btn btn-xs'},
]
})
},
doSomething: function () {
console.log('what is this?', this)
this.projectBanner.doUpdate()
}
},
content: {
projectFlag: function () {
console.log('what is this?', this)
return Date.now()
}
}
}