This article expand how webapp-zip.js works, please take a look into webapp-zip.js
webapp-zip.js is used to compress a gaia app into application.zip
which is in profile/webapps/APPNAME.gaiamobile.org/
since we have some rule to decide which files should be compressed.
- locales/ and locales.ini: if
GAIA_INLINE_LOCALES
orGAIA_CONCAT_LOCALES
is 1. - locales-obj: if
GAIA_CONCAT_LOCALES
is not 1 - shared/ and test/: always exclude.
If is HTML and used files in shared OR gaia_shared.json exists, and those files into zip.
we need to add file into zip without compression if zip property is specified in metadata.json
, it looks like:
{
external: false,
zip: {
no_compression: [
...
]
}
}
if file path is specified in no_compression
, the file should be added into zip without compression.
Since got files in shared directory which is included in certain HTML file, we also need to add them into zip from GAIA_DIR/shared directory. there are some types of file need to be copied: js, locales, resources, style and style_unstable and we also have some different rules to decide which files need to be copied:
- branding: if OFFICIAL is 1, file in "official" directory need to be copied, otherwise file in "unofficial" will be copied.
- localeFile: we need copy localeFile from
LOCALES_FILE
environment variable. - resource file with @(NUMBER)x: right resolution file will be copied into zip. e.g., if
GAIA_DEV_PIXELS_PER_PX
is 2, we need copy IMAGE_FILE@2x.png into zip. - ringtones: cusotmization ringtones will be copied if
DIST_DIR/ringtones
exists.
- system: add
DIST_DIR/power/
toresources/power/
if exists - wallpaper: add
DIST_DIR/wallpapers/
toresources/320x480/
if exists - homescreen: add
DIST_DIR/temp/apps/conf/singlevariantconf.json
tojs/singlevariantconf.json
if exists - communications: if
DIST_DIR/variant.json
exists- Generate a JSON and add to
resources/customization.json
- add resources into
resources/
- Generate a JSON and add to
- keyboard: add a localized manifest file into zip
use l10nManager.localize()
to localize manifest.webapp, *.ini & *.properties and replace original files in zip