Skip to content

Commit

Permalink
Merge pull request #428 from alephium/cli/gen-ralph
Browse files Browse the repository at this point in the history
Add a cli to generate ralph template for existing projects
  • Loading branch information
polarker authored Oct 4, 2024
2 parents 4f73f2b + d6f52eb commit 44cf36b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ jobs:
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
version: 9.4
- run: pnpm audit
2 changes: 0 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
node-version: 20

- uses: pnpm/action-setup@v4
with:
version: 9.4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
with:
node-version: 20
- uses: pnpm/action-setup@v4
with:
version: 9.4
- run: cd packages/web3 && pnpm i
# Wait for this issue to be resolved: https://github.com/acacode/swagger-typescript-api/issues/370
- run: npm run update-schemas && test -z "$(git status --porcelain)"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ jobs:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v4
with:
version: 9.4
- run: pnpm install
- run: git status
- name: Publish to npm
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v4
with:
version: 9.4
- run: |
pushd docker
docker compose up -d
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"elliptic@>=5.2.1 <=6.5.6": ">=6.5.7",
"micromatch@<4.0.8": ">=4.0.8"
}
}
},
"packageManager": "[email protected]+sha512.4abf725084d7bcbafbd728bfc7bee61f2f791f977fd87542b3579dcb23504d170d46337945e4c66485cd12d588a0c0e570ed9c477e7ccdd8507cf05f3f92eaca"
}
9 changes: 8 additions & 1 deletion packages/cli/cli_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { run as runJestTests } from 'jest'
import path from 'path'
import { deployAndSaveProgress } from './scripts/deploy'
import { Configuration, DEFAULT_CONFIGURATION_VALUES } from './src/types'
import { createProject } from './scripts/create-project'
import { createProject, genRalph } from './scripts/create-project'
import {
checkFullNodeVersion,
codegen,
Expand Down Expand Up @@ -81,6 +81,13 @@ program
createProject(templateType, __dirname, projectRoot)
})

program
.command('gen-ralph')
.description('generate ralph contract template for an existing project')
.action(() => {
genRalph(__dirname, process.cwd())
})

program
.command('compile')
.description('compile the project')
Expand Down
20 changes: 20 additions & 0 deletions packages/cli/scripts/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,23 @@ export function createProject(templateType: string, packageRoot: string, project
console.log(`Next step: checkout the readme under <${projectRoot}>`)
console.log()
}

export function genRalph(packageRoot: string, projectRoot: string) {
console.log('Creating the Ralph Template for the existing project')
for (const dir of ['contracts', 'scripts', 'test', 'alephium.config.ts']) {
fsExtra.copySync(path.join(packageRoot, 'templates/base', dir), path.join(projectRoot, dir))
}
console.log('✅ Done.')
console.log(`
Please install the dependencies:
@alephium/web3
@alephium/web3-wallet
Dev dependencies:
@alephium/web3-test
And add the following to your package.json scripts:
"compile": "npx cli compile",
"deploy": "npx cli deploy",
`)
}

0 comments on commit 44cf36b

Please sign in to comment.