Rework actions to be loaded dynamically

This commit is contained in:
Tom Wiesing 2023-11-08 10:29:09 +01:00
parent e49f89d4ee
commit 08ab7b4383
No known key found for this signature in database
22 changed files with 934 additions and 81 deletions

View file

@ -0,0 +1,43 @@
import Call, { Hooks } from './client'
import { Provision } from './client/calls';
const eConsole = new console.Console(process.stderr, process.stderr);
// read API KEY
const API_KEY = process.env.API_KEY;
if (!API_KEY) {
eConsole.error('API_KEY not speciied')
}
// READ ARGUMENTS
if (process.argv.length < 4) {
eConsole.error('Usage: API_KEY=$API_KEY <script> $REMOTE $SLUG');
process.exit(1);
}
const REMOTE = process.argv[2];
const SLUG = process.argv[3];
// do the call!
const result = Call(
{
url: REMOTE,
token: API_KEY,
},
Provision({
Slug: SLUG,
Flavor: "Drupal 10",
System: {
PHP: "Default (8.1)",
OpCacheDevelopment: false,
ContentSecurityPolicy: "",
}
}),
{
beforeCall: eConsole.log.bind(eConsole, 'beforeCall'),
afterCall: eConsole.log.bind(eConsole, 'afterCall'),
onError: eConsole.error.bind(eConsole, 'onError'),
onLogLine: (_, line) => process.stdout.write(line)
},
);
result.then((x) => eConsole.log(x)).catch((x) => eConsole.error(x));