update hub script

This commit is contained in:
Ruben Fiszel
2023-08-18 00:19:15 +02:00
parent cb00a1358d
commit a2b1d6997b
3 changed files with 23 additions and 6 deletions
@@ -0,0 +1 @@
-- Add down migration script here
@@ -0,0 +1,15 @@
-- Add up migration script here
UPDATE script SET content = 'import wmill from "https://deno.land/x/wmill@v1.151.0/main.ts";
export async function main() {
await run(
"workspace", "add", "__automation", "admins", Deno.env.get("BASE_INTERNAL_URL") + "/", "--token", Deno.env.get("WM_TOKEN"));
await run("hub", "pull");
}
async function run(...cmd: string[]) {
console.log("Running \"" + cmd.join('' '') + "\"");
await wmill.parse(cmd);
}', summary = 'Synchronize Hub Resource types with instance',
description = 'Basic administrative script to sync latest resource types from hub to share to every workspace. Recommended to run at least once. On a schedule by default.'
WHERE hash = -28028598712388162 AND workspace_id = 'admins';
+7 -6
View File
@@ -62,6 +62,12 @@ async function pull(opts: GlobalOptions) {
});
for (const x of list) {
try {
x.schema = JSON.parse(x.schema);
} catch (e) {
log.info("failed to parse schema for " + x.name);
continue;
}
if (
resourceTypes.find(
(y) =>
@@ -74,12 +80,7 @@ async function pull(opts: GlobalOptions) {
continue;
}
log.info("syncing " + x.name);
try {
x.schema = JSON.parse(x.schema);
} catch (e) {
log.info("failed to parse schema for " + x.name);
continue;
}
await pushResourceType(
workspace.workspaceId,
x.name + ".resource-type.json",