Skip to content

Commit 3c64927

Browse files
Merge pull request #14 from developerfred/refactory
Refactory Papi Simulator
2 parents 3ccb373 + 0035751 commit 3c64927

61 files changed

Lines changed: 4069 additions & 2386 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/update-papi.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Update Polkadot API
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-updates:
10+
runs-on: ubuntu-latest
11+
12+
outputs:
13+
has_updates: ${{ steps.check-version.outputs.has_updates }}
14+
new_version: ${{ steps.check-version.outputs.new_version }}
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: '20'
24+
cache: 'npm'
25+
26+
- name: Get current Polkadot API version
27+
id: current-version
28+
run: |
29+
CURRENT_VERSION=$(npm list polkadot-api --json | jq -r '.dependencies."polkadot-api".version')
30+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
31+
32+
- name: Check latest Polkadot API version
33+
id: check-version
34+
run: |
35+
LATEST_VERSION=$(npm view polkadot-api version)
36+
echo "Latest version: $LATEST_VERSION"
37+
echo "Current version: ${{ steps.current-version.outputs.current_version }}"
38+
39+
if [ "$LATEST_VERSION" != "${{ steps.current-version.outputs.current_version }}" ]; then
40+
echo "has_updates=true" >> $GITHUB_OUTPUT
41+
echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
42+
else
43+
echo "has_updates=false" >> $GITHUB_OUTPUT
44+
fi
45+
46+
update-papi:
47+
needs: check-updates
48+
if: needs.check-updates.outputs.has_updates == 'true'
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v3
54+
55+
- name: Setup Node.js
56+
uses: actions/setup-node@v3
57+
with:
58+
node-version: '20'
59+
cache: 'npm'
60+
61+
- name: Update Polkadot API
62+
run: |
63+
npm install polkadot-api@${{ needs.check-updates.outputs.new_version }}
64+
npx papi
65+
66+
- name: Run tests
67+
run: npm test
68+
69+
- name: Create Pull Request
70+
uses: peter-evans/create-pull-request@v5
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
commit-message: "Update Polkadot API to v${{ needs.check-updates.outputs.new_version }}"
74+
title: "Update Polkadot API to v${{ needs.check-updates.outputs.new_version }}"
75+
body: |
76+
This PR updates Polkadot API to v${{ needs.check-updates.outputs.new_version }}.
77+
78+
- Automatically generated by GitHub Actions
79+
- The descriptors have been regenerated using `papi`
80+
81+
Please verify the changes and merge if all tests pass.
82+
branch: "update-papi-v${{ needs.check-updates.outputs.new_version }}"
83+
base: main
84+
labels: dependencies,automated

next.config.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
1-
import type { NextConfig } from "next";
1+
import type { NextConfig } from 'next';
2+
import type { Configuration } from 'webpack';
3+
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
24

35
const nextConfig: NextConfig = {
4-
/* config options here */
6+
webpack: (config: Configuration, { isServer }): Configuration => {
7+
config.module = config.module || { rules: [] };
8+
config.module.rules = config.module.rules || [];
9+
10+
if (!isServer) {
11+
config.plugins = config.plugins || [];
12+
config.plugins.push(
13+
new MonacoWebpackPlugin({
14+
languages: ['typescript', 'javascript'],
15+
filename: 'static/[name].worker.js',
16+
})
17+
);
18+
}
19+
20+
config.module.rules.push({
21+
test: /\.d\.ts$/,
22+
use: 'raw-loader',
23+
});
24+
25+
return config;
26+
},
27+
poweredByHeader: false,
28+
reactStrictMode: true,
529
};
630

7-
export default nextConfig;
31+
export default nextConfig;

package.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "papi-simulator",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"author": "codingsh <codinsh@pm.me>",
55
"private": true,
66
"scripts": {
@@ -11,21 +11,31 @@
1111
},
1212
"dependencies": {
1313
"@monaco-editor/react": "^4.7.0",
14+
"@polkadot/api": "^15.9.2",
15+
"@types/webpack": "^5.28.5",
16+
"biome": "^0.3.3",
1417
"classnames": "^2.5.1",
1518
"lucide-react": "^0.487.0",
19+
"monaco-editor": "^0.52.2",
20+
"monaco-editor-webpack-plugin": "^7.1.0",
1621
"next": "15.2.4",
22+
"polkadot-api": "^1.9.13",
1723
"react": "^19.0.0",
18-
"react-dom": "^19.0.0"
24+
"react-dom": "^19.0.0",
25+
"rxjs": "^7.8.2",
26+
"webpack": "^5.99.6"
1927
},
2028
"devDependencies": {
21-
"typescript": "^5",
29+
"@biomejs/biome": "^1.9.4",
30+
"@eslint/eslintrc": "^3",
31+
"@tailwindcss/postcss": "^4",
2232
"@types/node": "^20",
2333
"@types/react": "^19",
2434
"@types/react-dom": "^19",
25-
"@tailwindcss/postcss": "^4",
26-
"tailwindcss": "^4",
2735
"eslint": "^9",
2836
"eslint-config-next": "15.2.4",
29-
"@eslint/eslintrc": "^3"
37+
"i": "^0.3.7",
38+
"tailwindcss": "^4",
39+
"typescript": "^5"
3040
}
3141
}

0 commit comments

Comments
 (0)