Skip to content

Commit 8d41732

Browse files
pwolaninvvi230714
andauthored
Vue3 upgrade (#296)
Initial vue3 upgrade and upgrade of other dependencies Switch to vite instead of webpack for build remove mapzen geocoding search that no longer exists Switch to cypress for testing --------- Co-authored-by: vvi230714 <139596503+vvi230714@users.noreply.github.com> Co-authored-by: pwolanin <107691+pwolanin@users.noreply.github.com>
1 parent f4d8223 commit 8d41732

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+31743
-13934
lines changed

.babelrc

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
{
22
"presets": [
3-
["env", {
4-
modules: false,
5-
useBuiltIns: true,
6-
targets: {
7-
browsers: [
8-
'> 1%',
9-
'last 2 versions'
10-
]
3+
["@babel/preset-env", {
4+
"useBuiltIns": "entry",
5+
"targets": {
6+
"node": "current"
117
}
128
}]
139
],
1410
"plugins": [
11+
'@babel/plugin-transform-modules-commonjs',
1512
"transform-object-rest-spread"
16-
],
17-
"env": {
18-
"test": {
19-
"presets": [
20-
["env", {
21-
targets: {
22-
"node": "current"
23-
}
24-
}]
25-
]
26-
}
27-
}
13+
]
2814
}

.github/workflows/node.js.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,32 @@ on:
1212
jobs:
1313
build:
1414

15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-22.04
1616

1717
strategy:
1818
matrix:
19-
node-version: [14.x]
19+
node-version: [20.x]
2020
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2121

2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v3
25+
uses: actions/setup-node@v4
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
cache: 'npm'
2929
- run: npm ci
30-
- run: npm run lint
30+
# - run: npm run lint
3131
- run: npm run build
32-
- run: npm test
33-
- run: npm run e2e-ci
34-
- name: Upload E2E Test Report
35-
uses: actions/upload-artifact@v3
32+
- run: npm run cy:run
33+
- name: Cypress e2e run
34+
uses: cypress-io/github-action@v6
35+
with:
36+
start: npm run serve-http
37+
- name: Upload E2E Test Artifacts
38+
uses: actions/upload-artifact@v4
3639
if: always()
3740
with:
38-
name: playwright-report
39-
path: playwright-report/
41+
name: e2e_tests
42+
path: cypress/videos/e2e_tests.cy.js.mp4
4043
retention-days: 30

.github/workflows/pages.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,30 @@ defaults:
3232
jobs:
3333
build:
3434

35-
runs-on: ubuntu-latest
35+
runs-on: ubuntu-22.04
3636

3737
steps:
3838
- name: Checkout
3939
uses: actions/checkout@v3
4040
- name: Use Node.js
4141
uses: actions/setup-node@v3
4242
with:
43-
node-version: 14.x
43+
node-version: 20.x
4444
cache: 'npm'
4545
- run: npm ci
4646
- run: npm run build
4747

4848
# Deployment job
4949
- name: Deploy 🚀
50+
if: ${{ github.ref_name == 'master' }}
5051
uses: JamesIves/github-pages-deploy-action@3.7.1
51-
with:
52+
with:
5253
BRANCH: gh-pages # The branch the action should deploy to.
53-
FOLDER: public # The folder the action should deploy.
54+
FOLDER: build # The folder the action should deploy.
55+
- name: Test build
56+
if: ${{ github.ref_name != 'master' }}
57+
uses: JamesIves/github-pages-deploy-action@3.7.1
58+
with:
59+
BRANCH: gh-pages-test # The branch the action should deploy to.
60+
FOLDER: build # The folder the action should deploy.
61+

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
node_modules/
3+
build/
34
public/build.js
45
public/build.js.map
56
public/assets
@@ -8,7 +9,7 @@ yarn-error.log
89
data-scripts/venv
910
data-scripts/__pycache__
1011
data-scripts/*.pyc
11-
12+
public/build
1213
# Editor directories and files
1314
.idea
1415
*.suo
@@ -17,4 +18,6 @@ data-scripts/*.pyc
1718
*.sln
1819
/test-results/
1920
/playwright-report/
20-
/playwright/.cache/
21+
/playwright/.cache/
22+
cypress/screenshots/*
23+
cypress/videos/*

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM node:14-alpine3.15
2-
RUN apk update && apk add --no-cache bash
1+
FROM node:20-alpine3.18
2+
RUN apk update && apk add --no-cache bash && apk add --no-cache python3
33
ENTRYPOINT ["bash"]

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ These endorsements are determined by Ward Leaders, and have a huge influence ove
77

88
# Local development
99

10-
This project currently requires outdated node and npm versions to build.
10+
This project currently uses node version 20 to build.
1111

12-
Use Docker to start up a container that has working versions. The lines with ">"
12+
You can use Docker to start up a container that has node 20 if you don't have it for local development. The lines with ">"
1313
are in the native shell, the lines with ~ are in Docker.
1414

1515
```bash
1616
# Build and start the Docker container.
17-
> docker-compose build
18-
> docker-compose up -d
19-
> docker-compose exec ward-leaders bash
17+
> docker compose build
18+
> docker compose up -d
19+
> docker compose exec ward-leaders bash
2020

2121
# Install dependencies in the Docker container
2222
~ npm ci
2323

24-
# In Docker, serve with hot reload at localhost:8080
25-
~ npm start
24+
# In Docker, serve at localhost:8080
25+
~ npm run dev
2626

2727
# Inital load of the app in your browser is slow, fyi.
2828
# The dev server has hot reload - you should see any
@@ -35,7 +35,7 @@ are in the native shell, the lines with ~ are in Docker.
3535
# Exit docker and stop the container
3636
~ exit
3737

38-
> docker-compose down
38+
> docker compose down
3939
```
4040

4141
# Technical overview
@@ -55,27 +55,27 @@ While this application runs in the browser, completely client-side, [Node.js](ht
5555
**Contentful**
5656
Poking around [their website](https://www.contentful.com/) may be enough, but it would be helpful to create a free account and poke around to make sure you understand the concept of a CMS-as-a-Service.
5757

58-
**Webpack**
59-
[Webpack](https://webpack.js.org/) is a tool that aids you in pulling your hair out, building up frustration, and considering leaving front-end development behind for good. You can also use it to combine JavaScript modules into a bundled file that can be run in the browser. In this project it’s also used to run a local development server. Webpack can do *a ton* of things, and one of the trade-offs is that it’s rather confusing to configure and debug.
58+
**Vite**
59+
[Vite](https://vite.dev/guide/) Is used to build and combine JavaScript modules into a bundled file that can be run in the browser. In this project it’s also used to run a local development server and the server for e2e tests.
6060

6161
**Modern JavaScript features**
6262
This application is written in modern JavaScript (ES2015-ES2017) with language features such as [arrow functions](https://github.com/DrkSephy/es6-cheatsheet#arrow-functions), [destructuring](https://github.com/DrkSephy/es6-cheatsheet#destructuring), [object spread operator](https://codeburst.io/master-javascripts-object-spread-operator-3803430e99aa), and [async/await](http://nikgrozev.com/2017/10/01/async-await/).
6363

64-
**Babel**
65-
[Babel](https://babeljs.io/) allows us to support older browsers by transpiling our modern source code into source code that is more widely supported.
66-
6764
**Vue.js**
68-
We chose this framework because it’s relatively easy to get up-to-speed in, even if you’ve never used a JS framework before. But there are probably a few Vue.js-only things you’ll find yourself scratching your head about if it’s your first Vue.js app. It would be worth reading through their [really great guide](https://vuejs.org/v2/guide/).
65+
We chose this framework because it’s relatively easy to get up-to-speed in, even if you’ve never used a JS framework before. But there are probably a few Vue.js-only things you’ll find yourself scratching your head about if it’s your first Vue.js app. It would be worth reading through their [really great guide](https://vuejs.org/guide/introduction.html). This project was initially developed with Vue 2 and later upgraded to Vue 3. It uses the Options API.
6966

7067
**Composing components**
7168
This is a concept that you’ll already know if you’ve used React, Angular, choo, or other modern JS frameworks. If not, you’ll come across it [in the Vue.js guide](https://vuejs.org/v2/guide/#Composing-with-Components). [React’s docs](https://reactjs.org/docs/thinking-in-react.html) are also helpful for the concept.
7269

7370
**Vuex**
74-
We use Vue.js’ official centralized state management library, vuex. If you’re familiar with flux, redux, or elm, this will be pretty recognizable. If it’s your first time with centralized state management, this may be the most complex concept. Read over the [vuex docs](https://vuex.vuejs.org/en/) — specifically “What is vuex?”
71+
We use Vue.js’ centralized state management library, vuex. If you’re familiar with flux, redux, or elm, this will be pretty recognizable. If it’s your first time with centralized state management, this may be the most complex concept. Read over the [vuex docs](https://vuex.vuejs.org/en/) — specifically “What is vuex?”
7572

7673
**Vue-router**
7774
If you’ve used a router before, whether in JS or a server-side environment, this should seem pretty familiar. But it will be helpful to have the [vue-router docs](https://router.vuejs.org/en/) handy for anything that’s not obvious.
7875

76+
**Testing**
77+
[Cypress](https://www.cypress.io/) Only the Cypress component and e2e tests are currently being utilized. The tests are run automatically using github actions, but also can be run locally with npm.
78+
7979
## Directory structure
8080
```
8181
.
@@ -84,10 +84,11 @@ If you’ve used a router before, whether in JS or a server-side environment, th
8484
├── README.md
8585
├── data-scripts
8686
├── package.json
87+
├── index.html
8788
├── public
8889
│ ├── data
8990
│ ├── CNAME
90-
│ ├── index.html
91+
│ ├── 404.html
9192
├── src
9293
│ ├── App.vue
9394
│ ├── api
@@ -103,14 +104,16 @@ If you’ve used a router before, whether in JS or a server-side environment, th
103104
│ │ └── mutations.js
104105
│ ├── util.js
105106
│ └── views
106-
├── tests
107-
└── webpack.config.js
107+
├── cypress
108+
└── vite.config.js
109+
└── cypress.config.js
108110
```
109111

110112
## `src` directory
111113
| **File / directory** | **Description** |
112114
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
113-
| `public` | The directory that gets deployed. It includes the static `index.html` in source control, but the `build` script will put additional (compiled) files into this directory. |
115+
| `index.html` | Vite uses this as the basis for serving the site. Inline JS code works together with code in 404.html to made this work as a single page app on github pages.
116+
| `public` | Static assests that are copied to the build to be deployed. The `build` script will put additional (compiled) files together with these files and `index.html` in a `build/` directory. |
114117
| `public/data` | Static data files that are requested dynamically by the application (at runtime). |
115118
| `main.js` | Primary entry point for the app. Initializes router, store, and the top-level Vue component, mounting it to the `#app` element in `index.html`. |
116119
| `App.vue` | Top-level Vue component. Provides the layout for the site, including the nav bar, loading indicator, and space for the current route’s view. Also sets up the site’s core styles. |

babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
"presets": [
3+
["@babel/preset-env", {
4+
"useBuiltIns": "entry",
5+
"targets": {
6+
"node": "current"
7+
}
8+
}]
9+
],
10+
"plugins": [
11+
'@babel/plugin-transform-modules-commonjs',
12+
"transform-object-rest-spread"
13+
]
14+
}

cypress.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { defineConfig } = require('cypress');
2+
const { startDevServer } = require('@cypress/vite-dev-server');
3+
4+
module.exports=defineConfig({
5+
component: {
6+
specPattern: '**/*.cy.{js,jsx,ts,tsx}',
7+
devServer: {
8+
framework: 'vue',
9+
bundler: 'vite',
10+
},
11+
},
12+
e2e: {
13+
baseUrl: 'http://localhost:8080', // Default Vite dev server port
14+
supportFile: 'cypress/support/e2e.js',
15+
specPattern: 'cypress/e2e/**/*.cy.js',
16+
viewportWidth: 1280,
17+
viewportHeight: 720,
18+
defaultCommandTimeout: 3000,
19+
video: true,
20+
retries: {
21+
runMode: 2,
22+
openMode: 0,
23+
},
24+
setupNodeEvents(on, config) {
25+
on('dev-server:start', (options) => {
26+
return startDevServer({
27+
options,
28+
viteConfig: {
29+
configFile: 'vite.config.js', // Path to your Vite config file
30+
},
31+
});
32+
});
33+
34+
return config;
35+
},
36+
},
37+
});
38+

0 commit comments

Comments
 (0)