Example #1
0
  grunt.registerMultiTask('imagemagick-hisrc', 'Performs a number of configured tasks', function() {
    var done = this.async();
    grunt.log.write("Beginning ImageMagick processing for HiSRC\n");

    var fls=grunt.file.expand(this.data.files);
    var i=0;
    var count=fls.length;
    var suffix=this.data.suffix;
    var cmds=[];
    var cmd;

    grunt.log.write("CWD:"+process.cwd()+"\n-files:"+fls.length+"\n-pattern:"+this.data.files+"\n");

    function onCmdComplete(cmd,success){
      grunt.log.write("completed : "+cmd.file+"\n");
      cmds.splice(cmds.indexOf(cmd),1);
      if(cmds.length<1){
        done();
      }
    }

    for(i=0;i<fls.length;i++){
      cmd = Object.create(HisrcCommand);
      cmds.push(cmd);
      cmd.init(fls[i],suffix,onCmdComplete,this);
    }
    if(fls.length<1){
      grunt.log.write("Nothing to do\n");
      done();
    }else{
      grunt.log.write("all queued\n");
    }
  });
Example #2
0
function read (chalkType, data, type) {
    var stdout = String(data);

    if (type === 'stderr') {
        grunt.log.write(chalk.yellow(stdout));
    } else {
        grunt.log.write(chalkType ? chalk[chalkType](stdout) : stdout);
    }
}
 _.each(env._instances, function (inst) {
     inst = inst.Instances[0];
     grunt.log.write('    ' + inst.InstanceId + ': ');
     grunt.log.write('[' + inst.State.Name + '] ');
     grunt.log.write(inst.PrivateIpAddress + ' ');
     if (inst.PublicIpAddress) {
         grunt.log.write('(pub: ' + inst.PublicIpAddress + ') ');
     }
     grunt.log.writeln();
 });
Example #4
0
 complete:function(err){
   grunt.log.write('convert complete...'+"\n");
   if (err !== undefined && err !== null) {
     if (this.context.data.fatals === true) {
       grunt.warn(err);
     } else {
       grunt.log.write('error: '+err+"\n");
     }
   }
   this.callback.apply(this.context,[this,true]);
 }
exports.jspClean = function(originalString, markupPrefix) {
  var modifiedString;
  if( typeof markupPrefix === 'undefined' ) {
    grunt.log.write('Cleaning leftover JSP markup');
    modifiedString = cleanerHelper.cleanJsp(originalString);
    grunt.log.ok();
  } else {
    grunt.log.write('cleaning leftover prefixed JSP markup');
    modifiedString = cleanerHelper.cleanPrefixedJsp(originalString, markupPrefix);
    grunt.log.ok();
  }
  return modifiedString;
};
Example #6
0
 resize2: function(err){
   try{
   grunt.log.write("Resizing lowrez\n");
   grunt.log.write("To size: "+Math.round(this.baseWidth/4)+"x"+Math.round(this.baseHeight/4)+"\n");
   this.im.resize({
     width:Math.round(this.baseWidth/4),
     height:Math.round(this.baseHeight/4),
     srcPath: this.file,
     dstPath: this.path + this.name.split(this.suffix[0]).join(this.suffix[2]) +'.'+this.ext
   },proxy(this.complete,this));
   } catch (e){
     grunt.log.write('error '+e+"\n");
   }
 },
Example #7
0
var createSession = function(options, callback){

  // TODO: save session somewhere else?

  var data = {
    config: {
      file: options.config,
      content_type: 'application/json'
    }
  };

  var session = null;
  var config = require(process.cwd() + '/' + options.config);

  if (config.name) {
    session = config.name
    callback(null, options, session);
  }
  else {
    grunt.log.write('Creating session...');
    needle.post( options.host, data, { multipart: true }, function(err, res, body){
         if (err) {
           grunt.log.error();
           callback(err);
         }
         else {
           grunt.log.ok();
           grunt.log.debug('sid: ' + body);
           callback(null, options, body);
         }
       }
    );
  }

};
Example #8
0
 function onCmdComplete(cmd,success){
   grunt.log.write("completed:"+cmd.dstPath+"\n");
   cmds.splice(cmds.indexOf(cmd),1);
   if(cmds.length<1){
     done();
   }
 }
Example #9
0
 resize: function(err,output){
   try{
   grunt.log.write("Resizing image: "+output+"\n");
   this.baseWidth=Number(output.split('x')[0]);
   this.baseHeight=Number(output.split('x')[1]);
   grunt.log.write("To size: "+Math.round(this.baseWidth/2)+"x"+Math.round(this.baseHeight/2)+"\n");
   this.im.resize({
     width:Math.round(this.baseWidth/2),
     height:Math.round(this.baseHeight/2),
     srcPath: this.file,
     dstPath: this.path + this.name.split(this.suffix[0]).join(this.suffix[1]) +'.'+this.ext
   },proxy(this.resize2,this));
   } catch (e){
     grunt.log.write('error '+e+"\n");
   }
 },
Example #10
0
function loadTask(filepath) {
  // In case this was called recursively, save registry for later.
  loadTaskStack.push(registry);
  // Reset registry.
  registry = {tasks: [], untasks: [], meta: {info: lastInfo, filepath: filepath}};
  var filename = path.basename(filepath);
  var msg = 'Loading "' + filename + '" tasks...';
  var regCount = 0;
  var fn;
  try {
    // Load taskfile.
    fn = require(path.resolve(filepath));
    if (typeof fn === 'function') {
      fn.call(grunt, grunt);
    }
    grunt.verbose.write(msg).ok();
    // Log registered/renamed/unregistered tasks.
    ['un', ''].forEach(function(prefix) {
      var list = grunt.util._.chain(registry[prefix + 'tasks']).uniq().sort().value();
      if (list.length > 0) {
        regCount++;
        grunt.verbose.writeln((prefix ? '- ' : '+ ') + grunt.log.wordlist(list));
      }
    });
    if (regCount === 0) {
      grunt.verbose.warn('No tasks were registered or unregistered.');
    }
  } catch (e) {
    // Something went wrong.
    grunt.log.write(msg).error().verbose.error(e.stack).or.error(e);
  }
  // Restore registry.
  registry = loadTaskStack.pop() || {};
}
 q.drain = function() {
     if (unVerifiedFiles.length) {
         grunt.fail.warn("The following files are not beautified:\n" + unVerifiedFiles.join("\n").cyan + "\n");
     }
     grunt.log.write("Beautified " + fileCount.toString().cyan + " files, changed " + changedFileCount.toString().cyan + " files...");
     grunt.log.ok();
     done();
 };
Example #12
0
  }, function ( err, result, code ) {
    if ( err ) {
      grunt.fail.fatal( result );
    } else {
      grunt.log.write( result );
    }

    callback();
  });
Example #13
0
  init:function(pArgs,pCallback,pContext){
    this.args=pArgs;
    this.callback=pCallback;
    this.context=pContext;
    this.im=require('node-imagemagick');

    grunt.log.write('convert: '+this.args+"...\n");
    this.im.convert(this.args,proxy(this.complete,this));
  },
Example #14
0
 grunt.registerMultiTask('imagemagick-convert','Converts images using imagemagick',function(){
   var done=this.async();
   grunt.log.write("Beginning convert operation\n");
   var cmd=Object.create(ConvertCommand);
   function onCmdComplete(cmd,success){
     grunt.log.write("completed:"+cmd.args+"\n");
     done();
   }
   cmd.init(this.data.args,onCmdComplete,this);
 });
Example #15
0
  init:function(pfrom,pto,pprops,pcallback,pcontext){
    
    this.props=Object.create(pprops);
    this.props.srcPath=pfrom;
    this.props.dstPath=pto;
    this.callback=pcallback;
    this.context=pcontext;
    this.im=require('node-imagemagick');

    grunt.log.write('resizing:'+this.props.srcPath+"...\n");
    this.im.resize(this.props,proxy(this.complete,this));
  },
Example #16
0
    function sigint () {
        if (!shell) { return; }
        if (aborting) { return exit(); }

        aborting = true;

        shell.write('\x03'); // SIGINT

        grunt.log.write('\nEnter %s again to exit session\n%s',
            chalk.red('ctrl+c'),
            chalk.cyan('ยป ')
        );
    }
Example #17
0
    error: function(filePath, errors, data) {
        grunt.log.write("Linting " + this._getFileName(filePath) + "...");
        grunt.log.error();

        // If there was an indent option in jshint, use it to determine our tabString.
        if(data.options && data.options.indent) {
            this.tabReplace = this._makeTabString(data.options.indent);
        }

        errors.forEach(this._reportError);

        grunt.log.writeln();
    },
exports.varReplace = function(originalString, constantsObject, markupPrefix) {
  var modifiedString = originalString;
  if( typeof markupPrefix === 'undefined') {
    grunt.log.write('Replacing variables:');
    for (var key in constantsObject) {
      if(constantsObject.hasOwnProperty(key)) {
        modifiedString = cleanerHelper.varJspReplace(modifiedString, key, constantsObject[key]);
      }
      grunt.log.write('.');
    }
  } else {
    grunt.log.write('Replacing Prefixed variables:');
    for (var i in constantsObject) {
      if(constantsObject.hasOwnProperty(i)) {
        modifiedString = cleanerHelper.varPrefixReplace(modifiedString, i, constantsObject[i], markupPrefix);
      }
      grunt.log.write('.');
    }
  }
  grunt.log.ok();
  return modifiedString;
};
Example #19
0
  grunt.registerMultiTask('imagemagick-resize','Resizes images using imagemagick',function(){
    var done= this.async();
    grunt.log.write("Beginning ImageMagick resizing process\n");
    var cmds=[],cmd;
    var i=0;
    var fls=grunt.file.expand(this.data.from+this.data.files);

    function onCmdComplete(cmd,success){
      grunt.log.write("completed:"+cmd.dstPath+"\n");
      cmds.splice(cmds.indexOf(cmd),1);
      if(cmds.length<1){
        done();
      }
    }

    if(!fileExists(this.data.to)){
      grunt.file.mkdir(this.data.to);
    }

    for(i=0;i<fls.length;i++){
      cmd=Object.create(ResizeCommand);
      cmds.push(cmd);
      cmd.init(
        fls[i],
        this.data.to+fls[i].substr(this.data.from.length), // replace folder
        this.data.props,
        onCmdComplete,
        this
      );
    }

    if(fls.length<1){
      grunt.log.write("Nothing to do\n");
      done();
    }else{
      grunt.log.write("all queued\n");
    }
  });
Example #20
0
  }, function ( err, result, code ) {
    if ( err ) {
      grunt.fail.fatal( result );
    } else {
      grunt.log.write( result );
    }

    // load the installed modules in case tasks are chained
    pkgString.split( '+' ).forEach( function ( mod ) {
      grunt.loadNpmTasks( mod );
      loadedModules.push( mod );
    });

    callback();
  });
Example #21
0
  init:function (fpath,fsuffix,fcallback,context){
    try{
      this.file=fpath;
      this.suffix=fsuffix;
      var lslash=fpath.lastIndexOf('/');
      var ldot=fpath.lastIndexOf('.');
      this.path=fpath.substr(0,lslash+1);
      this.ext=fpath.substr(ldot+1);
      this.name=fpath.substr(lslash+1,ldot-lslash-1);
      this.im=require('node-imagemagick');
      this.callback=fcallback;

      this.im.identify(['-format','%wx%h',this.file],proxy(this.resize,this));
    }catch(e){
      grunt.log.write('error '+e+"\n");
    }
  },
        cmisSession.loadRepositories().ok(function() {
            if (action === actions.list) {
                grunt.log.ok('Listing contents of', cmisPath);
                grunt.log.write('Gatherting info...');
            } else {
                grunt.log.ok('Detecting changes...');
            }

            cmisSession.getObjectByPath(cmisPath).ok(function(object) {
                var fileProcessor;
                if (object.succinctProperties) {
                    // current CMIS
                    fileProcessor = createFileProcessor(cmisSession, options, cmisPath, localPath, action);
                } else {
                    // legacy CMIS
                    fileProcessor = createLegacyFileProcessor(cmisSession, options, cmisPath, localPath, action);
                }

                fileProcessor.process(object, function(err) {
                    if (err) {
                        grunt.log.error();
                        grunt.log.error(err);
                        callback(err);
                        return;
                    }

                    if (action === actions.list) {
                        console.log();
                        fileProcessor.documents.sort().forEach(function(doc) {
                            console.log(removeLeadingSlash(doc));
                        });
                    }else{
                        VersionRegistry.save();
                    }
                    callback();
                });

            }).notOk(function(response) {
                var status = response.statusCode ? response.statusCode : "";
                var error = response.error ? response.error : "";
                callback('failed to get content: ' + status + " " + cmisPath + "\n" + error);
            });
        });
    function processFile(path, cmisFileProperties, callback) {
        var fileDir = path.slice(cmisPath.length + 1);
        var localDir;
        if (fileDir) {
            localDir = localPath + '/' + fileDir;
        } else {
            localDir = localPath;
        }

        if (action === actions.upload) {
            cmisFileProperties.setParentPath(path);
            fileIO.uploadFile(localDir, cmisFileProperties, callback);
//            fileIO.uploadFile(localDir, fileName, objectId, mimeType, function(err){
//                // update version registry on success
//                if(err){
//                    callback(err);
//                }else{
//                    // get new version
//                    cmisSession.getObject(objectId).ok(function(updatedObject) {
//                        console.log(updatedObject)
//                        //registry[nodeId] = updatedObject.succinctProperties["cmis:versionLabel"];
//                        callback();
//                    }).notOk(function(response) {
//                        var status = response.statusCode ? response.statusCode : "";
//                        var error = response.error ? response.error : "";
//                        callback('failed to get content: ' + status + " " + cmisPath + "\n" + error);
//                    });
//                }
//            });
            
        } else if (action === actions.download){
//            registry[nodeId] = version;
            fileIO.downloadFile(localDir, cmisFileProperties, callback);
        } else {
            // log progress
            grunt.log.write('.');
            
            documents.push(fileDir + '/' + cmisFileProperties.getName());
            callback();
        }
    }    
 }, function(err, result, code) {
   if (!err) { return; }
   // Something went horribly wrong.
   cleanup();
   grunt.verbose.or.writeln();
   grunt.log.write('Running PhantomJS...').error();
   if (code === 127) {
     grunt.log.errorlns(
       'In order for this task to work properly, PhantomJS must be ' +
       'installed and in the system PATH (if you can run "phantomjs" at' +
       ' the command line, this task should work). Unfortunately, ' +
       'PhantomJS cannot be installed automatically via npm or grunt. ' +
       'See the grunt FAQ for PhantomJS installation instructions: ' +
       'https://github.com/cowboy/grunt/blob/master/docs/faq.md'
     );
     grunt.warn('PhantomJS not found.', failCode);
   } else {
     String(result).split('\n').forEach(grunt.log.error, grunt.log);
     grunt.warn('PhantomJS exited unexpectedly with exit code ' + code + '.', failCode);
   }
   options.done(code);
 });
Example #25
0
var init = function(options, callback){

  grunt.log.write('Verify paths...');
  var tests = [
    processPath.bind(null, options, options.fonts),
    processPath.bind(null, options, options.styles)
  ];
  async.parallel(options.styles ? tests : [tests[0]], function(err, results){
    if(err) {
      grunt.log.error(err);
      callback(err);
    }
    else {
      grunt.log.ok();
      results.forEach(function(result){
        grunt.log.debug(result);
      });
      callback(null, options);
    }
  });

};
Example #26
0
  grunt.registerMultiTask('imagemagick-convert','Converts images using imagemagick',function(){
    var done=this.async();
    var cArgs = [];
    grunt.log.write("Beginning convert operation\n");
    function onCmdComplete(cmd,success){
      grunt.log.write("completed:"+cmd.args+"\n");
      cArgs.splice(cArgs.indexOf(cmd),1);
      if(cArgs.length<1) {
        done();
      }
    }

    // see if we are given single convert command or array of multiple ones
    if(Object.prototype.toString.call( this.data.args[0] ) !== '[object Array]') {
      cArgs.push(this.data.args);
    } else {
      cArgs = this.data.args;
    }
    for(var i=0; i<cArgs.length; i++) {
      var cmd=Object.create(ConvertCommand);
      cmd.init(cArgs[i],onCmdComplete,this);
    }
  });
Example #27
0
generators.setup = function setup(grunt) {
  // figure out the base application directory
  generators.cwd = process.cwd();
  generators.gruntfile = grunt.file.findup(generators.cwd, '{G,g}runtfile.{js,coffee}');
  generators.base = generators.gruntfile ? path.dirname(generators.gruntfile) : generators.cwd;

  // keep reference to this grunt object, so that other method of this module may use its API.
  generators.grunt = grunt;

  // when a Gruntfile is found, make sure to cdinto that path. This is the
  // root of the yeoman app (should probably check few other things too, this
  // gruntfile may be in another project up to this path), otherwise let the
  // default cwd be (mainly for app generator).
  if(generators.gruntfile) {
    // init the grunt config if a Gruntfile was found
    try {
      require(generators.gruntfile).call(grunt, grunt);
    } catch( e ) {
      grunt.log.write( e.message ).error().verbose.error( e.stack) .or.error( e );
    }

    // and cd into that base, all generators should write relative to the
    // application root.
    process.chdir(generators.base);
  }

  // try to locate locally installed yeoman plugin
  generators.plugins = grunt.file.expandDirs('node_modules/yeoman-*');

  // and built-in one in yeoman packages, within one of its npm deps
  // XXX: this is clumpsy, works specifically for yeoman and when
  // yeoman-generators is one of the top level deps.
  generators.plugins = generators.plugins.concat(path.join(__dirname, '..'));

  return generators;
};
Example #28
0
 watchTask(function() {
   grunt.file.write(path.join(watchDir, 'one', 'added-' + that.times + '.js'), 'var test = false;');
   grunt.log.write(that.times + ' ');
   that.times++;
 }, done);
Example #29
0
 watchTask(function() {
   grunt.file.delete(path.join(watchDir, 'three', 'four', 'test-' + that.times + '.js'));
   grunt.log.write(that.times + ' ');
   that.times++;
 }, done);
Example #30
0
 watchTask(function() {
   grunt.file.write(path.join(watchDir, 'one', 'test-99.js'), 'var test = "' + that.times + '"');
   grunt.log.write(that.times + ' ');
   that.times++;
 }, done);