diff --git a/common.mk b/common.mk index 28e3ca4d3..9a96b5d8c 100644 --- a/common.mk +++ b/common.mk @@ -1,12 +1,42 @@ # This makefile is intended to be included by each package's makefile. The # paths are relative to the package directory. -ROOT := $(CURDIR)/.. +ROOT := $(dir $(lastword $(MAKEFILE_LIST))) SOURCES := $(wildcard src/*) VERSION := $(shell node -pe "require('./package.json').version") +DOC_DESTINATION := $(subst @fluent, ../html, $(PACKAGE)) export SHELL := /bin/bash -export PATH := $(CURDIR)/node_modules/.bin:$(ROOT)/node_modules/.bin:$(PATH) +ESLINT ?= $(ROOT)node_modules/.bin/eslint +TSC ?= $(ROOT)node_modules/.bin/tsc +NYC ?= $(ROOT)node_modules/.bin/nyc +MOCHA ?= $(ROOT)node_modules/.bin/mocha +ROLLUP ?= $(ROOT)node_modules/.bin/rollup +TYPEDOC ?= $(ROOT)node_modules/.bin/typedoc + +ROLLUP_CMD = $(ROLLUP) $(CURDIR)/esm/index.js \ + --banner "/* $(PACKAGE)@$(VERSION) */" \ + --amd.id $(PACKAGE) \ + --name $(GLOBAL) \ + --output.format umd \ + --output.file \ + $(NULL) + +TYPEDOC_CMD = $(TYPEDOC) src \ + --out $(DOC_DESTINATION) \ + --mode file \ + --excludeNotExported \ + --excludePrivate \ + --logger none \ + --hideGenerator \ + $(NULL) + +MOCHA_CMD =@$(NYC) --reporter=text --reporter=html $(MOCHA) \ + --recursive --ui tdd \ + --require esm \ + $(MOCHA_EXTRA_ARGS) \ + test/**/*_test.js \ + $(NULL) # Common maintenance tasks. .PHONY: clean lint test build html diff --git a/fluent-bundle/makefile b/fluent-bundle/makefile index 834d83239..bad475dad 100644 --- a/fluent-bundle/makefile +++ b/fluent-bundle/makefile @@ -4,50 +4,37 @@ GLOBAL := FluentBundle include ../common.mk lint: - @eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test test: esm/.compiled - @nyc --reporter=text --reporter=html mocha \ - --recursive --ui tdd \ - --require esm \ - test/**/*_test.js + @$(MOCHA_CMD) .PHONY: build build: index.js index.js: esm/.compiled - @rollup $(CURDIR)/esm/index.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.format umd \ - --output.file $@ + @$(ROLLUP_CMD) $@ @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/bundle \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: @rm -f esm/*.js esm/*.d.ts esm/.compiled @rm -f index.js + @rm -rf $(DOC_DESTINATION) @rm -rf .nyc_output coverage @echo -e " $(OK) clean" diff --git a/fluent-dedent/makefile b/fluent-dedent/makefile index 0c064efcf..f2ca8d13a 100644 --- a/fluent-dedent/makefile +++ b/fluent-dedent/makefile @@ -4,45 +4,31 @@ GLOBAL := FluentDedent include ../common.mk lint: - @eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test test: esm/.compiled - @nyc --reporter=text --reporter=html mocha \ - --recursive --ui tdd \ - --require esm \ - test/**/*_test.js + @$(MOCHA_CMD) .PHONY: build build: index.js index.js: esm/.compiled - @rollup $(CURDIR)/esm/index.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.format umd \ - --output.file $@ + @$(ROLLUP_CMD) $@ @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/dedent \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: diff --git a/fluent-dom/makefile b/fluent-dom/makefile index 7c10690db..8ab8150b6 100644 --- a/fluent-dom/makefile +++ b/fluent-dom/makefile @@ -5,31 +5,28 @@ DEPS := cached-iterable:CachedIterable include ../common.mk lint: - @eslint --config $(ROOT)/eslint_js.json --max-warnings 0 src/ - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_js.json --max-warnings 0 src/ + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test +test: MOCHA_EXTRA_ARGS=--require ./test/index test: esm/.compiled - @nyc --reporter=text --reporter=html mocha \ - --recursive --ui tdd \ - --require esm \ - --require ./test/index \ - test/**/*_test.js + @$(MOCHA_CMD) .PHONY: build build: index.js index.js: esm/.compiled - @rollup $(CURDIR)/esm/index.js \ + @$(ROLLUP) $(CURDIR)/esm/index.js \ --banner "/* $(PACKAGE)@$(VERSION) */" \ --amd.id $(PACKAGE) \ --name $(GLOBAL) \ @@ -39,17 +36,12 @@ index.js: esm/.compiled @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/dom \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: @rm -f esm/*.js esm/*.d.ts esm/.compiled @rm -f index.js + @rm -rf $(DOC_DESTINATION) @rm -rf .nyc_output coverage @echo -e " $(OK) clean" diff --git a/fluent-gecko/makefile b/fluent-gecko/makefile index de38c0234..2fd82423e 100644 --- a/fluent-gecko/makefile +++ b/fluent-gecko/makefile @@ -7,7 +7,7 @@ version = $(1)@$(shell node -e "\ console.log(require('../$(1)/package.json').version)") lint: - @eslint --config $(ROOT)/eslint_js.json --max-warnings 0 src/ + @$(ESLINT) --config $(ROOT)/eslint_js.json --max-warnings 0 src/ @echo -e " $(OK) lint" test: ; @@ -17,7 +17,7 @@ build: FluentSyntax.jsm fluent-react.js FluentSyntax.jsm: $(SOURCES) $(MAKE) -sC ../fluent-syntax compile - @rollup $(CURDIR)/src/fluent-syntax.js \ + @$(ROLLUP) $(CURDIR)/src/fluent-syntax.js \ --config ./xpcom_config.js \ --no-treeshake \ --no-freeze \ @@ -27,7 +27,7 @@ FluentSyntax.jsm: $(SOURCES) fluent-react.js: $(SOURCES) $(MAKE) -sC ../fluent-react compile - @rollup $(CURDIR)/src/fluent-react.js \ + @$(ROLLUP) $(CURDIR)/src/fluent-react.js \ --config ./vendor_config.js \ --output.intro "/* $(call version,fluent-react) */" \ --output.file ./dist/$@ diff --git a/fluent-langneg/makefile b/fluent-langneg/makefile index 48a044ab9..6846b5eb4 100644 --- a/fluent-langneg/makefile +++ b/fluent-langneg/makefile @@ -4,49 +4,36 @@ GLOBAL := FluentLangNeg include ../common.mk lint: - @eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test test: esm/.compiled - @nyc --reporter=text --reporter=html mocha \ - --recursive --ui tdd \ - --require esm \ - test/**/*_test.js + @$(MOCHA_CMD) .PHONY: build build: index.js index.js: $(SOURCES) - @rollup $(CURDIR)/esm/index.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.format umd \ - --output.file $@ + @$(ROLLUP_CMD) $@ @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/langneg \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: @rm -f esm/*.js esm/*.d.ts esm/.compiled @rm -f index.js + @rm -rf $(DOC_DESTINATION) @rm -rf .nyc_output coverage @echo -e " $(OK) clean" diff --git a/fluent-react/makefile b/fluent-react/makefile index 53c099bae..cd24bfdfd 100644 --- a/fluent-react/makefile +++ b/fluent-react/makefile @@ -1,30 +1,31 @@ PACKAGE := @fluent/react GLOBAL := FluentReact +JEST ?= node_modules/.bin/jest include ../common.mk lint: - @eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test test: esm/.compiled - @jest --collect-coverage + @$(JEST) --collect-coverage .PHONY: build build: index.js index.js: esm/.compiled - @rollup $(CURDIR)/esm/index.js \ + @$(ROLLUP) $(CURDIR)/esm/index.js \ --banner "/* $(PACKAGE)@$(VERSION) */" \ --amd.id $(PACKAGE) \ --name $(GLOBAL) \ @@ -34,17 +35,12 @@ index.js: esm/.compiled @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/react \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: @rm -f esm/*.js esm/*.d.ts esm/.compiled @rm -f index.js + @rm -rf $(DOC_DESTINATION) @rm -rf .nyc_output coverage @echo -e " $(OK) clean" diff --git a/fluent-sequence/makefile b/fluent-sequence/makefile index f3ab1795e..3380f67a8 100644 --- a/fluent-sequence/makefile +++ b/fluent-sequence/makefile @@ -4,49 +4,36 @@ GLOBAL := FluentSequence include ../common.mk lint: - @eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test test: esm/.compiled - @nyc --reporter=text --reporter=html mocha \ - --recursive --ui tdd \ - --require esm \ - test/**/*_test.js + @$(MOCHA_CMD) .PHONY: build build: index.js index.js: esm/.compiled - @rollup $(CURDIR)/esm/index.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.format umd \ - --output.file $@ + @$(ROLLUP_CMD) $@ @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/sequence \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: @rm -f esm/*.js esm/*.d.ts esm/.compiled @rm -f index.js + @rm -rf $(DOC_DESTINATION) @rm -rf .nyc_output coverage @echo -e " $(OK) clean" diff --git a/fluent-syntax/makefile b/fluent-syntax/makefile index adb8bc751..8a3c47ccd 100644 --- a/fluent-syntax/makefile +++ b/fluent-syntax/makefile @@ -4,50 +4,37 @@ GLOBAL := FluentSyntax include ../common.mk lint: - @eslint --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts - @eslint --config $(ROOT)/eslint_test.json --max-warnings 0 test/ + @$(ESLINT) --config $(ROOT)/eslint_ts.json --max-warnings 0 src/*.ts + @$(ESLINT) --config $(ROOT)/eslint_test.json --max-warnings 0 test/ @echo -e " $(OK) lint" .PHONY: compile compile: esm/.compiled esm/.compiled: $(SOURCES) - @tsc + @$(TSC) @touch $@ @echo -e " $(OK) esm/ compiled" .PHONY: test test: esm/.compiled - @nyc --reporter=text --reporter=html mocha \ - --recursive --ui tdd \ - --require esm \ - test/**/*_test.js + @$(MOCHA_CMD) .PHONY: build build: index.js index.js: esm/.compiled - @rollup $(CURDIR)/esm/index.js \ - --banner "/* $(PACKAGE)@$(VERSION) */" \ - --amd.id $(PACKAGE) \ - --name $(GLOBAL) \ - --output.format umd \ - --output.file $@ + @$(ROLLUP_CMD) $@ @echo -e " $(OK) $@ built" html: - @typedoc src \ - --out ../html/syntax \ - --mode file \ - --excludeNotExported \ - --excludePrivate \ - --logger none \ - --hideGenerator + @$(TYPEDOC_CMD) @echo -e " $(OK) html built" clean: @rm -f esm/*.js esm/*.d.ts esm/.compiled @rm -f index.js + @rm -rf $(DOC_DESTINATION) @rm -rf .nyc_output coverage @echo -e " $(OK) clean" diff --git a/makefile b/makefile index 16db2725e..527cd9be1 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ export SHELL := /bin/bash -export PATH := $(CURDIR)/node_modules/.bin:$(PATH) +GH_PAGES ?= $(CURDIR)/node_modules/.bin/gh-pages TARGETS := all dist lint test build html deps depsclean PACKAGES := $(wildcard fluent-*) @@ -14,7 +14,7 @@ $(PACKAGES): .PHONY: $(TARGETS) $(PACKAGES) deploy-html: - gh-pages -d html + $(GH_PAGES) -d html clean: $(PACKAGES) @echo