{"id":20726206,"url":"https://github.com/figureland/git","last_synced_at":"2026-04-13T05:44:28.171Z","repository":{"id":239334027,"uuid":"799242297","full_name":"figureland/git","owner":"figureland","description":"A very minimal and tiny tool for working with git in Typescript apps","archived":false,"fork":false,"pushed_at":"2024-05-14T19:45:54.000Z","size":175,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-18T02:46:27.320Z","etag":null,"topics":["bun","git","typescript","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/figureland.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-11T14:55:27.000Z","updated_at":"2024-05-20T19:03:37.000Z","dependencies_parsed_at":"2024-05-15T12:57:13.524Z","dependency_job_id":"a4076c0f-a984-4ae2-837d-edfd3fc491ed","html_url":"https://github.com/figureland/git","commit_stats":null,"previous_names":["figureland/vite-plugin-git","figureland/git"],"tags_count":16,"template":false,"template_full_name":"figureland/base-bun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figureland%2Fgit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figureland%2Fgit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figureland%2Fgit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figureland%2Fgit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/figureland","download_url":"https://codeload.github.com/figureland/git/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243004120,"owners_count":20220237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","git","typescript","vite"],"created_at":"2024-11-17T04:23:53.676Z","updated_at":"2025-12-24T06:03:08.095Z","avatar_url":"https://github.com/figureland.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"A tiny tool for working with git and Typescript. I made this because I wanted a way of adding git information to be visible in the front-end.\n\nIt's so basic it probably doesn't need to be a library of its own. But I found myself needing this so often, I have packaged it up here for my own use.\n\n## Basic usage\n\nThe node.js/bun side of this library exports three little functions. These will fail if you try to use them in the browser, because they depend on access to the filesystem and git in the command line.\n\n```ts\nimport { git, state, isGitAvailable, commands } from '@figureland/git'\n\n// 1. A very basic wrapper that is essentially just a way\n// of calling 'git \u003ccommand\u003e' programmatically\nconst branchName: string = git('rev-parse --abbrev-ref HEAD')\n\n// There are a few preset commands if, like me, you are constantly\n// forgetting git commands.\n\nconst branchName: string = git(commands.branchName) // same as above\n\n// 2. state() returns an object representing the current\n// state of git in the current working directory\ntype GitInformation = {\n  status: 'ok' | 'error'\n  branch: string\n  commitHash: string\n  commitHashShort: string\n  timestamp: string\n  message: string\n}\nconst gitState = state()\n\n// 3. This one is hopefully self-explanatory\n\nconst available: boolean = isGitAvailable()\n```\n\n## Vite plugin\n\nThere is also a Vite plugin that does the same sort of thing but has the feature of adding git state throughout the whole app (front-end) using Vite's [virtual modules feature](https://vitejs.dev/guide/api-plugin#virtual-modules-convention).\n\n### Add it to `vite.config.ts`\n\n```ts\nimport { gitPlugin } from '@figureland/git/vite'\n\nexport default {\n  plugins: [gitPlugin()]\n}\n```\n\n### Import it in your Vite application\n\n```ts\nimport { gitState } from 'virtual:git'\n\n// gitState is a snapshot based on GitInformation (see above)\n```\n\nThis might also be required in a declaration if you are using typescript.\n\n```ts\n/// \u003creference types=\"@figureland/git/module\"/\u003e\n```\n\n## Scripts\n\n### Install\n\n```bash\nbun install\n```\n\n### Test\n\n```bash\nbun test\n```\n\n### Build\n\n```bash\nbun run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffigureland%2Fgit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffigureland%2Fgit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffigureland%2Fgit/lists"}