New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

front-build

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

front-build - npm Package Compare versions

Comparing version 0.3.8 to 0.3.9

csslint

19

lib/app.js

@@ -349,6 +349,13 @@ var _ = require('underscore');

fs.exists(absdir, function(exist) {
if (exist) {
fu.rmTreeSync(absdir);
if (!exist) {
fs.mkdir(absdir, callback);
}
fs.mkdir(absdir, callback);
fu.rmTree(absdir, function(err) {
if (err) {
return callback(err);
}
fs.mkdir(absdir, callback);
});
});

@@ -398,5 +405,5 @@ }, callback);

// console.log('buildCommon: %s', 'rmTemp');
fu.rmTreeSync(commonPage.srcDir);
fu.rmTreeSync(commonPage.destDir);
callback(null);
async.forEach([commonPage.srcDir, commonPage.destDir], function (p, callback) {
fu.rmTree(p, callback);
}, callback);
}

@@ -403,0 +410,0 @@

@@ -21,3 +21,4 @@ var npminfo = require('../package.json');

' [-t|-timestamp <timestamp>]',
'fb build common'
'fb build common',
'-w|watch monitor file change and auto rebuild',
]

@@ -24,0 +25,0 @@ },

@@ -7,7 +7,6 @@ var fs = require('fs');

var util = require('util');
var optimist = require('optimist').argv;
var watchDir = require('./watchdir');
module.exports = {

@@ -154,4 +153,35 @@ init: function(bin, callback) {

}
var utilswd = watchDir(app.getUtilsDir());
async.forEachSeries(jobs, function (job, callback) {
job.page.build(job.timestamp, callback);
if (argv.watch) {
var wd = watchDir(job.page.versionDir);
job.page.build(job.timestamp, function (err) {
if (err) {
console.error(err);
}
console.log('watching...');
//is change enough
wd.on('change', function (file) {
job.page.build(job.timestamp, function (err) {
if (err) {
console.error(err);
}
console.log('watching...');
});
});
utilswd.on('change', function (files) {
job.page.build(job.timestamp, function (err) {
if (err) {
console.error(err);
}
console.log('watching...');
});
})
});
} else {
job.page.build(job.timestamp, callback);
}
}, function (err) {

@@ -158,0 +188,0 @@ if (err) {

@@ -148,2 +148,54 @@ var path = require('path');

var rmTree = exports.rmTree = function(dir, callback) {
dir = path.resolve(dir);
fs.stat(dir, function(err, stat){
if (err) {
return callback(err);
}
if(!stat.isDirectory()) {
var error = new Error('The gaven path is not a directory!');
error.name = 'ENOTDIR'
return callback(error);
}
fs.readdir(dir, function(err, filenames){
if (err) {
return callback(err);
}
if (filenames.length === 0) {
fs.rmdir(dir, callback);
return;
}
async.forEach(filenames, function(p, callback) {
var ap = path.resolve(dir, p);
fs.stat(ap, function (err, stat) {
if (err) {
return callback(err);
}
if (stat.isFile()) {
fs.unlink(ap, callback);
return;
}
if (stat.isDirectory()){
rmTree(ap, callback);
return;
}
callback(null);
});
}, function (err) {
if (err) {
return callback(err);
}
fs.rmdir(dir, callback);
});
})
});
};
/**

@@ -266,3 +318,3 @@ * write JSON to a file with pretty print

*/
exports.iconv = function(config, callback){
exports.iconv = function(config, callback) {
var src_path = path.resolve(config.from.path);

@@ -325,3 +377,2 @@ var to_path = path.resolve(config.to.path);

});
}

@@ -35,2 +35,4 @@ var _ = require('underscore');

self._build_targets = {};
}

@@ -252,2 +254,6 @@

self.use(require('./plugins/csslint')({
base: 'core'
}));
self.use(require('./plugins/module-compiler')({

@@ -277,5 +283,5 @@ base: 'core'

build: function(timestamp, callback) {
_buildTarget: function (timestamp, callback) {
var self = this;
if (!self.version) {

@@ -286,3 +292,3 @@ return callback(new Error('Page#build: version is not setted; '));

if (!timestamp) {
return callback(new Error('Page#build: timestamp missing'))
return callback(new Error('Page#build: timestamp missing'));
}

@@ -310,2 +316,60 @@

/**
* 排队打包系统
* @param {String} timestamp timestamp of build target
* @param {Function} callback optional will call with error or null
*/
build: function (timestamp, callback) {
var self = this;
if (self._is_building) {
if (!self._build_targets[timestamp]) {
self._build_targets[timestamp] = [];
}
if (callback) {
self._build_targets[timestamp].push(callback)
}
return;
}
self._is_building = true;
if (!self._build_targets[timestamp]) {
self._build_targets[timestamp] = [];
}
if (callback) {
self._build_targets[timestamp].push(callback)
}
var callbacks = self._build_targets[timestamp];
delete self._build_targets[timestamp];
if (callbacks.length === 0 ){
return;
}
self._buildTarget(timestamp, function (err) {
self._is_building = false;
if (err) {
callbacks.forEach(function (cb) {
cb(err);
});
return;
}
callbacks.forEach(function (cb) {
cb(null);
});
var timestamps = _.keys(self._build_targets);
if (timestamps > 0) {
self.build(timestamps.pop());
}
});
},
_build: function(callback) {

@@ -394,11 +458,15 @@ var self = this;

// remove tempdir
[self.srcDir, self.destDir].forEach(function(dir) {
fu.rmTreeSync(dir);
async.forEach([self.srcDir, self.destDir], function(dir, callback) {
fu.rmTree(dir, callback);
}, function (err) {
if (err) {
return callback(err);
}
fu.writeJSON(path.resolve(self.timestampDir, Page.BUILD_JSON_NAME), {
build_version: self.version,
build_time: new Date().toString(),
build_used_time: new Date().getTime() - startTime.getTime()
}, callback);
});
fu.writeJSON(path.resolve(self.timestampDir, Page.BUILD_JSON_NAME), {
build_version: self.version,
build_time: new Date().toString(),
build_used_time: new Date().getTime() - startTime.getTime()
}, callback);
},

@@ -408,7 +476,16 @@

if (fs.existsSync(dir_name)) {
fu.rmTreeSync(dir_name);
}
fs.exists(dir_name, function (exist) {
if (!exist) {
return callback(null);
}
fu.rmTree(dir_name, function (err) {
if(err) {
return callback(err);
}
fs.mkdir(dir_name, callback);
});
fs.mkdir(dir_name, callback);
});
},

@@ -415,0 +492,0 @@ /**

@@ -1,2 +0,2 @@

var compressor = require('../cssmin').compressor;
var compressor = require('../3rd/cssmin/cssmin').compressor;
var fs = require('fs');

@@ -3,0 +3,0 @@ var path = require('path');

@@ -15,3 +15,10 @@ var fs = require('fs');

}
var ast = jsp.parse(content);
try {
var ast = jsp.parse(content);
} catch (e) {
console.log('%s: %s[%s:%s]', e.message, from_file, e.line, e.pos);
return done(e);
}
ast = pro.ast_mangle(ast);

@@ -18,0 +25,0 @@ ast = pro.ast_squeeze(ast);

@@ -5,3 +5,3 @@ {

"description": "build front project",
"version": "0.3.8",
"version": "0.3.9",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -6,17 +6,68 @@ # Front-Build(FB)

- 面向前端
## 相对于ant,FB的优势
<img src="http://www.36ria.com/wp-content/uploads/2012/07/FBvsAnt.png" />
## 特别适合使用FB的场景
- 基于kissy1.2的新项目或新应用
- 重构应用前端代码
- 基于kissy1.2的新项目或新应用
- 重构应用前端代码
## 最新更新 v0.3.9
- 添加 css lint
- 添加 目录监控功能
### CSSLint &times; FB
FB 打包开始前会对你的源码进行Lint, 并在命令台中显示出来
````sh
$ fb build page1/1.0 -t 20121212
#...
plugin: csslint
csslint: There are 1 problems in core/index.css.
index.css
1: warning at line 4, col 1
Element (index.css) is overqualified, just use .css without element name.
index.css {display: block;}
csslint: There are 1 problems in mods/a.css.
#...
````
### 目录监控 &times; FB
在build 命令之后添加 -w 或 --watch
FB 会进入自动监控模式。
每次对应page里面的文件修改后, FB自动对你的Page进行打包
````sh
$ fb build page1/1.0 -t 20121212 -w
building page1@1.0 to 20121212
#...
plugin: lesscss
plugin: concat
plugin: uglifyjs
plugin: cssmin
build end
watching...
````
## 快速开始
可以看:<a href="http://www.36ria.com/5536" target="_blank">《使用FB快速构建—kissy1.2最佳实践探索》</a>
### 安装
### 安装FB
1. 首先安装nodejs环境 (and npm) http://nodejs.org/#download;
2. npm install front-build -g;
1. 首先安装nodejs环境 (and npm) http://nodejs.org/#download
2. npm install front-build -g
3. done!
### 更新
### 更新FB

@@ -26,2 +77,4 @@ 1. npm update front-build -g

了解更多:<a href="http://www.36ria.com/5536" target="_blank">《使用FB快速构建—kissy1.2最佳实践探索》</a>
## 目录结构

@@ -123,5 +176,6 @@

## 常用命令介绍
### fb init
````sh

@@ -135,2 +189,4 @@ cd dir/to/app

### fb update
````sh

@@ -146,20 +202,11 @@ cd dir/to/app

### fb add
````sh
fb add name_of_page/1.0
````
在应用里面创建或初始化一个Version 为 "1.0" 的Page;
pageName 为 "name_of_page"
在应用里面创建或初始化 版本 为 "1.0" 的Page "name_of_page"
### fb build
````sh
fb version 1.0
#or
fb ver 1.0
````
**removed from v0.5.4, please use fb add name_of_page/1.0**
在Page文件夹里面执行, 为当前Page 创建一个Version
````sh
fb build about@1.0 -t 20120601

@@ -170,6 +217,6 @@ ````

如果不指定 -t, FB会自动选择最晚的时间戳目录为目标时间戳
如果不指定 -t, FB会自动打包到最新的时间戳目录
一次构建多个页面
一次构建多个页面
````sh

@@ -179,5 +226,12 @@ ## 同时指定多个page

````
common 目录构建
````sh
fb build common
````
或者使用组(group)
### fb group command
````sh

@@ -200,22 +254,17 @@ fb group set group1 about@1.0 index@1.0

common 目录构建
````sh
fb build common
````
## 依赖的包
## 依赖
- css-combo https://github.com/daxingplay/css-combo
- iconv-lite https://github.com/ashtuchkin/iconv-lite
- tbuild https://github.com/czy88840616/tbuild
- less.js
- cssmin
- uglifyjs
- less.js http://lesscss.org
- cssmin
- uglifyjs https://github.com/mishoo/UglifyJS
- csslint http://csslint.net
## 兼容性
* node 0.8.x +
* window xp +
* linux
* OSX 10.6 +
* OSX 10.7 +
{
"charset": "utf8",
"charset": "gbk",
"groups": {

@@ -4,0 +4,0 @@ "all": [

@@ -5,2 +5,3 @@ var fs = require('fs'),

fu = require('../lib/fileutil'),
async = require('async'),
cwd = process.cwd();

@@ -20,3 +21,3 @@

before(function(){
before(function (){
if (path.existsSync(json_file_name)) {

@@ -28,3 +29,3 @@ fs.unlinkSync(json_file_name);

after(function(done){
after(function (done){
fs.unlink(json_file_name, done);

@@ -115,3 +116,3 @@ });

describe('fileutil rmTree Test', function () {
describe('rmTreeSync Test', function () {
var root_name = 'test_rmtree_dir';

@@ -144,2 +145,52 @@ var sub1 = path.join(root_name, 'sub1');

describe('rmTree Test', function () {
var root_name = 'test_rmtree_dir';
var sub1 = path.join(root_name, 'sub1');
var sub2 = path.join(root_name, 'sub2');
var subsub1 = path.join(sub1, 'subsub1');
var subsub2 = path.join(sub1, 'subsub2');
var paths = [root_name, sub1, sub2, subsub1, subsub2];
var files = [
{
name: 'file1.txt',
content: 'file1 content'
},
{
name: 'file2.txt',
content: 'file2 content'
}
];
before(function(done){
async.forEachSeries(paths, function (p, callback) {
fs.mkdir(p, function (err) {
if (err) {
return done(err);
}
async.forEach(files, function (fo, callback){
fs.writeFile(path.resolve(p, fo.name), fo.content, callback);
}, callback);
});
}, done);
});
it('should rm all files created', function(done){
fu.rmTree(root_name, function (err) {
if (err) {
return done(err);
}
fs.exists(root_name, function (exist) {
exist.should.be.false;
done();
});
});
});
});
describe('fileutil copyTreeSync test', function(){

@@ -146,0 +197,0 @@ var src = path.resolve('files/test_tree');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc