summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2019-05-16 07:57:47 +0200
committerLauris BH <lauris@nix.lv>2019-05-16 08:57:47 +0300
commitd9dcd093403b3194bcf3b4be36eaf90250e06ed1 (patch)
treef2b18a690ae35773e7e6f06e3c312f3a2a9902ea /Makefile
parent775a5a5b0f4c1a7aa7b301569fe89d7c6e751c46 (diff)
downloadgitea-d9dcd093403b3194bcf3b4be36eaf90250e06ed1.tar.gz
gitea-d9dcd093403b3194bcf3b4be36eaf90250e06ed1.zip
add make targets for js and css, add js linter (#6952)
* add make targets for js,css, add javascript linter - add `make js`, deprecating `make javascripts` - add `make css`, deprecating `make generate-stylesheets` and `make stylesheets-check` - changed the unclean css check to only run on CI - add JS linting via eslint with basic configuration and fixed discovered issues - changed autoprefixer to use official `postcss-cli` avoiding the need to loop in the makefile - moved browserslist to package.json so other future tools can use it too. - update documentation for new make targets and added JS section * fix indentation * move functions used in html to 'exported' list * Run lessc binary without having to install anything to node_modules * use relative paths to node bin scripts, removing npx * Revert "use relative paths to node bin scripts, removing npx" This reverts commit 119b725525a8430b32ee7a6e6009b4ece544e39b. * fix lessc and postcss plugins * check for node_modules and use actual bin names
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile58
1 files changed, 40 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 2b77ce5dca..718836be65 100644
--- a/Makefile
+++ b/Makefile
@@ -365,33 +365,55 @@ release-compress:
fi
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
-.PHONY: javascripts
-javascripts: public/js/index.js
-
-.IGNORE: public/js/index.js
-public/js/index.js: $(JAVASCRIPTS)
- cat $< >| $@
-
-.PHONY: stylesheets-check
-stylesheets-check: generate-stylesheets
- @diff=$$(git diff public/css/*); \
- if [ -n "$$diff" ]; then \
- echo "Please run 'make generate-stylesheets' and commit the result:"; \
- echo "$${diff}"; \
+.PHONY: js
+js:
+ @if ([ ! -d "$(PWD)/node_modules" ]); then \
+ echo "node_modules directory is absent, please run 'npm install' first"; \
exit 1; \
fi;
+ @hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
+ echo "Please install npm version 5.2+"; \
+ exit 1; \
+ fi;
+ npx eslint public/js
-.PHONY: generate-stylesheets
-generate-stylesheets:
+.PHONY: css
+css:
+ @if ([ ! -d "$(PWD)/node_modules" ]); then \
+ echo "node_modules directory is absent, please run 'npm install' first"; \
+ exit 1; \
+ fi;
@hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
echo "Please install npm version 5.2+"; \
exit 1; \
fi;
- $(eval BROWSERS := "> 1%, last 2 firefox versions, last 2 safari versions, ie 11")
- npx lesshint public/less/
+
+ npx lesshint public/less/
npx lessc --clean-css="--s0 -b" public/less/index.less public/css/index.css
$(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),npx lessc --clean-css="--s0 -b" public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
- $(foreach file, $(wildcard public/css/*),npx postcss --use autoprefixer --autoprefixer.browsers $(BROWSERS) -o $(file) $(file);)
+ npx postcss --use autoprefixer --no-map --replace public/css/*
+
+ @diff=$$(git diff public/css/*); \
+ if ([ ! -z "$CI" ] && [ -n "$$diff" ]); then \
+ echo "Generated files in public/css have changed, please commit the result:"; \
+ echo "$${diff}"; \
+ exit 1; \
+ fi;
+
+.PHONY: javascripts
+javascripts:
+ echo "'make javascripts' is deprecated, please use 'make js'"
+ $(MAKE) js
+
+.PHONY: stylesheets-check
+stylesheets-check:
+ echo "'make stylesheets-check' is deprecated, please use 'make css'"
+ $(MAKE) css
+
+.PHONY: generate-stylesheets
+generate-stylesheets:
+ echo "'make generate-stylesheets' is deprecated, please use 'make css'"
+ $(MAKE) css
.PHONY: swagger-ui
swagger-ui: