docs: setup format/lint

This commit is contained in:
MapleLeaf
2021-12-29 13:32:47 -06:00
parent 38c5c74bc2
commit 3eae868f4e
9 changed files with 100 additions and 95 deletions

View File

@@ -4,3 +4,4 @@ node_modules
/build /build
/public/build /public/build
.env .env
.vscode

View File

@@ -0,0 +1,5 @@
node_modules
pnpm-lock.yaml
build
public/build

View File

@@ -1,53 +0,0 @@
# Welcome to Remix!
- [Remix Docs](https://remix.run/docs)
## Development
From your terminal:
```sh
npm run dev
```
This starts your app in development mode, rebuilding assets on file changes.
## Deployment
First, build your app for production:
```sh
npm run build
```
Then run the app in production mode:
```sh
npm start
```
Now you'll need to pick a host to deploy it to.
### DIY
If you're familiar with deploying node applications, the built-in Remix app server is production-ready.
Make sure to deploy the output of `remix build`
- `build/`
- `public/build/`
### Using a Template
When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server.
```sh
cd ..
# create a new project, and pick a pre-configured host
npx create-remix@latest
cd my-new-remix-app
# remove the new project's app (not the old one!)
rm -rf app
# copy your app over
cp -R ../my-old-remix-app/app app
```

View File

@@ -1,4 +1,4 @@
import { hydrate } from "react-dom"; import { hydrate } from "react-dom"
import { RemixBrowser } from "remix"; import { RemixBrowser } from "remix"
hydrate(<RemixBrowser />, document); hydrate(<RemixBrowser />, document)

View File

@@ -1,21 +1,21 @@
import { renderToString } from "react-dom/server"; import { renderToString } from "react-dom/server"
import { RemixServer } from "remix"; import { RemixServer } from "remix"
import type { EntryContext } from "remix"; import type { EntryContext } from "remix"
export default function handleRequest( export default function handleRequest(
request: Request, request: Request,
responseStatusCode: number, responseStatusCode: number,
responseHeaders: Headers, responseHeaders: Headers,
remixContext: EntryContext remixContext: EntryContext,
) { ) {
const markup = renderToString( const markup = renderToString(
<RemixServer context={remixContext} url={request.url} /> <RemixServer context={remixContext} url={request.url} />,
); )
responseHeaders.set("Content-Type", "text/html"); responseHeaders.set("Content-Type", "text/html")
return new Response("<!DOCTYPE html>" + markup, { return new Response("<!DOCTYPE html>" + markup, {
status: responseStatusCode, status: responseStatusCode,
headers: responseHeaders headers: responseHeaders,
}); })
} }

View File

@@ -4,13 +4,13 @@ import {
Meta, Meta,
Outlet, Outlet,
Scripts, Scripts,
ScrollRestoration ScrollRestoration,
} from "remix"; } from "remix"
import type { MetaFunction } from "remix"; import type { MetaFunction } from "remix"
export const meta: MetaFunction = () => { export const meta: MetaFunction = () => {
return { title: "New Remix App" }; return { title: "New Remix App" }
}; }
export default function App() { export default function App() {
return ( return (
@@ -28,5 +28,5 @@ export default function App() {
{process.env.NODE_ENV === "development" && <LiveReload />} {process.env.NODE_ENV === "development" && <LiveReload />}
</body> </body>
</html> </html>
); )
} }

View File

@@ -7,23 +7,48 @@
"prepare": "remix setup node", "prepare": "remix setup node",
"build": "remix build", "build": "remix build",
"dev": "remix dev", "dev": "remix dev",
"start": "remix-serve build" "start": "remix-serve build",
"lint": "eslint --ext js,ts,tsx .",
"lint-fix": "pnpm lint -- --fix",
"format": "prettier --write ."
}, },
"dependencies": { "dependencies": {
"@remix-run/react": "^1.1.1", "@remix-run/react": "^1.1.1",
"@remix-run/serve": "^1.1.1",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"remix": "^1.1.1", "remix": "^1.1.1"
"@remix-run/serve": "^1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@itsmapleleaf/configs": "^1.1.2",
"@remix-run/dev": "^1.1.1", "@remix-run/dev": "^1.1.1",
"@types/react": "^17.0.24", "@types/react": "^17.0.24",
"@types/react-dom": "^17.0.9", "@types/react-dom": "^17.0.9",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unicorn": "^39.0.0",
"prettier": "^2.5.1",
"typescript": "^4.1.2" "typescript": "^4.1.2"
}, },
"engines": { "engines": {
"node": ">=14" "node": ">=14"
}, },
"sideEffects": false "sideEffects": false,
"eslintConfig": {
"extends": [
"./node_modules/@itsmapleleaf/configs/eslint"
],
"ignorePatterns": [
"**/node_modules/**",
"**/.vscode/**"
]
},
"prettier": "@itsmapleleaf/configs/prettier"
} }

View File

@@ -7,5 +7,5 @@ module.exports = {
publicPath: "/build/", publicPath: "/build/",
serverBuildDirectory: "build", serverBuildDirectory: "build",
devServerPort: 8002, devServerPort: 8002,
ignoredRouteFiles: [".*"] ignoredRouteFiles: [".*"],
}; }

63
pnpm-lock.yaml generated
View File

@@ -4,33 +4,49 @@ importers:
packages/docs: packages/docs:
specifiers: specifiers:
'@itsmapleleaf/configs': ^1.1.2
'@remix-run/dev': ^1.1.1 '@remix-run/dev': ^1.1.1
'@remix-run/express': ^1.1.1
'@remix-run/react': ^1.1.1 '@remix-run/react': ^1.1.1
'@remix-run/serve': ^1.1.1
'@types/react': ^17.0.24 '@types/react': ^17.0.24
'@types/react-dom': ^17.0.9 '@types/react-dom': ^17.0.9
compression: ^1.7.4 '@typescript-eslint/eslint-plugin': ^5.8.1
cross-env: ^7.0.3 '@typescript-eslint/parser': ^5.8.1
express: ^4.17.1 eslint: ^8.5.0
morgan: ^1.10.0 eslint-config-prettier: ^8.3.0
eslint-import-resolver-typescript: ^2.5.0
eslint-plugin-import: ^2.25.3
eslint-plugin-jsx-a11y: ^6.5.1
eslint-plugin-react: ^7.28.0
eslint-plugin-react-hooks: ^4.3.0
eslint-plugin-unicorn: ^39.0.0
prettier: ^2.5.1
react: ^17.0.2 react: ^17.0.2
react-dom: ^17.0.2 react-dom: ^17.0.2
remix: ^1.1.1 remix: ^1.1.1
typescript: ^4.1.2 typescript: ^4.1.2
dependencies: dependencies:
'@remix-run/express': 1.1.1_c249933f376ca18b25ea8a9b07171fbd
'@remix-run/react': 1.1.1_react-dom@17.0.2+react@17.0.2 '@remix-run/react': 1.1.1_react-dom@17.0.2+react@17.0.2
compression: 1.7.4 '@remix-run/serve': 1.1.1_react-dom@17.0.2+react@17.0.2
cross-env: 7.0.3
express: 4.17.2
morgan: 1.10.0
react: 17.0.2 react: 17.0.2
react-dom: 17.0.2_react@17.0.2 react-dom: 17.0.2_react@17.0.2
remix: 1.1.1 remix: 1.1.1
devDependencies: devDependencies:
'@itsmapleleaf/configs': 1.1.2
'@remix-run/dev': 1.1.1 '@remix-run/dev': 1.1.1
'@types/react': 17.0.38 '@types/react': 17.0.38
'@types/react-dom': 17.0.11 '@types/react-dom': 17.0.11
'@typescript-eslint/eslint-plugin': 5.8.1_3a47348159e115370aa4cba56aba33b6
'@typescript-eslint/parser': 5.8.1_eslint@8.5.0+typescript@4.5.4
eslint: 8.5.0
eslint-config-prettier: 8.3.0_eslint@8.5.0
eslint-import-resolver-typescript: 2.5.0_f385d671d5f1c72a868db745a891bc1f
eslint-plugin-import: 2.25.3_eslint@8.5.0
eslint-plugin-jsx-a11y: 6.5.1_eslint@8.5.0
eslint-plugin-react: 7.28.0_eslint@8.5.0
eslint-plugin-react-hooks: 4.3.0_eslint@8.5.0
eslint-plugin-unicorn: 39.0.0_eslint@8.5.0
prettier: 2.5.1
typescript: 4.5.4 typescript: 4.5.4
packages/reacord: packages/reacord:
@@ -910,6 +926,19 @@ packages:
react-router-dom: 6.2.1_react-dom@17.0.2+react@17.0.2 react-router-dom: 6.2.1_react-dom@17.0.2+react@17.0.2
dev: false dev: false
/@remix-run/serve/1.1.1_react-dom@17.0.2+react@17.0.2:
resolution: {integrity: sha512-l9ibxAMFud808OjK0izIWwIP/jCuHsTBdV4FDA6K1Gwjom9uIHyXbBtJNIDYQuoSdRp7F2zM06TkT8jBXLKV2A==}
hasBin: true
dependencies:
'@remix-run/express': 1.1.1_c249933f376ca18b25ea8a9b07171fbd
compression: 1.7.4
express: 4.17.2
morgan: 1.10.0
transitivePeerDependencies:
- react
- react-dom
dev: false
/@remix-run/server-runtime/1.1.1_react-dom@17.0.2+react@17.0.2: /@remix-run/server-runtime/1.1.1_react-dom@17.0.2+react@17.0.2:
resolution: {integrity: sha512-uTTGSjCn2WTXUShruvTuErpbdbGoLu2dZ/zQ0ZHA0MMgP4VDA8xyuBeRcv/By3xqGcu2zSxcEGv7tRPgzU1AtA==} resolution: {integrity: sha512-uTTGSjCn2WTXUShruvTuErpbdbGoLu2dZ/zQ0ZHA0MMgP4VDA8xyuBeRcv/By3xqGcu2zSxcEGv7tRPgzU1AtA==}
peerDependencies: peerDependencies:
@@ -2434,14 +2463,6 @@ packages:
p-map: 3.0.0 p-map: 3.0.0
dev: true dev: true
/cross-env/7.0.3:
resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==}
engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'}
hasBin: true
dependencies:
cross-spawn: 7.0.3
dev: false
/cross-spawn/6.0.5: /cross-spawn/6.0.5:
resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==}
engines: {node: '>=4.8'} engines: {node: '>=4.8'}
@@ -2460,6 +2481,7 @@ packages:
path-key: 3.1.1 path-key: 3.1.1
shebang-command: 2.0.0 shebang-command: 2.0.0
which: 2.0.2 which: 2.0.2
dev: true
/crypto-random-string/2.0.0: /crypto-random-string/2.0.0:
resolution: {integrity: sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==} resolution: {integrity: sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==}
@@ -4982,6 +5004,7 @@ packages:
/isexe/2.0.0: /isexe/2.0.0:
resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=} resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=}
dev: true
/isobject/2.1.0: /isobject/2.1.0:
resolution: {integrity: sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=} resolution: {integrity: sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=}
@@ -7039,6 +7062,7 @@ packages:
/path-key/3.1.1: /path-key/3.1.1:
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true
/path-key/4.0.0: /path-key/4.0.0:
resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==}
@@ -7772,6 +7796,7 @@ packages:
engines: {node: '>=8'} engines: {node: '>=8'}
dependencies: dependencies:
shebang-regex: 3.0.0 shebang-regex: 3.0.0
dev: true
/shebang-regex/1.0.0: /shebang-regex/1.0.0:
resolution: {integrity: sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=} resolution: {integrity: sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=}
@@ -7781,6 +7806,7 @@ packages:
/shebang-regex/3.0.0: /shebang-regex/3.0.0:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true
/side-channel/1.0.4: /side-channel/1.0.4:
resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
@@ -8765,6 +8791,7 @@ packages:
hasBin: true hasBin: true
dependencies: dependencies:
isexe: 2.0.0 isexe: 2.0.0
dev: true
/widest-line/3.1.0: /widest-line/3.1.0:
resolution: {integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==} resolution: {integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==}