Skip to content

Commit

Permalink
install script for noirenberg
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Oct 1, 2024
1 parent 51b8303 commit 70de136
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
47 changes: 47 additions & 0 deletions bin/shell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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, 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();
}
13 changes: 13 additions & 0 deletions bin/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios';
export async function getBbVersion(noirVersion) {
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);
}
}
42 changes: 42 additions & 0 deletions install
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."

0 comments on commit 70de136

Please sign in to comment.