1- SUNTORY_VERSION = 1.1.0
1+ # ###############################################################
2+ # Suntory: Makefile for building Node.js packages
3+ # https://github.com/cliffano/suntory
4+ # ###############################################################
5+
6+ # Suntory's version number
7+ SUNTORY_VERSION = 1.4.0
28
39# ###############################################################
410# User configuration variables
11+ # https://github.com/cliffano/suntory#configuration
512# These variables should be stored in suntory.yml config file,
613# and they will be parsed using yq https://github.com/mikefarah/yq
7- # Example:
8- # ---
9- # package_name: somepackage
10- # author: Some Author
1114
1215# PACKAGE_NAME is the name of the node.js package
1316PACKAGE_NAME =$(shell yq .package_name suntory.yml)
1417
1518# AUTHOR is the author of the node.js package
1619AUTHOR ?= $(shell yq .author suntory.yml)
1720
21+ define set_generator_vars
22+ $(1 ) : GENERATOR_COMPONENT = $$(shell yq .generator.component suntory.yml)
23+ $(1 ) : GENERATOR_INPUTS_PROJECT_ID = $$(shell yq .generator.inputs.project_id suntory.yml)
24+ $(1 ) : GENERATOR_INPUTS_PROJECT_NAME = $$(shell yq .generator.inputs.project_name suntory.yml)
25+ $(1 ) : GENERATOR_INPUTS_PROJECT_DESC = $$(shell yq .generator.inputs.project_desc suntory.yml)
26+ $(1 ) : GENERATOR_INPUTS_AUTHOR_NAME = $$(shell yq .generator.inputs.author_name suntory.yml)
27+ $(1 ) : GENERATOR_INPUTS_AUTHOR_EMAIL = $$(shell yq .generator.inputs.author_email suntory.yml)
28+ $(1 ) : GENERATOR_INPUTS_AUTHOR_URL = $$(shell yq .generator.inputs.author_url suntory.yml)
29+ $(1 ) : GENERATOR_INPUTS_GITHUB_ID = $$(shell yq .generator.inputs.github_id suntory.yml)
30+ $(1 ) : GENERATOR_INPUTS_GITHUB_REPO = $$(shell yq .generator.inputs.github_repo suntory.yml)
31+ $(1 ) : GENERATOR_INPUTS_GITHUB_TOKEN_PREFIX = $$(shell yq .generator.inputs.github_token_prefix suntory.yml)
32+ endef
33+
1834$(info # ###############################################################)
1935$(info Building node.js package using Suntory with user configurations...)
2036$(info - Package name = ${PACKAGE_NAME})
2137$(info - Author = ${AUTHOR})
2238
2339export PATH := node_modules/bin:$(PATH )
2440
41+ define run_hook
42+ @if [ -f Makefile-extras ] && grep -q "^$(1 ) :" Makefile-extras; then \
43+ $(MAKE ) -f Makefile-extras $(1 ) ; \
44+ fi
45+ endef
46+
47+ define deps_extra
48+ @if command -v apt-get > /dev/null 2>&1; then \
49+ if [ "$$(id -u ) " = "0" ]; then \
50+ $(MAKE ) deps-extra-apt; \
51+ else \
52+ sudo $(MAKE ) deps-extra-apt; \
53+ fi; \
54+ fi
55+ endef
56+
2557# ###############################################################
2658# Base targets
2759
2860# CI target to be executed by CI/CD tool
29- all :ci
30- ci : deps clean style lint test coverage complexity doc package reinstall test-integration
61+ all : ci
62+ ci : clean style lint test coverage complexity doc package reinstall test-integration
3163
3264# Ensure stage directory exists
3365stage :
@@ -37,14 +69,16 @@ stage:
3769clean :
3870 bob clean
3971
40- # Retrieve the Pyhon package dependencies
72+ # Retrieve the Node.js package dependencies
4173deps :
4274 npm install -g bob@5.2.1
4375 bob dep
76+ $(call deps_extra)
4477
4578deps-extra-apt :
4679 apt-get update
4780 apt-get install -y markdownlint
81+ $(call run_hook,x-post-deps-extra-apt)
4882
4983deps-upgrade :
5084 bob updep
@@ -65,16 +99,7 @@ update-to-version:
6599 curl https://raw.githubusercontent.com/cliffano/suntory/$(TARGET_SUNTORY_VERSION ) /src/Makefile-suntory -o Makefile
66100
67101# Update dotfiles using the generator-node
68- update-dotfiles : GENERATOR_COMPONENT = $(shell yq .generator.component suntory.yml)
69- update-dotfiles : GENERATOR_INPUTS_PROJECT_ID = $(shell yq .generator.inputs.project_id suntory.yml)
70- update-dotfiles : GENERATOR_INPUTS_PROJECT_NAME = $(shell yq .generator.inputs.project_name suntory.yml)
71- update-dotfiles : GENERATOR_INPUTS_PROJECT_DESC = $(shell yq .generator.inputs.project_desc suntory.yml)
72- update-dotfiles : GENERATOR_INPUTS_AUTHOR_NAME = $(shell yq .generator.inputs.author_name suntory.yml)
73- update-dotfiles : GENERATOR_INPUTS_AUTHOR_EMAIL = $(shell yq .generator.inputs.author_email suntory.yml)
74- update-dotfiles : GENERATOR_INPUTS_AUTHOR_URL = $(shell yq .generator.inputs.author_url suntory.yml)
75- update-dotfiles : GENERATOR_INPUTS_GITHUB_ID = $(shell yq .generator.inputs.github_id suntory.yml)
76- update-dotfiles : GENERATOR_INPUTS_GITHUB_REPO = $(shell yq .generator.inputs.github_repo suntory.yml)
77- update-dotfiles : GENERATOR_INPUTS_GITHUB_TOKEN_PREFIX = $(shell yq .generator.inputs.github_token_prefix suntory.yml)
102+ $(eval $(call set_generator_vars,update-dotfiles))
78103update-dotfiles : stage
79104 cd stage/ && \
80105 rm -rf generator-node/ && \
@@ -97,19 +122,10 @@ update-dotfiles: stage
97122 cp .gitignore ../../../../.gitignore && \
98123 cp eslint.config.js ../../../../eslint.config.js && \
99124 cp .rtk.json ../../../../.rtk.json
100- make -f Makefile-extras x-overwrite- dotfiles
125+ $( call run_hook,x-post-update- dotfiles)
101126
102127# Update partial snippets using the generator-node
103- update-partials : GENERATOR_COMPONENT = $(shell yq .generator.component suntory.yml)
104- update-partials : GENERATOR_INPUTS_PROJECT_ID = $(shell yq .generator.inputs.project_id suntory.yml)
105- update-partials : GENERATOR_INPUTS_PROJECT_NAME = $(shell yq .generator.inputs.project_name suntory.yml)
106- update-partials : GENERATOR_INPUTS_PROJECT_DESC = $(shell yq .generator.inputs.project_desc suntory.yml)
107- update-partials : GENERATOR_INPUTS_AUTHOR_NAME = $(shell yq .generator.inputs.author_name suntory.yml)
108- update-partials : GENERATOR_INPUTS_AUTHOR_EMAIL = $(shell yq .generator.inputs.author_email suntory.yml)
109- update-partials : GENERATOR_INPUTS_AUTHOR_URL = $(shell yq .generator.inputs.author_url suntory.yml)
110- update-partials : GENERATOR_INPUTS_GITHUB_ID = $(shell yq .generator.inputs.github_id suntory.yml)
111- update-partials : GENERATOR_INPUTS_GITHUB_REPO = $(shell yq .generator.inputs.github_repo suntory.yml)
112- update-partials : GENERATOR_INPUTS_GITHUB_TOKEN_PREFIX = $(shell yq .generator.inputs.github_token_prefix suntory.yml)
128+ $(eval $(call set_generator_vars,update-partials))
113129update-partials : stage
114130 cd stage/ && \
115131 rm -rf generator-node/ && \
@@ -204,4 +220,4 @@ doc: stage
204220
205221# ###############################################################
206222
207- .PHONY : all ci clean complexity configurations coverage deps deps-extra-apt deps-upgrade rmdeps doc export export export install install-wheel lint name package package publish reinstall release-major release-minor release-patch stage style test test-examples test-integration uninstall update-dotfiles update-partials update-to-latest update-to-latest update-to-main update-to-version
223+ .PHONY : $( 1 ) all ci clean complexity configurations coverage deps deps-extra-apt deps-upgrade rmdeps doc export export export install install-wheel lint name package package publish reinstall release-major release-minor release-patch stage style test test-examples test-integration uninstall update-dotfiles update-partials update-to-latest update-to-latest update-to-main update-to-version
0 commit comments