Include schemas in deployments

This commit is contained in:
Evert Prants 2021-10-02 15:21:00 +03:00
parent 43d33a5937
commit 82f65b6fee
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
5 changed files with 26 additions and 11 deletions

View File

@ -20,10 +20,11 @@ For example, installing core plugins (Interactive mode `-i` on `squeebotd`):
## Interactive mode commands
The following commands are available when starting in interactive mode:
* `repository help`
* `plugin help`
* `channel help`
* `quit`
* `repository help` - Repository management commands
* `plugin help` - Plugin management commands
* `channel help` - Channel management commands
* `quit` - Exit Squeebot
* `inspector` - Enter JavaScript REPL (basically the same as running `node` without arguments)
## Creating a repository
In order to create a repository, you need to do the following:
@ -41,8 +42,9 @@ The build command supports a `-w` argument which will execute the entire build c
Within your new repository, each directory you make will be a plugin. The plugin **must** contain the following:
1. `plugin.json` - Manifest for your plugin.
2. `plugin.js` - Has to be a JavaScript file which exports a class inherited from `Plugin` at `@squeebot/core/lib/plugin`.
3. `schema.json` - (optionally) include a JSON schema for the plugin's configuration.
**Note:** `plugin.js` only has to exist in the distribution, so `.ts` is fine, but you have to use `$ squeebot repository build <path>`
**Note:** `plugin.js` only has to exist in the distribution, so `.ts` is fine, but you **have** to use `$ squeebot repository build <path>`
to build them into JavaScript files.
Plugin manifest (`plugin.json`) example:

View File

@ -1,6 +1,6 @@
{
"name": "@squeebot/cli",
"version": "3.4.1",
"version": "3.4.2",
"description": "Squeebot v3 runtime, environments and configuration",
"main": "dist/squeebot.js",
"bin": {

View File

@ -99,7 +99,7 @@ export async function buildRepository(
}
if (meta.typescript) {
console.log('Stripping source files');
console.log('Stripping TypeScript source files');
for (const plugin of plugins) {
const plOut = path.join(outDir, plugin.name);
const listAllFiles = await fs.readdir(plOut);
@ -111,6 +111,16 @@ export async function buildRepository(
}
}
console.log('Copying configuration schemas');
for (const plugin of plugins) {
const plOut = path.join(outDir, plugin.name);
const schemaFile = path.join(plOut, 'schema.json');
const outSchemaFile = path.join(outDir, `${plugin.name}.schema.json`);
if (await fs.pathExists(schemaFile)) {
await fs.copy(schemaFile, outSchemaFile);
}
}
console.log('Creating tarballs');
for (const plugin of plugins) {
const plOut = path.join(outDir, plugin.name);

View File

@ -33,9 +33,10 @@ export async function developDeploy(
console.log('Copying plugins to', pluginsPath);
const listAllFiles = await fs.readdir(outDir);
for (const f of listAllFiles) {
if (f === 'repository' || f.indexOf('.tgz') !== -1) {
if (f === 'repository' || f.endsWith('.tgz') || f.endsWith('.json')) {
continue;
}
const dst = path.join(pluginsPath, f);
await fs.copy(path.join(outDir, f), dst, {
overwrite: true,

View File

@ -26,9 +26,11 @@ export async function sshDeploy(
console.log('Deploying to %s@%s:%d%s', username, host, port, target);
const fileList = (await fs.readdir(outDir)).filter((val) => {
return val === 'repository.json' || val.match('.tgz$');
}).map((x) => path.join(outDir, x));
const fileList = (await fs.readdir(outDir)).filter((val) =>
val === 'repository.json'
|| val.endsWith('.tgz')
|| val.endsWith('schema.json')
).map((x) => path.join(outDir, x));
const pargs = [
'rsync',