Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Apr 6, 2023
1 parent 3809558 commit 7c7a884
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/clients/packages.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createPackagesClient(input: Input): InstanceType<typeof GitHub>
onRateLimit: (retryAfter: number, options: RequestOptions) => {
warning(`Request quota exhausted for request ${options.method} ${options.url}`)

// Retry five times after hitting a rate limit error, then give up
// Retry five times after hitting a rate limit error, then give up.
if (options.request?.retryCount <= 5) {
info(`Retrying after ${retryAfter} seconds!`)
return true
Expand All @@ -28,14 +28,14 @@ export function createPackagesClient(input: Input): InstanceType<typeof GitHub>
onSecondaryRateLimit: (retryAfter: number, options: RequestOptions) => {
warning(`Request quota exhausted for request ${options.method} ${options.url}`)

// Retry five times after hitting a rate limit error, then give up
// Retry five times after hitting a rate limit error, then give up.
if (options.request?.retryCount <= 5) {
info(`Retrying after ${retryAfter} seconds!`)
return true
}
},
onAbuseLimit: (retryAfter: number, options: RequestOptions) => {
// does not retry, only logs a warning
// Do not retry, only log a warning.
warning(`Abuse detected for request ${options.method} ${options.url}`)
},
},
Expand Down
1 change: 1 addition & 0 deletions src/delete/delete.strategy.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import { createPackagesClient } from "../clients/packages.client"

export function decideDeleteStrategy(input: Input): DeleteStrategy {
const packagesClient = createPackagesClient(input)

return input.organization ? new OrganizationDeleteStrategy(packagesClient) : new UserDeleteStrategy(packagesClient)
}
1 change: 1 addition & 0 deletions src/delete/strategies/organization.delete.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GitHub } from "@actions/github/lib/utils"

export default class OrganizationDeleteStrategy implements DeleteStrategy {
constructor(private readonly octokit: InstanceType<typeof GitHub>) {}

async deletePackageVersion(input: RestInput, name: string, id: string): Promise<void> {
await this.octokit.rest.packages.deletePackageVersionForOrg({
package_name: name,
Expand Down
1 change: 1 addition & 0 deletions src/delete/strategies/user.delete.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GitHub } from "@actions/github/lib/utils"

export default class UserDeleteStrategy implements DeleteStrategy {
constructor(private readonly octokit: InstanceType<typeof GitHub>) {}

async deletePackageVersion(input: RestInput, name: string, id: string): Promise<void> {
await this.octokit.rest.packages.deletePackageVersionForUser({
package_name: name,
Expand Down
1 change: 1 addition & 0 deletions src/query/query.strategy.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import { createPackagesClient } from "../clients/packages.client"

export function decideQueryStrategy(input: Input): QueryStrategy {
const packagesClient = createPackagesClient(input)

return input.organization ? new OrganizationQueryStrategy(packagesClient) : new UserQueryStrategy(packagesClient)
}
1 change: 1 addition & 0 deletions src/query/strategies/organization.query.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class OrganizationQueryStrategy implements QueryStrategy {
org: input.organization,
per_page: 100,
}

return this.octokit.rest.packages.getAllPackageVersionsForPackageOwnedByOrg(params)
} catch (error) {
throw new Error(`Failed to query package ${name}: ${error}`)
Expand Down
1 change: 1 addition & 0 deletions src/query/strategies/user.query.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class UserQueryStrategy implements QueryStrategy {
username: input.user,
per_page: 100,
}

return this.octokit.rest.packages.getAllPackageVersionsForPackageOwnedByUser(params)
} catch (error) {
throw new Error(`Failed to query package ${name}: ${error}`)
Expand Down

0 comments on commit 7c7a884

Please sign in to comment.