From 13291c3cf80d4b8280b38ab46c87b83ac0c27078 Mon Sep 17 00:00:00 2001 From: Kevin Chen Date: Wed, 2 Aug 2023 14:03:33 -0400 Subject: [PATCH] feat(hasura.io): Add package for the Hasura CLI (#2720) * feat(hasura.io): Add package for Hasura * fix: build make target * fix: Use Make v3 * fix: Use Make v4 * comments * fix: Use Make 4.3.0 * fix: Skip checksums Co-authored-by: Max Howell --- projects/hasura.io/package.yml | 51 ++++++++++++++++++++++++++++++++++ tea.yaml | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 projects/hasura.io/package.yml diff --git a/projects/hasura.io/package.yml b/projects/hasura.io/package.yml new file mode 100644 index 00000000..f12f759d --- /dev/null +++ b/projects/hasura.io/package.yml @@ -0,0 +1,51 @@ +distributable: + url: https://github.com/hasura/graphql-engine/archive/refs/tags/v{{version}}.tar.gz + strip-components: 1 + +versions: + github: hasura/graphql-engine + +provides: + - bin/hasura + +build: + # I copied the brew formula here --mxcl + # NOTE there is a `Makefile`, possibly not using it is asking for trouble + script: + - working-directory: cli-ext + run: + - npm update pkg # see https://github.com/hasura/graphql-engine/issues/9440 + - | + npm install --global --build-from-source --prefix={{prefix}} + npm run prebuild + node_modules/.bin/pkg ./build/command.js --output ./bin/cli-ext-hasura -t host + + - working-directory: cli + run: | + cp ../cli-ext/bin/cli-ext-hasura internal/cliext/static-bin/$PLATFORM/cli-ext + go build -v -ldflags="$LDFLAGS" -o="{{prefix}}/bin/hasura" ./cmd/hasura + + dependencies: + go.dev: ^1.16 + npmjs.com: ^8.19.4 + gnu.org/coreutils: '*' + nodejs.org: ^18 # fails with ^20 + env: + darwin/aarch64: {PLATFORM: darwin/arm64} + darwin/x86-64: {PLATFORM: darwin/amd64} + linux/aarch64: {PLATFORM: linux/arm64} + linux/x86-64: {PLATFORM: linux/amd64} + LDFLAGS: + - -s + - -w + - -X github.com/hasura/graphql-engine/cli/v2/version.BuildVersion={{version}} + - -X github.com/hasura/graphql-engine/cli/v2/plugins.IndexBranchRef=master + linux: + # or segmentation fault + # fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575 + LDFLAGS: + - -buildmode=pie + +test: | + hasura --skip-update-check version | grep {{version}} + hasura init testdir diff --git a/tea.yaml b/tea.yaml index 42c9aba6..4f094278 100644 --- a/tea.yaml +++ b/tea.yaml @@ -1,4 +1,4 @@ dependencies: - tea.xyz/brewkit: '>=0.28.1' + tea.xyz/brewkit: ^0.44 env: TEA_PANTRY_PATH: ${{srcroot}}