nickjanssen / angus

Declarative build tool for the web.
http://slides.com/nickjanssen/declarative-build-configurations
211 stars 13 forks source link

bower.localFolders create symlink for only the innermost directory #22

Closed rbudiharso closed 9 years ago

rbudiharso commented 9 years ago

Given this config (notice the bower.localFolders entry):

'use strict';

module.exports = {

    bower: {
        packages: [
            'http://code.jquery.com/jquery-2.1.0.min.js',
            'bootswatch-dist#3.2.0-lumen'
        ],
        localFolders: ['src/style'],
        filesNeeded: {
            js: [
                'jquery-2.1.0.min/index.js',
                'bootswatch-dist/js/bootstrap.min.js'
            ],
            css: [
                'bootswatch-dist/css/bootstrap.min.css',
                'style/main.css'
            ]
        }
    },
    port: 9000,
    cssCompiler: 'none',
    testRunner: 'karma',
    useJsHint: true,
    usesAngularJS: false

};

running ls -l bower_components result in this:

$ ls -l bower_components                                                                                                                
total 8
drwxr-xr-x  7 rahmat  staff  442 Oct  1 17:49 bootstrap
drwxr-xr-x  5 rahmat  staff  238 Oct  2 17:44 bootswatch-dist
drwxr-xr-x  4 rahmat  staff  238 Oct  1 17:49 jquery
drwxr-xr-x  2 rahmat  staff  136 Oct  1 17:49 jquery-2.1.0.min
lrwxr-xr-x  1 rahmat  staff   47 Oct  3 06:44 style -> /path/to/app/src/style

angus is symlink-ing to the innermost directory, so in order to get things right in bower.filesNeeded you have to use different directory scheme than in bower.localFolders, just like in the config above. Is this intentional? What if localFolder contain files in mixed directory structure? for example if some files are 2 directory down, some are 3, how do you handle that?

nickjanssen commented 9 years ago

Why did you add the src/ folder as a localFolder, and added the CSS files to filesNeeded.css? You don't need to do this, your index.html will automatically include any CSS files you have in your style/ or core/ folders.

I also don't fully understand your problem. It is true that it only symlinks the innermost directory, what do you suggest instead? The symlinked folder also links to any subfolders in your link source. So, if you have files that are further down, you can just add those to the path:

    bower: {
        packages: [
            'http://code.jquery.com/jquery-2.1.0.min.js',
            'bootswatch-dist#3.2.0-lumen'
        ],
        localFolders: ['src/style'],
        filesNeeded: {
            js: [
                'jquery-2.1.0.min/index.js',
                'bootswatch-dist/js/bootstrap.min.js'
            ],
            css: [
                'bootswatch-dist/css/bootstrap.min.css',
                'style/main.css',
                'style/somefolder/test.css',                
                'style/somefolder/subfolder/test.css',
            ]
        }
    },

Does that make sense to you?

rbudiharso commented 9 years ago

The src/style directory is just for example.

My problem is upon using the bower.localFolders options, I assume that I needed to use the same entry in bower.filesNeeded, so if I use src/style in localFolders I assume that I need to use src/style/blah.css but I just need the innermost directory, thus in bower.filesNeeded needs to be style/blah.css, which I thought to be a bit counter intuitive, but that's just my opinion. Maybe I'm just doesn't read the docs carefully.

nickjanssen commented 9 years ago

You are right, but the problem is that you otherwise can't use absolute directories or directories that are one or more levels above. For example, if you had to include a folder two levels above, you'd had to add ../../myLib as a localFolder which would be impossible to include with filesNeeded, since it would need to symlink a folder outside of bower_components. This is a requirement for my projects which use a common shared library.

Actually it used to be like the way you described it, I changed that very recently: https://github.com/nickjanssen/angus/commit/a5e5c1576efc1af2c6415d41af1a2882d464040b

I'm not 100% which approach is the most intuitive, but like I said I had problems with this approach and that's why I changed it to the new way. If you have a better way to solve my relative directories problem, I'm all ears!