|
1 | 1 | #!/bin/bash |
| 2 | +source "scripts/functions.sh" |
| 3 | + |
| 4 | +print_title "NPM packages list" |
2 | 5 |
|
3 | 6 | # List first level of installed libraries so we can check the installed versions. |
4 | 7 | npm list --depth=0 |
5 | 8 |
|
6 | | -# Compile AOT. |
7 | | -if [ $TRAVIS_BRANCH == 'integration' ] || [ $TRAVIS_BRANCH == 'master' ] || [ $TRAVIS_BRANCH == 'desktop' ] || [ $TRAVIS_BRANCH == 'security' ] || [ -z $TRAVIS_BRANCH ] ; then |
| 9 | +if [ "$TRAVIS_BRANCH" == 'master' ] && [ ! -z $GIT_TOKEN ] && [ "$TRAVIS_REPO_SLUG" == 'moodlehq/moodleapp' ]; then |
| 10 | + print_title "Update langpacks" |
8 | 11 | cd scripts |
9 | | - ./build_lang.sh |
| 12 | + ./update_lang.sh |
10 | 13 | cd .. |
11 | 14 |
|
12 | | - if [ "$TRAVIS_BRANCH" == 'master' ] && [ ! -z $GIT_TOKEN ] ; then |
13 | | - git remote set-url origin https://$GIT_TOKEN@github.com/$TRAVIS_REPO_SLUG.git |
14 | | - git fetch -q origin |
15 | | - git add src/assets/lang |
16 | | - git add */en.json |
17 | | - git commit -m 'Update lang files [ci skip]' |
18 | | - git push origin HEAD:$TRAVIS_BRANCH |
19 | | - |
20 | | - version=`grep versionname src/config.json| cut -d: -f2|cut -d'"' -f2` |
21 | | - date=`date +%Y%m%d`'00' |
22 | | - |
23 | | - pushd ../moodle-local_moodlemobileapp |
24 | | - sed -ie "s/release[ ]*=[ ]*'[^']*';/release = '$version';/1" version.php |
25 | | - sed -ie "s/version[ ]*=[ ]*[0-9]*;/version = $date;/1" version.php |
26 | | - rm version.phpe |
27 | | - git remote set-url origin https://$GIT_TOKEN@github.com/moodlehq/moodle-local_moodlemobileapp.git |
28 | | - git fetch -q origin |
29 | | - git add . |
30 | | - git commit -m "Update lang files from $version" |
31 | | - git push |
32 | | - popd |
33 | | - fi |
34 | | - |
35 | | - 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 |
36 | | - sed -ie "s/context\.isProd || hasArg('--minifyJs')/hasArg('--minifyJs')/g" node_modules/@ionic/app-scripts/dist/util/config.js |
37 | | - sed -ie "s/context\.isProd || hasArg('--optimizeJs')/hasArg('--optimizeJs')/g" node_modules/@ionic/app-scripts/dist/util/config.js |
38 | | - npm run ionic:build -- --prod |
| 15 | + print_title "Update generated lang files" |
| 16 | + git remote set-url origin https://$GIT_TOKEN@github.com/$TRAVIS_REPO_SLUG.git |
| 17 | + git fetch -q origin |
| 18 | + git add -A src/assets/lang |
| 19 | + git add */en.json |
| 20 | + git add src/config.json |
| 21 | + git commit -m 'Update lang files [ci skip]' |
| 22 | + git push origin HEAD:$TRAVIS_BRANCH |
39 | 23 | fi |
40 | 24 |
|
41 | | -# Copy to PGB git (only on a configured travis build). |
42 | | -if [ ! -z $GIT_ORG ] && [ ! -z $GIT_TOKEN ] ; then |
43 | | - gitfolder=${PWD##*/} |
44 | | - git clone --depth 1 --no-single-branch https://github.com/$GIT_ORG/moodlemobile-phonegapbuild.git ../pgb |
45 | | - pushd ../pgb |
46 | | - |
47 | | - mkdir /tmp/travistemp |
48 | | - cp .travis.yml /tmp/travistemp |
49 | | - mkdir /tmp/travistemp/scripts |
50 | | - cp scripts/* /tmp/travistemp/scripts |
51 | | - |
52 | | - git checkout $TRAVIS_BRANCH |
53 | | - |
54 | | - rm -Rf assets build index.html templates www destkop lib |
55 | | - |
56 | | - if [ $TRAVIS_BRANCH == 'desktop' ] ; then |
57 | | - cp -Rf ../$gitfolder/desktop ./ |
58 | | - cp -Rf ../$gitfolder/package.json ./ |
59 | | - cp -Rf ../$gitfolder/www ./ |
60 | | - rm -Rf www/assets/countries www/assets/mimetypes |
61 | | - else |
62 | | - cp -Rf ../$gitfolder/www/* ./ |
63 | | - rm -Rf assets/countries assets/mimetypes |
| 25 | +print_title "AOT Compilation" |
| 26 | +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 |
| 27 | +sed -ie "s/context\.isProd || hasArg('--minifyJs')/hasArg('--minifyJs')/g" node_modules/@ionic/app-scripts/dist/util/config.js |
| 28 | +sed -ie "s/context\.isProd || hasArg('--optimizeJs')/hasArg('--optimizeJs')/g" node_modules/@ionic/app-scripts/dist/util/config.js |
| 29 | +npm run ionic:build -- --prod |
| 30 | + |
| 31 | + |
| 32 | +if [ $TRAVIS_BRANCH == 'integration' ] || [ $TRAVIS_BRANCH == 'master' ] || [ $TRAVIS_BRANCH == 'desktop' ] ; then |
| 33 | + if [ ! -z $GIT_ORG_PRIVATE ] && [ ! -z $GIT_TOKEN ] ; then |
| 34 | + if [ "$TRAVIS_REPO_SLUG" == 'moodlehq/moodleapp' ]; then |
| 35 | + print_title "Mirror repository" |
| 36 | + git remote add mirror https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/moodleapp.git |
| 37 | + git fetch -q mirror |
| 38 | + git push -f mirror HEAD:$TRAVIS_BRANCH |
| 39 | + git push mirror --tags |
| 40 | + else |
| 41 | + print_title "Run scripts" |
| 42 | + git clone --depth 1 https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/apps-scripts.git ../scripts |
| 43 | + cp ../scripts/build.sh scripts/ |
| 44 | + ./scripts/build.sh |
| 45 | + fi |
64 | 46 | fi |
65 | | - |
66 | | - cp /tmp/travistemp/.travis.yml .travis.yml |
67 | | - mkdir scripts |
68 | | - cp /tmp/travistemp/scripts/* scripts |
69 | | - |
70 | | - |
71 | | - git add . |
72 | | - git commit -m "Travis build: $TRAVIS_BUILD_NUMBER" |
73 | | - git push https://$GIT_TOKEN@github.com/$GIT_ORG/moodlemobile-phonegapbuild.git |
74 | | - popd |
75 | 47 | fi |
76 | | - |
0 commit comments