Skip to content

Commit

Permalink
Merge pull request #17 from xmtp/rygine/yarn-turbo
Browse files Browse the repository at this point in the history
Convert to a yarn turborepo monorepo
  • Loading branch information
rygine authored Jan 30, 2024
2 parents c12275a + 5ecc047 commit c7e7bc3
Show file tree
Hide file tree
Showing 14 changed files with 28,430 additions and 79 deletions.
5 changes: 1 addition & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

* @MetaMask/snaps-devs
* @xmtp/web
84 changes: 64 additions & 20 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,70 @@ on:
pull_request:

jobs:
build-lint-test:
name: Build, Lint, and Test
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [18.x]
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm run test
all-jobs-pass:
name: All jobs pass
runs-on: ubuntu-20.04
needs:
- build-lint-test
node-version-file: ".nvmrc"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Check code format
run: yarn format:check

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Lint
run: yarn lint

test:
runs-on: ubuntu-latest
steps:
- run: echo "Great success!"
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Run tests
run: yarn test

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
17 changes: 9 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ jobs:
issues: write
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Use latest NPM
# Ensure we are using the latest version of NPM to get support for provenance
run: npm i -g npm
cache: 'yarn'
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
working-directory: packages/snap
run: npm ci
run: yarn
- name: Release
working-directory: packages/snap
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
run: yarn dlx semantic-release
893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
compressionLevel: mixed

enableGlobalCache: false

enableTelemetry: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.0.cjs
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
"license": "(MIT-0 OR Apache-2.0)",
"author": "",
"workspaces": [
"packages/site",
"packages/snap"
"packages/*"
],
"scripts": {
"build": "npm run build --workspaces",
"lint": "npm run lint:eslint && npm run lint:misc --check",
"lint:eslint": "npm run lint:eslint --workspace=site && npm run lint:eslint --workspace=@xmtp/snap",
"lint:fix": "npm run lint:eslint --fix && npm run lint:misc --write",
"lint:misc": "prettier '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"start": "concurrently \"npm start --workspace=site\" \"npm start --workspace=@xmtp/snap\"",
"test": "npm test --workspace=@xmtp/snap"
"build": "turbo run build --filter='./packages/snap'",
"clean": "turbo run clean && rm -rf node_modules && yarn cache clean",
"format:check": "turbo run format:check",
"format": "turbo run format",
"lint": "FORCE_COLOR=1 turbo run lint --filter='./packages/snap'",
"dev": "turbo run dev",
"test": "FORCE_COLOR=1 turbo run test"
},
"devDependencies": {
"@metamask/eslint-config": "^12.2.0",
Expand All @@ -44,9 +43,11 @@
"prettier": "^2.2.1",
"prettier-plugin-packagejson": "^2.2.18",
"semantic-release": "^21.0.7",
"turbo": "^1.11.3",
"typescript": "^5.1.0"
},
"engines": {
"node": ">=16.0.0"
}
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/site/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
23 changes: 13 additions & 10 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"private": true,
"license": "(MIT-0 OR Apache-2.0)",
"scripts": {
"build": "vite build",
"clean": "rimraf public",
"lint": "npm run lint:eslint && npm run lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "npm run lint:eslint -- --fix && npm run lint:misc -- --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path .gitignore",
"start": "vite",
"test": "echo TODO"
"build": "yarn clean:lib && vite build",
"clean": "rm -rf .turbo && rm -rf node_modules && yarn clean:lib",
"clean:lib": "rm -rf dist",
"dev": "vite",
"format": "yarn format:base -w .",
"format:base": "prettier --ignore-path ../../.gitignore",
"format:check": "yarn format:base -c .",
"lint": "eslint . --ignore-path ../../.gitignore"
},
"browserslist": {
"production": [
Expand All @@ -27,8 +27,8 @@
},
"dependencies": {
"@metamask/providers": "^9.0.0",
"@xmtp/proto": "^3.34.0",
"@xmtp/xmtp-js": "^11.3.0-beta.13",
"@xmtp/proto": "3.34.0",
"@xmtp/xmtp-js": "11.3.0-beta.13",
"buffer": "^6.0.3",
"ethers": "^6.6.2",
"react": "^18.2.0",
Expand All @@ -54,15 +54,18 @@
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"@vitejs/plugin-react": "^4.2.0",
"babel-plugin-styled-components": "^2.1.4",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"eslint": "^8.55.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jsdoc": "^43.0.7",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"gatsby": "^4.25.7",
"gatsby-plugin-manifest": "^4.24.0",
"gatsby-plugin-styled-components": "^5.24.0",
Expand Down
29 changes: 15 additions & 14 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@
"snap.manifest.json"
],
"scripts": {
"build": "mm-snap build --transpilationMode=localAndDeps",
"build:clean": "npm run clean && npm run build",
"build:website": "node ./scripts/build-website.js",
"clean": "rimraf dist",
"lint": "npm run lint:eslint && npm run lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "npm run lint:eslint -- --fix && npm run lint:misc -- --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path .gitignore",
"prepublishOnly": "npm run build:clean",
"build": "yarn clean:lib && mm-snap build --transpilationMode=localAndDeps",
"clean": "rm -rf .turbo && rm -rf node_modules && yarn clean:lib",
"clean:lib": "rm -rf dist",
"dev": "yarn clean:lib && mm-snap watch --transpilationMode=localAndDeps",
"format": "yarn format:base -w .",
"format:base": "prettier --ignore-path ../../.gitignore",
"format:check": "yarn format:base -c .",
"lint": "eslint . --ignore-path ../../.gitignore",
"prepublishOnly": "yarn build",
"serve": "mm-snap serve",
"start": "mm-snap watch --transpilationMode=localAndDeps",
"pretest": "npm run build",
"test": "jest --runInBand"
"pretest": "yarn build",
"test": "yarn build && jest --runInBand"
},
"release": {
"branches": [
Expand All @@ -38,8 +37,8 @@
]
},
"dependencies": {
"@xmtp/proto": "^3.34.0",
"@xmtp/xmtp-js": "^11.3.0-beta.13",
"@xmtp/proto": "3.34.0",
"@xmtp/xmtp-js": "11.3.0-beta.13",
"async-mutex": "^0.4.0",
"buffer": "^6.0.3",
"protobufjs": "^7.2.4"
Expand All @@ -60,8 +59,10 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jsdoc": "^43.0.7",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"ethers": "^6.6.2",
"jest": "^29.6.0",
"prettier": "^2.7.1",
Expand Down
9 changes: 8 additions & 1 deletion packages/snap/snap.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SnapConfig } from '@metamask/snaps-cli';
import { merge, type SnapConfig } from '@metamask/snaps-cli';

const config: SnapConfig = {
input: './src/index.ts',
Expand All @@ -11,6 +11,13 @@ const config: SnapConfig = {
experimental: {
wasm: true,
},
customizeWebpackConfig: (baseConfig) => {
return merge(baseConfig, {
output: {
chunkFormat: 'commonjs',
},
});
},
};

export default config;
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/xmtp/snap.git"
},
"source": {
"shasum": "LpjIZral3c0MjqEcc4mp6eQ8o3pvR1CyVvrkqgRwSXc=",
"shasum": "ax7SLJYHvMBFzUG2SWGVve7Jur9xujigTCIk7tnzsIM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
10 changes: 0 additions & 10 deletions scripts/cleanup.sh

This file was deleted.

30 changes: 30 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"clean": {
"outputs": []
},
"format": {
"outputs": []
},
"format:check": {
"outputs": []
},
"lint": {
"dependsOn": ["^build"],
"outputs": []
},
"dev": {
"dependsOn": ["^build"],
"persistent": true
},
"test": {
"outputs": []
}
}
}
Loading

0 comments on commit c7e7bc3

Please sign in to comment.