Skip to content

Commit

Permalink
Update documentation with BABELSHEET_ prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Blyszcz committed Sep 14, 2018
1 parent e9e9074 commit 16f87d6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 49 deletions.
21 changes: 11 additions & 10 deletions .env.dist
@@ -1,13 +1,14 @@
CLIENT_ID=
CLIENT_SECRET=
REDIRECT_URI=http://localhost:3000/oauth2callback
REFRESH_TOKEN=
REDIS_HOST=redis
REDIS_PORT=6379
SPREADSHEET_ID=
SPREADSHEET_NAME=
HOST=localhost
PORT=3000
BABELSHEET_CLIENT_ID=
BABELSHEET_CLIENT_SECRET=
BABELSHEET_SPREADSHEET_ID=
BABELSHEET_SPREADSHEET_NAME=
BABELSHEET_REFRESH_TOKEN=

BABELSHEET_REDIRECT_URI=http://localhost:3000/oauth2callback
BABELSHEET_REDIS_HOST=redis
BABELSHEET_REDIS_PORT=6379
BABELSHEET_HOST=localhost
BABELSHEET_PORT=3000
NODE_ENV=dev
APP_NAME=babelsheet-node
LOGGING_LEVEL=debug
Expand Down
52 changes: 26 additions & 26 deletions docs-src/configuration.md
Expand Up @@ -3,28 +3,28 @@ In order to start using babelsheet, you have to configure your `.env.babelsheet`
## Configuration file

```
CLIENT_ID=<GOOGLE-CLIENT-ID>
CLIENT_SECRET=<GOOGLE-CLIENT-SECRET>
SPREADSHEET_ID=<SPREADSHEET-ID>
SPREADSHEET_NAME=<SPREADSHEET-NAME>
REFRESH_TOKEN=<REFRESH-TOKEN>
REDIRECT_URI=http://localhost:3000/oauth2callback
REDIS_HOST=redis
REDIS_PORT=6379
HOST=localhost
PORT=3000
BABELSHEET_CLIENT_ID=<GOOGLE-CLIENT-ID>
BABELSHEET_CLIENT_SECRET=<GOOGLE-CLIENT-SECRET>
BABELSHEET_SPREADSHEET_ID=<SPREADSHEET-ID>
BABELSHEET_SPREADSHEET_NAME=<SPREADSHEET-NAME>
BABELSHEET_REFRESH_TOKEN=<REFRESH-TOKEN>
BABELSHEET_REDIRECT_URI=http://localhost:3000/oauth2callback
BABELSHEET_REDIS_HOST=redis
BABELSHEET_REDIS_PORT=6379
BABELSHEET_HOST=localhost
BABELSHEET_PORT=3000
NODE_ENV=dev
APP_NAME=babelsheet-node
LOGGING_LEVEL=debug
```

### Configuration options
`CLIENT_ID`* - client id received from Google ([see how to config](#configuring-google-spreadsheet-api))
`BABELSHEET_CLIENT_ID`* - client id received from Google ([see how to config](#configuring-google-spreadsheet-api))

`CLIENT_SECRET`* - client secret received from Google ([see how to config](#configuring-google-spreadsheet-api))
`BABELSHEET_CLIENT_SECRET`* - client secret received from Google ([see how to config](#configuring-google-spreadsheet-api))

`SPREADSHEET_ID`* - spreadsheet ID from spreadsheet URL
`BABELSHEET_SPREADSHEET_ID`* - spreadsheet ID from spreadsheet URL
<details>
<summary id="how-to-get-spreadsheet-id">How to get spreadsheet ID</summary>
<p>
Expand All @@ -33,7 +33,7 @@ LOGGING_LEVEL=debug
</p>
</details>

`SPREADSHEET_NAME`* - sheet name
`BABELSHEET_SPREADSHEET_NAME`* - sheet name
<details>
<summary id="how-to-get-spreadsheet-name">How to get spreadsheet name</summary>
<p>
Expand All @@ -42,17 +42,17 @@ LOGGING_LEVEL=debug
</p>
</details>

`REFRESH_TOKEN`* - refresh token ([see how to obtain](#generating-refresh-token))
`BABELSHEET_REFRESH_TOKEN`* - refresh token ([see how to obtain](#generating-refresh-token))

`REDIRECT_URI` - url to which user should be redirected after receiving refresh token
`BABELSHEET_REDIRECT_URI` - url to which user should be redirected after receiving refresh token

`REDIS_HOST` - host name of redis store
`BABELSHEET_REDIS_HOST` - host name of redis store

`REDIS_PORT` - port of redis store
`BABELSHEET_REDIS_PORT` - port of redis store

`HOST` - host name for winston
`BABELSHEET_HOST` - host name for winston

`PORT` - API port
`BABELSHEET_PORT` - API port

`NODE_ENV` - environment type

Expand Down Expand Up @@ -91,24 +91,24 @@ LOGGING_LEVEL=debug
<p>From previous view, select _Create credentials_.</p>
![Screenshot](img/google-config/create-credentials.png)
<p>Fill the form and click _Done_.</p>
<p><b>IMPORTANT! Remember to add `http://localhost:3000/oauth2callback` to 'Authorised redirect URIs'</b>, you can add any other redirect uri, later passing it as `REDIRECT_URI` in [.env.babelsheet file](#configuration-file).</p>
<p><b>IMPORTANT! Remember to add `http://localhost:3000/oauth2callback` to 'Authorised redirect URIs'</b>, you can add any other redirect uri, later passing it as `BABELSHEET_REDIRECT_URI` in [.env.babelsheet file](#configuration-file).</p>
![Screenshot](img/google-config/add-credentials.png)
</details>
4. You will be given Client ID and Client secret keys, use them in environment variables `CLIENT_ID` and `CLIENT_SECRET` in [`.env.babelsheet` file](#configuration-file).
4. You will be given Client ID and Client secret keys, use them in environment variables `BABELSHEET_CLIENT_ID` and `BABELSHEET_CLIENT_SECRET` in [`.env.babelsheet` file](#configuration-file).
5. You can get your [spreadsheet ID](#how-to-get-spreadsheet-id) and [spreadsheet name](#how-to-get-spreadsheet-name), then you will be ready to generate translations.

## Generating refresh token

1. To generate refresh token, you have to [configure Google Spreadsheet API](#configuring-google-spreadsheet-api) first.
2. When `CLIENT_ID` and `CLIENT_SECRET` are stored in `.env.babelsheet` file, you are ready to generate refresh-token.
2. When `BABELSHEET_CLIENT_ID` and `BABELSHEET_CLIENT_SECRET` are stored in `.env.babelsheet` file, you are ready to generate refresh-token.
3. Run `babelsheet init`.


<small>If babelsheet is not installed, run `npm i -g babelsheet` to install.</small>
<details>
<summary>CLIENT_ID and CLIENT_SECRET as params</summary>
<summary>BABELSHEET_CLIENT_ID and BABELSHEET_CLIENT_SECRET as params</summary>
<p>
You don't have to create .env.babelsheet file, you can pass CLIENT_ID and CLIENT_SECRET values as parameters to babelsheet:
You don't have to create .env.babelsheet file, you can pass BABELSHEET_CLIENT_ID and BABELSHEET_CLIENT_SECRET values as parameters to babelsheet:
`npm generate --client_id <yours-client-id> --client_secret <yours-client-secret>`
</p>
</details>
Expand Down
6 changes: 3 additions & 3 deletions docs-src/development.md
@@ -1,5 +1,5 @@
## Set refresh token read providers
You can set order of `REFRESH_TOKEN` providers in `/src/services/producer/container.ts` for producer, and in `/src/services/cli/container.ts` for CLI tool:
You can set order of `BABELSHEET_REFRESH_TOKEN` providers in `/src/services/producer/container.ts` for producer, and in `/src/services/cli/container.ts` for CLI tool:

```
readProviders: [
Expand All @@ -8,11 +8,11 @@ You can set order of `REFRESH_TOKEN` providers in `/src/services/producer/contai
container.resolve<InRedisStorage>('inRedisStorage'),
],
```
First .env.babelsheet file will be checked does it contain `REFRESH_TOKEN`, if not, next `data.json` file will be checked, and the last one will be redis storage. Feel free to change order of those providers, or creating new ones.
First .env.babelsheet file will be checked does it contain `BABELSHEET_REFRESH_TOKEN`, if not, next `data.json` file will be checked, and the last one will be redis storage. Feel free to change order of those providers, or creating new ones.


## Set refresh token write provider
You can set `REFRESH_TOKEN` write provider in `/src/services/cli/container.ts` for CLI tool, and in `/src/services/producer/container.ts` for producer. Notice that producer will only have ability to save `REFRESH_TOKEN` when you run it locally, not in docker container - browser window will be opened automatically.
You can set `BABELSHEET_REFRESH_TOKEN` write provider in `/src/services/cli/container.ts` for CLI tool, and in `/src/services/producer/container.ts` for producer. Notice that producer will only have ability to save `BABELSHEET_REFRESH_TOKEN` when you run it locally, not in docker container - browser window will be opened automatically.

`writeProvider: container.resolve<InEnvStorage>('inEnvStorage'),`

Expand Down
20 changes: 10 additions & 10 deletions docs-src/services.md
@@ -1,5 +1,5 @@
## CLI
Command line tool is used to obtain `REFRESH_TOKEN`, as well as to generate translations files.
Command line tool is used to obtain `BABELSHEET_REFRESH_TOKEN`, as well as to generate translations files.
Translations files are possible to generate in given formats:

- Android
Expand All @@ -12,7 +12,7 @@ To run command line tools, you need to install it first:
`npm i -g babelsheet`


If you want to obtain `REFRESH_TOKEN` then see [generating refresh token](configuration.md#generating-refresh-token) section.
If you want to obtain `BABELSHEET_REFRESH_TOKEN` then see [generating refresh token](configuration.md#generating-refresh-token) section.

### Generating translations files

Expand All @@ -22,7 +22,7 @@ To generate translations type:

Remember to [create .env.babelsheet file](configuration.md#configuration-file) before generating translations.

<small>If you wont provide `REFRESH_TOKEN` in `.env.babelsheet` file or `data.json` file, babelsheet will automatically open browser to create such token, and will save it in right storage - you can change read and write storages, check it [here](development.md#set-refresh-token-read-providers).</small>
<small>If you wont provide `BABELSHEET_REFRESH_TOKEN` in `.env.babelsheet` file or `data.json` file, babelsheet will automatically open browser to create such token, and will save it in right storage - you can change read and write storages, check it [here](development.md#set-refresh-token-read-providers).</small>

**Options**
<details>
Expand Down Expand Up @@ -88,31 +88,31 @@ Remember to [create .env.babelsheet file](configuration.md#configuration-file) b
<details>
<summary>--client_id</summary>
<p>
Client id received from Google. Overwrite .env.babelsheet `CLIENT_ID` value. ([see how to obtain](/../configuration#configuring-google-spreadsheet-api))
Client id received from Google. Overwrite .env.babelsheet `BABELSHEET_CLIENT_ID` value. ([see how to obtain](/../configuration#configuring-google-spreadsheet-api))
</p>
</details>
<details>
<summary>--client_secret</summary>
<p>
Client secret received from Google. Overwrite .env.babelsheet `CLIENT_SECRET` value. ([see how to obtain](/../configuration#configuring-google-spreadsheet-api))
Client secret received from Google. Overwrite .env.babelsheet `BABELSHEET_CLIENT_SECRET` value. ([see how to obtain](/../configuration#configuring-google-spreadsheet-api))
</p>
</details>
<details>
<summary>--spreadsheet_id</summary>
<p>
Spreadsheet ID from spreadsheet URL. Overwrite .env.babelsheet `SPREADSHEET_ID` value. ([see how to obtain](/../configuration#how-to-get-spreadsheet-id))
Spreadsheet ID from spreadsheet URL. Overwrite .env.babelsheet `BABELSHEET_SPREADSHEET_ID` value. ([see how to obtain](/../configuration#how-to-get-spreadsheet-id))
</p>
</details>
<details>
<summary>--spreadsheet_name</summary>
<p>
Sheet name. Overwrite .env.babelsheet `SPREADSHEET_NAME` value. ([see how to obtain](/../configuration#how-to-get-spreadsheet-name))
Sheet name. Overwrite .env.babelsheet `BABELSHEET_SPREADSHEET_NAME` value. ([see how to obtain](/../configuration#how-to-get-spreadsheet-name))
</p>
</details>
<details>
<summary>--spreadsheet_name</summary>
<p>
Url to which user should be redirected after receiving refresh token. Overwrite .env.babelsheet `REDIRECT_URI` value. ([see how to obtain](/../configuration/#how-to-get-spreadsheet-name))
Url to which user should be redirected after receiving refresh token. Overwrite .env.babelsheet `BABELSHEET_REDIRECT_URI` value. ([see how to obtain](/../configuration/#how-to-get-spreadsheet-name))
</p>
</details>
<details>
Expand All @@ -129,7 +129,7 @@ Remember to [create .env.babelsheet file](configuration.md#configuration-file) b
`babelsheet generate --format ios --path ./translations` - generates translations in iOS format in `./translations` folder.

## Producer
Producer is used to fetch translations file, convert it and then store it in a database. The process is wrapped in a scheduler which repeats the whole operation continuously every 5 minutes by default. Please note that if there are no proper environment variables such as `CLIENT_ID`, `CLIENT_SECRET` and `REFRESH_TOKEN` then producer wont be able to work properly. In such case it runs a command responsible for obtaining those keys.
Producer is used to fetch translations file, convert it and then store it in a database. The process is wrapped in a scheduler which repeats the whole operation continuously every 5 minutes by default. Please note that if there are no proper environment variables such as `BABELSHEET_CLIENT_ID`, `BABELSHEET_CLIENT_SECRET` and `BABELSHEET_REFRESH_TOKEN` then producer wont be able to work properly. In such case it runs a command responsible for obtaining those keys.

You can run Producer in docker container - see [Docker](docker.md).

Expand All @@ -141,7 +141,7 @@ If you want to run producer locally, first remember about [setting environment v

Producer should be working now.

You can change `REFRESH_TOKEN` read and write providers, check it [here](development.md#set-refresh-token-read-providers).
You can change `BABELSHEET_REFRESH_TOKEN` read and write providers, check it [here](development.md#set-refresh-token-read-providers).

You can also change translations storage from redis to file, check it [here](development.md#change-translations-storage-from-redis-to-file).

Expand Down

0 comments on commit 16f87d6

Please sign in to comment.