From 2b4d11fae11ce595946daff2e7c41391ddcdab03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tammerg=C3=A5rd?= Date: Thu, 9 Nov 2023 14:43:03 +0100 Subject: [PATCH] feat: add tool for authenticating npm to artifact registry --- tools/sgnpmartifactregistryauth/tools.go | 26 ++++++++++++++++++++++++ 1 file changed, 26 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..9be6bf25 --- /dev/null +++ b/tools/sgnpmartifactregistryauth/tools.go @@ -0,0 +1,26 @@ +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...") + return sg.Command( + ctx, + "npx", + "google-artifactregistry-auth@3.1.2", + ).Run() +}