MonkeyCanCode commented on code in PR #171: URL: https://github.com/apache/polaris-tools/pull/171#discussion_r2831368672
########## console/Makefile: ########## @@ -1,37 +1,91 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# Configures the shell for recipes to use bash, enabling bash commands and ensuring +# that recipes exit on any command failure (including within pipes). +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec + +## Variables DOCKER ?= docker DOCKER_IMAGE_NAME ?= apache/polaris-console DOCKER_IMAGE_TAG ?= latest -.PHONY: build-docker -build-docker: - @$(DOCKER) build -f docker/Dockerfile -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) . +## Version information +BUILD_VERSION := $(shell grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/') +GIT_COMMIT := $(shell git rev-parse HEAD) +##@ General -.PHONY: install -install: - npm install +.PHONY: help +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9\.-]+:.*?##/ { printf " \033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -.PHONY: lint -lint: format-check - npm run lint +.PHONY: version +version: ## Display version information + @echo "Build version: ${BUILD_VERSION}" + @echo "Git commit: ${GIT_COMMIT}" -.PHONY: format-fix -format-fix: - npm run format +##@ Polaris Console -.PHONE: lint-fix -lint-fix: format-fix - npm run lint -- --fix +.PHONY: build +build: lint ## Lint the console project + @echo "--- Building console project---" + @npm run build + @echo "--- Console project built ---" + +.PHONY: build-docker +build-docker: install ## Build docker image for console project + @echo "--- Building docker image for console project---" + @$(DOCKER) build -f docker/Dockerfile -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) . + @echo "--- Docker image for console project built ---" + +.PHONY: dev +dev: install ## Run the console project in development mode + @echo "--- Running console project in development mode ---" + @npm run dev + @echo "--- Console project in development mode completed ---" .PHONY: format-check -format-check: - npm run format:check +format-check: install ## Fix formatting in the console project Review Comment: Copy/Paste issue when I was refactor this. This had being updated. And the dependency is intensional as for a refresh setup (where there is no `node_modules` dir), the check format will fail such as following: ``` ➜ console git:(makefile_refactor) ✗ npm run format:check > [email protected] format:check > prettier --check "src/**/*.{ts,tsx,js,jsx,json,css,md}" sh: prettier: command not found ``` Then after the install, this will then complete without error: ``` ➜ console git:(makefile_refactor) ✗ npm run format:check > [email protected] format:check > prettier --check "src/**/*.{ts,tsx,js,jsx,json,css,md}" Checking formatting... All matched files use Prettier code style! ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
