From c023f5dcdba0a477fb56fef72c28aed102593214 Mon Sep 17 00:00:00 2001 From: Shane Earley Date: Mon, 11 Dec 2023 14:00:31 -0500 Subject: [PATCH] Update prerequisites --- README.md | 129 +++++++++++++++++++++--------------------- scripts/root/check.ts | 36 ++++++------ 2 files changed, 83 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 677895d0..58b194d7 100644 --- a/README.md +++ b/README.md @@ -37,77 +37,83 @@ Get started contributing to Casimir's codebase. ### Prerequisites -Configure the following prerequisite global dependency versions. +Configure the following prerequisite global dependency versions: -1. [Docker (v24.x)](https://docs.docker.com/engine/install/). + 1. [Git (v2.x)](https://git-scm.com/downloads). -2. [Go (v1.20.x)](https://golang.org/doc/install). + > 🚩 **GitHub submodule support:** You also need to make sure to have at least one SSH authentication key on your GitHub account (for the git cloning of submodules within submodules). See [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account). -3. [Node.js (v18.x)](https://nodejs.org/en/download/). + 2. [Docker (v24.x)](https://docs.docker.com/engine/install). -4. [Optional: AWS CLI (v2.x)](https://aws.amazon.com/cli/) + 3. [Go (v1.20.x)](https://golang.org/doc/install). + + 4. [Node.js (LTS)](https://nodejs.org/en/download). + + > 🚩 **Using NVM**: Install [NVM](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) and run `nvm install --lts`. + + 5. [AWS CLI (v2.x)](https://aws.amazon.com/cli). > 🚩 **Consensus Networks team only**: Create an [AWS profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) named `consensus-networks-dev`. ### Setup -Clone the repository and checkout a new branch from develop. +Clone the repository and checkout a new branch from develop: -```zsh -git clone https://github.com/consensusnetworks/casimir.git -cd casimir -git checkout -b <"feature || bug || enhancement">/<"your-branch-name" develop -``` + ```zsh + git clone https://github.com/consensusnetworks/casimir.git + cd casimir + git checkout -b <"feature || bug || enhancement">/<"your-branch-name" develop + ``` We are using [npm workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces) to simplify monorepo development workflows while keeping project-wide resources accessible. The core commands are below. -Install all repository dependencies and build necessary types. +Install all repository dependencies and build necessary types: -```zsh -npm install -``` + ```zsh + npm install + ``` - > 🚩 To see output from a npm preinstall or postinstall script on `npm i`, run `npm i --foreground-scripts`. +Clean all repository dependencies and reinstall: -Clean all repository dependencies and reinstall. - -```zsh -npm run clean -``` + ```zsh + npm run clean + ``` -Install a dev dependency to the root. +Install a dev dependency to the root: -```zsh -npm install -D some-dev-dependency -``` + ```zsh + npm install -D some-dev-dependency + ``` -Install a dependency or dev dependency to a specific workspace. +Install a dependency or dev dependency to a specific workspace: -```zsh -# dependency -npm install some-dependency --workspace @casimir/<"workspace-name"> + ```zsh + # dependency + npm install some-dependency --workspace @casimir/<"workspace-name"> -# dev dependency -npm install -D some-dev-dependency --workspace @casimir/<"workspace-name"> -``` + # dev dependency + npm install -D some-dev-dependency --workspace @casimir/<"workspace-name"> + ``` ### Configure Customize and override the development environment configuration by creating a [.env](.env) file in the root directory. -**If you are on the Consensus Networks organization**, make sure your AWS CLI and profile are configured correctly. By default, the scripts look for the `consensus-networks-dev` named profile, but you can override the `AWS_PROFILE` name to be used in the [.env](.env) file. Regardless, the profile must have access to the `consensus-networks-dev` account resources. +**If you are on the Consensus Networks organization**, make sure your AWS CLI and profile are configured correctly. By default, the scripts look for the `consensus-networks-dev` named profile, but you can override the `AWS_PROFILE` name to be used in the [.env](.env) file. Optionally, override the `AWS_PROFILE` name in your [.env](.env) file: -```zsh -# From the root directory -echo "AWS_PROFILE=<"your-aws-profile-name">" > .env -``` + ```zsh + # From the root directory + echo "AWS_PROFILE=<"your-aws-profile-name">" > .env + ``` -**If you are outside of the Consensus Networks organization**, make sure to set `USE_SECRETS` to `false`. + > 🚩 The AWS CLI profile must have command-line access to the `consensus-networks-dev` account resources. -```zsh -# From the root directory -echo "USE_SECRETS=false" > .env -``` +**If you are outside of the Consensus Networks organization**, set `USE_SECRETS` to `false` in your [.env](.env) file: + + ```zsh + # From the root directory + echo "USE_SECRETS=false" > .env + ``` #### Environment Variables @@ -133,18 +139,18 @@ The apps packages provide a UI to end-users. #### @casimir/app -Run the web app with an integrated development environment, including local contracts and services. +Run the main web app with an integrated development environment, including local contracts and services: -```zsh -# From the root directory -npm run dev -``` + ```zsh + # From the root directory + npm run dev + ``` See the [@casimir/app README.md](apps/app/README.md) for detailed documentation. #### @casimir/www -Run the www app. +Run the landing page app. ```zsh # From the root directory @@ -159,19 +165,12 @@ The contracts packages provide the smart contracts for the project. #### @casimir/ethereum -Test the Ethereum contracts. +Test the Ethereum contracts: -```zsh -# From the root directory -npm run test --workspace @casimir/ethereum -``` - -Fork the Ethereum contracts to local network and simulate events and oracle handling. - -```zsh -# From the root directory -npm run dev --workspace @casimir/ethereum -``` + ```zsh + # From the root directory + npm run test --workspace @casimir/ethereum + ``` See the [@casimir/ethereum README.md](contracts/ethereum/README.md) for detailed documentation. @@ -194,12 +193,12 @@ The infrastructure packages provide the infrastructure as code for the project. #### @casimir/cdk -Test the CDK infrastructure. +Test the CDK infrastructure: -```zsh -# From the root directory -npm run test:cdk -``` + ```zsh + # From the root directory + npm run test:cdk + ``` See the [@casimir/cdk README.md](infrastructure/cdk/README.md) for detailed documentation. diff --git a/scripts/root/check.ts b/scripts/root/check.ts index 43d4ec7c..4bbeec81 100644 --- a/scripts/root/check.ts +++ b/scripts/root/check.ts @@ -6,20 +6,6 @@ import fs from "fs" */ void async function () { if (process.env.CI !== "true") { - const docker = await run("docker --version") as string - try { - const dockerSplit = docker.split(" ") - const dockerNumber = dockerSplit[2] - const dockerNumberSplit = dockerNumber.split(".") - const dockerMajor = parseInt(dockerNumberSplit[0]) - if (dockerMajor < 24) { - throw new Error("🚩 Incompatible docker version") - } - } catch (error) { - console.error(error.message) - throw new Error("🚩 Please install docker 24.x (see https://github.com/consensusnetworks/casimir#prerequisites #1)") - } - const submodules = fs.readFileSync(".gitmodules", "utf8") const submoduleDirs = submodules.match(/path = (.*)/g)?.map((path) => path.replace("path = ", "")) if (submoduleDirs) { @@ -32,10 +18,24 @@ void async function () { } } catch (error) { console.error(error.message) - throw new Error("🚩 Please add an ssh key for submodules (see https://github.com/consensusnetworks/casimir#prerequisites #2)") + throw new Error("🚩 Please add an ssh key for submodules (see https://github.com/consensusnetworks/casimir#prerequisites #1)") } } + const docker = await run("docker --version") as string + try { + const dockerSplit = docker.split(" ") + const dockerNumber = dockerSplit[2] + const dockerNumberSplit = dockerNumber.split(".") + const dockerMajor = parseInt(dockerNumberSplit[0]) + if (dockerMajor < 24) { + throw new Error("🚩 Incompatible docker version") + } + } catch (error) { + console.error(error.message) + throw new Error("🚩 Please install docker 24.x (see https://github.com/consensusnetworks/casimir#prerequisites #2)") + } + const go = await run("go version") as string try { if (!go.includes("1.20")) { @@ -48,12 +48,14 @@ void async function () { try { const node = await run("node --version") as string - if (!node.includes("v18")) { + const nodeLtsList = (await run("nvm ls-remote --lts") as string).split("\n") + const nodeLts = nodeLtsList[nodeLtsList.length - 1].split(" ")[0] + if (!nodeLts.includes(node)) { throw new Error("🚩 Incompatible node version") } } catch (error) { console.error(error.message) - throw new Error("🚩 Please install node v18.x (see https://github.com/consensusnetworks/casimir#prerequisites #4)") + throw new Error("🚩 Please install node LTS (see https://github.com/consensusnetworks/casimir#prerequisites #4)") } } }() \ No newline at end of file