Skip to content

Commit

Permalink
add precommit hook to format code snippets (#55)
Browse files Browse the repository at this point in the history
* add pre-commit hook

* format code snippets
  • Loading branch information
eshaben authored Sep 25, 2024
1 parent 226c5bb commit d2c0a09
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 63 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ quote_type=single
indent_style=space
indent_size=4
max_line_length=80
quote_type=double
quote_type=double

[*.html]
max_line_length=off
9 changes: 9 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# Run Prettier on all files in snippets/code
echo "Running Prettier on the following files:"
npx prettier --write ".snippets/code/**/*.{js,ts,json,css,html}"

# Add formatted files back to the commit
echo "Adding formatted files back to the commit..."
git add $(find .snippets/code -name "*.js" -o -name "*.ts" -o -name "*.json" -o -name "*.css" -o -name "*.html")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>cargo build --release</span>
<span data-ty>Compiling solochain-template-node</span>
<span data-ty>Finished `release` profile [optimized] target(s) in 27.12s</span>
</div>
<span data-ty="input"><span class="file-path"></span>cargo build --release</span>
<span data-ty>Compiling solochain-template-node</span>
<span data-ty>Finished `release` profile [optimized] target(s) in 27.12s</span>
</div>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div id='termynal' data-termynal>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:32:47 💤 Idle (0 peers), best: #0 (0x0eef…935d), finalized #0 (0x0eef…935d), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:32:52 💤 Idle (0 peers), best: #1 (0xcb3d…265b), finalized #0 (0x0eef…935d), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:32:57 💤 Idle (0 peers), best: #2 (0x16d7…083f), finalized #0 (0x0eef…935d), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:33:02 💤 Idle (0 peers), best: #3 (0xe6a4…2cc4), finalized #1 (0xcb3d…265b), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
</div>
<div id="termynal" data-termynal>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:32:47 💤 Idle (0 peers), best: #0 (0x0eef…935d), finalized #0 (0x0eef…935d), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:32:52 💤 Idle (0 peers), best: #1 (0xcb3d…265b), finalized #0 (0x0eef…935d), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:32:57 💤 Idle (0 peers), best: #2 (0x16d7…083f), finalized #0 (0x0eef…935d), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
<span data-ty>2024-09-09 08:33:02 💤 Idle (0 peers), best: #3 (0xe6a4…2cc4), finalized #1 (0xcb3d…265b), ⬇ 0 ⬆ 0</span>
<span data-ty>...</span>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id='termynal' data-termynal>
<span data-ty>2024-09-10 09:10:03 💤 Idle (1 peers), best: #51 (0x0dd6…e763), finalized #49 (0xb70a…1fc0), ⬇ 0.7kiB/s ⬆ 0.6kiB/s</span>
<span data-ty>2024-09-10 09:10:08 💤 Idle (0 peers), best: #52 (0x2c40…a50e), finalized #49 (0xb70a…1fc0), ⬇ 0.3kiB/s ⬆ 0.3kiB/s</span>
</div>
<div id="termynal" data-termynal>
<span data-ty>2024-09-10 09:10:03 💤 Idle (1 peers), best: #51 (0x0dd6…e763), finalized #49 (0xb70a…1fc0), ⬇ 0.7kiB/s ⬆ 0.6kiB/s</span>
<span data-ty>2024-09-10 09:10:08 💤 Idle (0 peers), best: #52 (0x2c40…a50e), finalized #49 (0xb70a…1fc0), ⬇ 0.3kiB/s ⬆ 0.3kiB/s</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@
"0x2b06af9719ac64d755623cda8ddd9b94b1c371ded9e9c565e89ba783c4d5f5f9b4def25cfda6ef3a000000006f3d6b177c8acbd8dc9974cdb3cebfac4d31333c30865ff66c35c1bf898df5c5dd2924d3280e7201",
"0x9b000000"
],
[
"0x3a65787472696e7369635f696e646578",
null
],
["0x3a65787472696e7369635f696e646578", null],
[
"0x3f1467a096bcd71a5b6a0c8155e208103f2edf3bdf381debe331ab7446addfdc",
"0x550057381efedcffffffffffffffffff"
Expand Down Expand Up @@ -146,4 +143,4 @@
"offchainStorageDiff": [],
"runtimeLogs": []
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>npx @acala-network/chopsticks xcm \</span>
<span data-ty>--r polkadot \</span>
<span data-ty>--p moonbeam \</span>
<span data-ty>--p astar</span>
<br />
<span data-ty>[13:46:07.901] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/moonbeam.yml</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty>[13:46:12.631] INFO: Moonbeam RPC listening on port 8000</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty>[13:46:12.632] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/astar.yml</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty> chopsticks::executor TRACE: Calling Metadata_metadata</span>
<span data-ty> chopsticks::executor TRACE: Completed Metadata_metadata</span>
<span data-ty>[13:46:23.669] INFO: Astar RPC listening on port 8001</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty>[13:46:25.144] INFO (xcm): Connected parachains [2004,2006]</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty>[13:46:25.144] INFO: Loading config file https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/polkadot.yml</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty> chopsticks::executor TRACE: Calling Metadata_metadata</span>
<span data-ty> chopsticks::executor TRACE: Completed Metadata_metadata</span>
<span data-ty>[13:46:53.320] INFO: Polkadot RPC listening on port 8002</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty>[13:46:54.038] INFO (xcm): Connected relaychain 'Polkadot' with parachain 'Moonbeam'</span>
<span data-ty> app: "chopsticks"</span>
<span data-ty>[13:46:55.028] INFO (xcm): Connected relaychain 'Polkadot' with parachain 'Astar'</span>
<span data-ty> app: "chopsticks"</span>
</div>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
...,
"relaychain": {
"default_command": "polkadot",
"default_image": "polkadot-debug:master",
Expand All @@ -17,8 +16,6 @@
"validator": true,
"balance": 1000000000000
}
],
...
},
...
}
]
}
}
2 changes: 1 addition & 1 deletion develop/application-devs/tooling/chopsticks/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ npx @acala-network/chopsticks xcm \

After running it, you should see output similar to the following:

--8<-- 'code/tutorials/tooling/chopsticks/overview/terminal/fork-output.md'
--8<-- 'code/tutorials/tooling/chopsticks/overview/terminal/fork-output.html'

Now you can interact with your forked chains using the ports specified in the output.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ To start the validator nodes, follow these steps:
3. Review log messages as the node starts and take note of the `Local node identity` value. This value is the node’s peer ID, which you need to connect the parachain to the relay chain
--8<-- "code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.md"
--8<-- "code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-bootstraping-logs.html"
!!! note
You need to specify this identifier to enable other nodes to connect. In this case, the `Local node identity` is `12D3KooWG393uX82rR3QgDkZpb7U8StzuRx9BQUXCvWsP1ctgygp`.
Expand Down Expand Up @@ -161,6 +161,6 @@ To start the validator nodes, follow these steps:
5. Verify that the relay chain nodes are running by checking the logs for each node. The logs should show that the nodes are connected to each other and producing blocks. For example, Bob's logs will be displayed as follows:

--8<-- "code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.md"
--8<-- "code/tutorials/polkadot-sdk/build-a-parachain/prepare-relay-chain/relay-chain-running-logs.html"

Once the relay chain nodes are running, you can proceed to the next tutorial to set up a test parachain node and connect it to the relay chain.

0 comments on commit d2c0a09

Please sign in to comment.