diff --git a/package.json b/package.json index ddbb134..69a9d1f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/build/repository/build.ts b/src/build/repository/build.ts index a57adcd..350efdb 100644 --- a/src/build/repository/build.ts +++ b/src/build/repository/build.ts @@ -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; diff --git a/src/squeebot.ts b/src/squeebot.ts index 428f195..632504b 100644 --- a/src/squeebot.ts +++ b/src/squeebot.ts @@ -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));