upadte: clean code + add next cloud
This commit is contained in:
+3
-11
@@ -1,18 +1,17 @@
|
||||
import { Octokit } from '@octokit/rest'
|
||||
import { createHash } from 'crypto'
|
||||
import type { RemoteFile } from './types'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Octokit helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function getOctokit(): Octokit {
|
||||
function getOctokit(): Octokit {
|
||||
const token = process.env.GITHUB_TOKEN
|
||||
if (!token) throw new Error('GITHUB_TOKEN non configure')
|
||||
return new Octokit({ auth: token })
|
||||
}
|
||||
|
||||
export function parseRepoUrl(): { owner: string; repo: string } {
|
||||
function parseRepoUrl(): { owner: string; repo: string } {
|
||||
const url = process.env.GIT_REPO_URL
|
||||
if (!url) throw new Error('GIT_REPO_URL non configure')
|
||||
|
||||
@@ -26,15 +25,8 @@ export function parseRepoUrl(): { owner: string; repo: string } {
|
||||
return { owner: match[1], repo: match[2] }
|
||||
}
|
||||
|
||||
/** Compute the SHA that Git would assign to a blob with this content */
|
||||
export function computeGitBlobSha(content: Buffer): string {
|
||||
const header = `blob ${content.length}\0`
|
||||
const store = Buffer.concat([Buffer.from(header), content])
|
||||
return createHash('sha1').update(store).digest('hex')
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Read remote folder contents (with SHA per file)
|
||||
// Read remote folder contents (with size per file)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function getRemoteFolder(
|
||||
|
||||
Reference in New Issue
Block a user