Comparing version 0.1.1 to 0.1.2
require.config({ | ||
baseUrl: '/static/js' | ||
baseUrl: 'static/js' | ||
}); | ||
@@ -9,2 +9,3 @@ var fs = require('fs'); | ||
var UFO_JS = '/static/js/ufo.js'; | ||
@@ -34,3 +35,30 @@ var confJs = { | ||
var compileHtml = function(){ | ||
var base_path = process.cwd() + '/', | ||
html_path = base_path + 'html/'; | ||
var header = fs.readFileSync( html_path + 'header.html' ); | ||
var footer = fs.readFileSync( html_path + 'footer.html' ); | ||
var htmls = fs.readdirSync(html_path); | ||
var result = []; | ||
for (var i = 0; i < htmls.length; i += 1) { | ||
var file = htmls[i]; | ||
if( file.indexOf( '.html' ) == -1 ) continue; | ||
if( file == 'header.html' || file == 'footer.html' ) continue; | ||
try{ | ||
var body = fs.readFileSync( html_path + file ); | ||
fs.writeFileSync( base_path + 'build/' + file , header + body + footer ); | ||
result.push(file); | ||
}catch(e){ | ||
utils.error('Compile html file ' + file + ' failed'); | ||
continue; | ||
}; | ||
} | ||
utils.success( 'Compile html files '+ result.join(',') + ' success' ); | ||
}; | ||
exports.run = function(params , options){ | ||
@@ -42,3 +70,3 @@ options = options || {}; | ||
utils.processFolder(process.cwd() + '/build' , process.cwd() , ['static', 'build','app.json']); | ||
utils.processFolder(process.cwd() + '/build' , process.cwd() , ['build','app.json']); | ||
@@ -52,4 +80,8 @@ requirejs.optimize(confJs , function(res){ | ||
}); | ||
fs.writeFileSync( process.cwd() + '/build' + UFO_JS , fs.readFileSync(process.cwd() + UFO_JS) ); | ||
compileHtml(); | ||
if( options.compile ){ | ||
@@ -56,0 +88,0 @@ exec( 'java -jar '+ yuicompressor +' --type js --charset utf-8 ' + confJs.out + ' -o ' + confJs.out , function(error){ |
@@ -25,6 +25,24 @@ | ||
var param = req.params; | ||
var file = process.cwd() + '/html/' + param; | ||
var html_dir = process.cwd() + '/html/'; | ||
res.header('Content-type' , 'text/html'); | ||
res.send( fs.readFileSync(file) ); | ||
try{ | ||
res.header('Content-type' , 'text/html'); | ||
var body = fs.readFileSync( html_dir + param ); | ||
var header = fs.readFileSync( html_dir + 'header.html' ); | ||
var footer = fs.readFileSync( html_dir + 'footer.html' ); | ||
res.send( header + body + footer ); | ||
}catch(e){ | ||
try{ | ||
res.header('Content-type' , 'text/html'); | ||
var body = fs.readFileSync( process.cwd() + '/' + param ); | ||
res.send( body); | ||
}catch(e){ | ||
res.send(404); | ||
} | ||
} | ||
}); | ||
@@ -39,3 +57,3 @@ | ||
var path = url.path + url.file.replace('.o' , '.php'); | ||
var path = url.path + 'phpd/' + url.file.replace('.o' , '.php'); | ||
@@ -47,5 +65,6 @@ request.get(path).pipe(res); | ||
for( var reg in appconf.rewrite ){ | ||
app.get( /(\w*)$/ , function(reg){ | ||
app.get( new RegExp(reg) , function(reg){ | ||
return function( req , res){ | ||
var url = appconf.rewrite[reg]; | ||
utils.log('Rewrite ' + reg + ' to ' + url ); | ||
request.get(url).pipe(res); | ||
@@ -52,0 +71,0 @@ }; |
{ | ||
"name": "ufo", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "UFO is a develope environment for front-end developer", | ||
@@ -5,0 +5,0 @@ "author": "UFO Team of Sogou-inc.", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1113546
24
2978
11
5