Skip to content

Commit b0e6d44

Browse files
feat: Add client (#28)
1 parent 1d8d1b9 commit b0e6d44

File tree

134 files changed

+17770
-17
lines changed

Some content is hidden

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

134 files changed

+17770
-17
lines changed

.github/workflows/ci-client.yaml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build"
1+
name: "CI Client"
22
on:
33
push:
44
branches:
@@ -16,4 +16,45 @@ jobs:
1616
uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 1
19-
- run: echo "CI is running"
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 22.x
22+
- run: make build-client
23+
Lint:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 1
30+
- uses: actions/setup-node@v4
31+
- run: make lint-client
32+
33+
Test:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 1
40+
- uses: actions/setup-node@v4
41+
- run: make test-client
42+
43+
Coverage:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 1
50+
- uses: actions/setup-node@v4
51+
- run: make coverage-client
52+
- name: Upload coverage reports to Codecov
53+
uses: codecov/codecov-action@v5
54+
with:
55+
fail_ci_if_error: true
56+
token: ${{ secrets.CODECOV_TOKEN }}
57+
flags: client
58+
working-directory: client
59+
env:
60+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/ci-server.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
flags: server
7171
fail_ci_if_error: true
7272
token: ${{ secrets.CODECOV_TOKEN }}
73+
flags: server
7374
env:
7475
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7576

Makefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ RESET := $(shell tput -Txterm sgr0)
1414

1515
all: help
1616
## Build:
17-
build: build-api ## Build all the binaries and put the output in out/bin/
17+
build: build-server build-client## Build all the binaries and put the output in out/bin/
1818

1919
create-out-dir:
2020
mkdir -p out/bin
2121

22-
build-server: create-out-dir ## Build the migration cli in out/bin/
22+
build-server: create-out-dir ## Build the flag-management-api in out/bin/
2323
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/flag-management-api .
2424

25+
build-client: ## Build the react app
26+
cd client && npm install && npm run build
27+
2528
clean: ## Remove build related file
2629
-rm -fr ./bin ./out ./release
2730
-rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml
@@ -42,23 +45,35 @@ setup-env:
4245
sleep 2
4346
migrate -source "file://database_migration" -database "postgres://goff-user:my-secret-pw@localhost:5432/gofeatureflag?sslmode=disable" up
4447

48+
start-local: setup-env## Start the server locally
49+
$(GOCMD) run -mod vendor main.go --mode=development --postgresConnectionString="postgres://goff-user:my-secret-pw@localhost:5432/gofeatureflag?sslmode=disable"
50+
4551
## Test:
4652
test: test-server
47-
test-server: ## Run the tests of the project
53+
test-server: ## Run the tests of the server project
4854
$(GOTEST) -v -tags=docker -race ./...
4955

56+
test-client: ## Run the tests of the client project
57+
cd client && npm install && npm run test
58+
5059
## Coverage:
5160
coverage: coverage-server ## Run all the coverage on your project
5261
coverage-server: ## Run the tests of the project and export the coverage
5362
$(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov ./...
5463

64+
coverage-client: ## Run the tests of the project and export the coverage
65+
cd client && npm install && npm run coverage
66+
5567
## Lint:
56-
lint: lint-server ## Run all the linters on your project
68+
lint: lint-server lint-client ## Run all the linters on your project
5769
lint-server: ## Use golintci-lint on your project
5870
mkdir -p ./bin
5971
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest # Install linters
6072
./bin/golangci-lint run --timeout=5m --timeout=5m ./... --enable-only=gci --fix # Run linters
6173

74+
lint-client: ## Use linter to lint website
75+
cd client && npm install && npm run lint
76+
6277
## Help:
6378
help: ## Show this help.
6479
@echo ''

client/.eslintrc.cjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
parserOptions: {
5+
ecmaVersion: "latest",
6+
sourceType: "module",
7+
project: ["./tsconfig.json", "./tsconfig.node.json"],
8+
tsconfigRootDir: __dirname,
9+
},
10+
extends: [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/strict",
13+
"plugin:@typescript-eslint/stylistic-type-checked",
14+
"plugin:react-hooks/recommended",
15+
"plugin:react/jsx-runtime",
16+
"plugin:prettier/recommended",
17+
"plugin:react/recommended",
18+
"plugin:react-hooks/recommended",
19+
"plugin:tailwindcss/recommended",
20+
],
21+
ignorePatterns: ["dist", ".eslintrc.cjs"],
22+
parser: "@typescript-eslint/parser",
23+
plugins: ["react-refresh", "testing-library", "tailwindcss"],
24+
rules: {
25+
"react/react-in-jsx-scope": "off",
26+
"react/jsx-uses-react": "off",
27+
"@typescript-eslint/consistent-type-imports": "error",
28+
"react/no-unescaped-entities": "off",
29+
"react-refresh/only-export-components": [
30+
"warn",
31+
{ allowConstantExport: true },
32+
],
33+
"tailwindcss/classnames-order": [
34+
"error",
35+
{
36+
callees: ["classnames"],
37+
config: "tailwind.config.js",
38+
},
39+
],
40+
"tailwindcss/no-custom-classname": [
41+
"error",
42+
{
43+
config: "tailwind.config.js",
44+
},
45+
],
46+
"testing-library/await-async-queries": "error",
47+
"testing-library/no-await-sync-queries": "error",
48+
"testing-library/no-debugging-utils": "warn",
49+
"testing-library/no-dom-import": "off",
50+
},
51+
settings: {
52+
react: {
53+
version: "detect",
54+
},
55+
},
56+
};

client/.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
type-check.tsbuildinfo
27+
coverage/
28+
dist/

client/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plugins": [
3+
"prettier-plugin-organize-imports",
4+
"prettier-plugin-tailwindcss"
5+
],
6+
"trailingComma": "all"
7+
}

client/README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1-
# Client
1+
# React + TypeScript + Vite
22

3-
Here we will have the client code.
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default {
18+
// other rules...
19+
parserOptions: {
20+
ecmaVersion: "latest",
21+
sourceType: "module",
22+
project: ["./tsconfig.json", "./tsconfig.node.json"],
23+
tsconfigRootDir: __dirname,
24+
},
25+
};
26+
```
27+
28+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

client/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<style>
6+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;400&display=swap');
7+
</style>
8+
<link rel="icon" type="image/svg+xml" href="/gofeatureflag.svg" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
10+
<title>GO Feature Flag</title>
11+
</head>
12+
<body class="bg-gray-50 dark:bg-gray-900">
13+
<div id="root"></div>
14+
<script type="module" src="/src/main.tsx"></script>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)