diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..ad35aa391f --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +# Makefile for running typical developer workflow actions. +# To run actions in a subdirectory of the repo: +# make lint build dir=translate/snippets + +INTERFACE_ACTIONS="build test lint" + +.ONESHELL: #ease subdirectory work by using the same subshell for all commands +.-PHONY: * + +# Default to current dir if not specified. +dir ?= $(shell pwd) + +export GOOGLE_CLOUD_PROJECT = ${GOOGLE_SAMPLES_PROJECT} + +build: + cd ${dir} + npm install + npm run build --if-present + +test: check-env build + cd ${dir} + npm test + +lint: + cd ${dir} + npx gts fix + npx gts lint + +check-env: +ifndef GOOGLE_SAMPLES_PROJECT + $(error GOOGLE_SAMPLES_PROJECT environment variable is required to perform this action) +endif + +list-actions: + @ echo ${INTERFACE_ACTIONS} + diff --git a/package.json b/package.json index 91806d064b..650ce33f60 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,11 @@ "gts": "^5.0.1", "mocha": "^10.2.0", "nunjucks": "^3.2.4", - "prettier": "^3.0.0", + "prettier": "^3.0.3", "typescript": "^5.0.4" }, "dependencies": { - "commander": "^11.0.0" + "commander": "^11.0.0", + "eslint": "^8.53.0" } }