Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • chrome-manifest-v3
  • develop
  • feat/force-migration-check
  • feat/improve-network-scan
  • feature/android_api_19
  • feature/encrypted_comment
  • feature/migrate-cordova-13
  • gitlab_migration_1
  • master
  • rml8
  • 0.0.1.ES.alpha1
  • 0.0.2
  • 0.1.13
  • 0.1.14
  • 0.1.15
  • 0.1.16
  • 0.1.17
  • 0.1.18
  • 0.1.19
  • 0.1.20
  • 0.1.21
  • 0.1.22
  • 0.1.23
  • 0.1.24
  • 0.1.25
  • 0.1.26
  • 0.1.27
  • 0.1.28
  • 0.1.4
  • 0.1.7
  • 0.1.8
  • 0.2.0
  • 0.2.1
  • v0.10.0
  • v0.10.1
  • v0.10.2
  • v0.11.0
  • v0.11.1
  • v0.11.2
  • v0.11.3
  • v0.11.4
  • v0.11.5
  • v0.11.6
  • v0.11.7
  • v0.11.8
  • v0.12.0
  • v0.12.1
  • v0.12.2
  • v0.12.3
  • v0.12.4
  • v0.12.5
  • v0.12.6
  • v0.12.7
  • v0.12.8
  • v0.12.9
  • v0.13.0
  • v0.14.0
  • v0.14.1
  • v0.15.0
  • v0.15.1
  • v0.15.2
  • v0.15.3
  • v0.15.4
  • v0.15.5
  • v0.15.6
  • v0.15.7
  • v0.16.0
  • v0.16.1
  • v0.17.0
  • v0.17.1
  • v0.17.2
  • v0.17.3
  • v0.17.4
  • v0.17.5
  • v0.17.6
  • v0.18.0
  • v0.18.1
  • v0.18.2
  • v0.18.3
  • v0.19.0
  • v0.19.1
  • v0.19.2
  • v0.19.3
  • v0.19.4
  • v0.19.5
  • v0.19.6
  • v0.2.10
  • v0.2.12
  • v0.2.13
  • v0.2.14
  • v0.2.3
  • v0.2.4
  • v0.2.5
  • v0.2.6
  • v0.2.7
  • v0.2.8
  • v0.2.9
  • v0.3.0
  • v0.3.1
  • v0.3.10
  • v0.3.11
  • v0.3.12
  • v0.3.13
  • v0.3.14
  • v0.3.15
  • v0.3.16
  • v0.3.17
  • v0.3.2
  • v0.3.3
  • v0.3.4
110 results

Target

Select target project
  • cordeliaze/cesium
  • pfouque06/cesium
  • wellno1/cesium
  • 1000i100/cesium
  • vincentux/cesium
  • calbasi/cesium
  • thomasbromehead/cesium
  • matograine/cesium
  • clients/cesium-grp/cesium
  • cedricmenec/cesium
  • Pamplemousse/cesium
  • etienneleba/cesium
  • tnntwister/cesium
  • scanlegentil/cesium
  • morvanc/cesium
  • yyy/cesium
  • Axce/cesium
  • Bertrandbenj/cesium
  • Lupus/cesium
  • elmau/cesium
  • MartinDelille/cesium
  • tykayn/cesium
  • numeropi/cesium
  • Vivakvo/cesium
  • pokapow/cesium
  • pini-gh/cesium
  • anam/cesium
  • RavanH/cesium
  • bpresles/cesium
  • am97/cesium
  • tuxmain/cesium
  • jytou/cesium
  • oliviermaurice/cesium
  • 666titi999/cesium
  • Yvv/cesium
35 results
Select Git revision
  • Vivakvo-master-patch-80805
  • Vivakvo-master-patch-99327
  • dev
  • gitlab_migration_1
  • issue_4
  • issue_780
  • master
  • patch-1
  • patch-10
  • patch-11
  • patch-12
  • patch-13
  • patch-14
  • patch-15
  • patch-16
  • patch-17
  • patch-18
  • patch-19
  • patch-2
  • patch-21
  • patch-22
  • patch-23
  • patch-24
  • patch-25
  • patch-26
  • patch-3
  • patch-4
  • patch-5
  • patch-6
  • patch-7
  • patch-8
  • patch-9
  • rml8
  • undefined
  • 0.0.1.ES.alpha1
  • 0.0.2
  • 0.1.13
  • 0.1.14
  • 0.1.15
  • 0.1.16
  • 0.1.17
  • 0.1.18
  • 0.1.19
  • 0.1.20
  • 0.1.21
  • 0.1.22
  • 0.1.23
  • 0.1.24
  • 0.1.25
  • 0.1.26
  • 0.1.27
  • 0.1.28
  • 0.1.4
  • 0.1.7
  • 0.1.8
  • 0.2.0
  • 0.2.1
  • v0.10.0
  • v0.10.1
  • v0.10.2
  • v0.11.0
  • v0.11.1
  • v0.11.2
  • v0.11.3
  • v0.11.4
  • v0.11.5
  • v0.11.6
  • v0.11.7
  • v0.11.8
  • v0.12.0
  • v0.12.1
  • v0.12.2
  • v0.12.3
  • v0.12.4
  • v0.12.5
  • v0.12.6
  • v0.12.7
  • v0.12.8
  • v0.12.9
  • v0.13.0
  • v0.14.0
  • v0.14.1
  • v0.15.0
  • v0.15.1
  • v0.15.2
  • v0.15.3
  • v0.15.4
  • v0.15.5
  • v0.15.6
  • v0.15.7
  • v0.16.0
  • v0.16.1
  • v0.17.0
  • v0.17.1
  • v0.17.2
  • v0.17.3
  • v0.17.4
  • v0.17.5
  • v0.17.6
  • v0.18.0
  • v0.18.1
  • v0.18.2
  • v0.18.3
  • v0.19.0
  • v0.19.1
  • v0.19.2
  • v0.19.3
  • v0.19.4
  • v0.19.5
  • v0.19.6
  • v0.2.10
  • v0.2.12
  • v0.2.13
  • v0.2.14
  • v0.2.3
  • v0.2.4
  • v0.2.5
  • v0.2.6
  • v0.2.7
  • v0.2.8
  • v0.2.9
  • v0.3.0
  • v0.3.1
  • v0.3.10
  • v0.3.11
  • v0.3.12
  • v0.3.13
  • v0.3.14
  • v0.3.15
  • v0.3.16
  • v0.3.17
  • v0.3.2
  • v0.3.3
  • v0.3.4
134 results
Show changes
Showing
with 1364 additions and 1537 deletions
## Privacy policy
Android build allow user to upload user profile (avatar, pictures) used by the Cesium+ extension.
Cesium Android allow user to upload user profile (avatar, pictures), when the Cesium+ extension has been enable in settings.
### Cesium+ profile
Privacy policy are :
- Profile data and avatar are public data;
- Profile data and avatar on an [ES Duniter4j node](https://github.com/duniter/duniter4j); Open Cesium+ settings to known the node address;
- To totally remove your profile and avatar (if you use our official server [data.gtest.duniter.fr](http://data.gtest.duniter.fr)), please contact us at https://github.com/blavenie.
\ No newline at end of file
- Profile data and avatar on an [Cesium+ node](https://github.com/duniter/cesium-plus-pod); Open Cesium+ settings to know the node address;
- User can remove profile and avatar (open the Settings page, then use the options menu).
\ No newline at end of file
#!/bin/bash
### Control that the script is run on `dev` branch
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "master" ]];
then
echo ">> This script must be run under \`master\` branch"
exit 1
fi
### Get version to release
current=`grep -P "version\": \"\d+.\d+.\d+(\w*)" package.json | grep -m 1 -oP "\d+.\d+.\d+(\w*)"`
if [[ "_$current" == "_" ]]; then
echo "Unable to read the current version in 'package.json'. Please check version format is: x.y.z (x and y should be an integer)."
exit 1;
fi
echo "Current version: $current"
### Get repo URL
PROJECT_NAME=cesium
REPO="duniter/cesium"
REPO_API_URL=https://api.github.com/repos/$REPO
REPO_PUBLIC_URL=https://github.com/$REPO
### get auth token
GITHUB_TOKEN=`cat ~/.config/${PROJECT_NAME}/.github`
if [[ "_$GITHUB_TOKEN" != "_" ]]; then
GITHUT_AUTH="Authorization: token $GITHUB_TOKEN"
else
echo "ERROR: Unable to find github authentication token file: "
echo " - You can create such a token at https://github.com/settings/tokens > 'Generate a new token'."
echo " - Then copy the token and paste it in the file '~/.config/${PROJECT_NAME}/.github' using a valid token."
exit 1
fi
case "$1" in
del)
result=`curl -i "$REPO_API_URL/releases/tags/v$current"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "$REPO_API_URL/releases/\d+"`
if [[ $release_url != "" ]]; then
echo "Deleting existing release..."
curl -H 'Authorization: token $GITHUB_TOKEN' -XDELETE $release_url
fi
;;
pre|rel)
if [[ "_$2" != "_" ]]; then
if [[ $1 = "pre" ]]; then
prerelease="true"
else
prerelease="false"
fi
description=`echo $2`
if [[ "_$description" = "_" ]]; then
description="Release v$current"
fi
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/v$current"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+/releases/\d+"`
if [[ "_$release_url" != "_" ]]; then
echo "Deleting existing release... $release_url"
result=`curl -H ''"$GITHUT_AUTH"'' -s -XDELETE $release_url`
if [[ "_$result" != "_" ]]; then
error_message=`echo "$result" | grep -P "\"message\": \"[^\"]+" | grep -oP ": \"[^\"]+\""`
echo "Delete existing release failed with error$error_message"
exit 1
fi
else
echo "Release not exists yet on github."
fi
echo "Creating new release..."
echo " - tag: v$current"
echo " - description: $description"
result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_API_URL/releases -d '{"tag_name": "v'"$current"'","target_commitish": "master","name": "'"$current"'","body": "'"$description"'","draft": false,"prerelease": '"$prerelease"'}'`
#echo "DEBUG - $result"
upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
if [[ "_$upload_url" = "_" ]]; then
echo "Failed to create new release for repo $REPO."
echo "Server response:"
echo "$result"
exit 1
fi
### Sending files
echo "Uploading files to ${upload_url} ..."
dirname=$(pwd)
ZIP_FILE="$dirname/platforms/web/build/${PROJECT_NAME}-v$current-web.zip"
if [[ -f "${ZIP_FILE}" ]]; then
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${PROJECT_NAME}-v${current}-web.zip")
browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+")
ZIP_SHA256=$(sha256sum "${ZIP_FILE}")
echo " - ${browser_download_url} | SHA256 Checksum: ${ZIP_SHA256}"
else
echo " - ERROR: Web release (ZIP) not found! Skipping."
fi
APK_FILE="${dirname}/platforms/android/build/outputs/apk/release/android-release.apk"
if [[ -f "${APK_FILE}" ]]; then
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/vnd.android.package-archive' -T "${APK_FILE}" "${upload_url}?name=${PROJECT_NAME}-v${current}-android.apk")
browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+")
APK_SHA256=$(sha256sum "${APK_FILE}")
echo " - ${browser_download_url} | SHA256 Checksum: ${APK_SHA256}"
else
echo "- ERROR: Android release (APK) not found! Skipping."
fi
echo "-----------------------------------------"
echo "Successfully uploading files !"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/v${current}"
exit 0
else
echo "Wrong arguments"
echo "Usage:"
echo " > ./github.sh del|pre|rel <release_description>"
echo "With:"
echo " - del: delete existing release"
echo " - pre: use for pre-release"
echo " - rel: for full release"
exit 1
fi
;;
*)
echo "No task given"
exit 1
;;
esac
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var path = require("path");
var sass = require('gulp-sass');
var cleanCss = require('gulp-clean-css');
var base64 = require('gulp-base64');
var rename = require('gulp-rename');
var sh = require('shelljs');
var ngConstant = require('gulp-ng-constant');
var fs = require("fs");
var argv = require('yargs').argv;
var header = require('gulp-header');
var footer = require('gulp-footer');
var removeCode = require('gulp-remove-code');
var removeHtml = require('gulp-html-remove');
var templateCache = require('gulp-angular-templatecache');
var ngTranslate = require('gulp-angular-translate');
var ngAnnotate = require('gulp-ng-annotate');
var es = require('event-stream');
var zip = require('gulp-zip');
var del = require('del');
var useref = require('gulp-useref');
var filter = require('gulp-filter');
var uglify = require('gulp-uglify');
var csso = require('gulp-csso');
var replace = require('gulp-replace');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var clean = require('gulp-clean');
var htmlmin = require('gulp-htmlmin');
var jshint = require('gulp-jshint');
var sourcemaps = require('gulp-sourcemaps');
var concatCss = require('gulp-concat-css');
var markdown = require('gulp-markdown');
var paths = {
sass: ['./scss/**/*.scss'],
const gulp = require('gulp'),
path = require("path"),
sass = require('gulp-sass')(require('node-sass')),
cleanCss = require('gulp-clean-css'),
base64 = require('gulp-base64-v2'),
rename = require('gulp-rename'),
ngConstant = require('gulp-ng-constant'),
fs = require("fs"),
header = require('gulp-header'),
footer = require('gulp-footer'),
removeCode = require('gulp-remove-code'),
removeHtml = require('gulp-html-remove'),
templateCache = require('gulp-angular-templatecache'),
ngTranslate = require('gulp-angular-translate'),
ngAnnotate = require('gulp-ng-annotate'),
zip = require('gulp-zip'),
del = require('del'),
debug = require('gulp-debug'),
useref = require('gulp-useref'),
filter = require('gulp-filter'),
uglify = require('gulp-uglify-es').default,
sourcemaps = require('gulp-sourcemaps'),
lazypipe = require('lazypipe'),
csso = require('gulp-csso'),
replace = require('gulp-replace'),
clean = require('gulp-clean'),
htmlmin = require('gulp-htmlmin'),
jshint = require('gulp-jshint'),
markdown = require('gulp-markdown'),
merge = require('merge2'),
log = require('fancy-log'),
colors = require('ansi-colors'),
{argv} = require('yargs'),
sriHash = require('gulp-sri-hash'),
sort = require('gulp-sort'),
map = require('map-stream');
// Workaround because @ioni/v1-toolkit use gulp v3.9.2 instead of gulp v4
let jsonlint;
try {
jsonlint = require('@prantlf/gulp-jsonlint');
} catch(e) {
log(colors.red("Cannot load 'gulp-jsonlint'. Retrying using project path"), e);
}
const paths = {
license_md: ['./www/license/*.md'],
sass: ['./scss/ionic.app.scss'],
config: ['./app/config.json'],
templatecache: ['./www/templates/**/*.html'],
ng_translate: ['./www/i18n/locale-*.json'],
ng_annotate: ['./www/js/**/*.js', '!./www/js/vendor/*.js'],
// plugins:
leafletSass: ['./scss/leaflet.app.scss'],
css_plugin: ['./www/plugins/*/css/**/*.css'],
templatecache_plugin: ['./www/plugins/*/templates/**/*.html'],
ng_translate_plugin: ['./www/plugins/*/i18n/locale-*.json'],
ng_annotate_plugin: ['./www/plugins/*/**/*.js', '!./www/plugins/*/js/vendor/*.js'],
css_plugin: ['./www/plugins/*/css/**/*.css'],
license_md: ['./www/license/*.md']
ng_annotate_plugin: ['./www/plugins/*/**/*.js', '!./www/plugins/*/js/vendor/*.js']
};
gulp.task('serve:before', ['sass',
'templatecache',
'ng_annotate',
'ng_translate',
'templatecache_plugin',
'ng_annotate_plugin',
'ng_translate_plugin',
'css_plugin',
'license_md']);
gulp.task('default', ['config', 'serve:before']);
gulp.task('sass-images', function (done) {
gulp.src('./scss/leaflet/images/**/*.*')
.pipe(gulp.dest('./www/img/'))
.on('end', done);
});
const uglifyBaseOptions = {
toplevel: true,
warnings: true,
mangle: {
reserved: ['qrcode', 'Base58']
},
compress: {
global_defs: {
"@console.log": "alert"
},
passes: 2
},
output: {
beautify: false,
preamble: "/* minified */",
max_line_len: 120000
}
};
const cleanCssOptions = {
specialComments: 0 // new name of 'keepSpecialComments', since 4.0
}
const debugBaseOptions = {
title: 'Processing',
minimal: true,
showFiles: argv.debug || false,
showCount: argv.debug || false,
logger: m => log(colors.grey(m))
};
function appAndPluginWatch(done) {
gulp.task('sass', ['sass-images'], function(done) {
log(colors.green('Watching source files...'));
// Licenses
gulp.watch(paths.license_md, () => appLicense());
// App
gulp.watch(paths.sass, () => appSass());
gulp.watch(paths.templatecache, () => appNgTemplate());
gulp.watch(paths.ng_annotate, (event) => appNgAnnotate(event));
gulp.watch(paths.ng_translate, () => appNgTranslate());
// Plugins
gulp.watch(paths.templatecache_plugin, () => pluginNgTemplate());
gulp.watch(paths.ng_annotate_plugin, (event) => pluginNgAnnotate(event));
gulp.watch(paths.ng_translate_plugin, () => pluginNgTranslate());
gulp.watch(paths.css_plugin.concat(paths.leafletSass), () => pluginSass());
if (done) done();
}
function appAndPluginClean() {
return del([
'./www/dist',
'./www/css/ionic.app*.css',
'./www/css/leaflet.app*.css'
]);
}
/**
* Generate App CSS (using SASS)
* @returns {*}
*/
function appSass() {
log(colors.green('Building App Sass...'));
es.concat(
// Default App style
gulp.src('./scss/ionic.app.scss')
return gulp.src('./scss/ionic.app.scss')
.pipe(sass()).on('error', sass.logError)
.pipe(base64({
baseDir: "./www/css",
......@@ -81,92 +137,30 @@ gulp.task('sass', ['sass-images'], function(done) {
maxImageSize: 14 * 1024
}))
.pipe(gulp.dest('./www/css/'))
.pipe(cleanCss({
keepSpecialComments: 0
}))
.pipe(sourcemaps.write())
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/')),
// Leaflet App style
gulp.src('./scss/leaflet.app.scss')
.pipe(sass()).on('error', sass.logError)
// Fix bad images path
.pipe(replace("url('../images/", "url('../img/"))
.pipe(replace("url(\"../images/", "url(\"../img/"))
.pipe(replace("url('images/", "url('../img/"))
.pipe(replace("url(\"images/", "url(\"../img/"))
.pipe(replace("url(images/", "url(../img/"))
.pipe(base64({
baseDir: "./www/css/",
extensions: ['png', 'gif', /\.jpg#datauri$/i],
maxImageSize: 14 * 1024,
deleteAfterEncoding: true
}))
.pipe(gulp.dest('./www/css/'))
.pipe(cleanCss({
keepSpecialComments: 0
}))
.pipe(sourcemaps.write())
.pipe(cleanCss(cleanCssOptions))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
)
.on('end', done);
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.templatecache, ['templatecache']);
gulp.watch(paths.ng_annotate, ['ng_annotate']);
gulp.watch(paths.ng_translate, ['ng_translate']);
// plugins:
gulp.watch(paths.templatecache_plugin, ['templatecache_plugin']);
gulp.watch(paths.ng_annotate_plugin, ['ng_annotate_plugin']);
gulp.watch(paths.ng_translate_plugin, ['ng_translate_plugin']);
gulp.watch(paths.css_plugin, ['css_plugin']);
gulp.watch(paths.license_md, ['license_md']);
});
gulp.task('install', ['git-check'], function() {
return bower.commands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
gulp.task('git-check', function(done) {
if (!sh.which('git')) {
console.log(
' ' + gutil.colors.red('Git is not installed.'),
'\n Git, the version control system, is required to download Ionic.',
'\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
);
process.exit(1);
.pipe(gulp.dest('./www/css/'));
}
done();
});
gulp.task('config', function (done) {
var allConfig = JSON.parse(fs.readFileSync('./app/config.json', 'utf8'));
function appConfig() {
const allConfig = JSON.parse(fs.readFileSync('./app/config.json', 'utf8'));
// Determine which environment to use when building config.
var env = argv.env || 'default';
var config = allConfig[env];
const env = argv.env || 'default';
const config = allConfig[env];
if (!config) {
gutil.log(gutil.colors.red("=> Could not load `" + env + "` environment!"));
process.exit(1);
throw new Error(colors.red("=> Could not load `" + env + "` environment!"));
}
gutil.log(gutil.colors.green("Building `www/js/config.js` for `" + env + "` environment..."));
log(colors.green("Building App config at `www/js/config.js` for `" + env + "` environment..."));
var project = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const project = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
config['version'] = project.version;
config['build'] = (new Date()).toJSON();
config['newIssueUrl'] = project.bugs.new;
ngConstant({
return ngConstant({
name: 'cesium.config',
constants: {"csConfig": config},
stream: true,
......@@ -176,38 +170,102 @@ gulp.task('config', function (done) {
.pipe(header("/******\n* !! WARNING: This is a generated file !!\n*\n* PLEASE DO NOT MODIFY DIRECTLY\n*\n* => Changes should be done on file 'app/config.json'.\n******/\n\n"))
// Writes into file www/js/config.js
.pipe(rename('config.js'))
.pipe(gulp.dest('www/js'))
.on('end', done);
});
.pipe(gulp.dest('www/js'));
}
function appConfigTest() {
const allConfig = JSON.parse(fs.readFileSync('./app/config.json', 'utf8'));
// Determine which environment to use when building config.
const env = 'g1-test';
const config = allConfig[env];
gulp.task('templatecache', function (done) {
gulp.src(paths.templatecache)
if (!config) {
throw new Error(colors.red("=> Could not load `" + env + "` environment!"));
}
log(colors.green("Building App test config at `www/js/config-test.js` for `" + env + "` environment..."));
const project = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
config['version'] = project.version;
config['build'] = (new Date()).toJSON();
config['newIssueUrl'] = project.bugs.new;
return ngConstant({
name: 'cesium.config',
constants: {"csConfig": config},
stream: true,
dest: 'config-test.js'
})
// Add a warning header
.pipe(header("/******\n* !! WARNING: This is a generated file !!\n*\n* PLEASE DO NOT MODIFY DIRECTLY\n*\n* => Changes should be done on file 'app/config.json'.\n******/\n\n"))
// Writes into file www/js/config-test.js
.pipe(rename('config-test.js'))
.pipe(gulp.dest('www/js'));
}
function appAndPluginLint() {
log(colors.green('Linting JS files...'));
// Copy Js (and remove unused code)
return gulp.src(paths.ng_annotate.concat(paths.ng_annotate_plugin))
.pipe(debug({...debugBaseOptions, title: 'Linting'}))
.pipe(jshint())
.pipe(jshint.reporter(require('jshint-stylish')))
.pipe(map( (file, cb) => {
if (!file.jshint.success) {
console.error('jshint failed');
process.exit(1);
}
cb();
}));
}
function appNgTemplate() {
log(colors.green('Building template file...'));
return gulp.src(paths.templatecache)
.pipe(sort())
.pipe(templateCache({
standalone: true,
module: "cesium.templates",
root: "templates/"
}))
.pipe(gulp.dest('./www/dist/dist_js/app'))
.on('end', done);
});
.pipe(gulp.dest('./www/dist/dist_js/app'));
}
function appNgAnnotate(event) {
gulp.task('ng_annotate', function (done) {
gulp.src(paths.ng_annotate)
// If watch, apply only on changes files
if (event && event.type === 'changed' && event.path && event.path.indexOf('/www/js/') !== -1) {
let path = event.path.substring(event.path.indexOf('/www/js') + 7);
path = path.substring(0, path.lastIndexOf('/'));
return gulp.src(event.path)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest('./www/dist/dist_js/app'))
.on('end', done);
});
.pipe(gulp.dest('./www/dist/dist_js/app' + path));
}
gulp.task('ng_translate', function(done) {
gulp.src('www/i18n/locale-*.json')
log(colors.green('Building JS files...'));
return gulp.src(paths.ng_annotate)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest('./www/dist/dist_js/app'));
}
function appNgTranslate() {
log(colors.green('Building translation file...'));
return gulp.src('www/i18n/locale-*.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter())
.pipe(sort())
.pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
.pipe(gulp.dest('www/dist/dist_js/app'))
.on('end', done);
});
.pipe(gulp.dest('www/dist/dist_js/app'));
}
function appLicense() {
log(colors.green('Building License files...'));
gulp.task('license_md', function (done) {
es.concat(
return merge(
// Copy license into HTML
gulp.src(paths.license_md)
.pipe(markdown())
......@@ -220,105 +278,140 @@ gulp.task('license_md', function (done) {
.pipe(header('\ufeff')) // Need BOM character for UTF-8 files
.pipe(rename({ extname: '.txt' }))
.pipe(gulp.dest('www/license'))
)
.on('end', done);
});
gulp.task('debug_file', function(done) {
gutil.log(gutil.colors.green("Building `www/debug.html`..."));
return gulp.src(['www/index.html'])
.pipe(replace('dist/dist_js/app/', 'js/'))
.pipe(replace('dist/dist_js/plugins/', 'plugins/'))
// Restore some generate files
.pipe(replace('js/templates.js', 'dist/dist_js/app/templates.js'))
.pipe(replace('js/translations.js', 'dist/dist_js/app/translations.js'))
.pipe(replace('plugins/templates.js', 'dist/dist_js/plugins/templates.js'))
.pipe(replace('plugins/translations.js', 'dist/dist_js/plugins/translations.js'))
.pipe(replace('ng-strict-di', ''))
.pipe(rename('debug.html'))
.pipe(gulp.dest('www'))
.on('end', done);
});
);
}
/* -- Plugins -- */
gulp.task('templatecache_plugin', function (done) {
gulp.src(paths.templatecache_plugin)
function pluginNgTemplate() {
log(colors.green('Building Plugins template file...'));
return gulp.src(paths.templatecache_plugin)
.pipe(sort())
.pipe(templateCache({
standalone: true,
module: "cesium.plugins.templates",
root: "plugins/"
}))
.pipe(gulp.dest('./www/dist/dist_js/plugins'))
.on('end', done);
});
.pipe(gulp.dest('./www/dist/dist_js/plugins'));
}
gulp.task('ng_annotate_plugin', function (done) {
gulp.src(paths.ng_annotate_plugin)
function pluginNgAnnotate(event) {
// If watch, apply only on changes files
if (event && event.type === 'changed' && event.path && event.path.indexOf('/www/js/') !== -1) {
let path = event.path.substring(event.path.indexOf('/www/js') + 7);
path = path.substring(0, path.lastIndexOf('/'));
return gulp.src(event.path)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest('./www/dist/dist_js/plugins'))
.on('end', done);
});
.pipe(gulp.dest('./www/dist/dist_js/app' + path));
}
gulp.task('ng_translate_plugin', function(done) {
gulp.src(paths.ng_translate_plugin)
log(colors.green('Building Plugins JS file...'));
return gulp.src(paths.ng_annotate_plugin)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest('./www/dist/dist_js/plugins'));
}
function pluginNgTranslate() {
log(colors.green('Building Plugins translation file...'));
return gulp.src(paths.ng_translate_plugin)
.pipe(jsonlint())
.pipe(jsonlint.reporter())
.pipe(sort())
.pipe(ngTranslate({standalone:true, module: 'cesium.plugins.translations'}))
.pipe(gulp.dest('www/dist/dist_js/plugins'))
.on('end', done);
});
.pipe(gulp.dest('www/dist/dist_js/plugins'));
}
gulp.task('css_plugin', function (done) {
function pluginLeafletImages(dest) {
dest = dest || './www/img/';
// Leaflet images
return gulp.src(['scss/leaflet/images/*.*',
'www/lib/leaflet/dist/images/*.*',
'www/lib/leaflet-search/images/*.*',
'!www/lib/leaflet-search/images/back.png',
'!www/lib/leaflet-search/images/leaflet-search.jpg',
'www/lib/leaflet.awesome-markers/dist/images/*.*'],
{read: false, allowEmpty: true}
)
.pipe(gulp.dest(dest));
}
function pluginSass() {
log(colors.green('Building Plugins Sass...'));
return merge(
// Copy plugins CSS
gulp.src(paths.css_plugin)
.pipe(gulp.dest('./www/dist/dist_css/plugins'))
.on('end', done);
});
.pipe(gulp.dest('www/dist/dist_css/plugins')),
/* -- Web dist build -- */
gulp.task('clean:tmp', function() {
return del(['tmp']);
});
// Leaflet images
pluginLeafletImages('./www/img/'),
gulp.task('clean:web', function() {
// Leaflet App style
gulp.src('./scss/leaflet.app.scss')
.pipe(sass()).on('error', sass.logError)
// Fix bad images path
.pipe(replace("url('../images/", "url('../img/"))
.pipe(replace("url(\"../images/", "url(\"../img/"))
.pipe(replace("url('images/", "url('../img/"))
.pipe(replace("url(\"images/", "url(\"../img/"))
.pipe(replace("url(images/", "url(../img/"))
.pipe(base64({
baseDir: "./www/css/",
extensions: ['png', 'gif', /\.jpg#datauri$/i],
maxImageSize: 14 * 1024,
deleteAfterEncoding: false
}))
.pipe(gulp.dest('./www/css/'))
.pipe(cleanCss(cleanCssOptions))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
);
}
/* --------------------------------------------------------------------------
-- Build the web (ZIP) artifact
--------------------------------------------------------------------------*/
function webClean() {
return del([
'./platforms/web/www',
'./platforms/web/build'
'./dist/web/www'
]);
});
}
gulp.task('copy-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], function(done) {
var tmpPath = './platforms/web/www';
es.concat(
function webCopyFiles() {
log(colors.green('Preparing dist/web files...'));
let htmlminOptions = {removeComments: true, collapseWhitespace: true};
const debugOptions = { ...debugBaseOptions, title: 'Copying' };
var targetPath = './dist/web/www';
return merge(
// Copy Js (and remove unused code)
gulp.src('./www/js/**/*.js')
.pipe(debug(debugOptions))
.pipe(removeCode({"no-device": true}))
.pipe(jshint())
.pipe(gulp.dest(tmpPath + '/js')),
.pipe(gulp.dest(targetPath + '/js')),
// Copy HTML templates (and remove unused code)
gulp.src('./www/templates/**/*.html')
.pipe(removeCode({"no-device": true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(htmlmin())
.pipe(gulp.dest(tmpPath + '/templates')),
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(targetPath + '/templates')),
// Copy index.html (and remove unused code)
gulp.src('./www/index.html')
.pipe(removeCode({'no-device': true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(htmlmin())
.pipe(gulp.dest(tmpPath)),
// Copy index.html to debug.html (and remove unused code)
gulp.src('./www/index.html')
.pipe(removeCode({'no-device': true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(rename("debug.html"))
.pipe(gulp.dest(tmpPath)),
.pipe(htmlmin(/*no options, to keep comments*/))
.pipe(gulp.dest(targetPath)),
// Copy API index.html
gulp.src('./www/api/index.html')
......@@ -326,148 +419,162 @@ gulp.task('copy-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], functi
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(htmlmin())
.pipe(gulp.dest(tmpPath + '/api')),
.pipe(gulp.dest(targetPath + '/api')),
// Copy API index.html
gulp.src('./www/api/index.html')
.pipe(removeCode({'no-device': true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(rename("debug.html"))
.pipe(gulp.dest(tmpPath + '/api')),
// Copy config-test.js
gulp.src('./www/js/config*.js')
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath)),
// Copy fonts
gulp.src('./www/fonts/**/*.*')
.pipe(gulp.dest(tmpPath + '/fonts')),
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath + '/fonts')),
// Copy CSS
gulp.src('./www/css/**/*.*')
.pipe(gulp.dest(tmpPath + '/css')),
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath + '/css')),
// Copy i18n
gulp.src('./www/i18n/locale-*.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter())
.pipe(sort())
.pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
.pipe(gulp.dest(tmpPath + '/js')),
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath + '/js')),
// Copy img
gulp.src('./www/img/**/*.*')
.pipe(gulp.dest(tmpPath + '/img')),
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath + '/img')),
// Copy manifest
// Copy manifest.json
gulp.src('./www/manifest.json')
.pipe(gulp.dest(tmpPath)),
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath)),
// Copy lib/ionic
gulp.src('./www/lib/ionic/**/*.*')
.pipe(gulp.dest(tmpPath + '/lib/ionic')),
// Copy lib (JS, CSS and fonts)
gulp.src(['./www/lib/**/*.js', './www/lib/**/*.css', './www/lib/**/fonts/**/*.*'])
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath + '/lib')),
// Copy license into HTML
gulp.src('./www/license/*.md')
.pipe(markdown())
.pipe(header('<html><header><meta charset="utf-8"></header><body>'))
.pipe(footer('</body></html>'))
.pipe(gulp.dest(tmpPath + '/license')),
.pipe(gulp.dest(targetPath + '/license')),
// Copy license into txt
gulp.src('./www/license/*.md')
.pipe(header('\ufeff')) // Need BOM character for UTF-8 files
.pipe(rename({ extname: '.txt' }))
.pipe(gulp.dest(tmpPath + '/license'))
)
.on('end', done);
});
.pipe(gulp.dest(targetPath + '/license'))
);
}
gulp.task('templatecache:web', ['copy-files:web'], function (done) {
var tmpPath = './platforms/web/www';
gulp.src(tmpPath + '/templates/**/*.html')
function webNgTemplate() {
var targetPath = './dist/web/www';
return gulp.src(targetPath + '/templates/**/*.html')
.pipe(sort())
.pipe(templateCache({
standalone: true,
module: "cesium.templates",
root: "templates/"
}))
.pipe(gulp.dest(tmpPath + '/js'))
.on('end', done);
});
.pipe(gulp.dest(targetPath + '/dist/dist_js/app'));
}
gulp.task('ng_annotate:web', ['templatecache:web'], function (done) {
var tmpPath = './platforms/web/www';
function webAppNgAnnotate() {
var targetPath = './dist/web/www';
var jsFilter = filter(["**/*.js", "!**/vendor/*"]);
gulp.src(tmpPath + '/js/**/*.js')
return gulp.src(targetPath + '/js/**/*.js')
.pipe(jsFilter)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(tmpPath + '/dist/dist_js/app'))
.on('end', done);
});
.pipe(gulp.dest(targetPath + '/dist/dist_js/app'));
}
function webPluginCopyFiles() {
const targetPath = './dist/web/www';
return merge(
// Copy Js (and remove unused code)
gulp.src('./www/plugins/**/*.js')
.pipe(removeCode({"no-device": true}))
.pipe(jshint())
.pipe(gulp.dest(targetPath + '/plugins')),
// Copy HTML templates (and remove unused code)
gulp.src('./www/plugins/**/*.html')
.pipe(removeCode({"no-device": true}))
.pipe(removeHtml('.hidden-no-device'))
.pipe(removeHtml('[remove-if][remove-if="no-device"]'))
.pipe(htmlmin())
.pipe(gulp.dest(targetPath + '/plugins')),
gulp.task('copy-plugin-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], function(done) {
var tmpPath = './platforms/web/www';
es.concat(
// Transform i18n into JS
gulp.src(paths.ng_translate_plugin)
.pipe(jsonlint())
.pipe(jsonlint.reporter())
.pipe(sort())
.pipe(ngTranslate({standalone:true, module: 'cesium.plugins.translations'}))
.pipe(gulp.dest(tmpPath + '/dist/dist_js/plugins')),
.pipe(gulp.dest(targetPath + '/dist/dist_js/plugins')),
// Copy CSS
// Copy plugin CSS
gulp.src(paths.css_plugin)
.pipe(gulp.dest(tmpPath + '/dist/dist_css/plugins'))
)
.on('end', done);
});
.pipe(gulp.dest(targetPath + '/dist/dist_css/plugins')),
// Copy Leaflet images
pluginLeafletImages(targetPath + '/img'),
// Copy Leaflet CSS
gulp.src('./www/css/**/leaflet.*')
.pipe(gulp.dest(targetPath + '/css'))
);
}
gulp.task('templatecache-plugin:web', ['copy-plugin-files:web'], function (done) {
var tmpPath = './platforms/web/www';
gulp.src(paths.templatecache_plugin)
function webPluginNgTemplate() {
var targetPath = './dist/web/www';
return gulp.src(targetPath + '/plugins/**/*.html')
.pipe(sort())
.pipe(templateCache({
standalone: true,
module: "cesium.plugins.templates",
root: "plugins/"
}))
.pipe(gulp.dest(tmpPath + '/dist/dist_js/plugins'))
.on('end', done);
});
.pipe(gulp.dest(targetPath + '/dist/dist_js/plugins'));
}
gulp.task('ng_annotate-plugin:web', ['templatecache-plugin:web'], function (done) {
var tmpPath = './platforms/web/www';
gulp.src(paths.ng_annotate_plugin)
function webPluginNgAnnotate() {
var targetPath = './dist/web/www';
return gulp.src(targetPath + '/plugins/**/*.js')
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(tmpPath + '/dist/dist_js/plugins'))
.on('end', done);
});
.pipe(gulp.dest(targetPath + '/dist/dist_js/plugins'));
}
gulp.task('debug-api-files:web', ['ng_annotate:web', 'ng_annotate-plugin:web'], function(done) {
var tmpPath = './platforms/web/www';
var debugFilter = filter('**/debug.html', { restore: true });
function webUglify() {
const targetPath = './dist/web/www';
const enableUglify = argv.release || argv.uglify || false;
const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
gulp.src(tmpPath + '/*/debug.html')
.pipe(useref()) // Concatenate with gulp-useref
if (enableUglify) {
.pipe(debugFilter)
.pipe(replace("dist_js", "../dist_js"))
.pipe(replace("dist_css", "../dist_css"))
.pipe(replace("config.js", "../config.js"))
.pipe(debugFilter.restore)
.pipe(gulp.dest(tmpPath))
.on('end', done);
});
log(colors.green('Minify JS and CSS files...'));
gulp.task('optimize-api-files:web', ['debug-api-files:web'], function(done) {
var tmpPath = './platforms/web/www';
var jsFilter = filter(["**/*.js", '!**/config.js'], { restore: true });
var cssFilter = filter("**/*.css", { restore: true });
var revFilesFilter = filter(['**/*', '!**/index.html', '!**/config.js'], { restore: true });
var indexFilter = filter('**/index.html', { restore: true });
var uglifyOptions = {beautify: false, max_line_len: 120000};;
const indexFilter = filter('**/index.html', {restore: true});
const jsFilter = filter(["**/*.js", '!**/config.js', '!**/config-test.js'], {restore: true});
const cssFilter = filter("**/*.css", {restore: true});
// Process index.html
gulp.src(tmpPath + '/*/index.html')
.pipe(useref()) // Concatenate with gulp-useref
return gulp.src(targetPath + '/index.html')
.pipe(useref({}, lazypipe().pipe(sourcemaps.init, { loadMaps: true }))) // Concatenate with gulp-useref
// Process JS
.pipe(jsFilter)
.pipe(uglify(uglifyOptions)) // Minify any javascript sources
.pipe(uglify(uglifyBaseOptions)) // Minify javascript files
.pipe(jsFilter.restore)
// Process CSS
......@@ -475,46 +582,64 @@ gulp.task('optimize-api-files:web', ['debug-api-files:web'], function(done) {
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
// Add revision to filename (but not index.html and config.js)
.pipe(revFilesFilter)
.pipe(rev()) // Rename the concatenated files
.pipe(revFilesFilter.restore)
.pipe(revReplace()) // Substitute in new filenames
// Add version to file path
.pipe(indexFilter)
.pipe(replace("dist_js", "../dist_js"))
.pipe(replace("dist_css", "../dist_css"))
.pipe(replace("config.js", "../config.js"))
.pipe(replace(/"(dist_js\/[a-zA-Z0-9]+).js"/g, '"$1.js?v=' + version + '"'))
.pipe(replace(/"(dist_css\/[a-zA-Z0-9]+).css"/g, '"$1.css?v=' + version + '"'))
.pipe(indexFilter.restore)
.pipe(gulp.dest(tmpPath))
.on('end', done);
.pipe(sourcemaps.write('maps'))
});
.pipe(gulp.dest(targetPath));
}
else {
return Promise.resolve();
}
}
gulp.task('debug-files:web', ['optimize-api-files:web'], function(done) {
var tmpPath = './platforms/web/www';
gulp.src(tmpPath + '/debug.html')
.pipe(useref()) // Concatenate with gulp-useref
.pipe(gulp.dest(tmpPath))
.on('end', done);
});
function webIntegrity() {
const targetPath = './dist/web/www';
const enableIntegrity = argv.release || false;
gulp.task('optimize-files:web', ['debug-files:web'], function(done) {
var tmpPath = './platforms/web/www';
var jsFilter = filter(["**/*.js", '!**/config.js'], { restore: true });
var cssFilter = filter("**/*.css", { restore: true });
var revFilesFilter = filter(['**/*', '!**/index.html', '!**/config.js'], { restore: true });
var uglifyOptions = {beautify: false, max_line_len: 120000};
if (enableIntegrity) {
log(colors.green('Create index.integrity.html... '));
// Process index.html
gulp.src(tmpPath + '/index.html')
.pipe(useref()) // Concatenate with gulp-useref
return gulp.src(targetPath + '/index.html', {base: targetPath})
// Add an integrity hash
.pipe(sriHash())
.pipe(rename({ extname: '.integrity.html' }))
.pipe(gulp.dest(targetPath));
}
else {
return Promise.resolve();
}
}
function webApiUglify() {
const targetPath = './dist/web/www';
const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
const jsFilter = filter(["**/*.js", '!**/config.js', '!**/config-test.js'], {restore: true});
const cssFilter = filter("**/*.css", {restore: true});
const indexFilter = filter('**/index.html', {restore: true});
// Skip if not required
const enableUglify = argv.release || argv.uglify || false;
if (enableUglify) {
log(colors.green('API: Minify JS and CSS files...'));
// Process api/index.html
return gulp.src(targetPath + '/*/index.html')
.pipe(useref({}, lazypipe().pipe(sourcemaps.init, { loadMaps: true }))) // Concatenate with gulp-useref
// Process JS
.pipe(jsFilter)
.pipe(uglify(uglifyOptions)) // Minify any javascript sources
.pipe(uglify(uglifyBaseOptions)) // Minify any javascript sources
.pipe(jsFilter.restore)
// Process CSS
......@@ -522,47 +647,136 @@ gulp.task('optimize-files:web', ['debug-files:web'], function(done) {
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
// Add revision to filename (but not index.html and config.js)
.pipe(revFilesFilter)
.pipe(rev()) // Rename the concatenated files
.pipe(revFilesFilter.restore)
.pipe(indexFilter)
.pipe(revReplace()) // Substitute in new filenames
.pipe(gulp.dest(tmpPath))
.on('end', done);
});
// Add version to files path
.pipe(replace(/"(dist_js\/[a-zA-Z0-9-.]+).js"/g, '"$1.js?v=' + version + '"'))
.pipe(replace(/"(dist_css\/[a-zA-Z0-9-.]+).css"/g, '"$1.css?v=' + version + '"'))
gulp.task('clean-unused-files:web', ['optimize-files:web'], function(done) {
var tmpPath = './platforms/web/www';
.pipe(replace("dist_js", "../dist_js"))
.pipe(replace("dist_css", "../dist_css"))
.pipe(replace("config.js", "../config.js"))
.pipe(replace("config-test.js", "../config-test.js"))
.pipe(indexFilter.restore)
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(targetPath));
}
else {
log(colors.red('API: Skipping minify JS and CSS files') + colors.grey(' (missing options --release or --uglify)'));
return gulp.src(targetPath + '/*/index.html')
.pipe(useref()) // Concatenate with gulp-useref
es.concat(
gulp.src(tmpPath + '/js/**/*.js', {read: false})
.pipe(indexFilter)
.pipe(replace("dist_js", "../dist_js"))
.pipe(replace("dist_css", "../dist_css"))
.pipe(replace("config.js", "../config.js"))
.pipe(replace("config-test.js", "../config-test.js"))
.pipe(indexFilter.restore)
.pipe(gulp.dest(targetPath));
}
}
function webCleanUnusedFiles(done) {
log(colors.green('Clean unused files...'));
const targetPath = './dist/web/www';
const enableUglify = argv.release || argv.uglify || false;
const cleanSources = enableUglify;
const debugOptions = {...debugBaseOptions,
title: 'Deleting',
showCount: !argv.debug
};
if (cleanSources) {
return merge(
// Clean core JS
gulp.src(targetPath + '/js/**/*.js', {read: false})
.pipe(debug(debugOptions))
.pipe(clean()),
gulp.src(tmpPath + '/css/**/*.css', {read: false})
// Clean core CSS
gulp.src(targetPath + '/css/**/*.css', {read: false})
.pipe(debug(debugOptions))
.pipe(clean()),
// Clean plugins JS + CSS
gulp.src(targetPath + '/plugins/**/*.js', {read: false})
.pipe(debug(debugOptions))
.pipe(clean()),
gulp.src(targetPath + '/plugins/**/*.css', {read: false})
.pipe(debug(debugOptions))
.pipe(clean()),
// Unused maps/config.js.map
gulp.src(targetPath + '/maps/config.js.map', {read: false, allowEmpty: true})
.pipe(debug(debugOptions))
.pipe(clean()),
gulp.src(targetPath + '/maps/config-test.js.map', {read: false, allowEmpty: true})
.pipe(debug(debugOptions))
.pipe(clean())
)
.on('end', done);
});
}
gulp.task('clean-unused-directories:web', ['clean-unused-files:web'], function() {
var tmpPath = './platforms/web/www';
return del([
tmpPath + '/css',
tmpPath + '/templates',
tmpPath + '/js',
tmpPath + '/dist',
tmpPath + '/lib/ionic/scss',
tmpPath + '/lib/ionic/css',
tmpPath + '/lib/ionic/js',
tmpPath + '/lib/ionic/version.json'
if (done) done();
}
function webCleanUnusedDirectories() {
log(colors.green('Clean unused directories...'));
const enableUglify = argv.release || argv.uglify || false;
const debugOptions = { ...debugBaseOptions,
title: 'Deleting',
showCount: !argv.debug
};
// Clean dir
const wwwPath = './dist/web/www';
let patterns = [
wwwPath + '/templates',
wwwPath + '/plugins'
];
if (enableUglify) {
patterns = patterns.concat([
wwwPath + '/js',
wwwPath + '/css',
wwwPath + '/dist',
wwwPath + '/lib/*',
// Keep IonIcons font
'!' + wwwPath + '/lib/ionic',
wwwPath + '/lib/ionic/*',
'!' + wwwPath + '/lib/ionic/fonts',
// Keep RobotoDraft font
'!' + wwwPath + '/lib/robotodraft',
wwwPath + '/lib/robotodraft/*',
'!' + wwwPath + '/lib/robotodraft/fonts'
]);
});
}
else {
patterns = patterns.concat([
wwwPath + '/js/*',
'!' + wwwPath + '/js/vendor',
wwwPath + '/dist_css',
wwwPath + '/dist_js'
]);
}
gulp.task('zip:web', ['clean-unused-directories:web'], function() {
var tmpPath = './platforms/web/www';
var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
var txtFilter = filter(["**/*.txt"], { restore: true });
return gulp.src(patterns, {read: false, allowEmpty: true})
.pipe(debug(debugOptions))
.pipe(clean());
}
function webZip() {
const tmpPath = './dist/web/www';
const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
const txtFilter = filter(["**/*.txt"], { restore: true });
return gulp.src(tmpPath + '/**/*.*')
......@@ -573,12 +787,675 @@ gulp.task('zip:web', ['clean-unused-directories:web'], function() {
.pipe(zip('cesium-v'+version+'-web.zip'))
.pipe(gulp.dest('./platforms/web/build'));
});
.pipe(gulp.dest('./dist/web/build'));
}
function webExtClean() {
return del([
'./dist/web/ext'
]);
}
function webExtCopyFiles() {
const wwwPath = './dist/web/www';
const resourcesPath = './resources/web-ext';
log(colors.green('Copy web extension files...'));
const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
const manifestFilter = filter(["**/manifest.json"], { restore: true });
const txtFilter = filter(["**/*.txt"], { restore: true });
// Copy files
return gulp.src([
wwwPath + '/**/*',
// Skip API files
'!' + wwwPath + '/api',
'!' + wwwPath + '/dist_js/*-api.js',
'!' + wwwPath + '/dist_css/*-api.css',
'!' + wwwPath + '/maps/dist_js/*-api.js.map',
'!' + wwwPath + '/maps/dist_css/*-api.css.map',
// Skip web manifest
'!' + wwwPath + '/manifest.json',
// Add specific resource (and overwrite the default 'manifest.json')
resourcesPath + '/**/*.*'
])
// Process TXT files: Add the UTF-8 BOM character
.pipe(txtFilter)
.pipe(header('\ufeff'))
.pipe(txtFilter.restore)
// Replace version in 'manifest.json' file
.pipe(manifestFilter)
.pipe(replace(/\"version\": \"[^\"]*\"/, '"version": "' + version + '"'))
.pipe(manifestFilter.restore)
gulp.task('build:web', ['git-check', 'zip:web'], function() {
.pipe(gulp.dest('./dist/web/ext'));
}
function webExtensionZip() {
const srcPath = './dist/web/ext';
const distPath = './dist/web/build';
const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
return gulp.src(srcPath + '/**/*.*')
.pipe(zip('cesium-v'+version+'-extension.zip'))
.pipe(gulp.dest(distPath));
}
function webBuildSuccess(done) {
var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
log(colors.green("Web artifact created at: 'dist/web/build/cesium-v" + version + "-web.zip'"));
if (done) done();
}
function webExtBuildSuccess(done) {
var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
gutil.log(gutil.colors.green("Build for web created at: 'plateforms/web/build/cesium-v" + version + "-web.zip'"));
return del(['tmp']);
});
log(colors.green("Web extension artifact created at: 'dist/web/build/cesium-v" + version + "-extension.zip'"));
if (done) done();
}
function cdvAddPlatformToBodyTag() {
log(colors.green('Add platform CSS class to <body>... '));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app','src','main','assets','www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
const indexPath = path.join(wwwPath, 'index.html');
// no opening body tag, something's wrong
if (!fs.existsSync(indexPath)) throw new Error('Unable to find the file ' + indexPath +'!');
// add the platform class to the body tag
try {
const platformClass = 'platform-' + platform;
const cordovaClass = 'platform-cordova platform-webview';
let html = fs.readFileSync(indexPath, 'utf8');
// get the body tag
let matches = html && html.match(/<body[^>/]+>/gi)
const bodyTag = matches && matches[0];
// no opening body tag, something's wrong
if (!bodyTag) throw new Error('No <body> element found in file ' + indexPath);
if (bodyTag.indexOf(platformClass) > -1) return; // already added
let newBodyTag = '' + bodyTag;
matches = bodyTag.match(/ class=["|'](.*?)["|']/gi);
const classAttr = matches && matches[0];
if (classAttr) {
// body tag has existing class attribute, add the classname
let endingQuote = classAttr.substring(classAttr.length - 1);
let newClassAttr = classAttr.substring(0, classAttr.length - 1);
newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
newBodyTag = newBodyTag.replace(classAttr, newClassAttr);
} else {
// add class attribute to the body tag
newBodyTag = newBodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
}
html = html.replace(bodyTag, newBodyTag);
fs.writeFileSync(indexPath, html, 'utf8');
return Promise.resolve();
} catch (e) {
return Promise.reject(e);
}
}
function cdvNgAnnotate() {
log(colors.green('Building JS files... '));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app','src','main','assets','www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
const jsFilter = filter(["**/*.js", "!**/vendor/*"]);
return merge(
// Ng annotate app JS file
gulp.src(wwwPath + '/js/**/*.js')
.pipe(jsFilter)
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/app')),
// Ng annotate app JS file
gulp.src(wwwPath + '/plugins/**/*.js')
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/plugins'))
);
}
function cdvRemoveCode() {
log(colors.green('Removing code... '));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app','src','main','assets','www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
const appJsPath = [path.join(wwwPath, 'js', '**', '*.js'),
// Exclude vendor libs
"!" + path.join(wwwPath, 'js', 'vendor', '**', '*.js')];
const pluginPath = path.join(wwwPath, 'plugins', '*');
const pluginJsPath = path.join(pluginPath, '**', '*.js');
// Compute options {device-<platform>: true}
let removeCodeOptions = {};
removeCodeOptions[platform] = true; // = {<platform>: true}
const htmlminOptions = {removeComments: true, collapseWhitespace: true};
const debugOptions = {...debugBaseOptions,
showCount: false
};
// 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...
return merge(
// Remove unused HTML tags
gulp.src(path.join(wwwPath, 'templates', '**', '*.html'))
.pipe(debug(debugOptions))
.pipe(removeCode({device: true}))
.pipe(removeCode(removeCodeOptions))
.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(debug(debugOptions))
.pipe(removeCode({device: true}))
.pipe(removeCode(removeCodeOptions))
.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(debug(debugOptions))
.pipe(removeCode({device: true}))
.pipe(removeCode(removeCodeOptions))
.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(appJsPath)
.pipe(debug(debugOptions))
.pipe(removeCode({device: true}))
.pipe(removeCode(removeCodeOptions))
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/app')),
gulp.src(pluginJsPath)
.pipe(debug(debugOptions))
.pipe(removeCode({device: true}))
.pipe(removeCode(removeCodeOptions))
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/plugins'))
);
} else {
return merge(
gulp.src(path.join(wwwPath, 'templates', '**', '*.html'))
.pipe(debug(debugOptions))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(wwwPath + '/templates')),
gulp.src(path.join(pluginPath, '**', '*.html'))
.pipe(debug(debugOptions))
.pipe(htmlmin(htmlminOptions))
.pipe(gulp.dest(pluginPath)),
gulp.src(path.join(wwwPath, 'index.html'))
.pipe(gulp.dest(wwwPath)),
gulp.src(appJsPath)
.pipe(debug(debugOptions))
.pipe(ngAnnotate({single_quotes: true}))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/app')),
gulp.src(pluginJsPath)
.pipe(debug(debugOptions))
.pipe(gulp.dest(wwwPath + '/dist/dist_js/plugins'))
);
}
}
function cdvNgTemplate() {
log(colors.green('Building template files...'));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app','src','main','assets','www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
let distJsPath = path.join(wwwPath, 'dist', 'dist_js', 'app');
let pluginDistJsPath = path.join(wwwPath, 'dist', 'dist_js', 'plugins');
const debugOptions = { ...debugBaseOptions,
showCount: false
};
// Concat templates into a JS
return merge(
gulp.src(path.join(wwwPath, 'templates', '**', '*.html'))
.pipe(debug(debugOptions))
.pipe(templateCache({
standalone: true,
module: "cesium.templates",
root: "templates/"
}))
.pipe(gulp.dest(distJsPath)),
gulp.src(path.join(wwwPath, 'plugins', '*', 'templates', '**', '*.html'))
.pipe(debug(debugOptions))
.pipe(templateCache({
standalone: true,
module: "cesium.plugins.templates",
root: "plugins/"
}))
.pipe(gulp.dest(pluginDistJsPath))
);
}
function cdvNgTranslate() {
log(colors.green('Building translation files...'));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
let distJsPath = path.join(wwwPath, 'dist', 'dist_js', 'app');
let pluginDistJsPath = path.join(wwwPath, 'dist', 'dist_js', 'plugins');
const debugOptions = {
title: 'Processing',
minimal: true,
showFiles: argv.debug || false,
showCount: false,
logger: m => log(colors.grey(m))
};
// Concat templates into a JS
return merge(
gulp.src(wwwPath + '/i18n/locale-*.json')
.pipe(debug(debugOptions))
.pipe(ngTranslate({standalone: true, module: 'cesium.translations'}))
.pipe(gulp.dest(distJsPath)),
gulp.src(wwwPath + '/plugins/*/i18n/locale-*.json')
.pipe(debug(debugOptions))
.pipe(ngTranslate({standalone: true, module: 'cesium.plugins.translations'}))
.pipe(gulp.dest(pluginDistJsPath))
);
}
function cdvUglify() {
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
let indexPath = path.join(wwwPath, 'index.html');
// Skip if not required
const enableUglify = argv.release || argv.uglify || false;
if (enableUglify) {
log(colors.green('Minify JS and CSS files...'));
// WARN: uglify only libs, to keep sources readable (need by free repo)
const jsLibFilter = filter(['*/lib/**/*.js', '*/js/vendor/**/*.js'], {restore: true}); // External libs only
const cssFilter = filter("**/*.css", {restore: true});
const cdvUglifyOptions = {
...uglifyBaseOptions,
ecma: '5'
};
const debugOptions = { ...debugBaseOptions,
title: 'Minifying',
showCount: false
};
return gulp.src(indexPath)
.pipe(useref()) // Concatenate with gulp-useref
// Process JS
.pipe(jsLibFilter)
.pipe(debug(debugOptions))
.pipe(uglify(cdvUglifyOptions))// Minify javascript sources
.pipe(jsLibFilter.restore)
// Process CSS
.pipe(cssFilter)
.pipe(debug(debugOptions))
.pipe(csso()) // Minify any CSS sources
.pipe(cssFilter.restore)
.pipe(gulp.dest(wwwPath));
}
else {
log(colors.red('Skipping minify JS and CSS files') + colors.grey(' (missing options --release or --uglify)'));
return Promise.resolve();
}
}
function cdvCleanUnusedDirectories() {
log(colors.green('Clean unused directories...'));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
let wwwPath;
if (platform === 'android') {
wwwPath = path.join(projectRoot, 'platforms', platform, 'app', 'src', 'main', 'assets', 'www');
} else {
wwwPath = path.join(projectRoot, 'platforms', platform, 'www');
}
const enableUglify = argv.release || argv.uglify || false;
const debugOptions = {
title: 'Deleting',
minimal: true,
showFiles: argv.debug || false,
showCount: !argv.debug,
logger: m => log(colors.grey(m))
};
let patterns = [
wwwPath + '/api',
// Remove HTML templates - replaced by ngTemplate()
wwwPath + '/templates',
// Remove Cesium plugins
// (WARN: remove one by one, to keep Cordova plugins)
wwwPath + '/plugins/es',
wwwPath + '/plugins/graph',
wwwPath + '/plugins/map',
wwwPath + '/plugins/rml9',
// Remove translations - replaced by ngTranslate()
wwwPath + '/**/i18n',
];
if (enableUglify) {
patterns = patterns.concat([
wwwPath + '/js',
wwwPath + '/css', // Have been replaced by useref(), into 'dist_css'
wwwPath + '/dist', // Have been replaced by useref(), into 'dist_js'
wwwPath + '/cordova-js-src',
// Clean lib directory...
wwwPath + '/lib/*',
// ...but Keep IonIcons font
'!' + wwwPath + '/lib/ionic',
wwwPath + '/lib/ionic/*',
'!' + wwwPath + '/lib/ionic/fonts',
// ...but Keep RobotoDraft font
'!' + wwwPath + '/lib/robotodraft',
wwwPath + '/lib/robotodraft/*',
'!' + wwwPath + '/lib/robotodraft/fonts'
]);
}
else {
patterns = patterns.concat([
wwwPath + '/js/*', // Have been replace into dist/dist_js
'!' + wwwPath + '/js/vendor', // BUT keep vendor lib
]);
}
return gulp.src(patterns, {read: false, allowEmpty: true})
.pipe(debug(debugOptions))
.pipe(clean());
}
function cdvCopyBuildFiles() {
log(colors.green('Copy build files... '));
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
const srcPath = path.join(projectRoot, 'resources', platform, 'build');
const targetPath = path.join(projectRoot, 'platforms', platform);
const debugOptions = { ...debugBaseOptions, title: 'Copying',
showFiles: argv.debug || false,
showCount: !argv.debug
};
if (fs.existsSync(srcPath)) {
return gulp.src(srcPath + '/**/*.*')
.pipe(debug(debugOptions))
.pipe(gulp.dest(targetPath));
}
else {
log(colors.blue(' Directory ' + srcPath + 'not found. Skipping copy to ' + targetPath));
return Promise.resolve();
}
}
function cdvAndroidManifest() {
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
if (platform !== 'android') return Promise.resolve(); // Skip
const srcMainPath = path.join(projectRoot, 'platforms', platform, 'app', 'src', 'main');
const androidManifestFile = path.join(srcMainPath, 'AndroidManifest.xml');
log(colors.green('Patch Android manifest... ') + colors.grey(androidManifestFile));
if (!fs.existsSync(androidManifestFile)) {
throw Error("Missing required file " + androidManifestFile);
}
return 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">'))
// Use AndroidX
.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> (tools:overrideLibrary)
.pipe(replace(/(<\/manifest>)/, ' <uses-sdk tools:overrideLibrary="org.kaliumjni.lib,org.apache.cordova" />\n$1'))
// Add URI scheme web+june
// Patch invalid intent-filter (should be a bug of cordova-plugin-customurlschema)
// FIXME : this cause too many intent-filter are appended, on each build
//.pipe(replace('<data android:host=" " android:pathPrefix="/" android:scheme=" " />', '<data android:scheme="web+june" />'))
.pipe(gulp.dest(srcMainPath));
}
function cdvAndroidCheckSigning() {
const projectRoot = argv.root || '.';
const platform = argv.platform || 'android';
if (platform !== 'android') return Promise.resolve(); // Skip
const targetPath = path.join(projectRoot, 'platforms', platform);
const signingFile = path.join(targetPath, 'release-signing.properties');
// Check signing file exists
if (fs.existsSync(targetPath) && !fs.existsSync(signingFile)) {
log(colors.blue('WARNING: Missing file ' + signingFile));
log(colors.blue(' Please create it manually, otherwise release APK files will NOT be signed! '));
}
return Promise.resolve();
}
function cdvAsHook(wrapper) {
return (done, projectRoot, platform) => {
projectRoot = (typeof projectRoot === 'string' && projectRoot) || argv.root || '.';
platform = ((typeof platform === 'string' && platform) || argv.platform || 'android').toLowerCase();
// Override arguments, to pass it to other tasks
argv.root = projectRoot;
argv.platform = platform;
wrapper(done);
}
}
function help() {
log(colors.green("Usage: gulp {config|webBuild|webExtBuild} OPTIONS"));
log(colors.green(""));
log(colors.green("NAME"));
log(colors.green(""));
log(colors.green(" config --env <config_name> Configure environment (create file `www/config.js`). "));
log(colors.green(" build Build from sources (CSS and JS)"));
log(colors.green(" webBuild Build ZIP artifact"));
log(colors.green(" webExtBuild Build web extension artifact (browser module)"));
log(colors.green(""));
log(colors.green("OPTIONS"));
log(colors.green(""));
log(colors.green(" --release Release build (with uglify and sourcemaps)"));
log(colors.green(" --uglify Build using uglify plugin"));
}
/* --------------------------------------------------------------------------
-- Combine task
--------------------------------------------------------------------------*/
const translate = gulp.series(appNgTranslate, pluginNgTranslate);
const template = gulp.series(appNgTemplate, pluginNgTemplate);
const appAndPluginSass = gulp.series(appSass, pluginSass);
const app = gulp.series(appSass, appNgTemplate, appNgAnnotate, appNgTranslate);
const plugin = gulp.series(pluginSass, pluginNgTemplate, pluginNgAnnotate, pluginNgTranslate);
const build = gulp.series(appLicense, app, plugin);
const config = gulp.series(appConfig, appConfigTest);
const webApp = gulp.series(appSass, webCopyFiles, webNgTemplate, webAppNgAnnotate);
const webPlugin = gulp.series(pluginSass, webPluginCopyFiles, webPluginNgTemplate, webPluginNgAnnotate);
const webCompile = gulp.series(
webClean,
webApp,
webPlugin,
webUglify,
webIntegrity,
webApiUglify,
webCleanUnusedFiles,
webCleanUnusedDirectories
);
// note : Do not call config, to keep same config between web and webExt artifacts
const webBuild = gulp.series(
webClean,
webCompile,
webZip,
webBuildSuccess
);
const webExtCompile = gulp.series(
webExtClean,
webCompile,
webExtCopyFiles
);
// note : Do not call config, to keep same config between web and webExt artifacts
const webExtBuild = gulp.series(
webExtCompile,
webExtensionZip,
webExtBuildSuccess
);
/* --------------------------------------------------------------------------
-- Define public tasks
--------------------------------------------------------------------------*/
exports.help = help;
exports.config = config;
exports.license = appLicense;
exports.sass = appAndPluginSass;
exports.translate = translate;
exports.template = template;
exports.clean = appAndPluginClean;
exports.lint = appAndPluginLint;
exports.annotate = gulp.series(appNgAnnotate, pluginNgAnnotate);
exports.watch = appAndPluginWatch;
exports.build = build;
// Web
exports.webClean = webClean;
exports.webCompile = webCompile;
exports.webBuild = webBuild;
exports['build:web'] = exports.webBuild; // Alias
// Web extension
exports.webExtClean = webExtClean;
exports.webExtCompile = webExtCompile;
exports.webExtBuild = webExtBuild;
exports.webExtCopyFiles = webExtCopyFiles;
exports['build:webExt'] = exports.webExtBuild; // Alias
// Cordova (hooks)
const cdvAfterPrepare = gulp.series(
gulp.parallel(cdvNgAnnotate, cdvAddPlatformToBodyTag),
cdvRemoveCode,
gulp.parallel(cdvNgTemplate, cdvNgTranslate),
cdvUglify,
gulp.parallel(cdvCleanUnusedDirectories, cdvCopyBuildFiles),
// Android tasks
gulp.parallel(cdvAndroidManifest, cdvAndroidCheckSigning),
);
exports.cdvAfterPrepare = cdvAsHook(cdvAfterPrepare);
const cdvBeforeCompile = gulp.series(
cdvCleanUnusedDirectories,
cdvCopyBuildFiles,
cdvAndroidManifest,
cdvAndroidCheckSigning
);
exports.cdvBeforeCompile = cdvAsHook(cdvBeforeCompile);
exports.default = gulp.series(config, build);
exports.serveBefore = gulp.series(build, appAndPluginWatch);
exports['ionic:serve:before'] = exports.serveBefore; // Alias need by @ionic/cli
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Cordova Hooks
This directory may contain scripts used to customize cordova commands. This
directory used to exist at `.cordova/hooks`, but has now been moved to the
project root. Any scripts you add to these directories will be executed before
and after the commands corresponding to the directory name. Useful for
integrating your own build systems or integrating with version control systems.
__Remember__: Make your scripts executable.
## Hook Directories
The following subdirectories will be used for hooks:
after_build/
after_compile/
after_docs/
after_emulate/
after_platform_add/
after_platform_rm/
after_platform_ls/
after_plugin_add/
after_plugin_ls/
after_plugin_rm/
after_plugin_search/
after_prepare/
after_run/
after_serve/
before_build/
before_compile/
before_docs/
before_emulate/
before_platform_add/
before_platform_rm/
before_platform_ls/
before_plugin_add/
before_plugin_ls/
before_plugin_rm/
before_plugin_search/
before_prepare/
before_run/
before_serve/
pre_package/ <-- Windows 8 and Windows Phone only.
## Script Interface
All scripts are run from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables:
* CORDOVA_VERSION - The version of the Cordova-CLI.
* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
* CORDOVA_HOOK - Path to the hook that is being executed.
* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)
If a script returns a non-zero exit code, then the parent cordova command will be aborted.
## Writing hooks
We highly recommend writting your hooks using Node.js so that they are
cross-platform. Some good examples are shown here:
[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/)
#!/usr/bin/env node
"use strict";
var gulp = require('gulp');
var gutil = require('gulp-util');
var path = require("path");
var cmd = process.env.CORDOVA_CMDLINE;
var rootdir = process.argv[2];
var argv = require('yargs').argv;
var skip = true;
if (/*cmd.indexOf("--release") > -1 || */cmd.indexOf("--playstore") > -1) {
skip = false;
}
if (rootdir && !skip) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
var platformRoot = path.join(rootdir, 'platforms', platform);
// Deploy for Android
if(platform == 'android') {
var apkFileLocation = path.join(platformRoot, 'build/outputs/apk/android-release.apk');
console.log('Publishing APK file [' + apkFileLocation + '] to playstore...');
var config = require('../playstore-config.json');
if(!config) {
gutil.log(gutil.colors.red("ERROR => Could not load `hooks/playstore-config.json` file!"));
return;
}
if(!config.client_email || !config.private_key) {
gutil.log(gutil.colors.red("ERROR => Could not found 'client_email' or 'private_key' in 'hooks/playstore-config.json' file."));
return;
}
var publisher = require('playup')(config);
publisher.upload(apkFileLocation,
{
track: 'production',
recentChanges: {
'fr-FR': 'New stable release'
}
})
.then(function (data) {
console.log(' > APK file successfully deployed to Playstore !');
})
.catch(function(err) {
console.log('ERROR while publsihing to playtore: \n' + err);
})
}
else {
// TODO : deploy other for platforms
}
}
}
#!/usr/bin/env node
// Add Platform Class
// v1.0
// Automatically adds the platform class to the body tag
// after the `prepare` command. By placing the platform CSS classes
// directly in the HTML built for the platform, it speeds up
// rendering the correct layout/style for the specific platform
// instead of waiting for the JS to figure out the correct classes.
var fs = require('fs');
var path = require('path');
var rootdir = process.argv[2];
function addPlatformBodyTag(indexPath, platform) {
// add the platform class to the body tag
try {
var platformClass = 'platform-' + platform;
var cordovaClass = 'platform-cordova platform-webview';
var html = fs.readFileSync(indexPath, 'utf8');
var bodyTag = findBodyTag(html);
if(!bodyTag) return; // no opening body tag, something's wrong
if(bodyTag.indexOf(platformClass) > -1) return; // already added
var newBodyTag = bodyTag;
var classAttr = findClassAttr(bodyTag);
if(classAttr) {
// body tag has existing class attribute, add the classname
var endingQuote = classAttr.substring(classAttr.length-1);
var newClassAttr = classAttr.substring(0, classAttr.length-1);
newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
newBodyTag = bodyTag.replace(classAttr, newClassAttr);
} else {
// add class attribute to the body tag
newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
}
html = html.replace(bodyTag, newBodyTag);
fs.writeFileSync(indexPath, html, 'utf8');
process.stdout.write('add to body class: ' + platformClass + '\n');
} catch(e) {
process.stdout.write(e);
}
}
function findBodyTag(html) {
// get the body tag
try{
return html.match(/<body(?=[\s>])(.*?)>/gi)[0];
}catch(e){}
}
function findClassAttr(bodyTag) {
// get the body tag's class attribute
try{
return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
}catch(e){}
}
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
// open up the index.html file at the www root
try {
var platform = platforms[x].trim().toLowerCase();
var indexPath;
if(platform == 'android') {
indexPath = path.join('platforms', platform, 'assets', 'www', 'index.html');
} else {
indexPath = path.join('platforms', platform, 'www', 'index.html');
}
if(fs.existsSync(indexPath)) {
addPlatformBodyTag(indexPath, platform);
}
} catch(e) {
process.stdout.write(e);
}
}
}
#!/usr/bin/env node
"use strict";
var gulp = require('gulp');
var path = require("path");
var removeCode = require('gulp-remove-code');
var removeHtml = require('gulp-html-remove');
var es = require('event-stream');
var ngAnnotate = require('gulp-ng-annotate');
var htmlmin = require('gulp-htmlmin');
var rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
var wwwPath;
if(platform == 'android') {
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}
var platformRemoveCodeOptions = {};
platformRemoveCodeOptions[platform] = true; // = {<platform>: true}
var 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...
es.concat(
// 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 build 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 {
es.concat(
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";
var gulp = require('gulp');
var path = require("path");
var templateCache = require('gulp-angular-templatecache');
var es = require('event-stream');
var rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
var wwwPath;
if(platform == 'android') {
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
var distJsPath = path.join(wwwPath, 'dist', 'dist_js', 'app');
var pluginDistJsPath = path.join(wwwPath, 'dist', 'dist_js', 'plugins');
// Concat templates into a JS
es.concat(
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";
var gulp = require('gulp');
var path = require("path");
var es = require('event-stream');
var rootdir = process.argv[2];
var ngTranslate = require('gulp-angular-translate');
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
var wwwPath;
if(platform == 'android') {
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
var distJsPath = path.join(wwwPath, 'dist', 'dist_js', 'app');
var pluginDistJsPath = path.join(wwwPath, 'dist', 'dist_js', 'plugins');
// Concat templates into a JS
es.concat(
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";
var gulp = require('gulp');
var path = require("path");
var es = require('event-stream');
var useref = require('gulp-useref');
var filter = require('gulp-filter');
var uglify = require('gulp-uglify');
var csso = require('gulp-csso');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var cmd = process.env.CORDOVA_CMDLINE;
var rootdir = process.argv[2];
var 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
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
var wwwPath;
if(platform == 'android') {
wwwPath = path.join(rootdir, 'platforms', platform, 'assets', 'www');
} else {
wwwPath = path.join(rootdir, 'platforms', platform, 'www');
}
var indexPath = path.join(wwwPath, 'index.html');
var jsFilter = filter(["**/*.js", "!**/vendor/*", '!**/config.js'], { restore: true });
var cssFilter = filter("**/*.css", { restore: true });
var revFilesFilter = filter(['**/*', '!**/index.html', '!**/config.js'], { restore: true });
var uglifyOptions = {beautify: false};
// 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(revFilesFilter)
.pipe(rev()) // Rename the concatenated files (but not index.html)
.pipe(revFilesFilter.restore)
.pipe(revReplace()) // Substitute in new filenames
.pipe(gulp.dest(wwwPath))
);
}
}
#!/usr/bin/env node
"use strict";
var gulp = require('gulp');
var gutil = require('gulp-util');
var allConfig = require('../../app/config.json');
var path = require("path");
var del = require('del');
var cmd = process.env.CORDOVA_CMDLINE;
var rootdir = process.argv[2];
var argv = require('yargs').argv;
var 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
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
var wwwPath;
if(platform == 'android') {
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([
path.join(wwwPath, 'i18n'),
path.join(wwwPath, 'js'),
path.join(wwwPath, 'templates'),
path.join(wwwPath, 'css'),
path.join(wwwPath, 'dist'),
path.join(wwwPath, 'js'),
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'),
path.join(wwwPath, 'lib', '**'),
// Keep Ionic lib/ionic/fonts directory
'!'+path.join(wwwPath, 'lib'),
'!'+path.join(wwwPath, 'lib', 'ionic'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Black'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Black', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Bold'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Bold', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'BoldItalic'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'BoldItalic', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Italic'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Italic', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Light'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Light', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Medium'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Medium', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Regular'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Regular', '**'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Thin'),
'!'+path.join(wwwPath, 'lib', 'ionic', 'fonts', 'robotdraft', 'Thin', '**')
]);
}
}
#!/usr/bin/env node
"use strict";
var gulp = require('gulp');
var path = require("path");
var replace = require('gulp-replace');
var rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
if(platform == 'android') {
var platformPath = path.join(rootdir, 'platforms', platform);
var androidManifestFile = path.join(platformPath, '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">'))
// 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="28" tools:overrideLibrary="org.kaliumjni.lib" />\n$1'))
.pipe(gulp.dest(platformPath));
console.log('-----------------------------------------');
}
}
}
#!/usr/bin/env node
"use strict";
var fs = require('fs');
var glob = require('glob');
var path = require('path')
// See: https://stackoverflow.com/questions/49162538/running-cordova-build-android-unable-to-find-attribute-androidfontvariation
var rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for (var x = 0; x < platforms.length; x++) {
try {
var platform = platforms[x].trim().toLowerCase();
if (platform == 'android') {
var build_dir = rootdir + '/resources/android/build';
var android_dir = rootdir + '/platforms/android';
var build_files = build_dir + '/**/*.*';
console.log('-----------------------------------------');
if (fs.existsSync(android_dir) && fs.existsSync(build_dir)) {
var mkdirp = function(dir) {
var parent = path.dirname(dir);
if (!fs.existsSync(parent)){
mkdirp(parent);
}
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
};
glob(build_files, null, function(er, files) {
files.forEach(function(file) {
console.log(' Copy ' + file + ' to ' + android_dir);
var dest_file = file.replace(build_dir, android_dir);
mkdirp(path.dirname(dest_file));
fs.createReadStream(file).pipe(fs.createWriteStream(dest_file));
});
});
var gradle_file = build_dir + '/build-extras.gradle';
if (!fs.existsSync(gradle_file)) {
console.log( ' File ' + gradle_file + ' not found. Skipping copy to /platforms/android');
}
var signing_file = build_dir + '/release-signing.properties';
if (!fs.existsSync(signing_file)) {
console.log( ' File ' + signing_file + ' not found. Skipping copy to /platforms/android');
console.log( ' WARNING: Release APK files will not be signed !');
}
} else {
console.log( ' Directory ' + build_dir + ' not found. Skipping copy to /platforms/android');
}
console.log('-----------------------------------------');
}
} catch (e) {
process.stdout.write(e);
}
}
}
#!/usr/bin/env node
"use strict";
var gulp = require('gulp');
var path = require("path");
var replace = require('gulp-replace');
var rootdir = process.argv[2];
if (rootdir) {
// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
for(var x=0; x<platforms.length; x++) {
var platform = platforms[x].trim().toLowerCase();
if(platform == 'ubuntu') {
var platformPath = path.join(rootdir, 'platforms', platform);
var ionicConfigFile = path.join(platformPath, 'config.xml');
// Clean unused directories
console.log('-----------------------------------------');
console.log(' Updating file: ' + ionicConfigFile);
gulp.src(ionicConfigFile)
// change App ID into 'duniter-cesium'
.pipe(replace(/id="fr.duniter.cesium"/g, 'id="cesium"'))
.pipe(gulp.dest(platformPath));
console.log('-----------------------------------------');
}
}
}
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var jshint = require('jshint').JSHINT;
var async = require('async');
var foldersToProcess = [
'js',
'js/controllers',
'js/entities',
'js/services',
'plugins/es/js',
'plugins/es/js/controllers',
'plugins/es/js/entities',
'plugins/es/js/services'
];
foldersToProcess.forEach(function(folder) {
processFiles("www/" + folder);
});
function processFiles(dir, callback) {
var errorCount = 0;
fs.readdir(dir, function(err, list) {
if (err) {
console.log('processFiles err: ' + err);
return;
}
async.eachSeries(list, function(file, innercallback) {
file = dir + '/' + file;
fs.stat(file, function(err, stat) {
if(!stat.isDirectory()) {
if(path.extname(file) === ".js") {
lintFile(file, function(hasError) {
if(hasError) {
errorCount++;
}
innercallback();
});
} else {
innercallback();
}
} else {
innercallback();
}
});
}, function(error) {
if(errorCount > 0) {
process.exit(1);
}
});
});
}
function lintFile(file, callback) {
console.log("Linting '" + file + "'");
fs.readFile(file, function(err, data) {
if(err) {
console.error('Error: ' + err);
return;
}
if(jshint(data.toString())) {
//console.log('File ' + file + ' has no errors.');
//console.log('-----------------------------------------');
callback(false);
} else {
console.error("Errors in file '" + file + "':");
var out = jshint.data(),
errors = out.errors;
for(var j = 0; j < errors.length; j++) {
console.error( " Line " + errors[j].line + ':' + errors[j].character + ' -> ' + errors[j].reason + ' -> ' +
errors[j].evidence);
}
console.log('-----------------------------------------');
callback(true);
}
});
}
......@@ -6,16 +6,10 @@ is_installed() {
type "$1" > /dev/null 2>&1
}
if [ "_$1" != "_" ]; then
CESIUM_DIR="$1"
fi
if [ "_$CESIUM_DIR" = "_" ]; then
DIRNAME=`pwd`
CESIUM_DIR="$DIRNAME/cesium"
fi
CESIUM_DIR=${1:-$(pwd)/cesium}
latest_version() {
echo "v1.4.12" #lastest
echo "v1.7.13" # lastest
}
api_release_url() {
......@@ -39,16 +33,15 @@ download() {
install_from_github() {
local RELEASE=`curl -XGET -i $(api_release_url)`
local CESIUM_URL=`echo "$RELEASE" | grep -P "\"browser_download_url\": \"[^\"]+" | grep -oP "https://[a-zA-Z0-9/.-]+-web.zip"`
local CESIUM_ARCHIVE=$CESIUM_DIR/cesium.zip
if [ -d "$CESIUM_DIR" ]; then
if [ -f "$CESIUM_ARCHIVE" ]; then
echo "WARNING: Deleting existing archive [$CESIUM_ARCHIVE]"
rm $CESIUM_ARCHIVE
fi
else
local RELEASE=$(curl -XGET -i "$(api_release_url)")
local CESIUM_URL=$(echo "$RELEASE" | grep -P '"browser_download_url": "[^"]+' | grep -oP "https://[a-zA-Z0-9/.-]+-web.zip" | head -n 1)
local CESIUM_ARCHIVE="$CESIUM_DIR/cesium.zip"
if [ ! -d "$CESIUM_DIR" ]; then
mkdir -p "$CESIUM_DIR"
elif [ -f "$CESIUM_ARCHIVE" ]; then
echo "WARNING: Deleting existing archive [$CESIUM_ARCHIVE]"
rm "$CESIUM_ARCHIVE"
fi
echo "Downloading [$CESIUM_URL]"
......@@ -56,23 +49,23 @@ install_from_github() {
echo >&2 "Failed to download '$CESIUM_URL'"
return 4
}
echo "Unarchive to $CESIUM_DIR"
unzip -o $CESIUM_ARCHIVE -d $CESIUM_DIR
rm $CESIUM_ARCHIVE
echo
echo "Unarchiving to $CESIUM_DIR"
unzip -o "$CESIUM_ARCHIVE" -d "$CESIUM_DIR"
rm "$CESIUM_ARCHIVE"
echo "Cesium successfully installed at $CESIUM_DIR"
}
do_install() {
if ! is_installed "curl"; then
echo "=> curl is not available. You will likely need to install 'curl' package."
if ! is_installed "curl" && ! is_installed "wget"; then
echo "=> Neither 'curl' nor 'wget' is available. Please install one of them."
exit 1
fi
if ! is_installed "unzip"; then
echo "=> unzip is not available. You will likely need to install 'unzip' package."
echo "=> 'unzip' is not available. You will likely need to install the 'unzip' package."
exit 1
fi
......@@ -84,10 +77,9 @@ do_install() {
# during the execution of the install script
#
reset() {
unset -f reset is_installed latest_version \
download install_from_github do_install
unset -f reset is_installed latest_version api_release_url download install_from_github do_install
}
[ "_$CESIUM_ENV" = "_testing" ] || do_install $1
[ "_$CESIUM_ENV" = "_testing" ] || do_install "$1"
} # this ensures the entire script is downloaded #
{
"name": "Cesium",
"type": "ionic1",
"integrations": {
"cordova": {}
},
"type": "ionic1",
"watchPatterns": [
"www/index.html",
"www/dist/**/*",
"www/css/*.css"
],
"yarn": true
}
{
"name": "Cesium",
"app_id": "",
"watchPatterns": [
"www/**/*",
"!www/dist/**/*",
"!www/lib/**/*",
"!www/css/*.app.css"
],
"gulpStartupTasks": [
"serve:before",
"watch"
],
"defaultBrowser": "chrome",
"browsers": [
{
"platform": "android",
"browser": "crosswalk",
"version": "12.41.296.5"
}
]
}
\ No newline at end of file
{}
\ No newline at end of file
{
"compileOnSave": false
}
Licencc Ğ1 - v0.2.9
===================
:dato: 2017-04-04 12:59
:modifita: 2019-07-14 12:00
**Licenco de la mono kaj promeso de respondeco.**
Ĉiu atestado de nova membro de Ğ1 devas antaŭe akompaniĝi per transdono de tiu ĉi licenco de la mono Ğ1, pri kiu la atestanto devas certiĝi, ke ĝi estis studita, komprenita kaj akceptita de la persono, kiu estos atestita.
Ĉiu okazo de renkontiĝo rilate al Ğ1 devus akompaniĝi per transdono de tiu ĉi licenco, kiu povas esti laŭte legata, kaj transdonita ĉiamaniere.
Reto de Fido Ğ1 (RdF Ğ1)
------------------------------
**Averto :** Atesti ne estas nur certiĝi, ke vi renkontis la personon, tio estas certigi al la komunumo Ğ1, ke vi sufiĉe bone konas la atestitan personon, kaj ke vi tiel scipovos facile kontakti lin/ŝin, kaj kapablos malkovri duoblan konton kreitan de persono atestita de vi mem, aŭ alitipajn problemojn (malapero...), farante komparajn kontrolojn, kiuj eventuale ebligos elmontri la problemon.
**Ege rekomendindaj konsiloj**
Bone koni personon supozigas, ke vi scipovas kontakti lin/ŝin per pluraj rimedoj malsamaj (fizika, elektronika, alitipa...), sed ankaŭ ke vi konas plurajn personojn, kiuj konas lin/ŝin same bone, kaj kiuj ankaŭ scipovas kontakti lin/ŝin simile. Aparte se vi ne bone konas neniun el ties aliaj atestantoj, tio estas forta indiko, ke vi ne bone konas la personon, kaj tia atestaĵo ekas signalon al la tuta komunumo Ğ1. Kaze de nesufiĉa kono, necesas nepre ne atesti.
Neniam atestu sola, sed akompanata de almenaŭ unu alia membro de la RdF Ğ1 por eviti ĉian manipulan eraron. Kaze de eraro, tuj avertu aliajn membrojn de la RdF Ğ1.
Antaŭ ĉiu atestado, ne forgesu kontroli, ĉu tiu konto (ĉu ĝi estas validigota aŭ jam membro) jam ricevis unu aŭ plurajn atestaĵojn. Laŭnecese petu informojn por konkakti tiujn aliajn atestantojn por kune kontroli, ke vi bone konas la personon, kiu kreis la novan konton, kaj ankaŭ ties publikan ŝlosilon.
Kontrolu ke la atestoto bone regas sian konton: bona rimedo por kontroli tion estas sendi kelkajn Ğ1 al la celata konto, kaj poste peti resendon al via propra konto. Tio certigas, ke la atestoto bone regas sian privatan ŝlosilon.
Kontrolu ke viaj kontaktoj bone studis kaj komprenis la licencon Ğ1 ĝisdatan.
Se vi ekkonscias, ke efektiva aŭ ebla atestanto de la koncernata konto ne konas la koncernatan personon, tuj avertu fakulojn pri la temo inter viaj konatoj de la RdF Ğ1, por ke la valid-procezo estu kontrolita de la RdF Ğ1.
Kiam vi estas membro de la RdF Ğ1, kaj ke vi estas atestonta novan konton:
**Vi certiĝis:**
1°) ke vi sufiĉe bone konas (ne nur "vide" konas) la personon, kiu deklaras regi tiun publikan ŝlosilon (novan konton). Vidu la ĉi-suprajn ege rekomendindajn konsilojn por certiĝi "bone koni".
2°) ke vi persone kontrolis kun li/ŝi, ke temas ja pri tiu publika ŝlosilo, kiun vi estas atestonta (vidu ĉi-suprajn konsilojn).
3°) ke vi bone kontrolis kun la koncernata persono, ke li/ŝi ja kreis sian Duniter-dokumenton pri konto-nuligo, kiu laŭbezone ebligos al li/ŝi malaktivigi sian membro-statuson (kaze de konto-ŝtelo, ID-ŝanĝo, erare kreita konto, ktp.).
4a°) ke vi fizike renkontis la personon por certiĝi, ke ja lin/ŝin vi bone konas, kaj ke ja li/ŝi uzas tiun publikan ŝlosilon.
4b°) aŭ ke vi distance kontrolis la ligon persono/publik-ŝlosilo kontaktante la personon per pluraj komunikiloj malsamaj, kiel paper-poŝto + sociaj retoj + forumo + retpoŝto + video-konferenco + telefono (rekoni la voĉon). Ĉar se oni povas fiuzi retadreson aŭ forum-konton, estos multe pli malfacile fiuzi kvar malsamajn komunikilojn, kaj imiti la aspekton (vidan) kaj plie la voĉon de la persono.
La 4a°) tamen preferindas al la 4b°), dum la punktoj 1°) 2°) kaj 3°) estas antaŭ ĉio nepraj.
**Resumitaj reguloj de la RdF:**
Ĉiu membro havas rezervon da 100 eblaj atestaĵoj, kiujn li/ŝi povas sendi nur po 1 ĉiun 5-an tagon.
Valida 2 monatojn, atestaĵo por nova membro estas definitive aprobita nur se la atestito havas almenaŭ 4 aliajn atestaĵojn fine de tiuj 2 monatoj, alie la enir-procezo devos esti rekomencita.
Por fariĝi nova membro de la RdF Ğ1, necesas do akiri 5 atestaĵojn kaj troviĝi je distanco <= 5 paŝoj de 80% el la referencaj membroj de la RdF.
Membro de la RdF Ğ1 estas referenca membro, kiam li/ŝi ricevis kaj sendis almenaŭ Y[N] atestaĵojn, kie N estas la nombro de membroj de la RdF kaj Y[N] = plafono N^(1/5). Ekzemploj:
* por 1024 < N ≤ 3125 oni havas Y[N] = 5
* por 7776 < N ≤ 16807 oni havas Y[N] = 7
* por 59049 < N ≤ 100 000 oni havas Y[N] = 10
Ekde kiam la nova membro partoprenas en la RdF Ğ1, ties atestaĵoj restas validaj 2 jarojn.
Por resti membro necesas redoni regule sian konsenton per sia privata ŝlosilo (ĉiun 12-an monaton) kaj certiĝi daŭre havi almenaŭ 5 atestaĵojn validajn post la 2 jaroj.
Mono Ğ1
----------
Ğ1 produktiĝas per Universala Dividendo (UD) por ĉiu homa estaĵo membro de la Reto de Fido Ğ1, laŭ la formo:
* po 1 UD por ĉiu persono ĉiutage
**Kodo de la mono Ğ1**
La sumo en Ğ1 de la UD samas ĉiutage ĝis la venonta ekvinokso, kiam la UD estos tiam revalorigita laŭ la formulo (kun 1 tago = 86 400 sekundoj):
* UDtago(sekvanta ekvinokso) = UDtago(ekvinokso) + c² (M/N)(ekvinokso) / (182,625 tagoj)
kun kiel parametroj:
* c = 4,88% / ekvinokso
* UD(0) = 10,00 Ğ1
kaj kiel variabloj:
* *M* la ĉioma mona maso je ekvinokso
* *N* la nombro de membroj je ekvinokso
Programoj Ğ1 kaj licenco Ğ1
--------------------------
La programoj Ğ1 ebligantaj al la uzantoj mastrumi ties uzon de Ğ1 devas transdoni tiun licencon kun la programo, kaj ankaŭ la aron de la teknikaj parametroj de la mono Ğ1 kaj de la RdF Ğ1, kiu estas enskribita en la bloko 0 de Ğ1. Programo, kiu ne konformiĝus al tiuj devigoj de la licenco, ne estus kongrua kun Ğ1.
Por pli da precizigoj pri la teknikaj detaloj, eblas rekte konsulti la kodon de Duniter, kiu estas libera programo, kaj ankaŭ la datenojn de la blokĉeno Ğ1 ekhavante ĝin tra ekzemplero (aŭ nodo) Duniter Ğ1.
Pli da informoj ĉe la retejo de la teamo Duniter https://www.duniter.org
\ No newline at end of file