Socket
Socket
Sign inDemoInstall

ufo

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ufo - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

lib/assets/static/images/p.gif

2

lib/assets/static/js/main.js
require.config({
baseUrl: 'static/js'
});
//require(function(){});
var utils = require('./utils');
var fs = require('fs');
function makeOptionMap(optionInfo) {

@@ -64,2 +64,12 @@ var optionMap = {};

var command , argInfo;
var noNeedAppJsonCommand = ['help' , 'create'];
if( noNeedAppJsonCommand.indexOf( commandName ) == -1 ){
try{
fs.statSync( process.cwd() + '/app.json' ).isFile();
}catch(e){
utils.error("Can't find app.json, make sure you are in the app directory.Exit!" , '' , true);
}
}

@@ -70,2 +80,3 @@ try{

utils.error('Invalid command: '+ commandName);
console.log(e);
return;

@@ -72,0 +83,0 @@ };

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

var yuicompressor = __dirname + '/../../3rd/yuicompressor.jar';

@@ -15,3 +14,4 @@

name:"main",
out:"build/static/js/main.js"
out:"build/static/js/main.js",
optimize:"none"
};

@@ -32,2 +32,7 @@

'hasValue' : false
},
{
"shortName": "p",
"longName": "publish",
"hasValue": false
}

@@ -73,2 +78,3 @@ ];

//exec('r.js -o name='+ confJs.baseUrl + '/' + confJs.name + ' out=' + confJs.out);
requirejs.optimize(confJs , function(res){

@@ -78,6 +84,8 @@ utils.success('requirejs build js success.');

requirejs.optimize(confCss , function(res){
utils.success('requirejs build css success.');
});
exec('r.js -o cssIn='+ confCss.cssIn + ' out=' + confCss.out);
// requirejs.optimize(confCss , function(res){//sth. bug goes here
utils.success('requirejs build css success.');
// });
fs.writeFileSync( process.cwd() + '/build' + UFO_JS , fs.readFileSync(process.cwd() + UFO_JS) );

@@ -105,3 +113,16 @@

}
if( options.publish ){
utils.log('try to publish now.');
try{
utils.processFolder( process.cwd() + '/../static' , process.cwd() + '/build/static' );
}catch(e){
if( e.message.indexOf('ENOENT') != -1 ){
utils.error('Not in project folder.' ,null , true);
}
}
utils.success('Publish success.');
}
};

@@ -21,15 +21,4 @@ var fs = require('fs');

app.start(function(err){
if (err) {
utils.error('There was an error starting the application:\n');
utils.error(err);
console.log('\n');
utils.error('UFO was not started!\n', null, true);
return;
}
utils.success('\tUFO started' +
' on http://'+ (appconf.domain || 'ufo') +':' + port );
});
app.start();
};
if( process.argv.length > 2 && process.argv.indexOf('create') == -1 ){//非创建
var fs = require('fs');
var fs = require('fs');
var utils = require('./utils');
var conf_path = process.cwd() + '/app.json';
var config = JSON.parse(fs.readFileSync( conf_path , 'utf8' ));
var conf_path = process.cwd() + '/app.json';
exports.config = config;
if( !fs.statSync( conf_path ).isFile() ){
utils.error("Can't find app.json, make sure you are in the app directory." , '' , true);
}
var config = JSON.parse(fs.readFileSync( conf_path , 'utf8' ));
exports.config = config;
}

@@ -6,2 +6,3 @@

var fs = require('fs');
var querystring = require('querystring');

@@ -17,5 +18,16 @@ var appconf = require('./conf').config;

start: function(callback){
var app;
var app , port = this.port;
this.app = app = express.createServer();
app.on('error',function(error){
if( error.errno == 'EADDRINUSE' ){
utils.error('Server start failed. Try use other port.' , 'ufo start 8888' , true);
}
});
app.on('listening',function(error){
utils.success('\tUFO started' +
' on http://'+ (appconf.domain || 'ufo') +':' + port );
});
app.configure(function(){

@@ -50,20 +62,9 @@ app.use(express.static(process.cwd() + '/'));

});
app.get(/\/(\w*\.o)$/ , function(req,res){ //php file
var param = req.params;
var file = process.cwd() + '/' + param;
var url = utils.getApacheLocation(file) ;
var path = url.path + 'phpd/' + url.file.replace('.o' , '.php');
request.get(path).pipe(res);
});
if( appconf.rewrite ){
for( var reg in appconf.rewrite ){
app.get( new RegExp(reg) , function(reg){
app.get( reg , function(reg){
return function( req , res){
var url = appconf.rewrite[reg];
url += '?' + querystring.stringify(req.query);
utils.log('Rewrite ' + reg + ' to ' + url );

@@ -76,3 +77,31 @@ request.get(url).pipe(res);

app.get(/\/(\w*\.php)$/ , function(req,res , next){ //php file
var param = req.params;
var file = process.cwd() + '/' + param;
var url = utils.getApacheLocation(file) ;
var path = url.path + 'phpd/' + url.file;
request.get(path).pipe(res);
});
app.get(/^\/$/ , function(req,res){ //php file
var html_dir = process.cwd() + '/html/';
var htmls = fs.readdirSync(html_dir);
var html = '',
tpl = '<p><a href="{file}">{file}</a></p>';
htmls.forEach(function(item){
if( ['header.html' , 'footer.html'].indexOf(item) != -1 ) return;
html += tpl.replace(/{file}/g , item);
});
res.header('Content-type' , 'text/html');
res.send( html );
});
app.listen(this.port);

@@ -79,0 +108,0 @@

@@ -6,3 +6,2 @@

var util = require('util');
var appconf = require('./conf').config;

@@ -40,2 +39,3 @@ var log = function(message){

var getApacheLocation = function(filepath){
var appconf = require('./conf').config;
var url = appconf.apache_url ;

@@ -132,3 +132,3 @@

}
var path = fs.statSync(assets_dir + '/' + file);

@@ -135,0 +135,0 @@

{
"name": "ufo",
"version": "0.1.2",
"version": "0.1.3",
"description": "UFO is a develope environment for front-end developer",

@@ -13,3 +13,3 @@ "author": "UFO Team of Sogou-inc.",

"colors":"0.6.0",
"requirejs":"1.0.8"
"requirejs":"2.0.1"
},

@@ -16,0 +16,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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