feat: scripts

This commit is contained in:
2025-04-05 16:57:26 +08:00
parent bd4fe63cdc
commit 3e996ffab3
62 changed files with 4905 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
#! /usr/bin/env runjs
var colorPrint = require('component-colorprint-ex.js');
var checkResultList = [];
var getArchiveInfo = (gid, aid) => {
var archiveInfo = __.httprequest
.fromUrl('https://hatter.ink/repo/archive_info.jsonp')
.param('__auth_token', 'r7dyCJpant4VFs5vqQSphEBEEqNBXqSBiFPPG7Nz6')
.param('gid', gid)
.param('aid', aid)
.get();
return JSON.parse($STR(archiveInfo));
};
var checkNewestVersion = (printedLen, gid, aid, ver) => {
var printS = (79 - printedLen);
printS = ((printS < 0)? 0: printS) + 1;
print(printS.repeat(' ').join(''));
var archiveInfo = getArchiveInfo(gid, aid);
if (archiveInfo.data == null) {
println('-');
} else {
if (archiveInfo.data.latestVersion == ver) {
println(colorPrint.okgreen.render('OK'));
} else {
println(colorPrint.warning.render('NG') + ' ' + colorPrint.okgreen.render('-> ' + archiveInfo.data.latestVersion));
checkResultList.push([gid, aid, ver].join(':') + ' -> ' + archiveInfo.data.latestVersion);
}
}
};
var main = () => {
var outs = $$.shell().commands('build.js', '-q', 'dependencies', '--configuration', 'compile').mergeError().start();
var out = outs[0];
var lines = $STR(out).split(/\n/);
lines.forEach((ln) => {
var indexOfSSS = ln.indexOf('--- ');
if (indexOfSSS >= 0) {
print(ln);
if (ln.indexOf('(*)') >= 0) {
println();
} else {
var gidAidVerAndMore = ln.substring(indexOfSSS + 3).trim();
var gid = gidAidVerAndMore.split(':')[0];
var aid = gidAidVerAndMore.split(':')[1];
var ver = gidAidVerAndMore.split(':')[2];
if (gidAidVerAndMore.indexOf('->') >= 0) {
ver = gidAidVerAndMore.split('->')[1].trim();
}
checkNewestVersion(ln.length, gid, aid, ver);
}
} else {
println(ln);
}
});
if (checkResultList.length > 0) {
xprintln('[WARN] Check result:\n' + checkResultList.join('\n'));
}
};
main();