chore(library): implement turporepo (#206)

This commit is contained in:
Ayo Ayco 2022-11-23 20:05:07 +01:00 committed by GitHub
parent 89d1fde3d2
commit 7d05ecc580
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1302 additions and 26678 deletions

4
.eslintrc.cjs Normal file
View file

@ -0,0 +1,4 @@
/** @type {import("@types/eslint").Linter.Config} */
module.exports = {
extends: ["turbo"],
};

View file

@ -26,6 +26,7 @@ jobs:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: "npm" cache: "npm"
- run: npm ci - run: npm ci
- run: npm run clean
- run: npm run check - run: npm run check
- run: npm run test - run: npm run test-ci
- run: npm run lint - run: npm run lint

3
.gitignore vendored
View file

@ -11,3 +11,6 @@ pnpm-debug.log*
*~ *~
*swp *swp
*swo *swo
.turbo/

54
MONOREPO.md Normal file
View file

@ -0,0 +1,54 @@
# Monorepo Guide
This project is a monorepo configured with Turborepo + NPM workspace. Here are some common development scripts.
## Scripts
To clean and remove files, such as `node_modules`, `dist`, `.turbo` in every workspace.
```bash
npm run clean
```
Filtering workspaces. For more detail [https://turbo.build/repo/docs/core-concepts/monorepos/filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering).
```bash
# Append the `npm run` command with `-- --filter=<workspace>`
# with workspace name
npm run test -- --filter=validator
# Or equivalent
npm run test -- --filter=packages/validator
```
To run tests.
```bash
# Run all tests in every workspace.
npm run test
# Run test in selected workspace.
npm run test -- --filter=<workspace>
npm run test -- --filter=form
# Run test in watch mode. Can be filtered too.
npm run test:watch -- --filter=<workspace>
```
To lint workspaces.
```bash
# Lint all workspaces. Can be filtered.
npm run lint
# Lint and fix.
npm run lint:fix
```
To build workspaces.
```bash
# Build all workspaces. Can be filtered.
npm run build
```
To typecheck workspaces.
```bash
# Typecheck all workspaces. Can be filtered.
npm run check
```

View file

@ -11,11 +11,12 @@
"check": "astro check && tsc --noEmit && astro build", "check": "astro check && tsc --noEmit && astro build",
"build": "astro build", "build": "astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro",
"clean": "rimraf node_modules .turbo dist"
}, },
"dependencies": { "dependencies": {
"@astro-reactive/form": "file:packages/form", "@astro-reactive/form": "*",
"@astro-reactive/validator": "file:packages/validator", "@astro-reactive/validator": "*",
"astro": "^1.6.5" "astro": "^1.6.5"
}, },
"main": "index.js", "main": "index.js",
@ -27,5 +28,8 @@
"bugs": { "bugs": {
"url": "https://github.com/ayoayco/astro-reactive-library/issues" "url": "https://github.com/ayoayco/astro-reactive-library/issues"
}, },
"homepage": "https://github.com/ayoayco/astro-reactive-library#readme" "homepage": "https://github.com/ayoayco/astro-reactive-library#readme",
"devDependencies": {
"rimraf": "^3.0.2"
}
} }

10855
apps/docs/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,8 @@
"check": "astro check && tsc --noEmit && astro build", "check": "astro check && tsc --noEmit && astro build",
"build": "astro build", "build": "astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro",
"clean": "rimraf node_modules .turbo dist"
}, },
"dependencies": { "dependencies": {
"@algolia/client-search": "^4.13.1", "@algolia/client-search": "^4.13.1",
@ -31,12 +32,15 @@
"main": "index.js", "main": "index.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/Rishav-12/astro-reactive-library.git" "url": "git+https://github.com/ayoayco/astro-reactive-library.git"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"bugs": { "bugs": {
"url": "https://github.com/Rishav-12/astro-reactive-library/issues" "url": "https://github.com/ayoayco/astro-reactive-library/issues"
}, },
"homepage": "https://github.com/Rishav-12/astro-reactive-library#readme" "homepage": "https://github.com/ayoayco/astro-reactive-library#readme",
"devDependencies": {
"rimraf": "^3.0.2"
}
} }

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,7 @@
"preview": "astro preview", "preview": "astro preview",
"astro": "astro", "astro": "astro",
"format": "prettier --write .", "format": "prettier --write .",
"clean": "rimraf dist node_modules" "clean": "rimraf dist node_modules dist .turbo"
}, },
"devDependencies": { "devDependencies": {
"@astrojs/tailwind": "^2.0.2", "@astrojs/tailwind": "^2.0.2",

2341
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,31 +14,34 @@
".": "./index.ts" ".": "./index.ts"
}, },
"scripts": { "scripts": {
"start": "npm run dev -w apps/demo", "start": "turbo run dev --filter=demo",
"demo": "npm run dev -w apps/demo", "demo": "turbo run dev --filter=demo",
"docs": "npm run dev -w apps/docs", "docs": "turbo run dev --filter=docs",
"landing-page": "npm run dev -w apps/landing-page", "landing-page": "turbo run dev --filter=landing-page",
"test": "npm run test --workspaces --if-present", "test": "turbo run test",
"lint": "npm run lint --workspaces --if-present", "lint": "turbo run lint",
"lint:fix": "npm run lint:fix --workspaces --if-present", "lint:fix": "turbo run lint:fix",
"build": "npm run build --workspaces --if-present", "build": "turbo run build",
"check": "npm run check --workspaces --if-present", "check": "turbo run check",
"test:watch": "npm run test:watch --workspaces --if-present", "clean": "turbo clean",
"test:watch": "turbo run test:watch",
"patch": "npm version patch -w", "patch": "npm version patch -w",
"minor": "npm version minor -w", "minor": "npm version minor -w",
"major": "npm version major -w", "major": "npm version major -w",
"publish": "npm publish --access public -w" "publish": "turbo run lint build test && npm publish --access public -w",
"test-ci": "npm run test --workspaces --if-present"
}, },
"license": "ISC", "license": "ISC",
"workspaces": [ "workspaces": [
"packages/form", "packages/*",
"packages/validator", "apps/*"
"apps/demo",
"apps/docs",
"apps/landing-page",
"packages/common"
], ],
"dependencies": { "dependencies": {
"prettier-plugin-astro": "^0.7.0" "prettier-plugin-astro": "^0.7.0"
},
"devDependencies": {
"eslint-config-turbo": "^0.0.4",
"rimraf": "^3.0.2",
"turbo": "^1.6.3"
} }
} }

View file

@ -1,11 +1,13 @@
/** @type {import("@types/eslint").Linter.Config} */ /** @type {import("@types/eslint").Linter.Config} */
module.exports = { module.exports = {
root: true,
env: { env: {
node: true, node: true,
}, },
parser: "@typescript-eslint/parser", parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "prettier"], plugins: ["@typescript-eslint", "prettier"],
extends: [ extends: [
"../../../.eslintrc.cjs",
"eslint:recommended", "eslint:recommended",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended", "plugin:prettier/recommended",

View file

@ -3,12 +3,15 @@
"version": "0.1.2", "version": "0.1.2",
"description": "Common code for Astro Reactive Packages", "description": "Common code for Astro Reactive Packages",
"main": "index.js", "main": "index.js",
"devDependencies": {}, "devDependencies": {
"rimraf": "^3.0.2"
},
"exports": { "exports": {
".": "./index.ts" ".": "./index.ts"
}, },
"scripts": { "scripts": {
"check": "tsc --noEmit" "check": "tsc --noEmit",
"clean": "rimraf node_modules .turbo dist"
}, },
"files": [ "files": [
"types/", "types/",
@ -23,5 +26,8 @@
"bugs": { "bugs": {
"url": "https://github.com/ayoayco/astro-reactive-library/issues" "url": "https://github.com/ayoayco/astro-reactive-library/issues"
}, },
"homepage": "https://github.com/ayoayco/astro-reactive-library#readme" "homepage": "https://github.com/ayoayco/astro-reactive-library#readme",
"publishConfig": {
"access": "public"
}
} }

View file

@ -29,7 +29,8 @@
"format": "prettier -w .", "format": "prettier -w .",
"lint": "eslint . --ext .ts,.js", "lint": "eslint . --ext .ts,.js",
"lint:fix": "eslint --fix . --ext .ts,.js", "lint:fix": "eslint --fix . --ext .ts,.js",
"check": "astro check && tsc --noEmit" "check": "astro check && tsc --noEmit",
"clean": "rimraf node_modules .turbo dist"
}, },
"devDependencies": { "devDependencies": {
"@types/eslint": "^8.4.6", "@types/eslint": "^8.4.6",
@ -39,12 +40,12 @@
"@typescript-eslint/parser": "^5.37.0", "@typescript-eslint/parser": "^5.37.0",
"astro": "^1.5.0", "astro": "^1.5.0",
"astro-component-tester": "^0.6.0", "astro-component-tester": "^0.6.0",
"common": "file:packages/common",
"eslint": "^8.23.1", "eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"prettier-plugin-astro": "^0.7.0", "prettier-plugin-astro": "^0.7.0",
"rimraf": "^3.0.2",
"typescript": "^4.8.3", "typescript": "^4.8.3",
"vitest": "^0.25.2" "vitest": "^0.25.2"
}, },
@ -53,8 +54,11 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@astro-reactive/common": "^0.1.2", "@astro-reactive/common": "*",
"@astro-reactive/validator": "^0.2.3", "@astro-reactive/validator": "*",
"short-unique-id": "^4.4.4" "short-unique-id": "^4.4.4"
},
"publishConfig": {
"access": "public"
} }
} }

View file

@ -27,7 +27,8 @@
"format": "prettier -w .", "format": "prettier -w .",
"lint": "eslint . --ext .ts,.js", "lint": "eslint . --ext .ts,.js",
"lint:fix": "eslint --fix . --ext .ts,.js", "lint:fix": "eslint --fix . --ext .ts,.js",
"check": "astro check && tsc --noEmit" "check": "astro check && tsc --noEmit",
"clean": "rimraf node_modules .turbo dist"
}, },
"devDependencies": { "devDependencies": {
"@types/eslint": "^8.4.6", "@types/eslint": "^8.4.6",
@ -37,12 +38,12 @@
"@typescript-eslint/parser": "^5.37.0", "@typescript-eslint/parser": "^5.37.0",
"astro": "^1.5.0", "astro": "^1.5.0",
"astro-component-tester": "^0.6.0", "astro-component-tester": "^0.6.0",
"common": "file:packages/common",
"eslint": "^8.23.1", "eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"prettier-plugin-astro": "^0.7.0", "prettier-plugin-astro": "^0.7.0",
"rimraf": "^3.0.2",
"typescript": "^4.8.3", "typescript": "^4.8.3",
"vitest": "^0.25.2" "vitest": "^0.25.2"
}, },
@ -50,7 +51,7 @@
"astro": "^1.5.0" "astro": "^1.5.0"
}, },
"dependencies": { "dependencies": {
"@astro-reactive/common": "^0.1.2" "@astro-reactive/common": "*"
}, },
"main": "index.js", "main": "index.js",
"directories": { "directories": {
@ -59,5 +60,8 @@
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/ayoayco/astro-reactive-library/issues" "url": "https://github.com/ayoayco/astro-reactive-library/issues"
},
"publishConfig": {
"access": "public"
} }
} }

24
turbo.json Normal file
View file

@ -0,0 +1,24 @@
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"lint": {
"outputs": []
},
"lint:fix": {
"outputs": []
},
"test:watch": {
"cache": false
},
"dev": {
"cache": false
},
"test": {},
"check": {},
"clean": {}
}
}