main-bower-files icon indicating copy to clipboard operation
main-bower-files copied to clipboard

Support package.json

Open aimad-majdou opened this issue 7 years ago • 5 comments

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.

aimad-majdou avatar Nov 07 '17 16:11 aimad-majdou

the bowerDirectory should be node_modules and the bowerJson package.json

ck86 avatar Nov 08 '17 08:11 ck86

@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 avatar Nov 08 '17 09:11 aimad-majdou

@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

aimad-majdou avatar Nov 08 '17 17:11 aimad-majdou

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'
    }));

Cracky5457 avatar Feb 27 '18 08:02 Cracky5457

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

crazy-max avatar May 04 '18 15:05 crazy-max