refactored

This commit is contained in:
coderaiser 2012-11-02 11:40:02 -04:00
parent cb79a449a9
commit 626fa58ce0
7 changed files with 429 additions and 607 deletions

View file

@ -1,119 +1,121 @@
"use strict";
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main'),
(function(){
"use strict";
LIBDIR = main.LIBDIR,
SRVDIR = main.SRVDIR,
path = main.path,
fs = main.path,
CloudFunc = main.cloudfunc,
Util = main.util,
update = main.update,
Server = main.require(DIR + 'server'),
srv = Server.CloudServer,
Config = main.config,
WIN32 = main.WIN32;
readConfig();
Server.start(Config, indexProcessing, appCacheProcessing);
if(update)
update.get();
function indexProcessing(pIndex, pList){
/* если выбрана опция минифизировать скрпиты
* меняем в index.html обычные css на
* минифицированый
*/
if(srv.Minify._allowed.css){
var lReplace_s = '<link rel=stylesheet href=' +
(WIN32 ? '/css/reset.css>' : '"/css/reset.css">');
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main'),
pIndex = Util.removeStr(pIndex, lReplace_s);
pIndex = pIndex.replace('/css/style.css', srv.Minify.MinFolder + 'all.min.css');
}
pIndex = pIndex.replace('<div id=fm class=no-js>',
'<div id=fm class=no-js>'+ pList);
/* меняем title */
pIndex = pIndex.replace('<title>Cloud Commander</title>',
'<title>' + CloudFunc.setTitle() + '</title>');
if(!srv.Config.appcache)
pIndex = WIN32 ?
Util.removeStr(pIndex, ' manifest=/cloudcmd.appcache') :
Util.removeStr(pIndex, ' manifest="/cloudcmd.appcache"');
return pIndex;
}
function appCacheProcessing(){
var lAppCache = srv.AppCache,
lFiles = [
{'//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff' : './font/DroidSansMono.woff'},
{'//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js' : './lib/client/jquery.js'}];
if(srv.Minify._allowed.css)
lFiles.push('./min/all.min.css');
lAppCache.addFiles(lFiles);
lAppCache.createManifest();
}
function readConfig(){
/* Determining server.js directory
* and chang current process directory
* (usually /) to it.
* argv[1] - is always script name
*/
var lServerDir = path.dirname(process.argv[1]);
if( DIR !== lServerDir ){
console.log('current dir: ' + DIR);
process.chdir(lServerDir);
}
console.log('server dir: ' + lServerDir + '\n' +
'reading configuretion file config.json...');
if(Config){
console.log('config.json readed');
LIBDIR = main.LIBDIR,
SRVDIR = main.SRVDIR,
/* if command line parameter testing resolved
* setting config to testing, so server
* not created, just init and
* all logs writed to screen
*/
var lArg = process.argv;
lArg = lArg[lArg.length - 1];
if ( lArg === 'test' || lArg === 'test\r') {
console.log(process.argv);
Config.server =
Config.logs = false;
path = main.path,
fs = main.path,
CloudFunc = main.cloudfunc,
Util = main.util,
update = main.update,
Server = main.require(DIR + 'server'),
srv = Server.CloudServer,
Config = main.config,
WIN32 = main.WIN32;
readConfig();
Server.start(Config, indexProcessing, appCacheProcessing);
if(update)
update.get();
function indexProcessing(pIndex, pList){
/* если выбрана опция минифизировать скрпиты
* меняем в index.html обычные css на
* минифицированый
*/
if(srv.Minify._allowed.css){
var lReplace_s = '<link rel=stylesheet href=' +
(WIN32 ? '/css/reset.css>' : '"/css/reset.css">');
pIndex = Util.removeStr(pIndex, lReplace_s);
pIndex = pIndex.replace('/css/style.css', srv.Minify.MinFolder + 'all.min.css');
}
if (Config.logs) {
console.log('log param setted up in config.json\n' +
'from now all logs will be writed to log.txt');
writeLogsToFile();
}
pIndex = pIndex.replace('<div id=fm class=no-js>',
'<div id=fm class=no-js>'+ pList);
/* меняем title */
pIndex = pIndex.replace('<title>Cloud Commander</title>',
'<title>' + CloudFunc.setTitle() + '</title>');
if(!srv.Config.appcache)
pIndex = WIN32 ?
Util.removeStr(pIndex, ' manifest=/cloudcmd.appcache') :
Util.removeStr(pIndex, ' manifest="/cloudcmd.appcache"');
return pIndex;
}
}
/* function sets stdout to file log.txt */
function writeLogsToFile(){
var stdo = fs.createWriteStream('./log.txt');
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
stdo.write(string);
};
})(process.stdout.write);
}
function appCacheProcessing(){
var lAppCache = srv.AppCache,
lFiles = [
{'//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff' : './font/DroidSansMono.woff'},
{'//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js' : './lib/client/jquery.js'}];
if(srv.Minify._allowed.css)
lFiles.push('./min/all.min.css');
lAppCache.addFiles(lFiles);
lAppCache.createManifest();
}
function readConfig(){
/* Determining server.js directory
* and chang current process directory
* (usually /) to it.
* argv[1] - is always script name
*/
var lServerDir = path.dirname(process.argv[1]);
if( DIR !== lServerDir ){
console.log('current dir: ' + DIR);
process.chdir(lServerDir);
}
console.log('server dir: ' + lServerDir + '\n' +
'reading configuretion file config.json...');
if(Config){
console.log('config.json readed');
/* if command line parameter testing resolved
* setting config to testing, so server
* not created, just init and
* all logs writed to screen
*/
var lArg = process.argv;
lArg = lArg[lArg.length - 1];
if ( lArg === 'test' || lArg === 'test\r') {
console.log(process.argv);
Config.server =
Config.logs = false;
}
if (Config.logs) {
console.log('log param setted up in config.json\n' +
'from now all logs will be writed to log.txt');
writeLogsToFile();
}
}
}
/* function sets stdout to file log.txt */
function writeLogsToFile(){
var stdo = fs.createWriteStream('./log.txt');
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
stdo.write(string);
};
})(process.stdout.write);
}
})();

View file

@ -1,134 +1,139 @@
var DIR = process.cwd() + '/',
main = require(DIR + './lib/server/main'),
fs = main.fs,
Util = main.util,
/* varible contain all watched file names
* {name: true}
*/
FileNames = {},
NamesList_s = '',
FallBack_s = '',
/* function thet use for crossplatform
* access to fs.watch or fs.watchFile function
*/
fs_watch = null,
on_fs_watch = null,
firstFileRead_b = true,
Manifest = '';
setWatachFunctions();
/* function add file or files to manifest
* Examples:
* exports.addFiles('jquery.js'),
* exports.addFiles(['jquery.js', 'client.js']);
* exports.addFiles([{'http://cdn.jquery/jq.js':'jquery.js'}, 'client.js']);
*/
exports.addFiles = function(pFileNames){
/* if a couple files */
if(pFileNames instanceof Array)
for(var i=0; i < pFileNames.length; i++){
/* if fallback setted up */
var lCurrentName = pFileNames[i];
if(typeof lCurrentName === 'object')
for(var lName in lCurrentName){
FallBack_s += lName + ' ' + lCurrentName[lName] + '\n';
exports.watch(lCurrentName[lName]);
}
else exports.watch(pFileNames[i]);
}
else exports.watch(pFileNames);
(function(){
"use strict";
};
exports.createManifest = function(){
var lAllNames = main.require('hashes');
if(lAllNames)
for(var lName in lAllNames){
if(lName.indexOf('min') > 0)
lName = './min/' + lName;
exports.watch(lName);
}
processManifest();
};
exports.watch = function(pFileName){
console.log(pFileName + ' is watched');
var DIR = process.cwd() + '/',
main = require(DIR + './lib/server/main'),
fs = main.fs,
Util = main.util,
if(!FileNames[pFileName] &&
pFileName !== './cloudcmd.appcache'){
/* adding try...catch
* if watched files would be more then system limit
*/
var lWatch_f = function(){
Util.tryCatch(function(){
fs_watch(pFileName, on_fs_watch(pFileName));
});
};
/* varible contain all watched file names
* {name: true}
*/
FileNames = {},
NamesList_s = '',
FallBack_s = '',
/* function thet use for crossplatform
* access to fs.watch or fs.watchFile function
*/
fs_watch = null,
on_fs_watch = null,
firstFileRead_b = true,
Manifest = '';
setWatachFunctions();
/* function add file or files to manifest
* Examples:
* exports.addFiles('jquery.js'),
* exports.addFiles(['jquery.js', 'client.js']);
* exports.addFiles([{'http://cdn.jquery/jq.js':'jquery.js'}, 'client.js']);
*/
exports.addFiles = function(pFileNames){
/* if a couple files */
if(pFileNames instanceof Array)
for(var i=0; i < pFileNames.length; i++){
/* if fallback setted up */
var lCurrentName = pFileNames[i];
if(typeof lCurrentName === 'object')
for(var lName in lCurrentName){
FallBack_s += lName + ' ' + lCurrentName[lName] + '\n';
exports.watch(lCurrentName[lName]);
}
else exports.watch(pFileNames[i]);
}
else exports.watch(pFileNames);
/* if file.exists function exist and
* file actually exists
*/
if(fs.exists)
fs.exists(pFileName, lWatch_f);
else lWatch_f();
NamesList_s += pFileName + '\n';
FileNames[pFileName] = true;
}
else if(firstFileRead_b){
processManifest();
firstFileRead_b = false;
}
};
function setWatachFunctions(){
if(main.WIN32){
/* good on windows */
fs_watch = fs.watch;
on_fs_watch = onWatch;
}
else{
/* good on linux */
fs_watch = fs.watchFile;
on_fs_watch = onWatchFile;
}
}
function onWatch (pFileName){
return function(pEvent, pFileName){
console.log(pEvent);
console.log('file ' + pFileName + ' is changed');
};
exports.createManifest = function(){
var lAllNames = main.require('hashes');
if(lAllNames)
for(var lName in lAllNames){
if(lName.indexOf('min') > 0)
lName = './min/' + lName;
exports.watch(lName);
}
processManifest();
};
}
function onWatchFile(pFileName){
return function(pCurr, pPrev){
if(pCurr.mtime !== pPrev.mtime){
exports.watch = function(pFileName){
console.log(pFileName + ' is watched');
if(!FileNames[pFileName] &&
pFileName !== './cloudcmd.appcache'){
/* adding try...catch
* if watched files would be more then system limit
*/
var lWatch_f = function(){
Util.tryCatch(function(){
fs_watch(pFileName, on_fs_watch(pFileName));
});
};
/* if file.exists function exist and
* file actually exists
*/
if(fs.exists)
fs.exists(pFileName, lWatch_f);
else lWatch_f();
NamesList_s += pFileName + '\n';
FileNames[pFileName] = true;
}
else if(firstFileRead_b){
processManifest();
firstFileRead_b = false;
}
};
function setWatachFunctions(){
if(main.WIN32){
/* good on windows */
fs_watch = fs.watch;
on_fs_watch = onWatch;
}
else{
/* good on linux */
fs_watch = fs.watchFile;
on_fs_watch = onWatchFile;
}
}
function onWatch (pFileName){
return function(pEvent, pFileName){
console.log(pEvent);
console.log('file ' + pFileName + ' is changed');
processManifest();
}
};
}
function processManifest(){
Manifest = 'CACHE MANIFEST\n' +
'#' + new Date() + '\n' +
'CACHE:\n' +
NamesList_s +
'NETWORK:\n' +
'*\n' +
'FALLBACK:\n' +
FallBack_s;
fs.writeFile('cloudcmd.appcache', Manifest, function(){
console.log('cloudcmd.appcache refreshed');
});
}
};
}
function onWatchFile(pFileName){
return function(pCurr, pPrev){
if(pCurr.mtime !== pPrev.mtime){
console.log('file ' + pFileName + ' is changed');
processManifest();
}
};
}
function processManifest(){
Manifest = 'CACHE MANIFEST\n' +
'#' + new Date() + '\n' +
'CACHE:\n' +
NamesList_s +
'NETWORK:\n' +
'*\n' +
'FALLBACK:\n' +
FallBack_s;
fs.writeFile('cloudcmd.appcache', Manifest, function(){
console.log('cloudcmd.appcache refreshed');
});
}
})();

View file

@ -36,10 +36,11 @@
exports.appcache = srvrequire('appcache'),
exports.cloudfunc = librequire('cloudfunc'),
exports.auth = srvrequire('auth'),
exports.object = srvrequire('object');
exports.auth = srvrequire('auth'),
exports.socket = srvrequire('socket'),
exports.update = srvrequire('update'),
exports.minify = srvrequire('minify').Minify,
exports.cache = srvrequire('cache').Cache,
exports.zlib = mrequire('zlib');
@ -70,4 +71,4 @@
*/
function isWin32(){ return process.platform === 'win32'; }
})();
})();

View file

@ -1,187 +0,0 @@
/* Module contains Cloud Commander SS(Server Side) objects.
*
* List of objects:
* - Cache
* - Minify
*/
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main.js'),
SRVDIR = main.SRVDIR;
/*
* Обьект для работы с кэшем
* аналог клиентского обьекта
* с тем отличием, что в нём
* будут храниться серверные
* данные, такие как файлы
* отдаваемые клиенту
* (файлы проэкта по большому
* счёту, для ускорения
* первичной загрузки)
*/
exports.Cache = {
/* приватный переключатель возможности работы с кэшем */
_allowed :true,
/* данные в которых храняться файлы
* в формате <поле> : <значение>
* _data[name]=pData;
* одному имени соответствуют
* одни данные
*/
_data :{},
/* функция говорит можно ли работать с кэшем */
isAllowed :(function(){
return this._allowed;
}),
/* функция устанавливает возможность работать с кэшем */
setAllowed :(function(pAllowed){
this._allowed=pAllowed;
}),
/* Если доступен кэш
* сохраняем в него данные
*/
set :(function(pName, pData){
if(this._allowed && pName && pData){
this._data[pName]=pData;
}
}),
/* Если доступен Cache принимаем из него данные*/
get :(function(pName){
if(this._allowed && pName){
return this._data[pName];
}
else return null;
}),
/* Функция очищает кэш*/
clear :(function(){
if(this._allowed){
this._data={};
}
})
};
/* Обьект для сжатия скриптов и стилей
* по умолчанию - сжимаються
*/
exports.Minify = {
/* pathes to directories */
INDEX :'index.html',
/* приватный переключатель минимизации */
_allowed :{
css : true,
js : true,
html : true,
img : true
},
/* minimize even if file not changed */
forse : false,
/* функция разрешает или
* запрещает минимизировать
* css/js/html
* @pAllowed: - структура, в которой
* передаються параметры
* минификации, вида
* {js:true,css:true,html:false; img:true}
* img отвечает за перевод картинок в base64
* и сохранение их в css-файл
*/
setAllowed :(function(pAllowed){
if(pAllowed){
this._allowed = pAllowed;
}
}),
/*
* Функция минимизирует css/js/html
* если установлены параметры минимизации
*/
doit :(function(){
if(this._allowed.css ||
this._allowed.js ||
this._allowed.html){
var lMinify;
try{
lMinify = require('minify');
}catch(pError){
this._allowed = {js:false,css:false,html:false};
console.log('You coud install minify ' +
'for better download spead:\n' +
'npm i minify');
return this._allowed;
}
/*
* temporary changed dir path,
* becouse directory lib is write
* protected by others by default
* so if node process is started
* from other user (root for example
* in nodester) we can not write
* minified versions
*/
this.MinFolder = '/' + lMinify.MinFolder;
var lOptimizeParams = [];
if (this._allowed.js) {
lOptimizeParams.push('client.js');
}
if (this._allowed.html)
lOptimizeParams.push(this.INDEX);
if (this._allowed.css) {
lOptimizeParams.push({
'./css/style.css' : this._allowed.img
});
lOptimizeParams.push({
'./css/reset.css': this._allowed.img
});
}
if (lOptimizeParams)
lMinify.optimize(lOptimizeParams);
this.Cache = lMinify.Cache;
return this._allowed;
}
}),
optimize: function(pName, pParams){
var lResult = true;
pParams.force = this.force;
if(this._allowed.css ||
this._allowed.js ||
this._allowed.html){
var lMinify = main.require('minify');
if(lMinify)
lMinify.optimize(pName, pParams);
else{
lResult = false;
this._allowed = {js:false,css:false,html:false};
console.log('Could not minify ' +
'without minify module\n' +
'npm i minify');
}
}
else lResult = false;
return lResult;
},
/* minification folder name */
MinFolder : '',
Cache : {}
};

View file

@ -1,136 +1,140 @@
/* module make possible connectoin thrue socket.io on a server */
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main'),
SRVDIR = main.SRVDIR,
(function(){
"use strict";
io = main.require('socket.io'),
update = main.srvrequire('update'),
exec = main.child_process.exec,
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main'),
SRVDIR = main.SRVDIR,
io = main.require('socket.io'),
update = main.srvrequire('update'),
exec = main.child_process.exec,
ClientFuncs = [],
OnMessageFuncs = [],
Win32_b = main.WIN32;
ClientFuncs = [],
OnMessageFuncs = [],
Win32_b = main.WIN32;
/**
* function listen on servers port
* @pServer {Object} started server object
*/
exports.listen = function(pServer){
io = io.listen(pServer);
/* number of connections */
var lConnNum = 0;
io.sockets.on('connection', function (socket){
++lConnNum;
socket.send('{"stdout":"client connected"}');
/**
* function listen on servers port
* @pServer {Object} started server object
*/
exports.listen = function(pServer){
io = io.listen(pServer);
console.log('server connected');
if(!OnMessageFuncs[lConnNum])
OnMessageFuncs[lConnNum] = onMessage(lConnNum, socket);
var lConn_func = OnMessageFuncs[lConnNum];
socket.on('message', lConn_func);
});
};
/**
* function gets onMessage function
* that execute needed command
*
* @param pConnNum, pSocket
*/
function onMessage(pConnNum, pSocket){
return function(pCommand) {
console.log(pCommand);
/* number of connections */
var lConnNum = 0;
io.sockets.on('connection', function (socket){
++lConnNum;
socket.send('{"stdout":"client connected"}');
if( pCommand.indexOf('cloudcmd') === 0 ){
pCommand = pCommand.replace('cloudcmd', '');
if(pCommand.indexOf(' ') === 0){
pCommand = pCommand.replace(' ','');
if(pCommand.indexOf('update') === 0){
if(update)
update.get();
}
if(pCommand.indexOf('exit') === 0)
pCommand = 'kill -9 ' + process.pid;
}
else {
var lMsg = {
stdout : 'cloudcmd exit - for shutdown cloudcmd',
stderr : null
};
lMsg = JSON.stringify(lMsg);
pSocket.send(lMsg);
console.log('received from client: ' + pCommand);
console.log('sended to client: ' + lMsg);
return;
}
}
/* if we on windows and command is build in
* change code page to unicode becouse
* windows use unicode on non English versions
*/
if(Win32_b){
var lWinCommand = pCommand.toUpperCase();
if( Win32Commands.indexOf(lWinCommand) > 0 )
pCommand = 'chcp 65001 |' + pCommand;
}
if(!ClientFuncs[pConnNum])
ClientFuncs[pConnNum] = getExec(pSocket);
console.log('server connected');
var lExec_func = ClientFuncs[pConnNum];
if(!OnMessageFuncs[lConnNum])
OnMessageFuncs[lConnNum] = onMessage(lConnNum, socket);
exec(pCommand, lExec_func);
};
}
/**
* function send result of command to client
* @param pSocket
*/
function getExec(pSocket){
return function(pError, pStdout, pStderr) {
if (pError !== null) {
console.log('exec error: ' + pError);
}
var lExec = {
stdout : pStdout,
stderr : pStderr || pError
};
var lExec_str = JSON.stringify(lExec);
pSocket.send(lExec_str);
var lConn_func = OnMessageFuncs[lConnNum];
socket.on('message', lConn_func);
});
};
}
/* windows commands thet require
* unicode charset on locales
* different then English
*/
var Win32Commands = ['ASSOC', 'AT', 'ATTRIB', 'BREAK', 'CACLS', 'CALL',
'CD', 'CHCP', 'CHDIR', 'CHKDSK', 'CHKNTFS', 'CLS',
'CMD', 'COLOR', 'COMP', 'COMPACT', 'CONVERT', 'COPY',
'DATE', 'DEL', 'DIR', 'DISKCOMP', 'DISKCOPY', 'DOSKEY',
'ECHO', 'ENDLOCAL', 'ERASE', 'EXIT', 'FC', 'FIND',
'FINDSTR', 'FOR', 'FORMAT', 'FTYPE', 'GOTO', 'GRAFTABL',
'HELP', 'IF', 'LABEL', 'MD', 'MKDIR', 'MODE', 'MORE',
'MOVE', 'PATH', 'PAUSE', 'POPD', 'PRINT', 'PROMPT',
'PUSHD', 'RD', 'RECOVER', 'REM', 'REN', 'RENAME',
'REPLACE', 'RMDIR', 'SET', 'SETLOCAL', 'SHIFT', 'SORT',
'START', 'SUBST', 'TIME', 'TITLE', 'TREE', 'TYPE',
'VER', 'VERIFY', 'VOL', 'XCOPY'];
/**
* function gets onMessage function
* that execute needed command
*
* @param pConnNum, pSocket
*/
function onMessage(pConnNum, pSocket){
return function(pCommand) {
console.log(pCommand);
if( pCommand.indexOf('cloudcmd') === 0 ){
pCommand = pCommand.replace('cloudcmd', '');
if(pCommand.indexOf(' ') === 0){
pCommand = pCommand.replace(' ','');
if(pCommand.indexOf('update') === 0){
if(update)
update.get();
}
if(pCommand.indexOf('exit') === 0)
pCommand = 'kill -9 ' + process.pid;
}
else {
var lMsg = {
stdout : 'cloudcmd exit - for shutdown cloudcmd',
stderr : null
};
lMsg = JSON.stringify(lMsg);
pSocket.send(lMsg);
console.log('received from client: ' + pCommand);
console.log('sended to client: ' + lMsg);
return;
}
}
/* if we on windows and command is build in
* change code page to unicode becouse
* windows use unicode on non English versions
*/
if(Win32_b){
var lWinCommand = pCommand.toUpperCase();
if( Win32Commands.indexOf(lWinCommand) > 0 )
pCommand = 'chcp 65001 |' + pCommand;
}
if(!ClientFuncs[pConnNum])
ClientFuncs[pConnNum] = getExec(pSocket);
var lExec_func = ClientFuncs[pConnNum];
exec(pCommand, lExec_func);
};
}
/**
* function send result of command to client
* @param pSocket
*/
function getExec(pSocket){
return function(pError, pStdout, pStderr) {
if (pError !== null) {
console.log('exec error: ' + pError);
}
var lExec = {
stdout : pStdout,
stderr : pStderr || pError
};
var lExec_str = JSON.stringify(lExec);
pSocket.send(lExec_str);
};
}
/* windows commands thet require
* unicode charset on locales
* different then English
*/
var Win32Commands = ['ASSOC', 'AT', 'ATTRIB', 'BREAK', 'CACLS', 'CALL',
'CD', 'CHCP', 'CHDIR', 'CHKDSK', 'CHKNTFS', 'CLS',
'CMD', 'COLOR', 'COMP', 'COMPACT', 'CONVERT', 'COPY',
'DATE', 'DEL', 'DIR', 'DISKCOMP', 'DISKCOPY', 'DOSKEY',
'ECHO', 'ENDLOCAL', 'ERASE', 'EXIT', 'FC', 'FIND',
'FINDSTR', 'FOR', 'FORMAT', 'FTYPE', 'GOTO', 'GRAFTABL',
'HELP', 'IF', 'LABEL', 'MD', 'MKDIR', 'MODE', 'MORE',
'MOVE', 'PATH', 'PAUSE', 'POPD', 'PRINT', 'PROMPT',
'PUSHD', 'RD', 'RECOVER', 'REM', 'REN', 'RENAME',
'REPLACE', 'RMDIR', 'SET', 'SETLOCAL', 'SHIFT', 'SORT',
'START', 'SUBST', 'TIME', 'TITLE', 'TREE', 'TYPE',
'VER', 'VERIFY', 'VOL', 'XCOPY'];
})();

View file

@ -1,38 +1,42 @@
/* module update cloud commander */
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main'),
mainpackage = main.mainpackage,
exec = main.child_process.exec;
exports.get = function(){
exec('git pull', pull);
};
/**
* function pulls cloud cmd content from repo
* @param pError
* @param pStdout
* @param pStderr
*/
function pull(pError, pStdout, pStderr){
(function(){
"use strict";
if(!pError){
pStderr = '';
if(pStdout !== 'Already up-to-date.\n'){
pStdout = 'Cloud Commander updated. Restart to use new version.';
}
else pStdout = 'Cloud Commander is up to date.';
console.log( process.cwd() );
if(mainpackage)
pStdout = 'Version ' + mainpackage.version + '\n' + pStdout;
}
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main'),
mainpackage = main.mainpackage,
exec = main.child_process.exec;
var lExec = {
stdout : pStdout,
stderr : pStderr || pError
exports.get = function(){
exec('git pull', pull);
};
console.log(lExec);
}
/**
* function pulls cloud cmd content from repo
* @param pError
* @param pStdout
* @param pStderr
*/
function pull(pError, pStdout, pStderr){
if(!pError){
pStderr = '';
if(pStdout !== 'Already up-to-date.\n'){
pStdout = 'Cloud Commander updated. Restart to use new version.';
}
else pStdout = 'Cloud Commander is up to date.';
console.log( process.cwd() );
if(mainpackage)
pStdout = 'Version ' + mainpackage.version + '\n' + pStdout;
}
var lExec = {
stdout : pStdout,
stderr : pStderr || pError
};
console.log(lExec);
}
})();

View file

@ -35,16 +35,6 @@ var CloudServer = {
* данные клиенту
*/
sendResponse : function () {},
/* Обьект для работы с кэшем */
Cache : {},
/* Обьект через который
* выполняеться сжатие
* скриптов и стилей
*/
Minify : {},
/* Асоциативный масив обьектов для
* работы с ответами сервера
@ -88,7 +78,7 @@ var CloudServer = {
'.woff' : 'font/woff',
'.appcache' : 'text/cache-manifest',
'.mp3' : 'audio/mpeg'
}
},
},
DirPath = '/',
@ -114,17 +104,20 @@ if(!Zlib)
/* добавляем модуль с функциями */
var CloudFunc = main.cloudfunc,
Util = main.util;
/* Обьект для работы с кэшем */
CloudServer.Cache = main.cache,
/* Обьект через который
* выполняеться сжатие
* скриптов и стилей
*/
CloudServer.Minify = main.minify,
CloudServer.AppCache = main.appcache,
CloudServer.AppCache = main.appcache;
CloudServer.Socket = main.socket;
if(main.object){
CloudServer.Cache = main.object.Cache;
CloudServer.Minify = main.object.Minify;
}
else
console.log('could not found one of Cloud Commander SS files');
/* базовая инициализация */
CloudServer.init = (function(pAppCachProcessing){
/* Переменная в которой храниться кэш*/