Skip to content

Instantly share code, notes, and snippets.

@bnnk
Last active April 29, 2023 07:06
Show Gist options
  • Save bnnk/67f127e23e6e6b559990b12d25451d37 to your computer and use it in GitHub Desktop.
Save bnnk/67f127e23e6e6b559990b12d25451d37 to your computer and use it in GitHub Desktop.
Script Bin
#! /bin/bash -xe
CREATE_VERB="npm init"
INSTALL_VERB="npm install"
if [ "$(command -v yarn)" ]; then
CREATE_VERB="yarn create"
INSTALL_VERB="yarn add"
fi
pause(){
read -n1 -r -p "Press any key to continue . . ." key;
echo;
}
create_boot_file(){
TEMP="$(mktemp).js"
LINE=$(grep -n "boot: \[" quasar.config.js | cut -d ":" -f 1);
./node_modules/.bin/quasar new boot $1
sed "$[LINE + 1] i '$1'," quasar.config.js > $TEMP
cp $TEMP quasar.config.js
yarn eslint --fix .
}
clear;
echo -e "\u001b[38;5;202mWelcome to Quasar Setup! (Git+)\u001b[0m";
echo -e "\u001b[38;5;220mThis setup will quickly set up Quasar and";
trap "" SIGINT
echo "install Dicebear for avatars, Lodash for ";
echo "utilities, Zod for schemas and TanStack ";
echo "Query for data fetching and VueAuth for ";
echo "Authentication. ";
echo -e "\u001b[38;5;196mWARNING! This script will erase every files in:";
echo $PWD;
echo "Also, type '.' in Project Folder so that the script works."
pause; $CREATE_VERB quasar;
clear; echo -e "\u001b[0m"
trap "git init; exit" SIGINT
$INSTALL_VERB @tanstack/vue-query @dicebear/core @dicebear/collection \
zod lodash urijs validator vee-validate @vueuse/core \
@vueuse/integrations @vueuse/router
$INSTALL_VERB @quasar/cli --dev
create_boot_file tanstack-vue-query
if [ -f "$PWD/src/router/index.ts" ]; then
printf '%b' '\u001b[38;5;32mCreating TypeScript boot file for: @tanstack/vue-query\n'
TS_CREATE=1
tee src/boot/tanstack-vue-query.ts > /dev/null <<EOF
import { boot } from 'quasar/wrappers'
import { VueQueryPlugin } from "@tanstack/vue-query";
export default boot(async ({ app }: { app: App<HTMLDivElement> }) => {
app.use(VueQueryPlugin)
})
EOF
printf '%b' '\u001b[38;5;32mCreating JavaScript boot file for: VeeValidate\n'
tee src/boot/form-veevalidate.ts > /dev/null <<EOF
import { boot } from 'quasar/wrappers'
import { VueQueryPlugin } from "@tanstack/vue-query";
import { Form, Field } from "vee-validate";
declare module '@vue/runtime-core' {
export interface GlobalComponents {
VeeForm: typeof Form,
VeeField: typeof Field
}
}
export default boot(async ({ app }: { app: App<HTMLDivElement> }) => {
app.component("VeeForm", Form);
app.component("VeeField", Field);
})
EOF
fi
if [[ ! "$TS_CREATE" == 1 ]]; then
printf '%b' '\u001b[38;5;32mCreating JavaScript boot file for: @tanstack/vue-query\n'
tee src/boot/tanstack-vue-query.js > /dev/null <<EOF
import { boot } from 'quasar/wrappers'
import { VueQueryPlugin } from "@tanstack/vue-query";
export default boot(async ({ app }) => {
app.use(VueQueryPlugin)
})
EOF
printf '%b' '\u001b[38;5;32mCreating JavaScript boot file for: VeeValidate\n'
tee src/boot/tanstack-vue-query.js > /dev/null <<EOF
import { boot } from 'quasar/wrappers'
import { Form, Field } from "vee-validate";
export default boot(async ({ app }: { app: App<HTMLDivElement> }) => {
app.component("VeeForm", Form);
app.component("VeeField", Field);
})
EOF
printf '%b' '\u001b[0m'
fi
quasar ext add @vueauth/auth
rm .gitignore
printf '%b' '\u001b[38;5;32mCreating .gitignore and .dockerignore . . .\n'
yarn create gitignore node
tee -a .gitignore > /dev/null <<EOF
# Quasar core related directories
.quasar
/dist
# Cordova related directories and files
/src-cordova/node_modules
/src-cordova/platforms
/src-cordova/plugins
/src-cordova/www
# Capacitor related directories and files
/src-capacitor/www
/src-capacitor/node_modules
# BEX related directories and files
/src-bex/www
/src-bex/js/core
EOF
cat .gitignore > .dockerignore
git init
pause; printf '%b' '\u001b[0m\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment