Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementaiton #2

Merged
merged 10 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/bin
node_modules
/yalc.lock
/.yalc
/dist
/test-staging
/qa
63 changes: 63 additions & 0 deletions .sdlc-data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
projects:
workflows:
local:
node-build:
dependencies:
- '@liquid-labs/sdlc-resource-babel-and-rollup'
- '@liquid-labs/sdlc-resource-eslint'
- '@liquid-labs/sdlc-resource-jest'
artifacts:
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
priority: 0
path: Makefile
purpose: >-
Sets up standard target vars (like 'BUILD_TARGETS') and runs
scripts from 'make'.
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
priority: 10
path: make/10-locations.mk
purpose: Defines the most basic locations, like the source directory.
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
priority: 10
path: make/10-resources.mk
purpose: Locates tool executables and configuration files.
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
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/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
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/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
priority: 50
path: make/50-command-line-help-js.mk
purpose: Builds the 'dist/command-line-help.js' artifact.
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
priority: 55
path: make/55-lint.mk
purpose: Provides lint functionality with eslint.
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
priority: 55
path: make/55-test.mk
purpose: Provides test functionality with jest.
- builder: '@liquid-labs/sdlc-projects-workflow-local-node-build'
version: 1.0.0-alpha.5
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: {}
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

.DELETE_ON_ERROR:

SHELL:=bash

default: all

PHONY_TARGETS:=all default

BUILD_TARGETS:=

DOC_TARGETS:=

LINT_TARGETS:=

TEST_TARGETS:=

ifneq ($(wildcard make/*.mk),)
include make/*.mk
endif
10 changes: 10 additions & 0 deletions make/10-locations.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

SRC:=src
DIST:=dist
DOC:=doc
DOC_SRC:=src/doc
TEST_STAGING:=test-staging
QA:=qa
15 changes: 15 additions & 0 deletions make/10-resources.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

SDLC_BABEL:=npx babel
SDLC_BABEL_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-babel-and-rollup -- pwd)/dist/babel/babel.config.cjs

SDLC_ROLLUP:=npx rollup
SDLC_ROLLUP_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-babel-and-rollup -- pwd)/dist/rollup/rollup.config.mjs

SDLC_JEST:=npx jest
SDLC_JEST_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-jest -- pwd)/dist/jest.config.js

SDLC_ESLINT:=npx eslint
SDLC_ESLINT_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-eslint -- pwd)/dist/eslint.config.cjs
9 changes: 9 additions & 0 deletions make/15-data-finder.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

SDLC_DATA_SELECTOR=\( -path "*/test/data/*" -o -path "*/test/data-*/*" -o -path "*/test-data/*" \)

# all test data (cli and lib)
SDLC_TEST_DATA_SRC:=$(shell find $(SRC) -type f $(SDLC_DATA_SELECTOR))
SDLC_TEST_DATA_BUILT:=$(patsubst $(SRC)/%, $(TEST_STAGING)/%, $(SDLC_TEST_DATA_SRC))
11 changes: 11 additions & 0 deletions make/20-js-src-finder.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

SDLC_JS_SELECTOR=\( -name "*.js" -o -name "*.cjs" -o -name "*.mjs" \)
SDLC_TEST_SELECTOR=\( -name "*.test.*js" -o -path "*/test/*" \)

# all source, non-test files (cli and lib)
SDLC_ALL_JS_FILES_SRC:=$(shell find $(SRC) $(SDLC_JS_SELECTOR) -not $(SDLC_DATA_SELECTOR) -type f)
SDLC_ALL_NON_TEST_JS_FILES_SRC:=$(shell find $(SRC) $(SDLC_JS_SELECTOR) -not $(SDLC_DATA_SELECTOR) -not $(SDLC_TEST_SELECTOR) -type f)
SDLC_JS_TEST_FILES_BUILT:=$(patsubst %.cjs, %.js, $(patsubst %.mjs, %.js, $(patsubst $(SRC)/%, test-staging/%, $(SDLC_ALL_JS_FILES_SRC))))
20 changes: 20 additions & 0 deletions make/50-command-line-help-js.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

#####
# build dist/command-line-help.js
#####

SDLC_COMMAND_LINE_HELP_JS:=$(DIST)/command-line-help.js
SDLC_COMMAND_LINE_HELP_JS_ENTRY=$(SRC)/index.mjs
BUILD_TARGETS+=$(SDLC_COMMAND_LINE_HELP_JS)

$(SDLC_COMMAND_LINE_HELP_JS): package.json $(SDLC_ALL_NON_TEST_JS_FILES_SRC)
JS_BUILD_TARGET=$(SDLC_COMMAND_LINE_HELP_JS_ENTRY) \
JS_OUT=$@ \
$(SDLC_ROLLUP) --config $(SDLC_ROLLUP_CONFIG)

#####
# end dist/command-line-help.js
#####
33 changes: 33 additions & 0 deletions make/55-lint.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

#####
# lint rules
#####

SDLC_LINT_REPORT:=$(QA)/lint.txt
SDLC_LINT_PASS_MARKER:=$(QA)/.lint.passed
LINT_TARGETS+=$(SDLC_LINT_REPORT) $(SDLC_LINT_PASS_MARKER)
PRECIOUS_TARGETS+=$(SDLC_LINT_REPORT)

$(SDLC_LINT_REPORT) $(SDLC_LINT_PASS_MARKER): $(SDLC_ALL_JS_FILES_SRC)
mkdir -p $(dir $@)
echo -n 'Test git rev: ' > $(SDLC_LINT_REPORT)
git rev-parse HEAD >> $(SDLC_LINT_REPORT)
( set -e; set -o pipefail; \
ESLINT_USE_FLAT_CONFIG=true $(SDLC_ESLINT) \
--config $(SDLC_ESLINT_CONFIG) \
. \
| tee -a $(SDLC_LINT_REPORT); \
touch $(SDLC_LINT_PASS_MARKER) )

lint-fix:
@( set -e; set -o pipefail; \
ESLINT_USE_FLAT_CONFIG=true $(SDLC_ESLINT) \
--config $(SDLC_ESLINT_CONFIG) \
--fix . )

#####
# end lint
#####
55 changes: 55 additions & 0 deletions make/55-test.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

#####
# test rules
#####

SDLC_TEST_REPORT:=$(QA)/unit-test.txt
SDLC_TEST_PASS_MARKER:=$(QA)/.unit-test.passed
SDLC_COVERAGE_REPORTS:=$(QA)/coverage
TEST_TARGETS+=$(SDLC_TEST_REPORT) $(SDLC_TEST_PASS_MARKER) $(SDLC_COVERAGE_REPORTS)
PRECIOUS_TARGETS+=$(SDLC_TEST_REPORT)

SDLC_TEST_FILES_BUILT:=$(patsubst %.cjs, %.js, $(patsubst %.mjs, %.js, $(patsubst $(SRC)/%, $(TEST_STAGING)/%, $(SDLC_ALL_JS_FILES_SRC))))

$(SDLC_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?)
# We tried to ignore the data directories in the babel config, but as of 7.23.4, it didn't seem to work. This problem
# has been reported, though it claims to be fixed
$(SDLC_TEST_FILES_BUILT) &: $(SDLC_ALL_JS_FILES_SRC)
rm -rf $(TEST_STAGING)
mkdir -p $(TEST_STAGING)
NODE_ENV=test $(SDLC_BABEL) \
--config-file=$(SDLC_BABEL_CONFIG) \
--out-dir=./$(TEST_STAGING) \
--source-maps=inline \
--ignore='**/test/data/**' --ignore='**/test-data/**' \
$(SRC)

$(SDLC_TEST_PASS_MARKER) $(SDLC_TEST_REPORT) $(TEST_STAGING)/coverage &: package.json $(SDLC_TEST_FILES_BUILT) $(SDLC_TEST_DATA_BUILT)
rm -rf $@
mkdir -p $(dir $@)
echo -n 'Test git rev: ' > $(SDLC_TEST_REPORT)
git rev-parse HEAD >> $(SDLC_TEST_REPORT)
( set -e; set -o pipefail; \
( cd $(TEST_STAGING) && $(SDLC_JEST) \
--config=$(SDLC_JEST_CONFIG) \
--runInBand \
$(TEST) 2>&1 ) \
| tee -a $(SDLC_TEST_REPORT); \
touch $(SDLC_TEST_PASS_MARKER) )

$(SDLC_COVERAGE_REPORTS): $(SDLC_TEST_PASS_MARKER) $(TEST_STAGING)/coverage
rm -rf $(SDLC_COVERAGE_REPORTS)
mkdir -p $(SDLC_COVERAGE_REPORTS)
cp -r $(TEST_STAGING)/coverage/* $(SDLC_COVERAGE_REPORTS)

#####
# end test
#####
31 changes: 31 additions & 0 deletions make/95-final-targets.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file was generated by @liquid-labs/sdlc-projects-workflow-local-node-build.
# Refer to https://npmjs.com/package/@liquid-labs/sdlc-projects-workflow-local-
# node-build for further details

.PRECIOUS: $(PRECIOUS_TARGETS)

build: $(BUILD_TARGETS)

PHONY_TARGETS+=build

doc: $(DOC_TARGETS)

all: build doc

PHONY_TARGETS+=doc

lint: $(LINT_TARGETS)

lint-fix: $(LINT_FIX_TARGETS)

PHONY_TARGETS+=lint lint-fix

test: $(TEST_TARGETS)

PHONY_TARGETS+= test

qa: test lint

PHONY_TARGETS+=qa

.PHONY: $(PHONY_TARGETS)
Loading