checksum system

This commit is contained in:
Evert Prants 2022-12-01 14:46:22 +02:00
parent 0513c9827e
commit ea1fbd0b8d
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 21 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@squeebot/cli",
"version": "3.4.4",
"version": "3.5.0",
"description": "Squeebot v3 runtime, environments and configuration",
"main": "dist/squeebot.js",
"bin": {
@ -30,7 +30,7 @@
"typescript": "^4.4.2"
},
"dependencies": {
"@squeebot/core": "^3.3.8",
"@squeebot/core": "^3.4.0",
"fs-extra": "^10.0.0",
"node-watch": "^0.7.1",
"tar": "^6.1.11",

View File

@ -1,4 +1,5 @@
import { PluginMetaLoader } from '@squeebot/core/lib/plugin';
import { takeChecksum } from '@squeebot/core/lib/util';
import fs from 'fs-extra';
import path from 'path';
import tar from 'tar';
@ -82,15 +83,8 @@ export async function buildRepository(
return;
}
console.log('Creating repository index');
await fs.remove(outDir);
await fs.ensureDir(outDir);
await fs.writeJSON(path.join(outDir, 'repository.json'), {
created: Math.floor(Date.now() / 1000),
name: meta.name,
plugins: meta.plugins,
$schema: REPOSITORY_SCHEMA,
});
console.log('Copying plugins');
for (const plugin of plugins) {
@ -125,13 +119,29 @@ export async function buildRepository(
console.log('Creating tarballs');
for (const plugin of plugins) {
const plOut = path.join(outDir, plugin.name);
const fileName = `${plOut}.plugin.tgz`;
await tar.c({
gzip: true,
file: plOut + '.plugin.tgz',
file: fileName,
C: outDir,
}, [plugin.name]);
// Create checksum of tarball
const checksum = await takeChecksum(fileName);
const metaPlugin = meta.plugins.find((item: { name: string }) => item.name === plugin.name);
if (metaPlugin && checksum) {
metaPlugin.checksum = checksum;
}
}
console.log('Creating repository index');
await fs.writeJSON(path.join(outDir, 'repository.json'), {
created: Math.floor(Date.now() / 1000),
name: meta.name,
plugins: meta.plugins,
$schema: REPOSITORY_SCHEMA,
});
if (doDeploy == null) {
console.log('Done!');
return;

View File

@ -26,7 +26,7 @@ const yar = yargs.scriptName('squeebot')
})
.option('t', {
alias: 'no-typescript',
describe: 'Do not include typescript in the development environment',
describe: 'Do not include TypeScript in the development environment',
type: 'boolean',
});
}, (v) => newRepository(v.name as string, v.path as string, v.t !== true));