diff --git a/.travis.yml b/.travis.yml index 60d343646..7e5fad749 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,99 @@ os: linux dist: bionic group: edge - language: node_js node_js: 11 +android: + components: + - tools + - platform-tools + - build-tools-29.0.3 + - android-28 + - extra-google-google_play_services + - extra-google-m2repository + - extra-android-m2repository + +git: + depth: 3 + before_cache: - rm -rf $HOME/.cache/electron-builder/wine + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ cache: directories: - $HOME/.npm - $HOME/.cache/electron - $HOME/.cache/electron-builder + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + - $HOME/.android/build-cache before_script: - - npm install npm@latest -g + - if [ "$TRAVIS_OS_NAME" != 'windows' ] ; then npm install npm@latest -g ; fi - gulp -script: - - npm run build --bailOnLintError true --typeCheckOnLint true - -after_success: - - scripts/ci.sh +jobs: + include: + - stage: check + if: NOT branch =~ /(master$|integration$|desktop)/ + os: linux + script: npm run build --bailOnLintError true --typeCheckOnLint true + - stage: mirror + if: branch IN (master, integration, desktop) AND repo = moodlehq/moodleapp + os: linux + script: scripts/mirror.sh + - stage: prepare + if: branch =~ /(master$|integration)/ AND env(PREPARE) IS present AND env(PREPARE) = 1 + os: linux + script: scripts/aot.sh + - stage: build + name: "Build Android" + if: env(DEPLOY) IS present AND (env(DEPLOY) = 1 AND NOT branch = desktop) OR (env(DEPLOY) IN (2,3) AND tag IS present) + os: linux + dist: trusty + group: edge + language: android + before_install: + - nvm install 11 + - node --version + - npm --version + - nvm --version + - npm ci + - npm install -g gulp + script: scripts/aot.sh + - stage: build + name: "Build iOS" + if: env(DEPLOY) IS present AND (env(DEPLOY) = 1 AND NOT branch = desktop) OR (env(DEPLOY) IN (2,3) AND tag IS present) + os: osx + osx_image: xcode11.3 + script: scripts/aot.sh + - stage: build + name: "Build Linux" + if: env(DEPLOY) IS present AND (env(DEPLOY) = 1 AND branch = desktop) OR (env(DEPLOY) = 3 AND tag IS present) + os: linux + env: + - ELECTRON_CACHE=$HOME/.cache/electron + - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder + script: scripts/aot.sh + - stage: build + name: "Build MacOS" + if: env(DEPLOY) IS present AND (env(DEPLOY) = 1 AND branch = desktop) OR (env(DEPLOY) = 3 AND tag IS present) + os: osx + osx_image: xcode11.3 + env: + - ELECTRON_CACHE=$HOME/.cache/electron + - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder + script: scripts/aot.sh + - stage: build + name: "Build Windows" + if: env(DEPLOY) IS present AND (env(DEPLOY) = 1 AND branch = desktop) OR (env(DEPLOY) = 3 AND tag IS present) + os: windows + env: + - ELECTRON_CACHE=$HOME/.cache/electron + - ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder + - ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true + - DEBUG=electron-windows-store + script: scripts/aot.sh diff --git a/config.xml b/config.xml index b3b791ea8..4a19fb28a 100644 --- a/config.xml +++ b/config.xml @@ -1,49 +1,71 @@ - + Moodle Moodle official app Moodle Mobile team + + + + + + + - - - - + + + + - - + + - + + + + + + + + + @@ -51,11 +73,33 @@ + + + + + + + + + + + + + + + + + + @@ -65,57 +109,403 @@ We need your location so you can attach it as part of your submissions. + + We need camera access to take pictures so you can attach them as part of your submissions. + + + We need microphone access to record sounds so you can attach them as part of your submissions. + + + We need photo library access to get pictures from there so you can attach them as part of your submissions. + + + + + + 3.8.2 + + + + YES + + + + + CFBundleTypeName + Unknown File + LSHandlerRank + Alternate + LSItemContentTypes + + public.calendar-event + public.database + public.executable + public.data + public.content + public.item + + + + CFBundleTypeName + Video + LSHandlerRank + Alternate + LSItemContentTypes + + public.video + + + + CFBundleTypeName + Image + LSHandlerRank + Alternate + LSItemContentTypes + + public.image + + + + CFBundleTypeName + Web Archive + LSHandlerRank + Alternate + LSItemContentTypes + + com.apple.webarchive + + + + CFBundleTypeName + iWork Keynote + LSHandlerRank + Alternate + LSItemContentTypes + + com.apple.keynote.key + com.apple.iwork.keynote.key + com.apple.iwork.keynote.kth + + + + CFBundleTypeName + iWork Numbers + LSHandlerRank + Alternate + LSItemContentTypes + + com.apple.numbers.numbers + com.apple.iwork.numbers.numbers + com.apple.iwork.numbers.template + + + + CFBundleTypeName + iWork Pages + LSHandlerRank + Alternate + LSItemContentTypes + + com.apple.page.pages + com.apple.iwork.pages.pages + com.apple.iwork.pages.template + + + + CFBundleTypeName + OpenDocument Spreadsheet + LSHandlerRank + Alternate + LSItemContentTypes + + org.oasis.opendocument.spreadsheet + + + + CFBundleTypeName + OpenDocument Presentation + LSHandlerRank + Alternate + LSItemContentTypes + + org.oasis.opendocument.presentation + + + + CFBundleTypeName + OpenDocument Text + LSHandlerRank + Alternate + LSItemContentTypes + + org.oasis.opendocument.text + + + + CFBundleTypeName + Folder + LSHandlerRank + Alternate + LSItemContentTypes + + public.folder + + + + CFBundleTypeName + Audio + LSHandlerRank + Alternate + LSItemContentTypes + + public.audio + public.mp3 + public.mpeg-4-audio + com.apple.protected-​mpeg-4-audio + public.aifc-audio + com.apple.coreaudio-​format + public.aiff-audio + + + + CFBundleTypeName + Movie + LSHandlerRank + Alternate + LSItemContentTypes + + public.movie + public.3gpp2 + public.3gpp + public.mpeg + com.apple.quicktime-movie + public.mpeg-4 + + + + CFBundleTypeName + GIF image + LSHandlerRank + Alternate + LSItemContentTypes + + com.compuserve.gif + + + + CFBundleTypeName + PNG image + LSHandlerRank + Alternate + LSItemContentTypes + + public.png + + + + CFBundleTypeName + TIFF image + LSHandlerRank + Alternate + LSItemContentTypes + + public.tiff + + + + CFBundleTypeName + JPEG image + LSHandlerRank + Alternate + LSItemContentTypes + + public.jpeg + + + + CFBundleTypeName + XML + LSHandlerRank + Alternate + LSItemContentTypes + + public.xml + + + + CFBundleTypeName + HTML + LSHandlerRank + Alternate + LSItemContentTypes + + public.html + public.xhtml + + + + CFBundleTypeName + Rich Text + LSHandlerRank + Alternate + LSItemContentTypes + + public.rtf + com.apple.rtfd + com.apple.flat-rtfd + + + + CFBundleTypeName + Text + LSHandlerRank + Alternate + LSItemContentTypes + + public.text + public.plain-text + public.utf8-plain-text + public.utf16-external-plain-​text + public.utf16-plain-text + com.apple.traditional-mac-​plain-text + public.source-code + public.c-source + public.objective-c-source + public.c-plus-plus-source + public.objective-c-plus-​plus-source + public.c-header + public.c-plus-plus-header + com.sun.java-source + public.script + public.shell-script + + + + CFBundleTypeExtensions + + zip + zipx + + CFBundleTypeName + Zip archive + LSHandlerRank + Alternate + LSItemContentTypes + + public.zip-archive + public.archive + com.pkware.zip-archive + com.pkware.zipx-archive + + + + CFBundleTypeExtensions + + rar + RAR + + CFBundleTypeName + Rar archive + LSHandlerRank + Alternate + LSItemContentTypes + + com.rarlab.rar-archive + public.archive + + + + CFBundleTypeExtensions + + 7z + 7Z + + CFBundleTypeName + 7z archive + LSHandlerRank + Alternate + LSItemContentTypes + + org.7-zip.7-zip-archive + public.archive + + + + CFBundleTypeName + Waveform audio + LSHandlerRank + Alternate + LSItemContentTypes + + com.microsoft.waveform-​audio + + + + CFBundleTypeName + Windows icon image + LSHandlerRank + Alternate + LSItemContentTypes + + com.microsoft.ico + com.apple.icns + + + + CFBundleTypeName + Windows bitmap image + LSHandlerRank + Alternate + LSItemContentTypes + + com.microsoft.bmp + + + + CFBundleTypeName + Microsoft PowerPoint + LSHandlerRank + Alternate + LSItemContentTypes + + com.microsoft.powerpoint.​ppt + org.openxmlformats.presentationml.presentation + + + + CFBundleTypeName + Microsoft Excel + LSHandlerRank + Alternate + LSItemContentTypes + + org.openxmlformats.spreadsheetml.sheet + com.microsoft.excel.xls + + + + CFBundleTypeName + Microsoft Word + LSHandlerRank + Alternate + LSItemContentTypes + + com.microsoft.word.doc + com.microsoft.word.wordml + org.openxmlformats.wordprocessingml.document + + + + CFBundleTypeName + PDF + LSHandlerRank + Alternate + LSItemContentTypes + + com.adobe.pdf + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - YES - - - diff --git a/scripts/aot.sh b/scripts/aot.sh new file mode 100755 index 000000000..4ebb56b0d --- /dev/null +++ b/scripts/aot.sh @@ -0,0 +1,32 @@ +#!/bin/bash +source "scripts/functions.sh" + +if [ ! -z $GIT_ORG_PRIVATE ] && [ ! -z $GIT_TOKEN ] ; then + print_title "Run scripts" + git clone --depth 1 https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/apps-scripts.git ../scripts + cp ../scripts/*.sh scripts/ + + if [ $TRAVIS_BUILD_STAGE_NAME == 'prepare' ] && [ -f scripts/prepare.sh ] ; then + print_title 'Prepare Build' + ./scripts/prepare.sh + + if [ $? -ne 0 ]; then + exit 1 + fi + elif [ $TRAVIS_BUILD_STAGE_NAME != 'prepare' ] && [ -f scripts/platform.sh ]; then + print_title 'Platform Build' + ./scripts/platform.sh + + if [ $? -ne 0 ]; then + exit 1 + fi + fi +else + print_title "AOT Compilation" + # Dynamic template loading without errors. + sed -ie $'s~throw new Error("No ResourceLoader.*~url = "templates/" + url;\\\nvar resolve;\\\nvar reject;\\\nvar promise = new Promise(function (res, rej) {\\\nresolve = res;\\\nreject = rej;\\\n});\\\nvar xhr = new XMLHttpRequest();\\\nxhr.open("GET", url, true);\\\nxhr.responseType = "text";\\\nxhr.onload = function () {\\\nvar response = xhr.response || xhr.responseText;\\\nvar status = xhr.status === 1223 ? 204 : xhr.status;\\\nif (status === 0) {\\\nstatus = response ? 200 : 0;\\\n}\\\nif (200 <= status \&\& status <= 300) {\\\nresolve(response);\\\n}\\\nelse {\\\nreject("Failed to load " + url);\\\n}\\\n};\\\nxhr.onerror = function () { reject("Failed to load " + url); };\\\nxhr.send();\\\nreturn promise;\\\n~g' node_modules/@angular/platform-browser-dynamic/esm5/platform-browser-dynamic.js + # Do not run JS optimizations to avoid problems with site plugins. + sed -ie "s/context\.isProd || hasArg('--optimizeJs')/false/g" node_modules/@ionic/app-scripts/dist/util/config.js + npm run ionic:build -- --prod +fi + diff --git a/scripts/ci.sh b/scripts/ci.sh deleted file mode 100755 index 0fe5022a1..000000000 --- a/scripts/ci.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -source "scripts/functions.sh" - -if [ "$TRAVIS_EVENT_TYPE" == 'cron' ] ; then - # Tests scripts. - print_error 'CRON NOT IMPLEMENTED YET' -else - if [ -z $GIT_ORG_PRIVATE ] || [ -z $GIT_TOKEN ]; then - print_error "Env vars not correctly defined" - exit 1 - fi - - # List first level of installed libraries so we can check the installed versions. - print_title "NPM packages list" - npm list --depth=0 - - if [ "$TRAVIS_REPO_SLUG" == 'moodlehq/moodleapp' ]; then - if [ "$TRAVIS_BRANCH" == 'master' ]; then - print_title "Update langpacks" - cd scripts - ./update_lang.sh - cd .. - - print_title "Update generated lang files" - git remote set-url origin https://$GIT_TOKEN@github.com/$TRAVIS_REPO_SLUG.git - git fetch -q origin - git add -A src/assets/lang - git add */en.json - git add src/config.json - git commit -m 'Update lang files [ci skip]' - - print_title "Update Licenses" - npm install -g license-checker - - jq --version - license-checker --json --production --relativeLicensePath > licenses.json - jq 'del(.[].path)' licenses.json > licenses_old.json - mv licenses_old.json licenses.json - licenses=`jq -r 'keys[]' licenses.json` - echo "{" > licensesurl.json - first=1 - for license in $licenses; do - obj=`jq --arg lic $license '.[$lic]' licenses.json` - licensePath=`echo $obj | jq -r '.licenseFile'` - file="" - if [[ ! -z "$licensePath" ]] || [[ "$licensePath" != "null" ]]; then - file=$(basename $licensePath) - if [ $first -eq 1 ] ; then - first=0 - echo "\"$license\" : { \"licenseFile\" : \"$file\"}" >> licensesurl.json - else - echo ",\"$license\" : { \"licenseFile\" : \"$file\"}" >> licensesurl.json - fi - fi - done - echo "}" >> licensesurl.json - - jq -s '.[0] * .[1]' licenses.json licensesurl.json > licenses_old.json - mv licenses_old.json licenses.json - rm licensesurl.json - - git add licenses.json - git commit -m 'Update licenses [ci skip]' - - git push origin HEAD:$TRAVIS_BRANCH - fi - - if [ "$TRAVIS_BRANCH" == 'integration' ] || [ "$TRAVIS_BRANCH" == 'master' ] || [ "$TRAVIS_BRANCH" == 'desktop' ] ; then - print_title "Mirror repository" - git remote add mirror https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/moodleapp.git - git fetch -q --unshallow mirror - git push -f mirror HEAD:$TRAVIS_BRANCH - git push mirror --tags - fi - elif [ "$TRAVIS_REPO_SLUG" == "$GIT_ORG_PRIVATE/moodleapp" ]; then - print_title "Run scripts" - git clone --depth 1 https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/apps-scripts.git ../scripts - cp ../scripts/build.sh scripts/ - ./scripts/build.sh - fi -fi diff --git a/scripts/functions.sh b/scripts/functions.sh index 55af8536b..5f9513299 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -1,6 +1,16 @@ #!/bin/bash LANGPACKSFOLDER='../../moodle-langpacks' +stepnumber=$1 + +function check_success_exit { + if [ $? -ne 0 ]; then + print_error "$1" + exit 1 + elif [ "$#" -gt 1 ]; then + print_ok "$2" + fi +} function check_success { if [ $? -ne 0 ]; then diff --git a/scripts/mirror.sh b/scripts/mirror.sh new file mode 100755 index 000000000..a6aa5bdac --- /dev/null +++ b/scripts/mirror.sh @@ -0,0 +1,89 @@ +#!/bin/bash +source "scripts/functions.sh" + +npm run build --bailOnLintError true --typeCheckOnLint true + +if [ -z $GIT_ORG_PRIVATE ] || [ -z $GIT_TOKEN ]; then + print_error "Env vars not correctly defined" + exit 1 +fi + +# List first level of installed libraries so we can check the installed versions. +print_title "NPM packages list" +npm list --depth=0 + +if [ "$TRAVIS_BRANCH" == 'master' ]; then + print_title "Update langpacks" + cd scripts + ./update_lang.sh + cd .. + + print_title "Update generated lang files" + git remote set-url origin https://$GIT_TOKEN@github.com/$TRAVIS_REPO_SLUG.git + git fetch -q origin + git add -A src/assets/lang + git add */en.json + git add src/config.json + git commit -m 'Update lang files [ci skip]' + + print_title "Update Licenses" + npm install -g license-checker + + jq --version + license-checker --json --production --relativeLicensePath > licenses.json + jq 'del(.[].path)' licenses.json > licenses_old.json + mv licenses_old.json licenses.json + licenses=`jq -r 'keys[]' licenses.json` + echo "{" > licensesurl.json + first=1 + for license in $licenses; do + obj=`jq --arg lic $license '.[$lic]' licenses.json` + licensePath=`echo $obj | jq -r '.licenseFile'` + file="" + if [[ ! -z "$licensePath" ]] || [[ "$licensePath" != "null" ]]; then + file=$(basename $licensePath) + if [ $first -eq 1 ] ; then + first=0 + echo "\"$license\" : { \"licenseFile\" : \"$file\"}" >> licensesurl.json + else + echo ",\"$license\" : { \"licenseFile\" : \"$file\"}" >> licensesurl.json + fi + fi + done + echo "}" >> licensesurl.json + + jq -s '.[0] * .[1]' licenses.json licensesurl.json > licenses_old.json + mv licenses_old.json licenses.json + rm licensesurl.json + + git add licenses.json + git commit -m 'Update licenses [ci skip]' + + git push origin HEAD:$TRAVIS_BRANCH +fi + +VERSION=`jq -r '.versionname' src/config.json` +if [ "$TRAVIS_BRANCH" == 'integration' ] && [ "$VERSION" != *-dev ] ; then + VERSION=$VERSION-dev + + jq -r --indent 4 --arg version "$VERSION" -s '.[0] + {versionname: $version}' src/config.json > src/config_new.json + mv src/config_new.json src/config.json + + sed -ie "s/version[ ]*=[ ]*\"[0-9\.]*\">/version=\"$VERSION\">/1" config.xml + + git remote set-url origin https://$GIT_TOKEN@github.com/$TRAVIS_REPO_SLUG.git + git fetch -q origin + + git add src/config.json + git commit -m 'Change config version [ci skip]' + + git push origin HEAD:$TRAVIS_BRANCH +fi + +if [ "$TRAVIS_BRANCH" == 'integration' ] || [ "$TRAVIS_BRANCH" == 'master' ] || [ "$TRAVIS_BRANCH" == 'desktop' ] ; then + print_title "Mirror repository" + git remote add mirror https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/moodleapp.git + git fetch -q --unshallow mirror + git push -f mirror HEAD:$TRAVIS_BRANCH + git push -f mirror --tags +fi