MCPcopy Index your code
hub / github.com/aircloud/sync-to-github / githubCreateFile

Function githubCreateFile

apps/chrome-ext/src/utils/githubSync.ts:19–40  ·  view source on GitHub ↗
(payload: SyncPayload)

Source from the content-addressed store, hash-verified

17}
18
19export const githubCreateFile = async (payload: SyncPayload): Promise<CreateOrUpdateResponse> => {
20 const octokit = new Octokit({
21 auth: payload.userConfig?.accessToken,
22 })
23
24 const fileName = payload.title
25 const filePath = `${payload.userConfig.pathPrefix || ''}/${fileName}`.replace(/^\//, '')
26
27 // Base64 encode the file content
28 const encodedContent = base64encode(payload.markdown)
29
30 const res = await octokit.request('PUT /repos/{owner}/{repo}/contents/{path}', {
31 owner: payload.userConfig.owner,
32 repo: payload.userConfig.repo,
33 path: filePath,
34 message: `add ${fileName}`,
35 content: encodedContent,
36 sha: payload.sha,
37 })
38
39 return res as CreateOrUpdateResponse
40}
41
42export const githubUpdateFile = async (payload: SyncPayload) => {
43 const octokit = new Octokit({

Callers 2

syncFunction · 0.90
githubUpdateFileFunction · 0.85

Calls 1

base64encodeFunction · 0.85

Tested by

no test coverage detected