@@ -3,33 +3,31 @@ const enableAutomatedSecurityFixes = ({ github, settings, enabled }) => {
33 return Promise . resolve ( )
44 }
55
6- const args = {
6+ const verb = enabled ? 'PUT' : 'DELETE'
7+
8+ return github . request ( `${ verb } /repos/{owner}/{repo}/automated-security-fixes` , {
79 owner : settings . owner ,
810 repo : settings . repo ,
911 mediaType : {
1012 previews : [ 'london' ]
1113 }
12- }
13- const methodName = enabled ? 'enableAutomatedSecurityFixes' : 'disableAutomatedSecurityFixes'
14-
15- return github . repos [ methodName ] ( args )
14+ } )
1615}
1716
1817const enableVulnerabilityAlerts = ( { github, settings, enabled } ) => {
1918 if ( enabled === undefined ) {
2019 return Promise . resolve ( )
2120 }
2221
23- const args = {
22+ const verb = enabled ? 'PUT' : 'DELETE'
23+
24+ return github . request ( `${ verb } /repos/{owner}/{repo}/vulnerability-alerts` , {
2425 owner : settings . owner ,
2526 repo : settings . repo ,
2627 mediaType : {
2728 previews : [ 'dorian' ]
2829 }
29- }
30- const methodName = enabled ? 'enableVulnerabilityAlerts' : 'disableVulnerabilityAlerts'
31-
32- return github . repos [ methodName ] ( args )
30+ } )
3331}
3432
3533export default class Repository {
@@ -46,23 +44,23 @@ export default class Repository {
4644 delete this . settings . enable_automated_security_fixes
4745 }
4846
49- sync ( ) {
47+ async sync ( ) {
5048 this . settings . name = this . settings . name || this . settings . repo
51- return this . github . repos
52- . update ( this . settings )
53- . then ( ( ) => {
54- if ( this . topics ) {
55- return this . github . repos . replaceAllTopics ( {
56- owner : this . settings . owner ,
57- repo : this . settings . repo ,
58- names : this . topics . split ( / \s * , \s * / ) ,
59- mediaType : {
60- previews : [ 'mercy' ]
61- }
62- } )
49+
50+ await this . github . request ( 'PATCH /repos/{owner}/{repo}' , this . settings )
51+
52+ if ( this . topics ) {
53+ await this . github . request ( 'PUT /repos/{owner}/{repo}/topics' , {
54+ owner : this . settings . owner ,
55+ repo : this . settings . repo ,
56+ names : this . topics . split ( / \s * , \s * / ) ,
57+ mediaType : {
58+ previews : [ 'mercy' ]
6359 }
6460 } )
65- . then ( ( ) => enableVulnerabilityAlerts ( { enabled : this . enableVulnerabilityAlerts , ...this } ) )
66- . then ( ( ) => enableAutomatedSecurityFixes ( { enabled : this . enableAutomatedSecurityFixes , ...this } ) )
61+ }
62+
63+ await enableVulnerabilityAlerts ( { enabled : this . enableVulnerabilityAlerts , ...this } )
64+ await enableAutomatedSecurityFixes ( { enabled : this . enableAutomatedSecurityFixes , ...this } )
6765 }
6866}
0 commit comments