Skip to content

Commit

Permalink
Vite-based Vue temaplates (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpota authored Jun 3, 2023
1 parent 7aeb9df commit c0be24e
Show file tree
Hide file tree
Showing 22 changed files with 177 additions and 226 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build
on: [push, pull_request]
on: [push]
jobs:

test:
Expand All @@ -9,7 +9,7 @@ jobs:
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
id: go
- name: Check out
uses: actions/checkout@v2
Expand All @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [ 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18 ]
go: [ 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v1
Expand Down
29 changes: 24 additions & 5 deletions .github/workflows/verify-templates.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: verify-templates
on:
push:
pull_request:
schedule:
- cron: '0 14 * * *'
jobs:
Expand All @@ -18,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18
go-version: 1.20
- name: Checkout project
uses: actions/checkout@v2
- name: Generate application
Expand All @@ -29,8 +28,28 @@ jobs:
run: timeout 60 bash -c 'until curl -s localhost:8080/api/technologies | grep Go > /dev/null; do sleep 1; done'
- name: Check availability of frontend
run: |
npm i domcurl
timeout 60 bash -c 'until ./node_modules/domcurl/index.js http://localhost:8080 | grep Go > /dev/null; do sleep 1; done'
npm i puppeteer
cat > index.js << EOF
const puppeteer = require('puppeteer');
(async () => {
try {
const browser = await puppeteer.launch({headless: "new"});
const page = await browser.newPage();
await page.goto('http://localhost:8080');
page.on('console', (message) => {
console.log('Console ' + message.type().toUpperCase() + ': ' + message.text());
});
await page.waitForSelector('.technologies', { timeout: 60000 });
const content = await page.content();
console.log(content);
await browser.close();
} catch (error) {
console.error('Error:', error);
throw error;
}
})();
EOF
node index.js
- name: Stop application
run: cd app && docker-compose down
if: always()
if: always()
189 changes: 78 additions & 111 deletions static/generated.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/angular.webapp/src/app/tech/tech.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul>
<ul class="technologies">
<li *ngFor="let tech of technologies">
<b>{{tech.name}}</b>: {{tech.details}}
</li>
Expand Down
2 changes: 1 addition & 1 deletion templates/mongo.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16.18.1-alpine3.16 AS JS_BUILD
COPY webapp /webapp
WORKDIR webapp
WORKDIR /webapp
RUN npm install && npm run build

FROM golang:1.19.0-alpine3.16 AS GO_BUILD
Expand Down
2 changes: 1 addition & 1 deletion templates/mysql.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16.18.1-alpine3.16 AS JS_BUILD
COPY webapp /webapp
WORKDIR webapp
WORKDIR /webapp
RUN npm install && npm run build

FROM golang:1.19.0-alpine3.16 AS GO_BUILD
Expand Down
2 changes: 1 addition & 1 deletion templates/postgres.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16.18.1-alpine3.16 AS JS_BUILD
COPY webapp /webapp
WORKDIR webapp
WORKDIR /webapp
RUN npm install && npm run build

FROM golang:1.19.0-alpine3.16 AS GO_BUILD
Expand Down
2 changes: 0 additions & 2 deletions templates/vue.webapp/.env.development

This file was deleted.

2 changes: 2 additions & 0 deletions templates/vue.webapp/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NODE_ENV=local
VITE_API_URL=http://localhost:8080
3 changes: 1 addition & 2 deletions templates/vue.webapp/.env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
NODE_ENV=production
VUE_APP_API_URL=
VITE_API_URL=
11 changes: 11 additions & 0 deletions templates/vue.webapp/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env node */
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended'
],
parserOptions: {
ecmaVersion: 'latest'
}
}
3 changes: 3 additions & 0 deletions templates/vue.webapp/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
5 changes: 0 additions & 5 deletions templates/vue.webapp/babel.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions templates/vue.webapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>project-name</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
19 changes: 0 additions & 19 deletions templates/vue.webapp/jsconfig.json

This file was deleted.

47 changes: 12 additions & 35 deletions templates/vue.webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,19 @@
"version": "0.1.0",
"private": true,
"scripts": {
"start": "vue-cli-service serve --port 3000",
"build": "vue-cli-service build --dest build",
"lint": "vue-cli-service lint"
"start": "vite --port 3000",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
},
"dependencies": {
"axios": "~0.27.2",
"core-js": "^3.8.3",
"vue": "^3.2.13"
"axios": "^1.4.0",
"vue": "^3.3.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
"@vitejs/plugin-vue": "^4.2.3",
"eslint": "^8.39.0",
"eslint-plugin-vue": "^9.11.0",
"vite": "^4.3.5"
}
}
16 changes: 0 additions & 16 deletions templates/vue.webapp/public/index.html

This file was deleted.

25 changes: 7 additions & 18 deletions templates/vue.webapp/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<script setup>
import TechItems from './components/TechItems.vue'
import logoSVG from '@/assets/logo.svg';
</script>

<template>
<div id="app">
<main id="app">
<h2 class="title">project-name</h2>
<div class="logo">
<img :src="logoSVG" height="150" alt="logo" />
Expand All @@ -16,25 +21,9 @@
and <code>server/web/app.go</code>.
<TechItems />
</div>
</div>
</main>
</template>

<script>
import TechItems from './components/TechItems.vue'
export default {
name: 'App',
components: {
TechItems
},
data() {
return {
logoSVG: require('./assets/logo.svg')
}
}
};
</script>

<style>
body {
margin-top: 5%;
Expand Down
2 changes: 1 addition & 1 deletion templates/vue.webapp/src/components/TechItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
},
mounted() {
axios
.get(`${process.env.VUE_APP_API_URL}/api/technologies`)
.get(`${import.meta.env.VITE_API_URL}/api/technologies`)
.then(response => (this.technologies = response.data));
}
};
Expand Down
17 changes: 17 additions & 0 deletions templates/vue.webapp/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
outDir: 'build',
},
})
4 changes: 0 additions & 4 deletions templates/vue.webapp/vue.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion transform/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module transform

go 1.19
go 1.20

0 comments on commit c0be24e

Please sign in to comment.