-
Notifications
You must be signed in to change notification settings - Fork 1
/
deleteAllRepo.js
42 lines (39 loc) · 1.25 KB
/
deleteAllRepo.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
const https = require('https')
const accessToken = ''
const req = https.request({
hostname: 'gitee.com',
path: `/api/v5/user/repos?sort=full_name&page=1&per_page=1&access_token=${accessToken}`,
method: 'GET',
}, res => {
console.log(`列出授权用户的所有仓库 statusCode: ${res.statusCode}`)
let data = ''
res.on('data', chunk => {
data += chunk
})
res.on('end', () => {
const list = JSON.parse(data)
console.log('仓库数: ',list.length)
list.forEach((item) => {
const reqDel = https.request({
hostname: 'gitee.com',
path: `/api/v5/repos/${item.project_creator}/${item.path}?access_token=${accessToken}`,
method: 'DELETE',
}, res => {
console.log(`删除 statusCode: ${res.statusCode}`)
let data = ''
res.on('data', chunk => {
data += chunk
})
res.on('end', () => {
try {
// console.log(JSON.parse(data))
} catch (e) {
console.log(e)
}
})
})
reqDel.end()
})
})
})
req.end()