gemercheung před 3 roky
revize
d36f70523a

+ 7 - 0
.eslintignore

@@ -0,0 +1,7 @@
+node_modules
+!.*
+dist
+build
+
+
+examples/cra-ejected-babel

+ 25 - 0
.eslintrc.js

@@ -0,0 +1,25 @@
+module.exports = {
+  parser: '@typescript-eslint/parser',
+  parserOptions: {
+    project: 'tsconfig.json',
+    tsconfigRootDir : __dirname, 
+    sourceType: 'module',
+  },
+  plugins: ['@typescript-eslint/eslint-plugin'],
+  extends: [
+    'plugin:@typescript-eslint/recommended',
+    'plugin:prettier/recommended',
+  ],
+  root: true,
+  env: {
+    node: true,
+    jest: true,
+  },
+  ignorePatterns: ['.eslintrc.js'],
+  rules: {
+    '@typescript-eslint/interface-name-prefix': 'off',
+    '@typescript-eslint/explicit-function-return-type': 'off',
+    '@typescript-eslint/explicit-module-boundary-types': 'off',
+    '@typescript-eslint/no-explicit-any': 'off',
+  },
+};

+ 36 - 0
.github/workflows/tests.yml

@@ -0,0 +1,36 @@
+name: tests
+
+on:
+  push:
+  pull_request:
+    branches: [ $default-branch ]
+
+jobs:
+  tests:
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - uses: pnpm/action-setup@v2.2.2
+        with:
+          version: latest
+
+      - name: Install Node
+        uses: actions/setup-node@v3
+        with:
+          node-version: 14
+          cache: 'pnpm'
+
+      - name: Install dependencies
+        run: pnpm i
+
+      - name: Lint
+        run: pnpm run lint
+
+      - name: Build
+        run: pnpm run build
+
+      - name: Test
+        run: pnpm run test

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+node_modules
+**/dist
+results
+.nyc_output
+*.tsbuildinfo

+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2019 Gemer Cheung
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 0 - 0
README.md


+ 31 - 0
package.json

@@ -0,0 +1,31 @@
+{
+  "name": "ts-monorepo",
+  "description": "Template for setting up a TypeScript monorepo",
+  "private": true,
+  "workspaces": [
+    "packages/*",
+    "examples/*"
+  ],
+  "scripts": {
+    "docs": "doctoc --title '**Table of content**' README.md",
+    "clean": "pnpm run -r clean",
+    "build": "pnpm run -r build",
+    "test": "pnpm run -r test",
+    "lint": "eslint --fix --ext js,ts,tsx ."
+  },
+  "devDependencies": {
+    "@nighttrax/eslint-config-tsx": "~10.0.0-beta.2",
+    "@typescript-eslint/parser": "^5.30.6",
+    "doctoc": "~2.2.0",
+    "eslint": "~8.19.0",
+    "eslint-plugin-import": "~2.26.0",
+    "typescript": "~4.7.4"
+  },
+  "pnpm": {
+    "peerDependencyRules": {
+      "allowedVersions": {
+        "react-scripts": "^5.0.0"
+      }
+    }
+  }
+}

+ 22 - 0
packages/bar/package.json

@@ -0,0 +1,22 @@
+{
+  "name": "@medici/bar",
+  "version": "1.0.0",
+  "main": "dist/index",
+  "types": "dist/index",
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build": "pnpm run clean && pnpm run compile",
+    "clean": "rimraf -rf ./dist",
+    "compile": "tsc -p tsconfig.build.json",
+    "prepublishOnly": "pnpm run build"
+  },
+  "dependencies": {
+    "@nighttrax/foo": "workspace:~1.0.0"
+  },
+  "devDependencies": {
+    "rimraf": "~3.0.2",
+    "typescript": "~4.7.4"
+  }
+}

+ 3 - 0
packages/bar/src/index.ts

@@ -0,0 +1,3 @@
+import { meaningOfLife } from "@nighttrax/foo";
+// eslint-disable-next-line no-console
+console.log(meaningOfLife);

+ 11 - 0
packages/bar/tsconfig.build.json

@@ -0,0 +1,11 @@
+{
+  "extends": "../../tsconfig.build.json",
+
+  "compilerOptions": {
+    "outDir": "./dist"
+  },
+
+  "include": [
+    "src/**/*"
+  ]
+}

+ 3 - 0
packages/bar/tsconfig.json

@@ -0,0 +1,3 @@
+{
+  "extends": "../../tsconfig.json"
+}

+ 22 - 0
packages/components/package.json

@@ -0,0 +1,22 @@
+{
+  "name": "@medici/components",
+  "version": "1.0.0",
+  "scripts": {
+    "build": "pnpm run clean && pnpm run compile",
+    "clean": "rimraf -rf ./dist",
+    "compile": "tsc -p tsconfig.build.json",
+    "prepublishOnly": "pnpm run build"
+  },
+  "peerDependencies": {
+    "react": "~18.2.0"
+  },
+  "dependencies": {
+    "@nighttrax/foo": "*"
+  },
+  "devDependencies": {
+    "@types/react": "~18.0.15",
+    "react": "~18.2.0",
+    "react-dom": "~18.2.0",
+    "rimraf": "~3.0.2"
+  }
+}

+ 12 - 0
packages/components/src/button.tsx

@@ -0,0 +1,12 @@
+/* eslint-disable no-alert */
+import { meaningOfLife } from "@nighttrax/foo";
+import React from "react";
+
+export const Button = () => (
+  <button
+    type="button"
+    onClick={() => alert(`the meaning if life is ${meaningOfLife}`)}
+  >
+    Click me
+  </button>
+);

+ 13 - 0
packages/components/tsconfig.build.json

@@ -0,0 +1,13 @@
+{
+  "extends": "../../tsconfig.build.json",
+
+  "compilerOptions": {
+    "outDir": "./dist",
+    "jsx": "react",
+    "esModuleInterop": true
+  },
+
+  "include": [
+    "src/**/*"
+  ]
+}

+ 7 - 0
packages/components/tsconfig.json

@@ -0,0 +1,7 @@
+{
+  "extends": "../../tsconfig.json",
+  "compilerOptions": {
+    "jsx": "react",
+    "esModuleInterop": true
+  }
+}

+ 19 - 0
packages/foo/package.json

@@ -0,0 +1,19 @@
+{
+  "name": "@medici/foo",
+  "version": "1.0.0",
+  "main": "dist/index",
+  "types": "dist/index",
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "build": "pnpm run clean && pnpm run compile",
+    "clean": "rimraf -rf ./dist",
+    "compile": "tsc -p tsconfig.build.json",
+    "prepublishOnly": "pnpm run build"
+  },
+  "devDependencies": {
+    "rimraf": "~3.0.2",
+    "typescript": "~4.7.4"
+  }
+}

+ 1 - 0
packages/foo/src/index.ts

@@ -0,0 +1 @@
+export const meaningOfLife = 42;

+ 11 - 0
packages/foo/tsconfig.build.json

@@ -0,0 +1,11 @@
+{
+  "extends": "../../tsconfig.build.json",
+
+  "compilerOptions": {
+    "outDir": "./dist"
+  },
+
+  "include": [
+    "src/**/*"
+  ]
+}

+ 3 - 0
packages/foo/tsconfig.json

@@ -0,0 +1,3 @@
+{
+  "extends": "../../tsconfig.json"
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 18137 - 0
pnpm-lock.yaml


+ 3 - 0
pnpm-workspace.yaml

@@ -0,0 +1,3 @@
+packages:
+  - 'packages/**'
+  # - 'examples/**'

+ 8 - 0
renovate.json

@@ -0,0 +1,8 @@
+{
+  "extends": [
+    "config:base"
+  ],
+  "ignorePresets": [":ignoreModulesAndTests"],
+  "rangeStrategy": "replace",
+  "automerge": true
+}

+ 19 - 0
tsconfig.build.json

@@ -0,0 +1,19 @@
+{
+  "compilerOptions": {
+    "module": "commonjs",
+    "target": "es5",
+    "sourceMap": true,
+    "declaration": true,
+    "declarationMap": true,
+    "noEmitOnError": true,
+    "skipLibCheck": true,
+    "esModuleInterop": true,
+    "types": [],
+    "jsx": "react",
+    "noEmit": false
+  },
+  "exclude": [
+    "node_modules",
+    "dist"
+  ]
+}

+ 12 - 0
tsconfig.json

@@ -0,0 +1,12 @@
+{
+  "extends": "./tsconfig.build.json",
+
+  "compilerOptions": {
+    "baseUrl": ".",
+    "paths": {
+      "@nighttrax/components/*": ["packages/components/src/*"],
+      "@nighttrax/*": ["packages/*/src"]
+    },
+    "noEmit": true
+  }
+}