-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: goodbye noir-starter, hello noirenberg #89
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ package-lock.json | |
|
||
# To use with nektos/act | ||
.github/event.json | ||
npx.js | ||
bin/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { execSync } from 'child_process'; | ||
import logSymbols from 'log-symbols'; | ||
import ora from 'ora'; | ||
|
||
export function sourceShellConfig() { | ||
const shell = execSync('echo $SHELL', { encoding: 'utf-8' }).trim(); | ||
|
||
if (shell.includes('bash')) { | ||
execSync('source ~/.bashrc', { stdio: 'inherit' }); | ||
} else if (shell.includes('zsh')) { | ||
execSync(`zsh -c "source ~/.zshrc"`, { stdio: 'inherit' }); | ||
} else if (shell.includes('fish')) { | ||
execSync(`fish -c "source ~/.config/fish/config.fish"`, { stdio: 'inherit' }); | ||
} else { | ||
throw new Error('Unsupported shell environment'); | ||
} | ||
} | ||
|
||
export function exec(cmd: string, options = {}) { | ||
return execSync(cmd, { | ||
encoding: 'utf-8', | ||
stdio: 'pipe', | ||
...options, | ||
}); | ||
} | ||
const spinner = ora({ color: 'blue', discardStdin: false }); | ||
|
||
export function installInstallers() { | ||
try { | ||
exec('which noirup', { stdio: 'ignore' }); | ||
spinner.succeed('noirup is already installed'); | ||
} catch { | ||
spinner.start('Installing noirup'); | ||
exec('curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash'); | ||
spinner.stopAndPersist({ symbol: logSymbols.success }); | ||
} | ||
try { | ||
exec('which bbup', { stdio: 'ignore' }); | ||
spinner.succeed('bbup is already installed'); | ||
} catch { | ||
spinner.start('Installing bbup'); | ||
exec( | ||
'curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/master/barretenberg/cpp/installation/install | bash', | ||
); | ||
spinner.stopAndPersist({ symbol: logSymbols.success }); | ||
} | ||
sourceShellConfig(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import axios from 'axios'; | ||
|
||
export async function getBbVersion(noirVersion: string) { | ||
const url = `https://raw.githubusercontent.com/noir-lang/noir/v${noirVersion}/scripts/install_bb.sh`; | ||
|
||
try { | ||
const { data } = await axios.get(url); | ||
const versionMatch = data.match(/VERSION="([\d.]+)"/); | ||
const version = versionMatch ? versionMatch[1] : null; | ||
|
||
return version; | ||
} catch (e) { | ||
throw new Error(e); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# Function to install NVM and Node.js | ||
install_nvm_and_node() { | ||
echo "Installing NVM..." | ||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash | ||
|
||
# Load NVM | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
# Install the latest LTS version of Node.js | ||
echo "Installing the latest LTS version of Node.js..." | ||
nvm install --lts | ||
|
||
# Use the installed version | ||
nvm use --lts | ||
|
||
# Verify installation | ||
node --version | ||
npm --version | ||
} | ||
|
||
# Check if NVM is installed | ||
if ! command_exists nvm; then | ||
install_nvm_and_node | ||
fi | ||
|
||
|
||
# Install noirenberg globally | ||
echo "Installing noirenberg..." | ||
npm install -g noirenberg | ||
|
||
echo "Installation complete. You can now use the 'noirenberg' command." | ||
echo "Please restart your terminal or run 'source ~/.bashrc' (or your shell's equivalent) to start using noirenberg." |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env node | ||
import { Command, Option } from 'commander'; | ||
import select from '@inquirer/select'; | ||
import input from '@inquirer/input'; | ||
import shelljs from 'shelljs'; | ||
const program = new Command(); | ||
import tiged from 'tiged'; | ||
import { sourceShellConfig, exec, installInstallers } from './bin/shell.js'; | ||
import ora from 'ora'; | ||
import logSymbols from 'log-symbols'; | ||
import { getBbVersion } from './bin/versions.js'; | ||
import { execSync } from 'child_process'; | ||
|
||
const spinner = ora({ color: 'blue', discardStdin: false }); | ||
|
||
program | ||
.command('install', { isDefault: true }) | ||
.description('Installs compatible versions of Noir and Barretenberg.') | ||
.addOption( | ||
new Option( | ||
'-n --nightly', | ||
'Install the nightly version of Noir and the compatible version of Barretenberg', | ||
).conflicts('version'), | ||
) | ||
.option( | ||
'-v, --version <version>', | ||
'Install a specific version of Noir and the compatible version of Barretenberg', | ||
) | ||
.hook('preAction', () => { | ||
installInstallers(); | ||
}) | ||
.action(async ({ nightly, version }) => { | ||
try { | ||
spinner.start( | ||
`Installing nargo ${nightly ? 'nightly' : version ? `version ${version}` : 'stable'}`, | ||
); | ||
exec(`noirup ${nightly ? '-n' : version ? `-v ${version}` : ''}`); | ||
sourceShellConfig(); | ||
const output = exec('nargo --version'); | ||
const nargoVersion = output.match(/nargo version = (\d+\.\d+\.\d+)/)!; | ||
spinner.succeed(`Installed nargo version ${nargoVersion[1]}`); | ||
|
||
spinner.start(`Getting compatible barretenberg version`); | ||
const compatibleVersion = await getBbVersion(nargoVersion[1]); | ||
exec(`bbup -v ${compatibleVersion}`); | ||
const bbVersion = exec('bb --version'); | ||
spinner.text = `Installed barretenberg version ${bbVersion}`; | ||
spinner.succeed(); | ||
} catch (error) { | ||
spinner.fail(`Error installing Noir and Barretenberg`); | ||
throw error; | ||
} | ||
}); | ||
|
||
program | ||
.command('new') | ||
.description('Bootstraps a ready-to-go Noir project with Noir and Barretenberg') | ||
.option('-v, --verbose', 'Show verbose output') | ||
.option('-f, --force', 'Force overwriting existing files') | ||
.action(async ({ verbose, force }) => { | ||
const appType = await select({ | ||
message: 'Please choose an option:', | ||
choices: [ | ||
{ value: 'vite-hardhat', name: 'Browser App using Vite' }, | ||
{ value: 'with-foundry', name: 'Solidity App using Foundry' }, | ||
], | ||
}); | ||
|
||
const appName = await input({ | ||
message: 'Your app name:', | ||
default: 'my-noir-app', | ||
}); | ||
|
||
spinner.start(`Bootstrapping ${appType}`); | ||
const emitter = tiged(`noir-lang/noir-starter/${appType}`, { | ||
disableCache: true, | ||
force, | ||
verbose, | ||
}); | ||
|
||
emitter.on('info', info => { | ||
verbose && spinner.info(info.message); | ||
}); | ||
|
||
emitter.clone(`./${appName}`).then(() => { | ||
spinner.succeed(`Bootstrapped ${appType} at ${appName}`); | ||
}); | ||
}); | ||
|
||
program.parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
{ | ||
"name": "create-noir", | ||
"name": "noirenberg", | ||
"version": "0.1.1", | ||
"type": "module", | ||
"description": "This is a reference repo to help you get started with writing zero-knowledge circuits with [Noir](https://noir-lang.org/).", | ||
"description": "This repo contains starter projects using Noir and Barretenberg, together with a CLI tool to help you get started.", | ||
"bin": "npx.js", | ||
"author": "", | ||
"license": "ISC", | ||
"scripts": { | ||
"start": "bunx tsx npx.ts", | ||
"compile": "tsc npx.ts --esModuleInterop true --module nodenext && chmod +x npx.js", | ||
"publish": "bun compile && npm publish" | ||
}, | ||
"dependencies": { | ||
"@inquirer/input": "^1.2.16", | ||
"@inquirer/select": "^1.3.3", | ||
"axios": "^1.7.7", | ||
"commander": "^11.1.0", | ||
"log-symbols": "^7.0.0", | ||
"ora": "^8.1.0", | ||
"tiged": "^2.12.6" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flagging that I'm not sure if / when @TomAFrench might plan to deprecate this script from Noir, which could break this noirenberg script here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how there is no good way to source Noir compatibility from within Barretenberg yet, don't think this should be blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, this script is purely an implementation detail of the noir repo CI and we don't provide any guarantees about its stability.