Compare commits

...

3 Commits

5 changed files with 67 additions and 15 deletions

View File

@ -23,8 +23,7 @@ concurrency:
cancel-in-progress: false
jobs:
# Build job
build:
prepare-for-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
@ -39,10 +38,33 @@ jobs:
with:
node-version: "16"
cache: "pnpm"
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install dependencies
run: pnpm install
build-webxdc:
runs-on: ubuntu-latest
needs: prepare-for-build
steps:
- name: Build
run: pnpm run build-webxdc
- name: Release
uses: softprops/action-gh-release@v1
with:
# prerelease: ${{ contains(github.event.ref, '-beta') }}
prerelease: true
fail_on_unmatched_files: true
files: dist/*.xdc
# Deploy to GitHub Pages.
deploy-gh-pages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: prepare-for-build
steps:
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build
env:
REPO_OWNER_AND_NAME: ${{ github.repository }}
@ -53,15 +75,6 @@ jobs:
uses: actions/upload-pages-artifact@v1
with:
path: ./dist
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1

27
create-xdc.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
case "$1" in
"-h" | "--help")
echo "usage: ${0##*/} [PACKAGE_NAME]"
exit
;;
"")
PACKAGE_NAME=${PWD##*/} # '##*/' removes everything before the last slash and the last slash
;;
*)
PACKAGE_NAME=${1%.xdc} # '%.xdc' removes the extension and allows PACKAGE_NAME to be given with or without extension
;;
esac
rm "$PACKAGE_NAME.xdc" 2> /dev/null
zip -9 --recurse-paths "$PACKAGE_NAME.xdc" --exclude LICENSE README.md webxdc.js webxdc.d.ts "./*.sh" "./*.xdc" -- *
echo "success, archive contents:"
unzip -l "$PACKAGE_NAME.xdc"
# check package size
MAXSIZE=655360
size=$(wc -c < "$PACKAGE_NAME.xdc")
if [ "$size" -ge $MAXSIZE ]; then
echo "WARNING: package size exceeded the limit ($size > $MAXSIZE)"
fi

7
generate-webxdc-manifest.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
echo -n 'name = "'
# Get the contents of the `<title>` element of `index.html`
grep -oP "(?<=<title>).*?(?=</title>)" index.html | tr -d '\n' \
&& echo '"' \
&& echo -n 'source_code_url = "https://github.com/WofWca/vikunja-frontend"'

View File

@ -27,6 +27,8 @@
"preview": "vite preview --port 4173",
"preview:dev": "vite preview --outDir dist-dev --mode development --port 4173",
"build": "vite build && workbox copyLibraries dist/",
"build-webxdc": "pnpm run build && pnpm run pack-webxdc",
"pack-webxdc": "./generate-webxdc-manifest.sh > dist/manifest.toml && cd dist && cp images/icons/icon-maskable.png icon.png && ../create-xdc.sh",
"build:modern-only": "BUILD_MODERN_ONLY=true vite build && workbox copyLibraries dist/",
"build:dev": "vite build --mode development --outDir dist-dev/",
"lint": "eslint --ignore-pattern '*.test.*' ./src --ext .vue,.js,.ts",

View File

@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import type { RouteLocation } from 'vue-router'
import {saveLastVisited} from '@/helpers/saveLastVisited'
@ -63,7 +63,10 @@ const EditTeamComponent = () => import('@/views/teams/EditTeam.vue')
const NewTeamComponent = () => import('@/views/teams/NewTeam.vue')
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
// Using `createWebHashHistory` instead of `createWebHistory` so it can
// properly work on GitHub pages and such.
// TODO_OFFLINE make it configurable, make MR to the upstream repo.
history: createWebHashHistory(import.meta.env.BASE_URL),
scrollBehavior(to, from, savedPosition) {
// If the user is using their forward/backward keys to navigate, we want to restore the scroll view
if (savedPosition) {