From 8b2886e3209c92b34e952fc46b4865421196cf13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tammerg=C3=A5rd?= Date: Thu, 9 Nov 2023 14:34:34 +0100 Subject: [PATCH] feat: add package for authenticating npm to artifact registry --- tools/sgnpmartifactregistryauth/tools.go | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tools/sgnpmartifactregistryauth/tools.go diff --git a/tools/sgnpmartifactregistryauth/tools.go b/tools/sgnpmartifactregistryauth/tools.go new file mode 100644 index 00000000..1b4aae06 --- /dev/null +++ b/tools/sgnpmartifactregistryauth/tools.go @@ -0,0 +1,29 @@ +package sgnpmartifactregistryauth + +import ( + "context" + "os/exec" + + "go.einride.tech/sage/sg" +) + +const ( + name = "npm-artifact-registry-auth" +) + +func Command(ctx context.Context, args ...string) *exec.Cmd { + sg.Deps(ctx, PrepareCommand) + return sg.Command(ctx, sg.FromBinDir(name), args...) +} + +func PrepareCommand(ctx context.Context) error { + sg.Logger(ctx).Println("authenticating npm to artifact registry...") + if err := sg.Command( + ctx, + "npx", + "google-artifactregistry-auth", + ).Run(); err != nil { + return err + } + return nil +}