-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add create + delete milestone commands
- Loading branch information
Showing
5 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const ProgressBar = require('progress'); | ||
const colors = require('colors'); | ||
const auth = require('../../auth'); | ||
const log = require('../../log'); | ||
|
||
module.exports.command = 'create [milestone]'; | ||
|
||
module.exports.describe = 'Create a new milestone in multiple repositories'; | ||
|
||
module.exports.builder = { | ||
description: { | ||
type: 'string', | ||
describe: 'description of the milestone' | ||
}, | ||
due: { | ||
alias: 'd', | ||
type: 'string', | ||
describe: 'milestone\'s due date. format: YYYY-MM-DD' | ||
} | ||
}; | ||
|
||
module.exports.handler = async function(argv) { | ||
const { github, repos } = await auth.init(); | ||
|
||
log.info(`Creating milestones...`); | ||
const progress = new ProgressBar(':current/:total [:bar]', { total: repos.length }); | ||
for (let repo of repos) { | ||
await github.issues.createMilestone({ | ||
owner: repo.owner, | ||
repo: repo.name, | ||
title: argv.milestone, | ||
description: argv.description, | ||
due_on: argv.due || getDefaultDue() | ||
}); | ||
progress.tick(); | ||
} | ||
|
||
log.success(`Done.`); | ||
}; | ||
|
||
function getDefaultDue() { | ||
var now = new Date(); | ||
now.setDate(now.getDate() + 14); | ||
return now.toISOString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const ProgressBar = require('progress'); | ||
const auth = require('../../auth'); | ||
const log = require('../../log'); | ||
|
||
module.exports.command = 'delete [milestone]'; | ||
|
||
module.exports.describe = 'Permanently delete a milestone a milestone (see `close` to update milestone status)'; | ||
|
||
module.exports.handler = async function(argv) { | ||
const { github, repos, hydrateMilestones, filterMilestones } = await auth.init(); | ||
await hydrateMilestones(repos, 'all'); | ||
const milestones = await filterMilestones(repos, argv.milestone); | ||
if (!milestones.length) return; | ||
|
||
log.info(`Deleting milestones...`); | ||
const progress = new ProgressBar(':current/:total [:bar]', { total: milestones.length }); | ||
|
||
for (let milestone of milestones) { | ||
await github.issues.deleteMilestone({ | ||
owner: milestone.repo.owner, | ||
repo: milestone.repo.name, | ||
number: milestone.number | ||
}); | ||
progress.tick(); | ||
} | ||
|
||
log.success(`Done.`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
module.exports = yargs => { | ||
return yargs | ||
.command(require('./list')) | ||
.command(require('./close')) | ||
.command(require('./create')) | ||
.command(require('./delete')) | ||
.command(require('./list')) | ||
.command(require('./open')) | ||
.command(require('./update')); | ||
}; |