1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export PATH := ./node_modules/.bin:$(PATH)
|
7 |
|
8 |
|
9 | SHELL := /bin/bash
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | .PHONY: test
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | clea%:
|
23 |
|
24 | @git clean -fxd
|
25 | @$(DONE)
|
26 |
|
27 |
|
28 | instal%: node_modules bower_components _install_scss_lint .editorconfig .eslintrc.js .scss-lint.yml .env webpack.config.js
|
29 | @$(MAKE) $(foreach f, $(shell find functions/* -type d -maxdepth 0 2>/dev/null), $f/node_modules)
|
30 | @$(DONE)
|
31 |
|
32 |
|
33 | deplo%: _deploy_apex
|
34 | @$(DONE)
|
35 |
|
36 |
|
37 | verif%: _verify_lintspaces _verify_eslint _verify_scss_lint
|
38 | @$(DONE)
|
39 |
|
40 |
|
41 | buil%: public/__about.json
|
42 | @if [ -e webpack.config.js ]; then webpack $(if $(findstring build-production,$@),--bail,--dev); fi
|
43 | @if [ -e Procfile ] && [ "$(findstring build-production,$@)" == "build-production" ]; then haikro build; fi
|
44 | @$(DONE)
|
45 |
|
46 |
|
47 | watc%:
|
48 | @if [ -e webpack.config.js ]; then webpack --watch --dev; fi
|
49 | @$(DONE)
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | node_modules: package.json
|
59 | @if [ -e package.json ]; then $(NPM_INSTALL) && $(DONE); fi
|
60 |
|
61 |
|
62 | bower_components: bower.json
|
63 | @if [ -e bower.json ]; then bower install --config.registry.search=http://registry.origami.ft.com --config.registry.search=https://bower.herokuapp.com && $(DONE); fi
|
64 |
|
65 |
|
66 | package.json:
|
67 | bower.json:
|
68 |
|
69 |
|
70 | functions/%/node_modules:
|
71 | @cd $(dir $@) && if [ -e package.json ]; then $(NPM_INSTALL) && $(DONE); fi
|
72 |
|
73 | _install_scss_lint:
|
74 | @if [ ! -x "$(shell which scss-lint)" ] && [ "$(shell $(call GLOB,'*.scss'))" != "" ]; then gem install scss-lint -v 0.35.0 && $(DONE); fi
|
75 |
|
76 |
|
77 | .editorconfig .eslintrc.js .scss-lint.yml webpack.config.js: n.Makefile
|
78 | @if $(call IS_GIT_IGNORED); then curl -sL https://raw.githubusercontent.com/Financial-Times/n-makefile/$(VERSION)/config/$@ > $@ && $(DONE); fi
|
79 |
|
80 | .env:
|
81 | @if $(call IS_GIT_IGNORED); then heroku auth:whoami &>/dev/null || (echo Please make sure the Heroku CLI is installed and authenticated by running ‘heroku auth:token’. See more https://toolbelt.heroku.com/. && exit 1); fi
|
82 | @if $(call IS_GIT_IGNORED) && [ -e package.json ]; then ($(call CONFIG_VARS,development) > .env && $(DONE)) || (echo "Cannot get config vars for this service. Check you are added to the ft-next-config-vars service on Heroku with operate permissions. Do that here - https://docs.google.com/spreadsheets/d/1mbJQYJOgXAH2KfgKUM1Vgxq8FUIrahumb39wzsgStu0 (or ask someone to do it for you). Check that your package.json's name property is correct. Check that your project has config-vars set up in models/development.js." && exit 1); fi
|
83 |
|
84 |
|
85 |
|
86 | _verify_eslint:
|
87 | @if [ -e .eslintrc.js ]; then $(call GLOB,'*.js') | xargs eslint && $(DONE); fi
|
88 |
|
89 | _verify_lintspaces:
|
90 | @if [ -e .editorconfig ] && [ -e package.json ]; then $(call GLOB) | xargs lintspaces -e .editorconfig -i js-comments,html-comments && $(DONE); fi
|
91 |
|
92 | _verify_scss_lint:
|
93 |
|
94 | @if [ -e .scss-lint.yml ]; then { scss-lint -c ./.scss-lint.yml `$(call GLOB,'*.scss')`; if [ $$? -ne 0 -a $$? -ne 1 ]; then exit 1; fi; $(DONE); } fi
|
95 |
|
96 |
|
97 |
|
98 | _deploy_apex:
|
99 | @if [ -e project.json ]; then $(call CONFIG_VARS,production) | sed 's/\(.*\)/-s \1/' | tr '\n' ' ' | xargs apex deploy && $(DONE); fi
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | public/__about.json:
|
105 | @if [ -e Procfile ]; then mkdir -p public && echo '{"description":"$(call APP_NAME)","support":"next.team@ft.com","supportStatus":"active","appVersion":"$(shell git rev-parse HEAD | xargs echo -n)","buildCompletionTime":"$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")"}' > $@ && $(DONE); fi
|
106 |
|
107 |
|
108 | GLOB = git ls-files -z $1 | tr '\0' '\n' | xargs -I {} find {} ! -type l
|
109 | NPM_INSTALL = npm prune --production=false && npm install
|
110 | JSON_GET_VALUE = grep $1 | head -n 1 | sed 's/[," ]//g' | cut -d : -f 2
|
111 | IS_GIT_IGNORED = grep -q $(if $1, $1, $@) .gitignore
|
112 | VERSION = v1.0.9
|
113 | APP_NAME = $(shell cat package.json 2>/dev/null | $(call JSON_GET_VALUE,name))
|
114 | DONE = echo ✓ $@ done
|
115 | CONFIG_VARS = curl -fsL https://ft-next-config-vars.herokuapp.com/$1/$(if $2,$2,$(call APP_NAME)).env -H "Authorization: `heroku config:get APIKEY --app ft-next-config-vars`"
|
116 |
|
117 | # UPDATE TASK
|
118 |
|
119 | update-tools:
|
120 | $(eval LATEST = $(shell curl -fs https://api.github.com/repos/Financial-Times/n-makefile/tags | $(call JSON_GET_VALUE,name)))
|
121 | $(if $(filter $(LATEST), $(VERSION)), $(error Cannot update n-makefile, as it is already up to date!))
|
122 | @curl -sL https://raw.githubusercontent.com/Financial-Times/n-makefile/$(LATEST)/Makefile > n.Makefile
|
123 | @sed -i "" "s/^VERSION = master/VERSION = $(LATEST)/" n.Makefile
|
124 | @read -p "Updated tools from $(VERSION) to $(LATEST). Do you want to commit and push? [y/N] " Y;\
|
125 | if [ $$Y == "y" ]; then git add n.Makefile && git commit -m "Updated tools to $(LATEST)" && git push origin HEAD; fi
|
126 | @$(DONE)
|
127 |
|
\ | No newline at end of file |