Skip to content

Commit a134803

Browse files
committed
fix: fix dependabot generator
1 parent 7660610 commit a134803

1 file changed

Lines changed: 54 additions & 49 deletions

File tree

lib/package.js

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,6 @@ export default class Package {
13691369
} );
13701370
}
13711371

1372-
// XXX
13731372
async #updateDependabotConfig () {
13741373
const upstream = this.git.upstream;
13751374

@@ -1423,26 +1422,28 @@ export default class Package {
14231422
}
14241423

14251424
if ( directories.size ) {
1425+
const schedule = {
1426+
"interval": this.cliConfig.meta.dependabot.npm.interval,
1427+
};
1428+
1429+
if ( schedule.interval === "cron" ) {
1430+
schedule.cronjob = this.cliConfig.meta.dependabot.npm.cronjob;
1431+
}
1432+
else {
1433+
schedule.day = this.cliConfig.meta.dependabot.npm.day?.toLowerCase();
1434+
1435+
if ( this.cliConfig.meta.dependabot.npm.time ) {
1436+
schedule.time = new Locale().formatDate( Temporal.PlainTime.from( this.cliConfig.meta.dependabot.npm.time ), "timeStyle:short" );
1437+
}
1438+
}
1439+
1440+
schedule.timezone = this.cliConfig.meta.dependabot.npm.timezone;
1441+
14261442
updates.set( "npm", {
14271443
"package-ecosystem": "npm",
14281444
"registries": "*",
14291445
"directories": [ ...directories ].sort(),
1430-
"schedule": {
1431-
"interval": this.cliConfig.meta.dependabot.npm.interval,
1432-
...( this.cliConfig.meta.dependabot.npm.interval === "cron"
1433-
? {
1434-
"cronjob": this.cliConfig.meta.dependabot.npm.cronjob,
1435-
}
1436-
: {
1437-
"day": this.cliConfig.meta.dependabot.npm.day
1438-
? this.cliConfig.meta.dependabot.npm.day.toLowerCase()
1439-
: undefined,
1440-
"time": this.cliConfig.meta.dependabot.npm.time
1441-
? new Locale().formatDate( Temporal.PlainTime.from( this.cliConfig.meta.dependabot.npm.time ), "timeStyle:short" )
1442-
: undefined,
1443-
} ),
1444-
"timezone": this.cliConfig.meta.dependabot.npm.timezone,
1445-
},
1446+
schedule,
14461447
"open-pull-requests-limit": this.cliConfig.meta.dependabot.npm[ "open-pull-requests-limit" ],
14471448
} );
14481449

@@ -1456,26 +1457,28 @@ export default class Package {
14561457

14571458
// docker
14581459
if ( this.cliConfig?.meta.dependabot.docker?.enabled && this.hasDockerfile ) {
1460+
const schedule = {
1461+
"interval": this.cliConfig.meta.dependabot.docker.interval,
1462+
};
1463+
1464+
if ( schedule.interval === "cron" ) {
1465+
schedule.cronjob = this.cliConfig.meta.dependabot.docker.cronjob;
1466+
}
1467+
else {
1468+
schedule.day = this.cliConfig.meta.dependabot.docker.day?.toLowerCase();
1469+
1470+
if ( this.cliConfig.meta.dependabot.docker.time ) {
1471+
schedule.time = new Locale().formatDate( Temporal.PlainTime.from( this.cliConfig.meta.dependabot.docker.time ), "timeStyle:short" );
1472+
}
1473+
}
1474+
1475+
schedule.timezone = this.cliConfig.meta.dependabot.docker.timezone;
1476+
14591477
updates.set( "docker", {
14601478
"package-ecosystem": "docker",
14611479
"registries": "*",
14621480
"directories": [ "/" ],
1463-
"schedule": {
1464-
"interval": this.cliConfig.meta.dependabot.docker.interval,
1465-
...( this.cliConfig.meta.dependabot.docker.interval === "cron"
1466-
? {
1467-
"cronjob": this.cliConfig.meta.dependabot.docker.cronjob,
1468-
}
1469-
: {
1470-
"day": this.cliConfig.meta.dependabot.docker.day
1471-
? this.cliConfig.meta.dependabot.docker.day.toLowerCase()
1472-
: undefined,
1473-
"time": this.cliConfig.meta.dependabot.docker.time
1474-
? new Locale().formatDate( Temporal.PlainTime.from( this.cliConfig.meta.dependabot.docker.time ), "timeStyle:short" )
1475-
: undefined,
1476-
} ),
1477-
"timezone": this.cliConfig.meta.dependabot.docker.timezone,
1478-
},
1481+
schedule,
14791482
"open-pull-requests-limit": this.cliConfig.meta.dependabot.docker[ "open-pull-requests-limit" ],
14801483
} );
14811484

@@ -1508,25 +1511,27 @@ export default class Package {
15081511
}
15091512

15101513
if ( directories.size ) {
1514+
const schedule = {
1515+
"interval": this.cliConfig.meta.dependabot[ "github-actions" ].interval,
1516+
};
1517+
1518+
if ( schedule.interval === "cron" ) {
1519+
schedule.cronjob = this.cliConfig.meta.dependabot[ "github-actions" ].cronjob;
1520+
}
1521+
else {
1522+
schedule.day = this.cliConfig.meta.dependabot[ "github-actions" ].day?.toLowerCase();
1523+
1524+
if ( this.cliConfig.meta.dependabot[ "github-actions" ].time ) {
1525+
schedule.time = new Locale().formatDate( Temporal.PlainTime.from( this.cliConfig.meta.dependabot[ "github-actions" ].time ), "timeStyle:short" );
1526+
}
1527+
}
1528+
1529+
schedule.timezone = this.cliConfig.meta.dependabot[ "github-actions" ].timezone;
1530+
15111531
updates.set( "github-actions", {
15121532
"package-ecosystem": "github-actions",
15131533
"directories": [ ...directories ].sort(),
1514-
"schedule": {
1515-
"interval": this.cliConfig.meta.dependabot[ "github-actions" ].interval,
1516-
...( this.cliConfig.meta.dependabot[ "github-actions" ].interval === "cron"
1517-
? {
1518-
"cronjob": this.cliConfig.meta.dependabot[ "github-actions" ].cronjob,
1519-
}
1520-
: {
1521-
"day": this.cliConfig.meta.dependabot[ "github-actions" ].day
1522-
? this.cliConfig.meta.dependabot[ "github-actions" ].day.toLowerCase()
1523-
: undefined,
1524-
"time": this.cliConfig.meta.dependabot[ "github-actions" ].time
1525-
? new Locale().formatDate( Temporal.PlainTime.from( this.cliConfig.meta.dependabot[ "github-actions" ].time ), "timeStyle:short" )
1526-
: undefined,
1527-
} ),
1528-
"timezone": this.cliConfig.meta.dependabot[ "github-actions" ].timezone,
1529-
},
1534+
schedule,
15301535
"open-pull-requests-limit": this.cliConfig.meta.dependabot[ "github-actions" ][ "open-pull-requests-limit" ],
15311536
} );
15321537
}

0 commit comments

Comments
 (0)