diff --git a/.envrc b/.envrc index 772fc1f..50c44c6 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,6 @@ layout go use flake -export INTAKE_DATA_DIR=tmp +rootPath=$(dirname $(dirname $(realpath "$0"))) +export INTAKE_DATA_DIR=$(expand_path tmp) unset AR AS CC CONFIG_SHELL CXX HOST_PATH LD NIX_BINTOOLS NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu NIX_BUILD_CORES NIX_CC NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu NIX_CFLAGS_COMPILE NIX_ENFORCE_NO_NATIVE NIX_HARDENING_ENABLE NIX_LDFLAGS NIX_STORE NM OBJCOPY OBJDUMP RANLIB READELF SIZE SOURCE_DATE_EPOCH STRINGS STRIP __structuredAttrs buildInputs buildPhase builder cmakeFlags configureFlags depsBuildBuild depsBuildBuildPropagated depsBuildTarget depsBuildTargetPropagated depsHostHost depsHostHostPropagated depsTargetTarget depsTargetTargetPropagated doCheck doInstallCheck dontAddDisableDepTrack mesonFlags name nativeBuildInputs out outputs patches phases preferLocalBuild propagatedBuildInputs propagatedNativeBuildInputs shell shellHook stdenv strictDeps system diff --git a/Makefile b/Makefile index cfba4f0..9eea140 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,16 @@ .PHONY: help serve test-data demo +ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) + help: ## display this help @awk 'BEGIN{FS = ":.*##"; printf "\033[1m\nUsage\n \033[1;92m make\033[0;36m \033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST) serve: ## Run "intake serve" with live reload - @air -build.cmd "go build -o tmp/intake" -build.bin tmp/intake -build.args_bin serve,--data-dir,tmp -build.include_ext "go,html,css" + @air \ + -build.cmd "go build -o ${ROOT_DIR}/tmp/intake" \ + -build.bin ${ROOT_DIR}/tmp/intake \ + -build.args_bin serve \ + -build.include_ext "go,html,css" test-data: ## Recreate test data in tmp/ @test/test_items.sh diff --git a/test/hello.sh b/test/hello.sh new file mode 100755 index 0000000..0743d17 --- /dev/null +++ b/test/hello.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cat /dev/random \ + | base32 \ + | head -c8 \ + | jq -cR '{id: ., title: "Hello"}' diff --git a/test/test_items.sh b/test/test_items.sh index 311397e..b7e8c2a 100755 --- a/test/test_items.sh +++ b/test/test_items.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash set -eu -go build -o tmp/intake -rm tmp/intake.db* || true -export INTAKE_DATA_DIR="tmp" +rootPath=$(dirname $(dirname $(realpath "$0"))) + +rm -v "$rootPath"/tmp/intake.db* || true +cp -v "$rootPath"/test/*.sh "$rootPath/tmp/" +go build -o "$rootPath/tmp/intake" +export INTAKE_DATA_DIR="$rootPath/tmp" tmp/intake migrate # testing item display format @@ -57,7 +60,7 @@ tmp/intake item add -s page --id 212 --title "Item 212" --body "This is the body # test auto update tmp/intake source env -s nothing --set "INTAKE_FETCH=every 5m" tmp/intake source add -s hello -tmp/intake action add -s hello -a fetch -- sh -c "cat /dev/random | base32 | head -c8 | jq -cR '{id: ., title: \"Hello\"}'" +tmp/intake action add -s hello -a fetch -- ./hello.sh tmp/intake source env -s hello --set "INTAKE_FETCH=every 1m" # and batch tmp/intake source env -s hello --set "INTAKE_BATCH=00:00"