From 149a0d284291b32837099a43072433f0305c2335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Mon, 15 Apr 2024 17:52:41 +0100 Subject: [PATCH] chore: adding wait-for-sandbox.sh script --- .devcontainer/react/devcontainer.json | 7 +++--- .../token contract/devcontainer.json | 16 ------------- .devcontainer/token/devcontainer.json | 18 +++++++++++++++ .devcontainer/vanilla js/devcontainer.json | 16 ------------- .devcontainer/vanilla/devcontainer.json | 17 ++++++++++++++ .vscode/settings.json | 3 ++- boxes/README.md | 2 +- boxes/bin.js | 7 ++++-- boxes/package.json | 2 +- boxes/scripts/steps/sandbox/install.js | 6 +---- boxes/scripts/steps/sandbox/run.js | 23 +++++++++---------- 11 files changed, 60 insertions(+), 57 deletions(-) delete mode 100644 .devcontainer/token contract/devcontainer.json create mode 100644 .devcontainer/token/devcontainer.json delete mode 100644 .devcontainer/vanilla js/devcontainer.json create mode 100644 .devcontainer/vanilla/devcontainer.json diff --git a/.devcontainer/react/devcontainer.json b/.devcontainer/react/devcontainer.json index a3a46fb1935..d384cec9126 100644 --- a/.devcontainer/react/devcontainer.json +++ b/.devcontainer/react/devcontainer.json @@ -1,16 +1,17 @@ { + "name": "React App", "image": "node:lts-bookworm", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, - "onCreateCommand": "cd boxes && yarn", - "postCreateCommand": "cd boxes && (nohup npx . -t app -n react -s &) && bash", + "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", "customizations": { "vscode": { "settings": {}, "extensions": ["noir-lang.vscode-noir"] } }, - "workspaceMount": "source=${localWorkspaceFolder},target=/root/workspace,type=bind", + "workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/react,target=/root/workspace,type=bind", "workspaceFolder": "/root/workspace" } diff --git a/.devcontainer/token contract/devcontainer.json b/.devcontainer/token contract/devcontainer.json deleted file mode 100644 index ff52da41f0e..00000000000 --- a/.devcontainer/token contract/devcontainer.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "image": "node:lts-bookworm", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {} - }, - "onCreateCommand": "cd boxes && yarn", - "postCreateCommand": "cd boxes && (nohup npx . -t contract -n token_contract -s &) && bash", - "customizations": { - "vscode": { - "settings": {}, - "extensions": ["noir-lang.vscode-noir"] - } - }, - "workspaceMount": "source=${localWorkspaceFolder},target=/root/workspace,type=bind", - "workspaceFolder": "/root/workspace" -} diff --git a/.devcontainer/token/devcontainer.json b/.devcontainer/token/devcontainer.json new file mode 100644 index 00000000000..974938edbd0 --- /dev/null +++ b/.devcontainer/token/devcontainer.json @@ -0,0 +1,18 @@ +{ + "name": "Token Contract Only", + "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 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", + "customizations": { + "vscode": { + "settings": {}, + "extensions": ["noir-lang.vscode-noir"] + } + }, + "workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/token,target=/root/workspace,type=bind", + "workspaceFolder": "/root/workspace" +} diff --git a/.devcontainer/vanilla js/devcontainer.json b/.devcontainer/vanilla js/devcontainer.json deleted file mode 100644 index 9abbc012804..00000000000 --- a/.devcontainer/vanilla js/devcontainer.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "image": "node:lts-bookworm", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {} - }, - "onCreateCommand": "cd boxes && yarn", - "postCreateCommand": "cd boxes && (nohup npx . -t app -n vanilla -s &) && bash", - "customizations": { - "vscode": { - "settings": {}, - "extensions": ["noir-lang.vscode-noir"] - } - }, - "workspaceMount": "source=${localWorkspaceFolder},target=/root/workspace,type=bind", - "workspaceFolder": "/root/workspace" -} diff --git a/.devcontainer/vanilla/devcontainer.json b/.devcontainer/vanilla/devcontainer.json new file mode 100644 index 00000000000..a293161a54f --- /dev/null +++ b/.devcontainer/vanilla/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "Vanilla JS/TS", + "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", + "customizations": { + "vscode": { + "settings": {}, + "extensions": ["noir-lang.vscode-noir"] + } + }, + "workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/vanilla,target=/root/workspace,type=bind", + "workspaceFolder": "/root/workspace" +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 38503f995b7..bdf60c8c40b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -170,5 +170,6 @@ "**/l1-contracts/lib/**": true, "**/barretenberg/cpp/build*/**": true }, - "workbench.editor.enablePreviewFromQuickOpen": true + "workbench.editor.enablePreviewFromQuickOpen": true, + "cmake.sourceDirectory": "/Users/zpedro/Documents/GitHub/aztec-packages/barretenberg/cpp" } diff --git a/boxes/README.md b/boxes/README.md index c86e754a29f..67cf195e9ed 100644 --- a/boxes/README.md +++ b/boxes/README.md @@ -16,7 +16,7 @@ If you have [node](https://nodejs.org/en/download) installed, you can open a ter or -`npm create aztec-app` +`npx create-aztec-app` The script will install the sandbox, run it, and clone the boilerplate you chose. You can pass some options: diff --git a/boxes/bin.js b/boxes/bin.js index 8bc4847bf7d..3de6d5ecbd9 100755 --- a/boxes/bin.js +++ b/boxes/bin.js @@ -86,7 +86,7 @@ const init = async ({ debug, github_token, version }) => { program.option("-d, --debug", "output extra debugging"); program.option("-gh, --github_token ", "a github token"); program.option("-v, --version ", "a version number or master tag"); -program.option("-s, --sandbox", "install and run sandbox after cloning"); +program.option("-s, --skip-sandbox", "install and run sandbox after cloning"); program.option( "-t, --project-type ", @@ -107,11 +107,14 @@ if (optsKeys.length % 2) { } program.action(async (options) => { - const { projectType, projectName, sandbox } = options; + console.log(options) + const { projectType, projectName, skipSandbox } = options; // SETUP: Initialize global variables await init(options); // STEP 1: Choose the boilerplate await chooseProject({ projectType, projectName }); + + if (skipSandbox) return; // STEP 2: Install the Sandbox await sandboxInstallOrUpdate({ skipQuestion: sandbox }); // STEP 3: Running the Sandbox diff --git a/boxes/package.json b/boxes/package.json index b782ec6ec55..78525b35c9f 100644 --- a/boxes/package.json +++ b/boxes/package.json @@ -1,7 +1,7 @@ { "name": "create-aztec-app", "packageManager": "yarn@4.1.0", - "version": "0.2.15", + "version": "0.3.15", "type": "module", "scripts": { "compile": "yarn workspaces foreach -A -v run compile", diff --git a/boxes/scripts/steps/sandbox/install.js b/boxes/scripts/steps/sandbox/install.js index 33162c08fcd..7448b2e359c 100644 --- a/boxes/scripts/steps/sandbox/install.js +++ b/boxes/scripts/steps/sandbox/install.js @@ -84,7 +84,7 @@ function findOutUserVersion() { return sandboxVersion; } -export async function sandboxInstallOrUpdate({ skipQuestion }) { +export async function sandboxInstallOrUpdate() { // Checking for docker try { execSync("docker info >/dev/null 2>&1"); @@ -98,10 +98,6 @@ export async function sandboxInstallOrUpdate({ skipQuestion }) { // Let's get which version of the sandbox the user has installed const sandboxVersion = findOutUserVersion(); - if (skipQuestion) { - await installSandbox(); - return; - } // Base case is that the user doesn't have the sandbox installed if (sandboxVersion == null) { const answer = await confirm({ diff --git a/boxes/scripts/steps/sandbox/run.js b/boxes/scripts/steps/sandbox/run.js index ce87f76f4d5..e857f0515fa 100644 --- a/boxes/scripts/steps/sandbox/run.js +++ b/boxes/scripts/steps/sandbox/run.js @@ -2,7 +2,7 @@ import confirm from "@inquirer/confirm"; import { execSync } from "child_process"; import axios from "axios"; -export async function sandboxRun({ skipQuestion }) { +export async function sandboxRun() { spinner.text = "Trying to reach the sandbox..."; try { @@ -24,18 +24,17 @@ export async function sandboxRun({ skipQuestion }) { process.exit(0); } catch (error) { spinner.fail(); - if (!skipQuestion) { - const answer = await confirm({ - message: - "Sandbox can't be reached on localhost:8080. Do you want to start it?", - default: true, + const answer = await confirm({ + message: + "Sandbox can't be reached on localhost:8080. Do you want to start it?", + default: true, + }); + if (answer) { + info("Starting the sandbox... This might take a few minutes."); + info(`Go and explore the boilerplate code while you wait!`); + execSync(`$HOME/.aztec/bin/aztec sandbox`, { + stdio: "inherit", }); - if (answer) process.exit(0); } - info("Starting the sandbox... This might take a few minutes."); - info(`Go and explore the boilerplate code while you wait!`); - execSync(`$HOME/.aztec/bin/aztec sandbox`, { - stdio: "inherit", - }); } }