mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-01-05 22:29:08 +00:00
feat(lib): relocate GithubReleases
type and implement custom payload
* Also breaks down `GithubReleases` into array of `GithubRelease` type * Adds a `Custom` operation type for internal `Github` class, allowing user to mention custom request data
This commit is contained in:
parent
bc2d438975
commit
5b1a25bd53
2 changed files with 28 additions and 16 deletions
|
@ -18,7 +18,28 @@ export type Config = {
|
||||||
authToken: Option<string>,
|
authToken: Option<string>,
|
||||||
retries: Option<number>,
|
retries: Option<number>,
|
||||||
}
|
}
|
||||||
export type GithubOperation = "FetchReleases" | "GetMetadata" | "GetActionArtifacts"
|
export type GithubOperation =
|
||||||
|
"FetchReleases"
|
||||||
|
| "GetMetadata"
|
||||||
|
| "GetActionArtifacts"
|
||||||
|
| { type: "Custom", payload: net.FetchParams }
|
||||||
|
|
||||||
|
export type GithubRelease = {
|
||||||
|
tag_name: string,
|
||||||
|
created_at: string,
|
||||||
|
published_at: string,
|
||||||
|
prerelease: boolean,
|
||||||
|
draft: boolean,
|
||||||
|
assets: {
|
||||||
|
{
|
||||||
|
name: string,
|
||||||
|
browser_download_url: string,
|
||||||
|
size: number,
|
||||||
|
content_type: string,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
export type GithubReleases = { GithubRelease }
|
||||||
|
|
||||||
local API_BASE_URL = "https://api.github.com"
|
local API_BASE_URL = "https://api.github.com"
|
||||||
local DEFAULT_MAX_RETRIES = 5
|
local DEFAULT_MAX_RETRIES = 5
|
||||||
|
@ -60,6 +81,10 @@ function Github.queueTransactions(self: Github, operations: { GithubOperation })
|
||||||
req.method = "GET"
|
req.method = "GET"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if typeof(operation) == "table" and operation.type == "Custom" then
|
||||||
|
req = operation.payload
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: Other methods
|
-- TODO: Other methods
|
||||||
|
|
||||||
table.insert(queue, function(retries: number)
|
table.insert(queue, function(retries: number)
|
||||||
|
|
|
@ -31,21 +31,8 @@ export type ToolId = {
|
||||||
version: Option<Semver.SemverImpl>,
|
version: Option<Semver.SemverImpl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GithubReleases = {
|
-- TODO: Remove this in a breaking change
|
||||||
{
|
export type GithubReleases = Github.GithubReleases
|
||||||
tag_name: string,
|
|
||||||
prerelease: boolean,
|
|
||||||
draft: boolean,
|
|
||||||
assets: {
|
|
||||||
{
|
|
||||||
name: string,
|
|
||||||
browser_download_url: string,
|
|
||||||
size: number,
|
|
||||||
content_type: string,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local WARN_PREFIX = `{stdio.color("yellow")}{stdio.style("bold")}warn{stdio.color("reset")}:`
|
local WARN_PREFIX = `{stdio.color("yellow")}{stdio.style("bold")}warn{stdio.color("reset")}:`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue