🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

legov

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legov - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+3
-10
package.json
{
"name": "legov",
"version": "1.1.0",
"version": "1.2.0",
"description": "基于项目的多站点前端集成解决方案。",
"main": "package.json",
"bin": {
"lv": "bin/legov.js",
"lego": "bin/legov.js",
"legov": "bin/legov.js"
},
"scripts": {

@@ -21,7 +16,5 @@ "test": "echo \"Error: no test specified\" && exit 1"

"dependencies": {
"chalk": "^1.1.1",
"commander": "^2.9.0",
"hexo-fs": "^0.1.5",
"js-yaml": "^3.4.6"
"legov-bundler": "^1.0.0",
"legov-server": "^1.0.0"
}
}

@@ -5,13 +5,11 @@ # LegoV

# Version
## 1.1.0
Commands:
### 1.2.0
* 新增legov-bundler
* 调整依赖关系
init 初始化前端工程。
get [key] 获取 LegoV 环境变量。
set <key> <val> 配置 LegoV 环境变量。
generator|g <seed> 播种站点(请确定种子已经就位)。
start|s 启动站点。
proxy|p 启动代理服务器。
### 1.1.0
* cmd:generater|start|proxy|
## 1.0.0
项目初始化。
### 1.0.0
* cmd:init
* 初始架构

Sorry, the diff of this file is not supported yet

The MIT License (MIT)
Copyright (c) 2015 legojs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"name": "legov",
"version": "1.1.0",
"description": "基于项目的多站点前端集成解决方案。",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/legojs/legov.git"
},
"author": "ronesam",
"license": "MIT",
"dependencies": {
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-wrap-exports": "^0.3.0"
}
}
# LegoV
基于项目的多站点前端集成解决方案。
# Version
## 1.1.0
Commands:
init 初始化前端工程。
get [key] 获取 LegoV 环境变量。
set <key> <val> 配置 LegoV 环境变量。
generator|g <seed> 播种站点(请确定种子已经就位)。
start|s 启动站点。
proxy|p 启动代理服务器。
## 1.0.0
项目初始化。
#!/usr/bin/env node
var program = require('commander');
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
var yml = require('js-yaml');
var app_info = require('../package.json');
var add = require('../lib/add');
//读取配置文件
var _readConfig = function () {
var local_yml = path.join(__dirname, 'legov.yml');
var config = {};
return Promise.resolve()
.then(function () {
//判断bin/legov.yml是否存在
return fs.exists(local_yml);
})
.then(function (exist) {
//如果存在就读取;否则给一个默认值(yml格式)
return exist? fs.readFile(local_yml): '\
local:\n\
yml:\n\
path:\n\
seed:\n\
prefix: legov-seed-\
site:\n';
})
.then(function (data) {
//将yml转为json
config = yml.safeLoad(data);
//本机是否已经初始化?
//如果已经初始化,被初始化的目录是否还存在?
return config.local.path? fs.exists(config.local.path): false;
})
.then(function (exist) {
//目录不存在直接置为空值
if (!exist) {
config.local.path = ''
}
//直接指定配置文件所在地址
config.local.yml = local_yml
return config;
})
.catch(console.log)
}
//基本信息
program
.version(app_info.version)
.usage(chalk.magenta('[lv|lego]') + ' [options] <cmd>\n\n ' + app_info.description);
//$ lv init
program
.command('init')
.description('初始化前端工程。')
.action(function () {
console.log('\n 开始初始化:' + chalk.green(process.cwd())) + '\n';
_readConfig().then(function (config) {
if (config.local.path) {
return console.log('\n 操作无法执行!@legov已存在:' + chalk.green(config.local.path) + '\n');
} else {
require('../lib/init')(config);
}
}).catch(console.log);
})
.on('--help', function() {
console.log(' Examples: \n');
console.log(' $ mkdir <工程目录>\n');
console.log(' $ cd <工程目录>\n');
console.log(' $ %s %s\n', chalk.magenta('lv'), chalk.cyan('init'));
});
//$ lv get [key]
program
.command('get [key]')
.description('获取 LegoV 环境变量。')
.action(function(key){
_readConfig().then(function (config) {
require('../lib/get')(config, key);
}).catch(console.log);
})
.on('--help', function () {
console.log(' Examples: \n');
console.log(' $ %s %s all \n', chalk.magenta('lv'), chalk.cyan('get'));
console.log(' $ %s %s local/path \n', chalk.magenta('lv'), chalk.cyan('get'));
});
//$ lv set <key> <val>
program
.command('set <key> <val>')
.description('配置 LegoV 环境变量。')
.action(function(key, val){
_readConfig().then(function (config) {
require('../lib/set')(config, key, val);
}).catch(console.log);
})
.on('--help', function() {
console.log(' Examples: \n');
console.log(' $ %s %s seed/prefix "@tencent/wxpay-seed-" #内网前缀,引号是必须的\n', chalk.magenta('lv'), chalk.cyan('set'));
console.log(' $ %s %s seed/prefix "legov-seed-" #默认值\n', chalk.magenta('lv'), chalk.cyan('set'));
});
//$ lv generator <seed>
program
.command('generator <seed>')
.alias('g')
.description('播种站点(请确定种子已经就位)。')
.action(function (seed) {
_readConfig().then(function (config) {
if ('' == config.local.path){
console.log('\n 尚未初始化工程,请执行以下命令查看帮助:\n');
console.log(' $ %s %s -h\n', chalk.magenta('lv'), chalk.cyan('init'));
} else {
console.log('\n [%s]开始播种站点~~\n', chalk.green(seed));
require('../lib/generator')(config, seed);
}
}).catch(console.log);
})
.on('--help', function() {
console.log(' Examples: \n');
console.log(' $ cd "<工程目录>/@legov"\n');
console.log(' $ tnpm i @tencent/wxpay-seed-codeigniter\n');
console.log(' $ cd .. #返回<工程目录>\n');
console.log(' $ mkdir <站点目录> #建立<站点目录>(或者从 Svn or Git 拉取)\n');
console.log(' $ cd <站点目录>\n');
console.log(' $ %s %s seed/prefix "@tencent/wxpay-seed-" #引号是必须的\n', chalk.magenta('lv'), chalk.cyan('set'));
console.log(' $ %s %s codeigniter\n', chalk.magenta('lv'), chalk.cyan('g'));
console.log(' $ %s %s #不加参数,进行补种\n', chalk.magenta('lv'), chalk.cyan('g'));
});
//$ lv start
program
.command('start')
.alias('s')
.description('启动站点。')
.action(function () {
_readConfig().then(function (config) {
if ('' == config.local.path){
console.log('\n 尚未初始化工程,请执行以下命令查看帮助:\n');
console.log(' $ %s %s -h\n', chalk.magenta('lv'), chalk.cyan('init'));
} else {
console.log('\n 启动站点~~');
require('../lib/start')(config);
}
}).catch(console.log);
})
.on('--help', function() {
console.log(' Examples: \n');
console.log(' $ cd wxpay.oa.com-boss\n');
console.log(' $ %s %s\n', chalk.magenta('lv'), chalk.cyan('s'));
});
//$ lv proxy
program
.command('proxy')
.alias('p')
.description('启动代理服务器。')
.action(function(){
_readConfig().then(function (config) {
if ('' == config.local.path){
console.log('\n 尚未初始化工程,请执行以下命令查看帮助:\n');
console.log(' $ %s %s -h\n', chalk.magenta('lv'), chalk.cyan('init'));
} else {
console.log('\n 启动反向代理服务器~~');
require('../lib/proxy')(config);
}
}).catch(console.log);
})
.on('--help', function() {
console.log(' Examples: \n');
console.log(' $ cd wxpay.oa.com-boss\n');
console.log(' $ %s %s\n', chalk.magenta('lv'), chalk.cyan('p'));
});
//$ lv add <leaf>
program
.command('add <leaf>')
.description('增加项目(请确定叶子已经就位)。')
.action(function(leaf){
console.log('\n [%s]开始增加项目~~', chalk.green(leaf)) + '\n';
add(current, leaf);
})
.on('--help', function() {
console.log(' Examples: \n');
console.log(' $ cd "<工程目录>/@legov"\n');
console.log(' $ tnpm i @tencent/wxpay-leaf-flame\n');
console.log(' $ cd ../<站点目录>\n');
console.log(' $ %s %s flame -n project\n', chalk.magenta('lv'), chalk.cyan('add'));
});
program.parse(process.argv);
local:
yml: "F:\\Node\\node_modules\\legov\\bin\\legov.yml"
path: "E:\\Wxpay\\@legov"
seed:
prefix: '@tencent/wxpay-seed-'
site:
wxpay.oa.com:
kunpeng:
port: 57320
view: ''
main:
port: 57293
view: ''
boss:
port: 57080
view: ''
'use strict';
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
var asset = path.join(__dirname, '../asset');
module.exports = function(current) {
}
'use strict';
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
var yml = require('js-yaml');
module.exports = function(config, seed) {
var seed_path = path.join(config.local.path, 'node_modules', config.seed.prefix + seed);
return fs.exists(seed_path)
.then(function (exist) {
if (exist) {
var asset = path.join(seed_path, 'asset');
//拷贝种子站点中的资源到当前目录
return fs.listDir(asset).map(function (item) {
var src = path.join(asset, item);
var dest = path.join(process.cwd(), item);
return fs.exists(dest).then(function (exist) {
if(!exist){
return fs.copyFile(src, dest).then(function() {
console.log(' ' + chalk.magenta(dest));
});
} else {
return console.log('\n ' + chalk.red('文件已经存在:' + dest));
}
});
});
} else {
console.log('\n [%s]没有找到种子。请确定种子已经就位。', chalk.red(seed));
console.log('\n [%s]查找目录为:%s', chalk.red(seed), chalk.red(seed_path));
console.log('\n 如需帮助,请执行:\n');
console.log(' $ %s %s -h', chalk.magenta('lv'), chalk.cyan('g'));
}
})
.then(function () {
console.log('\n 站点初始化完成!');
});
};
'use strict';
var chalk = require('chalk');
module.exports = function(config, key) {
if (!key || 'all' == key){
console.log('\n 所有环境变量如下:\n');
console.dir(config);
return console.log('\n');
} else {
var look = config;
key = key.split('/');
for (var i = 0, len = key.length; i < len; i++){
look = look[key[i]];
if(typeof(look) == "undefined"){
return console.log('\n [%s]未定义此变量。\n', chalk.red(key.join('/')));
}
}
console.log('\n [%s]:\n', chalk.green(key.join('/')));
console.dir(look);
return console.log('\n');
}
}
'use strict';
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
var yml = require('js-yaml');
module.exports = function (config) {
var local = path.join(process.cwd(), '@legov');
var local_yml = config.local.yml;
//写入@legov安装路径
config.local.path = local;
fs.writeFile(local_yml, yml.safeDump(config));
console.log('\n 拷贝文件到:' + chalk.green(local) + '\n');
var asset = path.join(local_yml, '../../asset');
return fs.listDir(asset).map(function(item) {
var src = path.join(asset, item);
//npm会自动把gitignore转为npmignore,这里要做兼容处理
var dest = item === 'gitignore' ? '.' + item : item;
dest = path.join(local, dest);
return fs.copyFile(src, dest)
.then(function() {
console.log(' ' + chalk.magenta(dest));
});
})
.then(function (data) {
fs.mkdir(path.join(local, '_sublime')); //sublime项目目录,gulp不支持全局构建,需要统一到这里。
console.log('\n 初始化完成!请执行以下操作:\n');
console.log(' $ cd @legov');
console.log(' $ npm install');
})
.catch(console.dir)
};
'use strict';
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
module.exports = function (config) {
var server = path.join(config.local.path, 'node_modules', 'legov-server');
return fs.exists(server).then(function (exist) {
if (exist) {
require(server).proxy(config);
} else {
console.log('[%s]当前目录下没有反向代理服务器。', chalk.red(server));
}
})
}
'use strict';
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
var yml = require('js-yaml');
module.exports = function(config, key, val) {
key = key.split('/');
var len = key.length;
if (len < 2) {
return console.log('\n [%s]仅能配置最终子项。\n', key);
}
_setConfig(config, key, val);
return fs.writeFile(config.local.yml, yml.safeDump(config))
}
var _setConfig = function (config, key ,val) {
if(typeof(config[key[0]]) == "undefined"){
return console.log('\n [%s]未定义此变量。\n', chalk.red(key.join('/')));
}
if (key.length > 1){
_setConfig(config[key[0]], key.slice(1), val);
} else {
if (typeof(config[key[0]]) != "string") {
return console.log('\n [%s]仅能配置最终子项。\n', key);
}
config[key[0]] = val;
}
}
'use strict';
var path = require('path');
var chalk = require('chalk');
var fs = require('hexo-fs');
module.exports = function (config) {
var server = path.join(config.local.path, 'node_modules', 'legov-server');
return fs.exists(server).then(function (exist) {
if (exist) {
require(server).start(config);
} else {
console.log('[%s]当前目录下没有找到站点服务器。', chalk.red(server));
}
})
}