Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

thinkjs

Package Overview
Dependencies
Maintainers
1
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thinkjs - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

lib/Tpl/ctrl.sh

3

lib/Common/function.js

@@ -304,2 +304,5 @@ var fs = require("fs");

};
if (event === null) {
return instance.removeAllListeners();
};
if (callback === null) {

@@ -306,0 +309,0 @@ return instance.removeAllListeners(event);

@@ -6,2 +6,3 @@ /**

var fs = require("fs");
var path = require("path");

@@ -89,3 +90,3 @@ //系统路径设置

};
build_first_action();
copyFiles();
}else{

@@ -96,11 +97,32 @@ console.log(APP_PATH + " is not writable.");

}
function build_first_action(){
var file = LIB_PATH + "/Controller/Home/IndexController.class.js";
if (!isFile(file)) {
var content = getFileContent(THINK_PATH + "/Tpl/IndexController.class.js");
fs.writeFileSync(file, content);
};
/**
* 拷贝相关的文件
* @return {[type]} [description]
*/
function copyFiles(){
var sourceFiles = [
THINK_PATH + "/Tpl/IndexController.class.js",
THINK_PATH + "/Tpl/index_index.html",
THINK_PATH + "/Tpl/common.js",
THINK_PATH + "/Tpl/ctrl.sh"
];
var dstFiles = [
LIB_PATH + "/Controller/Home/IndexController.class.js",
TPL_PATH + "/Home/index_index.html",
COMMON_PATH + "/common.js",
APP_PATH + "/../ctrl.sh"
];
dstFiles.forEach(function(file, i){
if (!isFile(file)) {
mkdir(path.dirname(file));
var readStream = fs.createReadStream(sourceFiles[i]);
var writeStream = fs.createWriteStream(file);
readStream.pipe(writeStream);
readStream.on("end", function(){});
};
})
}
load_runtime_files();
//启动
thinkRequire('Think').start();

@@ -8,2 +8,3 @@ /**

debug_retain_files: ['/node_modules/', '/Model.class.js'], //这些文件在debug模式下不清除缓存
use_cluster: false
}

32

lib/Lib/Core/App.class.js

@@ -11,4 +11,2 @@ /**

this.http = http;
this.loadExtFile();
this.loadExtConfig();
},

@@ -128,32 +126,2 @@ dispatch: function(){

return promise;
},
//加载自定义外部文件
loadExtFile: function(){
var files = C('load_ext_file');
if (files) {
if (isString(files)) {
files = files.split(',');
};
files.forEach(function(file){
file = COMMONT_PATH + "/" + file + ".js";
if (isFile(file)) {
require(file);
};
})
};
},
//加载额外的配置
loadExtConfig: function(){
var files = C('load_ext_config');
if (files) {
if (isString(files)) {
files = files.split(",");
};
files.forEach(function(file){
file = CONF_PATH + "/" + file + ".js";
if (isFile(file)) {
C(require(file));
};
})
};
}

@@ -160,0 +128,0 @@ }

@@ -17,5 +17,11 @@ /**

registerAutoload(this.autoload);
this.buildApp();
//加载文件
this.loadFiles();
//debug模式
if (APP_DEBUG) {
this.debug();
};
//记录进程的id
this.log_process_pid();
thinkRequire('App').run();

@@ -36,3 +42,3 @@ },

*/
buildApp: function(){
loadFiles: function(){
//加载系统默认配置

@@ -46,6 +52,4 @@ C(require(THINK_PATH + '/Conf/config.js'));

//自定义路由
if (C('url_route_on')) {
if (isFile(CONF_PATH + "/route.js")) {
C("url_route_rules", require(CONF_PATH + "/route.js"));
};
if (C('url_route_on') && isFile(CONF_PATH + "/route.js")) {
C("url_route_rules", require(CONF_PATH + "/route.js"));
};

@@ -70,39 +74,77 @@ //加载行为配置

};
//debug模式
if (APP_DEBUG) {
//加载debug模式下的配置
if (isFile(THINK_PATH + "/Conf/debug.js")) {
C(require(THINK_PATH + "/Conf/debug.js"));
this.loadExtConfig();
this.loadExtFiles();
},
//加载自定义外部文件
loadExtFiles: function(){
var files = C('load_ext_file');
if (files) {
if (isString(files)) {
files = files.split(',');
};
//debug下自定义状态的配置
var status = C('app_status');
if (status) {
if (isFile(CONF_PATH + "/" + status + '.js')) {
C(require(CONF_PATH + "/" + status + ".js"));
files.forEach(function(file){
file = COMMONT_PATH + "/" + file + ".js";
if (isFile(file)) {
require(file);
};
}else{
if (isFile(CONF_PATH + '/debug.js')) {
C(require(CONF_PATH + '/debug.js'));
})
};
},
//加载额外的配置
loadExtConfig: function(){
var files = C('load_ext_config');
if (files) {
if (isString(files)) {
files = files.split(",");
};
files.forEach(function(file){
file = CONF_PATH + "/" + file + ".js";
if (isFile(file)) {
C(require(file));
};
}
//debug模式下实时加载,文件修改后刷新立即生效。
//只针对model,controller等类有效
//这些文件不清除缓存
var retainFiles = C('debug_retain_files');
setInterval(function(){
for(var file in require.cache){
var flag = retainFiles.some(function(item){
if (file.indexOf(item) > -1) {
return true;
};
});
if (!flag) {
delete require.cache[file];
};
}
}, 100);
})
};
},
loadDebugFiles: function(){
//加载debug模式下的配置
C(require(THINK_PATH + "/Conf/debug.js"));
//debug下自定义状态的配置
var status = C('app_status');
if (status) {
if (isFile(CONF_PATH + "/" + status + '.js')) {
C(require(CONF_PATH + "/" + status + ".js"));
};
}else{
if (isFile(CONF_PATH + '/debug.js')) {
C(require(CONF_PATH + '/debug.js'));
};
}
},
/**
* debug模式下一些特殊处理
* @return {[type]} [description]
*/
debug: function(){
this.loadDebugFiles();
//这些文件不清除缓存
var retainFiles = C('debug_retain_files');
var self = this;
setInterval(function(){
//清除已经绑定的自定义事件
E(null);
for(var file in require.cache){
var flag = retainFiles.some(function(item){
if (file.indexOf(item) > -1) {
return true;
};
});
if (!flag) {
delete require.cache[file];
};
}
self.loadFiles();
self.loadDebugFiles();
}, 100);
},
/**
* 记录当前进程的id

@@ -109,0 +151,0 @@ * 记录在Runtime/Data/app.pid文件里

//这里定义一些全局通用的函数,该文件会被自动加载
/**
* //返回首页
* global.return_home = function(group, controller, http){
* http.redirect("/");
* }
*/
{
"name": "thinkjs",
"description": "thinkphp web framework for nodejs",
"version": "0.3.0",
"version": "0.3.1",
"author": {

@@ -6,0 +6,0 @@ "name": "welefen",

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