Skip to content

Commit

Permalink
chore: adding stuff for prebuild, open ports, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Apr 18, 2024
1 parent 550a5ec commit 9613108
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 19 deletions.
14 changes: 10 additions & 4 deletions .devcontainer/react/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"onCreateCommand": "curl -s install.aztec.network | NON_INTERACTIVE=1 BIN_PATH=/usr/local/bin bash -s && echo 'y' | npx create-aztec-app -t app -n react -s && cd react && yarn",
"postAttachCommand": "(nohup /usr/local/bin/aztec sandbox &) && cd react",
"onCreateCommand": "cp -R /root/workspace /root/scripts && rm -rf /root/workspace/* && sh /root/scripts/onCreateCommand.sh app react",
"postAttachCommand": "sh /root/scripts/postAttachCommand.sh app react",
"customizations": {
"vscode": {
"settings": {},
"extensions": ["noir-lang.vscode-noir"]
}
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/react,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace"
"hostRequirements": {
"cpus": 8,
"memory": "8gb",
"storage": "32gb"
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/scripts,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace",
"forwardPorts": [8080]
}
20 changes: 20 additions & 0 deletions .devcontainer/scripts/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

TYPE=$1
NAME=$2

curl -s install.aztec.network | NON_INTERACTIVE=1 BIN_PATH=/usr/local/bin bash -s
docker compose -f $HOME/.aztec/docker-compose.yml pull

if ! grep -q "PXE_URL" ~/.bashrc; then
echo "export PXE_URL=https://\$CODESPACE_NAME-8080.preview.\$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" >> ~/.bashrc
fi

echo 'y' | npx create-aztec-app -t $TYPE -n $NAME -s
mv react/* .
rm -rf react

yarn

npx -y playwright install --with-deps
yarn prep
65 changes: 65 additions & 0 deletions .devcontainer/scripts/postAttachCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
TYPE=$1
NAME=$2

# apt install gh
# gh codespace ports visibility 8080:public -c $CODESPACE_NAME

# (nohup /usr/local/bin/aztec sandbox &)

r=$(tput sgr0) # Reset color
bold=$(tput bold) # Bold text
g=$(tput setaf 46) # Light Green
b=$(tput setaf 21) # Bright Blue
p=$(tput setaf 13) # Magenta
y=$(tput setaf 226) # Bright Yellow
c=$(tput setaf 51) # Cyan
o=$(tput setaf 208) # Orange

# Function to print colored text
print_colored() {
case $2 in
green)
color=$g
;;
blue)
color=$b
;;
magenta)
color=$p
;;
yellow)
color=$y
;;
cyan)
color=$c
;;
orange)
color=$o
;;
*)
color=$r
;;
esac
echo "${color}$1${r}"
}

echo
echo "${bold}${c} █████╗ ███████╗████████╗███████╗ ██████╗${r}"
echo "${bold}${o}██╔══██╗╚══███╔╝╚══██╔══╝██╔════╝██╔════╝${r}"
echo "${bold}${g}███████║ ███╔╝ ██║ █████╗ ██║${r}"
echo "${bold}${b}██╔══██║ ███╔╝ ██║ ██╔══╝ ██║${r}"
echo "${bold}${p}██║ ██║███████╗ ██║ ███████╗╚██████╗${r}"
echo "${bold}${y}╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝${r}"
echo
print_colored "${bold}Sandbox Codespace" "cyan"
print_colored "${bold}Your codespace is ready with your chosen box! 🎉" "cyan"
echo
print_colored "All the packages are already installed, and you can now run yarn dev or any other package.json script." "magenta"
print_colored "You can also use this codespace for its running sandbox, by connecting your local environment to it." "magenta"
echo
print_colored "To do so, set the PXE_URL to this codespace's sandbox URL:" "magenta"
print_colored "${PXE_URL}" "green"
print_colored "ex. PXE_URL=\"${PXE_URL}\" yarn dev"
echo
print_colored "${bold}Enjoy your sandbox! 🏖️" "orange"
22 changes: 17 additions & 5 deletions .devcontainer/token/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"onCreateCommand": "curl -s install.aztec.network | NON_INTERACTIVE=1 BIN_PATH=/usr/local/bin bash -s && echo 'y' | npx create-aztec-app -t contract -n token_contract -s && cd token_contract && yarn",
"postCreateCommand": "cd boxes && yarn && npx create-aztec-app -t contract -n token_contract -s",
"postAttachCommand": "(nohup /usr/local/bin/aztec sandbox &) && cd token_contract",
"onCreateCommand": ".devcontainer/scripts/onCreateCommand.sh contract token_contract",
"postAttachCommand": ".devcontainer/scripts/postAttachCommand.sh contract token_contract",
"customizations": {
"vscode": {
"settings": {},
"extensions": ["noir-lang.vscode-noir"]
}
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/token,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace"
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/token_contract,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace",
"hostRequirements": {
"cpus": 8,
"memory": "8gb",
"storage": "32gb"
},
"mounts": [
{
"source": "${localWorkspaceFolder}/.devcontainer/scripts",
"target": "/root/workspace/.devcontainer/scripts",
"type": "bind"
}
],
"forwardPorts": [8080]
}
21 changes: 17 additions & 4 deletions .devcontainer/vanilla/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
{
"name": "Vanilla JS/TS",
"name": "Vanilla Typescript App",
"image": "node:lts-bookworm",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"onCreateCommand": "curl -s install.aztec.network | NON_INTERACTIVE=1 BIN_PATH=/usr/local/bin bash -s && echo 'y' | npx create-aztec-app -t app -n vanilla -s && cd vanilla && yarn",
"postAttachCommand": "(nohup /usr/local/bin/aztec sandbox &) && cd vanilla",
"onCreateCommand": ".devcontainer/scripts/onCreateCommand.sh app vanilla",
"postAttachCommand": ".devcontainer/scripts/postAttachCommand.sh app vanilla",
"customizations": {
"vscode": {
"settings": {},
"extensions": ["noir-lang.vscode-noir"]
}
},
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/vanilla,target=/root/workspace,type=bind",
"workspaceFolder": "/root/workspace"
"workspaceFolder": "/root/workspace",
"hostRequirements": {
"cpus": 8,
"memory": "8gb",
"storage": "32gb"
},
"mounts": [
{
"source": "${localWorkspaceFolder}/.devcontainer/scripts",
"target": "/root/workspace/.devcontainer/scripts",
"type": "bind"
}
],
"forwardPorts": [8080]
}
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,5 @@
"**/l1-contracts/lib/**": true,
"**/barretenberg/cpp/build*/**": true
},
"workbench.editor.enablePreviewFromQuickOpen": true,
"cmake.sourceDirectory": "/Users/zpedro/Documents/GitHub/aztec-packages/barretenberg/cpp"
"cmake.sourceDirectory": "/mnt/user-data/adam/aztec-packages/barretenberg/cpp"
}
5 changes: 2 additions & 3 deletions boxes/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ if (optsKeys.length % 2) {
}

program.action(async (options) => {
console.log(options)
const { projectType, projectName, skipSandbox } = options;
// SETUP: Initialize global variables
await init(options);
Expand All @@ -116,8 +115,8 @@ program.action(async (options) => {

if (skipSandbox) return;
// STEP 2: Install the Sandbox
await sandboxInstallOrUpdate({ skipQuestion: sandbox });
await sandboxInstallOrUpdate({ skipQuestion: skipSandbox });
// STEP 3: Running the Sandbox
await sandboxRun({ skipQuestion: sandbox });
await sandboxRun({ skipQuestion: skipSandbox });
});
program.parse();
1 change: 1 addition & 0 deletions boxes/boxes/react/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
1 change: 1 addition & 0 deletions boxes/boxes/vanilla/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion boxes/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-aztec-app",
"packageManager": "[email protected]",
"version": "0.3.15",
"version": "0.3.16",
"type": "module",
"scripts": {
"compile": "yarn workspaces foreach -A -v run compile",
Expand Down

0 comments on commit 9613108

Please sign in to comment.