Skip to content

Commit

Permalink
Merge pull request #17 from edx/george/samples-make-target
Browse files Browse the repository at this point in the history
Separate build and local preview of samples
  • Loading branch information
gsong authored Oct 13, 2017
2 parents 90ad82e + f406730 commit 516204d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
50 changes: 26 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,43 @@

.DEFAULT_GOAL := help

NPM_BIN = $(shell npm bin)

# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
help: ## display this help message
@echo "Please use \`make <target>' where <target> is one of"
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'

install: ## install requirements
npm install

clean: ## remove build artifacts
rm -rf css/
rm -rf samples/css/
rm -rf samples/edx-bootstrap/

samples: clean ## build the samples
mkdir samples/edx-bootstrap
cp -r sass/ samples/edx-bootstrap/sass
mkdir samples/css
mkdir samples/css/edx
mkdir samples/css/open-edx
./node_modules/node-sass/bin/node-sass samples/edx/sass --output samples/edx/css --include-path samples --include-path node_modules
./node_modules/node-sass/bin/node-sass samples/open-edx/sass --output samples/open-edx/css --include-path samples --include-path node_modules
./node_modules/.bin/opn samples/index.html

build: clean ## build the npm package

preview: samples ## build the preview site
aws s3 sync samples s3://${S3_PREVIEW_DOMAIN}/$(shell git rev-parse --abbrev-ref HEAD)
@echo Preview generated to http://${S3_PREVIEW_DOMAIN}/$(shell git rev-parse --abbrev-ref HEAD)
rm -rf {css,samples/{css,edx-bootstrap}}

build.samples: clean ## build the samples
$(eval $@_INCLUDE = --include-path samples --include-path node_modules)
mkdir -p samples/edx-bootstrap
mkdir -p samples/css/{edx,open-edx}
cp -R sass/ samples/edx-bootstrap/sass
$(NPM_BIN)/node-sass samples/edx/sass --output samples/edx/css $($@_INCLUDE)
$(NPM_BIN)/node-sass samples/open-edx/sass --output samples/open-edx/css $($@_INCLUDE)

samples: clean build.samples ## build and show the samples
$(NPM_BIN)/opn samples/index.html

preview: build.samples ## build the preview site
$(eval $@_REF = $(shell git rev-parse --abbrev-ref HEAD))
aws s3 sync samples s3://${S3_PREVIEW_DOMAIN}/$($@_REF)
@echo Preview generated to http://${S3_PREVIEW_DOMAIN}/$($@_REF)
$(NPM_BIN)/opn http://${S3_PREVIEW_DOMAIN}/$($@_REF)

quality:
./node_modules/stylelint/bin/stylelint.js sass/**/*.scss samples/**/*.scss
$(NPM_BIN)/stylelint sass/**/*.scss samples/**/*.scss

fix:
./node_modules/stylelint/bin/stylelint.js sass/**/*.scss samples/**/*.scss --fix
$(NPM_BIN)/stylelint sass/**/*.scss samples/**/*.scss --fix

test: clean quality ## run tests
test: clean quality build.samples ## run tests

xxx:
echo $(shell git rev-parse --abbrev-ref HEAD)
echo $$(git rev-parse --abbrev-ref HEAD)
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 516204d

Please sign in to comment.