linny-r 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.js +18 -10
- package/static/scripts/linny-r-model.js +2 -3
package/package.json
CHANGED
package/server.js
CHANGED
@@ -75,9 +75,12 @@ function getVersionInfo() {
|
|
75
75
|
console.log('This indicates that Linny-R is not installed properly.');
|
76
76
|
process.exit();
|
77
77
|
}
|
78
|
+
console.log('\nNode.js server for Linny-R version', info.current);
|
79
|
+
console.log('Looking for newer version on https://npmjs.com');
|
78
80
|
try {
|
79
81
|
const
|
80
|
-
json = child_process.execSync(
|
82
|
+
json = child_process.execSync(
|
83
|
+
'npm show linny-r time version --json', {timeout: 5000}),
|
81
84
|
obj = JSON.parse(json);
|
82
85
|
info.latest = obj.version;
|
83
86
|
info.latest_time = new Date(Date.parse(obj.time[info.latest]));
|
@@ -87,12 +90,13 @@ function getVersionInfo() {
|
|
87
90
|
// `latest` = 0 indicates that version check failed
|
88
91
|
info.latest = 0;
|
89
92
|
}
|
90
|
-
console.log('\nNode.js server for Linny-R version', info.current);
|
91
93
|
if(!info.latest) {
|
92
|
-
console.log('
|
94
|
+
console.log(connectionErrorText('Could not connect to https://nodejs.com'));
|
93
95
|
} else if(!info.up_to_date) {
|
94
96
|
console.log('UPDATE: Version ' + info.latest + ' was released on ' +
|
95
97
|
info.latest_time.toString());
|
98
|
+
} else {
|
99
|
+
console.log('Linny-R software is up-to-date');
|
96
100
|
}
|
97
101
|
return info;
|
98
102
|
}
|
@@ -433,7 +437,7 @@ function repositoryByName(name) {
|
|
433
437
|
while(rbn.length < 2) rbn.push('');
|
434
438
|
if(rbn[0] === name) return rbn;
|
435
439
|
}
|
436
|
-
console.log(`ERROR: Repository "${name}" not
|
440
|
+
console.log(`ERROR: Repository "${name}" not registered on this computer`);
|
437
441
|
return false;
|
438
442
|
}
|
439
443
|
|
@@ -485,7 +489,7 @@ function repoAdd(res, sp) {
|
|
485
489
|
// Error callback function is used twice, so define it here
|
486
490
|
const noConnection = (error, res) => {
|
487
491
|
console.log(error);
|
488
|
-
servePlainText(res, '
|
492
|
+
servePlainText(res, connectionErrorText('Failed to connect to ' + url));
|
489
493
|
};
|
490
494
|
// Verify that the URL points to a Linny-R repository
|
491
495
|
postRequest(url, {action: 'id'},
|
@@ -596,8 +600,8 @@ function repoDir(res, rname) {
|
|
596
600
|
// The `on_error` function
|
597
601
|
(error, res) => {
|
598
602
|
console.log(error);
|
599
|
-
servePlainText(res,
|
600
|
-
`
|
603
|
+
servePlainText(res, connectionErrorText(
|
604
|
+
`Failed to access remote repository "${rname}"`));
|
601
605
|
},
|
602
606
|
res);
|
603
607
|
} else {
|
@@ -751,7 +755,7 @@ function repoAccess(res, rname, rtoken) {
|
|
751
755
|
// The `on_error` function
|
752
756
|
(error, res) => {
|
753
757
|
console.log(error);
|
754
|
-
servePlainText(res, '
|
758
|
+
servePlainText(res, connectionErrorText('Failed to connect to' + r[1]));
|
755
759
|
},
|
756
760
|
res);
|
757
761
|
}
|
@@ -808,7 +812,7 @@ function repoStore(res, rname, mname, mxml) {
|
|
808
812
|
// The `on_error` function
|
809
813
|
(error, res) => {
|
810
814
|
console.log(error);
|
811
|
-
servePlainText(res, '
|
815
|
+
servePlainText(res, connectionErrorText('Failed to connect to' + r[1]));
|
812
816
|
},
|
813
817
|
res);
|
814
818
|
} else {
|
@@ -870,7 +874,7 @@ function loadData(res, url) {
|
|
870
874
|
getTextFromURL(url,
|
871
875
|
(data, res) => servePlainText(res, data),
|
872
876
|
(error, res) => servePlainText(res,
|
873
|
-
`
|
877
|
+
connectionErrorText(`Failed to get data from <tt>${url}</tt>`)),
|
874
878
|
res);
|
875
879
|
} catch(err) {
|
876
880
|
console.log(err);
|
@@ -1378,6 +1382,10 @@ function formData(obj) {
|
|
1378
1382
|
return fields.join('&');
|
1379
1383
|
}
|
1380
1384
|
|
1385
|
+
function connectionErrorText(msg) {
|
1386
|
+
return 'WARNING: ' + msg + ' - Please check your internet connection';
|
1387
|
+
}
|
1388
|
+
|
1381
1389
|
//
|
1382
1390
|
// Functions used during initialization
|
1383
1391
|
//
|
@@ -2019,10 +2019,9 @@ class LinnyRModel {
|
|
2019
2019
|
this.timeout_period = Math.max(0,
|
2020
2020
|
safeStrToInt(nodeContentByTag(node, 'timeout-period')));
|
2021
2021
|
// Legacy models have tag "optimization-period" instead of "block-length"
|
2022
|
-
const
|
2022
|
+
const bl_str = nodeContentByTag(node, 'block-length') ||
|
2023
2023
|
nodeContentByTag(node, 'optimization-period');
|
2024
|
-
this.block_length = Math.max(1,
|
2025
|
-
safeStrToInt(nodeContentByTag(node, bl_tag)));
|
2024
|
+
this.block_length = Math.max(1, safeStrToInt(node, bl_str));
|
2026
2025
|
this.start_period = Math.max(1,
|
2027
2026
|
safeStrToInt(nodeContentByTag(node, 'start-period')));
|
2028
2027
|
this.end_period = Math.max(1,
|