Add upload tool and related APIs (#187)
* Add utils for r2 upload * Add the tool and new routes * fix auth issue * sign headers * add comment * use our own API key to auth signed uploads * Restructure things slightly * tweak * tweak * add comments * tweak * revert a thing * twaek * drop mime type filtering * new incarnation of mime type filtering * jsut allow all octet-streams * simplify further * tweak * update lockfile --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
This commit is contained in:
committed by
pullfrog[bot]
parent
cac9b0e645
commit
071e885d63
@@ -0,0 +1,46 @@
|
||||
import type { Octokit } from "@octokit/rest";
|
||||
import packageJson from "../package.json" with { type: "json" };
|
||||
import { log } from "./cli.ts";
|
||||
import { type OctokitWithPlugins, parseRepoContext } from "./github.ts";
|
||||
import { fetchRunContext, type RepoSettings } from "./runContext.ts";
|
||||
|
||||
export interface RunContextData {
|
||||
repo: {
|
||||
owner: string;
|
||||
name: string;
|
||||
data: Awaited<ReturnType<Octokit["repos"]["get"]>>["data"];
|
||||
};
|
||||
repoSettings: RepoSettings;
|
||||
apiToken: string;
|
||||
}
|
||||
|
||||
interface ResolveRunContextDataParams {
|
||||
octokit: OctokitWithPlugins;
|
||||
token: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize run context data: parse context, fetch repo info and settings
|
||||
*/
|
||||
export async function resolveRunContextData(
|
||||
params: ResolveRunContextDataParams
|
||||
): Promise<RunContextData> {
|
||||
log.info(`» running Pullfrog v${packageJson.version}...`);
|
||||
|
||||
const repoContext = parseRepoContext();
|
||||
|
||||
const [repoResponse, runContext] = await Promise.all([
|
||||
params.octokit.repos.get({ owner: repoContext.owner, repo: repoContext.name }),
|
||||
fetchRunContext({ token: params.token, repoContext }),
|
||||
]);
|
||||
|
||||
return {
|
||||
repo: {
|
||||
owner: repoContext.owner,
|
||||
name: repoContext.name,
|
||||
data: repoResponse.data,
|
||||
},
|
||||
repoSettings: runContext.settings,
|
||||
apiToken: runContext.apiToken,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user