Skip to content

Commit

Permalink
feat: YASSG compat (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi authored May 2, 2022
1 parent a854888 commit 05e5cfc
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 37 deletions.
35 changes: 35 additions & 0 deletions resources/YASSG/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ifndef APP_ROOT
$(error APP_ROOT must be defined before loading YASSG/common.mk)
endif

APP_PORT ?= 9988
BUILD_DIR ?= public
BUILD_OPTS ?=
BASE_URL ?= file://localhost${APP_ROOT}/${BUILD_DIR}

start/dev: dev ## Start app in "dev" mode
dev: clean
@make dev/assets dev/server -j2
dev/server: vendor index.php
symfony server:start --no-tls --document-root=. --port=${APP_PORT}
dev/assets: node_modules
node_modules/.bin/encore dev-server
index.php:
ln -s vendor/sigwin/yassg/web/index.php

build: ${BUILD_DIR}/assets/entrypoints.json vendor ## Build app for "prod" target
php vendor/sigwin/yassg/bin/yassg yassg:generate --env prod $(BASE_URL) ${BUILD_OPTS}
.PHONY: build

${BUILD_DIR}:
mkdir -p ${BUILD_DIR}
${BUILD_DIR}/assets/entrypoints.json: | ${BUILD_DIR} node_modules
BASE_URL=${BASE_URL} node_modules/.bin/encore production

clean:
rm -rf var/cache/* var/log/* ${BUILD_DIR}
.PHONY: clean
node_modules:
npm install
vendor:
composer install
24 changes: 24 additions & 0 deletions resources/YASSG/compat.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SIGWIN_INFRA_ROOT := $(dir $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))))
include ${SIGWIN_INFRA_ROOT}/PHP/library.mk
include ${SIGWIN_INFRA_ROOT}/YASSG/common.mk

ifndef LYCHEE_DOCKER_IMAGE
LYCHEE_DOCKER_IMAGE=lycheeverse/lychee:20220118134522908286
endif

ifndef LYCHEE_DOCKER_COMMAND
LYCHEE_DOCKER_COMMAND=docker run --init --interactive ${TTY} --rm --user "$(shell id -u):$(shell id -g)" --volume "$(shell pwd):/project:ro" --workdir /project ${LYCHEE_DOCKER_IMAGE}
endif

self/check: analyze/composer analyze/cs analyze/phpstan analyze/psalm check
ci/check: analyze/composer analyze/cs analyze/phpstan analyze/psalm lychee

check: hack
@make lychee

hack:
# TODO: hack until this can be done natively by the tool
php -r '$$u=rtrim(parse_url("${BASE_URL}",PHP_URL_PATH),"/");if($$u!==null&&$$u!==""&&$$u!=="/"){$$p=dirname("./${BUILD_DIR}".$$u);if(!file_exists($$p)){mkdir($$p,0755,true);}symlink(str_repeat("../",substr_count($$u,"/")-1)?:"./",$$p."/".basename($$u));}'

lychee:
sh -c "${LYCHEE_DOCKER_COMMAND} --offline --base ./public ./public"
39 changes: 2 additions & 37 deletions resources/YASSG/default.mk
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
ifndef APP_ROOT
$(error APP_ROOT must be defined before loading YASSG/default.mk)
endif
ifndef SIGWIN_INFRA_ROOT
SIGWIN_INFRA_ROOT := $(dir $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))))
endif
include ${SIGWIN_INFRA_ROOT}/Common/default.mk
APP_PORT ?= 9988
BUILD_DIR ?= public
BUILD_OPTS ?=
BASE_URL ?= file://localhost${APP_ROOT}/${BUILD_DIR}

start/dev: dev ## Start app in "dev" mode
dev: clean
@make dev/assets dev/server -j2
dev/server: vendor index.php
symfony server:start --no-tls --document-root=. --port=${APP_PORT}
dev/assets: node_modules
node_modules/.bin/encore dev-server
index.php:
ln -s vendor/sigwin/yassg/web/index.php

build: ${BUILD_DIR}/assets/entrypoints.json vendor ## Build app for "prod" target
php vendor/sigwin/yassg/bin/yassg yassg:generate --env prod $(BASE_URL) ${BUILD_OPTS}
.PHONY: build

${BUILD_DIR}:
mkdir -p ${BUILD_DIR}
${BUILD_DIR}/assets/entrypoints.json: | ${BUILD_DIR} node_modules
BASE_URL=${BASE_URL} node_modules/.bin/encore production

clean:
rm -rf var/cache/* var/log/* ${BUILD_DIR}
.PHONY: clean
node_modules:
npm install
vendor:
composer install
include ${SIGWIN_INFRA_ROOT}/PHP/library.mk
include ${SIGWIN_INFRA_ROOT}/YASSG/common.mk

0 comments on commit 05e5cfc

Please sign in to comment.