1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | const chalk = require( 'chalk' );
|
11 |
|
12 | const task = process.argv[ 2 ];
|
13 |
|
14 | const tasks = {
|
15 | |
16 |
|
17 |
|
18 | collect() {
|
19 | const collectTranslations = require( './../lib/translations/collect' );
|
20 |
|
21 | collectTranslations();
|
22 | },
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | upload() {
|
30 | const uploadTranslations = require( './../lib/translations/upload' );
|
31 | const getToken = require( './../lib/translations/gettoken' );
|
32 |
|
33 | return getToken()
|
34 | .then( credentials => uploadTranslations( credentials ) );
|
35 | },
|
36 |
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 | download() {
|
43 | const downloadTranslations = require( './../lib/translations/download' );
|
44 | const getToken = require( './../lib/translations/gettoken' );
|
45 |
|
46 | return getToken()
|
47 | .then( credentials => downloadTranslations( credentials ) );
|
48 | }
|
49 | };
|
50 |
|
51 | const taskNames = Object.keys( tasks );
|
52 |
|
53 | if ( !task || !tasks[ task ] ) {
|
54 | console.log( `Please provide valid task name. Available tasks: ${ taskNames.map( task => chalk.bold( task ) ).join( ', ' ) }.` );
|
55 |
|
56 | process.exit( 1 );
|
57 | }
|
58 |
|
59 | tasks[ task ]();
|