Skip to content

Commit

Permalink
feat(turborepo): migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
eunchurn committed Aug 24, 2024
1 parent ff0f95b commit e65f887
Show file tree
Hide file tree
Showing 158 changed files with 13,553 additions and 29,162 deletions.
171 changes: 67 additions & 104 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -1,112 +1,75 @@
name: Node.js Package

on:
release:
types: [created]
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys:
|
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
yarn bootstrap --no-progress --concurrency 2
- name: Type Check
run: |
yarn typecheck
- name: Unit Test
run: |
yarn test --collectCoverage
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage1.xml,./coverage2.xml
flags: unittests
name: codecov-umbrella
- name: Build
run: |
yarn tsc
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys:
|
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
yarn bootstrap --no-progress --concurrency 2
- name: "Publish to Node Package Manager"
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@eunchurn"
npm config list
echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_AUTH_TOKEN}}" > ~/.npmrc
# npm publish --access public
npm config set access public
yarn lerna:publish:npm
env:
CI: true
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}

publish-gpr:
needs: build
runs-on: ubuntu-latest
steps:
- name: "Setup actions"
uses: actions/checkout@v3
- name: "npm/registry setup"
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
scope: '@eunchurn'
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_GITHUB_TOKEN}}
- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys:
|
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
yarn bootstrap --no-progress --concurrency 2
- name: "Publish to Github Package Registry"
run: |
echo "registry=https://npm.pkg.github.com/eunchurn" >> ~/.npmrc
# npm publish
yarn lerna:publish:github
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_GITHUB_TOKEN}}
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 9
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=pnpm" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Restore cache
uses: actions/cache@v3
with:
path: |
node_modules
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-
- name: Install dependencies
run: |
${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Unit Test
run: |
${{ steps.detect-package-manager.outputs.manager }} test
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: ${{ steps.detect-package-manager.outputs.manager }} publish-packages
env:
GITHUB_TOKEN: ${{ secrets.NPM_GITHUB_TOKEN }}
NPM_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
66 changes: 45 additions & 21 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,59 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [16.x, 18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 9
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=pnpm" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Restore cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys:
|
${{ runner.OS }}-build-
${{ runner.OS }}-
path: |
node_modules
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-
- name: Install dependencies
run: |
yarn install --immutable --immutable-cache --check-cache
- name: Lerna Bootstrap
run: |
yarn bootstrap --no-progress --concurrency 2
${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Unit Test
run: |
yarn test --collectCoverage
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage-final.json
flags: unittests
name: codecov-umbrella
${{ steps.detect-package-manager.outputs.manager }} test
# - uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./coverage/coverage-final.json
# flags: unittests
# name: codecov-umbrella
39 changes: 37 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage
.npmrc
.DS_Store

# next.js
.next/
out/
build

# other
dist/

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo

# test
junit.xml
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public-hoist-pattern[]=*
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"explorer.fileNesting.enabled": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false,
"yaml.extension.recommendations": false,
"git.detectSubmodulesLimit": 30,
"[yaml]": {
"editor.autoIndent": "advanced",
"editor.formatOnSave": false
},
"[github-actions-workflow]": {
"editor.autoIndent": "advanced"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
3 changes: 3 additions & 0 deletions apps/next-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@repo/eslint-config/next.js"],
};
34 changes: 34 additions & 0 deletions apps/next-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
28 changes: 28 additions & 0 deletions apps/next-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Getting Started

First, run the development server:

```bash
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `src/app/page.tsx`. The page auto-updates as you edit the file.

To create [API routes](https://nextjs.org/docs/app/building-your-application/routing/router-handlers) add an `api/` directory to the `app/` directory with a `route.ts` file. For individual endpoints, create a subfolder in the `api` directory, like `api/hello/route.ts` would map to [http://localhost:3000/api/hello](http://localhost:3000/api/hello).

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn/foundations/about-nextjs) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_source=github.com&utm_medium=referral&utm_campaign=turborepo-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Loading

0 comments on commit e65f887

Please sign in to comment.