Skip to content

Commit 1948f5f

Browse files
committed
docs: deploy example aepps
1 parent 194588f commit 1948f5f

File tree

11 files changed

+68
-34
lines changed

11 files changed

+68
-34
lines changed

.github/workflows/docs-develop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,13 @@ jobs:
1818
with:
1919
path: ~/.cache/pip3
2020
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
21+
- uses: actions/cache@v3
22+
with:
23+
path: |
24+
~/.npm
25+
~/.autorest
26+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
2127
- run: pip3 install -r docs/requirements.txt
28+
- run: git config --global user.email "[email protected]"
29+
- run: git config --global user.name "GitHub Action"
2230
- run: mike deploy --push develop

.github/workflows/docs-release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ jobs:
1717
with:
1818
path: ~/.cache/pip3
1919
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
20+
- uses: actions/cache@v3
21+
with:
22+
path: |
23+
~/.npm
24+
~/.autorest
25+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
2026
- run: pip3 install -r docs/requirements.txt
2127
- run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
28+
- run: git config --global user.email "[email protected]"
29+
- run: git config --global user.name "GitHub Action"
2230
- run: mike deploy --push --update-aliases $RELEASE_VERSION latest

docs/build-assets.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
[ ! -d "node_modules" ] && npm i
5+
npm run docs:examples
6+
npm run docs:api
7+
8+
# TODO: revisit --ignore-scripts after solving https://github.com/npm/cli/issues/4202
9+
perl -i -pe 's/"prepare"/"rem-prepare"/g' package.json
10+
mkdir -p docs/examples/browser
11+
12+
echo Build example aepp
13+
cd ./examples/browser/aepp
14+
npm i
15+
VUE_APP_WALLET_URL=../wallet-iframe/ PUBLIC_PATH=./ npm run build
16+
rm -rf ../../../docs/examples/browser/aepp
17+
mv dist/ ../../../docs/examples/browser/aepp
18+
19+
echo Build example wallet-iframe
20+
cd ../wallet-iframe
21+
npm i
22+
VUE_APP_AEPP_URL=../aepp/ PUBLIC_PATH=./ npm run build
23+
rm -rf ../../../docs/examples/browser/wallet-iframe
24+
mv dist/ ../../../docs/examples/browser/wallet-iframe
25+
26+
echo Build example wallet-web-extension
27+
cd ../wallet-web-extension
28+
npm i
29+
NODE_OPTIONS=--openssl-legacy-provider npm run build
30+
mv artifacts/wallet-web-extension-v0.1.0-production.zip ../../../docs/examples/browser/wallet-web-extension.zip
31+
32+
cd ../../..
33+
perl -i -pe 's/"rem-prepare"/"prepare"/g' package.json

docs/hooks.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import os.path
21
import subprocess
32
import re
43
import urllib.request
54

65
def pre_build(**kwargs):
7-
if not os.path.exists('node_modules'):
8-
subprocess.run(['npm', 'install', '--ignore-scripts'], check=True)
9-
subprocess.run(['npm', 'run', 'build:api'], check=True)
10-
subprocess.run(['npm', 'run', 'build:generate'], check=True)
11-
subprocess.run(['npm', 'run', 'docs:examples'], check=True)
12-
subprocess.run(['npm', 'run', 'docs:api'], check=True)
6+
subprocess.run(['./docs/build-assets.sh'], check=True)
137

148
def replacer(match):
159
filename = f'{match.group(3)}.{match.group(4)}'

examples/browser/aepp/src/Connect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default {
5858
walletConnected: false,
5959
walletConnecting: null,
6060
reverseIframe: null,
61-
reverseIframeWalletUrl: 'http://localhost:9000',
61+
reverseIframeWalletUrl: process.env.VUE_APP_WALLET_URL ?? 'http://localhost:9000',
6262
walletInfo: null,
6363
}),
6464
computed: {

examples/browser/aepp/vue.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { defineConfig } = require('@vue/cli-service');
22

33
module.exports = defineConfig({
4+
publicPath: process.env.PUBLIC_PATH ?? '/',
45
devServer: {
56
port: 9001,
67
},

examples/browser/wallet-iframe/src/App.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<iframe
2424
v-if="!runningInFrame"
2525
ref="aepp"
26-
src="http://localhost:9001"
26+
:src="aeppUrl"
2727
/>
2828
</template>
2929

@@ -37,14 +37,13 @@ import Value from './Value.vue';
3737
3838
export default {
3939
components: { Value },
40-
data() {
41-
return {
42-
runningInFrame: window.parent !== window,
43-
nodeName: '',
44-
address: '',
45-
balancePromise: null,
46-
};
47-
},
40+
data: () => ({
41+
aeppUrl: process.env.VUE_APP_AEPP_URL ?? 'http://localhost:9001',
42+
runningInFrame: window.parent !== window,
43+
nodeName: '',
44+
address: '',
45+
balancePromise: null,
46+
}),
4847
methods: {
4948
async shareWalletInfo(clientId, { interval = 5000, attemps = 5 } = {}) {
5049
this.aeSdk.shareWalletInfo(clientId);

examples/browser/wallet-iframe/vue.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { defineConfig } = require('@vue/cli-service');
22

33
module.exports = defineConfig({
4+
publicPath: process.env.PUBLIC_PATH ?? '/',
45
devServer: {
56
port: 9000,
67
},

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ nav:
7171
- examples/node/paying-for-contract-call-tx.md
7272
- examples/node/paying-for-spend-tx.md
7373
- examples/node/account-generalized.md
74+
- Browser:
75+
- 'Aepp example': examples/browser/aepp/index.html
76+
- 'Iframe wallet example': examples/browser/wallet-iframe/index.html
77+
- 'Webextension wallet example': examples/browser/wallet-web-extension.zip
7478
- tutorials/vuejs/helloworld-blockheight.md
7579
- 'API Reference': api/index.html
7680
- compatibility.md

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"test:unit": "mocha './test/unit/'",
4848
"test:watch": "mocha './test/unit/' './test/integration/' --watch",
4949
"prepare": "npm run build",
50-
"prepublishOnly": "test/examples.sh && npm run docs:examples && npm run docs:api",
50+
"prepublishOnly": "test/examples.sh",
5151
"release": "standard-version --skip.tag --infile docs/CHANGELOG.md",
5252
"release-alpha": "npm run release -- --prerelease alpha",
5353
"release-beta": "npm run release -- --prerelease beta"

0 commit comments

Comments
 (0)