2022-04-18 11:27:25 +00:00
|
|
|
/**
|
|
|
|
* This will go through our videotex and ansitex frames and check for inconsistencies.
|
|
|
|
*
|
|
|
|
* We'll check for:
|
|
|
|
* + Mismatched metadata items
|
|
|
|
* + Out of sync content
|
|
|
|
*/
|
2022-04-15 12:40:19 +00:00
|
|
|
|
|
|
|
load('ansitex/load/funcs.js');
|
2024-01-01 06:03:25 +00:00
|
|
|
// Our page handler
|
|
|
|
load('ansitex/load/page.js');
|
2022-04-15 12:40:19 +00:00
|
|
|
|
|
|
|
/* parse command arguments */
|
|
|
|
if (argv.length !== 1) {
|
|
|
|
writeln('! ERROR: Need only 1 argument');
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//const vtx_ext = 'tex';
|
|
|
|
const vtx_src = 'bin';
|
2024-01-01 06:03:25 +00:00
|
|
|
const tex_src = 'ans';
|
2022-04-15 12:40:19 +00:00
|
|
|
|
|
|
|
const page = argv.shift();
|
|
|
|
const vtx_srcname = page+'.'+vtx_src;
|
2024-01-01 06:03:25 +00:00
|
|
|
const tex_srcname = page+'.'+tex_src;
|
2022-04-15 12:40:19 +00:00
|
|
|
var errors = false;
|
|
|
|
|
|
|
|
PAGE_FILE_PREFX = /^[0-9]+[a-z]$/;
|
|
|
|
|
|
|
|
if (! PAGE_FILE_PREFX.test(page)) {
|
|
|
|
writeln('PAGE is not a frame: '+page);
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
writeln('Comparing Frame: '+page);
|
|
|
|
|
|
|
|
// Load frame
|
2024-01-01 06:03:25 +00:00
|
|
|
require(ANSITEX_HOME+'/load/session/viewdata.js','SESSION_VIEWDATA');
|
|
|
|
vtx = new Page();
|
|
|
|
if (! vtx.import(FRAMES_HOME+SESSION_EXT+'/'+page)) {
|
2022-04-15 12:40:19 +00:00
|
|
|
writeln('- ! ERROR: VTX File doesnt exist? :'+page);
|
|
|
|
errors = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Check content between TEX/ANS & VTX/BIN
|
2024-01-01 06:03:25 +00:00
|
|
|
vtx_srcfile = new File(FRAMES_HOME+SESSION_EXT+'/'+vtx_srcname);
|
|
|
|
|
2022-04-15 12:40:19 +00:00
|
|
|
if (! vtx_srcfile.exists || ! vtx_srcfile.open('r')) {
|
|
|
|
writeln('- ! ERROR: VTX SRC File doesnt exist? :'+vtx_srcname);
|
|
|
|
errors = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
writeln('- LOADING: VTX Source :'+vtx_srcname);
|
|
|
|
|
2024-01-01 06:03:25 +00:00
|
|
|
var x = md5_calc(vtx.raw);
|
|
|
|
var y = md5_calc(vtx_srcfile.read());
|
2022-04-15 12:40:19 +00:00
|
|
|
|
|
|
|
// Check Content
|
|
|
|
if (x !== y) {
|
2024-01-01 06:03:25 +00:00
|
|
|
writeln(' - Page Content :'+x);
|
|
|
|
writeln(' - Source Content :'+y);
|
|
|
|
writeln('- ! WARNING: Content Differs.');
|
2022-04-15 12:40:19 +00:00
|
|
|
errors = true;
|
2024-01-01 06:03:25 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
writeln('= Source matches.');
|
2022-04-15 12:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-01 06:03:25 +00:00
|
|
|
require(ANSITEX_HOME+'/load/session/ansitex.js','SESSION_ANSITEX');
|
|
|
|
tex = new Page();
|
|
|
|
if (! tex.import(FRAMES_HOME+SESSION_EXT+'/'+page)) {
|
|
|
|
writeln('- ! ERROR: TEX File doesnt exist? :'+page);
|
2022-04-15 12:40:19 +00:00
|
|
|
errors = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Check content between TEX/ANS & VTX/BIN
|
2024-01-01 06:03:25 +00:00
|
|
|
tex_srcfile = new File(FRAMES_HOME+SESSION_EXT+'/'+tex_srcname);
|
|
|
|
if (! tex_srcfile.exists || ! tex_srcfile.open('r')) {
|
|
|
|
writeln('- ! ERROR: TEX SRC File doesnt exist? :'+tex_srcname);
|
2022-04-15 12:40:19 +00:00
|
|
|
errors = true;
|
|
|
|
|
|
|
|
} else {
|
2024-01-01 06:03:25 +00:00
|
|
|
writeln('- LOADING: TEX Source :'+tex_srcname);
|
2022-04-15 12:40:19 +00:00
|
|
|
|
2024-01-01 06:03:25 +00:00
|
|
|
var x = md5_calc(tex.raw);
|
|
|
|
var y = md5_calc(tex_srcfile.read());
|
2022-04-15 12:40:19 +00:00
|
|
|
|
|
|
|
if (x !== y) {
|
|
|
|
// Check Content
|
2024-01-01 06:03:25 +00:00
|
|
|
writeln(' - Page Content :'+x);
|
|
|
|
writeln(' - Source Content :'+y);
|
|
|
|
writeln('- ! WARNING: Content Differs.');
|
2022-04-15 12:40:19 +00:00
|
|
|
errors = true;
|
2024-01-01 06:03:25 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
writeln('= Source matches.');
|
2022-04-15 12:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checking keys
|
2024-01-01 06:03:25 +00:00
|
|
|
if (vtx.raw && tex.raw) {
|
|
|
|
|
|
|
|
writeln('- Checking Page: ');
|
|
|
|
if (vtx.name.toString() !== tex.name.toString()) {
|
|
|
|
writeln(' - ! VTX: '+vtx.name.toString());
|
|
|
|
writeln(' - ! TEX: '+tex.name.toString());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
writeln(' = PAGE: '+vtx.name.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
for each (var k in ['key','cost','type']) {
|
|
|
|
writeln('- Checking KEY: '+k);
|
|
|
|
|
|
|
|
if (JSON.stringify(vtx[k]) !== JSON.stringify(tex[k])) {
|
2022-04-15 12:40:19 +00:00
|
|
|
writeln(' - ! VTX: '+vtx[k]);
|
2024-01-01 06:03:25 +00:00
|
|
|
writeln(' - ! TEX: '+tex[k]);
|
|
|
|
errors = true;
|
|
|
|
} else {
|
|
|
|
writeln(' = KEY: '+vtx[k]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for each (var k in ['isAccessible','isPublic']) {
|
|
|
|
writeln('- Checking Property: '+k);
|
|
|
|
|
|
|
|
if (JSON.stringify(vtx.__properties__[k]) !== JSON.stringify(tex.__properties__[k])) {
|
|
|
|
writeln(' - ! VTX: '+vtx.__properties__[k]);
|
|
|
|
writeln(' - ! TEX: '+tex.__properties__[k]);
|
2022-04-15 12:40:19 +00:00
|
|
|
errors = true;
|
2024-01-01 06:03:25 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
writeln(' = KEY: '+vtx.__properties__[k]);
|
2022-04-15 12:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-01 06:03:25 +00:00
|
|
|
}
|
2022-04-15 12:40:19 +00:00
|
|
|
|
|
|
|
if (errors)
|
|
|
|
exit(1);
|
2022-05-01 07:42:19 +00:00
|
|
|
else
|
|
|
|
writeln('= OK');
|