Skip to content

Commit

Permalink
"remove svn"
Browse files Browse the repository at this point in the history
  • Loading branch information
hazelnutcloud committed Jun 30, 2023
1 parent e4cbf9c commit 6798144
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 50 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v0.5.0
# v0.4.15
- feat: populate relational entities on graphql endpoint
- feat: add overload to `manifest.addChain` and `chain.addContract` functions to pass in a callback function that takes in a DataSourceBuilder and ContractBuilder instance respectively
- feat: remove svn as a dependancy to run `arkiver init` command
- change: deprecate `manifest.chain` for `manifest.addChain`
- change: deprecate `manifest.contract` for `manifest.addContract`
- change: `transactionIndex` and `logIndex` field in event is now number type to align with viem's return types
Expand Down
5 changes: 2 additions & 3 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ command
// init
command
.command('init', 'Initialize a new arkive project')
.option('--overwrite', 'Overwrite existing files')
.action(async (opts, ...args) => {
.action(async () => {
util.logHeader(version)
await checkVersion(version)
await init.action(opts, ...args)
await init.action()
})

// upgrade
Expand Down
103 changes: 68 additions & 35 deletions cli/init/mod.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { $, Input, join, prompt, Select, Toggle, wait } from '../deps.ts'
import { $, Input, join, prompt, Select, Toggle } from '../deps.ts'

export const action = async (
options: { overwrite?: boolean },
) => {
let spinner = wait('Fetching templates...').start()
export const action = async () => {
let pb = $.progress('Fetching templates...')

const templatesRes = await fetch(
'https://api.github.com/repos/RoboVault/robo-arkiver/contents/examples',
)
let templatesRes: Response

if (!templatesRes.ok) {
console.log('Error fetching templates')
await pb.with(async () => {
templatesRes = await fetch(
'https://api.github.com/repos/RoboVault/robo-arkiver/contents/examples',
)
})

if (!templatesRes!.ok) {
console.log('Error fetching templates: ', templatesRes!.statusText)
return
}

const templates = await templatesRes.json() as {
const templates = await templatesRes!.json() as {
name: string
type: string
}[]
Expand All @@ -28,8 +30,6 @@ export const action = async (
name: t.name,
}))

spinner.stop()

const defaultPath = './cool-new-arkive'

const arkive = await prompt([
Expand Down Expand Up @@ -62,31 +62,64 @@ export const action = async (
const newDir = join(Deno.cwd(), arkive.dir ?? defaultPath)
const template = arkive.template ?? templateNames[0].value

spinner = wait('Initializing arkive...').start()
pb = $.progress('Initializing arkive...')

const initRes = await $`svn export ${
options.overwrite ? `--force ` : ''
}https://github.com/RoboVault/robo-arkiver/trunk/examples/${template} ${newDir}`
.captureCombined(true)
try {
await $`git init ${newDir} && cd ${newDir} && git config core.sparseCheckout true`
.quiet('both')

if (initRes.code !== 0) {
spinner.fail(`Error initializing arkive: ${initRes.stderr}`)
return
}

if (arkive.vscode) {
const dir = arkive.dir ?? defaultPath
await Deno.mkdir(join(Deno.cwd(), dir, '.vscode'))

const vscode = `{
"deno.enable": true,
"deno.unstable": true
}`
await Deno.writeTextFile(
join(Deno.cwd(), dir, '.vscode', 'settings.json'),
vscode,
await Deno.writeFile(
join(newDir, '.git', 'info', 'sparse-checkout'),
new TextEncoder().encode(`examples/${template}`),
)

await $`git remote add origin https://github.com/RoboVault/robo-arkiver && git pull origin main && rm -rf .git`
.cwd(newDir)
.quiet('stdout')

// traverse the template directory and move all files to the root
for await (
const entry of Deno.readDir(join(newDir, `examples/${template}`))
) {
const source = join(newDir, `examples/${template}`, entry.name)
const destination = join(newDir, entry.name)
await Deno.rename(source, destination)
}

await Deno.remove(join(newDir, 'examples'), { recursive: true })

if (arkive.vscode) {
const dir = arkive.dir ?? defaultPath
await Deno.mkdir(join(Deno.cwd(), dir, '.vscode'))

const vscode = `{
"deno.enable": true,
"deno.unstable": true
}`
await Deno.writeTextFile(
join(Deno.cwd(), dir, '.vscode', 'settings.json'),
vscode,
)

const gitignore = `/.vscode
/.vscode/*
/.vscode/**/*
`
await Deno.writeTextFile(
join(Deno.cwd(), dir, '.gitignore'),
gitignore,
)
}

await $`git init && git add . && git commit -m "Initial commit"`
.cwd(newDir)
.quiet('stdout')
} catch (e) {
$.logError(`Error initializing arkive: ${e}`)
return
}

spinner.succeed('Initialized arkive')
// spinner.succeed('Initialized arkive')
pb.finish()
$.logStep('Initialized arkive')
}
2 changes: 1 addition & 1 deletion examples/block-handler-vaults/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
} from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
2 changes: 1 addition & 1 deletion examples/block-handler-vaults/handlers/vault.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatUnits, getContract } from 'npm:viem'
import { type BlockHandler } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { type BlockHandler } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
import { VaultSnapshot } from '../entities/vault.ts'
import { YearnV2Abi } from '../abis/YearnV2.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/block-handler-vaults/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
import { VaultSnapshot } from './entities/vault.ts'
import { snapshotVault } from './handlers/vault.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-balance-history/entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEntity } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { createEntity } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'

// @note: "Index: true" enhances graphql queries

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-balance-history/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatUnits } from 'npm:viem'
import { type EventHandlerFor } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { type EventHandlerFor } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
import erc20 from './erc20.ts'
import { Balance, BalanceHistory, Transfer } from './entities.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-balance-history/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
import erc20 from './erc20.ts'
import { Entities } from './entities.ts'
import { onTransfer } from './handlers.ts'
Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-events/entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEntity } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { createEntity } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'

// @note: "Index: true" enhances graphql queries
export const Transfer = createEntity('Transfer', {
Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-events/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatUnits } from 'npm:viem'
import { type EventHandlerFor } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { type EventHandlerFor } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
import erc20 from './erc20.ts'
import { Approval, Transfer } from './entities.ts'

Expand Down
2 changes: 1 addition & 1 deletion examples/erc20-events/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
import erc20 from './erc20.ts'
import { Approval, Transfer } from './entities.ts'
import { onApproval, onTransfer } from './handlers.ts'
Expand Down
2 changes: 1 addition & 1 deletion examples/event-wildcard/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
} from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'
2 changes: 1 addition & 1 deletion examples/simple/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export {
createEntity,
type EventHandlerFor,
Manifest,
} from 'https://deno.land/x/robo_arkiver@v0.5.0/mod.ts'
} from 'https://deno.land/x/robo_arkiver@v0.4.15/mod.ts'

0 comments on commit 6798144

Please sign in to comment.