From eb6d05aae0a1a0a61b4a36bc3bb05cd0779af9fc Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 12:22:13 +0800 Subject: [PATCH 01/12] Add more nested imports --- package.json | 5 ++-- packages/api/package.json | 3 ++- packages/app/package.json | 3 ++- packages/comps/package.json | 15 ++++++++++++ packages/comps/src/CompOne.tsx | 12 +++++++++ packages/comps/src/index.ts | 1 + packages/comps/tsconfig.json | 11 +++++++++ packages/react-app/package.json | 6 +++-- packages/react-app/src/App.tsx | 35 +++++++++++++++++---------- packages/react-app/src/LegacyComp.jsx | 3 +++ packages/react-app/tsconfig.json | 3 +++ packages/shared/package.json | 3 ++- packages/shared/src/index.ts | 11 ++++++++- tsconfig.json | 1 + 14 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 packages/comps/package.json create mode 100644 packages/comps/src/CompOne.tsx create mode 100644 packages/comps/src/index.ts create mode 100644 packages/comps/tsconfig.json create mode 100644 packages/react-app/src/LegacyComp.jsx diff --git a/package.json b/package.json index 5962ae3..dc76957 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,9 @@ "build": "lerna run build --parallel", "start:api": "lerna run start --scope=@mono/api --stream", "start:app": "lerna run start --scope=@mono/app --stream", - "start:react": "lerna run start --scope=@mono/react-app --scope=@mono/shared --parallel", - "start": "lerna run start --scope=@mono/api --scope=@mono/app --scope=@mono/react-app --scope=@mono/shared --parallel" + "start:react": "lerna run start --scope=@mono/react-app --scope=@mono/shared --scope=@mono/comps --parallel", + "start": "lerna run start --scope=@mono/api --scope=@mono/app --scope=@mono/react-app --scope=@mono/shared --scope=@mono/comps --parallel", + "clean": "lerna run clean --parallel" }, "private": true, "devDependencies": { diff --git a/packages/api/package.json b/packages/api/package.json index eaf5ce6..281394d 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -9,6 +9,7 @@ }, "scripts": { "build": "tsc --build --preserveWatchOutput", - "start": "yarn build --watch" + "start": "yarn build --watch", + "clean": "rm -rf dist *.tsbuildinfo" } } diff --git a/packages/app/package.json b/packages/app/package.json index 7728136..698a56e 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -9,6 +9,7 @@ }, "scripts": { "build": "tsc --build --preserveWatchOutput", - "start": "yarn build --watch" + "start": "yarn build --watch", + "clean": "rm -rf dist *.tsbuildinfo" } } diff --git a/packages/comps/package.json b/packages/comps/package.json new file mode 100644 index 0000000..cb9f091 --- /dev/null +++ b/packages/comps/package.json @@ -0,0 +1,15 @@ +{ + "name": "@mono/comps", + "version": "1.0.0", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "license": "MIT", + "dependencies": { + "@mono/shared": "*" + }, + "scripts": { + "build": "tsc --build --preserveWatchOutput", + "start": "yarn build --watch", + "clean": "rm -rf dist *.tsbuildinfo" + } +} diff --git a/packages/comps/src/CompOne.tsx b/packages/comps/src/CompOne.tsx new file mode 100644 index 0000000..5d086f9 --- /dev/null +++ b/packages/comps/src/CompOne.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { sum } from '@mono/shared'; + +export enum MyEnum { + A, + B, + C, +} + +export const CompOne: React.FC = () => { + return
CompOne: 1+2={sum(1, 2)}
; +}; diff --git a/packages/comps/src/index.ts b/packages/comps/src/index.ts new file mode 100644 index 0000000..7500044 --- /dev/null +++ b/packages/comps/src/index.ts @@ -0,0 +1 @@ +export * from './CompOne'; diff --git a/packages/comps/tsconfig.json b/packages/comps/tsconfig.json new file mode 100644 index 0000000..3e79dd9 --- /dev/null +++ b/packages/comps/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["./src"], + "compilerOptions": { + "composite": true, + "rootDir": "src", + "outDir": "dist", + "lib": ["dom", "dom.iterable", "esnext"], + "jsx": "react" + } +} diff --git a/packages/react-app/package.json b/packages/react-app/package.json index caab4eb..53a2ee0 100644 --- a/packages/react-app/package.json +++ b/packages/react-app/package.json @@ -5,7 +5,8 @@ "dependencies": { "react": "^16.12.0", "react-dom": "^16.12.0", - "@mono/shared": "*" + "@mono/shared": "*", + "@mono/comps": "*" }, "devDependencies": { "@types/jest": "^24.0.0", @@ -19,7 +20,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "clean": "rm -rf dist *.tsbuildinfo" }, "eslintConfig": { "extends": "react-app" diff --git a/packages/react-app/src/App.tsx b/packages/react-app/src/App.tsx index 9601237..8ce61a2 100644 --- a/packages/react-app/src/App.tsx +++ b/packages/react-app/src/App.tsx @@ -1,7 +1,17 @@ -import React from 'react' -import logo from './logo.svg' -import './App.css' -import { SHARED_CONFIG } from '@mono/shared' +import React from 'react'; +import logo from './logo.svg'; +import './App.css'; +import { SHARED_CONFIG, DummyShared } from '@mono/shared'; +import { CompOne } from '@mono/comps'; +import { LegacyComp } from './LegacyComp'; + +enum Dummy1 { + A, + B, +} + +const a: Dummy1 = Dummy1.A; +const b: DummyShared = DummyShared.chair; const App: React.FC = () => { return ( @@ -9,18 +19,17 @@ const App: React.FC = () => {
logo

I SEE MONOREPOS

- + Learn React

Is shared: {SHARED_CONFIG.SHARED}

+

+ +

+
- ) -} + ); +}; -export default App +export default App; diff --git a/packages/react-app/src/LegacyComp.jsx b/packages/react-app/src/LegacyComp.jsx new file mode 100644 index 0000000..9aa0b5e --- /dev/null +++ b/packages/react-app/src/LegacyComp.jsx @@ -0,0 +1,3 @@ +import React from 'react'; + +export const LegacyComp = () =>
Legacy
; diff --git a/packages/react-app/tsconfig.json b/packages/react-app/tsconfig.json index b61514c..4ef924c 100644 --- a/packages/react-app/tsconfig.json +++ b/packages/react-app/tsconfig.json @@ -3,6 +3,9 @@ "references": [ { "path": "../shared" + }, + { + "path": "../comps" } ], "include": ["src"], diff --git a/packages/shared/package.json b/packages/shared/package.json index 05b2724..f92472e 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -6,6 +6,7 @@ "license": "MIT", "scripts": { "build": "tsc --build --preserveWatchOutput", - "start": "yarn build --watch" + "start": "yarn build --watch", + "clean": "rm -rf dist *.tsbuildinfo" } } diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index d1062c9..84e433f 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -1,5 +1,14 @@ +export enum DummyShared { + chair, + table, +} + export const SHARED_CONFIG = { DUMMY: true, SHARED: 'of course', - MONO: 'REPO' + MONO: 'REPO', +}; + +export function sum(a: number, b: number): number { + return a + b; } diff --git a/tsconfig.json b/tsconfig.json index 4db0cbf..d1a3f1d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "extends": "./tsconfig.base.json", "references": [ { "path": "packages/shared" }, + { "path": "packages/comps" }, { "path": "packages/app" }, { "path": "packages/api" }, { "path": "packages/react-app" } From 7f1a6bd7d3620f2e220d08101dff94c433a91e37 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 12:37:25 +0800 Subject: [PATCH 02/12] Add tests --- package.json | 3 +- packages/comps/package.json | 3 +- packages/comps/src/CompOne.test.tsx | 9 +++ packages/comps/src/react-app-env.d.ts | 1 + packages/comps/src/setupTests.ts | 5 ++ packages/comps/tsconfig.json | 19 ++++- packages/react-app/package.json | 3 + packages/react-app/src/App.tsx | 4 +- yarn.lock | 105 ++++++++++++++++++++++++-- 9 files changed, 137 insertions(+), 15 deletions(-) create mode 100644 packages/comps/src/CompOne.test.tsx create mode 100644 packages/comps/src/react-app-env.d.ts create mode 100644 packages/comps/src/setupTests.ts diff --git a/package.json b/package.json index dc76957..882d1bb 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "start:app": "lerna run start --scope=@mono/app --stream", "start:react": "lerna run start --scope=@mono/react-app --scope=@mono/shared --scope=@mono/comps --parallel", "start": "lerna run start --scope=@mono/api --scope=@mono/app --scope=@mono/react-app --scope=@mono/shared --scope=@mono/comps --parallel", - "clean": "lerna run clean --parallel" + "clean": "lerna run clean --parallel", + "test": "CI=1 lerna run test --parallel" }, "private": true, "devDependencies": { diff --git a/packages/comps/package.json b/packages/comps/package.json index cb9f091..2087055 100644 --- a/packages/comps/package.json +++ b/packages/comps/package.json @@ -10,6 +10,7 @@ "scripts": { "build": "tsc --build --preserveWatchOutput", "start": "yarn build --watch", - "clean": "rm -rf dist *.tsbuildinfo" + "clean": "rm -rf dist *.tsbuildinfo", + "test": "react-scripts test" } } diff --git a/packages/comps/src/CompOne.test.tsx b/packages/comps/src/CompOne.test.tsx new file mode 100644 index 0000000..36445bf --- /dev/null +++ b/packages/comps/src/CompOne.test.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { CompOne } from './CompOne'; + +test('renders learn react link', () => { + const { getByText } = render(); + const linkElement = getByText(/3/i); + expect(linkElement).toBeInTheDocument(); +}); diff --git a/packages/comps/src/react-app-env.d.ts b/packages/comps/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/packages/comps/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/comps/src/setupTests.ts b/packages/comps/src/setupTests.ts new file mode 100644 index 0000000..74b1a27 --- /dev/null +++ b/packages/comps/src/setupTests.ts @@ -0,0 +1,5 @@ +// jest-dom adds custom jest matchers for asserting on DOM nodes. +// allows you to do things like: +// expect(element).toHaveTextContent(/react/i) +// learn more: https://github.com/testing-library/jest-dom +import '@testing-library/jest-dom/extend-expect'; diff --git a/packages/comps/tsconfig.json b/packages/comps/tsconfig.json index 3e79dd9..47fe7a5 100644 --- a/packages/comps/tsconfig.json +++ b/packages/comps/tsconfig.json @@ -1,11 +1,24 @@ { "extends": "../../tsconfig.base.json", - "include": ["./src"], + "include": [ + "./src" + ], "compilerOptions": { "composite": true, "rootDir": "src", "outDir": "dist", - "lib": ["dom", "dom.iterable", "esnext"], - "jsx": "react" + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "jsx": "react", + "allowJs": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true } } diff --git a/packages/react-app/package.json b/packages/react-app/package.json index 53a2ee0..b2b08c5 100644 --- a/packages/react-app/package.json +++ b/packages/react-app/package.json @@ -9,6 +9,9 @@ "@mono/comps": "*" }, "devDependencies": { + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", "@types/jest": "^24.0.0", "@types/node": "^12.0.0", "@types/react": "^16.9.0", diff --git a/packages/react-app/src/App.tsx b/packages/react-app/src/App.tsx index 8ce61a2..7539d8b 100644 --- a/packages/react-app/src/App.tsx +++ b/packages/react-app/src/App.tsx @@ -23,9 +23,7 @@ const App: React.FC = () => { Learn React

Is shared: {SHARED_CONFIG.SHARED}

-

- -

+ diff --git a/yarn.lock b/yarn.lock index db08b8b..a4cad30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -905,7 +905,7 @@ dependencies: regenerator-runtime "^0.13.2" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.4": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.1", "@babel/runtime@^7.6.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.4": version "7.7.6" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.6.tgz#d18c511121aff1b4f2cd1d452f1bac9601dd830f" integrity sha512-BWAJxpNVa0QlE5gZdWjSxXtemZyZ9RmrmVozxt3NUXeZhVIJ5ANyqmMc0JDrivBZyxUuQvFxlvH4OWWOogGfUw== @@ -1956,6 +1956,11 @@ dependencies: "@types/node" ">= 8" +"@sheerun/mutationobserver-shim@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b" + integrity sha512-vTCdPp/T/Q3oSqwHmZ5Kpa9oI7iLtGl3RQaA/NyLHikvcrPxACkkKVr/XzkSPJWXHRhKGzVvb0urJsbMlRxi1Q== + "@svgr/babel-plugin-add-jsx-attribute@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz#dadcb6218503532d6884b210e7f3c502caaa44b1" @@ -2059,6 +2064,47 @@ "@svgr/plugin-svgo" "^4.3.1" loader-utils "^1.2.3" +"@testing-library/dom@^6.3.0": + version "6.10.1" + resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-6.10.1.tgz#da5bf5065d3f9e484aef4cc495f4e1a5bea6df2e" + integrity sha512-5BPKxaO+zSJDUbVZBRNf9KrmDkm/EcjjaHSg3F9+031VZyPACKXlwLBjVzZxheunT9m72DoIq7WvyE457/Xweg== + dependencies: + "@babel/runtime" "^7.6.2" + "@sheerun/mutationobserver-shim" "^0.3.2" + "@types/testing-library__dom" "^6.0.0" + aria-query "3.0.0" + pretty-format "^24.9.0" + wait-for-expect "^3.0.0" + +"@testing-library/jest-dom@^4.2.4": + version "4.2.4" + resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-4.2.4.tgz#00dfa0cbdd837d9a3c2a7f3f0a248ea6e7b89742" + integrity sha512-j31Bn0rQo12fhCWOUWy9fl7wtqkp7In/YP2p5ZFyRuiiB9Qs3g+hS4gAmDWONbAHcRmVooNJ5eOHQDCOmUFXHg== + dependencies: + "@babel/runtime" "^7.5.1" + chalk "^2.4.1" + css "^2.2.3" + css.escape "^1.5.1" + jest-diff "^24.0.0" + jest-matcher-utils "^24.0.0" + lodash "^4.17.11" + pretty-format "^24.0.0" + redent "^3.0.0" + +"@testing-library/react@^9.3.2": + version "9.3.3" + resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-9.3.3.tgz#87fe594adb02cba4d0e86369d025ea13ad570d7c" + integrity sha512-IuoiJR/NAzu9EuT3Fqs92sRHe/9egCipar92wTnXe3fMloWy0Q7JdAXaszzbv2ogH30ztb6Axp5XW63vOTd4jA== + dependencies: + "@babel/runtime" "^7.6.0" + "@testing-library/dom" "^6.3.0" + "@types/testing-library__react" "^9.1.0" + +"@testing-library/user-event@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-7.1.2.tgz#3a71bb8a45a1e08b71a54c9efcee9927f3895e80" + integrity sha512-lDyCVxxgX5lrgCa75ELCfWcdEDyfisjqoDIM3YsghQ+lyViIac/qT67qabQ/HmoVxyikFKovjKwWdn3b/oKhZA== + "@types/babel__core@^7.1.0": version "7.1.3" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30" @@ -2168,7 +2214,7 @@ resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8" integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw== -"@types/react-dom@^16.9.0": +"@types/react-dom@*", "@types/react-dom@^16.9.0": version "16.9.4" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.4.tgz#0b58df09a60961dcb77f62d4f1832427513420df" integrity sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw== @@ -2188,6 +2234,21 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== +"@types/testing-library__dom@*", "@types/testing-library__dom@^6.0.0": + version "6.10.0" + resolved "https://registry.yarnpkg.com/@types/testing-library__dom/-/testing-library__dom-6.10.0.tgz#590d76e3875a7c536dc744eb530cbf51b6483404" + integrity sha512-mL/GMlyQxiZplbUuFNwA0vAI3k3uJNSf6slr5AVve9TXmfLfyefNT0uHHnxwdYuPMxYD5gI/+dgAvc/5opW9JQ== + dependencies: + pretty-format "^24.3.0" + +"@types/testing-library__react@^9.1.0": + version "9.1.2" + resolved "https://registry.yarnpkg.com/@types/testing-library__react/-/testing-library__react-9.1.2.tgz#e33af9124c60a010fc03a34eff8f8a34a75c4351" + integrity sha512-CYaMqrswQ+cJACy268jsLAw355DZtPZGt3Jwmmotlcu8O/tkoXBI6AeZ84oZBJsIsesozPKzWzmv/0TIU+1E9Q== + dependencies: + "@types/react-dom" "*" + "@types/testing-library__dom" "*" + "@types/yargs-parser@*": version "13.1.0" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-13.1.0.tgz#c563aa192f39350a1d18da36c5a8da382bbd8228" @@ -2629,7 +2690,7 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -aria-query@^3.0.0: +aria-query@3.0.0, aria-query@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-3.0.0.tgz#65b3fcc1ca1155a8c9ae64d6eee297f15d5133cc" integrity sha1-ZbP8wcoRVajJrmTW7uKX8V1RM8w= @@ -4131,7 +4192,12 @@ css-what@^3.2.1: resolved "https://registry.yarnpkg.com/css-what/-/css-what-3.2.1.tgz#f4a8f12421064621b456755e34a03a2c22df5da1" integrity sha512-WwOrosiQTvyms+Ti5ZC5vGEK0Vod3FTt1ca+payZqvKuGJF+dq7bG63DstxtN0dpm6FxY27a/zS3Wten+gEtGw== -css@^2.0.0: +css.escape@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb" + integrity sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s= + +css@^2.0.0, css@^2.2.3: version "2.2.4" resolved "https://registry.yarnpkg.com/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929" integrity sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw== @@ -6856,7 +6922,7 @@ jest-config@^24.9.0: pretty-format "^24.9.0" realpath-native "^1.1.0" -jest-diff@^24.3.0, jest-diff@^24.9.0: +jest-diff@^24.0.0, jest-diff@^24.3.0, jest-diff@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.9.0.tgz#931b7d0d5778a1baf7452cb816e325e3724055da" integrity sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ== @@ -6970,7 +7036,7 @@ jest-leak-detector@^24.9.0: jest-get-type "^24.9.0" pretty-format "^24.9.0" -jest-matcher-utils@^24.9.0: +jest-matcher-utils@^24.0.0, jest-matcher-utils@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-24.9.0.tgz#f5b3661d5e628dffe6dd65251dfdae0e87c3a073" integrity sha512-OZz2IXsu6eaiMAwe67c1T+5tUAtQyQx27/EMEkbFAGiw52tB9em+uGbzpcgYVpA8wl0hlxKPZxrly4CXU/GjHA== @@ -7933,6 +7999,11 @@ mimic-fn@^2.0.0, mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +min-indent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.0.tgz#cfc45c37e9ec0d8f0a0ec3dd4ef7f7c3abe39256" + integrity sha1-z8RcN+nsDY8KDsPdTvf3w6vjklY= + mini-css-extract-plugin@0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.0.tgz#81d41ec4fe58c713a96ad7c723cdb2d0bd4d70e1" @@ -9799,7 +9870,7 @@ pretty-error@^2.1.1: renderkid "^2.0.1" utila "~0.4" -pretty-format@^24.9.0: +pretty-format@^24.0.0, pretty-format@^24.3.0, pretty-format@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA== @@ -10346,6 +10417,14 @@ redent@^2.0.0: indent-string "^3.0.0" strip-indent "^2.0.0" +redent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" + integrity sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg== + dependencies: + indent-string "^4.0.0" + strip-indent "^3.0.0" + regenerate-unicode-properties@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e" @@ -11424,6 +11503,13 @@ strip-indent@^2.0.0: resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g= +strip-indent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" + integrity sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ== + dependencies: + min-indent "^1.0.0" + strip-json-comments@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7" @@ -12110,6 +12196,11 @@ w3c-xmlserializer@^1.1.2: webidl-conversions "^4.0.2" xml-name-validator "^3.0.0" +wait-for-expect@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-3.0.1.tgz#ec204a76b0038f17711e575720aaf28505ac7185" + integrity sha512-3Ha7lu+zshEG/CeHdcpmQsZnnZpPj/UsG3DuKO8FskjuDbkx3jE3845H+CuwZjA2YWYDfKMU2KhnCaXMLd3wVw== + walker@^1.0.7, walker@~1.0.5: version "1.0.7" resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb" From 96d1f65acfe95fc22d0a893b63d659b87e32d939 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 13:05:02 +0800 Subject: [PATCH 03/12] Fix dependency build order --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 882d1bb..3e1b3db 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "packages/*" ], "scripts": { - "build": "lerna run build --parallel", + "build:leaf": "lerna run build --scope @mono/api --scope @mono/react-app --scope @mono/app --parallel", + "build": "lerna run build --scope @mono/shared && lerna run build --scope @mono/comps && yarn build:leaf", "start:api": "lerna run start --scope=@mono/api --stream", "start:app": "lerna run start --scope=@mono/app --stream", "start:react": "lerna run start --scope=@mono/react-app --scope=@mono/shared --scope=@mono/comps --parallel", From c12215e6dbdc5496e736703d9670c98641ca08f3 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 13:07:24 +0800 Subject: [PATCH 04/12] Use separate tsconfig for building comps Deals with react-scripts overwriting the tsconfig --- .gitignore | 2 +- packages/comps/package.json | 2 +- packages/comps/tsconfig-build.json | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 packages/comps/tsconfig-build.json diff --git a/.gitignore b/.gitignore index 9ecd5b2..5686df9 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,4 @@ build tmp -tsconfig.tsbuildinfo \ No newline at end of file +*.tsbuildinfo diff --git a/packages/comps/package.json b/packages/comps/package.json index 2087055..51dd3d1 100644 --- a/packages/comps/package.json +++ b/packages/comps/package.json @@ -8,7 +8,7 @@ "@mono/shared": "*" }, "scripts": { - "build": "tsc --build --preserveWatchOutput", + "build": "tsc --build tsconfig-build.json --preserveWatchOutput", "start": "yarn build --watch", "clean": "rm -rf dist *.tsbuildinfo", "test": "react-scripts test" diff --git a/packages/comps/tsconfig-build.json b/packages/comps/tsconfig-build.json new file mode 100644 index 0000000..3e79dd9 --- /dev/null +++ b/packages/comps/tsconfig-build.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["./src"], + "compilerOptions": { + "composite": true, + "rootDir": "src", + "outDir": "dist", + "lib": ["dom", "dom.iterable", "esnext"], + "jsx": "react" + } +} From 388aa546ff6098e3061e07fdb25782050528dc41 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 13:09:16 +0800 Subject: [PATCH 05/12] Add skipLibCheck to help jest Fixes bad import of JSX-specific types from non-JSX project. See https://stackoverflow.com/questions/51634361/how-to-force-tsc-to-ignore-node-modules-folder --- tsconfig.base.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index fd8fe9f..13aa668 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,7 +9,8 @@ "moduleResolution": "node", "target": "es6", "jsx": "preserve", - "lib": ["es6"] + "lib": ["es6"], + "skipLibCheck": true }, "exclude": ["node_modules"] } From 5aa2720dd1c485731e778a0ff2d4e638d0a05996 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 13:21:23 +0800 Subject: [PATCH 06/12] Begin work on linting --- .eslintrc | 29 +++++++ .prettierrc | 5 ++ package.json | 8 ++ packages/react-app/src/App.tsx | 7 +- yarn.lock | 137 ++++++++++++++++++++++++++++++++- 5 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 .eslintrc create mode 100644 .prettierrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..b1293d7 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,29 @@ +{ + "root": true, + "env": { + "node": true + }, + "extends": [ + "airbnb-base", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + "prettier/@typescript-eslint" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "./tsconfig.json", + "sourceType": "module" + }, + "plugins": ["@typescript-eslint"], + "settings": { + "import/extensions": [".js", ".jsx", ".ts", ".tsx"], + "import/parsers": { + "@typescript-eslint/parser": [".ts", ".tsx"] + }, + "import/resolver": { + "node": { + "extensions": [".js", ".jsx", ".ts", ".tsx"] + } + } + } +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..789ac2e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "printWidth": 100, + "singleQuote": true, + "trailingComma": "es5" +} diff --git a/package.json b/package.json index 3e1b3db..67e53ae 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,15 @@ }, "private": true, "devDependencies": { + "@typescript-eslint/eslint-plugin": "2.11.0", + "@typescript-eslint/parser": "2.11.0", + "eslint": "6.7.2", + "eslint-config-airbnb-base": "14.0.0", + "eslint-config-prettier": "6.7.0", + "eslint-plugin-import": "2.19.1", + "eslint-plugin-prettier": "3.1.1", "lerna": "^3.19.0", + "prettier": "1.19.1", "typescript": "^3.7.3" } } diff --git a/packages/react-app/src/App.tsx b/packages/react-app/src/App.tsx index 7539d8b..b7d0549 100644 --- a/packages/react-app/src/App.tsx +++ b/packages/react-app/src/App.tsx @@ -19,7 +19,12 @@ const App: React.FC = () => {
logo

I SEE MONOREPOS

- + Learn React

Is shared: {SHARED_CONFIG.SHARED}

diff --git a/yarn.lock b/yarn.lock index a4cad30..8a0c515 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2261,6 +2261,17 @@ dependencies: "@types/yargs-parser" "*" +"@typescript-eslint/eslint-plugin@2.11.0": + version "2.11.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.11.0.tgz#4477c33491ccf0a9a3f4a30ef84978fa0ea0cad2" + integrity sha512-G2HHA1vpMN0EEbUuWubiCCfd0R3a30BB+UdvnFkxwZIxYEGOrWEXDv8tBFO9f44CWc47Xv9lLM3VSn4ORLI2bA== + dependencies: + "@typescript-eslint/experimental-utils" "2.11.0" + eslint-utils "^1.4.3" + functional-red-black-tree "^1.0.1" + regexpp "^3.0.0" + tsutils "^3.17.1" + "@typescript-eslint/eslint-plugin@^2.8.0": version "2.10.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.10.0.tgz#c4cb103275e555e8a7e9b3d14c5951eb6d431e70" @@ -2281,6 +2292,25 @@ "@typescript-eslint/typescript-estree" "2.10.0" eslint-scope "^5.0.0" +"@typescript-eslint/experimental-utils@2.11.0": + version "2.11.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.11.0.tgz#cef18e6b122706c65248a5d8984a9779ed1e52ac" + integrity sha512-YxcA/y0ZJaCc/fB/MClhcDxHI0nOBB7v2/WxBju2cOTanX7jO9ttQq6Fy4yW9UaY5bPd9xL3cun3lDVqk67sPQ== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/typescript-estree" "2.11.0" + eslint-scope "^5.0.0" + +"@typescript-eslint/parser@2.11.0": + version "2.11.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.11.0.tgz#cdcc3be73ee31cbef089af5ff97ccaa380ef6e8b" + integrity sha512-DyGXeqhb3moMioEFZIHIp7oXBBh7dEfPTzGrlyP0Mi9ScCra4SWEGs3kPd18mG7Sy9Wy8z88zmrw5tSGL6r/6A== + dependencies: + "@types/eslint-visitor-keys" "^1.0.0" + "@typescript-eslint/experimental-utils" "2.11.0" + "@typescript-eslint/typescript-estree" "2.11.0" + eslint-visitor-keys "^1.1.0" + "@typescript-eslint/parser@^2.8.0": version "2.10.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.10.0.tgz#24b2e48384ab6d5a6121e4c4faf8892c79657ad3" @@ -2304,6 +2334,19 @@ semver "^6.3.0" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@2.11.0": + version "2.11.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.11.0.tgz#21ada6504274cd1644855926312c798fc697e9fb" + integrity sha512-HGY4+d4MagO6cKMcKfIKaTMxcAv7dEVnji2Zi+vi5VV8uWAM631KjAB5GxFcexMYrwKT0EekRiiGK1/Sd7VFGA== + dependencies: + debug "^4.1.1" + eslint-visitor-keys "^1.1.0" + glob "^7.1.6" + is-glob "^4.0.1" + lodash.unescape "4.0.1" + semver "^6.3.0" + tsutils "^3.17.1" + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" @@ -2773,6 +2816,14 @@ array-unique@^0.3.2: resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= +array.prototype.flat@^1.2.1: + version "1.2.3" + resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz#0de82b426b0318dbfdb940089e38b043d37f6c7b" + integrity sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -3819,7 +3870,7 @@ config-chain@^1.1.11: ini "^1.3.4" proto-list "~1.2.1" -confusing-browser-globals@^1.0.9: +confusing-browser-globals@^1.0.7, confusing-browser-globals@^1.0.9: version "1.0.9" resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz#72bc13b483c0276801681871d4898516f8f54fdd" integrity sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw== @@ -4865,6 +4916,23 @@ es-abstract@^1.12.0, es-abstract@^1.15.0, es-abstract@^1.5.1, es-abstract@^1.7.0 string.prototype.trimleft "^2.1.0" string.prototype.trimright "^2.1.0" +es-abstract@^1.17.0-next.1: + version "1.17.0-next.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.0-next.1.tgz#94acc93e20b05a6e96dacb5ab2f1cb3a81fc2172" + integrity sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.1.4" + is-regex "^1.0.4" + object-inspect "^1.7.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimleft "^2.1.0" + string.prototype.trimright "^2.1.0" + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -4934,6 +5002,22 @@ escodegen@^1.11.0, escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" +eslint-config-airbnb-base@14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.0.0.tgz#8a7bcb9643d13c55df4dd7444f138bf4efa61e17" + integrity sha512-2IDHobw97upExLmsebhtfoD3NAKhV4H0CJWP3Uprd/uk+cHuWYOczPVxQ8PxLFUAw7o3Th1RAU8u1DoUpr+cMA== + dependencies: + confusing-browser-globals "^1.0.7" + object.assign "^4.1.0" + object.entries "^1.1.0" + +eslint-config-prettier@6.7.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.7.0.tgz#9a876952e12df2b284adbd3440994bf1f39dfbb9" + integrity sha512-FamQVKM3jjUVwhG4hEMnbtsq7xOIDm+SY5iBPfR8gKsJoAB2IQnNF+bk1+8Fy44Nq7PPJaLvkRxILYdJWoguKQ== + dependencies: + get-stdin "^6.0.0" + eslint-config-react-app@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-5.1.0.tgz#a37b3f2d4f56f856f93277281ef52bd791273e63" @@ -4960,7 +5044,7 @@ eslint-loader@3.0.2: object-hash "^1.3.1" schema-utils "^2.2.0" -eslint-module-utils@^2.4.0: +eslint-module-utils@^2.4.0, eslint-module-utils@^2.4.1: version "2.5.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.5.0.tgz#cdf0b40d623032274ccd2abd7e64c4e524d6e19c" integrity sha512-kCo8pZaNz2dsAW7nCUjuVoI11EBXXpIzfNxmaoLhXoRDOnqXLC4iSGVRdZPhOitfbdEfMEfKOiENaK6wDPZEGw== @@ -4992,6 +5076,24 @@ eslint-plugin-import@2.18.2: read-pkg-up "^2.0.0" resolve "^1.11.0" +eslint-plugin-import@2.19.1: + version "2.19.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.19.1.tgz#5654e10b7839d064dd0d46cd1b88ec2133a11448" + integrity sha512-x68131aKoCZlCae7rDXKSAQmbT5DQuManyXo2sK6fJJ0aK5CWAkv6A6HJZGgqC8IhjQxYPgo6/IY4Oz8AFsbBw== + dependencies: + array-includes "^3.0.3" + array.prototype.flat "^1.2.1" + contains-path "^0.1.0" + debug "^2.6.9" + doctrine "1.5.0" + eslint-import-resolver-node "^0.3.2" + eslint-module-utils "^2.4.1" + has "^1.0.3" + minimatch "^3.0.4" + object.values "^1.1.0" + read-pkg-up "^2.0.0" + resolve "^1.12.0" + eslint-plugin-jsx-a11y@6.2.3: version "6.2.3" resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.2.3.tgz#b872a09d5de51af70a97db1eea7dc933043708aa" @@ -5007,6 +5109,13 @@ eslint-plugin-jsx-a11y@6.2.3: has "^1.0.3" jsx-ast-utils "^2.2.1" +eslint-plugin-prettier@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.1.tgz#507b8562410d02a03f0ddc949c616f877852f2ba" + integrity sha512-A+TZuHZ0KU0cnn56/9mfR7/KjUJ9QNVXUhwvRFSR7PGPe0zQR6PTkmyqg1AtUUEOzTqeRsUwyKFh0oVZKVCrtA== + dependencies: + prettier-linter-helpers "^1.0.0" + eslint-plugin-react-hooks@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04" @@ -5055,7 +5164,7 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== -eslint@^6.6.0: +eslint@6.7.2, eslint@^6.6.0: version "6.7.2" resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.7.2.tgz#c17707ca4ad7b2d8af986a33feba71e18a9fecd1" integrity sha512-qMlSWJaCSxDFr8fBPvJM9kJwbazrhNcBU3+DszDW1OlEwKBBRWsJc7NJFelvwQpanHCR14cOLD41x8Eqvo3Nng== @@ -5325,6 +5434,11 @@ fast-deep-equal@^2.0.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + fast-glob@^2.0.2, fast-glob@^2.2.6: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -5725,6 +5839,11 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + get-stream@^4.0.0, get-stream@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" @@ -9857,6 +9976,18 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + pretty-bytes@^5.1.0: version "5.3.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.3.0.tgz#f2849e27db79fb4d6cfe24764fc4134f165989f2" From 44f16d11b67a3d354acbbbe72139bdb161fe0b52 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 14:05:35 +0800 Subject: [PATCH 07/12] Add test for shared --- packages/shared/jest.config.js | 7 ++++ packages/shared/package.json | 6 +++- packages/shared/src/index.ts | 4 +-- packages/shared/src/math.test.ts | 9 +++++ packages/shared/src/math.ts | 3 ++ yarn.lock | 56 ++++++++++++++++++++++++-------- 6 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 packages/shared/jest.config.js create mode 100644 packages/shared/src/math.test.ts create mode 100644 packages/shared/src/math.ts diff --git a/packages/shared/jest.config.js b/packages/shared/jest.config.js new file mode 100644 index 0000000..5e50958 --- /dev/null +++ b/packages/shared/jest.config.js @@ -0,0 +1,7 @@ +module.exports = { + roots: ['/src'], + testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], + transform: { + '^.+\\.(ts|tsx)$': 'ts-jest', + }, +}; diff --git a/packages/shared/package.json b/packages/shared/package.json index f92472e..8dcde59 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -7,6 +7,10 @@ "scripts": { "build": "tsc --build --preserveWatchOutput", "start": "yarn build --watch", - "clean": "rm -rf dist *.tsbuildinfo" + "clean": "rm -rf dist *.tsbuildinfo", + "test": "jest" + }, + "dependencies": { + "ts-jest": "24.2.0" } } diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 84e433f..e6f2411 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -9,6 +9,4 @@ export const SHARED_CONFIG = { MONO: 'REPO', }; -export function sum(a: number, b: number): number { - return a + b; -} +export * from './math'; diff --git a/packages/shared/src/math.test.ts b/packages/shared/src/math.test.ts new file mode 100644 index 0000000..8a8e21b --- /dev/null +++ b/packages/shared/src/math.test.ts @@ -0,0 +1,9 @@ +import { sum } from './math'; + +describe('math', () => { + describe('sum', () => { + it('should return 3 for 1+2', () => { + expect(sum(1, 2)).toBe(3); + }); + }); +}); diff --git a/packages/shared/src/math.ts b/packages/shared/src/math.ts new file mode 100644 index 0000000..7372ed0 --- /dev/null +++ b/packages/shared/src/math.ts @@ -0,0 +1,3 @@ +export function sum(a: number, b: number): number { + return a + b; +} diff --git a/yarn.lock b/yarn.lock index 8a0c515..3caa3d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3312,6 +3312,13 @@ browserslist@^4.0.0, browserslist@^4.6.0, browserslist@^4.6.2, browserslist@^4.6 electron-to-chromium "^1.3.322" node-releases "^1.1.42" +bs-logger@0.x: + version "0.2.6" + resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" + integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== + dependencies: + fast-json-stable-stringify "2.x" + bser@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" @@ -3324,7 +3331,7 @@ btoa-lite@^1.0.0: resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337" integrity sha1-M3dm2hWAEhD92VbCLpxokaudAzc= -buffer-from@^1.0.0: +buffer-from@1.x, buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== @@ -5451,7 +5458,7 @@ fast-glob@^2.0.2, fast-glob@^2.2.6: merge2 "^1.2.3" micromatch "^3.1.10" -fast-json-stable-stringify@^2.0.0: +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= @@ -7505,6 +7512,13 @@ json3@^3.3.2: resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81" integrity sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA== +json5@2.x, json5@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6" + integrity sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ== + dependencies: + minimist "^1.2.0" + json5@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" @@ -7512,13 +7526,6 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" -json5@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6" - integrity sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ== - dependencies: - minimist "^1.2.0" - jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -7773,7 +7780,7 @@ lodash.ismatch@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc= -lodash.memoize@^4.1.2: +lodash.memoize@4.x, lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= @@ -7877,6 +7884,11 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" +make-error@1.x: + version "1.3.5" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" + integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g== + make-fetch-happen@^5.0.0: version "5.0.2" resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-5.0.2.tgz#aa8387104f2687edca01c8687ee45013d02d19bd" @@ -8255,7 +8267,7 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*, mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: +mkdirp@*, mkdirp@0.5.1, mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= @@ -10789,7 +10801,7 @@ resolve@1.12.2: dependencies: path-parse "^1.0.6" -resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: +resolve@1.x, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: version "1.13.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.13.1.tgz#be0aa4c06acd53083505abb35f4d66932ab35d16" integrity sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w== @@ -11000,7 +11012,7 @@ selfsigned@^1.10.7: dependencies: node-forge "0.9.0" -"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -11974,6 +11986,22 @@ trim-off-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= +ts-jest@24.2.0: + version "24.2.0" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.2.0.tgz#7abca28c2b4b0a1fdd715cd667d65d047ea4e768" + integrity sha512-Yc+HLyldlIC9iIK8xEN7tV960Or56N49MDP7hubCZUeI7EbIOTsas6rXCMB4kQjLACJ7eDOF4xWEO5qumpKsag== + dependencies: + bs-logger "0.x" + buffer-from "1.x" + fast-json-stable-stringify "2.x" + json5 "2.x" + lodash.memoize "4.x" + make-error "1.x" + mkdirp "0.x" + resolve "1.x" + semver "^5.5" + yargs-parser "10.x" + ts-pnp@1.1.5, ts-pnp@^1.1.2: version "1.1.5" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.5.tgz#840e0739c89fce5f3abd9037bb091dbff16d9dec" @@ -12836,7 +12864,7 @@ yaml@^1.7.2: dependencies: "@babel/runtime" "^7.6.3" -yargs-parser@^10.0.0: +yargs-parser@10.x, yargs-parser@^10.0.0: version "10.1.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== From d1344f9501c1d48293c5218b7226c1d1df41be51 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 14:09:28 +0800 Subject: [PATCH 08/12] Add tests for app (broken) --- packages/app/jest.config.js | 7 +++++++ packages/app/package.json | 3 ++- packages/app/src/index.test.ts | 9 +++++++++ packages/app/src/index.ts | 16 +++++++++++++--- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 packages/app/jest.config.js create mode 100644 packages/app/src/index.test.ts diff --git a/packages/app/jest.config.js b/packages/app/jest.config.js new file mode 100644 index 0000000..5e50958 --- /dev/null +++ b/packages/app/jest.config.js @@ -0,0 +1,7 @@ +module.exports = { + roots: ['/src'], + testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], + transform: { + '^.+\\.(ts|tsx)$': 'ts-jest', + }, +}; diff --git a/packages/app/package.json b/packages/app/package.json index 698a56e..81b563b 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -10,6 +10,7 @@ "scripts": { "build": "tsc --build --preserveWatchOutput", "start": "yarn build --watch", - "clean": "rm -rf dist *.tsbuildinfo" + "clean": "rm -rf dist *.tsbuildinfo", + "test": "jest" } } diff --git a/packages/app/src/index.test.ts b/packages/app/src/index.test.ts new file mode 100644 index 0000000..5ff9fb6 --- /dev/null +++ b/packages/app/src/index.test.ts @@ -0,0 +1,9 @@ +import { times } from './index'; + +describe('math', () => { + describe('times', () => { + it('should return 12 for 3*4', () => { + expect(times(3, 4)).toBe(12); + }); + }); +}); diff --git a/packages/app/src/index.ts b/packages/app/src/index.ts index 0af3ef9..50f3332 100644 --- a/packages/app/src/index.ts +++ b/packages/app/src/index.ts @@ -1,5 +1,15 @@ -import { SHARED_CONFIG } from '@mono/shared' +import { SHARED_CONFIG } from '@mono/shared'; -const APP = true +const APP = true; -console.log(SHARED_CONFIG) +console.log(SHARED_CONFIG); + +export function times(a: number, b: number): number { + let result = 0; + + for (let i = 0; i < b; i++) { + result = result + a; + } + + return result; +} From 2c39d4d244f340bd12fbc9c1516ff890c4ee6914 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Fri, 13 Dec 2019 14:18:27 +0800 Subject: [PATCH 09/12] Fix ts-jest for app --- packages/app/jest.config.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/app/jest.config.js b/packages/app/jest.config.js index 5e50958..3f92418 100644 --- a/packages/app/jest.config.js +++ b/packages/app/jest.config.js @@ -2,6 +2,14 @@ module.exports = { roots: ['/src'], testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], transform: { - '^.+\\.(ts|tsx)$': 'ts-jest', + '^.+\\.(ts|tsx|js|jsx)$': 'ts-jest', + }, + globals: { + 'ts-jest': { + tsConfig: { + importHelpers: true, + allowJs: true, + }, + }, }, }; From d3fd49f7c3a971eced7b84f39b439ca3d2a3b493 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Sat, 14 Dec 2019 10:26:08 +0800 Subject: [PATCH 10/12] Add API start example --- packages/api/package.json | 4 +++- packages/api/src/index.ts | 8 +++++++- packages/shared/package.json | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index 281394d..dfa5b69 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -3,13 +3,15 @@ "version": "1.0.0", "main": "dist/index.js", "types": "dist/index.d.ts", + "type": "module", "license": "MIT", "dependencies": { "@mono/shared": "*" }, "scripts": { "build": "tsc --build --preserveWatchOutput", - "start": "yarn build --watch", + "start": "node --experimental-modules dist/index.js", + "build:watch": "yarn build --watch", "clean": "rm -rf dist *.tsbuildinfo" } } diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 27c0693..c1e3e6b 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -1 +1,7 @@ -export const API = true +import { sum } from '@mono/shared'; + +export const API = true; + +const port = sum(3000, 1); + +console.log(`Would listen on port ${port}...`); diff --git a/packages/shared/package.json b/packages/shared/package.json index 8dcde59..de165fb 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "main": "dist/index.js", "types": "dist/index.d.ts", + "type": "module", "license": "MIT", "scripts": { "build": "tsc --build --preserveWatchOutput", From af204956d362151ebf9ee419a51105b1ef387211 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Sat, 14 Dec 2019 10:39:13 +0800 Subject: [PATCH 11/12] Add workaround for --experimental-modules support --- packages/shared/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index e6f2411..0c0c9f9 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -9,4 +9,4 @@ export const SHARED_CONFIG = { MONO: 'REPO', }; -export * from './math'; +export * from './math.js'; From 343acc2f6555b16cbf4a465af550dc3896b89bbf Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Sat, 14 Dec 2019 12:11:59 +0800 Subject: [PATCH 12/12] Switch to commonjs --- packages/api/package.json | 3 +-- packages/shared/package.json | 1 - packages/shared/src/index.ts | 2 +- tsconfig.base.json | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index dfa5b69..7bcf0b1 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -3,14 +3,13 @@ "version": "1.0.0", "main": "dist/index.js", "types": "dist/index.d.ts", - "type": "module", "license": "MIT", "dependencies": { "@mono/shared": "*" }, "scripts": { "build": "tsc --build --preserveWatchOutput", - "start": "node --experimental-modules dist/index.js", + "start": "node dist/index.js", "build:watch": "yarn build --watch", "clean": "rm -rf dist *.tsbuildinfo" } diff --git a/packages/shared/package.json b/packages/shared/package.json index de165fb..8dcde59 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -3,7 +3,6 @@ "version": "1.0.0", "main": "dist/index.js", "types": "dist/index.d.ts", - "type": "module", "license": "MIT", "scripts": { "build": "tsc --build --preserveWatchOutput", diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 0c0c9f9..e6f2411 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -9,4 +9,4 @@ export const SHARED_CONFIG = { MONO: 'REPO', }; -export * from './math.js'; +export * from './math'; diff --git a/tsconfig.base.json b/tsconfig.base.json index 13aa668..d63eea4 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,7 +5,7 @@ "sourceMap": true, "esModuleInterop": true, "strict": true, - "module": "esnext", + "module": "commonjs", "moduleResolution": "node", "target": "es6", "jsx": "preserve",