Skip to content

Commit

Permalink
Applanga Command Line Interface Version 1.0.89
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and Jenkins committed Aug 7, 2023
1 parent 8d599da commit 26ae191
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
*Applanga CLI Documentation:* <https://www.applanga.com/docs-integration/cli>
***

### Version 1.0.89 (7 Aug 2023)
#### Added
- Improved pull command to retrieve localization changes immediately
---

### Version 1.0.86 (7 Jul 2023)
#### Added
- Added `branch_id` description to the Documenation
Expand Down
134 changes: 68 additions & 66 deletions README.md

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def pull(ctx):
click.secho('There was a problem with the config file:\n%s\n' % str(e), err=True, fg='red')
return

projectVersion = api.getProjectVersion(debug=ctx.obj['DEBUG'])

all_app_languages = []
for target in config_file_data['app']['pull']['target']:
if 'language' not in target:
Expand All @@ -29,15 +31,14 @@ def pull(ctx):
continue

try:
all_app_languages = api.getAllAppLanguages(debug=ctx.obj['DEBUG'])
all_app_languages = api.getAllAppLanguages(projectVersion, debug=ctx.obj['DEBUG'])
except api.ApplangaRequestException as e:
click.echo('Result: "Error"')
click.secho('There was a problem getting the app languages:\n%s\n' % str(e), err=True, fg='red')
return

break


request_languages = []
for target in config_file_data['app']['pull']['target']:

Expand All @@ -63,6 +64,8 @@ def pull(ctx):

request_languages = [x for x in request_languages if x not in exclude_languages]

target['projectVersion'] = projectVersion

# Go through all the languages that should be downloaded
for language in request_languages:
target['language'] = language
Expand Down
6 changes: 5 additions & 1 deletion commands/pullSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def pullSource(ctx):
click.secho('There was a problem with the config file:\n%s\n' % str(e), err=True, fg='red')
return

projectVersion = api.getProjectVersion(debug=ctx.obj['DEBUG'])

all_app_languages = []
for target in config_file_data['app']['push']['source']:
if 'language' not in target:
Expand All @@ -29,7 +31,7 @@ def pullSource(ctx):
continue

try:
all_app_languages = api.getAllAppLanguages(debug=ctx.obj['DEBUG'])
all_app_languages = api.getAllAppLanguages(projectVersion, debug=ctx.obj['DEBUG'])
except api.ApplangaRequestException as e:
click.echo('Result: "Error"')
click.secho('There was a problem getting the app languages:\n%s\n' % str(e), err=True, fg='red')
Expand Down Expand Up @@ -62,6 +64,8 @@ def pullSource(ctx):

request_languages = [x for x in request_languages if x not in exclude_languages]

target['projectVersion'] = projectVersion

# Go through all the languages that should be downloaded
for language in request_languages:
target['language'] = language
Expand Down
31 changes: 29 additions & 2 deletions lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import re
import time
from lib import constants
from lib import config_file
from lib import files
Expand Down Expand Up @@ -88,6 +89,8 @@ def downloadFile(file_data, debug=False):
if 'key_prefix' in file_data:
request_data['removeKeyPrefix'] = file_data['key_prefix']

request_data['version'] = file_data['projectVersion']

response = makeRequest(data=request_data, api_path='/files', debug=debug)

except ApplangaRequestException as e:
Expand Down Expand Up @@ -300,7 +303,7 @@ def uploadFile(file_data, force=False, draft=False, debug=False):



def getAllAppLanguages(debug):
def getAllAppLanguages(projectVersion, debug):
"""Gets all the languages the app has defined
Args:
Expand All @@ -316,7 +319,8 @@ def getAllAppLanguages(debug):
'includeSrc': 'false',
'includeDescription' : 'false',
'includeStatus' : 'false',
'keepEmptyDataEntries' : 'true'
'keepEmptyDataEntries' : 'true',
'version': projectVersion
}

response = makeRequest(data=data, debug=debug)
Expand All @@ -329,6 +333,29 @@ def getAllAppLanguages(debug):



def getProjectVersion(debug):
"""Gets the latest project version
Args:
debug: Display debug output.
Returns:
Version number
"""
request_data = {
'timestamp': time.time()
}

response = makeRequest(data=request_data, api_path='/projectVersion', debug=debug)
response_data = response.json()

if 'appVersion' not in response_data:
return 0;

return response_data['appVersion'];



def makeRequest(data={}, api_path=None, access_token=None, upload_file=None, method='GET', debug=False, base_path=constants.API_BASE_PATH):
"""Makes a request to Applanga API.
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NUMBER = '1.0.86'
VERSION_NUMBER = '1.0.89'
APPLANGA_HOST = 'https://api.applanga.com'
API_BASE_PATH = '/v1/api'
CONFIG_FILE_NAME = '.applanga.json'
Expand Down

0 comments on commit 26ae191

Please sign in to comment.