Commit files without cloning
Use the JavaScript SDK to create one commit from generated files.
Install the SDK and create an API key with repository read and write access:
npm install @thegarage/sdk
garage keys create sdk \
--scope repos:read \
--scope repos:write
Store the printed key in GARAGE_API_KEY. Then stage and commit the files:
import { garage } from '@thegarage/sdk'
const repo = await garage('codegen-output', {
token: process.env.GARAGE_API_KEY!,
})
await repo.add('src/client.ts', 'export class ApiClient {}\n')
await repo.add('src/types.ts', 'export type ApiResult = { ok: boolean }\n')
const commit = await repo.commit('Regenerate client')
console.log(commit.sha)
commit() creates the repository if it does not exist. It then writes all
staged changes in one commit. The printed SHA identifies the new commit.
See the JavaScript SDK reference for binary content, removals, branches, authors, and read operations.