-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (47 loc) · 1.58 KB
/
Makefile
File metadata and controls
58 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# General project vars
SHELL := /bin/bash
NODE_ENV ?= production
PWD ?= .
VERSION = $(shell git tag --points-at HEAD)
COMMIT ?= $(shell git rev-parse --short HEAD)
# Google Cloud vars
GC_PROJECT ?= project-name
GC_COMPUTE_ZONE ?= us-central1-b
GC_TIMEOUT ?= 10
GC_REPO ?= https://source.developers.google.com/p/$(GC_PROJECT)/r/services
GC_REPO_BRANCH ?= master
GC_REGISTRY = "us.gcr.io/$(GC_PROJECT)"
# Google Cloud commands
GC_FUNC_CMD = gcloud alpha functions
GC_PUBSUB_CMD = gcloud alpha pubsub
# Organizational vars
NAME ?= Component
TEMPLATE_NAME ?= Template
TEMPLATES_DIR ?= src/components/examples/$(TEMPLATE_NAME)
TEMPLATES = $(shell find $(TEMPLATES_DIR) -type f)
TARGET_DIR ?= src/components/shared
TARGET_DIR_NAME = $(TARGET_DIR)/$(NAME)
# Check if commands exist in PATH
.PHONY: check-sed
check-sed:
@which sed > /dev/null || (echo; echo 'Install sed first'; echo; exit 1)
.PHONY: check-find
check-find:
@which find > /dev/null || (echo; echo 'Install find first'; echo; exit 1)
# Create new component from template (pass -NAME param to specify target name)
.PHONY: component
component: check-sed check-find $(TARGET_DIR_NAME) rename-templates
@$(foreach \
file, \
$(shell find $(TARGET_DIR_NAME) -type f), \
sed -i '' -e ''s/$(TEMPLATE_NAME)/$(NAME)/g'' $(file);)
# Copy templates to target
$(TARGET_DIR_NAME):
@cp -R $(TEMPLATES_DIR) $(TARGET_DIR_NAME)
# Rename template files
.PHONY: rename-templates
rename-templates: $(TARGET_DIR_FILES)
@$(foreach \
file, \
$(shell find $(TARGET_DIR_NAME) -type f), \
mv $(file) $(shell echo $(file) | sed 's/$(TEMPLATE_NAME)/$(NAME)/');)