diff --git a/.env.dist b/.env.dist index 45f3d01..f81c20f 100644 --- a/.env.dist +++ b/.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 diff --git a/docs-src/configuration.md b/docs-src/configuration.md index 9f81e7d..5b1818e 100644 --- a/docs-src/configuration.md +++ b/docs-src/configuration.md @@ -3,28 +3,28 @@ In order to start using babelsheet, you have to configure your `.env.babelsheet` ## Configuration file ``` -CLIENT_ID= -CLIENT_SECRET= -SPREADSHEET_ID= -SPREADSHEET_NAME= -REFRESH_TOKEN= - -REDIRECT_URI=http://localhost:3000/oauth2callback -REDIS_HOST=redis -REDIS_PORT=6379 -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 ``` ### 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
How to get spreadsheet ID

@@ -33,7 +33,7 @@ LOGGING_LEVEL=debug

-`SPREADSHEET_NAME`* - sheet name +`BABELSHEET_SPREADSHEET_NAME`* - sheet name
How to get spreadsheet name

@@ -42,17 +42,17 @@ LOGGING_LEVEL=debug

-`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 @@ -91,24 +91,24 @@ LOGGING_LEVEL=debug

From previous view, select _Create credentials_.

![Screenshot](img/google-config/create-credentials.png)

Fill the form and click _Done_.

-

IMPORTANT! Remember to add `http://localhost:3000/oauth2callback` to 'Authorised redirect URIs', you can add any other redirect uri, later passing it as `REDIRECT_URI` in [.env.babelsheet file](#configuration-file).

+

IMPORTANT! Remember to add `http://localhost:3000/oauth2callback` to 'Authorised redirect URIs', you can add any other redirect uri, later passing it as `BABELSHEET_REDIRECT_URI` in [.env.babelsheet file](#configuration-file).

![Screenshot](img/google-config/add-credentials.png) -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`. If babelsheet is not installed, run `npm i -g babelsheet` to install.
- CLIENT_ID and CLIENT_SECRET as params + BABELSHEET_CLIENT_ID and BABELSHEET_CLIENT_SECRET as params

- 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 --client_secret `

diff --git a/docs-src/development.md b/docs-src/development.md index 64edebd..b4a92de 100644 --- a/docs-src/development.md +++ b/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: [ @@ -8,11 +8,11 @@ You can set order of `REFRESH_TOKEN` providers in `/src/services/producer/contai container.resolve('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'),` diff --git a/docs-src/services.md b/docs-src/services.md index bc8ca44..17afc65 100644 --- a/docs-src/services.md +++ b/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 @@ -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 @@ -22,7 +22,7 @@ To generate translations type: Remember to [create .env.babelsheet file](configuration.md#configuration-file) before generating translations. -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). +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). **Options**
@@ -88,31 +88,31 @@ Remember to [create .env.babelsheet file](configuration.md#configuration-file) b
--client_id

- 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))

--client_secret

- 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))

--spreadsheet_id

- 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))

--spreadsheet_name

- 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))

--spreadsheet_name

- 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))

@@ -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). @@ -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).