-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinit.js
106 lines (98 loc) · 2.74 KB
/
init.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const fs = require('fs-extra')
const configContents = `
module.exports = {
source: {
/**
* URL for the API endpoint of your source github. Do not include a trailing /
*/
baseUrl: 'https://api.github.com/repos',
/**
* Org or Username of your source github
*/
org: '',
/**
* Repo field of your source github
*/
repo: '',
/**
* Optional token to access your source github. If you have GHE, you may not need to fill this in
*/
token: '',
/**
* URL for the API endpoint of your source github. Do not include a trailing /
*/
},
target: {
baseUrl: 'https://api.github.com/repos',
/**
* Org or Username of your target github
*/
org: '',
/**
* Repo field of your target github
*/
repo: '',
/**
* Optional token to access your target github. If you have GHE, you may not need to fill this in
*/
token: '',
/**
* Optional comment token. Comments only need read-only. If this is defined, this token will be used for comments, otherwise it will fall back to the general token
*/
commentToken: '',
/**
* Optional URL for user avatars when creating issues and comments. Requires 'id' config in 'users.json'
* @example
*/
avatarUrl: 'https://avatars0.githubusercontent.com/u/{id}?s=40&v=4',
},
/**
* This value will throttle scripts to prevent going over API limits
*/
apiCallsPerHour: 3000,
/**
* Optional
* BFG command to run: https://rtyley.github.io/bfg-repo-cleaner/
* This value will include just arguments.
* For example: '--strip-blobs-bigger-than 5M'
*/
bfg: '',
/**
* Optional
* If you are moving from Github Enterprise to github.com, you're images won't be viewable when migrated.
* If you have an s3 account, this will upload images to an s3 bucket (you have to make the bucket public)
**/
s3Bucket: '',
}
`
if (!fs.pathExistsSync('./config.js')) {
console.log('Creating a config')
fs.writeFileSync('./config.js', configContents)
}
if (!fs.pathExistsSync('./s3Config.json')) {
console.log('Creating an s3 config')
const s3Config = {
accessKeyId: '',
secretAccessKey: '',
region: 'us-east-1',
}
fs.writeFileSync('./s3Config.json', JSON.stringify(s3Config, null, ' '))
}
usersContent = `
module.exports = {
/**
* Username in source
*/
'username': {
/**
* Username in target
*/
target: 'new-user-name',
id: '', // ID for avatars. If you go the the profile of the user in the target repo, it will be something like 'https://avatars0.githubusercontent.com/u/{id}?s=140&v=4'
},
}
`
if (!fs.pathExistsSync('./users.js')) {
console.log('Creating a user map file')
fs.writeFileSync('./users.js', usersContent)
}