Skip to content

Commit

Permalink
Update Makefile, use pnpm as nodejs package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed Jun 17, 2024
1 parent 5393e8b commit 205e1f6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/dist/
/docs/html/
/node_modules/
/package-lock.json
/pnpm-lock.yaml
/requirements-mxdev.txt
/treibstoff-*.tgz
/venv/
130 changes: 55 additions & 75 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#: core.packages
#: docs.jsdoc
#: docs.sphinx
#: js.npm
#: js.nodejs
#: js.rollup
#: js.wtr
#: system.dependencies
#
# SETTINGS (ALL CHANGES MADE BELOW SETTINGS WILL BE LOST)
##############################################################################
Expand Down Expand Up @@ -46,38 +45,37 @@ INCLUDE_MAKEFILE?=include.mk
# No default value.
EXTRA_PATH?=

## js.npm
## js.nodejs

# Value for `--prefix` option.
# The package manager to use. Defaults to `npm`. Possible values
# are `npm` and `pnpm`
# Default: npm
NODEJS_PACKAGE_MANAGER?=pnpm

# Value for `--prefix` option when installing packages.
# Default: .
NPM_PREFIX?=.
NODEJS_PREFIX?=.

# Packages which get installed with `--no-save` option.
# Packages to install with `--no-save` option.
# No default value.
NPM_PACKAGES?=
NODEJS_PACKAGES?=

# Packages which get installed with `--save-dev` option.
# Packages to install with `--save-dev` option.
# No default value.
NPM_DEV_PACKAGES?=
NODEJS_DEV_PACKAGES?=

# Packages which get installed with `--save-prod` option.
# Packages to install with `--save-prod` option.
# No default value.
NPM_PROD_PACKAGES?=
NODEJS_PROD_PACKAGES?=

# Packages which get installed with `--save-optional` option.
# Packages to install with `--save-optional` option.
# No default value.
NPM_OPT_PACKAGES?=
NODEJS_OPT_PACKAGES?=

# Additional install options. Possible values are `--save-exact`
# and `--save-bundle`.
# No default value.
NPM_INSTALL_OPTS?=

## system.dependencies

# Space separated system package names.
# No default value.
SYSTEM_DEPENDENCIES?=
NODEJS_INSTALL_OPTS?=

## js.wtr

Expand Down Expand Up @@ -206,103 +204,85 @@ $(SENTINEL): $(firstword $(MAKEFILE_LIST))
@echo "Sentinels for the Makefile process." > $(SENTINEL)

##############################################################################
# npm
# nodejs
##############################################################################

export PATH:=$(shell pwd)/$(NPM_PREFIX)/node_modules/.bin:$(PATH)
export PATH:=$(shell pwd)/$(NODEJS_PREFIX)/node_modules/.bin:$(PATH)

# case `system.dependencies` domain is included
SYSTEM_DEPENDENCIES+=npm

NPM_TARGET:=$(SENTINEL_FOLDER)/npm.sentinel
$(NPM_TARGET): $(SENTINEL)
@echo "Install npm packages"
@test -z "$(NPM_DEV_PACKAGES)" \
NODEJS_TARGET:=$(SENTINEL_FOLDER)/nodejs.sentinel
$(NODEJS_TARGET): $(SENTINEL)
@echo "Install nodejs packages"
@test -z "$(NODEJS_DEV_PACKAGES)" \
&& echo "No dev packages to be installed" \
|| npm --prefix $(NPM_PREFIX) install \
|| $(NODEJS_PACKAGE_MANAGER) --prefix $(NODEJS_PREFIX) install \
--save-dev \
$(NPM_INSTALL_OPTS) \
$(NPM_DEV_PACKAGES)
@test -z "$(NPM_PROD_PACKAGES)" \
$(NODEJS_INSTALL_OPTS) \
$(NODEJS_DEV_PACKAGES)
@test -z "$(NODEJS_PROD_PACKAGES)" \
&& echo "No prod packages to be installed" \
|| npm --prefix $(NPM_PREFIX) install \
|| $(NODEJS_PACKAGE_MANAGER) --prefix $(NODEJS_PREFIX) install \
--save-prod \
$(NPM_INSTALL_OPTS) \
$(NPM_PROD_PACKAGES)
@test -z "$(NPM_OPT_PACKAGES)" \
$(NODEJS_INSTALL_OPTS) \
$(NODEJS_PROD_PACKAGES)
@test -z "$(NODEJS_OPT_PACKAGES)" \
&& echo "No opt packages to be installed" \
|| npm --prefix $(NPM_PREFIX) install \
|| $(NODEJS_PACKAGE_MANAGER) --prefix $(NODEJS_PREFIX) install \
--save-optional \
$(NPM_INSTALL_OPTS) \
$(NPM_OPT_PACKAGES)
@test -z "$(NPM_PACKAGES)" \
$(NODEJS_INSTALL_OPTS) \
$(NODEJS_OPT_PACKAGES)
@test -z "$(NODEJS_PACKAGES)" \
&& echo "No packages to be installed" \
|| npm --prefix $(NPM_PREFIX) install \
|| $(NODEJS_PACKAGE_MANAGER) --prefix $(NODEJS_PREFIX) install \
--no-save \
$(NPM_PACKAGES)
@touch $(NPM_TARGET)
$(NODEJS_PACKAGES)
@touch $(NODEJS_TARGET)

.PHONY: npm
npm: $(NPM_TARGET)
.PHONY: nodejs
nodejs: $(NODEJS_TARGET)

.PHONY: npm-dirty
npm-dirty:
@rm -f $(NPM_TARGET)
.PHONY: nodejs-dirty
nodejs-dirty:
@rm -f $(NODEJS_TARGET)

.PHONY: npm-clean
npm-clean: npm-dirty
@rm -rf $(NPM_PREFIX)/node_modules
.PHONY: nodejs-clean
nodejs-clean: nodejs-dirty
@rm -rf $(NODEJS_PREFIX)/node_modules

INSTALL_TARGETS+=npm
DIRTY_TARGETS+=npm-dirty
CLEAN_TARGETS+=npm-clean

##############################################################################
# system dependencies
##############################################################################

.PHONY: system-dependencies
system-dependencies:
@echo "Install system dependencies"
@test -z "$(SYSTEM_DEPENDENCIES)" && echo "No System dependencies defined"
@test -z "$(SYSTEM_DEPENDENCIES)" \
|| sudo apt-get install -y $(SYSTEM_DEPENDENCIES)
INSTALL_TARGETS+=nodejs
DIRTY_TARGETS+=nodejs-dirty
CLEAN_TARGETS+=nodejs-clean

##############################################################################
# web test runner
##############################################################################

# extend npm dev packages
NPM_DEV_PACKAGES+=\
NODEJS_DEV_PACKAGES+=\
@web/test-runner \
@web/dev-server-import-maps

.PHONY: wtr
wtr: $(NPM_TARGET)
wtr: $(NODEJS_TARGET)
@web-test-runner $(WTR_OPTIONS) --config $(WTR_CONFIG)

##############################################################################
# rollup
##############################################################################

# extend npm dev packages
NPM_DEV_PACKAGES+=\
NODEJS_DEV_PACKAGES+=\
rollup \
rollup-plugin-cleanup \
@rollup/plugin-terser

.PHONY: rollup
rollup: $(NPM_TARGET)
rollup: $(NODEJS_TARGET)
@rollup --config $(ROLLUP_CONFIG)

##############################################################################
# jsdoc
##############################################################################

# extend npm dev packages
NPM_DEV_PACKAGES+=jsdoc

# extend sphinx requirements and docs targets
NODEJS_DEV_PACKAGES+=jsdoc
DOCS_REQUIREMENTS+=sphinx_js

##############################################################################
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"@rollup/plugin-terser": "^0.4.4",
"@web/dev-server-import-maps": "^0.2.1",
"@web/test-runner": "^0.18.2",
"@web/test-runner-core": "^0.13.2",
"install": "^0.13.0",
"jquery": "^4.0.0-beta",
"jsdoc": "^3.6.11",
"qunit": "^2.20.1",
"rollup": "^2.79.1",
"rollup-plugin-cleanup": "^3.2.1",
"web-test-runner-qunit": "^2.0.0"
}
},
"packageManager": "[email protected]+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631"
}

0 comments on commit 205e1f6

Please sign in to comment.