Skip to content

Commit

Permalink
feat: set up basic website and catalog apps (#4) (#11)
Browse files Browse the repository at this point in the history
* chore: add gitignore and package jsons for website (4)

* feat: set up minimal website (#4)

* chore: remove unnecessary commitlint dependency (#4)

* chore: add commit message checks (#4)

* chore: add pre-commit checks (#4)

* chore: add github action to run checks on pull request (#4)

* feat: set up minimal catalog (#4)

* chore: update precommit hook to check both apps (#4)

* chore: update github action to check both apps (#4)

* fix: add blank favicons (#4)

* chore: use latest version of findable ui (#4)

* Fix PUBLIC_DIR creation when run in a new repo -- public won't exist and
we need to create /public/ as well as /public/favicons/

---------

Co-authored-by: Dannon Baker <[email protected]>
  • Loading branch information
hunterckx and dannon authored Aug 29, 2024
1 parent ebd02d9 commit 8661914
Show file tree
Hide file tree
Showing 74 changed files with 33,812 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run checks
on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "20.10.0"
- run: |
cd ./website
npm ci
npm run check-format
npm run lint
npx tsc --noEmit
cd ../data-catalog
npm ci
npm run check-format
npm run lint
npx tsc --noEmit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dependencies
/node_modules
18 changes: 18 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "Checking commit message"

# Check for issue number

commit_regex='#[0-9]'
error_msg="Aborting commit. Your commit message is missing a '#xxx' reference to a corresponding GitHub issue. Add '--no-verify' to your git commit command if you wish to skip this check."

if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi

# Check for Conventional Commits format

npx commitlint --config ./commitlint.config.js --edit $1
35 changes: 35 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

echo '🏗️👷 Checking your project before committing'

for app in "website" "data-catalog"
do
echo "\nChecking $app"

cd "./$app"

# Check Prettier
npm run check-format ||
(
echo '🤔 Prettier Check Failed. Run npx prettier --write . try commit again.';
false;
)

# Check ESLint
npm run lint ||
(
echo '🤔 ESLint Check Failed. Make the required changes listed above, add changes and try to commit again.'
false;
)

# Check TypeScript
npx tsc --noEmit ||
(
echo 'TypeScript compile failed';
false;
)
echo 'TypeScript compile succeeded!'

cd ..
done
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
Empty file added data-catalog/.env
Empty file.
2 changes: 2 additions & 0 deletions data-catalog/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules/*
**/.next/*
71 changes: 71 additions & 0 deletions data-catalog/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"sonarjs",
"jsdoc",
"sort-destructure-keys",
"typescript-sort-keys",
"react-hooks"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended",
"next",
"plugin:sonarjs/recommended",
"plugin:eslint-comments/recommended"
],
"rules": {
"sort-keys": [
"error",
"asc",
{
"caseSensitive": true,
"minKeys": 2,
"natural": false
}
],
"sort-destructure-keys/sort-destructure-keys": [
"error",
{
"caseSensitive": false
}
],
"typescript-sort-keys/interface": [
"error",
"asc",
{
"caseSensitive": false
}
],
"typescript-sort-keys/string-enum": [
"error",
"asc",
{
"caseSensitive": false
}
],
"eslint-comments/require-description": "error",
"jsdoc/require-description": "error",
"jsdoc/require-param": "error",
"jsdoc/require-param-name": "error",
"jsdoc/require-param-description": "error",
"jsdoc/require-hyphen-before-param-description": "error",
"jsdoc/require-returns": "error",
"jsdoc/require-returns-description": "error",
"jsdoc/check-alignment": "error",
"jsdoc/check-param-names": "error",
"react-hooks/exhaustive-deps": "error"
},
"overrides": [
{
"files": "**",
"excludedFiles": "*.styles.ts?(x)",
"rules": {
"@typescript-eslint/explicit-function-return-type": "error"
}
}
]
}
30 changes: 30 additions & 0 deletions data-catalog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# dependencies
/node_modules

# next.js
/.next/

# misc
.DS_Store
*.pem

# debug
npm-debug.log*

# env files
/.env*.local
/.env.development
/.env.production

# typescript
*.tsbuildinfo

# editors
/.vscode
.idea

# nvm
.nvmrc

# favicons
/public/favicons/*
5 changes: 5 additions & 0 deletions data-catalog/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# next.js
.next

# dependencies
node_modules
1 change: 1 addition & 0 deletions data-catalog/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface BRCDataCatalogGenome {
species: string;
}
1 change: 1 addition & 0 deletions data-catalog/app/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { BasicCell } from "@databiosphere/findable-ui/lib/components/Table/components/TableCell/components/BasicCell/basicCell";
31 changes: 31 additions & 0 deletions data-catalog/app/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { setConfig } from "@databiosphere/findable-ui/lib/config/config";
import { SiteConfig } from "@databiosphere/findable-ui/lib/config/entities";
import brcAnalyticsCatalogLocal from "../../site-config/brc-analytics-catalog/local/config";
const CONFIGS: { [k: string]: SiteConfig } = {
"brc-analytics-catalog-local": brcAnalyticsCatalogLocal,
};

let appConfig: SiteConfig | null = null;

export const config = (): SiteConfig => {
if (appConfig) {
return appConfig;
}

const config = process.env.NEXT_PUBLIC_SITE_CONFIG;

if (!config) {
console.error(`Config not found. config: ${config}`);
}

appConfig = CONFIGS[config as string];

if (!appConfig) {
console.error(`No app config was found for the config: ${config}`);
} else {
console.log(`Using app config ${config}`);
}

setConfig(appConfig); // Sets app config.
return appConfig;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { BRCDataCatalogGenome } from "../../../../apis/catalog/brc-analytics-catalog/common/entities";
import * as C from "../../../../components/index";

/**
* Build props for the species cell.
* @param genome - Genome entity.
* @returns Props to be used for the cell.
*/
export const buildSpecies = (
genome: BRCDataCatalogGenome
): React.ComponentProps<typeof C.BasicCell> => {
return {
value: genome.species,
};
};
1 change: 1 addition & 0 deletions data-catalog/files/out/genomes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{ "species": "Foo bar" }]
6 changes: 6 additions & 0 deletions data-catalog/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
83 changes: 83 additions & 0 deletions data-catalog/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import nextMDX from "@next/mdx";
import withPlugins from "next-compose-plugins";
import path from "path";

const ESM_PACKAGES = [
"axios",
"@databiosphere/findable-ui",
"@tanstack/react-table",
];

const withMDX = nextMDX({
extension: /\.mdx?$/,
});
export default withPlugins(
[[withMDX, { pageExtensions: ["md", "mdx", "ts", "tsx"] }]],
{
basePath: "",
experimental: {
instrumentationHook: true,
},
images: {
unoptimized: true,
},
reactStrictMode: true,
transpilePackages: [...ESM_PACKAGES],
webpack: (config) => {
// Add the alias for the peer dependency
config.resolve.alias["@emotion/react"] = path.resolve(
process.cwd(),
"node_modules/@emotion/react"
);
config.resolve.alias["@emotion/styled"] = path.resolve(
process.cwd(),
"node_modules/@emotion/styled"
);
config.resolve.alias["@mui/icons-material"] = path.resolve(
process.cwd(),
"node_modules/@mui/icons-material"
);
config.resolve.alias["@mui/material"] = path.resolve(
process.cwd(),
"node_modules/@mui/material"
);
config.resolve.alias["react-dropzone"] = path.resolve(
process.cwd(),
"node_modules/react-dropzone"
);
config.resolve.alias["isomorphic-dompurify"] = path.resolve(
process.cwd(),
"node_modules/isomorphic-dompurify"
);
config.resolve.alias["next"] = path.resolve(
process.cwd(),
"node_modules/next"
);
config.resolve.alias["react"] = path.resolve(
process.cwd(),
"node_modules/react"
);
config.resolve.alias["react-dom"] = path.resolve(
process.cwd(),
"node_modules/react-dom"
);
config.resolve.alias["react-gtm-module"] = path.resolve(
process.cwd(),
"node_modules/react-gtm-module"
);
config.resolve.alias["react-window"] = path.resolve(
process.cwd(),
"node_modules/react-window"
);
config.resolve.alias["uuid"] = path.resolve(
process.cwd(),
"node_modules/uuid"
);
config.resolve.alias["validate.js"] = path.resolve(
process.cwd(),
"node_modules/validate.js"
);
return config;
},
}
);
Loading

0 comments on commit 8661914

Please sign in to comment.