Skip to content

Commit b921314

Browse files
authored
Merge all changes from develop (#104)
1 parent 564b7e9 commit b921314

Some content is hidden

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

60 files changed

+5555
-1159
lines changed

.eslintrc.cjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
module.exports = {
22
root: true,
3-
env: { browser: true, es2020: true },
3+
env: { node: true, browser: true, es2020: true },
44
extends: [
55
'eslint:recommended',
66
'plugin:@typescript-eslint/recommended',
77
'plugin:react-hooks/recommended',
8+
'prettier'
89
],
910
ignorePatterns: ['dist', '.eslintrc.cjs'],
1011
parser: '@typescript-eslint/parser',
11-
plugins: ['react-refresh'],
12+
plugins: ['react-refresh', 'prettier'],
1213
rules: {
1314
'react-refresh/only-export-components': [
1415
'warn',
1516
{ allowConstantExport: true },
1617
],
18+
'prettier/prettier': [
19+
'error',
20+
{},
21+
{
22+
usePrettierrc: true,
23+
}
24+
]
1725
},
1826
}

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Build and Lint on Pull Requests'
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repository
10+
uses: actions/checkout@v4
11+
12+
- name: Set up node
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 20
16+
cache: npm
17+
18+
- name: Install dependencies
19+
run: npm install
20+
21+
- name: Build application
22+
run: npm run build
23+
24+
- name: Check for ESLint warnings and errors
25+
run: npm run lint
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build and Deploy Docker Image
2+
3+
permissions:
4+
contents: read
5+
id-token: write
6+
7+
8+
on:
9+
push:
10+
branches:
11+
- develop
12+
- main
13+
paths:
14+
- 'src/**'
15+
- 'server.js'
16+
- 'index.html'
17+
- 'tsconfig.json'
18+
- 'tsconfig.node.json'
19+
- 'vite.config.ts'
20+
- 'package.json'
21+
- 'package-lock.json'
22+
- 'Dockerfile'
23+
release:
24+
types: [published]
25+
workflow_dispatch:
26+
27+
env:
28+
REGISTRY: europe-north1-docker.pkg.dev/artifact-registry-5n/dapla-stat-docker
29+
IMAGE: dapla-ctrl
30+
TAG: ${{ github.ref_name }}-${{ github.sha }}
31+
32+
jobs:
33+
build-and-push:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Check out repo
37+
uses: actions/checkout@v3
38+
39+
- id: "auth"
40+
name: "Authenticate to Google Cloud"
41+
uses: "google-github-actions/auth@v1.1.1"
42+
with:
43+
workload_identity_provider: "projects/848539402404/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions"
44+
service_account: "gh-actions-dapla-stat@artifact-registry-5n.iam.gserviceaccount.com"
45+
token_format: "access_token"
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v1
49+
50+
- name: Login to registry
51+
uses: docker/login-action@v2
52+
with:
53+
registry: ${{ env.REGISTRY }}
54+
username: "oauth2accesstoken"
55+
password: "${{ steps.auth.outputs.access_token }}"
56+
57+
- name: Docker meta
58+
id: metadata
59+
uses: docker/metadata-action@v4
60+
with:
61+
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
62+
tags: |
63+
type=schedule
64+
type=ref,event=branch
65+
type=ref,event=pr
66+
type=semver,pattern=v{{version}}
67+
type=semver,pattern=v{{major}}.{{minor}}
68+
type=semver,pattern=v{{major}}
69+
type=sha
70+
type=raw,value=${{ env.TAG }}, enable=true
71+
72+
- name: Build and push
73+
uses: docker/build-push-action@v2
74+
with:
75+
context: .
76+
file: ./Dockerfile
77+
push: true
78+
tags: ${{ steps.metadata.outputs.tags }}
79+
build-args: |
80+
BASE_IMAGE=${{ env.REGISTRY }}/base-image:latest

.github/workflows/dependabot.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Dependabot auto-merge patch
2+
on: pull_request_target
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
env:
13+
PR_URL: ${{github.event.pull_request.html_url}}
14+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
15+
steps:
16+
- name: Dependabot metadata
17+
id: metadata
18+
uses: dependabot/fetch-metadata@v1
19+
with:
20+
github-token: "${{ secrets.GITHUB_TOKEN }}"
21+
- name: approve
22+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
23+
run: gh pr review --approve "$PR_URL"
24+
- name: merge
25+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
26+
run: gh pr merge --auto --squash "$PR_URL"

.prettierrc.cjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
arrowParens: 'always',
3+
printWidth: 120,
4+
semi: false,
5+
tabWidth: 2,
6+
singleQuote: true,
7+
jsxSingleQuote: true,
8+
trailingComma: 'es5'
9+
}

README.md

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
</p>
1313
</div>
1414

15-
16-
1715
<!-- TABLE OF CONTENTS -->
1816
<details>
1917
<summary>Table of Contents</summary>
@@ -37,28 +35,23 @@
3735
</ol>
3836
</details>
3937

40-
41-
4238
<!-- ABOUT THE PROJECT -->
39+
4340
## About The Project
4441

4542
A web interface for performing administrative tasks related to Dapla teams. TODO: Put more info here.
4643

4744
<p align="right">(<a href="#readme-top">back to top</a>)</p>
4845

49-
50-
5146
### Built With
5247

53-
* [![Vite][Vite.js]][Vite-url]
54-
* [![React][React.js]][React-url]
55-
48+
- [![Vite][Vite.js]][Vite-url]
49+
- [![React][React.js]][React-url]
5650

5751
<p align="right">(<a href="#readme-top">back to top</a>)</p>
5852

59-
60-
6153
<!-- GETTING STARTED -->
54+
6255
## Getting Started
6356

6457
This is an example of how you may give instructions on setting up your project locally.
@@ -67,24 +60,25 @@ To get a local copy up and running follow these simple example steps.
6760
### Prerequisites
6861

6962
This is an example of how to list things you need to use the software and how to install them.
70-
* npm
63+
64+
- npm
7165
```sh
7266
npm install npm@latest -g
7367
```
74-
* Install nodemon (required to run the development server)
75-
```
76-
npm install -g nodemon
77-
```
78-
* If you want to test against local version of dapla-team-api-redux. [Click here for step by step guide to set it up](https://example.com)
79-
* Create .env.local (note you must replace dummy names with real values)
80-
If testing with local version of dapla-team-api-redux put this:
81-
```sh
82-
touch .env.local && printf 'VITE_DAPLA_TEAM_API_URL="http://localhost:8080"\nVITE_JWKS_URI="https://your-keycloak.domain.com/auth/realms/ssb/protocol/openid-connect/certs"\n' >> .env.local
83-
```
84-
If testing with dapla-team-api-redux in production, put this:
85-
```sh
86-
touch .env.local && printf 'VITE_DAPLA_TEAM_API_URL="http://your-running-application.domain.com"\nVITE_JWKS_URI="https://your-keycloak.domain.com/auth/realms/ssb/protocol/openid-connect/certs"\n' >> .env.local
87-
```
68+
- Install nodemon (required to run the development server)
69+
```
70+
npm install -g nodemon
71+
```
72+
- If you want to test against local version of dapla-team-api-redux. [Click here for step by step guide to set it up](https://example.com)
73+
- Create .env.local (note you must replace dummy names with real values)
74+
If testing with local version of dapla-team-api-redux put this:
75+
```sh
76+
touch .env.local && printf 'VITE_DAPLA_TEAM_API_URL="http://localhost:8080"\nVITE_JWKS_URI="https://your-keycloak.domain.com/auth/realms/ssb/protocol/openid-connect/certs"\nVITE_SSB_BEARER_URL="https://your-http-bin.domain.com/bearer"' >> .env.local
77+
```
78+
If testing with dapla-team-api-redux in production, put this:
79+
```sh
80+
touch .env.local && printf 'VITE_DAPLA_TEAM_API_URL="http://your-running-application.domain.com"\nVITE_JWKS_URI="https://your-keycloak.domain.com/auth/realms/ssb/protocol/openid-connect/certs"\nVITE_SSB_BEARER_URL="https://your-http-bin.domain.com/bearer"' >> .env.local
81+
```
8882

8983
### Installation
9084

@@ -93,9 +87,9 @@ This is an example of how to list things you need to use the software and how to
9387
git clone https://github.com/statisticsnorway/dapla-ctrl.git
9488
```
9589
2. Navigate into the repository
96-
```sh
97-
cd dapla-ctrl
98-
```
90+
```sh
91+
cd dapla-ctrl
92+
```
9993
3. Install NPM packages
10094
```sh
10195
npm install
@@ -105,10 +99,46 @@ This is an example of how to list things you need to use the software and how to
10599
npm run dev
106100
```
107101

108-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
102+
### ESLint and Prettier
103+
104+
For ensuring code consistency and adhering to coding standards, our project utilizes ESLint and Prettier. To view linting warnings and errors in the console, it's recommended to run the following script during development:
109105

106+
```sh
107+
npm run lint
108+
```
109+
110+
To automatically fix linting and formatting issues across all files, you can use the following scripts (Note: While these scripts resolve many ESLint warnings or errors, some issues may require manual intervention):
111+
112+
```sh
113+
npm run lint:fix && npm run lint:format
114+
```
115+
116+
### Integrated Development Environments (IDEs) Support
117+
118+
For seamless integration with popular IDEs such as Visual Studio Code and IntelliJ, consider installing the following plugins:
119+
120+
#### Visual Studio Code
121+
122+
1. **ESLint**: Install the ESLint extension to enable real-time linting and error highlighting.
123+
[ESLint Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
124+
125+
2. **Prettier**: Enhance code formatting by installing the Prettier extension.
126+
[Prettier Extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
127+
128+
#### IntelliJ
129+
130+
1. **ESLint**: Install the ESLint plugin to enable ESLint integration within IntelliJ.
131+
[ESLint Plugin](https://plugins.jetbrains.com/plugin/7494-eslint)
132+
133+
2. **Prettier**: Integrate Prettier for code formatting by installing the Prettier plugin.
134+
[Prettier Plugin](https://plugins.jetbrains.com/plugin/10456-prettier)
135+
136+
By incorporating these plugins into your development environment, you can take full advantage of ESLint and Prettier to maintain code quality and consistent formatting throughout your project.
137+
138+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
110139

111140
<!-- CONTRIBUTING -->
141+
112142
## Contributing
113143

114144
Any contributions you make are **greatly appreciated**.
@@ -124,21 +154,17 @@ Don't forget to give the project a star! Thanks again!
124154

125155
<p align="right">(<a href="#readme-top">back to top</a>)</p>
126156

127-
128-
129157
<!-- LICENSE -->
158+
130159
## License
131160

132161
Distributed under the MIT License. See `LICENSE.txt` for more information.
133162

134-
135-
136163
<p align="right">(<a href="#readme-top">back to top</a>)</p>
137164

138-
139-
140165
<!-- MARKDOWN LINKS & IMAGES -->
141166
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
167+
142168
[contributors-shield]: https://img.shields.io/github/contributors/github_username/repo_name.svg?style=for-the-badge
143169
[contributors-url]: https://github.com/github_username/repo_name/graphs/contributors
144170
[forks-shield]: https://img.shields.io/github/forks/github_username/repo_name.svg?style=for-the-badge

0 commit comments

Comments
 (0)