Skip to content

Commit

Permalink
chore: adding wait-for-sandbox.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Apr 15, 2024
1 parent 847e15e commit 149a0d2
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 57 deletions.
7 changes: 4 additions & 3 deletions .devcontainer/react/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 0 additions & 16 deletions .devcontainer/token contract/devcontainer.json

This file was deleted.

18 changes: 18 additions & 0 deletions .devcontainer/token/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 0 additions & 16 deletions .devcontainer/vanilla js/devcontainer.json

This file was deleted.

17 changes: 17 additions & 0 deletions .devcontainer/vanilla/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion boxes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 5 additions & 2 deletions boxes/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const init = async ({ debug, github_token, version }) => {
program.option("-d, --debug", "output extra debugging");
program.option("-gh, --github_token <github_token>", "a github token");
program.option("-v, --version <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 <projectType>",
Expand All @@ -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
Expand Down
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.2.15",
"version": "0.3.15",
"type": "module",
"scripts": {
"compile": "yarn workspaces foreach -A -v run compile",
Expand Down
6 changes: 1 addition & 5 deletions boxes/scripts/steps/sandbox/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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({
Expand Down
23 changes: 11 additions & 12 deletions boxes/scripts/steps/sandbox/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
});
}
}

0 comments on commit 149a0d2

Please sign in to comment.