Skip to content

Commit

Permalink
chore: init monorepo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywu6 committed Aug 21, 2023
0 parents commit 9348e43
Show file tree
Hide file tree
Showing 48 changed files with 9,876 additions and 0 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
26 changes: 26 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/devcontainers/base:bullseye

RUN apt-get update \
&& apt-get install -y unzip curl

# Default non-root user
USER vscode

# Install fnm
RUN curl -fsSL https://fnm.vercel.app/install \
| bash -s -- --install-dir $HOME/.fnm

# Install Node
RUN $HOME/.fnm/fnm install 16.20 \
&& $HOME/.fnm/fnm default 16.20

# Install PNPM
RUN eval $($HOME/.fnm/fnm env) \
&& npm install -g pnpm \
&& SHELL=bash pnpm setup

# Install Rye
# https://rye-up.com/guide/installation/
RUN curl -fsS https://rye-up.com/get \
| RYE_INSTALL_OPTION=--yes bash \
&& echo '\nsource "$HOME/.rye/env"' >> $HOME/.bashrc
46 changes: 46 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "javascript-monorepo-template",
"build": {
"dockerfile": "Dockerfile"
},
"containerUser": "vscode",
"mounts": [
// https://github.com/pnpm/pnpm/issues/5803
{
"type": "volume",
"source": "${localWorkspaceFolderBasename}-node_modules",
"target": "${containerWorkspaceFolder}/node_modules"
}
],
"postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/post-create.sh",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"streetsidesoftware.code-spell-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"ms-python.black-formatter"
]
}
},
"forwardPorts": [3000, 8000],
"portsAttributes": {
"3000": {
"label": "Docusaurus",
"onAutoForward": "notify"
},
"8000": {
"label": "Umi",
"onAutoForward": "notify"
}
}
}
7 changes: 7 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# node_modules is mounted as a volume, fix permissions
sudo chown -R "$(id -un):$(id -gn)" node_modules

# set pnpm to use node_modules/.pnpm-store as store-dir to support hardlinks
pnpm config set store-dir $PWD/node_modules/.pnpm-store
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .git

.git

# packages

**/node_modules
**/.venv

# artifacts

**/__pycache__
**/build
**/dist
**/.dumi/tmp
**/.dumi/tmp-production

**/Dockerfile
**/*.Dockerfile
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length=88

[*.py]
indent_size = 4

[Makefile]
indent_style = tab
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!.dumi
.dumi/tmp
.dumi/tmp-production

**/dist/**/*.js
**/dist/**/*.cjs
**/dist/**/*.mjs
98 changes: 98 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
module.exports = {
root: true,

extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:promise/recommended',
'prettier',
],
plugins: ['import'],

env: {
node: true,
},
settings: {
react: {
version: '18',
},
},

rules: {
// common pitfalls
eqeqeq: 'error',
curly: 'error',

// stricter type correctness
'@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }],
'@typescript-eslint/no-shadow': [
'warn',
{
ignoreTypeValueShadow: true,
},
],

// react rules
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',

// no sloppiness
'no-console': ['error', { allow: ['error', 'warn'] }],

// import rules and fixes
'@typescript-eslint/consistent-type-imports': 'warn',
'import/newline-after-import': 'warn',
'import/order': [
'warn',
{
pathGroups: [
{
pattern: '@/**',
group: 'internal',
position: 'before',
},
],
distinctGroup: false,
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},

overrides: [
{
files: ['*.js', '*.cjs', '*.mjs', '*.jsx'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['*.mdx'],
extends: ['plugin:mdx/recommended'],
parserOptions: {
extensions: ['.mdx'],
},
rules: {
'react/jsx-no-undef': 'off',
'react/no-unescaped-entities': 'off',
'react/prop-types': 'off',
},
},
],
};
7 changes: 7 additions & 0 deletions .eslintrc.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: true,
extends: [require.resolve('./.eslintrc.js')],
rules: {
'no-console': 'off',
},
};
46 changes: 46 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Fix end-of-lines in Git versions older than 2.10
# https://github.com/git/git/blob/master/Documentation/RelNotes/2.10.0.txt#L248 # https://github.com/git/git/blob/master/Documentation/RelNotes/2.10.0.txt#L248
* text=auto eol=lf

# ===
# Binary Files (don't diff, don't fix line endings)
# ===

# Images
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.tiff binary

# Fonts
*.oft binary
*.ttf binary
*.eot binary
*.woff binary
*.woff2 binary

# Videos
*.mov binary
*.mp4 binary
*.webm binary
*.ogg binary
*.mpg binary
*.3gp binary
*.avi binary
*.wmv binary
*.flv binary
*.asf binary

# Audio
*.mp3 binary
*.wav binary
*.flac binary

# Compressed
*.gz binary
*.zip binary
*.7z binary
*.tar.gz binary
*.tgz binary
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: 'Code: CI'

on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
push:
branches:
- main

jobs:
ci:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ['16.20.x']
python-version: ['3.8.16', '3.9.x', '3.10.x']

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: nrwl/nx-set-shas@v3
# https://nx.dev/recipes/ci/monorepo-ci-github-actions
# https://github.com/marketplace/actions/nx-set-shas
with:
main-branch-name: 'main'

- name: Use Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements.lock
requirements-dev.lock
- name: Use PNPM
uses: pnpm/action-setup@v2
with:
version: ^8.6.0
run_install: false

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Cache Nx output
uses: actions/cache@v3
with:
path: node_modules/.cache/nx
key: |
cache-nx
-${{ runner.os }}
-${{ matrix.node-version }}
-${{ matrix.python-version }}
-${{ github.ref }}
- name: Setup projects
run: pnpm bootstrap

- name: Run linters and tests
run: pnpm run ci:affected
Loading

0 comments on commit 9348e43

Please sign in to comment.