From 805b4e0b6163caaf6dababf9e048a7557a7f7b8a Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Thu, 26 Dec 2019 12:44:33 +0100 Subject: [PATCH] [fix] Fix the watch pattern used by 'ionic serve' to reload the browser. [fix] Remove unused gulp script [fix] Compile web artifact into /dist --- .yarnrc | 1 + doc/build_ios.md | 2 +- doc/development_guide.md | 4 +- doc/fr/development_tutorial-01.md | 28 ++---- gulpfile.js | 158 +++++++++++++----------------- ionic.project | 6 +- package.json | 17 ++-- 7 files changed, 89 insertions(+), 127 deletions(-) create mode 100644 .yarnrc diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 00000000..5e7a4dd3 --- /dev/null +++ b/.yarnrc @@ -0,0 +1 @@ +--install.ignore-engines true diff --git a/doc/build_ios.md b/doc/build_ios.md index 91d77479..eb6ee0e6 100644 --- a/doc/build_ios.md +++ b/doc/build_ios.md @@ -82,7 +82,7 @@ npm install -g nw-gyp node-pre-gyp 2. Install global dependencies (see [Development Guide](./development_guide.md) for versions to used) : ``` -npm install -g gulp bower cordova ionic@1.7.16 +npm install -g yarn gulp cordova ionic@1.7.16 ``` 3. Install project dependencies : diff --git a/doc/development_guide.md b/doc/development_guide.md index 435a996a..f9ba1798 100644 --- a/doc/development_guide.md +++ b/doc/development_guide.md @@ -25,7 +25,7 @@ If you are using fish shell, there is a [dedicated plugin](https://github.com/jo - Installing node.js build tools: ``` - npm install -g gulp bower cordova ionic@1.7.16 + npm install -g yarn gulp cordova ionic@1.7.16 ``` ## Get the source code and dependencies @@ -34,7 +34,7 @@ If you are using fish shell, there is a [dedicated plugin](https://github.com/jo ``` git clone git@git.duniter.org:clients/cesium-grp/cesium.git cd cesium - npm install + yarn ``` - Installing Cordova plugins (need for platforms specific builds) diff --git a/doc/fr/development_tutorial-01.md b/doc/fr/development_tutorial-01.md index c325af98..4f7b6b0a 100644 --- a/doc/fr/development_tutorial-01.md +++ b/doc/fr/development_tutorial-01.md @@ -116,7 +116,7 @@ Puis lancez l'installeur ainsi téléchargé. ### Installer les modules Node.js de Cesium -Cesium repose sur des librairies tierce pour fonctionner appelées *dépendances*, comme par exemple des librairies de compilation (gulp, bower, ionic). +Cesium repose sur des librairies tierce pour fonctionner appelées *dépendances*, comme par exemple des librairies de compilation (gulp, ionic, angularJS). Le fait d'avoir cloné les sources n'est en réalité pas suffisant pour lancer l'application. Nous devons obtenir le code des dépendances pour obtenir ainsi l'ensemble du code exécutable du programme. Pour ce faire, retournez dans la console Git et déplacez-vous dans le répertoire cloné : @@ -127,13 +127,13 @@ cd cesium Puis, lancez le téléchargement et l'installation des modules Cesium à l'aide de la commande : ```bash -npm install -g gulp bower cordova ionic@1.7.16 +npm install -g yarn gulp cordova ionic@1.7.16 ``` Puis pour les dépendances non globales : ```bash -npm install +yarn ``` > Le processus d'installation peut prendre plusieurs minutes. En effet, il faut télécharger toutes les dépendances de Cesium et même en compiler certaines. @@ -141,23 +141,11 @@ npm install Si tout s'est bien passé, vous devriez obtenir une fin d'arborescence dans la console, et l'invité de commande devrait vous avoir rendu la main : ```bash -├── bower@1.8.8 -├─┬ gulp@3.9.1 -│ ├── archy@1.0.0 -│ ├─┬ chalk@1.1.3 - (...) -│ ├─┬ through2@0.5.1 -│ │ ├── readable-stream@1.0.34 -│ │ └── xtend@3.0.0 -│ └─┬ vinyl@0.2.3 -│ └── clone-stats@0.0.1 -└── shelljs@0.3.0 - - -npm WARN cesium@0.0.1 No repository field. -npm WARN cesium@0.0.1 No license field. - -user1@~$ +yarn install v1.15.2 +[1/4] Resolving packages... + (...) +$ node -e "try { require('fs').symlinkSync(require('path').resolve('node_modules/@bower_components'), 'www/lib', 'junction') } catch (e) { }" +Done in 0.82s. ``` > Il se peut que vous obteniez des messages `npm WARN [...]`. Rien de grave : comme le nom du message l'indique, il s'agit simplement d'un avertissement non bloquant pour la suite des événements. diff --git a/gulpfile.js b/gulpfile.js index 3050d7cf..7ee1be1e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,41 +1,35 @@ '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 gulp = require('gulp'), + sass = require('gulp-sass'), + cleanCss = require('gulp-clean-css'), + base64 = require('gulp-base64'), + rename = require('gulp-rename'), + ngConstant = require('gulp-ng-constant'), + fs = require("fs"), + argv = require('yargs').argv, + 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'), + es = require('event-stream'), + zip = require('gulp-zip'), + del = require('del'), + useref = require('gulp-useref'), + filter = require('gulp-filter'), + uglify = require('gulp-uglify'), + csso = require('gulp-csso'), + replace = require('gulp-replace'), + rev = require('gulp-rev'), + revReplace = require('gulp-rev-replace'), + clean = require('gulp-clean'), + htmlmin = require('gulp-htmlmin'), + jshint = require('gulp-jshint'), + markdown = require('gulp-markdown'), + sourcemaps = require('gulp-sourcemaps'); var paths = { sass: ['./scss/**/*.scss'], @@ -51,7 +45,8 @@ var paths = { license_md: ['./www/license/*.md'] }; -gulp.task('serve:before', ['sass', +gulp.task('serve:before', [ + 'sass', 'templatecache', 'ng_annotate', 'ng_translate', @@ -61,6 +56,19 @@ gulp.task('serve:before', ['sass', 'css_plugin', 'license_md']); +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('default', ['config', 'serve:before']); gulp.task('sass-images', function (done) { @@ -74,6 +82,7 @@ gulp.task('sass', ['sass-images'], function(done) { es.concat( // Default App style gulp.src('./scss/ionic.app.scss') + .pipe(sass()).on('error', sass.logError) .pipe(base64({ baseDir: "./www/css", @@ -114,39 +123,6 @@ gulp.task('sass', ['sass-images'], function(done) { .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); - } - done(); -}); - gulp.task('config', function (done) { var allConfig = JSON.parse(fs.readFileSync('./app/config.json', 'utf8')); @@ -282,13 +258,13 @@ gulp.task('clean:tmp', function() { gulp.task('clean:web', function() { return del([ - './platforms/web/www', - './platforms/web/build' + './dist/web/www', + './dist/web/build' ]); }); gulp.task('copy-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; es.concat( // Copy Js (and remove unused code) gulp.src('./www/js/**/*.js') @@ -379,7 +355,7 @@ gulp.task('copy-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], functi }); gulp.task('templatecache:web', ['copy-files:web'], function (done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; gulp.src(tmpPath + '/templates/**/*.html') .pipe(templateCache({ standalone:true, @@ -391,7 +367,7 @@ gulp.task('templatecache:web', ['copy-files:web'], function (done) { }); gulp.task('ng_annotate:web', ['templatecache:web'], function (done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; var jsFilter = filter(["**/*.js", "!**/vendor/*"]); gulp.src(tmpPath + '/js/**/*.js') @@ -402,7 +378,7 @@ gulp.task('ng_annotate:web', ['templatecache:web'], function (done) { }); gulp.task('copy-plugin-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; es.concat( // Transform i18n into JS gulp.src(paths.ng_translate_plugin) @@ -417,7 +393,7 @@ gulp.task('copy-plugin-files:web', ['clean:tmp', 'clean:web', 'sass', 'config'], }); gulp.task('templatecache-plugin:web', ['copy-plugin-files:web'], function (done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; gulp.src(paths.templatecache_plugin) .pipe(templateCache({ standalone:true, @@ -429,7 +405,7 @@ gulp.task('templatecache-plugin:web', ['copy-plugin-files:web'], function (done) }); gulp.task('ng_annotate-plugin:web', ['templatecache-plugin:web'], function (done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; gulp.src(paths.ng_annotate_plugin) .pipe(ngAnnotate({single_quotes: true})) .pipe(gulp.dest(tmpPath + '/dist/dist_js/plugins')) @@ -437,7 +413,7 @@ gulp.task('ng_annotate-plugin:web', ['templatecache-plugin:web'], function (done }); gulp.task('debug-api-files:web', ['ng_annotate:web', 'ng_annotate-plugin:web'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; var debugFilter = filter('**/debug.html', { restore: true }); gulp.src(tmpPath + '/*/debug.html') @@ -454,12 +430,12 @@ gulp.task('debug-api-files:web', ['ng_annotate:web', 'ng_annotate-plugin:web'], }); gulp.task('optimize-api-files:web', ['debug-api-files:web'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/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};; + var uglifyOptions = {beautify: false, max_line_len: 120000}; // Process index.html gulp.src(tmpPath + '/*/index.html') @@ -494,7 +470,7 @@ gulp.task('optimize-api-files:web', ['debug-api-files:web'], function(done) { }); gulp.task('debug-files:web', ['optimize-api-files:web'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; gulp.src(tmpPath + '/debug.html') .pipe(useref()) // Concatenate with gulp-useref .pipe(gulp.dest(tmpPath)) @@ -502,7 +478,7 @@ gulp.task('debug-files:web', ['optimize-api-files:web'], function(done) { }); gulp.task('optimize-files:web', ['debug-files:web'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/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 }); @@ -533,7 +509,7 @@ gulp.task('optimize-files:web', ['debug-files:web'], function(done) { }); gulp.task('clean-unused-files:web', ['optimize-files:web'], function(done) { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; es.concat( gulp.src(tmpPath + '/js/**/*.js', {read: false}) @@ -546,19 +522,21 @@ gulp.task('clean-unused-files:web', ['optimize-files:web'], function(done) { }); gulp.task('clean-unused-directories:web', ['clean-unused-files:web'], function() { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; return del([ tmpPath + '/css', tmpPath + '/templates', tmpPath + '/js', tmpPath + '/dist', - //tmpPath + '/lib/**/*', - //tmpPath + '!/lib/ionic' + tmpPath + '/lib/*', + tmpPath + '!/lib/robotodraft', + tmpPath + '/lib/robotodraft/*', + tmpPath + '!/lib/robotodraft/fonts' ]); }); gulp.task('zip:web', ['clean-unused-directories:web'], function() { - var tmpPath = './platforms/web/www'; + var tmpPath = './dist/web/www'; var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; var txtFilter = filter(["**/*.txt"], { restore: true }); @@ -571,10 +549,10 @@ 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')); }); -gulp.task('build:web', ['git-check', 'zip:web'], function() { +gulp.task('build:web', ['zip:web'], function() { 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']); diff --git a/ionic.project b/ionic.project index cf31b5ea..c8a5fe92 100644 --- a/ionic.project +++ b/ionic.project @@ -2,10 +2,8 @@ "name": "Cesium", "app_id": "", "watchPatterns": [ - "www/**/*", - "!www/dist/**/*", - "!www/lib/**/*", - "!www/css/*.app.css" + "www/dist/**/*", + "www/css/*.css" ], "gulpStartupTasks": [ "serve:before", diff --git a/package.json b/package.json index 5b22af81..7ef1e133 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "url": "git@git.duniter.org:clients/cesium/cesium.git" }, "scripts": { + "clean": "trash www/dist/** platforms/web platforms/**/*.apk platforms/desktop/**/*.deb", "postinstall": "node -e \"try { require('fs').symlinkSync(require('path').resolve('node_modules/@bower_components'), 'www/lib', 'junction') } catch (e) { }\" && rm -f hooks/minify-conf.json hooks/uglify-config.json hooks/after_prepare/ionic-minify.js hooks/after_prepare/uglify.js", "install-platforms": "ionic state restore", "start": "ionic serve", @@ -64,7 +65,7 @@ "@bower_components/angular-chart.js": "jtblin/angular-chart#1.1.1", "@bower_components/angular-file-saver": "alferov/angular-file-saver#^1.1.3", "@bower_components/angular-fullscreen": "E-IS/angular-fullscreen#1.0.2", - "@bower_components/angular-idle": "HackedByChinese/ng-idle#^1.3.2", + "@bower_components/angular-idle": "moribvndvs/ng-idle#^1.3.2", "@bower_components/angular-image-crop": "andyshora/angular-image-crop#^2.0.0", "@bower_components/angular-leaflet-directive": "E-IS/angular-leaflet-directive#0.10.1", "@bower_components/angular-messages": "angular/bower-angular-messages#~1.5.11", @@ -76,7 +77,7 @@ "@bower_components/angular-translate": "PascalPrecht/bower-angular-translate#^2.18.1", "@bower_components/angular-ui-router": "angular-ui/angular-ui-router-bower#^0.2.18", "@bower_components/blob-polyfill": "bjornstar/blob-polyfill#~1.0.20150320", - "@bower_components/chart.js": "chartjs/Chart.js#2.x", + "@bower_components/chart.js": "chartjs/Chart.js#^2.9.3", "@bower_components/file-saver.js": "Teleborder/FileSaver.js#~1.20150507.2", "@bower_components/ion-digit-keyboard": "skol-pro/ion-digit-keyboard#973b90c2fc", "@bower_components/ionic": "driftyco/ionic-bower#1.3.5", @@ -94,9 +95,8 @@ "@bower_components/numeral": "adamwdraper/Numeral-js#^1.5.6", "@bower_components/qrcode.js": "davidshimjs/qrcodejs#*", "@bower_components/robotodraft": "raibutera/robotodraft#1.1.0", - "@bower_components/socket.io": "socketio/socket.io#^1.4.4", - "@bower_components/socket.io-parser": "socketio/socket.io-parser#^2.2.6", - "@bower_components/socket.io-client": "socketio/socket.io-client#^1.4.4", + "@bower_components/socket.io": "socketio/socket.io#^1.7.4", + "@bower_components/socket.io-client": "socketio/socket.io-client#^1.7.4", "@bower_components/ui-leaflet": "angular-ui/ui-leaflet#^2.0.0", "@bower_components/underscore": "jashkenas/underscore#^1.8.3", "@bower_components/waves": "fians/Waves#0.6" @@ -109,14 +109,13 @@ "event-stream": "3.3.4", "glob": "^5.0.15", "gulp": "^3.9.1", + "gulp-wait": "^0.0.2", "gulp-angular-templatecache": "^1.8.0", "gulp-angular-translate": "^0.1.4", "gulp-base64": "^0.1.3", "gulp-bump": "^2.1.0", "gulp-clean": "^0.3.2", "gulp-clean-css": "^3.7.0", - "gulp-concat": "^2.2.0", - "gulp-concat-css": "^2.3.0", "gulp-css-base64": "^1.3.4", "gulp-csso": "^2.0.0", "gulp-filter": "^4.0.0", @@ -137,7 +136,6 @@ "gulp-sourcemaps": "^1.6.0", "gulp-uglify": "^2.0.0", "gulp-useref": "^3.1.0", - "gulp-util": "^3.0.8", "gulp-zip": "^3.2.0", "ionic": "^1.7.16", "@ionic/v1-toolkit": "2.0.18", @@ -146,8 +144,7 @@ "mv": "^2.1.1", "node-sass": "^3.13.1", "playup": "^1.0.2", - "shelljs": "^0.3.0", - "yargs": "^4.3.1" + "yargs": "^4.8.1" }, "cordovaPlugins": [ "cordova-plugin-whitelist", -- GitLab