Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winter 2022 build update #20

Merged
merged 31 commits into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
899acda
Introduce monorepo reference tools
nyonson Nov 4, 2022
4b83ab3
Update workflow
nyonson Nov 4, 2022
a4d94ac
Post coverage
nyonson Nov 4, 2022
29bb982
move deps to packages
nyonson Nov 4, 2022
77f9809
Move linting down
nyonson Nov 4, 2022
a98f27f
Add some jest configs
nyonson Nov 4, 2022
24e9a76
Jest almost working
nyonson Nov 4, 2022
d2725cb
Jest testing
nyonson Nov 4, 2022
b3a8ca8
fix test
nyonson Nov 5, 2022
93b0053
Maybe package type module
nyonson Nov 7, 2022
dbdecab
got jest working
nyonson Nov 7, 2022
93a4409
Add some comments to jest
nyonson Nov 8, 2022
6e3df89
more tweaks
nyonson Nov 8, 2022
481ae83
update rest of repo
nyonson Nov 8, 2022
97aed2b
more fixes
nyonson Nov 8, 2022
086e147
BAIL
nyonson Nov 8, 2022
ab2a00f
try different action
nyonson Nov 8, 2022
b23f3a7
Use real version
nyonson Nov 8, 2022
9a73dc9
move release check to end
nyonson Nov 8, 2022
5ea1e90
spelling
nyonson Nov 8, 2022
3881301
Fix shitty coverage detection
mdedys Nov 8, 2022
5bcda32
Do not publish tests and simplify ignore rules
nyonson Nov 8, 2022
a0b9fd2
Merge branch 'chore/winter-2022-build-update' of github.com:getmash/m…
nyonson Nov 8, 2022
46f3177
Changeset
nyonson Nov 8, 2022
bcac016
add justfile
nyonson Nov 8, 2022
0f39331
add references check to test target
nyonson Nov 8, 2022
947d149
Switch default export to import
mdedys Nov 9, 2022
640a4b1
Revert to top-level module and types to support typescript node modul…
mdedys Nov 9, 2022
b775863
Prelease
mdedys Nov 11, 2022
d650217
Exit from changeset pre mode
mdedys Nov 11, 2022
cd4b139
Update yarn lock file
mdedys Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/test.yml
Expand Up @@ -48,22 +48,21 @@ jobs:
# branch protection rules
if: github.head_ref != 'changeset-release/main'
run: yarn release:status

- name: Buld packages
shell: bash
run: yarn build
# Fails if project references drift from package.json, fix with reference script
- name: Check project reference
run: yarn reference:check

- name: Test packages
run: yarn test
run: yarn workspaces foreach --topological --parallel run test

- name: Lint packages
run: yarn lint
run: yarn workspaces foreach --topological --parallel run lint

- name: Post coverage
uses: vebr/jest-lcov-reporter@v0.2.1
uses: ScaCap/code-coverage-assistant@v1
# only post on PRs
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
lcov-file: ./coverage/lcov.info
monorepo-base-path: "./packages"
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -24,7 +24,7 @@ coverage
*.tsbuildinfo

# jest
.cache/jest
**/.cache/jest

#parcel
.parcel-cache
8 changes: 8 additions & 0 deletions conf/README.md
Expand Up @@ -2,6 +2,14 @@

Configuration files shared by the packages in the monorepo.

## TypeScript

`tsconfig.base.json` is the base TypeScript shared by all tools and packages.

## eslint

We need to keep `.eslintrc` files out of root or LSPs will create an instance to lint the entire repository. Quickly bogs down.

## jest

`jest.base.js` is imported by all packages.
12 changes: 11 additions & 1 deletion conf/eslintrc.base.js
Expand Up @@ -53,5 +53,15 @@ module.exports = {
],
"@typescript-eslint/ban-ts-comment": "off",
},
settings: {},
settings: {
// import settings along with eslint-import-resolver-typescript allow js imports to be mapped back to ts files
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"project": ["tsconfig.json"]
},
}
},
};
37 changes: 37 additions & 0 deletions conf/jest/jest.base.js
@@ -0,0 +1,37 @@
const path = require("path");

const tsconfig = path.join(__dirname, "tsconfig.test.json");
const setupPostMessage = path.join(__dirname, "setupPostMessage.js");

function generate(config) {
return Object.assign(
{
cache: true,
cacheDirectory: ".cache/jest",
/*
* Automatically clear mock calls and instances before every test.
* Equivalent to calling jest.clearAllMocks() before each test.
* This does not remove any mock implementation that may have been provided.
*/
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: [ "**/*.{ts,tsx}" ],
coverageDirectory: "coverage/",
extensionsToTreatAsEsm: [".ts", ".tsx", ".mts"],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
nyonson marked this conversation as resolved.
Show resolved Hide resolved
'^uuid$': require.resolve('uuid'),
},
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{ useESM: true, tsconfig, diagnostics: false },
],
},
setupFiles: [setupPostMessage],
},
config,
);
}

module.exports = generate
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.test.json → conf/jest/tsconfig.test.json
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"noEmit": true
Expand Down
File renamed without changes.
58 changes: 0 additions & 58 deletions jest.config.js

This file was deleted.

34 changes: 6 additions & 28 deletions package.json
Expand Up @@ -17,13 +17,8 @@
"packages/*"
],
"scripts": {
"clean": "yarn workspaces foreach -p run clean",
"build": "yarn clean && yarn workspaces foreach -ipt run build",
"lint": "eslint packages/*",
"lint:fix": "eslint --fix packages/*",
"test": "jest --colors",
"test:config": "jest --showConfig",
"test:watch": "jest --watch --colors",
mdedys marked this conversation as resolved.
Show resolved Hide resolved
"references": "yarn workspaces-to-typescript-project-references --includesRoot",
"references:check": "yarn workspaces-to-typescript-project-references --includesRoot --check",
"release:add:empty": "yarn changeset add --empty",
"release:add": "yarn changeset add",
"release:status": "yarn changeset status --since origin/main --output",
Expand All @@ -32,27 +27,10 @@
"release": "yarn clean && yarn build && yarn release:publish"
},
"devDependencies": {
"@babel/preset-env": "^7.19.3",
"@changesets/changelog-github": "^0.4.7",
"@types/babel__preset-env": "^7",
"@types/eslint": "^8",
"@types/jest": "^29.1.1",
"@typescript-eslint/eslint-plugin": "^5.39.0",
"@typescript-eslint/parser": "^5.39.0",
"babel-jest": "^29.1.2",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.1.2",
"jest-environment-jsdom": "^29.1.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"tslib": "^2.4.0",
"typescript": "^4.8.4"
},
"dependencies": {
"@changesets/cli": "^2.25.0"
"@changesets/cli": "^2.25.0",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.8.2",
"@types/jest": "^29.2.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be in each package now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, yea, not sure why it got added here

"eslint-import-resolver-typescript": "^3.5.2"
}
}
1 change: 0 additions & 1 deletion packages/client-sdk/.eslintrc.js
Expand Up @@ -2,7 +2,6 @@ module.exports = {
extends: ["../../conf/eslintrc.base.js"],
root: true,
parserOptions: {
project: "tsconfig.lint.json",
tsconfigRootDir: __dirname,
},
};
1 change: 1 addition & 0 deletions packages/client-sdk/jest.config.js
@@ -0,0 +1 @@
module.exports = require('../../conf/jest/jest.base.js')({ testEnvironment: "jsdom" });
27 changes: 26 additions & 1 deletion packages/client-sdk/package.json
Expand Up @@ -13,7 +13,10 @@
"types": "dist/index.d.js",
"scripts": {
"clean": "rm -f tsconfig.tsbuildinfo && rm -rf dist",
"build": "tsc --build"
"build": "tsc --build",
"lint": "tsc --build && eslint",
"lint:fix": "tsc --build && eslint --fix",
"test": "tsc --build && jest"
nyonson marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@getmash/jsonrpc-engine": "^1.0.2",
Expand All @@ -31,5 +34,27 @@
},
"bugs": {
"url": "https://github.com/getmash/mash-js/issues"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@types/babel__preset-env": "^7",
"@types/eslint": "^8",
"@types/jest": "^29.2.2",
"@types/prettier": "^2",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"babel-jest": "^29.2.2",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.4",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"typescript": "^4.8.4"
}
}
7 changes: 3 additions & 4 deletions packages/client-sdk/tsconfig.json
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../conf/tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"outDir": "./dist"
},
"include": ["./src/**/*.ts"],
"exclude": ["./src/**/*.test.*"],
"include": ["./src/**/*"],
"references": [{ "path": "../jsonrpc-engine" }, { "path": "../post-message" }]
}
6 changes: 0 additions & 6 deletions packages/client-sdk/tsconfig.lint.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/jsonrpc-engine/.eslintrc.js
Expand Up @@ -2,7 +2,6 @@ module.exports = {
extends: ["../../conf/eslintrc.base.js"],
root: true,
parserOptions: {
project: "tsconfig.lint.json",
tsconfigRootDir: __dirname,
},
};
30 changes: 27 additions & 3 deletions packages/jsonrpc-engine/package.json
@@ -1,23 +1,47 @@
{
"name": "@getmash/jsonrpc-engine",
"version": "1.0.2",
"description": "JsonRPC wrapper over window.postMessage to allow a structured method to call functions through window.postMessage",
"description": "JsonRPC wrapper over window.postMessage to allow a structured method to call functions through window.postMessage",
"keywords": [
"post message",
"jsonrpc"
],
"main": "dist/index.js",
"type": "module",
nyonson marked this conversation as resolved.
Show resolved Hide resolved
"types": "dist/index.d.ts",
"scripts": {
"clean": "rm -f tsconfig.tsbuildinfo && rm -rf dist",
"build": "tsc --build"
"build": "tsc --build",
"lint": "tsc --build && eslint",
"lint:fix": "tsc --build && eslint --fix",
"test": "tsc --build && jest"
},
"dependencies": {
"@getmash/post-message": "^1.0.2",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/uuid": "^8.3.4"
"@babel/preset-env": "^7.20.2",
"@types/babel__preset-env": "^7",
"@types/eslint": "^8",
"@types/jest": "^29.2.2",
"@types/prettier": "^2",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"babel-jest": "^29.2.2",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.4",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"typescript": "^4.8.4"
},
"files": [
"dist"
Expand Down
7 changes: 3 additions & 4 deletions packages/jsonrpc-engine/tsconfig.json
@@ -1,10 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../conf/tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"outDir": "./dist"
},
"include": ["./src/**/*.ts"],
"exclude": ["./src/**/*.test.*"],
"include": ["./src/**/*"],
"references": [{ "path": "../post-message" }]
}
6 changes: 0 additions & 6 deletions packages/jsonrpc-engine/tsconfig.lint.json

This file was deleted.

Expand Up @@ -2,7 +2,6 @@ module.exports = {
extends: ["../../conf/eslintrc.base.js"],
root: true,
parserOptions: {
project: "tsconfig.lint.json",
tsconfigRootDir: __dirname,
},
};
1 change: 1 addition & 0 deletions packages/post-message/jest.config.cjs
@@ -0,0 +1 @@
module.exports = require('../../conf/jest/jest.base.js')({ testEnvironment: "jsdom" });