@@ -8,7 +8,7 @@ import { readConfig, readConfigSync, writeConfigSync } from "#core/config";
88import env from "#core/env" ;
99import File from "#core/file" ;
1010import FileTree from "#core/file-tree" ;
11- import { chmodSync , pathExists , pathExistsSync } from "#core/fs" ;
11+ import { chmodSync , pathExists , pathExistsSync , rm } from "#core/fs" ;
1212import { glob , globSync } from "#core/glob" ;
1313import GlobPatterns from "#core/glob/patterns" ;
1414import Locale from "#core/locale" ;
@@ -1369,6 +1369,7 @@ export default class Package {
13691369
13701370 var filename ,
13711371 config ,
1372+ registries = new Map ( ) ,
13721373 updates = new Map ( ) ;
13731374
13741375 if ( await pathExists ( this . root + "/.github/dependabot.yaml" ) ) {
@@ -1386,6 +1387,10 @@ export default class Package {
13861387 }
13871388
13881389 if ( config ) {
1390+ for ( const registry in config . registries ) {
1391+ registries . set ( registry , config . registries [ registry ] ) ;
1392+ }
1393+
13891394 for ( const update of config . updates || [ ] ) {
13901395 if ( update [ "package-ecosystem" ] === "npm" ) continue ;
13911396
@@ -1412,6 +1417,7 @@ export default class Package {
14121417 if ( directories . size ) {
14131418 updates . set ( "npm" , {
14141419 "package-ecosystem" : "npm" ,
1420+ "registries" : "*" ,
14151421 "directories" : [ ...directories ] . sort ( ) ,
14161422 "schedule" : {
14171423 "interval" : this . cliConfig . meta . dependabot . npm . interval ,
@@ -1421,13 +1427,20 @@ export default class Package {
14211427 } ,
14221428 "open-pull-requests-limit" : this . cliConfig . meta . dependabot . npm [ "open-pull-requests-limit" ] ,
14231429 } ) ;
1430+
1431+ registries . set ( "npm.pkg.github.com" , {
1432+ "type" : "npm-registry" ,
1433+ "url" : "https://npm.pkg.github.com" ,
1434+ "token" : "${{secrets.DEPENDABOT_GITHUB_TOKEN}}" ,
1435+ } ) ;
14241436 }
14251437 }
14261438
14271439 // docker
14281440 if ( this . cliConfig ?. meta . dependabot . docker ?. enabled && this . hasDockerfile ) {
14291441 updates . set ( "docker" , {
14301442 "package-ecosystem" : "docker" ,
1443+ "registries" : "*" ,
14311444 "directories" : [ "/" ] ,
14321445 "schedule" : {
14331446 "interval" : this . cliConfig . meta . dependabot . docker . interval ,
@@ -1437,6 +1450,13 @@ export default class Package {
14371450 } ,
14381451 "open-pull-requests-limit" : this . cliConfig . meta . dependabot . docker [ "open-pull-requests-limit" ] ,
14391452 } ) ;
1453+
1454+ registries . set ( "ghcr.io" , {
1455+ "type" : "docker-registry" ,
1456+ "url" : "ghcr.io" ,
1457+ "username" : "${{github.repository_owner}}" ,
1458+ "password" : "${{secrets.DEPENDABOT_GITHUB_TOKEN}}" ,
1459+ } ) ;
14401460 }
14411461
14421462 // github-actions
@@ -1474,30 +1494,38 @@ export default class Package {
14741494 }
14751495 }
14761496
1497+ // dependabot is not configured
14771498 if ( ! updates . size ) {
14781499 if ( await pathExists ( this . root + "/.github" ) ) {
1500+
1501+ // remove dependabot config
14791502 await fs . promises . rm ( this . root + "/.github/" + filename , {
14801503 "force" : true ,
14811504 } ) ;
14821505
1483- const files = await fs . promises . readdir ( this . root + "/.github" ) ;
1484-
1485- if ( ! files . length ) {
1486- await fs . promises . rm ( this . root + "/.github" , {
1487- "recursive" : true ,
1488- } ) ;
1489- }
1506+ // remove empty ".github" directory
1507+ await rm ( this . root + "/.github" , {
1508+ "ifDirectoryEmpty" : true ,
1509+ "recursive" : true ,
1510+ } ) ;
14901511 }
14911512
14921513 return result ( 200 ) ;
14931514 }
14941515
14951516 config = {
14961517 "version" : 2 ,
1497- "updates" : [ ] ,
14981518 } ;
14991519
1520+ for ( const registry of [ ...registries . keys ( ) ] . sort ( ) ) {
1521+ config . registries ??= { } ;
1522+
1523+ config . registries [ registry ] = registries . get ( registry ) ;
1524+ }
1525+
15001526 for ( const update of [ ...updates . keys ( ) ] . sort ( ) ) {
1527+ config . updates ??= [ ] ;
1528+
15011529 config . updates . push ( updates . get ( update ) ) ;
15021530 }
15031531
0 commit comments