abc-team / generator-kissy-cake

yeoman generator for kissy cake
9 stars 1 forks source link

component 相关尝试 #50

Open neekey opened 11 years ago

neekey commented 11 years ago

component 类似 bower,基于github仓库进行组件的储存,使用component.json进行信息的配置,其本身不进行组件的注册,直接通过

component install username/reponame@tag

来进行组件的定位,它会先去读取component.json文件,然后抓取里面指定的文件,会在当前目录生成如下格式文件:

component/username-reponame

它的优势:

劣势:

整体来说还是无法很好地满足需求,相关代码保存一下:

使用exec组件来执行命令:

exec: {
            /**
             * Component 安装
             */
            component_install: {
                command: function(){
                    var deps = ABCConfig.dependencies;
                    var depsArr = [];
                    grunt.util._.each(deps, function( version, name ){
                        var depStr = name;
                        if( version != '*' ){
                            depStr += '@' + version;
                        }
                        depsArr.push( depStr );
                    });
                    return 'node ' + PATH.resolve( __dirname, 'node_modules/component/bin/component' ) + ' install ' + depsArr.join( ' ' );
                },
                cwd: 'src'
            },
            /**
             * Component 搜索
             */
            component_search: {
                command: function( keyword ){
                    return 'node ' + PATH.resolve( __dirname, 'node_modules/component/bin/component' ) + ' search ' + keyword;
                }
            },

添加依赖:

{
    "component": "~0.17.4",
    "grunt-exec": "*"
}
neekey commented 11 years ago

相关文章:http://flippinawesome.org/2013/08/26/choosing-between-npm-bower-and-component/