Skip to content

Commit

Permalink
feat: added base structure for ui/web folder for 3.0 (#4028)
Browse files Browse the repository at this point in the history
* feat: added base structure for web folder

Signed-off-by: Sahil <[email protected]>

* feat: added config and models for API types

Signed-off-by: Sahil <[email protected]>

* feat: added APIs for consumption

Signed-off-by: Sahil <[email protected]>

* feat: added string util for easy translations

Signed-off-by: Sahil <[email protected]>

* chore: code cleanup

Signed-off-by: Sahil <[email protected]>

* fix: removed unused code

Signed-off-by: Sahil <[email protected]>

---------

Signed-off-by: Sahil <[email protected]>
  • Loading branch information
SahilKr24 committed Jun 29, 2023
1 parent 2e98b19 commit 712662c
Show file tree
Hide file tree
Showing 117 changed files with 30,596 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chaoscenter/web/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jest.config.js
scripts/
node_modules
dist
*.js
_mocks/
config/
143 changes: 143 additions & 0 deletions chaoscenter/web/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
parser: '@typescript-eslint/parser'
root: true
parserOptions:
ecmaVersion: 2020
sourceType: module
ecmaFeatures:
jsx: true
impliedStrict: true
project: ./tsconfig.json
plugins:
- react
- '@typescript-eslint/eslint-plugin'
- react-hooks
- jest
- import
env:
browser: true
node: true
shared-node-browser: true
es6: true
jest: true
globals:
__DEV__: readonly
extends:
- eslint:recommended
- plugin:react/recommended
- plugin:@typescript-eslint/recommended
- plugin:import/errors
- plugin:import/typescript
- prettier
settings:
react:
version: detect
import/resolver:
typescript:
alwaysTryTypes: true

rules:
# built-in
no-console: 2
semi: 0
no-await-in-loop: 2
no-shadow: 0

# react hooks
react-hooks/rules-of-hooks: 2
react-hooks/exhaustive-deps: 1

# react
react/prop-types: 0
react/display-name: 1

#typescript
'@typescript-eslint/no-use-before-define': 0
'@typescript-eslint/explicit-function-return-type':
- 1
- allowExpressions: true
no-unused-vars: 0
'@typescript-eslint/no-unused-vars':
- 2
- vars: all
args: after-used
ignoreRestSiblings: true
argsIgnorePattern: ^_
'@typescript-eslint/member-delimiter-style': 0
'@typescript-eslint/no-shadow': 2
'@typescript-eslint/no-extra-semi': 0
'@typescript-eslint/no-duplicate-imports': 2

#import
import/order:
- error
- groups:
- builtin
- external
- internal
- - parent
- sibling
pathGroups:
- pattern: '*.scss'
group: index
position: after
patternOptions:
matchBase: true
import/no-useless-path-segments: 2

import/no-cycle:
- error

no-restricted-imports:
- warn
- patterns:
- lodash.*
- microfrontends/*
- '!microfrontends/ChildAppMounter'
- _mocks/*
paths:
- lodash
- name: yaml
importNames:
- stringify
message: 'Please use yamlStringify from @utils instead of this'
- name: react-router
message: 'import from "react-router-dom" instead'
- name: microfrontends
message: Import from 'microfrontends' is only allowed in child apps
- name: '@harness/uicore'
importNames:
- Color
- FontVariation
- Intent
- Spacing
message: import from "@harness/design-system" instead
no-restricted-syntax:
- error
- selector: "CallExpression[callee.name='useContext'][arguments.0.name='PipelineContext']"
message: 'Please use usePipelineContext instead'
- selector: "CallExpression[callee.object.name='React'][callee.property.name='useContext'][arguments.0.name='PipelineContext']"
message: 'Please use usePipelineContext instead'

overrides:
- files:
- '**/*.test.ts'
- '**/*.test.tsx'
rules:
'@typescript-eslint/no-magic-numbers': 0
'@typescript-eslint/no-non-null-assertion': 0
'@typescript-eslint/no-non-null-asserted-optional-chain': 0
'@typescript-eslint/no-explicit-any': 0
no-await-in-loop: 0
jest/consistent-test-it:
- 2
- fn: test
withinDescribe: test
jest/expect-expect: 2
jest/no-disabled-tests: 2
jest/no-commented-out-tests: 2
- files:
- services.tsx
rules:
'@typescript-eslint/explicit-function-return-type': 0
'@typescript-eslint/no-explicit-any': 0
20 changes: 20 additions & 0 deletions chaoscenter/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules
coverage
.nyc_output
reports
cypress-coverage
merged-coverage
.DS_Store
tsconfig.tmp
.idea
yarn-error.log
temp
dist/*
.yalc/
yalc.lock
.env
junit.xml
cypress/videos/
certificates
.npmrc
tasks.md
27 changes: 27 additions & 0 deletions chaoscenter/web/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

declare MATCH_PATH='chaoscenter/web/'

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

if [[ "$BRANCH" == "main" ]]; then
echo "\033[0;31;1mYou can't commit directly to main branch\033[0m"
exit 1
fi

if [[ "$BRANCH" =~ ^release\/.* ]]; then
echo "\033[0;31;1mYou cannot commit directly to release branch\033[0m"
exit 1
fi

declare LITMUS_UI_FILE_CHANGES=$(git diff --name-only --cached | grep $MATCH_PATH -c)

echo "\033[0;93mLITMUS_UI_FILE_CHANGES\033[0m ⟶ $LITMUS_UI_FILE_CHANGES"

if [[ $LITMUS_UI_FILE_CHANGES -gt 0 ]]
then
cd ./chaoscenter/web && yarn lint-staged
else
echo "\033[0;93mSkipping husky pre-commit hook in $MATCH_PATH folder\033[0m"
fi
36 changes: 36 additions & 0 deletions chaoscenter/web/.husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

declare MATCH_PATH='chaoscenter/web/'

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

echo "ON_BRANCH ⟶ $BRANCH"

declare REMOTE_EXISTS=$(git ls-remote --heads origin $BRANCH | wc -l)

declare CHECK_AGAINST_COMMIT

if [[ $REMOTE_EXISTS -gt 0 ]]
then
# remote exists, compare changes from last pushed commit
declare LAST_PUSHED_COMMIT_ID=$(git rev-parse --short @{push})
echo "LAST_PUSHED_COMMIT ⟶ $LAST_PUSHED_COMMIT_ID"
CHECK_AGAINST_COMMIT=$LAST_PUSHED_COMMIT_ID
else
# remote doesn't exists, compare changes from branched off commit
declare BRANCHED_COMMIT_ID=$(git rev-parse --short $(git merge-base main $BRANCH))
echo "BRANCHED_COMMIT_ID ⟶ $BRANCHED_COMMIT_ID"
CHECK_AGAINST_COMMIT=$BRANCHED_COMMIT_ID
fi

declare CHAOS_UI_FILE_CHANGES=$(git diff --name-only -r --stat --oneline $CHECK_AGAINST_COMMIT HEAD | grep $MATCH_PATH -c)

echo "CHAOS_UI_FILE_CHANGES ⟶ $CHAOS_UI_FILE_CHANGES"

if [[ $CHAOS_UI_FILE_CHANGES -gt 0 ]]
then
cd ./chaoscenter/web && yarn test:silent --changedSince=$CHECK_AGAINST_COMMIT
else
echo "Skipping husky pre-push hook in $MATCH_PATH folder"
fi
1 change: 1 addition & 0 deletions chaoscenter/web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/strings/types.ts
11 changes: 11 additions & 0 deletions chaoscenter/web/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
printWidth: 120
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
trailingComma: none
bracketSpacing: true
bracketSameLine: false
arrowParens: avoid
endOfLine: lf
34 changes: 34 additions & 0 deletions chaoscenter/web/config/moduleFederation.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const packageJSON = require('../package.json');
const { pick, mapValues } = require('lodash');

/**
* These packages must be stricly shared with exact versions
*/
const ExactSharedPackages = [
'react-dom',
'react',
'@blueprintjs/core',
'@blueprintjs/select',
'@blueprintjs/datetime',
'react-router-dom',
'restful-react',
'lodash-es'
];

/**
* @type {import('webpack').ModuleFederationPluginOptions}
*/
module.exports = {
name: 'chaos',
filename: 'remoteEntry.js',
exposes: {
'./MicroFrontendApp': './src/app/App'
},
shared: {
formik: packageJSON.dependencies['formik'],
...mapValues(pick(packageJSON.dependencies, ExactSharedPackages), version => ({
singleton: true,
requiredVersion: version
}))
}
};
13 changes: 13 additions & 0 deletions chaoscenter/web/config/pem.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

[ req ]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no

[v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names

[alt_names]
DNS.1 = localhost
Loading

0 comments on commit 712662c

Please sign in to comment.