Skip to content
Snippets Groups Projects
Select Git revision
  • 12c1b25215a3082c43085ed297865fe206d5807c
  • master default protected
  • tuxmain/fix-change-owner-key
  • fix_picked_up_file_in_runtime_release
  • network/gtest-1000 protected
  • upgradable-multisig
  • runtime/gtest-1000
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • gtest-1000-0.11.1 protected
  • gtest-1000-0.11.0 protected
  • gtest-1000 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
41 results

duniter-debug.Dockerfile

Blame
  • 020_remove_code.js 3.92 KiB
    #!/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'))
          );
        }
      }
    }