RetireJS/grunt-retire

Support bower

zetsub0u opened this issue · 10 comments

I don't understand how to use this with bower from what i see in the code it tries to read a bower.json file but doesn't really parse it, just tests the bower package name not it's dependencies... I don't see how this is useful, also, it says the path in js:[] is recursive in an example, but from looking at the code it's not really recursive? if i give it a directory like 'app/bower_components' it just tells me all the directories there are not js files and that's it.

Can you provide some more information like OS, node version, retire version, grunt-retire version etc.?

Ubuntu 14.04
node v0.10.25

├─┬ grunt-retire@0.3.10
│ └─┬ retire@1.0.1

I don't see how this is relevant in any case, unless i'm missing something really bad, i don't see the code:

function scanBowerFile(file, repo, options) {
  try {
  var bower = JSON.parse(fs.readFileSync(file));
    if (bower.version) {
      var results = retire.check(bower.name, bower.version, repo);
      printResults(file, results, options);
    }
  } catch (e) {
    log(options).warn('Could not parse file: ' + file);
  }
}

This just reads the pacakge name and version doesnt do anything with the dependencies key on bower.json

once('retire-js-repo', function() {
         filesSrc.forEach(function(filepath) {
            if (!grunt.file.exists(filepath)) {
               grunt.log.debug('Skipping directory file:', filepath);
               return;               
            }
            if (!grunt.file.isFile(filepath)) {
               grunt.log.debug('Not a file:', filepath);
               return;               
            }
            if(options.verbose) {
               grunt.log.writeln('Checking:', filepath);
            }
            if (filepath.match(/\.js$/)) {
               scanner.scanJsFile(filepath, jsRepo, options);
            } else if (filepath.match(/\/bower.json$/)) {

               scanner.scanBowerFile(filepath, jsRepo, options);
            } else {
               grunt.log.debug('Unknown file type:', filepath);
            }
         }); 
         grunt.event.emit('retire-done');        
      });

If it's not a file it just prints "Not a file"

For example: from a config

        retire: {
            options: {},
            js: ['./app/bower_components/*'],
            node: ['.']
        }

if i run grunt retire:js --verbose --debug --stack i get:

Files: ./app/bower_components/FileSaver, ./app/bower_components/almond, ./app/bower_components/backbone, ./app/bower_components/backbone-pageable, ./app/bower_components/backbone-query-parameters, ./app/bower_components/backgrid, ./app/bower_components/backgrid-filter, ./app/bower_components/backgrid-paginator, ./app/bower_components/backgrid-select-all, ./app/bower_components/blob, ./app/bower_components/bootbox, ./app/bower_components/bootstrap, ./app/bower_components/bootstrap-application-wizard, ./app/bower_components/bootstrap-tagsinput, ./app/bower_components/canvg, ./app/bower_components/crossfilter, ./app/bower_components/d3, ./app/bower_components/d3-cloud, ./app/bower_components/dcjs, ./app/bower_components/dist, ./app/bower_components/floatThead, ./app/bower_components/font-awesome, ./app/bower_components/handlebars, ./app/bower_components/jcarousel, ./app/bower_components/jquery, ./app/bower_components/jquery-color, ./app/bower_components/jquery-ui, ./app/bower_components/jquery.easy-pie-chart, ./app/bower_components/jsPDF, ./app/bower_components/ladda-bootstrap, ./app/bower_components/lunr.js, ./app/bower_components/modernizr, ./app/bower_components/moment, ./app/bower_components/moment-precise-range, ./app/bower_components/nprogress, ./app/bower_components/nvd3, ./app/bower_components/pdfmake, ./app/bower_components/pick-a-color, ./app/bower_components/pickadate, ./app/bower_components/pnotify, ./app/bower_components/requirejs, ./app/bower_components/requirejs-handlebars, ./app/bower_components/requirejs-text, ./app/bower_components/rivets, ./app/bower_components/rrule, ./app/bower_components/select2, ./app/bower_components/socket.io-client, ./app/bower_components/spin.js, ./app/bower_components/table2CSV, ./app/bower_components/tinycolor, ./app/bower_components/twbs-bootstrap-sass, ./app/bower_components/underscore -> js
Options: verbose, packageOnly=false, jsRepository="https://raw.github.com/RetireJS/retire.js/master/repository/jsrepository.json", nodeRepository="https://raw.github.com/RetireJS/retire.js/master/repository/npmrepository.json", logger=undefined, warnlogger=undefined
Ignoring []
Options: verbose, packageOnly=false, jsRepository="https://raw.github.com/RetireJS/retire.js/master/repository/jsrepository.json", nodeRepository="https://raw.github.com/RetireJS/retire.js/master/repository/npmrepository.json", logger=undefined, warnlogger=undefined, cachedir="/tmp/.retire-cache", ignore=[]
Downloading https://raw.github.com/RetireJS/retire.js/master/repository/jsrepository.json ...
[D] Not a file: ./app/bower_components/FileSaver
[D] Not a file: ./app/bower_components/almond
[D] Not a file: ./app/bower_components/backbone
[D] Not a file: ./app/bower_components/backbone-pageable
[D] Not a file: ./app/bower_components/backbone-query-parameters
[D] Not a file: ./app/bower_components/backgrid
[D] Not a file: ./app/bower_components/backgrid-filter
[D] Not a file: ./app/bower_components/backgrid-paginator
[D] Not a file: ./app/bower_components/backgrid-select-all
[D] Not a file: ./app/bower_components/blob
[D] Not a file: ./app/bower_components/bootbox
[D] Not a file: ./app/bower_components/bootstrap
[D] Not a file: ./app/bower_components/bootstrap-application-wizard
[D] Not a file: ./app/bower_components/bootstrap-tagsinput
[D] Not a file: ./app/bower_components/canvg
[D] Not a file: ./app/bower_components/crossfilter
[D] Not a file: ./app/bower_components/d3
[D] Not a file: ./app/bower_components/d3-cloud
[D] Not a file: ./app/bower_components/dcjs
[D] Not a file: ./app/bower_components/dist
[D] Not a file: ./app/bower_components/floatThead
[D] Not a file: ./app/bower_components/font-awesome
[D] Not a file: ./app/bower_components/handlebars
[D] Not a file: ./app/bower_components/jcarousel
[D] Not a file: ./app/bower_components/jquery
[D] Not a file: ./app/bower_components/jquery-color
[D] Not a file: ./app/bower_components/jquery-ui
[D] Not a file: ./app/bower_components/jquery.easy-pie-chart
[D] Not a file: ./app/bower_components/jsPDF
[D] Not a file: ./app/bower_components/ladda-bootstrap
[D] Not a file: ./app/bower_components/lunr.js
[D] Not a file: ./app/bower_components/modernizr
[D] Not a file: ./app/bower_components/moment
[D] Not a file: ./app/bower_components/moment-precise-range
[D] Not a file: ./app/bower_components/nprogress
[D] Not a file: ./app/bower_components/nvd3
[D] Not a file: ./app/bower_components/pdfmake
[D] Not a file: ./app/bower_components/pick-a-color
[D] Not a file: ./app/bower_components/pickadate
[D] Not a file: ./app/bower_components/pnotify
[D] Not a file: ./app/bower_components/requirejs
[D] Not a file: ./app/bower_components/requirejs-handlebars
[D] Not a file: ./app/bower_components/requirejs-text
[D] Not a file: ./app/bower_components/rivets
[D] Not a file: ./app/bower_components/rrule
[D] Not a file: ./app/bower_components/select2
[D] Not a file: ./app/bower_components/socket.io-client
[D] Not a file: ./app/bower_components/spin.js
[D] Not a file: ./app/bower_components/table2CSV
[D] Not a file: ./app/bower_components/tinycolor
[D] Not a file: ./app/bower_components/twbs-bootstrap-sass
[D] Not a file: ./app/bower_components/underscore

"This just reads the pacakge name and version doesnt do anything with the dependencies key on bower.json"
Any downloaded dependency, also has a bower.json, so it will check the actual downloaded dependencies, and not just the ones referenced in the top level bower.json file.

But yes, it looks like there is an issue here that need to be looked at

Try with (notice the double asterisk):

retire: {
        options: {},
        js: ['./app/bower_components/**'],
        node: ['.']
}

@zetsub0u have you tried the suggestion to @eoftedal ?

@zetsub0u Any feedback? If not, should we close this issue, @kozmic?

Closing issue because of no feedback in over a year.