From d926e5ed06c5b32490fdb07b96f1bef64d554340 Mon Sep 17 00:00:00 2001 From: NuclearRedeye Date: Thu, 18 Mar 2021 15:40:57 +0000 Subject: [PATCH 1/5] feat: add initial makefile --- Makefile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..6cce85fd4 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ + +PROJECT := $(notdir $(CURDIR)) +NODE_VERSION ?= boron +PHP_VERSION ?= 7.3-fpm + +SOURCES = $(wildcard source/**/*) $(wildcard assets/**/*) + +.PHONY: start clean distclean test + +.DEFAULT_GOAL := start + +distclean: clean + @rm -rf node_modules + +clean: + @rm -rf public + +node_modules: package.json + docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) npm install + +public: node_modules $(SOURCES) + @mkdir -p $(CURDIR)/public + @cp -r ./core/styleguide $(CURDIR)/public/ + @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) ./node_modules/.bin/gulp + @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) php:$(PHP_VERSION) php ./core/builder.php -g + +start: public + @docker run -it --rm -p 8080:8080 -v $(CURDIR):/$(PROJECT):ro -w=/$(PROJECT)/public php:$(PHP_VERSION) php -S 0.0.0.0:8080 \ No newline at end of file From ad7b86f6e1df088e05ad1373a8fd1cb1835cccf1 Mon Sep 17 00:00:00 2001 From: NuclearRedeye Date: Thu, 18 Mar 2021 15:50:12 +0000 Subject: [PATCH 2/5] chore: update makefile with some comments --- Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6cce85fd4..8ae6d841e 100644 --- a/Makefile +++ b/Makefile @@ -3,26 +3,37 @@ PROJECT := $(notdir $(CURDIR)) NODE_VERSION ?= boron PHP_VERSION ?= 7.3-fpm -SOURCES = $(wildcard source/**/*) $(wildcard assets/**/*) +# Source files that when changed should trigger a rebuild. +SOURCES := $(wildcard source/**/*) $(wildcard assets/**/*) -.PHONY: start clean distclean test +# Targets that don't result in output of the same name. +.PHONY: start \ + clean \ + distclean \ + test +# When no target is specified, the default target to run. .DEFAULT_GOAL := start +# Cleans build output and local dependencies distclean: clean @rm -rf node_modules +# Cleans build output clean: @rm -rf public +# Install Node.js dependencies if either, the node_modules directory is not present or package.json has changed. node_modules: package.json docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) npm install +# Builds the patterns, and pattern-lab static site. public: node_modules $(SOURCES) @mkdir -p $(CURDIR)/public @cp -r ./core/styleguide $(CURDIR)/public/ @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) ./node_modules/.bin/gulp @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) php:$(PHP_VERSION) php ./core/builder.php -g +# Builds and runs the application on localhost:8080. start: public @docker run -it --rm -p 8080:8080 -v $(CURDIR):/$(PROJECT):ro -w=/$(PROJECT)/public php:$(PHP_VERSION) php -S 0.0.0.0:8080 \ No newline at end of file From 2903bc0b8db23b800b6b4fb604b3bc61c45b9a94 Mon Sep 17 00:00:00 2001 From: NuclearRedeye Date: Thu, 18 Mar 2021 16:14:04 +0000 Subject: [PATCH 3/5] fix: clean not deleting interim build files --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8ae6d841e..7b45d528f 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ NODE_VERSION ?= boron PHP_VERSION ?= 7.3-fpm # Source files that when changed should trigger a rebuild. -SOURCES := $(wildcard source/**/*) $(wildcard assets/**/*) +SOURCES := $(wildcard assets/**/*) $(wildcard source/**/*) # Targets that don't result in output of the same name. .PHONY: start \ @@ -21,7 +21,7 @@ distclean: clean # Cleans build output clean: - @rm -rf public + @rm -rf public source/assets # Install Node.js dependencies if either, the node_modules directory is not present or package.json has changed. node_modules: package.json From 04fc9ceb3435d92be6fbac7e2f9687a5cc3623d9 Mon Sep 17 00:00:00 2001 From: NuclearRedeye Date: Fri, 19 Mar 2021 15:19:21 +0000 Subject: [PATCH 4/5] chore: update to use php-cli and nginx --- Makefile | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7b45d528f..2b2bc8878 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ PROJECT := $(notdir $(CURDIR)) NODE_VERSION ?= boron -PHP_VERSION ?= 7.3-fpm +PHP_VERSION ?= 7.3-cli +COMPOSER_VERSION ?= 1.6.4 +PORT ?= 8080 # Source files that when changed should trigger a rebuild. SOURCES := $(wildcard assets/**/*) $(wildcard source/**/*) @@ -10,7 +12,8 @@ SOURCES := $(wildcard assets/**/*) $(wildcard source/**/*) .PHONY: start \ clean \ distclean \ - test + test \ + validate # When no target is specified, the default target to run. .DEFAULT_GOAL := start @@ -27,6 +30,10 @@ clean: node_modules: package.json docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) npm install +# Install PHP dependencies if, the vendor directory is not present or if composer.json or composer.lock have changed. +vendor: composer.json composer.lock + @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) composer:$(COMPOSER_VERSION) composer --no-interaction install --ignore-platform-reqs --classmap-authoritative --no-suggest --prefer-dist + # Builds the patterns, and pattern-lab static site. public: node_modules $(SOURCES) @mkdir -p $(CURDIR)/public @@ -34,6 +41,19 @@ public: node_modules $(SOURCES) @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) ./node_modules/.bin/gulp @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) php:$(PHP_VERSION) php ./core/builder.php -g +# Runs the unit test suite +unit: public + @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) node:$(NODE_VERSION) ./node_modules/.bin/gulp test:unit + +# Runs the schema validator +validate: vendor + @docker run -it --rm -v $(CURDIR):/$(PROJECT):rw -w=/$(PROJECT) php:$(PHP_VERSION) php bin/validate + # Builds and runs the application on localhost:8080. start: public - @docker run -it --rm -p 8080:8080 -v $(CURDIR):/$(PROJECT):ro -w=/$(PROJECT)/public php:$(PHP_VERSION) php -S 0.0.0.0:8080 \ No newline at end of file + @docker run --rm -d --name $(PROJECT) -p $(PORT):80 -v $(CURDIR)/public:/usr/share/nginx/html/:ro nginx:alpine + @echo "$(PROJECT) listening on 'http://localhost:$(PORT)'" + +# If running, stops the container. +stop: + @-docker stop $(PROJECT) From 08f58bb2791c7e290f373336b42c2e320f46c6dc Mon Sep 17 00:00:00 2001 From: NuclearRedeye Date: Sun, 21 Mar 2021 21:16:26 +0000 Subject: [PATCH 5/5] fix: spaces not tabs --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2b2bc8878..2700c863d 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,9 @@ SOURCES := $(wildcard assets/**/*) $(wildcard source/**/*) # Targets that don't result in output of the same name. .PHONY: start \ clean \ - distclean \ - test \ - validate + distclean \ + test \ + validate # When no target is specified, the default target to run. .DEFAULT_GOAL := start