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 all 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
12 changes: 12 additions & 0 deletions .changeset/pre.json
@@ -0,0 +1,12 @@
{
"mode": "exit",
"tag": "alpha",
"initialVersions": {
"@getmash/client-sdk": "1.1.3",
"@getmash/jsonrpc-engine": "1.0.2",
"@getmash/post-message": "1.1.0"
},
"changesets": [
"strong-eagles-shop"
]
}
7 changes: 7 additions & 0 deletions .changeset/strong-eagles-shop.md
@@ -0,0 +1,7 @@
---
"@getmash/client-sdk": major
"@getmash/jsonrpc-engine": major
"@getmash/post-message": major
---

Upgrade all packages to ESM only. Dropping tech debt and simplifying our tooling.
31 changes: 15 additions & 16 deletions .github/workflows/test.yml
Expand Up @@ -41,29 +41,28 @@ jobs:
- name: Install dependencies
shell: bash
run: yarn install --immutable

- name: Check release definition
# Don't run on changeset-release branch as it does not require a changeset to update
# package versions. Simplifies the automation of package versioning and allows
# 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 references: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: eeshdarthvader/code-coverage-assistant@0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

# 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"

- name: Check release definition
# Don't run on changeset-release branch as it does not require a changeset to update
# package versions. Simplifies the automation of package versioning and allows
# branch protection rules
if: github.head_ref != 'changeset-release/main'
run: yarn release:status
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"]
},
}
},
};
39 changes: 39 additions & 0 deletions conf/jest/jest.base.js
@@ -0,0 +1,39 @@
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: ["src/**/*.{ts,tsx}"],
coverageDirectory: "coverage/",
extensionsToTreatAsEsm: [".ts", ".tsx", ".mts"],
moduleNameMapper: {
// jest resolver needs help finding the ts files from js extensions in imports
"^(\\.{1,2}/.*)\\.js$": "$1",
// there is a bug in jest and it can't handle the exports in this library
"^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.

8 changes: 8 additions & 0 deletions justfile
@@ -0,0 +1,8 @@
# default help menu lists tasks
@help:
just --list --justfile {{justfile()}} --list-heading $'mash-js\n'

# test all packages
@test:
yarn references:check
yarn workspaces foreach --topological --parallel run test
32 changes: 4 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,8 @@
"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"
}
}
Expand Up @@ -2,7 +2,6 @@ module.exports = {
extends: ["../../conf/eslintrc.base.js"],
root: true,
parserOptions: {
project: "tsconfig.lint.json",
tsconfigRootDir: __dirname,
},
};
7 changes: 0 additions & 7 deletions packages/client-sdk/.npmignore

This file was deleted.

12 changes: 12 additions & 0 deletions packages/client-sdk/CHANGELOG.md
@@ -1,5 +1,17 @@
# @getmash/client-sdk

## 2.0.0-alpha.0

### Major Changes

- [#20](https://github.com/getmash/mash-js/pull/20) [`46f3177`](https://github.com/getmash/mash-js/commit/46f3177fde43f265ddb41aeb9daad3b19ecc6aa7) Thanks [@nyonson](https://github.com/nyonson)! - Upgrade all packages to ESM only. Dropping tech debt and simplifying our tooling.

### Patch Changes

- Updated dependencies [[`46f3177`](https://github.com/getmash/mash-js/commit/46f3177fde43f265ddb41aeb9daad3b19ecc6aa7)]:
- @getmash/jsonrpc-engine@2.0.0-alpha.0
- @getmash/post-message@2.0.0-alpha.0

## 1.1.3

### Patch Changes
Expand Down
1 change: 1 addition & 0 deletions packages/client-sdk/jest.config.cjs
@@ -0,0 +1 @@
module.exports = require('../../conf/jest/jest.base.js')({ testEnvironment: "jsdom" });
45 changes: 38 additions & 7 deletions packages/client-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@getmash/client-sdk",
"version": "1.1.3",
"version": "2.0.0-alpha.0",
"description": "Mash Client SDK to interact with the Mash Wallet on a site",
"keywords": [
"lightning",
Expand All @@ -9,18 +9,27 @@
"mash",
"monetize"
],
"main": "dist/index.js",
"types": "dist/index.d.js",
"exports": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"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 && node --experimental-vm-modules $(yarn bin jest) src"
},
"dependencies": {
"@getmash/jsonrpc-engine": "^1.0.2",
"@getmash/post-message": "^1.1.0"
"@getmash/jsonrpc-engine": "^2.0.0-alpha.0",
"@getmash/post-message": "^2.0.0-alpha.0"
},
"files": [
"dist"
"dist",
"!dist/**/*.test.*"
],
"author": "Mash <support@getmash.com> (https://getmash.com/)",
"license": "MIT",
Expand All @@ -31,5 +40,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: 5 additions & 2 deletions packages/client-sdk/src/IFrame.test.ts
@@ -1,3 +1,5 @@
import { jest } from "@jest/globals";

import PostMessageEngine, { PostMessageEvent } from "@getmash/post-message";

import IFrame, {
Expand All @@ -12,8 +14,8 @@ import IFrame, {
MIN_CONTENT_WIDTH,
MAX_SHIFT_HORIZONTAL,
MAX_SHIFT_UP,
} from "./IFrame";
import { FloatLocation, MashSettings, merge } from "./settings";
} from "./IFrame.js";
import { FloatLocation, MashSettings, merge } from "./settings.js";

const IFRAME_SOURCE = "http://localhost";

Expand All @@ -36,6 +38,7 @@ function mockMatchMedia(mobile = false) {
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
Object.defineProperty(window, "matchMedia", {
writable: true,
// @ts-ignore ignore type of wrapped to allow mock to function
value: jest.fn().mockImplementation((query: string) => ({
matches: mobile,
media: query,
Expand Down