Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
iarna committed Jun 16, 2017
0 parents commit 0b0c629
Show file tree
Hide file tree
Showing 14 changed files with 2,345 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions ABANDONED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
We're closing this issue as it has gone thirty days without activity. In our experience if an issue has gone thirty days without any activity then it's unlikely to be addressed. In the case of bug reports, often the underlying issue will be addressed but finding related issues is quite difficult and often incomplete.

If this was a bug report and it is still relevant then we encourage you to open it again as a new issue. If this was a feature request then you should feel free to open it again, or even better open a PR.

For more information about our new issue aging policies and why we've instituted them please see our [blog post](http://blog.npmjs.org/post/161832149430/npm-the-npm-github-issue-tracker-and-you).
3 changes: 3 additions & 0 deletions OLD-PR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
We're closing this pull request as it has gone sixty days without activity. In our experience pull requests that go this long are unlikely to land. If you have updates to it, please feel free to open a new pull request.

For more information about our new issue aging policies and why we've instituted them please see our [blog post](http://blog.npmjs.org/post/161832149430/npm-the-npm-github-issue-tracker-and-you).
3 changes: 3 additions & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
We're closing this support issue as it has gone three days without activity. The npm CLI team itself does not provide support via this issue tracker, but we are happy when users help each other here. In our experience once a support issue goes dormant it's unlikely to get further activity. If you're still having problems, you may be better served by joining [package.community](https://package.community/) and asking your question there.

For more information about our new issue aging policies and why we've instituted them please see our [blog post](http://blog.npmjs.org/post/161832149430/npm-the-npm-github-issue-tracker-and-you).
5 changes: 5 additions & 0 deletions UNLABELED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
We're closing this issue as it has gone seven days without activity and without being labeled. If we haven't even labeled in issue in seven days then we're unlikely to ever read it.

If you are still experiencing the issue that led to you opening this or this is a feature request you're still interested in then we encourage you to open a new issue. If this was a support issue, you may be better served by joining [package.communty](https://package.community/) and asking your question there.

For more information about our new issue aging policies and why we've instituted them please see our [blog post](http://blog.npmjs.org/post/161832149430/npm-the-npm-github-issue-tracker-and-you).
21 changes: 21 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'
const onExit = require('signal-exit')
let exited = false

onExit(() => {
if (!exited) {
console.error('Abnormal exit: Promises not resolved')
process.exit(1)
}
})
module.exports = function (entry) {
setImmediate(() => {
entry(process.argv.slice(2)).then(() => {
exited = true
}, err => {
exited = true
console.error(err && err.stack ? err.stack : err)
process.exit(1)
})
})
}
48 changes: 48 additions & 0 deletions close-issues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict'
const fs = require('fs')
const { promisify } = require('util')
const readFile = promisify(fs.readFile)
const split = require('split')
const fun = require('funstream')
const github = require('./github.js')

function sleep (num) {
return new Promise((resolve) => {
setTimeout(resolve, num)
})
}

require('./app')(main)
async function main (args) {
if (args.length !== 2) {
console.error('close-issues <label> <messagefile> < issueids')
return
}
const [ label, messageFile ] = args
const message = await readFile(messageFile, 'utf8')

await fun(process.stdin).pipe(split()).filter(id => id !== '').map(id => Number(id)).forEach(async id => {
await github.issues.addLabels({
owner: 'npm',
repo: 'npm',
number: id,
labels: [ label ]
})
await sleep(500)
await github.issues.createComment({
owner: 'npm',
repo: 'npm',
number: id,
body: message
})
await sleep(1000)
await github.issues.edit({
owner: 'npm',
repo: 'npm',
number: id,
state: 'closed',
})
console.log(id)
await sleep(1500)
})
}
18 changes: 18 additions & 0 deletions github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'
const fs = require('fs')
const os = require('os')
const GitHubApi = require('github')
const Bluebird = require('bluebird')

const github = new GitHubApi({
headers: {
'user-agent': 'npm gh-issues manager/1.0.0 ([email protected]; https://github.com/npm/gh-issues)'
},
Promise: Bluebird,
timeout: 5000,
})
github.authenticate({
type: 'token',
token: fs.readFileSync(`${os.homedir()}/.gh-issues-token`, 'utf8').trim()
})
module.exports = github
41 changes: 41 additions & 0 deletions list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict'
const github = require('./github.js')
const fs = require('fs')
const issueList = fs.createWriteStream('issue-list.ndjson')
const prList = fs.createWriteStream('pr-list.ndjson')
require('./app.js')(main)

function closeStream (stream) {
stream.end()
return new Promise((resolve, reject) => {
stream.on('error', reject)
stream.on('close', resolve)
})
}

async function main () {
let res
do {
if (res) {
res = await github.getNextPage(res)
} else {
res = await github.issues.getForRepo({
owner: 'npm',
repo: 'npm',
state: 'open',
assignee: 'none',
milestone: 'none',
per_page: 100
})
}
const issues = res.data
issues.forEach(issue => {
if (issue.pull_request) {
prList.write(JSON.stringify(issue) + '\n')
} else {
issueList.write(JSON.stringify(issue) + '\n')
}
})
} while (github.hasNextPage(res))
await Promise.all([closeStream(prList), closeStream(issueList)])
}
25 changes: 25 additions & 0 deletions old-issues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'
const fs = require('fs')
const ndjson = require('ndjson')
const fun = require('funstream')
const moment = require('moment')
const Bluebird = require('bluebird')
require('./app')(main)

// don't let this filter close issues
const safeTags = [ 'support', 'npm5' ]

function moreThanDaysAgo (days, date) {
return moment(date).isBefore(moment().subtract(days, 'days'))
}

async function main () {
await fun(fs.createReadStream('issue-list.ndjson')).pipe(ndjson()).filter(issue => {
return moreThanDaysAgo(30, issue.updated_at)
}).filter(issue => {
const labels = issue.labels.map(issue => issue.name)
return labels.length && !labels.some(l => safeTags.some(t => t === l))
}).forEach(issue => {
console.log(issue.number)
})
}
Loading

0 comments on commit 0b0c629

Please sign in to comment.