Skip to content

Commit 538e8a9

Browse files
authored
Rebase the frontend using Vite (#10)
* Docs & Helm * Vite migration done * Fix tests in makefile
1 parent 3764129 commit 538e8a9

Some content is hidden

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

61 files changed

+3574
-15388
lines changed

.github/workflows/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
branches: [main]
1313

1414
env:
15-
VERSION: 0.8.4
15+
VERSION: 0.8.5
1616
BUILD_INFO: "Build:development / Workflow:${{ github.workflow }} / RunId:${{ github.run_id }} / Ref:${{ github.ref }} / SHA:${{ github.sha }} / ImageTag:${{ github.run_id }}"
1717
IMAGE_REG: ghcr.io
1818
IMAGE_TAG: ${{ github.run_id }}

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SERVICE_DIR := cmd
22
FRONTEND_DIR := web/frontend
33
OUTPUT_DIR := ./output
4-
VERSION ?= 0.8.4
4+
VERSION ?= 0.8.5
55
BUILD_INFO ?= "Local makefile build"
66
DAPR_RUN_LOGLEVEL := warn
77

@@ -28,7 +28,7 @@ lint-fix: $(FRONTEND_DIR)/node_modules ## 📝 Lint & format, fixes errors and
2828

2929
test: ## 🎯 Unit tests for services and snapshot tests for SPA frontend
3030
go test -v -count=1 ./$(SERVICE_DIR)/...
31-
@cd $(FRONTEND_DIR); NODE_ENV=test npm run test -- --ci
31+
@cd $(FRONTEND_DIR); npm run test:unit
3232

3333
frontend: $(FRONTEND_DIR)/node_modules ## 💻 Build and bundle the frontend Vue SPA
3434
cd $(FRONTEND_DIR); npm run build
@@ -46,7 +46,7 @@ clean: ## 🧹 Clean the project, remove modules, binaries and outputs
4646
rm -rf $(SERVICE_DIR)/frontend-host/frontend-host
4747

4848
run: ## 🚀 Start & run everything locally as processes
49-
cd $(FRONTEND_DIR); npm run serve &
49+
cd $(FRONTEND_DIR); npm run dev &
5050
dapr run --app-id cart --app-port 9001 --log-level $(DAPR_RUN_LOGLEVEL) go run github.com/azure-samples/dapr-store/cmd/cart &
5151
dapr run --app-id products --app-port 9002 --log-level $(DAPR_RUN_LOGLEVEL) go run github.com/azure-samples/dapr-store/cmd/products ./cmd/products/sqlite.db &
5252
dapr run --app-id users --app-port 9003 --log-level $(DAPR_RUN_LOGLEVEL) go run github.com/azure-samples/dapr-store/cmd/users &

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ See `scripts/local-gateway` for details on how this is done, the `scripts/local-
180180

181181
# Running in Kubernetes - Quick guide
182182

183-
#### [📃 SUB-SECTION: Deployment guide for Kubernetes](./deploy/)
183+
#### [📃 Extra Doc: Deployment guide for Kubernetes](./deploy/)
184184

185185
# Running Locally - Quick guide
186186

@@ -262,7 +262,7 @@ The default mode of operation for the Dapr Store is in "demo mode" where there i
262262

263263
Optionally Dapr store can be configured utilise the [Microsoft identity platform](https://docs.microsoft.com/en-us/azure/active-directory/develop/) (aka Microsoft Entra ID) as an identity provider. This then supports real user sign-in, and securing of the APIs.
264264

265-
#### [📃 SECTION: Full details on security, identity & authentication](./docs/auth-identity/)
265+
#### [📃 Extra Doc: Security, identity & authentication](./docs/auth-identity/)
266266

267267
# Configuration
268268

@@ -300,7 +300,7 @@ Frontend host config:
300300

301301
## Dapr Components
302302

303-
#### [📃 SECTION: Details of the Dapr components used by the application and how to configure them.](components/)
303+
#### [📃 Extra Doc: Dapr components used and how to configure them.](components/)
304304

305305
# Concepts and Terms
306306

build/frontend.Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ FROM node:20-alpine as frontend-build
2828
ARG VERSION="0.0.1"
2929
ARG BUILD_INFO="Not provided"
3030

31-
ENV VUE_APP_BUILD_INFO=${BUILD_INFO}
31+
ENV VITE_BUILD_INFO=${BUILD_INFO}
3232
WORKDIR /build
3333

3434
# Install all the Vue.js dev tools & CLI, and our app dependencies
@@ -38,11 +38,13 @@ RUN npm version $VERSION --allow-same-version
3838
RUN npm install --silent
3939

4040
# Copy in the Vue.js app source
41-
COPY web/frontend/.eslintrc.js .
41+
COPY web/frontend/.eslintrc.cjs .
42+
COPY web/frontend/vite.config.js .
43+
COPY web/frontend/index.html .
4244
COPY web/frontend/public ./public
4345
COPY web/frontend/src ./src
4446

45-
# Now main Vue CLI build & bundle, this will output to ./dist
47+
# Now build & bundle, this will output to ./dist
4648
RUN npm run build
4749

4850
# ================================================================================================

deploy/helm/daprstore/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: A reference application showcasing the use of Dapr
55
type: application
66

77
# This is the chart version.
8-
version: 0.8.4
8+
version: 0.8.5
99

1010
# This is the version number of the application being deployed.
11-
appVersion: 0.8.4
11+
appVersion: 0.8.5

deploy/helm/daprstore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A reference application showcasing the use of Dapr
2020
| frontendHost.replicas | int | `1` | Dapr store frontend host replica count |
2121
| image.pullSecrets | list | `[]` | Any pullsecrets that are required to pull the image |
2222
| image.registry | string | `"ghcr.io"` | Image registry, only change if you're using your own images |
23-
| image.repo | string | `"benc-uk/azure-samples"` | Image repository |
23+
| image.repo | string | `"azure-samples/dapr-store"` | Image repository |
2424
| image.tag | string | `"latest"` | Image tag |
2525
| ingress.certIssuer | string | `nil` | Cert manager issuer, leave unset to run in insecure mode |
2626
| ingress.certName | string | `nil` | Set this to enable TLS, leave unset to run in insecure mode |

deploy/helm/daprstore/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ image:
66
# -- Image registry, only change if you're using your own images
77
registry: ghcr.io
88
# -- Image repository
9-
repo: benc-uk/azure-samples
9+
repo: azure-samples/dapr-store
1010
# -- Image tag
1111
tag: latest
1212
# -- Any pullsecrets that are required to pull the image

deploy/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a brief guide to deploying Dapr Store to Kubernetes.
55
Assumptions:
66

77
- kubectl is installed, and configured to access your Kubernetes cluster
8-
- dapr CLI is installed - https://docs.dapr.io/getting-started/install-dapr-cli/
8+
- Dapr CLI is installed - https://docs.dapr.io/getting-started/install-dapr-cli/
99
- helm is installed - https://helm.sh/docs/intro/install/
1010

1111
This guide does not cover more advanced deployment scenarios such as deploying behind a DNS name, or with HTTPS enabled or with used identity enabled.

docs/auth-identity/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Note. If running a services directly from their own directory i.e. `cmd/cart/` t
5151

5252
[MSAL.js for browser](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) is used to provide authentication to the web app frontend
5353

54-
To enable auth, when working locally - create the following file `web/frontend/.env.development.local` and set `VUE_APP_AUTH_CLIENT_ID` with your client id. Note the `VUE_APP_` prefix, this is important.
54+
To enable auth, when working locally - create the following file `web/frontend/.env.development.local` and set `VITE_AUTH_CLIENT_ID` with your client id. Note the `VITE_` prefix, this is important.
5555

5656
When served from the frontend-host, the frontend will try to fetch it's configuration from the `/config` endpoint and try to get `AUTH_CLIENT_ID` this way. This allows dynamic configuration of the auth feature at runtime.
5757

@@ -60,7 +60,7 @@ When `AUTH_CLIENT_ID` is set the application behavior changes as follows:
6060
- Login page allows users to register, and sign-in with real user accounts in Azure AD.
6161
- If a user is signed-in, an access token is acquired via the auth service, and used for all API calls made by the frontend to the backend Dapr Store APIs. This token is requested for the scope `store-api`. The fetched access token is then added to the Authorization header of all API calls.
6262

63-
In both cases if `AUTH_CLIENT_ID` is not found at `/config` or if `VUE_APP_AUTH_CLIENT_ID` is not set locally - then the app falls back into "demo user mode" with a fake user account in the frontend.
63+
In both cases if `AUTH_CLIENT_ID` is not found at `/config` or if `VITE_AUTH_CLIENT_ID` is not set locally - then the app falls back into "demo user mode" with a fake user account in the frontend.
6464

6565
# Services & Token Validation
6666

testing/mock-data/products.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"id": "prd1",
4-
"name": "Top Hat (6″)",
4+
"name": "Top Hat (6″)",
55
"cost": 39.95,
66
"description": "Made from 100% wool and quite nice",
77
"image": "/img/catalog/1.jpg",
@@ -23,4 +23,4 @@
2323
"image": "/img/catalog/3.jpg",
2424
"onOffer": false
2525
}
26-
]
26+
]

web/frontend/.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VUE_APP_API_ENDPOINT=/
2-
VUE_APP_AUTH_CLIENT_ID=""
1+
VITE_API_ENDPOINT=/
2+
VITE_AUTH_CLIENT_ID=""

web/frontend/.eslintrc.cjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-env node */
2+
require('@rushstack/eslint-patch/modern-module-resolution')
3+
4+
module.exports = {
5+
root: true,
6+
7+
env: {
8+
node: true,
9+
es6: true
10+
},
11+
12+
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/eslint-config-prettier/skip-formatting'],
13+
14+
parserOptions: {
15+
ecmaVersion: 'latest'
16+
},
17+
18+
rules: {
19+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
20+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
21+
'vue/multi-word-component-names': 'off',
22+
'prefer-const': 'error'
23+
}
24+
}

web/frontend/.eslintrc.js

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

web/frontend/.gitignore

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
.DS_Store
2-
node_modules
3-
/dist
4-
5-
# local env files
6-
.env.local
7-
.env.*.local
8-
9-
# Log files
1+
# Logs
2+
logs
3+
*.log
104
npm-debug.log*
115
yarn-debug.log*
126
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
/cypress/videos/
18+
/cypress/screenshots/
1319

1420
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
1523
.idea
16-
.vscode
1724
*.suo
1825
*.ntvs*
1926
*.njsproj
2027
*.sln
2128
*.sw?
29+
30+
*.tsbuildinfo

web/frontend/README.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,41 @@
1-
# Dapr Store Frontend
1+
# dapr-store-new-vite
22

3-
Created with Vue CLI
3+
This template should help get you started developing with Vue 3 in Vite.
44

5-
## Project setup
5+
## Recommended IDE Setup
66

7-
```bash
8-
npm install
9-
```
7+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
108

11-
### Compiles and hot-reloads for development
9+
## Customize configuration
1210

13-
```bash
14-
npm run serve
15-
```
11+
See [Vite Configuration Reference](https://vitejs.dev/config/).
1612

17-
### Compiles and minifies for production
13+
## Project Setup
1814

19-
```bash
20-
npm run build
15+
```sh
16+
npm install
2117
```
2218

23-
### Lints and fixes files
24-
25-
```bash
26-
npm run lint
27-
```
19+
### Compile and Hot-Reload for Development
2820

29-
```bash
30-
npm run lint-fix
21+
```sh
22+
npm run dev
3123
```
3224

33-
### Run unit tests (snapshots)
34-
35-
Against current snapshots
25+
### Compile and Minify for Production
3626

37-
```bash
38-
npm run test
27+
```sh
28+
npm run build
3929
```
4030

41-
Update snapshots with
31+
### Run Unit Tests with [Vitest](https://vitest.dev/)
4232

43-
```bash
44-
npm run test-update
33+
```sh
34+
npm run test:unit
4535
```
4636

47-
### Customize configuration
37+
### Lint with [ESLint](https://eslint.org/)
4838

49-
See [Configuration Reference](https://cli.vuejs.org/config/).
39+
```sh
40+
npm run lint
41+
```

web/frontend/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="icon" href="logo.png" type="image/png" />
7+
<title>Dapr Store</title>
8+
9+
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&family=Josefin+Sans:wght@400&display=swap" rel="stylesheet" />
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" />
11+
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> -->
12+
</head>
13+
<body>
14+
<noscript>
15+
<strong>We're sorry but Dapr Store doesn't work without JavaScript!</strong>
16+
</noscript>
17+
18+
<div id="app"></div>
19+
20+
<script type="module" src="/src/main.js"></script>
21+
</body>
22+
</html>

web/frontend/jest.config.js

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

web/frontend/jsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"paths": {
4+
"@/*": ["./src/*"]
5+
}
6+
},
7+
"exclude": ["node_modules", "dist"]
8+
}

0 commit comments

Comments
 (0)