ck86 / main-bower-files

Getting all main bower files
583 stars 56 forks source link

Support package.json #168

Open aimad-majdou opened 7 years ago

aimad-majdou commented 7 years ago

It would be nice if this plugin support yarn (package.json) which iterate through dependencies in package.json and return an array of files defined in the main property of the packages package.json, and the base directory will be node_modules/@bower_components.

I tried as following :

yarnFiles({
        paths: {
            bowerDirectory: 'node_modules/@bower_components',
            bowerJson: 'package.json'
        }
  })

but it didn't work.

This solution worked for me :

yarnFiles({
        paths: {
            bowerDirectory: 'node_modules/@bower_components',
            bowerrc: '.bowerrc',
            bowerJson: 'bower.json'
        }
  })

But I shouldn't rely on the bower.json file, since I'm moving from bower to yarn.

ck86 commented 7 years ago

the bowerDirectory should be node_modules and the bowerJson package.json

aimad-majdou commented 7 years ago

@ck86 I have defined a scope @bower_components for all my bower_components so they are installed inside node_modules/@bower_components this isn't the problem the problem is with bowerJson: 'package.json', I think the problem is from this line (index.js 58) :

bowerJson = opts.paths.bowerJson ? path.resolve(process.cwd(), opts.paths.bowerJson)
                                     : path.resolve(cwd, bowerJson || 'bower.json');

Warning: Variable (bowerJson) might not have been initialized

aimad-majdou commented 7 years ago

@ck86 I've created a fork that supports package.json, the main-yarn-plugins is helpful when you move from using bower to yarn. https://github.com/aimad-majdou/main-yarn-files

Cracky5457 commented 6 years ago

Hey aimad,

Your fork is a good idea, but the README is mostly wrong, there is a lot of error like ifyou don't override the configuration on the contrary of main-bower-files which was really working with just a filter as parameter.

This is the only configuration which was working for me

   mainYarnFiles({
        filter: '**/*.js',
        paths: {
            modulesFolder: 'node_modules/@yarn_components',
            jsonFile: 'package.json'
        },
        scope: '@yarn_components'
    }));
crazy-max commented 6 years ago

I've just migrating from bower/npm to yarn on a project if you want to take a look : https://github.com/neard/neard.github.io