upadte: clean code + add next cloud

This commit is contained in:
Tom Boullay
2026-04-14 16:21:37 +02:00
parent 3adcf9d30e
commit 3a7a5e2eea
20 changed files with 663 additions and 131 deletions
+3 -11
View File
@@ -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(