Skip to content

Commit

Permalink
refactor: ✨ Create TS monorepo structure (#3091)
Browse files Browse the repository at this point in the history
* refactor: ✨ Dual publish typesbundle properly

* refactor: ✨ ApiAugment fixed paths

* feat: ✨ Added new ScrapeMetadata script

* build: 🏗️ add built `/dist` to repo

* style: 💄 lint

* style: 💄 Exclude dist from editorconfig

* fix: 🐛 Fix typegen check CI

* refactor: ♻️ Tidy script call

* fix: 🐛 Fix tracing CI

* refactor: ♻️ Remove dist from repo

* remove dist

* fix: 📦 Fix packages!

* fix: 💚 Fix typegen CI

* style: 🚨 pretty

* ci: 👷 Disable typegen check
  • Loading branch information
timbrinded authored Dec 11, 2024
1 parent 24de03a commit 276c527
Show file tree
Hide file tree
Showing 33 changed files with 1,239 additions and 895 deletions.
16 changes: 0 additions & 16 deletions .github/workflow-templates/dev-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ runs:
cache: "pnpm"
cache-dependency-path: pnpm-lock.yaml

- name: Setup Moonbeam PolkadotJS types
shell: bash
run: |
#### Preparing the legacy types
cd moonbeam-types-bundle
pnpm i
pnpm build
#### Preparing the typescript api
cd ../typescript-api
pnpm i
pnpm build
cd ../test
pnpm add ../typescript-api
- name: "Install and run dev test"
shell: bash
env:
Expand Down
99 changes: 43 additions & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
chmod +x bin/ec-linux-amd64
- name: Check files
# Prettier and editorconfig-checker have different ideas about indentation
run: /tmp/bin/ec-linux-amd64 --exclude "(typescript-api\/)|(test\/contracts\/lib\/.*)" -disable-indent-size
run: /tmp/bin/ec-linux-amd64 --exclude "(typescript-api\/)|(test\/contracts\/lib\/.*)|(\/?dist\/)" -disable-indent-size

check-prettier:
name: "Check with Prettier"
Expand Down Expand Up @@ -554,6 +554,48 @@ jobs:
- name: Run sccache stat for check pre test
run: ${SCCACHE_PATH} --show-stats

# Renable typegen_check when we have a bot in place to update PR for us in case of missing it

# typegen_check:
# needs: ["set-tags", "build"]
# name: "Check Rust/TS bindings are up to date"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# ref: ${{ needs.set-tags.outputs.git_ref }}
# - uses: pnpm/action-setup@v4
# with:
# version: 9
# - uses: actions/setup-node@v4
# with:
# node-version-file: "test/.nvmrc"
# cache: "pnpm"
# cache-dependency-path: pnpm-lock.yaml
# - name: "Download branch built node"
# uses: actions/download-artifact@v4
# with:
# name: moonbeam
# path: target/release
# - run: chmod uog+x target/release/moonbeam
# - name: Run Typegen
# run: |
# pnpm i

# cd test
# pnpm typegen
# - name: Check for changes
# run: |
# cd typescript-api
# if [ -n "$(git status --porcelain .)" ]; then
# echo "Typegen produced changes. Please run 'pnpm typegen' locally and commit the changes."
# false
# else
# echo "No changes"
# true
# fi

dev-test:
runs-on:
labels: bare-metal
Expand Down Expand Up @@ -661,16 +703,6 @@ jobs:
run: |
chmod uog+x build/moonbeam
chmod uog+x target/release/moonbeam
#### Preparing the repository
cd moonbeam-types-bundle
pnpm i
pnpm build
#### Preparing the typescript api
cd ../typescript-api
pnpm i
pnpm build
- name: Running Tracing Tests
env:
DEBUG_COLOURS: "1"
Expand Down Expand Up @@ -774,21 +806,6 @@ jobs:
with:
name: moonbeam
path: target/release
- name: Setup Moonbeam PolkadotJS types
shell: bash
run: |
#### Preparing the legacy types
cd moonbeam-types-bundle
pnpm i
pnpm build
#### Preparing the typescript api
cd ../typescript-api
pnpm i
pnpm build
cd ../test
pnpm add ../typescript-api
- name: "Run lazy loading tests"
run: |
chmod uog+x target/release/moonbeam
Expand Down Expand Up @@ -842,21 +859,6 @@ jobs:
with:
name: runtimes
path: target/release/wbuild/${{ matrix.chain }}-runtime/
- name: Setup Moonbeam PolkadotJS types
shell: bash
run: |
#### Preparing the legacy types
cd moonbeam-types-bundle
pnpm i
pnpm build
#### Preparing the typescript api
cd ../typescript-api
pnpm i
pnpm build
cd ../test
pnpm add ../typescript-api
- name: "Install and run upgrade test"
run: |
cd test
Expand Down Expand Up @@ -919,21 +921,6 @@ jobs:
docker create --name moonbeam_container $DOCKER_TAG bash
docker cp moonbeam_container:moonbeam/moonbeam test/tmp/moonbeam_rt
docker rm -f moonbeam_container
- name: Setup Moonbeam PolkadotJS types
shell: bash
run: |
#### Preparing the legacy types
cd moonbeam-types-bundle
pnpm i
pnpm build
#### Preparing the typescript api
cd ../typescript-api
pnpm i
pnpm build
cd ../test
pnpm add ../typescript-api
- name: Prepare Chainspecs
run: |
cd test
Expand Down
65 changes: 0 additions & 65 deletions .github/workflows/upgrade-typescript-api.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Typescript directories
**/node_modules
**/.yarn
**/dist

# Spec/Wasm build directory
/build/
Expand Down
2 changes: 0 additions & 2 deletions moonbeam-types-bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# ignore files generated by typescript
dist/
**.json
tsconfig.tsbuildinfo
44 changes: 30 additions & 14 deletions moonbeam-types-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@
"name": "moonbeam-types-bundle",
"version": "3.0.0",
"description": "Bundled types to instantiate the Polkadot JS api with a Moonbeam network",
"main": "dist/index.js",
"main": "./dist/definitions.cjs",
"prepublish": "tsc",
"type": "module",
"module": "./dist/definitions.js",
"types": "./dist/types/definitions.d.ts",
"types": "./dist/definitions.d.ts",
"exports": {
".": {
"types": "./dist/types/definitions.d.ts",
"module": "./dist/definitions.js",
"default": "./dist/definitions.js"
"types": "./dist/definitions.d.ts",
"import": "./dist/definitions.js",
"require": "./dist/definitions.cjs"
},
"./types": {
"types": "./dist/types.d.ts",
"import": "./dist/types.js",
"require": "./dist/types.cjs"
},
"./rpc": {
"types": "./dist/rpc.d.ts",
"import": "./dist/rpc.js",
"require": "./dist/rpc.cjs"
}
},
"files": [
"dist",
"src"
],
"scripts": {
"clean": "rm -rf node_modules && rm -rf dist",
"tsc": "tsc --noEmit --pretty",
"build": "tsc -b --verbose",
"build": "tsup src --format cjs,esm --dts --no-splitting",
"publish-package": "npm run build && npm publish",
"fmt:fix": "prettier --write --ignore-path .gitignore '**/*.(yml|js|ts|json)'"
},
Expand All @@ -35,13 +50,14 @@
"url": "git+https://github.com/moonbeam-foundation/moonbeam.git"
},
"dependencies": {
"@polkadot/api": "14.0.1",
"@polkadot/api-base": "14.0.1",
"@polkadot/rpc-core": "14.0.1",
"@polkadot/typegen": "14.0.1",
"@polkadot/types": "14.0.1",
"@polkadot/types-codec": "14.0.1",
"prettier": "2.8.8",
"typescript": "5.6.2"
"@polkadot/api": "*",
"@polkadot/api-base": "*",
"@polkadot/rpc-core": "*",
"@polkadot/typegen": "*",
"@polkadot/types": "*",
"@polkadot/types-codec": "*",
"prettier": "*",
"tsup": "*",
"typescript": "*"
}
}
11 changes: 6 additions & 5 deletions moonbeam-types-bundle/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"declaration": true,
"declarationDir": "dist/types",
"allowImportingTsExtensions": false,
"typeRoots": [
// "dist/types",
"node_modules/@types"
],
"skipLibCheck": true
"typeRoots": ["node_modules/@types"],
"skipLibCheck": true,
"moduleResolution": "bundler",
"module": "ESNext",
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "scripts"]
Expand Down
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "moonbeam",
"version": "1.0.0",
"description": "Moonbeam Network Monorepo",
"private": true,
"type": "module",
"workspaces": [
"test",
"typescript-api",
"moonbeam-types-bundle"
],
"scripts": {
"clean-all": "rm -rf node_modules && pnpm -r clean",
"build": "pnpm -r build",
"postinstall": "pnpm build",
"lint": "pnpm -r lint",
"fmt": "pnpm -r fmt",
"fmt:fix": "pnpm -r fmt:fix"
},
"dependencies": {
"@polkadot/api": "14.3.1",
"@polkadot/api-augment": "14.3.1",
"@polkadot/api-derive": "14.3.1",
"@polkadot/keyring": "13.2.3",
"@polkadot/rpc-provider": "14.3.1",
"@polkadot/types": "14.3.1",
"@polkadot/types-codec": "14.3.1",
"@polkadot/util": "13.2.3",
"@polkadot/util-crypto": "13.2.3",
"ethers": "6.13.4",
"tsup": "8.3.5"
},
"devDependencies": {
"@types/node": "^22.10.1",
"eslint": "^8.55.0",
"prettier": "2.8.8",
"tsx": "^4.19.2",
"typescript": "^5.3.3"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Loading

0 comments on commit 276c527

Please sign in to comment.