Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
varun2948 authored May 28, 2024
0 parents commit 88b5bb7
Show file tree
Hide file tree
Showing 138 changed files with 12,045 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SITE_NAME="Starter Kit -v3 (Ts)"
BASE_URL=https://admin.naxa.com.np
API_URL_V1=https://admin.naxa.com.np/api/v1
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
dist
vite.config.ts
src/vite-env.d.ts
src/schemas/types/vite-env.d.ts
src/constants/Proxies.ts
tailwind.config.js
postcss.config.js
54 changes: 54 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'airbnb',
'plugin:react/recommended',
// 'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json'],

extraFileExtensions: ['.json'],
tsconfigRootDir: __dirname,
},
plugins: ['react-hooks', 'prettier'],
rules: {
'prettier/prettier': 'error',
'no-console': 'error',
'react/react-in-jsx-scope': 0,
'react/jsx-props-no-spreading': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/forbid-prop-types': 'off',
'react/prop-types': 'off',
'no-unsafe-optional-chaining': 'warn',
'import/no-import-module-exports': 'off',
'react/function-component-definition': 'off',
'react/jsx-filename-extension': 'off',
'import/prefer-default-export': 'warn',
'react/require-default-props': 'off',
'object-curly-newline': 'off',
'no-undef': 0,
'import/no-unresolved': 0,
'prefer-template': 1,
'react/jsx-no-useless-fragment': 0,
'import/extensions': 0,
'no-plusplus': 0,
'no-unused-vars': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'class-methods-use-this': 'warn',
'react/state-in-constructor': 0,
'react/destructuring-assignment': 0,
'no-param-reassign': 'warn',
'jsx-a11y/label-has-associated-control': 'off',
'jsx-a11y/control-has-associated-label': 'off',
},
};
39 changes: 39 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## What type of PR is this? (check multiple if applicable)

- [ ] 🍕 Feature
- [ ] 🐛 Bug Fix
- [ ] 📝 Documentation
- [ ] 🧑‍💻 Refactor
- [ ] ✅ Test
- [ ] 🤖 Build or CI
- [ ] ❓ Other (please specify)

## Related Issue

Example: Fixes #123

## Describe this PR

A brief description of how this solves the issue (in present tense).

## Screenshots

Please provide screenshots of the change.

## Alternative Approaches Considered

Did you attempt any other approaches that are not documented in code?

## Review Guide

Notes for the reviewer. Specific key points and additional information that might be useful to the reviewer in evaluating this pull request. This could include performance considerations,design choices, etc.

## Checklist before requesting a review ( must have all the items ticked )

- [ ] My code adheres to the coding and style guidelines of the project.
- [ ] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have wrote use cases for complex functions I made.
- [ ] My changes generate no new warnings

## [optional] What gif best describes this PR or how it makes you feel?
137 changes: 137 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Build Starterkit Frontend CICD

on:
push:
branches:
- develop
- staging
- master
workflow_dispatch:

env:
AUTHOR: naxa
AWS_REGION: ap-south-1

jobs:
build:
name: Build Static Files
runs-on: self-hosted
steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 19.x

- name: Cache node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Write Environment Variables
id: write_env
run: |
case "${{ github.ref }}" in
refs/heads/develop)
echo '
SITE_NAME="Starter Kit -v3 (Ts)"
BASE_URL=https://admin.naxa.com.np
API_URL_V1=https://admin.naxa.com.np/api/v1
' > .env
;;
refs/heads/staging)
echo '
SITE_NAME="Starter Kit -v3 (Ts)"
BASE_URL=https://admin.naxa.com.np
API_URL_V1=https://admin.naxa.com.np/api/v1
' > .env
;;
refs/heads/master)
echo '
SITE_NAME="Starter Kit -v3 (Ts)"
BASE_URL=https://admin.naxa.com.np
API_URL_V1=https://admin.naxa.com.np/api/v1
' > .env
;;
esac
- name: Install yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install

- name: Generate build
run: |
yarn build
- name: Upload Dist as Artifacts
uses: actions/upload-artifact@v3
if: ${{ github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' }}
with:
name: DFIMS-${{ github.ref_name }}
path: dist
retention-days: 1

deploy:
name: Deploy Static Files
needs:
- build
if: ${{ github.ref == 'refs/heads/develop-xxx' || github.ref == 'refs/heads/staging-xxx' || github.ref == 'refs/heads/master-xxx' }}
runs-on: self-hosted
steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Get Artifacts
uses: actions/download-artifact@v1
with:
path: dist
name: DFIMS-${{ github.ref_name }}

- name: Get VM SSH host and user
id: get_vm_conf
run: |
case "${{ github.ref }}" in
refs/heads/develop)
export SERVER_IP=159.89.164.123
export SERVER_USERNAME=devops
export PROJECT_PATH=/srv/Projects/react-typescript-starterkit-v3/dist
;;
refs/heads/staging)
export SERVER_IP=159.89.164.123
export SERVER_USERNAME=devops
export PROJECT_PATH=/srv/Projects/react-typescript-starterkit-v3/dist
;;
refs/heads/master)
export SERVER_IP=159.89.164.123
export SERVER_USERNAME=devops
export PROJECT_PATH=/srv/Projects/react-typescript-starterkit-v3/dist
esac
echo "SERVER_IP=${SERVER_IP}" >> $GITHUB_OUTPUT
echo "SERVER_USERNAME=${SERVER_USERNAME}" >> $GITHUB_OUTPUT
echo "PROJECT_PATH=${PROJECT_PATH}" >> $GITHUB_OUTPUT
- name: Configure SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
ssh-keyscan ${{ steps.get_vm_conf.outputs.SERVER_IP }} >> ~/.ssh/known_hosts
- name: copy static files
run: |
scp -r ./dist/* ${{ steps.get_vm_conf.outputs.SERVER_USERNAME }}@${{ steps.get_vm_conf.outputs.SERVER_IP }}:${{ steps.get_vm_conf.outputs.PROJECT_PATH }}
echo "Build Pass"
- name: Clean SSH keys
run: |
chmod 700 ~/.ssh/id_rsa
rm -rf ~/.ssh/id_rsa
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
.vite/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# **/__test__/
.env
todo.txt
3 changes: 3 additions & 0 deletions .husky/.lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,jsx,ts,tsx}": "eslint --fix"
}
15 changes: 15 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
if head -1 "$1" | grep -qE "Merge .{1,}$"; then
echo $'\e[1;36m Skipping commit check.\e[0m\n'
exit 0
fi
if ! head -1 "$1" | grep -qE "^(feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|hotfix|asap)(\(.+?\))?: .{1,}$"; then
echo $'\e[1;31m Aborting commit. Your commit message is invalid.\e[0m\n' >&2
echo $'\e[1;36m Please fix your commit message starting with prefix-\e[0m \e[36m\n feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|hotfix|asap \n followed by ":" and what work did you do.\e[0m \n for example: \e[1;42m feat: your commit message \e[0m\n'
exit 1
fi
if ! head -1 "$1" | grep -qE "^.{1,200}$"; then
echo $'\n\e[1;31m Aborting commit. Your commit message is too long.\n\e[0m' >&2
echo $'\e[42m Please keep your commit message short i.e. only upto 200 characters.\e[0m\n'
exit 1
fi
21 changes: 21 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

BRANCH=$(git rev-parse --abbrev-ref HEAD)

ALLOWED_BRANCHES="staging|master|main|develop"
REGEX="^(feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|prd|hotfix|asap)/.{1,}$"

if echo "$BRANCH" | grep -Eq "$ALLOWED_BRANCHES"; then
echo $'\e[1;36m Skipping branch check for \e[0m'$'\e[1;31m'$BRANCH$'\e[0m \e[1;36mbranch\e[0m.\n'
exit 0
fi
if ! echo "$BRANCH" | grep -Eq "$REGEX"; then
echo $'\n\e[1;31m Your commit was rejected due to branching name.\e[0m\n'
echo $'\e[1;36mPlease rename your branch starting with prefix-\e[0m \e[36m\nfeat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|prd|hotfix|asap)\nfollowed by "/" and separated by "-".\e[0m \nfor example: \e[1;42mfeat/check-branch-name\e[0m\n'
exit 1
fi

yarn lint-staged


3 changes: 3 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,jsx,ts,tsx}": "eslint --fix"
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.16.0
9 changes: 9 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 80,
endOfLine: 'auto',
arrowParens: 'avoid',
plugins: ['prettier-plugin-tailwindcss'],
};
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

## Getting started with the starter kit



1. Do not use npm to install packages, use yarn. If you want to run `npm install` then delete the `yarn.lock` file and install the packages using npm.

2. Create a .env file and copy .env.sample to .env

3. Run `yarn dev` to start the development server.

4. If there is error on "/dashboard" route then comment out the proxy setup part on `vite.config.ts` file.



## Folder Structure



- [API](./src/api/readme.md)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$--> Api's for the project

- [Wrappers](./src/api/wrappers/readme.md)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$--> Wrappers

- [Routes](./src/routes/readme.md)$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$--> Routes

- [Utils](./src/utils/readme.md)

- [UI](./src/ui/readme.md)



## Example to add shadcn component (select component- [link](https://ui.shadcn.com/docs/components/select) )

npx shadcn-ui add select
give path as
**./src/ui/atoms/common/**

- resolve all classes with tailwind prefix
- replace classes with color variables with project color variables
- add missing dependencies ( if npx failed to install dependencies automatically e.g: @radix-ui/react-select )

16 changes: 16 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/assets/css/tailwind.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "components/RadixComponents",
"utils": "@/lib/utils"
}
}
Loading

0 comments on commit 88b5bb7

Please sign in to comment.