Freestyle Docs

Freestyle / Docs

Repositories

Create, list, delete, and authenticate Freestyle Git repositories.

Create An Empty Repository

import { freestyle } from "freestyle";

const { repoId, repo } = await freestyle.git.repos.create({
  name: "my-repo",
});

Create From A Source Repository

Fork an existing repository and preserve its history:

await freestyle.git.repos.create({
  source: {
    url: "https://github.com/user/repo.git",
    rev: "main",
  },
});

List Repositories

const result = await freestyle.git.repos.list({
  limit: 20,
  cursor: "0",
});

for (const repo of result.repositories) {
  console.log(repo);
}

Delete A Repository

await freestyle.git.repos.delete({
  repoId: "your-repo-id",
});

Deleting a repository permanently removes its Git data.

Authenticate Native Git

Repositories are private by default. Grant access through Freestyle identities.

const { identity } = await freestyle.identities.create();

await identity.permissions.git.grant({
  permission: "write",
  repoId,
});

const { token } = await identity.tokens.create();

console.log(
  `git clone https://x-access-token:${token}@git.freestyle.sh/${repoId}`,
);

For local testing with your API key:

git -c http.extraHeader="Authorization: Bearer $FREESTYLE_API_KEY" \
  clone https://git.freestyle.sh/<repo-id>

Public Repositories

await freestyle.git.repos.create({
  public: true,
});

Public repositories can be cloned without authentication, but pushes still require write access.

esc