diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..6e3c7d8 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,2 @@ +# Run pre-commit hooks for commit-msg stage +pre-commit run --hook-stage commit-msg --commit-msg-filename "$1" diff --git a/.husky/pre-commit b/.husky/pre-commit index 7f1e6bd..d8f48dd 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,13 +1,12 @@ # Lint FE code -echo "Formatting and linting FE code" +echo "Formatting and linting FE code..." pnpm exec lint-staged # Capture list of staged files STAGED_FILES=$(git diff --name-only --cached) - # Format BE code -echo "Formatting BE code" -pre-commit run +echo "Formatting BE code..." +pre-commit run --all-files -echo "Committing changes" \ No newline at end of file +# You may want to consider also running `pre-commit autoupdate` periodically to keep hooks updated. \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38c8d6c..ea253cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,35 @@ -files: '^java/.*java' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v6.0.0 hooks: - id: check-merge-conflict - id: end-of-file-fixer + files: '^(java/.*\.java|py.*\.py)$' - id: trailing-whitespace + files: '^(java/.*\.java|py.*\.py)$' - id: mixed-line-ending args: ['--fix=auto'] + files: '^(java/.*\.java|py.*\.py)$' - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks rev: v2.15.0 hooks: - id: pretty-format-java args: [--autofix, --google-java-formatter-version=1.28.0] + files: '^java/.*\.java$' - repo: https://github.com/commitizen-tools/commitizen rev: v3.10.0 hooks: - id: commitizen stages: [commit-msg] + - repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black + language_version: python3 + files: '^py.*\.py$' + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: ['--profile', 'black'] + files: '^py.*\.py$' diff --git a/README.md b/README.md index 7810ea2..bee60f6 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,13 @@ This repository includes several tools to help maintain code quality: - [ESLint](https://eslint.org/docs/latest/use/core-concepts/): Checks your front-end code for quality and common errors. - [pre-commit](https://pre-commit.com/): Ensures code formatting and quality checks are run before committing (primarily for back-end code). - [lint-staged](https://github.com/okonet/lint-staged): Runs Prettier and ESLint on staged files before each commit to prevent bad code from being pushed. + - Note: if you are a Mac user, and your commits are erroring out with the message `" not foundECURSIVE_EXEC_FIRST_FAIL  Command "lint-staged`, then you likely need to change your line-endings in `./husky/pre-commit` and `./husky/commit-msg` from CRLF to LF. +- [commitizen](https://www.conventionalcommits.org/en/v1.0.0/): This pre-commit hook uses conventional commit syntax. Check this link out to understand how to format your commit messages. Here are some common examples: + - `feat: Major feature added` + - `docs: Documentation changed/updated` + - `fix: Bug fixed and code restored to working state` + - `refactor(style): Changed some code around to adhere to better style` + - `chore: Some update/chore that you've been needing to do` --- diff --git a/client/src/pages/HomePage.tsx b/client/src/pages/HomePage.tsx index bd6f329..d9301cc 100644 --- a/client/src/pages/HomePage.tsx +++ b/client/src/pages/HomePage.tsx @@ -1,8 +1,36 @@ +import { useLoadingPixel } from '@/hooks'; +import { Stack, Typography } from '@mui/material'; + /** * Renders the home page. * * @component */ export const HomePage = () => { - return
Home page
; + const [data, isLoading] = useLoadingPixel('HelloUser()'); + + return ( + + Home page + + Welcome to the SEMOSS Template application! This repository is + meant to be a starting point for your own SEMOSS application. + + Example pixel call: + + + ); }; diff --git a/java/src/reactors/HelloWorldReactor.java b/java/src/reactors/HelloWorldReactor.java deleted file mode 100644 index f7c73ef..0000000 --- a/java/src/reactors/HelloWorldReactor.java +++ /dev/null @@ -1,19 +0,0 @@ -package reactors; - -import prerna.sablecc2.om.PixelDataType; -import prerna.sablecc2.om.nounmeta.NounMetadata; -import util.Constants; - -public class HelloWorldReactor extends AbstractProjectReactor { - - // Note: Has access to protected variables defined in AbstractProjectReactor - - @Override - protected NounMetadata doExecute() { - - // grabbing user from AbstractProjectReactor - String response = Constants.HELLO_WORLD + " " + user.getPrimaryLoginToken().getId(); - - return new NounMetadata(response, PixelDataType.CONST_STRING); - } -} diff --git a/java/src/reactors/example/HelloUserReactor.java b/java/src/reactors/example/HelloUserReactor.java new file mode 100644 index 0000000..5822d1b --- /dev/null +++ b/java/src/reactors/example/HelloUserReactor.java @@ -0,0 +1,35 @@ +package reactors.example; + +import prerna.sablecc2.om.PixelDataType; +import prerna.sablecc2.om.ReactorKeysEnum; +import prerna.sablecc2.om.nounmeta.NounMetadata; +import reactors.AbstractProjectReactor; + +public class HelloUserReactor extends AbstractProjectReactor { + + // Note: Has access to protected variables defined in AbstractProjectReactor + + public HelloUserReactor() { + + // list of keys the reactor is expecting + this.keysToGet = new String[] {ReactorKeysEnum.NAME.getKey()}; + + // 1 for required keys, 0 for optional + this.keyRequired = new int[] {0}; + } + + @Override + protected NounMetadata doExecute() { + + // returns null if the argument is not found + String name = this.keyValue.get(ReactorKeysEnum.NAME.getKey()); + + // if name is not provided, use the user's name + name = (name == null) ? user.getPrimaryLoginToken().getName() : name; + + // grabbing user from AbstractProjectReactor + String response = "Hello, " + name + "! Welcome to SEMOSS."; + + return new NounMetadata(response, PixelDataType.CONST_STRING); + } +} diff --git a/java/src/util/Constants.java b/java/src/util/Constants.java index 3e4a686..28656af 100644 --- a/java/src/util/Constants.java +++ b/java/src/util/Constants.java @@ -4,5 +4,4 @@ public class Constants { // TODO add any constants to be referenced in the project - public static final String HELLO_WORLD = "Hello World!"; } diff --git a/java/src/util/HelperMethods.java b/java/src/util/HelperMethods.java index b24968e..54954b0 100644 --- a/java/src/util/HelperMethods.java +++ b/java/src/util/HelperMethods.java @@ -1,10 +1,3 @@ package util; -import prerna.auth.User; - -public class HelperMethods { - - public static String getUserId(User user) { - return user.getPrimaryLoginToken().getId(); - } -} +public class HelperMethods {}