diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index ded9059c3c..88b72eb170 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -44,15 +44,21 @@ And of course our premier language is [Typescript](https://www.typescriptlang.or ## Local development -1. Prepare your environment variables: - - clone `.env.example` into `configs/envs/.env.secrets` and fill it with necessary secrets for the [external services](./ENVS.md#external-services-configuration) integration; you can pick up only those that your needed - - choose one of the following options: - A. create `.env.local` file in the root folder with environment variables from the [list](./ENVS.md); all required variables should be present in the file; - B. pick up one of the predefined configurations located at `/configs/envs` folder; no actual action is needed at this stage; -2. Run your local dev server: - - if you picked up option "A" above, use `yarn dev` command - - if your options is "B", use `yarn dev:` command -3. In browser navigate to the URL from the command output (by default, it is `http://localhost:3000`) +To develop locally, follow one of the two paths outlined below: + +A. Custom configuration: + +1. Create `.env.local` file in the root folder and include all required environment variables from the [list](./ENVS.md) +2. Optionally, clone `.env.example` and name it `.env.secrets`. Fill it with necessary secrets for integrating with [external services](./ENVS.md#external-services-configuration). Include only secrets your need. +3. Use `yarn dev` command to start the dev server. +4. Open your browser and navigate to the URL provided in the command line output (by default, it is `http://localhost:3000`). + +B. Pre-defined configuration: + +1. Optionally, clone `.env.example` file into `configs/envs/.env.secrets`. Fill it with necessary secrets for integrating with [external services](./ENVS.md#external-services-configuration). Include only secrets your need. +2. Choose one of the predefined configurations located in the `/configs/envs` folder. +3. Start your local dev server using the `yarn dev:` command. +4. Open your browser and navigate to the URL provided in the command line output (by default, it is `http://localhost:3000`).   diff --git a/package.json b/package.json index 918c4419f3..7d96b46026 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "npm": "8" }, "scripts": { - "dev": "next dev", + "dev": "./tools/scripts/dev.sh", "dev:preset": "./tools/scripts/dev.preset.sh", "build": "next build", "build:docker": "docker build --build-arg GIT_COMMIT_SHA=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0) -t blockscout-frontend:local ./", diff --git a/tools/scripts/dev.preset.sh b/tools/scripts/dev.preset.sh index 1110089f72..37e01e3f38 100755 --- a/tools/scripts/dev.preset.sh +++ b/tools/scripts/dev.preset.sh @@ -14,11 +14,6 @@ if [ ! -f "$config_file" ]; then exit 1 fi -if [ ! -f "$secrets_file" ]; then - echo "Error: File '$secrets_file' not found." - exit 1 -fi - # download assets for the running instance dotenv \ -e $config_file \ diff --git a/tools/scripts/dev.sh b/tools/scripts/dev.sh new file mode 100755 index 0000000000..a01e2af95f --- /dev/null +++ b/tools/scripts/dev.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# download assets for the running instance +dotenv \ + -e .env.development.local \ + -e .env.local \ + -e .env.development \ + -e .env \ + -- bash -c './deploy/scripts/download_assets.sh ./public/assets' + +# generate envs.js file and run the app +dotenv \ + -v NEXT_PUBLIC_GIT_COMMIT_SHA=$(git rev-parse --short HEAD) \ + -v NEXT_PUBLIC_GIT_TAG=$(git describe --tags --abbrev=0) \ + -e .env.secrets \ + -e .env.development.local \ + -e .env.local \ + -e .env.development \ + -e .env \ + -- bash -c './deploy/scripts/make_envs_script.sh && next dev -- -p $NEXT_PUBLIC_APP_PORT' | +pino-pretty \ No newline at end of file