Skip to content

Commit

Permalink
Merge pull request #908 from 3YOURMIND/turborepo
Browse files Browse the repository at this point in the history
dx(build): Cache with Turborepo for Performance
  • Loading branch information
FlorianWendelborn authored Apr 3, 2024
2 parents f389758 + ebe7483 commit 34cd8fe
Show file tree
Hide file tree
Showing 26 changed files with 307 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = {
},
overrides: [
{
files: ['packages/kotti-ui/**/*.{ts,js,vue}'],
files: ['packages/kotti-ui/**/*.{ts,js,json,vue}'],
rules: {
...noExtraneousDependenciesOverride('kotti-ui'),
},
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ jobs:
key: ${{ hashFiles('**/yarn.lock') }}
- name: Install modules
run: yarn install --frozen-lockfile
- run: ./scripts/build-kotti.sh
- name: Run Publint
run: yarn run check:publint
gh-pages-dry-run:
Expand All @@ -121,7 +120,5 @@ jobs:
key: ${{ hashFiles('**/yarn.lock') }}
- name: Install modules
run: yarn install --frozen-lockfile
- name: Build Kotti & its dependencies
run: ./scripts/build-kotti.sh
- name: Build @3yourmind/documentation
run: yarn workspace @3yourmind/documentation run build
run: yarn run turbo run --filter=@3yourmind/documentation build
4 changes: 1 addition & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ jobs:
key: ${{ hashFiles('**/yarn.lock') }}
- name: Install modules
run: yarn install --frozen-lockfile
- name: Build Kotti & its dependencies
run: yarn run build:kotti
- name: Build @3yourmind/documentation
run: yarn workspace @3yourmind/documentation run build
run: yarn run turbo run --filter=@3yourmind/documentation build
- name: Deploy
uses: JamesIves/[email protected]
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.nuxt/
.turbo/
dist/
gh-pages/
node_modules/
packages/kotti-ui/report.*.html
packages/yoco/fonts/
*.log

# vite config gets transpiled in-place for a short moment
vite.config.ts.timestamp*
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint"
"stylelint.vscode-stylelint",
"Vercel.turbo-vsc"
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ yarn install
4. Build Kotti. Make sure it builds successfully.

```bash
yarn run build:kotti
yarn run turbo run --filter=@3yourmind/kotti-ui build
```

5. Optional: If you haven't already, make sure to functionally test:
Expand Down Expand Up @@ -245,7 +245,7 @@ npm login
7. Build yoco

```bash
yarn --cwd packages/yoco run build
yarn run turbo run --filter=@3yourmind/yoco build
```

8. Publish. Lerna will auto-detect the packages whose versions got updated in `package.json` and ask you to confirm the packages to be updated and their corresponding versions.
Expand All @@ -259,7 +259,7 @@ yarn run lerna publish from-package
### Build

```bash
yarn run lerna run build
yarn run build
```

## Internals
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vue/eslint-config-typescript": "^12.0.0",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -73,6 +72,7 @@
"stylelint-config-standard-scss": "^10.0.0",
"stylelint-csstree-validator": "^3.0.0",
"stylelint-prettier": "^4.0.2",
"turbo": "^1.13.2",
"typescript": "^5.3",
"unimported": "1.31.1"
},
Expand Down Expand Up @@ -108,21 +108,21 @@
"private": true,
"repository": "[email protected]:3YOURMIND/kotti",
"scripts": {
"build:kotti": "./scripts/build-kotti.sh",
"check": "concurrently \"yarn run check:eslint\" \"yarn run check:prettier\" \"yarn run check:publint\" \"yarn run check:stylelint\"",
"check:eslint": "eslint --max-warnings=0 --ignore-path .gitignore '**/*.{js,json,ts,vue}'",
"check:prettier": "prettier --check --ignore-path .gitignore .",
"check:publint": "lerna run --no-private check:publint",
"check:stylelint": "stylelint 'packages/**/*.{css,scss,vue}'",
"check:unimported": "lerna run check:unimported",
"fix": "yarn run fix:eslint && yarn run fix:stylelint && yarn run fix:prettier",
"fix:eslint": "yarn run check:eslint --fix",
"fix:prettier": "prettier --write --ignore-path .gitignore .",
"fix:stylelint": "yarn run check:stylelint --fix",
"build": "turbo run build",
"check": "turbo run check",
"check:eslint": "turbo run check:eslint",
"check:prettier": "turbo run check:prettier",
"check:publint": "turbo run check:publint",
"check:stylelint": "turbo run check:stylelint",
"check:unimported": "turbo run check:unimported",
"fix": "turbo run fix",
"fix:eslint": "turbo run fix:eslint",
"fix:prettier": "turbo run fix:prettier",
"fix:stylelint": "turbo run fix:stylelint",
"prepare": "husky install",
"prepublishOnly": "yarn run check && lerna run --no-private build",
"test": "yarn --cwd packages/kotti-ui run vitest --typecheck",
"watch": "./scripts/watch.sh"
"prepublishOnly": "turbo run check build",
"test": "turbo run test",
"watch": "nodemon -e js,ts,vue,scss,css,json --watch packages/vue-use-tippy/source --watch packages/yoco/source --exec \"turbo run watch\""
},
"version": "1.0.0",
"workspaces": [
Expand Down
13 changes: 13 additions & 0 deletions packages/documentation/.unimportedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"entry": [
"pages/**/*.vue",
"layouts/**/*.vue",
"plugins/**/*.js",
"nuxt.config.ts"
],
"extensions": [".js", ".ts", ".vue"],
"ignorePatterns": ["**/node_modules/**", "**/dist/**"],
"ignoreUnimported": ["shims-*"],
"ignoreUnresolved": [],
"ignoreUnused": ["core-js"]
}
13 changes: 5 additions & 8 deletions packages/documentation/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ const config: NuxtConfig = {
],
},
buildModules: ['@nuxt/typescript-build'],
}

if (process.env.DEPLOY_ENV === 'GH_PAGES') {
config.generate = {
dir: 'gh-pages',
}
config.router = {
generate: {
dir: 'dist',
},
router: {
base: '/kotti/',
}
},
}

module.exports = config
11 changes: 9 additions & 2 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@
},
"private": true,
"scripts": {
"build": "DEPLOY_ENV=GH_PAGES nuxt generate",
"build": "nuxt generate",
"check:eslint": "yarn --cwd ../.. run eslint --max-warnings=0 --ignore-path=.gitignore ./packages/documentation",
"check:prettier": "yarn --cwd ../.. run prettier --check --ignore-path=.gitignore ./packages/documentation",
"check:stylelint": "stylelint './**/*.{css,scss,vue}'",
"check:unimported": "unimported --no-cache",
"fix:eslint": "yarn run check:eslint --fix",
"fix:prettier": "yarn run check:prettier --write",
"fix:stylelint": "yarn run check:stylelint --fix",
"format": "prettier --write **/*.{vue,js,json,ts,md}",
"serve": "nuxt"
"watch": "nuxt"
},
"version": "2.0.0"
}
30 changes: 14 additions & 16 deletions packages/documentation/pages/foundations/icons/typescript.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,21 @@ console.log(Yoco.Icon.ANNOUNCE)
### Vue Example

```html
<templateTag>
<i class="yoco" v-text="Yoco.Icon.ANNOUNCE" />
</templateTag>
<i class="yoco" v-text="Yoco.Icon.ANNOUNCE" />
```

<script lang="ts">
import { Yoco } from '@3yourmind/yoco'
import { defineComponent } from 'vue'
export default defineComponent({
name: 'Example',
setup() {
return {
Yoco,
}
},
})
</script>
```ts
import { Yoco } from '@3yourmind/yoco'
import { defineComponent } from 'vue'

export default defineComponent({
name: 'Example',
setup() {
return {
Yoco,
}
},
})
```

### Details
Expand Down
12 changes: 12 additions & 0 deletions packages/documentation/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {
"check:publint": {
"dependsOn": []
},
"watch": {
"dependsOn": ["^build"]
}
}
}
1 change: 1 addition & 0 deletions packages/kotti-ui/.unimportedrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"source/test-utils/**",
"vite.config.ts"
],
"ignoreUnresolved": [],
"ignoreUnused": ["core-js", "normalize.css"]
}
15 changes: 11 additions & 4 deletions packages/kotti-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,20 @@
"url": "git+https://github.com/3YOURMIND/kotti.git"
},
"scripts": {
"build": "rm -rf dist && yarn run build:tokens && yarn run build:vite",
"build:tokens": "node tokens/generate.js && prettier --write source/kotti-style/tokens.css",
"build:vite": "vite build",
"build:vue-tsc": "vue-tsc --declaration --emitDeclarationOnly",
"check:unimported": "unimported --no-cache",
"build:vue-tsc": "./scripts/build-vue-tsc.sh",
"check:eslint": "yarn --cwd ../.. run eslint --max-warnings=0 --ignore-path=.gitignore ./packages/kotti-ui",
"check:prettier": "yarn --cwd ../.. run prettier --check --ignore-path=.gitignore ./packages/kotti-ui",
"check:publint": "publint",
"format": "prettier --write '**/*.{vue,js,json,ts,md}'"
"check:stylelint": "stylelint 'source/**/*.{css,scss,vue}'",
"check:unimported": "unimported --no-cache",
"fix:eslint": "yarn run check:eslint --fix",
"fix:prettier": "yarn run check:prettier --write",
"fix:stylelint": "yarn run check:stylelint --fix",
"format": "prettier --write '**/*.{vue,js,json,ts,md}'",
"test": "vitest --run --typecheck",
"watch": "vite build --watch"
},
"sideEffects": [
"./dist/style.css"
Expand Down
20 changes: 20 additions & 0 deletions packages/kotti-ui/scripts/build-vue-tsc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -euo pipefail

# this directory is assumed to exist, so create it
mkdir -p dist

# delete all output files of vue-tsc in dist folder:
## - *.d.ts
find ./dist -type f -name "*.d.ts" -delete
## - *.cts
find ./dist -type f -name "*.cts" -delete
## - empty directories that previously contained the above files
find ./dist -type d -empty -delete

# generate types
vue-tsc --declaration --emitDeclarationOnly

# HACK: duplicate index.d.ts in order to calm down publint
cp ./dist/index.d.ts ./dist/index.d.cts
39 changes: 39 additions & 0 deletions packages/kotti-ui/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {
"build": {
"dependsOn": ["^build", "build:vue-tsc", "build:vite", "build:tokens"]
},
"build:tokens": {
"inputs": ["./tokens/**"],
"outputMode": "new-only",
"outputs": ["./source/kotti-style/tokens.css"]
},
"build:vite": {
"dependsOn": ["^build"],
"inputs": ["vite.config.ts", "source/**", "tsconfig*.json"],
"outputMode": "new-only",
"outputs": [
"./dist/kotti-ui.*",
"./dist/variables.scss",
"./dist/style.css"
]
},
"build:vue-tsc": {
"dependsOn": ["^build"],
"inputs": ["source/**", "tsconfig*.json"],
"outputMode": "new-only",
"outputs": ["./dist/**/*.{cts,d.ts}"]
},
"test": {
"dependsOn": ["^build"],
"inputs": ["source/**", "tsconfig*.json", "vite.config.ts"],
"outputMode": "new-only",
"outputs": []
},
"watch": {
"dependsOn": ["build"]
}
}
}
8 changes: 8 additions & 0 deletions packages/vue-use-tippy/.unimportedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"entry": ["source/index.ts"],
"extensions": [".ts"],
"ignorePatterns": ["**/node_modules/**", "**/dist/**"],
"ignoreUnimported": [],
"ignoreUnresolved": [],
"ignoreUnused": []
}
7 changes: 6 additions & 1 deletion packages/vue-use-tippy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
},
"scripts": {
"build": "./scripts/build.sh",
"check:publint": "publint"
"check:eslint": "yarn --cwd ../.. run eslint --max-warnings=0 --ignore-path=.gitignore ./packages/vue-use-tippy",
"check:prettier": "yarn --cwd ../.. run prettier --check --ignore-path=.gitignore ./packages/vue-use-tippy",
"check:publint": "publint",
"check:unimported": "unimported --no-cache",
"fix:eslint": "yarn run check:eslint --fix",
"fix:prettier": "yarn run check:prettier --write"
},
"type": "module",
"types": "./dist/mjs/index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions packages/vue-use-tippy/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {
"build": {
"inputs": ["./scripts/**", "./source/**", "tsconfig.*"],
"outputMode": "new-only",
"outputs": ["./dist/**"]
}
}
}
8 changes: 8 additions & 0 deletions packages/yoco/.unimportedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"entry": ["source/generate.ts", "source/index.ts"],
"extensions": [".ts"],
"ignorePatterns": ["**/node_modules/**", "**/dist/**"],
"ignoreUnimported": [],
"ignoreUnresolved": [["./index.js", ["source/generate.ts"]]],
"ignoreUnused": []
}
8 changes: 7 additions & 1 deletion packages/yoco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@
"repository": "git+https://github.com/3YOURMIND/kotti.git",
"scripts": {
"build": "./scripts/build.sh",
"check:publint": "publint"
"check:eslint": "yarn --cwd ../.. run eslint --max-warnings=0 --ignore-path=.gitignore ./packages/yoco",
"check:prettier": "yarn --cwd ../.. run prettier --check --ignore-path=.gitignore ./packages/yoco",
"check:publint": "publint",
"check:stylelint": "stylelint style.css",
"check:unimported": "unimported --no-cache",
"fix:eslint": "yarn run check:eslint --fix",
"fix:prettier": "yarn run check:prettier --write"
},
"style": "./style.css",
"type": "module",
Expand Down
Loading

0 comments on commit 34cd8fe

Please sign in to comment.