Skip to content

Commit 6621c90

Browse files
committed
Updated depdendencies about up-to-date feature.
1 parent 31cea12 commit 6621c90

3 files changed

Lines changed: 41 additions & 21 deletions

File tree

changes.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
- added: `components` more in docs
44
- added: `X-Powered-By` header again with option to disable it in the framework config `disable-xpoweredby : false`
5-
- adedd: `UPTODATE(type, url, [options], interval, [callback(err)])` more in docs
5+
- added: `UPTODATE(type, url, [options], interval, [callback(err)])` more in docs
6+
- added: `F.on('uptodate', function(type, name) {})` new event for up-to-date dependencies
67

78
- updated: new error message `The field "@" is invalid.`
89
- updated: `NOSQL().insert(doc, [unique])`
910
- updated: `quicksort` algorithm has been replaced for `shellsort` (increased performance of sorting about 10-15%)
1011
- updated: `NOSQL().counter.monthly(true, ...)` shows all stats by ID
1112
- updated: `NOSQL().counter.yearly(true, ...)` shows all stats by ID
13+
- updated: `dependencies` supports up-to-date features e.g. `module (1 day) : https://......js`
1214

1315
- removed: behaviours
1416
- removed: restrictions
@@ -1231,7 +1233,7 @@ Framework loads modules, packages, models, definitions, controllers
12311233
- added: controller.throw500(error)
12321234
- added: controller.throw501([problem])
12331235
- added: request.signature()
1234-
- adedd: Builders.create(schemaName)
1236+
- added: Builders.create(schemaName)
12351237
- added: controller.exception
12361238
- added: framework.onMail(address, subject, body, callback)
12371239
- added: controller.mail(address, subject, viewName, [model], [callback])

index.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,14 +2862,14 @@ Framework.prototype.uptodate = function(type, url, options, interval, callback)
28622862
options = null;
28632863
}
28642864

2865-
var obj = { type: type, name: '', url: url, interval: interval, options: options, updated: null, created: F.datetime, errors: [], callback: callback };
2865+
var obj = { type: type, name: '', url: url, interval: interval, options: options, count: 0, updated: F.datetime, errors: [], callback: callback };
28662866

28672867
if (!F.uptodates)
28682868
F.uptodates = [];
28692869

28702870
F.uptodates.push(obj);
28712871
F.install(type, url, options, function(err, name) {
2872-
err && obj.errors.puhs(err);
2872+
err && obj.errors.push(err);
28732873
obj.name = name;
28742874
obj.callback && obj.callback(err, name);
28752875
});
@@ -6410,16 +6410,19 @@ Framework.prototype._service = function(count) {
64106410
}
64116411

64126412
F.uptodates && (count % F.config['default-interval-uptodate'] === 0) && F.uptodates.length && F.uptodates.wait(function(item, next) {
6413-
if (item.latest > F.datetime)
6413+
if (item.updated.add(item.interval) > F.datetime)
64146414
return next();
6415-
item.latest = F.datetime;
6415+
item.updated = F.datetime;
64166416
item.name && F.uninstall(item.type, item.name);
6417+
item.count++;
64176418
F.install(item.type, item.url, item.options, function(err, name) {
64186419
if (err) {
64196420
item.errors.push(err);
64206421
item.errors.length > 50 && F.errors.shift();
6421-
} else
6422+
} else {
64226423
item.name = name;
6424+
F.emit('uptodate', item.type, name);
6425+
}
64236426
item.callback && item.callback(err, name);
64246427
next();
64256428
});
@@ -8033,6 +8036,8 @@ Framework.prototype._configure_dependencies = function(arr) {
80338036
if (!arr)
80348037
return F;
80358038

8039+
var type;
8040+
80368041
for (var i = 0, length = arr.length; i < length; i++) {
80378042

80388043
var str = arr[i];
@@ -8050,9 +8055,15 @@ Framework.prototype._configure_dependencies = function(arr) {
80508055
var key = str.substring(0, index).trim();
80518056
var url = str.substring(index + 2).trim();
80528057
var options = EMPTYOBJECT;
8058+
var interval;
80538059

8054-
index = url.indexOf('-->');
8060+
index = key.indexOf('(');
8061+
if (index !== -1) {
8062+
interval = key.substring(index, key.indexOf(')', index)).replace(/\(|\)/g, '').trim();
8063+
key = key.substring(0, index).trim();
8064+
}
80558065

8066+
index = url.indexOf('-->');
80568067
if (index !== -1) {
80578068
var opt = url.substring(index + 3).trim();
80588069
if (opt.isJSON())
@@ -8064,53 +8075,60 @@ Framework.prototype._configure_dependencies = function(arr) {
80648075
case 'package':
80658076
case 'packages':
80668077
case 'pkg':
8067-
F.install('package', url, options);
8078+
type = 'package';
80688079
break;
80698080
case 'module':
80708081
case 'modules':
8071-
F.install('module', url, options);
8082+
type = 'module';
80728083
break;
80738084
case 'model':
80748085
case 'models':
8075-
F.install('model', url, options);
8086+
type = 'model';
80768087
break;
80778088
case 'source':
80788089
case 'sources':
8079-
F.install('source', url, options);
8090+
type = 'source';
80808091
break;
80818092
case 'controller':
80828093
case 'controllers':
8083-
F.install('controller', url, options);
8094+
type = 'controller';
80848095
break;
80858096
case 'view':
80868097
case 'views':
8087-
F.install('view', url, options);
8098+
type = 'view';
80888099
break;
80898100
case 'version':
80908101
case 'versions':
8091-
F.install('version', url, options);
8102+
type = 'version';
80928103
break;
80938104
case 'config':
80948105
case 'configuration':
8095-
F.install('config', url, options);
8106+
type = 'config';
80968107
break;
80978108
case 'isomorphic':
80988109
case 'isomorphics':
8099-
F.install('isomorphic', url, options);
8110+
type = 'isomorphic';
81008111
break;
81018112
case 'definition':
81028113
case 'definitions':
8103-
F.install('definition', url, options);
8114+
type = 'definition';
81048115
break;
81058116
case 'middleware':
81068117
case 'middlewares':
8107-
F.install('middleware', url, options);
8118+
type = 'middleware';
81088119
break;
81098120
case 'component':
81108121
case 'components':
8111-
F.install('component', url, options);
8122+
type = 'component';
81128123
break;
81138124
}
8125+
8126+
if (type) {
8127+
if (interval)
8128+
F.uptodate(type, url, options, interval);
8129+
else
8130+
F.install(type, url, options);
8131+
}
81148132
}
81158133

81168134
return F;

test/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module : https://www.totaljs.com/framework/include.js --> {"test":true}
1+
module (1 day) : https://www.totaljs.com/framework/include.js --> {"test":true}

0 commit comments

Comments
 (0)