Skip to content

Commit

Permalink
Initial commit 🔪
Browse files Browse the repository at this point in the history
  • Loading branch information
jarry3369 committed Nov 20, 2023
0 parents commit b15c2ff
Show file tree
Hide file tree
Showing 34 changed files with 3,807 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true,
},
extends: [
"eslint:recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
],
parserOptions: {
ecmaVersion: 2023,
sourceType: "module",
},

overrides: [
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
],
rules: {
"import/named": "off",
"import/export": "off",
"import/default": "off",
"import/namespace": "off",
"import/no-unresolved": "warn",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"react/no-children-prop": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
},
plugins: ["@typescript-eslint"],
parserOptions: {
warnOnUnsupportedTypeScriptVersion: true,
},
},
{
files: [".eslintrc.cjs", "*/vite.config.ts", "scripts/**/*.js"],
env: { node: true },
},
{
files: ["*.cjs"],
parserOptions: { sourceType: "script" },
},
],

ignorePatterns: ["/.cache", "/.git", "/*/dist"],

settings: {
"import/resolver": {
typescript: {
project: ["app/tsconfig.json", "scripts/tsconfig.json"],
},
},
react: {
version: "detect",
},
},
};
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### fix.

#### tickets inf.

#### comment.

#### yikes shits.
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Compiled
/*/dist/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

.cache

.eslintcache

# Override Environment variables
*.override.env

# Visual Studio Code
# https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/settings.json
!.vscode/react.code-snippets

.idea

.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-linker=hoisted
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*/dist/

/.cache

/.github

# ts
/tsconfig.base.json
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "lf"
}
22 changes: 22 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"recommendations": [
"akamud.vscode-theme-onedark",
"formulahendry.auto-rename-tag",
"naumovs.color-highlight",
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint",
"figma.figma-vscode-extension",
"mhutchie.git-graph",
"github.remotehub",
"eamodio.gitlens",
"sidthesloth.html5-boilerplate",
"ecmel.vscode-html-css",
"yzhang.markdown-all-in-one",
"bierner.markdown-preview-github-styles",
"davidanson.vscode-markdownlint",
"pkief.material-icon-theme",
"esbenp.prettier-vscode",
"burkeholland.simple-react-snippets",
"simonsiefke.svg-preview"
]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Atom One Dark",
"bracket-pair-colorizer-2.depreciation-notice": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.foldingMaximumRegions": 10000,
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always",
"workbench.editor.enablePreview": false,
"workbench.editor.wrapTabs": true,
"git.confirmSync": false,
"vscord.status.problems.enabled": false,
"vscord.status.image.small.idle.text": "editing {file_extension}",
"vscord.status.button.active.enabled": false,
"vscord.ignore.workspacesText": "",
"vscord.status.details.text.idle": "editing {file_extension}",
"vscord.status.state.text.idle": "editing {file_extension}",
"vscord.status.image.large.idle.text": "editing {file_extension}",
"vscord.status.state.text.editing": "Working on...",
"vscord.status.details.enabled": false,
"editor.inlineSuggest.enabled": true,
"livePreview.hostIP": "222.110.133.193",
"livePreview.autoRefreshPreview": "On Changes to Saved Files",
"liveServer.settings.host": "222.110.133.193",
"liveServer.settings.donotShowInfoMsg": true,
"livePreview.httpHeaders": {
"Accept-Ranges": "bytes"
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 jarry3369

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# React Monorepo Boilerplate

template for building web applications with [React](https://react.dev/)

## Features

- Auto Page Routing based on File System
- Pre-configured with VSCode code snippets and other VSCode settings
- Pre-configured with code quality tools: ESLint, Prettier, TypeScript, Vitest, etc.

## Directory Structure

basically it's monopoe, so additional scripts or servers can be developed in repo

`├──`[`.github`](.github) — GitHub configuration including CI/CD workflows
`├──`[`.vscode`](.vscode) — VSCode settings, recommended extensions etc.
`├──`[`app`](./app) — Web application front-end built with [React](https://react.dev/)
`├──`[`env`](./env) — Application settings, API keys, etc.
`├──`[`scripts`](./scripts) — Automation scripts such as `deploy`
`├──`[`tsconfig.json`](./tsconfig.json) — The root TypeScript configuration
`└──`[`tsconfig.base.json`](./tsconfig.base.json) — The common/shared TypeScript configuration

## Tech Stack

- [React](https://react.dev/), [React Router](https://reactrouter.com/), [React Query](https://tanstack.com/query/)
- [Vite](https://vitejs.dev/), [Vitest](https://vitejs.dev/),
[TypeScript](https://www.typescriptlang.org/), [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [PNPm](https://pnpm.io/)

## Requirements

- [Node.js](https://nodejs.org/) v18+ with [Corepack](https://nodejs.org/api/corepack.html) (`$ corepack enable`)
- [VS Code](https://code.visualstudio.com/) editor with [recommended extensions](.vscode/extensions.json)
- Optionally [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en)
and [Reactime](https://chrome.google.com/webstore/detail/reactime/cgibknllccemdnfhfpmjhffpjfeidjga?hl=en) browser extensions

## Getting Started

[Generate](https://github.com/jarry3369/react-monorepo-boilerplate) a new project
from this template, clone, install dependencies, update the
environment variables found in [`env/*.env`](./env/), and enjoy party :

```bash
$ git clone https://github.com/jarry3369/react-monorepo-boilerplate.git [app_name]
$ cd [app_name]

# can spell just `pnpm i`
$ pnpm install
$ pnpm dev
```

**IMPORTANT**: Ensure that VSCode is using the workspace [version of TypeScript](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions)
and ESLint.

![](https://files.tarkus.me/typescript-workspace.png)

add dependencies for party,

```bash
# This command will install Package on root
$ pnpm add -w <NODE_PACKAGE_NAME>
# If you want to add a dependency for special Repo,
$ pnpm add --filter <MONOREPO_PACKAGE_NAME> <NODE_PACKAGE_NAME>
```

wanna remve dependencies from party,

```bash
# When used inside a workspace, removes a dependency (or dependencies) from every workspace package.
# can spell 'rm' or 'uninstall' or 'un' as well
$ pnpm remove -r <NODE_PACKAGE_NAME>
# If you want to remove dependency for special Repo,
$ pnpm remove --filter <MONOREPO_PACKAGE_NAME> <NODE_PACKAGE_NAME>
```

[check more infomations here](https://pnpm.io/cli/add)

## Scripts

- `pnpm dev` — Launches the app in development env
- `pnpm preview` — Launches the app in production env
- `pnpm test` — Run unit tests with Vitest, Supertest
- `pnpm build` — Run build for all projects in repository.

## How to Deploy

Ensure that all the environment variables for the target deployment environment in [`/env/*.env`](./env/) files are up-to-date.

```
$ pnpm build
- theres no automation deploy yet, but _will be update_
```

## MADE BY 🤡

<a href="https://github.com/jarry3369"><img src="https://avatars.githubusercontent.com/u/25889048?v=4" height="60" /></a>&nbsp;&nbsp;

## Update Scheduled Features

- Vitest setup
- CI/CD pipeline Scripts for [Amplify](https://aws.amazon.com/amplify/)

## License

[Copyright © 2023 @jarry3369](https://github.com/jarry3369/react-monorepo-boilerplate/blob/main/LICENSE)
11 changes: 11 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# APP_NAME

## NOTICE

**IMPORTANT**: you should not modify `./core` and root files like `..config..` or `index.tsx`. It might break your app cuz it's such a powerful hug 🤡.

## Directory Structure

`├──`[`core`](core) — Core Scripts
`├──`[`test`](test) — Test files // not setted yet
`└──`[`pages`](pages) — Set Domains and place Apps here. it will be automatically routed by your `file name`
Empty file added app/core/config.ts
Empty file.
48 changes: 48 additions & 0 deletions app/core/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Fragment } from "react";
import { Routes, Route } from "react-router-dom";

type servedType = {
[key: string | number | symbol]: any;
};

/**
* File System 기반 라우터
* 수정 금지
*/

const PRESERVED = import.meta.glob<Record<string, string>>("../pages/(_app|404).(js|jsx|ts|tsx)", {
eager: true,
});
const ROUTES = import.meta.glob<Record<string, string>>("../pages/**/[a-z[]*.(js|jsx|ts|tsx)", {
eager: true,
});

const preserve: servedType = Object.keys(PRESERVED).reduce((p, file) => {
const key = file.replace(/\.\.\/pages\/|\.(js|jsx|ts|tsx)$/g, "");
return { ...p, [key]: PRESERVED[file].default };
}, {});

const routes = Object.keys(ROUTES).map((route) => {
const path = route
.replace(/\.\.\/pages|index|\.(js|jsx|ts|tsx)$/g, "")
.replace(/\[\.{3}[^/]+\]/, "*")
.replace(/\[([^/]+)\]/g, ":$1");

return { path, component: ROUTES[route].default };
});

export default function FileRoutes() {
const App = preserve?.["_app"] || Fragment;
const NotFound = preserve?.["404"] || Fragment;

return (
<App>
<Routes>
{routes.map(({ path, component: Component = Fragment }) => {
return <Route key={path} path={path} element={<Component />} />;
})}
<Route path="*" element={<NotFound />} />
</Routes>
</App>
);
}
Loading

0 comments on commit b15c2ff

Please sign in to comment.