OverviewFilesCommitsIssuesDocsReleasesPeers

pear-git / scripts / register-pear-git.js

34 lines · javascript ref:
#!/usr/bin/env bare
import Corestore from 'corestore'
import Hyperbee from 'hyperbee'

const store = new Corestore('./pear-git-storage')
const registryCore = store.get({ name: 'registry' })
const registry = new Hyperbee(registryCore, {
  keyEncoding: 'utf-8',
  valueEncoding: 'json'
})

await registry.ready()

const pearGitRepo = {
  name: 'pear-git',
  path: '/home/fleeky/git-repos/pear-git.git',
  commits: 1,
  branches: 1,
  lastCommit: {
    hash: '81d4a0d',
    author: 'plankatron',
    email: 'fleeky@gmail.com',
    timestamp: Math.floor(Date.now() / 1000),
    message: 'Initial commit: P2P git forge with ANProto authentication'
  },
  isBare: true,
  registeredAt: Date.now()
}

await registry.put('repo:pear-git', pearGitRepo)
console.log('✓ Registered pear-git:', pearGitRepo)

await store.close()