Skip to content

Commit

Permalink
Allow to use per project tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbo committed Nov 27, 2017
1 parent 4e84766 commit 5f2a00c
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 21 deletions.
44 changes: 30 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@ Simply install via [yarn](https://yarnpkg.com) package manager:

## Usage

```
$ node_modules/.bin/yata-fetch [options]
```

Options:

* `config` (string, optional, default: yata.json) - path to json config file.
* `locale` - if you like you can generate only one locale instead whole
stack from config file

### Setup

Example:
* Create config file in project folder (see details below).
* Add `MY_YATA_API_TOKEN` key to env variables in `.zshrc/.bashrc`:

```
node_modules/.bin/yata-fetch --config config.json --locale en_US
export MY_YATA_API_TOKEN=XXXX
```

### Config file
You can check token in your organization settings.

Example `yata.json` file should look like this:

### Configuration file

Example `yata.json` file:

```
{
"token": "MY_YATA_API_TOKEN",
"project": "1",
"locales": [
"en_US", "de_DE"
Expand All @@ -45,6 +41,7 @@ Example `yata.json` file should look like this:
}
```

* `token` (string, required) - name of ENV variable containing API token
* `project` (string, required) - ID of the project
* `locales` (array, required) - locales to generate
* `format` (string, optional, default: yml) - output file format
Expand All @@ -53,6 +50,25 @@ Example `yata.json` file should look like this:
* `outputPath` (string, optional, default: './translations') - path where
files will be generated

### Fetching translations

```
$ node_modules/.bin/yata-fetch [options]
```

Options:

* `config` (string, optional, default: yata.json) - path to json config file.
* `locale` - if you like you can generate only one locale instead whole
stack from config file


Example:

```
node_modules/.bin/yata-fetch --config config.json --locale en_US
```

## Problems?

* Open an Issue
Expand Down
2 changes: 1 addition & 1 deletion dist/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cli.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/yata.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/yata.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = async function() {

try {
if (yata.validateConfig(
nconf.get('YATA_API_TOKEN'),
nconf.get(nconf.get('token')),
nconf.get('project'),
nconf.get('locales'),
nconf.get('format'),
Expand Down
2 changes: 1 addition & 1 deletion src/yata.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {

validateConfig(token, project, locales, format, root, outputPath) {
if (!token) {
throw new Error('No `YATA_API_TOKEN` in ENV');
throw new Error('No `token` in ENV');
} else {
this.token = token;
}
Expand Down
Loading

0 comments on commit 5f2a00c

Please sign in to comment.