Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config CLI #994

Merged
merged 11 commits into from
Jan 17, 2019
3 changes: 1 addition & 2 deletions .env-template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Note: You also need to set Stripe secret key in Flex Console.
#
REACT_APP_SHARETRIBE_SDK_CLIENT_ID=
REACT_APP_SHARETRIBE_SDK_CLIENT_ID=change-me
REACT_APP_STRIPE_PUBLISHABLE_KEY=
REACT_APP_MAPBOX_ACCESS_TOKEN=

Expand Down Expand Up @@ -32,7 +32,6 @@ REACT_APP_ENV=production
# BASIC_AUTH_USERNAME=sharetribe
# BASIC_AUTH_PASSWORD=secret
# REACT_APP_GOOGLE_ANALYTICS_ID=change-me
# REACT_APP_SHARETRIBE_SDK_BASE_URL=change-me


# Features
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2019-XX-XX

- [add] Add CLI tool for creating .env file and setting up the environment variables.
[#994](https://github.com/sharetribe/flex-template-web/pull/994)
- [change] Change from Raven to Sentry SDKs for browser and Node.js to version 4.5.1. With the new
SDKs only one DSN needs to be configured so update also environment variables and documentation
related to Sentry. [#999](https://github.com/sharetribe/flex-template-web/pull/999)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ If you just want to get the app running quickly to test it out, first install
```sh
git clone [email protected]:sharetribe/flex-template-web.git # clone this repository
cd flex-template-web/ # change to the cloned directory
cp .env-template .env # copy the env template file to add your local config
emacs .env # in your favorite editor, add the mandatory env vars to the config
yarn install # install dependencies
yarn run config # add the mandatory env vars to your local config
yarn run dev # start the dev server, this will open a browser in localhost:3000
```

Expand Down
19 changes: 11 additions & 8 deletions docs/customization-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,24 @@ In the `master` branch (or in the branch you want to merge in the upstream chang

See also the [Syncing a fork](https://help.github.com/articles/syncing-a-fork/) documentation.

## Installing dependecies

In your project root, install dependencies:

yarn install

## Configuration

There are some mandatory configuration, and some configuration that you most likely want to at least
go through.

To get started, first copy the config template:
To get started, run:

cp .env-template .env
yarn run config

The `.env` file is the place to add your local configuration. It is ignored in Git, so you'll have
to add the corresponding configuration also to your server environment.
This command will create `.env` file and guide you trough setting up the required environment
variables. The `.env` file is the place to add your local configuration. It is ignored in Git, so
you'll have to add the corresponding configuration also to your server environment.

There are some mandatory configuration variables that are defined in the template. See the
[Environment configuration variables](env.md) documentation for more information.
Expand All @@ -99,10 +106,6 @@ See also the [src/config.js](../src/config.js) file for more configuration optio

## Development

In your project root, install dependencies:

yarn install

To develop the application and to see changes live, start the frontend development server:

yarn run dev
Expand Down
5 changes: 3 additions & 2 deletions docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ them have defaults that work for development environment. For production deploys
## Defining configuration

When the app is started locally with `yarn run dev` or `yarn run dev-server`, you can set
environment variables by using the (gitignored) `.env` file. The repository contains a template file
`.env-template` with default configuration. Just copy that as `.env` and edit as necessary.
environment variables by using the (gitignored) `.env` file. You can edit the basic variables via
`yarn run config` or by editing directly the .env file. Some variables can be edited only in the
.env file. The repository contains a template file `.env-template` with default configuration.

In production, it's recommended that you set the configuration via env variables and do not deploy
an .env file. The client application will only be packaged with env variables that start with
Expand Down
8 changes: 4 additions & 4 deletions docs/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ In case you have added a new language translation file and are pulling translati
in sync. Running the following command in the project root

```
node translations.js
yarn run translate
```

will start a command line application:
Expand All @@ -189,8 +189,8 @@ will start a command line application:
The command line application can be used to match a translation file against the English
translations. If your new translations file follows the `<LANG CODE>.json` naming, the CLI will pick
it up automatically. In order to improve readability, you can add the language name to the
`TARGET_LANG_NAMES` map in `translations.js` if it is not yet in there and the CLI will use the
correct name for your language instead of the language code when prompting about translations.
`TARGET_LANG_NAMES` map in `scripts/translations.js` if it is not yet in there and the CLI will use
the correct name for your language instead of the language code when prompting about translations.

In case you wish to use something else than English as the source language, modify the `SOURCE_LANG`
object in `translations.js` to match your needs.
object in `scripts/translations.js` to match your needs.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
},
"scripts": {
"clean": "rm -rf build/*",
"dev": "sharetribe-scripts start",
"config": "node scripts/config.js",
"dev": "node scripts/config.js --check && sharetribe-scripts start",
"build": "sharetribe-scripts build",
"format": "prettier --write '**/*.{js,css}'",
"format-ci": "prettier --list-different '**/*.{js,css}'",
Expand All @@ -76,7 +77,8 @@
"eject": "sharetribe-scripts eject",
"start": "node server/index.js",
"dev-server": "export NODE_ENV=development PORT=4000 REACT_APP_CANONICAL_ROOT_URL=http://localhost:4000&&yarn run build&&nodemon --watch server server/index.js",
"heroku-postbuild": "yarn run build"
"heroku-postbuild": "yarn run build",
"translate": "node scripts/translations.js"
},
"prettier": {
"singleQuote": true,
Expand Down
Loading