Deno plugins (#42)

Switch from BoaJS to Deno core
This commit is contained in:
Gregory Schier
2024-06-07 10:47:41 -07:00
committed by GitHub
parent f43b38c893
commit acfc254a58
32 changed files with 1378 additions and 5663 deletions

View File

@@ -5,7 +5,7 @@ import {
HttpRequest,
Workspace,
} from '../../../src-web/lib/models';
import { parse as parseYaml } from 'yaml';
import '../../../src-web/plugin/runtime.d.ts';
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
@@ -17,7 +17,7 @@ export interface ExportResources {
folders: AtLeast<Folder, 'name' | 'id' | 'model' | 'workspaceId'>[];
}
export function pluginHookImport(contents: string) {
export function pluginHookImport(ctx: YaakContext, contents: string) {
let parsed: any;
try {
@@ -25,8 +25,10 @@ export function pluginHookImport(contents: string) {
} catch (e) {}
try {
parsed = parseYaml(contents);
} catch (e) {}
parsed = parsed ?? YAML.parse(contents);
} catch (e) {
console.log('FAILED', e);
}
if (!isJSObject(parsed)) return;
if (!Array.isArray(parsed.resources)) return;