Skip to content

Commit

Permalink
✨ Set up turborepo (#31)
Browse files Browse the repository at this point in the history
- install `turbo`, remove `nps`
- fix turbo config
- lint
- Remove `package-scripts.yml`
- Update README.md
- Update static analysis GH workflow
  • Loading branch information
sripwoud authored Aug 14, 2023
1 parent f2657f3 commit dbd1b19
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 323 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-

- name: Setup turbo cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: turbo-${{ github.job }}-${{ github.ref_name }}-

- name: Install
run: pnpm i --ignore-scripts

- name: Validate
run: pnpm run nps v.ci
run: pnpm validate
14 changes: 11 additions & 3 deletions .github/workflows/coveralls.yaml → .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Coverage Report
name: Test Coverage
on:
# push trigger required to get coveralls monitoring of default branch
# pull_request required to get PR comments
Expand All @@ -9,7 +9,7 @@ on:
paths-ignore: ['**/*md', '**/*yaml', '**/*yml']

jobs:
coveralls:
test:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -40,11 +40,19 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-

- name: Setup turbo cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: turbo-${{ github.job }}-${{ github.ref_name }}-

- name: Install
run: pnpm i --ignore-scripts --reporter=silent

- name: Test
run: pnpm run nps t.ci
run: pnpm test

- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ coverage
.idea

.env

.turbo
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

node_modules/.bin/nps precommit
pnpm precommit
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ COPY .npmrc package.json pnpm-lock.yaml ./
RUN pnpm i -P --frozen-lockfile --ignore-scripts --reporter=silent
RUN pnpm i reflect-metadata ts-node-dev tsconfig-paths tslib typescript

COPY .env package-scripts.yaml tsconfig.json tsconfig.compile.json .barrelsby.json ./
COPY .env tsconfig.json tsconfig.compile.json .barrelsby.json ./
COPY src src

COPY scripts/secrets-entrypoint.sh /usr/local/bin/secrets-entrypoint.sh
RUN chmod +x /usr/local/bin/secrets-entrypoint.sh
ENTRYPOINT ["secrets-entrypoint.sh"]

RUN nps build
RUN pnpm build

CMD ["nps", "start.prod"]
CMD ["pnpm", "start.prod"]

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
| Feature | With | Configuration File |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Typings | [Typescript](https://www.typescriptlang.org/) | [tsconfig.json](./tsconfig.json) |
| Scripts | [Nps](https://github.com/sezna/nps) | [package-scripts.yaml](./package-scripts.yaml) |
| Testing | [Jest](https://jestjs.io/), [ts-jest](https://kulshekhar.github.io/ts-jest/) | [jest.config.ts](test/jest.config.ts) |
| Coverage reports | [Coveralls](https://coveralls.io/) | [Coveralls GitHub Action](https://github.com/marketplace/actions/coveralls-github-action) |
| Linting | [Eslint](https://eslint.org/) | [.eslintrc.yaml](./.eslintrc.yaml) |
Expand All @@ -22,15 +21,15 @@
| Rollup exports | [Barrelsby](https://github.com/bencoveney/barrelsby) | [.barrelsby.json](./.barrelsby.json) |
| Containerization | [Docker](https://www.docker.com/) | [Dockerfile](./Dockerfile), [docker-compose.yaml](./docker-compose.yaml) |
| Pre-commit hook (linting, formatting) | [Husky](https://typicode.github.io/husky), [lint-staged](https://github.com/okonet/lint-staged) | [pre-commit](./.husky/pre-commit), [.lintstagedrc.yaml](./.lintstagedrc.yaml) |
| Security Checks | [Snyk](https://snyk.io/) | [snyk.yaml](./.github/workflows/snyk.yaml) |
| Build System / Caching | [Turborepo](https://turbo.build) | [turbo.json](./turbo.json) |

## Start

Node

```commandline
npm run setup
nps start
pnpm start
```

Docker
Expand Down
74 changes: 0 additions & 74 deletions package-scripts.yaml

This file was deleted.

33 changes: 24 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
{
"name": "ts-template",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"nps": "nps",
"barrels": "barrelsby --config .barrelsby.json",
"_build": "pnpm barrels && rm -rf dist && tsc --project tsconfig.compile.json",
"build": "turbo run _build",
"clean": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +",
"fix": "turbo _format _lint",
"_lint": "eslint --ext .js,.jsx,.ts,.tsx --fix .",
"lint": "turbo run _lint",
"_lint.check": "eslint --ext .js,.jsx,.ts,.tsx .",
"lint.check": "turbo run _lint.check",
"_format": "prettier --write .",
"format": "turbo run _format",
"_format.check": "prettier --check .",
"format.check": "turbo run _format.check",
"precommit": "tsc && pnpm barrels && lint-staged",
"prepare": "husky install",
"setup": "pnpm 2> /dev/null || npm i -g pnpm && pnpm i"
"setup": "pnpm 2> /dev/null || npm i -g pnpm && pnpm i",
"start": "pnpm build && pnpm start.prod",
"start.dev": "NODE_ENV=development tsnd --cls --exit-child --ignore-watch node_modules --quiet --respawn --rs --transpile-only -r tsconfig-paths/register src",
"start.prod": "NODE_ENV=production node -r module-alias/register dist",
"test": "turbo run _test --cache-dir=.turbo",
"test.watch": "pnpm _test --watch --coverage=false",
"_test": "jest --config test/jest.config.ts",
"validate": "turbo _format.check _lint.check --cache-dir=.turbo"
},
"_moduleAliases": {
"@mod": "dist/mod"
},
"author": "r1oga",
"license": "ISC",
"devDependencies": {
"@r1oga/eslint-config": "1.1.8",
"@r1oga/prettier-config": "1.1.11",
Expand All @@ -36,13 +51,13 @@
"ts-node-dev": "^2.0.0",
"tsconfig-paths": "^4.1.0",
"tslib": "^2.4.1",
"turbo": "^1.10.12",
"typescript": "^4.9.4"
},
"dependencies": {
"barrelsby": "^2.5.1",
"concurrently": "^7.6.0",
"module-alias": "^2.2.2",
"nps": "^5.10.0"
"module-alias": "^2.2.2"
},
"engines": {
"node": ">=19"
Expand Down
Loading

0 comments on commit dbd1b19

Please sign in to comment.