Rename examples cmd and add checks (#563)

* add checks for node and npm versions

* rename example cmd to examples
This commit is contained in:
Fabio Pliger
2022-07-04 13:21:17 -05:00
committed by GitHub
parent 9b3433f6ae
commit 91a09a09f7

View File

@@ -10,8 +10,25 @@ CONDA_EXE := conda
CONDA_ENV ?= ./env CONDA_ENV ?= ./env
env := $(CONDA_ENV) env := $(CONDA_ENV)
conda_run := $(CONDA_EXE) run -p $(env) conda_run := $(CONDA_EXE) run -p $(env)
GOOD_NODE_VER := 14
GOOD_NPM_VER := 6
NODE_VER := $(shell node -v | cut -d. -f1 | sed 's/^v\(.*\)/\1/')
NPM_VER := $(shell npm -v | cut -d. -f1)
GOOD_NODE := $(shell if [ $(NODE_VER) -ge $(GOOD_NODE_VER) ]; then echo true; else echo false; fi)
GOOD_NPM := $(shell if [ $(NPM_VER) -ge $(GOOD_NPM_VER) ]; then echo true; else echo false; fi)
.PHONY: check-node
check-node:
@echo Build requires Node $(GOOD_NODE_VER).x or higher: $(NODE_VER) detected && $(GOOD_NODE)
.PHONY: check-npm
check-npm:
@echo Build requires npm $(GOOD_NPM_VER).x or higher: $(NPM_VER) detected && $(GOOD_NPM)
setup: setup:
make check-node
make check-npm
npm install npm install
$(CONDA_EXE) env $(shell [ -d $(env) ] && echo update || echo create) -p $(env) --file environment.yml $(CONDA_EXE) env $(shell [ -d $(env) ] && echo update || echo create) -p $(env) --file environment.yml
$(conda_run) playwright install $(conda_run) playwright install
@@ -34,16 +51,15 @@ dev:
build: build:
npm run build npm run build
example: examples:
mkdir -p ./examples mkdir -p ./examples
cp -r ../examples/* ./examples cp -r ../examples/* ./examples
chmod -R 755 examples chmod -R 755 examples
find ./examples/toga -type f -name '*.html' -exec sed -i '' s+https://pyscript.net/alpha/+../build/+g {} \; find ./examples/toga -type f -name '*.html' -exec sed -i '' s+https://pyscript.net/alpha/+../build/+g {} \;
find ./examples/webgl -type f -name '*.html' -exec sed -i '' s+https://pyscript.net/alpha/+../../build/+g {} \; find ./examples/webgl -type f -name '*.html' -exec sed -i '' s+https://pyscript.net/alpha/+../../build/+g {} \;
find ./examples -type f -name '*.html' -exec sed -i '' s+https://pyscript.net/alpha/+./build/+g {} \; find ./examples -type f -name '*.html' -exec sed -i '' s+https://pyscript.net/alpha/+./build/+g {} \;
test: test:
make example make examples
npm run build npm run build
$(conda_run) pytest -vv $(ARGS) tests/ --log-cli-level=warning $(conda_run) pytest -vv $(ARGS) tests/ --log-cli-level=warning