master
cyhhao 2 years ago
parent 7cefdd447b
commit 1c7cb54d41

@ -0,0 +1,12 @@
{
"name": "git-remote-git3",
"type": "module",
"pkg": {
"targets": [
"node18-macos-x64",
"node18-linux-x64",
"node18-win-x64"
],
"outputPath": "bin"
}
}

@ -0,0 +1,12 @@
{
"name": "git3",
"type": "module",
"pkg": {
"targets": [
"node18-macos-x64",
"node18-linux-x64",
"node18-win-x64"
],
"outputPath": "bin"
}
}

@ -1,17 +1,12 @@
{
"name": "git3-cli",
"version": "1.0.0",
"bin": "dist/index.js",
"pkg": {
"targets": [
"node18-macos-arm64",
"node18-macos-x64",
"node18-linux-x64",
"node18-win-x64"
],
"outputPath": "bin"
},
"license": "MIT",
"type": "module",
"engines": {
"node": ">=14.16"
},
"bin": "dist/git3/index.js",
"dependencies": {
"@ethersproject/experimental": "^5.7.0",
"bip39": "^3.0.4",
@ -31,21 +26,25 @@
"superpathjoin": "^2.0.1"
},
"scripts": {
"build": "yarn clean && tsc",
"install-linux": "yarn pkg:linux && cp ./bin/index /usr/local/bin/git-remote-git3",
"install-mac": "yarn pkg && cp ./bin/index-macos-x64 /usr/local/bin/git-remote-git3",
"install-mac-arm": "yarn pkg && cp ./bin/index-macos-arm64 /usr/local/bin/git-remote-git3",
"pkg:linux": "yarn build && pkg ./dist/index.js --out-path bin/ --targets node18-linux-x64",
"pkg": "yarn build && pkg ./dist/index.js --out-path bin/ --targets node18-macos-x64,node18-macos-arm64,node18-linux-x64,node18-win-x64",
"build:git3": "esbuild ./src/git3/index.js --bundle --platform=node --target=es6 --outfile=dist/git3.js",
"pkg:git3": "yarn build:git3 && pkg dist/git3.js --output bin/git3 && cp bin/git3 /usr/local/bin/git3",
"clean": "rm -rf ./dist ./bin"
"clean": "rm -rf ./dist ./bin",
"build:git3": "esbuild src/git3/index.ts --bundle --platform=node --outfile=dist/git3.cjs --format=cjs",
"build:git-remote": "esbuild src/git-remote-git3/index.ts --bundle --platform=node --outfile=dist/git-remote-git3.cjs --format=cjs",
"build": "yarn clean && yarn build:git3 & yarn build:git-remote & wait",
"pkg:git3": "pkg dist/git3.cjs -c git3.pkg.json",
"pkg:git-remote": "pkg dist/git-remote-git3.cjs -c git-remote-git3.pkg.json",
"pkg:all": "yarn pkg:git3 && yarn pkg:git-remote",
"pkg": "yarn build && yarn pkg:all",
"install-mac": "yarn pkg && cp bin/git3-macos /usr/local/bin/git3 && cp bin/git-remote-git3-macos /usr/local/bin/git-remote-git3",
"install-linux": "yarn pkg && cp bin/git3-linux /usr/local/bin/git3 && cp bin/git-remote-git3-linux /usr/local/bin/git-remote-git3"
},
"devDependencies": {
"esbuild": "^0.16.4",
"@types/buffer-split": "^1.0.0",
"@types/debug": "^4.1.7",
"@types/inquirer": "^9.0.3",
"@types/node": "^18.11.10",
"@types/parse-git-config": "^3.0.1",
"esbuild": "^0.17.0",
"pkg": "^5.8.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
}

@ -1,8 +1,8 @@
import { log } from './log'
import { log } from './log.js'
import { superpathjoin as join } from 'superpathjoin'
import { ApiBaseParams } from './git-remote-helper'
import { Ref, Status, Storage } from '../storage/storage'
import { GitUtils } from './git-utils'
import { ApiBaseParams } from './git-remote-helper.js'
import { Ref, Status, Storage } from '../storage/storage.js'
import { GitUtils } from './git-utils.js'
class Git {
gitdir: string
remoteName: string

@ -1,12 +1,11 @@
import GitRemoteHelper from './git/git-remote-helper'
import { ApiBaseParams } from './git/git-remote-helper'
import Git from './git/git'
// import { log } from './git/log'
import { ETHStorage } from './storage/ETHStorage'
import nameServices from './config/name-services'
import GitRemoteHelper from './git-remote-helper.js'
import { ApiBaseParams } from './git-remote-helper.js'
import Git from './git.js'
import { ETHStorage } from '../storage/ETHStorage.js'
import nameServices from '../config/name-services.js'
// https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
let git: Git;
GitRemoteHelper({
env: process.env,

@ -1,3 +0,0 @@
export default {
"ETHStorage": '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"chunkId","type":"uint256"}],"name":"chunkStakeTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"name","type":"bytes"}],"name":"countChunks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"createRepo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"name","type":"bytes"}],"name":"delRef","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"download","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOptimize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"}],"name":"listRefs","outputs":[{"components":[{"internalType":"bytes20","name":"hash","type":"bytes20"},{"internalType":"bytes","name":"name","type":"bytes"}],"internalType":"struct Git3.refData[]","name":"list","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"nameToRefInfo","outputs":[{"internalType":"bytes20","name":"hash","type":"bytes20"},{"internalType":"uint96","name":"index","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"remove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"repoNameToOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"repoNameToRefs","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"name","type":"bytes"},{"internalType":"bytes20","name":"refHash","type":"bytes20"}],"name":"setRef","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"name","type":"bytes"}],"name":"size","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"stakeTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upload","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"repoName","type":"bytes"},{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"uint256","name":"chunkId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uploadChunk","outputs":[],"stateMutability":"payable","type":"function"}]'
}

@ -5,8 +5,8 @@ import bip39 from 'bip39'
import inquirer from 'inquirer'
import parse from 'parse-git-config'
import { importActions, generateActions } from './actions.js'
import abis from "../config/abis"
import network from "../config/evm-network"
import abis from "../config/abis.js"
import network from "../config/evm-network.js"
const program = new Command()
program
@ -145,17 +145,15 @@ program.command('create')
const contract = new ethers.Contract(
net.contracts.git3,
abis.ETHStorage,
etherWallet, {
gasLimit: 10000000000
})
etherWallet)
contract.repoNameToOwner(Buffer.from(repo))
.then(res => { console.log(res) })
.catch(err => { console.error(err) })
.then((res: any) => { console.log(res) })
.catch((err: any) => { console.error(err) })
contract.createRepo(Buffer.from(repo))
.then(res => { console.log(res) })
.catch(err => { console.error(err) })
.then((res: any) => { console.log(res) })
.catch((err: any) => { console.error(err) })
})
@ -225,8 +223,8 @@ program.command('set-wallet')
newConfigText += `\t${subKey} = ${newConfig[key][subKey]}\n`
})
})
writeFileSync(parse.resolve(), newConfigText)
let path = parse.resolveConfigPath("global") || ""
writeFileSync(path, newConfigText)
} else {
console.error(`remote ${git3} not found`)
console.error('you can add a remote with `git remote add <name> <url>')

@ -1,9 +1,9 @@
import { Ref, Status, Storage } from "./storage"
import { getWallet } from "../wallet/index"
import { Ref, Status, Storage } from "./storage.js"
import { getWallet } from "../wallet/index.js"
import { ethers, Signer } from "ethers"
import { NonceManager } from "@ethersproject/experimental"
import abis from "../config/abis"
import network from "../config/evm-network"
import abis from "../config/abis.js"
import network from "../config/evm-network.js"
export class ETHStorage implements Storage {
repoName: string
wallet: Signer

@ -1,6 +1,6 @@
import { promises as fs } from 'fs'
import pathUtil from 'path'
import { Ref, Status, Storage } from "./storage"
import { Ref, Status, Storage } from "./storage.js"
import { superpathjoin as join } from 'superpathjoin'
const mockPath = process.env.HOME + "/.git3/mock"
fs.mkdir(mockPath, { recursive: true })

@ -1,4 +1,4 @@
import { ETHStorage } from "../storage/ETHStorage";
import { ETHStorage } from "../storage/ETHStorage.js";
let es = new ETHStorage("test123", 3334, { git3Address: null, sender: null })

@ -1,5 +0,0 @@
<body>
"git3://" web3 git protocol, code for the open web
</body>

File diff suppressed because one or more lines are too long

@ -5,8 +5,8 @@
"preserveConstEnums": true, /* Do not erase const enum declarations in generated code. */
"resolveJsonModule": true, /* Include modules imported with '.json' extension. Requires TypeScript version 2.9 or later. */
/* Basic Options */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "ESNext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [
"es5",
"es6"
@ -40,7 +40,7 @@
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "nodenext", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "src", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
@ -64,7 +64,8 @@
"exclude": [
"node_modules",
"test",
"dist",
"bin",
"types",
"src/git3"
]
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save