From af8a692cd13906d5d18e4bd474edeccc8016cd14 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 7 Oct 2024 13:05:21 -0400 Subject: [PATCH] wip: rpc for python builds --- platform/src/components/aws/function.ts | 65 ++++++++++++------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/platform/src/components/aws/function.ts b/platform/src/components/aws/function.ts index 3913a2b59..e083fbdaa 100644 --- a/platform/src/components/aws/function.ts +++ b/platform/src/components/aws/function.ts @@ -1182,41 +1182,25 @@ export class Function extends Component implements Link.Linkable { this.logGroup = logGroup; this.fnUrl = fnUrl; - all([ - dev, - name, - linkData, - args.handler, - args.bundle, + const buildInput = output({ + functionID: name, + handler: args.handler, + bundle: args.bundle, runtime, - args.nodejs, + links: linkData.apply((input) => + Object.fromEntries(input.map((item) => [item.name, item.properties])), + ), copyFiles, - ]).apply( - async ([ - dev, - name, - links, - handler, - bundle, - runtime, - nodejs, - copyFiles, - ]) => { - if (!dev) return; - await rpc.call("Runtime.AddTarget", { - functionID: name, - handler: handler, - bundle: bundle, - runtime: runtime, - links: Object.fromEntries( - links.map((link) => [link.name, link.properties]), - ), - copyFiles: copyFiles, - properties: nodejs, - dev: true, - }); - }, - ); + properties: output({ nodejs: args.nodejs, python: args.python }).apply( + (val) => val.nodejs || val.python, + ), + dev, + }); + + buildInput.apply(async (input) => { + if (!input.dev) return; + await rpc.call("Runtime.AddTarget", input); + }); this.registerOutputs({ _live: unsecret( @@ -1464,6 +1448,21 @@ export class Function extends Component implements Link.Linkable { }; } + if (false) { + const buildResult = buildInput.apply(async (input) => { + const result = await rpc.call<{ + handler: string; + out: string; + errors: string[]; + }>("Runtime.Build", input); + if (result.errors.length > 0) { + throw new Error(result.errors.join("\n")); + } + return result; + }); + return buildResult; + } + if (args.bundle) { return { bundle: output(args.bundle),