add dev scripts.

This commit is contained in:
Miroslav Šedivý 2022-07-16 20:53:37 +02:00
parent 17be646493
commit ecbd2d3ca2
6 changed files with 106 additions and 0 deletions

20
dev/api-gen Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
OPENAPI_URL="https://raw.githubusercontent.com/demodesk/neko/master/openapi.yaml"
rm -rf "${PWD}/../src/component/api"
mkdir "${PWD}/../src/component/api"
docker run --rm \
--user "$(id -u):$(id -g)" \
-v "${PWD}/../src/component/api:/local/out" \
openapitools/openapi-generator-cli generate \
-i "$OPENAPI_URL" \
-g typescript-axios \
-o /local/out \
--additional-properties=enumPropertyNaming=original,modelPropertyNaming=original,withSeparateModelsAndApi=true,modelPackage=models,apiPackage=api
# Remove not needed git_push.sh
rm -f "${PWD}/../src/component/api/git_push.sh"
# Fix lint errors
./npm run lint -- --fix src/component/api

10
dev/build Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
cd "$(dirname "$0")"
# start component watch
docker run --rm -it \
--user "$(id -u):$(id -g)" \
--volume "${PWD}/../:/app" \
--entrypoint="npm" \
--workdir="/app" \
node:16-buster-slim run build

10
dev/exec Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
cd "$(dirname "$0")"
# start component watch
docker run --rm -it \
--user "$(id -u):$(id -g)" \
--volume "${PWD}/../:/app" \
--entrypoint="/bin/bash" \
--workdir="/app" \
node:16-buster-slim

10
dev/npm Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
cd "$(dirname "$0")"
# npm
docker run --rm -it \
--user "$(id -u):$(id -g)" \
--volume "${PWD}/../:/app" \
--entrypoint="npm" \
--workdir="/app" \
node:16-buster-slim "$@"

33
dev/serve Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
cd "$(dirname "$0")"
if [ -z $NEKO_PORT ]; then
NEKO_PORT="3000"
fi
if [ -z $NEKO_HOST ]; then
for i in $(ifconfig -l 2>/dev/null); do
NEKO_HOST=$(ipconfig getifaddr $i)
if [ ! -z $NEKO_HOST ]; then
break
fi
done
if [ -z $NEKO_HOST ]; then
NEKO_HOST=$(hostname -i 2>/dev/null)
fi
fi
echo "Using app port: ${NEKO_PORT}"
echo "Using IP address: ${NEKO_HOST}"
# npm run serve
docker run --rm -it \
-p 3001:8080 \
-e "NEKO_HOST=$NEKO_HOST" \
-e "NEKO_PORT=$NEKO_PORT" \
--user "$(id -u):$(id -g)" \
--volume "${PWD}/../:/app" \
--entrypoint="npm" \
--workdir="/app" \
node:16-buster-slim run serve

23
dev/version Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
cd "$(dirname "$0")"
if ! git diff-index --quiet HEAD
then
echo "Please clean git before publishing."
exit
fi
# bump npm version
VERSION=$(./npm version "${1-patch}" --no-git-tag-version)
if [ $? -ne 0 ]; then
echo "Npm version bump failed."
exit
fi
VERSION=$(echo "$VERSION" | head -1 | cut -c 2- | tr -d '\r')
echo "New version is: $VERSION"
git add ../package*
git commit -m "version ${VERSION}"
git tag -a "v${VERSION}" -m "version ${VERSION}"
git push origin "v${VERSION}"