Commit 0ceaebfc authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[enh] Upgrade to Cordova@10.0.0 cordova-android@9.0.0 and cordova-ios@6.1.0

parent d61f5d75
......@@ -37,6 +37,7 @@
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#000" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="loadUrlTimeoutValue" value="700000" />
<allow-navigation href="*" />
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
......@@ -48,6 +49,19 @@
<param name="android-package" onload="true" value="me.lockate.plugins.MiniSodium" />
</feature>
<platform name="android">
<preference name="AndroidXEnabled" value="true" />
<preference name="cdvMinSdkVersion" value="16" />
<preference name="cdvCompileSdkVersion" value="29" />
<preference name="cdvBuildToolsVersion" value="29.0.2" />
<hook src="scripts/hooks/before_prepare/061_copy_build_extras.js" type="before_prepare" />
<hook src="scripts/hooks/after_prepare/010_add_platform_class.js" type="after_prepare" />
<hook src="scripts/hooks/after_prepare/021_template_cache.js" type="after_prepare" />
<hook src="scripts/hooks/after_prepare/022_translate.js" type="after_prepare" />
<hook src="scripts/hooks/after_prepare/040_useref.js" type="after_prepare" />
<hook src="scripts/hooks/after_prepare/040_useref.js" type="after_prepare" />
<hook src="scripts/hooks/after_prepare/050_clean_unused_directories.js" type="after_prepare" />
<hook src="scripts/hooks/after_prepare/061_copy_build_extras.js" type="after_prepare" />
<hook src="scripts/hooks/before_compile/060_prepare_android_manifest.js" type="after_prepare" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
......@@ -129,8 +143,6 @@
<icon height="512" src="resources/osx/icon-512.png" width="512" />
<icon height="1024" src="resources/osx/icon-1024.png" width="1024" />
</platform>
<plugin name="cordova-plugin-minisodium" spec="git+https://github.com/duniter-cesium/cordova-plugin-minisodium.git#v1.0.1" />
<plugin name="cordova-plugin-secure-storage-android10" spec="git+https://github.com/duniter-cesium/cordova-plugin-secure-storage-android10#6.0.4" />
<plugin name="cordova-plugin-camera" spec="^4.1.0">
<variable name="CAMERA_USAGE_DESCRIPTION" value="Add picture to the user profile" />
<variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="Take a picture for the user profile" />
......@@ -162,8 +174,6 @@
</plugin>
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
<plugin name="cordova-plugin-androidx" spec="^1.0.2" />
<plugin name="cordova-plugin-androidx-adapter" spec="^1.1.0" />
<engine name="ios" spec="git+https://github.com/duniter-cesium/cordova-ios.git#5.1.0" />
<engine name="osx" spec="^5.0.0" />
<engine name="android" spec="^9.0.0" />
<engine name="ios" spec="^6.1.0" />
<engine name="osx" spec="^6.0.0" />
</widget>
......@@ -40,7 +40,7 @@ To build Cesium, you will have to:
3. Installing node build tools, as global dependencies:
```bash
npm install -g yarn gulp cordova@8.1.2 @ionic/cli web-ext
npm install -g yarn gulp cordova@10.0.0 @ionic/cli web-ext
```
### Get the source code and dependencies
......
......@@ -127,7 +127,7 @@ cd cesium
Puis, lancez le téléchargement et l'installation des modules Cesium à l'aide de la commande :
```bash
npm install -g yarn gulp@3.9.1 cordova@8.1.2 @ionic/cli@6.6.0 web-ext
npm install -g yarn gulp cordova@10.0.0 @ionic/cli web-ext
```
Puis pour les dépendances non globales :
......
......@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-6.5.1-all.zip
#!/usr/bin/env node
"use strict";
const gulp = require('gulp');
const path = require("path");
const removeCode = require('gulp-remove-code');
const removeHtml = require('gulp-html-remove');
const es = require('event-stream');
const ngAnnotate = require('gulp-ng-annotate');
const htmlmin = require('gulp-htmlmin');
const merge = require('merge2');
const rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
const platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(let x=0; x<platforms.length; x++) {
let platform = platforms[x].trim().toLowerCase();
let wwwPath;
if(platform === 'android') {
//wwwPath = path.join(rootdir, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
var pluginPath = path.join(wwwPath, 'plugins') + '/es';
// Log
//console.log('['+process.mainModule.filename+'] Removing code for platform '+platform+'\n');
// Compute options {device-<platform>: true}
let platformRemoveCodeOptions = {};
platformRemoveCodeOptions[platform] = true; // = {<platform>: true}
let htmlminOptions = {removeComments: true, collapseWhitespace: true};
// Do not remove desktop code for iOS and macOS (support for tablets and desktop macs)
if (platform !== 'ios' && platform !== 'osx') {
// Removing unused code for device...
merge(
// Remove unused HTML tags
gulp.src(path.join(wwwPath, 'templates', '**', '*.html'))
.pipe(removeCode({device: true}))
.pipe(removeCode(platformRemoveCodeOptions))
.pipe(removeHtml('.hidden-xs.hidden-sm'))
.pipe(removeHtml('.hidden-device'))
.pipe(removeHtml('[remove-if][remove-if="device"]'))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(wwwPath + '/templates')),
gulp.src(path.join(pluginPath, '**', '*.html'))
.pipe(removeCode({device: true}))
.pipe(removeCode(platformRemoveCodeOptions))
.pipe(removeHtml('.hidden-xs.hidden-sm'))
.pipe(removeHtml('.hidden-device'))
.pipe(removeHtml('[remove-if][remove-if="device"]'))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(pluginPath)),
gulp.src(path.join(wwwPath, 'index.html'))
.pipe(removeCode({device: true}))
.pipe(removeCode(platformRemoveCodeOptions))
.pipe(removeHtml('.hidden-xs.hidden-sm'))
.pipe(removeHtml('.hidden-device'))
.pipe(removeHtml('[remove-if][remove-if="device"]'))
.pipe(htmlmin(/*no options, to keep comments*/))
.pipe(gulp.dest(wwwPath)),
// Remove unused JS code + add ng annotations
gulp.src(path.join(wwwPath, 'js', '**', '*.js'))
.pipe(removeCode({device: true}))
.pipe(removeCode(platformRemoveCodeOptions))
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/app')),
gulp.src([pluginPath + '/js/**/*.js'])
.pipe(removeCode({device: true}))
.pipe(removeCode(platformRemoveCodeOptions))
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/plugins'))
);
} else {
merge(
gulp.src(path.join(wwwPath, 'templates', '**', '*.html'))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(wwwPath + '/templates')),
gulp.src(path.join(pluginPath, '**', '*.html'))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(pluginPath)),
gulp.src(path.join(wwwPath, 'index.html'))
.pipe(gulp.dest(wwwPath)),
gulp.src(path.join(wwwPath, 'js', '**', '*.js'))
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/app')),
gulp.src([pluginPath + '/js/**/*.js'])
.pipe(gulp.dest(wwwPath + '/dist/dist_js/plugins'))
);
}
}
}
#!/usr/bin/env node
"use strict";
const gulp = require('gulp');
const path = require("path");
const templateCache = require('gulp-angular-templatecache');
const merge = require('merge2');
const rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
const platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(let x=0; x<platforms.length; x++) {
let platform = platforms[x].trim().toLowerCase();
let wwwPath;
if (platform === 'android') {
//wwwPath = path.join(rootdir, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
let distJsPath = path.join(wwwPath, 'dist', 'dist_js', 'app');
let pluginDistJsPath = path.join(wwwPath, 'dist', 'dist_js', 'plugins');
// Concat templates into a JS
merge(
gulp.src(path.join(wwwPath, 'templates', '**', '*.html'))
.pipe(templateCache({
standalone:true,
module:"cesium.templates",
root: "templates/"
}))
.pipe(gulp.dest(distJsPath)),
gulp.src(path.join(wwwPath, 'plugins', '*', 'templates', '**', '*.html'))
.pipe(templateCache({
standalone:true,
module:"cesium.plugins.templates",
root: "plugins/"
}))
.pipe(gulp.dest(pluginDistJsPath))
);
}
}
#!/usr/bin/env node
"use strict";
const gulp = require('gulp');
const path = require("path");
const merge = require('merge2');
const rootdir = process.argv[2];
const ngTranslate = require('gulp-angular-translate');
if (rootdir) {
// go through each of the platform directories that have been prepared
const platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(let x=0; x<platforms.length; x++) {
let platform = platforms[x].trim().toLowerCase();
let wwwPath;
if(platform === 'android') {
//wwwPath = path.join(rootdir, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
let distJsPath = path.join(wwwPath, 'dist', 'dist_js', 'app');
let pluginDistJsPath = path.join(wwwPath, 'dist', 'dist_js', 'plugins');
// Concat templates into a JS
merge(
gulp.src(wwwPath + '/i18n/locale-*.json')
.pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
.pipe(gulp.dest(distJsPath)),
gulp.src(wwwPath + '/plugins/*/i18n/locale-*.json')
.pipe(ngTranslate({standalone:true, module: 'cesium.plugins.translations'}))
.pipe(gulp.dest(pluginDistJsPath))
);
}
}
#!/usr/bin/env node
"use strict";
const gulp = require('gulp'),
path = require("path"),
es = require('event-stream'),
useref = require('gulp-useref'),
filter = require('gulp-filter'),
uglify = require('gulp-uglify-es').default,
csso = require('gulp-csso'),
log = require('fancy-log'),
colors = require('ansi-colors');
const cmd = process.env.CORDOVA_CMDLINE;
const rootdir = process.argv[2];
let skip = true;
if (cmd.indexOf("--release") > -1 || cmd.indexOf("--useref") > -1) {
skip = false;
}
else {
log(colors.grey('Skipping useref'));
}
if (rootdir && !skip) {
// go through each of the platform directories that have been prepared
const platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(let x=0; x<platforms.length; x++) {
let platform = platforms[x].trim().toLowerCase();
let wwwPath;
if(platform === 'android') {
//wwwPath = path.join(rootdir, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
let indexPath = path.join(wwwPath, 'index.html');
const jsFilter = filter(['*/lib/**/*.js', '*/js/vendor/**/*.js'], { restore: true });
const cssFilter = filter('**/*.css', { restore: true });
const uglifyOptions = {
toplevel: true,
warnings: true,
ecma: '5',
mangle: {
reserved: ['qrcode', 'Base58']
},
compress: {
global_defs: {
"@console.log": "alert"
},
passes: 2
},
output: {
beautify: false,
preamble: "/* minified */",
max_line_len: 120000
}
};
// Removing unused code for device...
es.concat(
gulp.src(indexPath)
.pipe(useref()) // Concatenate with gulp-useref
.pipe(jsFilter)
.pipe(uglify(uglifyOptions)) // Minify any javascript sources
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
.pipe(gulp.dest(wwwPath))
);
}
}
#!/usr/bin/env node
"use strict";
const gulp = require('gulp');
const path = require("path");
const del = require('del');
const cmd = process.env.CORDOVA_CMDLINE;
const rootdir = process.argv[2];
let skip = true;
if (cmd.indexOf("--release") > -1 || cmd.indexOf("--useref") > -1) {
skip = false;
}
if (rootdir && !skip) {
// go through each of the platform directories that have been prepared
const platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(let x=0; x<platforms.length; x++) {
let platform = platforms[x].trim().toLowerCase();
let wwwPath;
if(platform === 'android') {
//wwwPath = path.join(rootdir, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
// Log
console.log('['+process.mainModule.filename+'] Cleaning unused directories');
// Clean unused directories
del.sync([
path.join(wwwPath, 'api'),
path.join(wwwPath, 'i18n'),
path.join(wwwPath, 'js'),
path.join(wwwPath, 'templates'),
path.join(wwwPath, 'css'),
path.join(wwwPath, 'dist'),
path.join(wwwPath, 'cordova-js-src'),
path.join(wwwPath, 'plugins', 'es'),
path.join(wwwPath, 'plugins', 'graph'),
path.join(wwwPath, 'plugins', 'map'),
path.join(wwwPath, 'plugins', 'rml9'),
// Clean lib directory...
path.join(wwwPath, 'lib', '*'),
// ...but keep Ionic fonts directory
'!'+path.join(wwwPath, 'lib', 'ionic'),
path.join(wwwPath, 'lib', 'ionic', '*'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts'),
// ...and keep Robotodraft fonts directory
'!'+path.join(wwwPath, 'lib', 'robotdraft'),
path.join(wwwPath, 'lib', 'robotdraft', '*'),
'!'+path.join(wwwPath, 'lib', 'robotdraft', 'fonts')
]);
}
}
#!/usr/bin/env node
"use strict";
const gulp = require('gulp');
const path = require("path");
const replace = require('gulp-replace');
const rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
const platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(let x=0; x<platforms.length; x++) {
let platform = platforms[x].trim().toLowerCase();
if (platform === 'android') {
//let srcMainPath = path.join(rootdir, 'platforms', platform, 'app', 'src', 'main');
let srcMainPath = path.join(rootdir, 'platforms', platform);
let androidManifestFile = path.join(srcMainPath, 'AndroidManifest.xml');
// Clean unused directories
console.log('-----------------------------------------');
console.log(' Updating file: ' + androidManifestFile);
gulp.src(androidManifestFile)
// Add 'tools' namespace to root tag
.pipe(replace(/(xmlns:android="http:\/\/schemas.android.com\/apk\/res\/android")\s*>/g, '$1 xmlns:tools="http://schemas.android.com/tools">'))
// Add <application> (replace 'targetSdkversion' and add tools:overrideLibrary)
.pipe(replace(/\s+tools:replace="android:appComponentFactory"/, ''))
.pipe(replace(/\s+android:appComponentFactory="[^"]+"/, ''))
.pipe(replace(/(\s*<application)\s*/, '$1 tools:replace="android:appComponentFactory" android:appComponentFactory="androidx.core.app.CoreComponentFactory" '))
// remove all <uses-sdk>
.pipe(replace(/<uses-sdk [^>]+\/>/g, ''))
// add <uses-sdk> (replace 'targetSdkversion' and add tools:overrideLibrary)
.pipe(replace(/(<\/manifest>)/, ' <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="29" tools:overrideLibrary="org.kaliumjni.lib" />\n$1'))
.pipe(gulp.dest(srcMainPath));
console.log('-----------------------------------------');
}
}
}
......@@ -11,7 +11,7 @@
},
"scripts": {
"clean": "trash www/dist/** dist/web/* dist/desktop/**/*.deb platforms/android/**/*.apk",
"postinstall": "node -e \"try { require('fs').symlinkSync(require('path').resolve('node_modules/@bower_components'), 'www/lib', 'junction') } catch (e) { }\" && rm -f hooks/uglify-config.json hooks/after_prepare/uglify.js www/lib/moment/meteor/moment.js",
"postinstall": "node scripts/node/postinstall.js",
"install-platforms": "ionic cordova prepare",
"start": "ionic serve",
"start:firefox": "gulp webExtCompile && web-ext run --source-dir ./dist/web/ext/",
......@@ -84,35 +84,32 @@
},
"devDependencies": {
"@ionic/cli": "^6.11.0",
"@ionic/v1-toolkit": "^3.2.0",
"@ionic/v1-toolkit": "^3.2.3",
"@prantlf/gulp-jsonlint": "^2.4.0",
"ansi-colors": "^4.1.1",
"cordova": "^8.1.2",
"cordova-android": "^8.1.0",
"cordova": "^10.0.0",
"cordova-android": "^9.0.0",
"cordova-clipboard": "^1.3.0",
"cordova-ios": "git+https://github.com/duniter-cesium/cordova-ios.git#5.1.0",
"cordova-osx": "^5.0.0",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-ios": "^6.1.0",
"cordova-osx": "^6.0.0",
"cordova-plugin-androidx": "^2.0.0",
"cordova-plugin-androidx-adapter": "^1.1.1",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-customurlscheme": "^5.0.2",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-minisodium": "git+https://github.com/duniter-cesium/cordova-plugin-minisodium.git#v1.0.2",
"cordova-plugin-secure-storage-android10": "git+https://github.com/duniter-cesium/cordova-plugin-secure-storage-android10.git#6.0.4",
"cordova-plugin-splashscreen": "^6.0.0",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-vibration": "^3.1.1",
"cordova-plugin-websocket": "^0.12.2",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-plugin-x-toast": "^2.7.2",
"ionic-plugin-keyboard": "^2.2.1",
"phonegap-plugin-barcodescanner": "^8.1.0",
"cordova-plugin-customurlscheme": "^5.0.2",
"cordova-plugin-minisodium": "git+https://github.com/duniter-cesium/cordova-plugin-minisodium.git#v1.0.1",
"cordova-plugin-secure-storage-android10": "git+https://github.com/duniter-cesium/cordova-plugin-secure-storage-android10.git#6.0.4",
"cordova-uglify": "^0.3.4",
"del": "^5.1.0",
"delete-empty": "^0.1.3",
"event-stream": "3.3.4",
......@@ -149,11 +146,13 @@
"gulp-uglify-es": "^2.0.0",
"gulp-useref": "^4.0.1",
"gulp-zip": "^5.0.2",
"ionic-plugin-keyboard": "^2.2.1",
"jshint": "^2.10.3",
"lazypipe": "^1.0.2",
"merge2": "^1.3.0",
"mv": "^2.1.1",
"node-sass": "^4.14.1",
"phonegap-plugin-barcodescanner": "^8.1.0",
"playup": "^1.1.0",
"vinyl-fs": "^3.0.3",
"web-ext": "^4.3.0",
......@@ -170,37 +169,6 @@
"gulp-cli": "2.3.0",
"graceful-fs": "4.2.4"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
"cordova-plugin-device",
"cordova-plugin-statusbar",
"cordova-plugin-camera",
"cordova-plugin-websocket",
"cordova-plugin-vibration",
"cordova-plugin-dialogs",
"cordova-plugin-secure-storage-android10",
"cordova-plugin-x-toast",
"cordova-clipboard",
"cordova-plugin-minisodium",
"phonegap-plugin-barcodescanner",
"cordova-plugin-ionic-keyboard",
"cordova-plugin-ionic-webview@4.1.2",
"cordova-plugin-customurlscheme"
],
"cordovaPlatforms": [
{
"platform": "ios",
"version": "5.1.0",
"locator": "https://github.com/duniter-cesium/cordova-ios.git#5.1.0"
},
{
"platform": "android",
"version": "6.4.0",
"locator": "android@6.4.0"
}
],