Last active
May 24, 2024 10:38
-
-
Save aniruddha-adhikary/4675513edf9b397d8060e0dcdfa8a39b to your computer and use it in GitHub Desktop.
Bulk Archive Completed tickets in Linear.app
This file contains hidden or 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
import {LinearClient} from '@linear/sdk' | |
if (!process.env.LINEAR_API_KEY) { | |
throw new Error('Linear API key is required, set LINEAR_API_KEY environment variable') | |
} | |
const client = new LinearClient({ | |
apiKey: process.env.LINEAR_API_KEY | |
}) | |
async function getClosedIssues() { | |
return await client.issues({ | |
first: 50, | |
filter: { | |
state: { | |
name: { | |
in: ["Done", "Canceled", "Duplicate"] | |
} | |
}, | |
} | |
}); | |
} | |
async function archiveClosedIssues() { | |
let issuesResponse = await getClosedIssues(); | |
while (issuesResponse.pageInfo.hasNextPage) { | |
const archiveRequests = issuesResponse.nodes.map(issue => { | |
client.archiveIssue(issue.id); | |
console.log("Archive request for issue ", issue.id); | |
}); | |
await Promise.all(archiveRequests); | |
issuesResponse = await issuesResponse.fetchNext() | |
} | |
} | |
archiveClosedIssues().then(() => console.log("Done")).catch(console.error) |
This file contains hidden or 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
{ | |
"name": "linear-auto-archive", | |
"version": "1.0.0", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "ts-node linear-auto-archive.ts" | |
}, | |
"keywords": [], | |
"author": "Aniruddha Adhikary", | |
"license": "MIT", | |
"description": "", | |
"devDependencies": { | |
"@types/node": "^20.11.0", | |
"ts-node": "^10.9.2", | |
"typescript": "^5.4.5" | |
}, | |
"dependencies": { | |
"@linear/sdk": "^21.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment