App-tools is a bundle of tools that are useful for writing client applications. Currently it consists of the following tools:
- app-entity
- app-image
- app-strings
The app-tools use python3.9. This needs to be installed, which could be done with brew install [email protected]
on the Mac.
python3 -m pip install .
Any changes are only available for use after they have been installed using the previous command. Thus, if you change anything or change the branch, run this command again. It should be possible to install it with the -e
flag to remove the need for re-running this command, but this has only worked on Stefan's system (Mac) for now.
After that use pip to make package commands available from command line:
pip3.9 install App-tools
(NOTE that pipX in this case is pip3.9, because this is how it's installed on my Mac)
Check that installation went well:
[app-tools * master] app-entity -h
usage: app-entity [-h] {java,kotlin,swift,typescript} ...
Transform entities to models in n programming languages
positional arguments:
{java,kotlin,swift,typescript}
Supported writers
optional arguments:
-h, --help show this help message and exit
App-entity is a tool to generate boiler plate client code for apps that use an API based on Navajo Entities. It supports multiple client languages (writers) and new ones may be added. Depending on the target language, it will generate datamodel classes (objects), stubs for logic classes, and services to perform operations defined in the Entity API.
When running multiple times it will always replace the Service and Datamodel classes. The logic will not be updated because it could contain hand-crafted app logic which we cannot recreate (eg "isPlayer" -> roleId field equals "PLAYER").
The first argument should be which writer you want to use. See app-entity -h for all possible writers.
The tool displays all possible arguments when you run app-entity -h. Each writer can have different arguments. To check them out run eg. app-entity swift -h.
The -o argument expects a folder to which the generates source are written. Folder entries that do not exist are created.
The examples below show how the tool could be used:
app-entity swift \
--input "$GIT"/sportlink/scripts/entity/common/memberportal/app \
--output "$GIT"/sportlinked-app-ios/app/Sportlinked \
app-entity java \
--input "$GIT"/sportlink/scripts/entity/common/memberportal/app \
--output "$GIT"/sportlinked-app-android/app/src/main/java/com/dexels/sportlinked
app-entity typescript \
--input "$GIT"/sportlink/scripts/entity/common/clubweb \
--output "$GIT"/com.sportlink.club.web/src/@types/generated
App entity was build for Java and Objective-C. Currently we use it for Kotlin and Swift. The latter languages are more advanced and could simplify the generation tool. Currently we have what we call a Logic class so we can update the datamodel always without worries and have the logic in the logic class. In both languages we can extend classes without subclassing so we might get away with just creating the datamodels and added logic through extensions which would decrease the complexity of the generation script by a lot. Also Swift currently has automatic encoding and decoding build in the compile time. So we do not have to generate it anymore.
A tool to generate all the required images from one source called the app_spec.json
. The files referred to in this json need to exist relative to the json file.
app-image\
-s "../shared/app_spec.json"\
-p "ios"
This file states which platform receives which images and in what scales. Both platform has different scales and different locations the images needs to be put. Most important is the images
array.
Possible keys:
- The
basename
is a relative path in the shared directory to an actual image. - The
platforms
states which platform receives the images (eg ios/android). - The
targets
states which target will receive the image (eg ras, taronga). - The
size
is a string stating the size the lowest scale should be. For that point we scale up.
The placeholder_colormap
and the themes
keys should no longer be used. For iOS and Android development you can now use tint colors to style an image to a different colorset. This needs to be removed from the app-image toolset.
A tool to generate and combine all the strings defined using json files that will be set in the correct place for Android and iOS.
app-strings swift\
--platform ios\
--input "../shared/strings"\
--output "cashless-app-visitor-ios/Taronga/en.lproj/Localizable.strings"\
--default en\
--language en\
--target taronga
The order the files will be merged in is:
- strings-{default}.json
- strings-{language}.json
- strings-{target}.json
In other words, a definition in strings-{target}.json overrules one in strings-{language}.json and strings-{default}.json, and one in strings-{language}.json overrules the one in strings-{default}.json, if not specified in strings-{target}.json.