-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from zanerock/work-liquid-labs/npm-toolkit/19
Update build and refactor 'update'
- Loading branch information
Showing
16 changed files
with
3,299 additions
and
1,990 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
workflows: | ||
local: | ||
node-project: | ||
dependencies: | ||
- '@liquid-labs/catalyst-resource-babel-and-rollup' | ||
- '@liquid-labs/catalyst-resource-eslint' | ||
- '@liquid-labs/catalyst-resource-jest' | ||
artifacts: | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 0 | ||
path: Makefile | ||
purpose: >- | ||
Sets up standard target vars (like 'BUILD_TARGETS') and runs scripts | ||
from 'make'. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 10 | ||
path: make/10-locations.mk | ||
purpose: Defines the most basic locations, like the source directory. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 10 | ||
path: make/10-resources.mk | ||
purpose: Locates tool executables and configuration files. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 15 | ||
path: make/15-data-finder.mk | ||
purpose: >- | ||
Sets up vars listing test data files which will need to be copied | ||
under the test staging dir. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 20 | ||
path: make/20-js-src-finder.mk | ||
purpose: >- | ||
Sets up vars listing JS files which will need to be tested and | ||
built. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 50 | ||
path: make/50-npm-toolkit-js.mk | ||
purpose: Builds the 'dist/npm-toolkit.js' artifact. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 55 | ||
path: make/55-lint.mk | ||
purpose: Provides lint functionality with eslint. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 55 | ||
path: make/55-test.mk | ||
purpose: Provides test functionality with jest. | ||
- builder: '@liquid-labs/catalyst-builder-workflow-local-make-node' | ||
version: 1.0.0-alpha.0 | ||
priority: 95 | ||
path: make/95-final-targets.mk | ||
purpose: >- | ||
Sets up the final basic targets (like 'build') based on the target | ||
vars (like 'BUILD_TARGETS'). | ||
config: | ||
noDevInstall: true | ||
noDoc: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,148 +1,23 @@ | ||
BUILD_KEY:=npm-toolkit | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
.DELETE_ON_ERROR: | ||
.PHONY: all build lint lint-fix qa test | ||
|
||
SHELL:=bash | ||
|
||
default: build | ||
|
||
DIST:=dist | ||
QA:=qa | ||
TEST_STAGING:=test-staging | ||
ifndef (SRC) | ||
SRC:=src | ||
endif | ||
|
||
.PRECIOUS: $(QA)/unit-test.txt $(QA)/lint.txt | ||
|
||
CATALYST_JS_BABEL:=npx babel | ||
CATALYST_JS_JEST:=npx jest | ||
CATALYST_JS_ROLLUP:=npx rollup | ||
CATALYST_JS_ESLINT:=npx eslint | ||
|
||
ifndef CATALYST_JS_LIB_SRC_PATH | ||
ifeq ($(SRC)/lib, $(shell ls -d $(SRC)/lib 2> /dev/null)) | ||
CATALYST_JS_LIB_SRC_PATH:=$(SRC)/lib | ||
else ifeq ($(SRC), $(shell ls -d $(SRC))) | ||
CATALYST_JS_LIB_SRC_PATH:=$(SRC) | ||
else | ||
ERROR:=$(error 'CATALYST_JS_LIB_SRC_PATH' is not set and cannot be resolved automatically.) | ||
endif | ||
endif | ||
|
||
ifeq ($(SRC)/cli, $(shell ls -d $(SRC)/cli 2> /dev/null)) | ||
CATALYST_JS_CLI_SRC_PATH:=$(SRC)/cli | ||
endif | ||
default: all | ||
|
||
# all source files (cli and lib) | ||
CATALYST_JS_ALL_FILES_SRC:=$(shell find $(SRC) \( -name "*.js" -o -name "*.mjs" -o -name "*.cjs" \)) | ||
CATALYST_JS_TEST_FILES_SRC:=$(shell find $(SRC) -name "*.js") | ||
CATALYST_JS_TEST_FILES_BUILT:=$(patsubst $(SRC)/%, test-staging/%, $(CATALYST_JS_TEST_FILES_SRC)) | ||
# all test data (cli and lib) | ||
CATALYST_JS_TEST_DATA_SRC:=$(shell find $(SRC) -path "*/test/data/*" -type f) | ||
CATALYST_JS_TEST_DATA_BUILT:=$(patsubst $(SRC)/%, $(TEST_STAGING)/%, $(CATALYST_JS_TEST_DATA_SRC)) | ||
# lib specific files | ||
CATALYST_JS_LIB_FILES_SRC:=$(shell find $(CATALYST_JS_LIB_SRC_PATH) \( -name "*.js" -o -name "*.mjs" -o -name "*.cjs" \) -not -path "*/test/*" -not -name "*.test.js") | ||
CATALYST_JS_LIB:=dist/$(BUILD_KEY).js | ||
# cli speciifc files | ||
ifdef CATALYST_JS_CLI_SRC_PATH | ||
CATALYST_JS_CLI_FILES_SRC:=$(shell find $(CATALYST_JS_CLI_SRC_PATH) \( -name "*.js" -o -name "*.mjs" -o -name "*.cjs" \) -not -path "*/test/*" -not -name "*.test.js") | ||
CATALYST_JS_CLI:=dist/$(BUILD_KEY)-cli.js | ||
endif | ||
PHONY_TARGETS:=all default | ||
|
||
BUILD_TARGETS:= | ||
|
||
# build rules | ||
BUILD_TARGETS+=$(CATALYST_JS_LIB) | ||
DOC_TARGETS:= | ||
|
||
INSTALL_BASE:=$(shell npm explore @liquid-labs/catalyst-scripts-node-project -- pwd) | ||
LINT_TARGETS:= | ||
|
||
$(CATALYST_JS_LIB): package.json $(CATALYST_JS_LIB_FILES_SRC) | ||
JS_BUILD_TARGET=$(CATALYST_JS_LIB_SRC_PATH)/index.js \ | ||
JS_OUT=$@ \ | ||
$(CATALYST_JS_ROLLUP) --config $(INSTALL_BASE)/dist/rollup/rollup.config.mjs | ||
TEST_TARGETS:= | ||
|
||
ifdef CATALYST_JS_CLI_SRC_PATH | ||
BUILD_TARGETS+=$(CATALYST_JS_CLI) | ||
|
||
# see DEVELOPER_NOTES.md 'CLI build' | ||
$(CATALYST_JS_CLI): package.json $(CATALYST_JS_ALL_FILES_SRC) | ||
JS_BUILD_TARGET=$(CATALYST_JS_CLI_SRC_PATH)/index.js \ | ||
JS_OUT=$@ \ | ||
JS_OUT_PREAMBLE='#!/usr/bin/env node' \ | ||
$(CATALYST_JS_ROLLUP) --config $(INSTALL_BASE)/dist/rollup/rollup.config.mjs | ||
chmod a+x $@ | ||
ifneq ($(wildcard make/*.mk),) | ||
include make/*.mk | ||
endif | ||
|
||
|
||
# test | ||
UNIT_TEST_REPORT:=$(QA)/unit-test.txt | ||
UNIT_TEST_PASS_MARKER:=$(QA)/.unit-test.passed | ||
|
||
$(CATALYST_JS_TEST_DATA_BUILT): test-staging/%: $(SRC)/% | ||
@echo "Copying test data..." | ||
@mkdir -p $(dir $@) | ||
@cp $< $@ | ||
|
||
# Jest is not picking up the external maps, so we inline them for the test. (As of?) | ||
$(CATALYST_JS_TEST_FILES_BUILT) &: $(CATALYST_JS_ALL_FILES_SRC) | ||
rm -rf $(TEST_STAGING) | ||
mkdir -p $(TEST_STAGING) | ||
NODE_ENV=test $(CATALYST_JS_BABEL) \ | ||
--config-file=$(INSTALL_BASE)/dist/babel/babel.config.cjs \ | ||
--out-dir=./$(TEST_STAGING) \ | ||
--source-maps=inline \ | ||
$(SRC) | ||
|
||
# Tried to use '--testPathPattern=$(TEST_STAGING)' awithout the 'cd $(TEST_STAGING)', but it seemed to have no effect' | ||
$(UNIT_TEST_PASS_MARKER) $(UNIT_TEST_REPORT): package.json $(CATALYST_JS_TEST_FILES_BUILT) $(CATALYST_JS_TEST_DATA_BUILT) | ||
@rm -f $@ | ||
@mkdir -p $(dir $@) | ||
@echo -n 'Test git rev: ' > $(UNIT_TEST_REPORT) | ||
@git rev-parse HEAD >> $(UNIT_TEST_REPORT) | ||
@( set -e; set -o pipefail; \ | ||
( cd $(TEST_STAGING) && $(CATALYST_JS_JEST) \ | ||
--config=$(INSTALL_BASE)/dist/jest/jest.config.js \ | ||
--runInBand 2>&1 ) \ | ||
| tee -a $(UNIT_TEST_REPORT)) | ||
@touch $@ | ||
|
||
TEST_TARGETS+=$(UNIT_TEST_PASS_MARKER) $(UNIT_TEST_REPORT) | ||
|
||
# lint rules | ||
LINT_REPORT:=$(QA)/lint.txt | ||
LINT_PASS_MARKER:=$(QA)/.lint.passed | ||
$(LINT_PASS_MARKER) $(LINT_REPORT): $(CATALYST_JS_LIB_ALL_FILES) | ||
@mkdir -p $(dir $@) | ||
@echo -n 'Test git rev: ' > $(LINT_REPORT) | ||
@git rev-parse HEAD >> $(LINT_REPORT) | ||
@( set -e; set -o pipefail; \ | ||
$(CATALYST_JS_ESLINT) \ | ||
--config $(INSTALL_BASE)/dist/eslint/eslint.config.js \ | ||
--ext .cjs,.js,.mjs,.cjs,.xjs \ | ||
--ignore-pattern '$(DIST)/**/*' \ | ||
--ignore-pattern '$(TEST_STAGING)/**/*' \ | ||
. \ | ||
| tee -a $(LINT_REPORT)) | ||
touch $@ | ||
|
||
LINT_TARGETS+=$(LINT_PASS_MARKER) $(LINT_REPORT) | ||
|
||
lint-fix: | ||
@( set -e; set -o pipefail; \ | ||
$(CATALYST_JS_ESLINT) \ | ||
--config $(INSTALL_BASE)/dist/eslint/eslint.config.js \ | ||
--ext .js,.mjs,.cjs,.xjs \ | ||
--ignore-pattern $(DIST)/**/* \ | ||
--ignore-pattern '$(TEST_STAGING)/**/*' \ | ||
--fix . ) | ||
|
||
|
||
build: $(BUILD_TARGETS) | ||
|
||
test: $(TEST_TARGETS) | ||
|
||
lint: $(LINT_TARGETS) | ||
|
||
qa: test lint | ||
|
||
all: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
SRC:=src | ||
DIST:=dist | ||
TEST_STAGING:=test-staging | ||
QA:=qa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
CATALYST_BABEL:=npx babel | ||
CATALYST_BABEL_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-babel-and-rollup -- pwd)/dist/babel/babel.config.cjs | ||
|
||
CATALYST_ROLLUP:=npx rollup | ||
CATALYST_ROLLUP_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-babel-and-rollup -- pwd)/dist/rollup/rollup.config.mjs | ||
|
||
CATALYST_JEST:=npx jest | ||
CATALYST_JEST_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-jest -- pwd)/dist/jest.config.js | ||
|
||
CATALYST_ESLINT:=npx eslint | ||
CATALYST_ESLINT_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-eslint -- pwd)/dist/eslint.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
CATALYST_DATA_SELECTOR=\( -path "*/test/data/*" -o -path "*/test/data-*/*" -o -path "*/test-data/*" \) | ||
|
||
# all test data (cli and lib) | ||
CATALYST_TEST_DATA_SRC:=$(shell find $(SRC) -type f $(CATALYST_DATA_SELECTOR)) | ||
CATALYST_TEST_DATA_BUILT:=$(patsubst $(SRC)/%, $(TEST_STAGING)/%, $(CATALYST_TEST_DATA_SRC)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
CATALYST_JS_SELECTOR=\( -name "*.js" -o -name "*.cjs" -o -name "*.mjs" \) | ||
CATALYST_TEST_SELECTOR=\( -name "*.test.*js" -o -path "*/test/*" \) | ||
|
||
# all source, non-test files (cli and lib) | ||
CATALYST_ALL_JS_FILES_SRC:=$(shell find $(SRC) $(CATALYST_JS_SELECTOR) -not $(CATALYST_DATA_SELECTOR) -type f) | ||
CATALYST_ALL_NON_TEST_JS_FILES_SRC:=$(shell find $(SRC) $(CATALYST_JS_SELECTOR) -not $(CATALYST_DATA_SELECTOR) -not $(CATALYST_TEST_SELECTOR) -type f) | ||
CATALYST_JS_TEST_FILES_BUILT:=$(patsubst %.cjs, %.js, $(patsubst %.mjs, %.js, $(patsubst $(SRC)/%, test-staging/%, $(CATALYST_ALL_JS_FILES_SRC)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
##### | ||
# build dist/npm-toolkit.js | ||
##### | ||
|
||
CATALYST_NPM_TOOLKIT_JS:=$(DIST)/npm-toolkit.js | ||
CATALYST_NPM_TOOLKIT_JS_ENTRY=$(SRC)/index.js | ||
BUILD_TARGETS+=$(CATALYST_NPM_TOOLKIT_JS) | ||
|
||
$(CATALYST_NPM_TOOLKIT_JS): package.json $(CATALYST_ALL_NON_TEST_JS_FILES_SRC) | ||
JS_BUILD_TARGET=$(CATALYST_NPM_TOOLKIT_JS_ENTRY) \ | ||
JS_OUT=$@ \ | ||
$(CATALYST_ROLLUP) --config $(CATALYST_ROLLUP_CONFIG) | ||
|
||
##### | ||
# end dist/npm-toolkit.js | ||
##### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
##### | ||
# lint rules | ||
##### | ||
|
||
CATALYST_LINT_REPORT:=$(QA)/lint.txt | ||
CATALYST_LINT_PASS_MARKER:=$(QA)/.lint.passed | ||
LINT_TARGETS+=$(CATALYST_LINT_REPORT) $(CATALYST_LINT_PASS_MARKER) | ||
PRECIOUS_TARGETS+=$(CATALYST_LINT_REPORT) | ||
|
||
LINT_IGNORE_PATTERNS:=--ignore-pattern '$(DIST)/**/*'\ | ||
--ignore-pattern '$(TEST_STAGING)/**/*' | ||
|
||
$(CATALYST_LINT_REPORT) $(CATALYST_LINT_PASS_MARKER): $(CATALYST_ALL_JS_FILES_SRC) | ||
mkdir -p $(dir $@) | ||
echo -n 'Test git rev: ' > $(CATALYST_LINT_REPORT) | ||
git rev-parse HEAD >> $(CATALYST_LINT_REPORT) | ||
( set -e; set -o pipefail; \ | ||
$(CATALYST_ESLINT) \ | ||
--config $(CATALYST_ESLINT_CONFIG) \ | ||
--ext .cjs,.js,.mjs,.cjs,.xjs \ | ||
$(LINT_IGNORE_PATTERNS) \ | ||
. \ | ||
| tee -a $(CATALYST_LINT_REPORT); \ | ||
touch $(CATALYST_LINT_PASS_MARKER) ) | ||
|
||
lint-fix: | ||
@( set -e; set -o pipefail; \ | ||
$(CATALYST_ESLINT) \ | ||
--config $(CATALYST_ESLINT_CONFIG) \ | ||
--ext .js,.mjs,.cjs,.xjs \ | ||
$(LINT_IGNORE_PATTERNS) \ | ||
--fix . ) | ||
|
||
##### | ||
# end lint | ||
##### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This file was generated by @liquid-labs/catalyst-builder-workflow-local-make- | ||
# node. Refer to https://npmjs.com/package/@liquid-labs/catalyst-builder-workflow- | ||
# local-make-node for further details | ||
|
||
##### | ||
# test rules | ||
##### | ||
|
||
CATALYST_TEST_REPORT:=$(QA)/unit-test.txt | ||
CATALYST_TEST_PASS_MARKER:=$(QA)/.unit-test.passed | ||
CATALYST_COVERAGE_REPORTS:=$(QA)/coverage | ||
TEST_TARGETS+=$(CATALYST_TEST_REPORT) $(CATALYST_TEST_PASS_MARKER) $(CATALYST_COVERAGE_REPORTS) | ||
PRECIOUS_TARGETS+=$(CATALYST_TEST_REPORT) | ||
|
||
CATALYST_TEST_FILES_BUILT:=$(patsubst %.cjs, %.js, $(patsubst %.mjs, %.js, $(patsubst $(SRC)/%, $(TEST_STAGING)/%, $(CATALYST_ALL_JS_FILES_SRC)))) | ||
|
||
$(CATALYST_TEST_DATA_BUILT): $(TEST_STAGING)/%: $(SRC)/% | ||
@echo "Copying test data..." | ||
@mkdir -p $(dir $@) | ||
@cp $< $@ | ||
|
||
# Jest is not picking up the external maps, so we inline them for the test. (As of?) | ||
$(CATALYST_TEST_FILES_BUILT) &: $(CATALYST_ALL_JS_FILES_SRC) | ||
rm -rf $(TEST_STAGING) | ||
mkdir -p $(TEST_STAGING) | ||
NODE_ENV=test $(CATALYST_BABEL) \ | ||
--config-file=$(CATALYST_BABEL_CONFIG) \ | ||
--out-dir=./$(TEST_STAGING) \ | ||
--source-maps=inline \ | ||
$(SRC) | ||
|
||
$(CATALYST_TEST_PASS_MARKER) $(CATALYST_TEST_REPORT) $(TEST_STAGING)/coverage &: package.json $(CATALYST_TEST_FILES_BUILT) $(CATALYST_TEST_DATA_BUILT) | ||
rm -rf $@ | ||
mkdir -p $(dir $@) | ||
echo -n 'Test git rev: ' > $(CATALYST_TEST_REPORT) | ||
git rev-parse HEAD >> $(CATALYST_TEST_REPORT) | ||
( set -e; set -o pipefail; \ | ||
( cd $(TEST_STAGING) && $(CATALYST_JEST) \ | ||
--config=$(CATALYST_JEST_CONFIG) \ | ||
--runInBand \ | ||
$(TEST) 2>&1 ) \ | ||
| tee -a $(CATALYST_TEST_REPORT); \ | ||
touch $(CATALYST_TEST_PASS_MARKER) ) | ||
|
||
$(CATALYST_COVERAGE_REPORTS): $(CATALYST_TEST_PASS_MARKER) $(TEST_STAGING)/coverage | ||
rm -rf $(CATALYST_COVERAGE_REPORTS) | ||
mkdir -p $(CATALYST_COVERAGE_REPORTS) | ||
cp -r $(TEST_STAGING)/coverage/* $(CATALYST_COVERAGE_REPORTS) | ||
|
||
##### | ||
# end test | ||
##### |
Oops, something went wrong.