create-blocklet 0.2.8 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/.github/workflows/main.yml +6 -6
- package/common/Makefile +1 -1
- package/index.js +27 -32
- package/lib/index.js +0 -0
- package/lib/server.js +41 -0
- package/package.json +2 -2
- package/template-dapp/react/README.md +12 -12
- package/template-dapp/react/blocklet.yml +1 -6
- package/template-dapp/react/server/hooks/pre-start.js +4 -4
- package/template-dapp/react/server/libs/auth.js +4 -8
- package/template-dapp/react/server/libs/env.js +2 -8
- package/template-dapp/react/server/routes/index.js +2 -0
- package/template-dapp/vue/README.md +12 -12
- package/template-dapp/vue/blocklet.yml +1 -6
- package/template-dapp/vue/server/hooks/pre-start.js +4 -4
- package/template-dapp/vue/server/libs/auth.js +4 -8
- package/template-dapp/vue/server/libs/env.js +2 -8
- package/template-dapp/vue/server/routes/index.js +2 -0
- package/template-dapp/vue2/README.md +12 -12
- package/template-dapp/vue2/blocklet.yml +1 -6
- package/template-dapp/vue2/server/hooks/pre-start.js +4 -4
- package/template-dapp/vue2/server/libs/auth.js +4 -8
- package/template-dapp/vue2/server/libs/env.js +2 -8
- package/template-dapp/vue2/server/routes/index.js +2 -0
- package/template-static/react/README.md +12 -12
- package/template-static/react/blocklet.yml +1 -1
- package/template-static/vue/README.md +12 -12
- package/template-static/vue/blocklet.yml +1 -1
- package/template-static/vue2/README.md +12 -12
- package/template-static/vue2/blocklet.yml +1 -1
- package/CHANGELOG.md +0 -74
- package/lib/abtnode.js +0 -45
- package/template-dapp/react/server/middlewares/user.js +0 -10
- package/template-dapp/vue/server/middlewares/user.js +0 -10
- package/template-dapp/vue2/server/middlewares/user.js +0 -10
|
@@ -22,15 +22,15 @@ jobs:
|
|
|
22
22
|
run: yarn
|
|
23
23
|
|
|
24
24
|
- name: Blocklet workflow
|
|
25
|
-
uses: blocklet/action-workflow@v1
|
|
25
|
+
uses: blocklet/action-workflow@v1
|
|
26
26
|
with:
|
|
27
27
|
skip-upload: false
|
|
28
28
|
skip-deploy: false
|
|
29
29
|
bundle-command: yarn bundle
|
|
30
|
-
store-endpoint: ${{ secrets.
|
|
31
|
-
store-access-token: ${{ secrets.
|
|
32
|
-
|
|
33
|
-
access-key: ${{ secrets.STAGING_NODE_ACCESS_KEY }}
|
|
34
|
-
access-secret: ${{ secrets.STAGING_NODE_ACCESS_SECRET }}
|
|
30
|
+
store-endpoint: ${{ secrets.STORE_ENDPOINT_DEV }}
|
|
31
|
+
store-access-token: ${{ secrets.STORE_ACCESS_TOKEN_DEV }}
|
|
32
|
+
server-endpoint: ${{ secrets.STAGING_NODE_ENDPOINT }}
|
|
33
|
+
server-access-key: ${{ secrets.STAGING_NODE_ACCESS_KEY }}
|
|
34
|
+
server-access-secret: ${{ secrets.STAGING_NODE_ACCESS_SECRET }}
|
|
35
35
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
|
36
36
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
package/common/Makefile
CHANGED
package/index.js
CHANGED
|
@@ -12,12 +12,7 @@ import * as envfile from 'envfile';
|
|
|
12
12
|
|
|
13
13
|
import { echoBrand, echoDocument } from './lib/arcblock.js';
|
|
14
14
|
import { getAuthor } from './lib/npm.js';
|
|
15
|
-
import {
|
|
16
|
-
checkAbtnodeInstalled,
|
|
17
|
-
checkAbtnodeRunning,
|
|
18
|
-
checkSatisfiedVersion,
|
|
19
|
-
getAbtnodeDirectory,
|
|
20
|
-
} from './lib/abtnode.js';
|
|
15
|
+
import { checkServerInstalled, checkServerRunning, checkSatisfiedVersion, getServerDirectory } from './lib/server.js';
|
|
21
16
|
import { toBlockletDid, toDidIcon } from './lib/did.js';
|
|
22
17
|
|
|
23
18
|
const argv = minimist(process.argv.slice(2));
|
|
@@ -199,43 +194,43 @@ async function init() {
|
|
|
199
194
|
await echoBrand();
|
|
200
195
|
await echoDocument();
|
|
201
196
|
|
|
202
|
-
console.log('Checking
|
|
197
|
+
console.log('Checking blocklet server runtime environment...', '\n');
|
|
203
198
|
|
|
204
|
-
const
|
|
199
|
+
const isServerInstalled = checkServerInstalled();
|
|
205
200
|
const isSatisfiedVersion = checkSatisfiedVersion();
|
|
206
|
-
const
|
|
201
|
+
const isServerRunning = checkServerRunning();
|
|
207
202
|
|
|
208
|
-
if (!
|
|
209
|
-
// 未安装
|
|
210
|
-
console.log(red('To run the blocklet, you need a running
|
|
203
|
+
if (!isServerInstalled) {
|
|
204
|
+
// 未安装 blocklet server
|
|
205
|
+
console.log(red('To run the blocklet, you need a running blocklet server instance on local machine.'), '\n');
|
|
211
206
|
console.log(`Checkout ${green('README.md')} for more usage instructions.`);
|
|
212
207
|
console.log('Now you should run:', '\n');
|
|
213
|
-
console.log(cyan('npm install -g @
|
|
214
|
-
console.log(cyan('
|
|
208
|
+
console.log(cyan('npm install -g @blocklet/cli'));
|
|
209
|
+
console.log(cyan('blocklet server start -a'));
|
|
215
210
|
} else if (!isSatisfiedVersion) {
|
|
216
|
-
// 已安装
|
|
217
|
-
console.log(red('Your
|
|
211
|
+
// 已安装 blocklet server,但版本不满足
|
|
212
|
+
console.log(red('Your blocklet server version is outdate, please update it to the latest version.'));
|
|
218
213
|
console.log('Now you should run:', '\n');
|
|
219
|
-
if (
|
|
220
|
-
//
|
|
221
|
-
const
|
|
222
|
-
console.log(cyan(`cd ${
|
|
223
|
-
console.log(cyan('
|
|
224
|
-
console.log(cyan('npm install -g @
|
|
225
|
-
console.log(cyan('
|
|
214
|
+
if (isServerRunning) {
|
|
215
|
+
// blocklet server 已经启动
|
|
216
|
+
const serverPath = getServerDirectory();
|
|
217
|
+
console.log(cyan(`cd ${serverPath}`));
|
|
218
|
+
console.log(cyan('blocklet server stop'));
|
|
219
|
+
console.log(cyan('npm install -g @blocklet/cli'));
|
|
220
|
+
console.log(cyan('blocklet server start'));
|
|
226
221
|
console.log(cyan(`cd ${cwd}`));
|
|
227
222
|
} else {
|
|
228
|
-
//
|
|
229
|
-
// TODO: 如何获取未启动的
|
|
230
|
-
console.log(cyan('npm install -g @
|
|
231
|
-
console.log(cyan('
|
|
223
|
+
// blocklet server 未启动
|
|
224
|
+
// TODO: 如何获取未启动的 blocklet server 实例目录?
|
|
225
|
+
console.log(cyan('npm install -g @blocklet/cli'));
|
|
226
|
+
console.log(cyan('blocklet server start -a'));
|
|
232
227
|
}
|
|
233
|
-
} else if (!
|
|
234
|
-
// 已经安装
|
|
235
|
-
console.log(red('You need to start your
|
|
228
|
+
} else if (!isServerRunning) {
|
|
229
|
+
// 已经安装 blocklet server,且版本满足,并且 blocklet server 未启动
|
|
230
|
+
console.log(red('You need to start your blocklet server before develop this blocklet.'));
|
|
236
231
|
console.log('Now you should run:', '\n');
|
|
237
|
-
// TODO: 如何获取未启动的
|
|
238
|
-
console.log(cyan('
|
|
232
|
+
// TODO: 如何获取未启动的 blocklet server 实例目录?
|
|
233
|
+
console.log(cyan('blocklet server start -a'));
|
|
239
234
|
}
|
|
240
235
|
|
|
241
236
|
console.log(`\n\nScaffolding project in ${root}...`);
|
package/lib/index.js
CHANGED
|
File without changes
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import { getOutput } from './index.js';
|
|
3
|
+
|
|
4
|
+
export function checkServerInstalled() {
|
|
5
|
+
const output = getOutput('which blocklet');
|
|
6
|
+
return !!output;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getServerVersion() {
|
|
10
|
+
const output = getOutput('blocklet --version');
|
|
11
|
+
return output.trim();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getServerStatus() {
|
|
15
|
+
const output = getOutput('blocklet server status');
|
|
16
|
+
const [matchStr] = output.match(/Blocklet Server status:[\s\S]*?\n/g) || [];
|
|
17
|
+
if (!matchStr) {
|
|
18
|
+
return 'stop';
|
|
19
|
+
}
|
|
20
|
+
const status = matchStr.replace(/Blocklet Server status:\s*(\S+)\s*\S*\n*[\s\S]*/gm, '$1');
|
|
21
|
+
return status.toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
export function checkServerRunning() {
|
|
24
|
+
const status = getServerStatus();
|
|
25
|
+
return status === 'running';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function checkSatisfiedVersion() {
|
|
29
|
+
const output = getOutput('blocklet --version');
|
|
30
|
+
const version = output.trim();
|
|
31
|
+
return semver.satisfies(version, '>= 1.6.1');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getServerDirectory() {
|
|
35
|
+
const output = getOutput('blocklet server status');
|
|
36
|
+
const [matchStr] = output.match(/Blocklet Server Data Directory:[\s\S]*?\n/gm) || [];
|
|
37
|
+
if (!matchStr) return null;
|
|
38
|
+
|
|
39
|
+
const directory = matchStr.replace(/Blocklet Server Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
|
|
40
|
+
return directory;
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-blocklet",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"exports": "./index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:blocklet/create-blocklet.git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"prompts": "^2.4.1",
|
|
41
41
|
"rc": "^1.2.8",
|
|
42
42
|
"semver": "^7.3.5",
|
|
43
|
-
"shelljs": "^0.8.
|
|
43
|
+
"shelljs": "^0.8.5",
|
|
44
44
|
"terminal-link": "^3.0.0",
|
|
45
45
|
"yaml": "^1.10.2"
|
|
46
46
|
},
|
|
@@ -34,17 +34,17 @@ This blocklet is a dapp project, which means this is a full-stack application. I
|
|
|
34
34
|
|
|
35
35
|
## Development
|
|
36
36
|
|
|
37
|
-
1. Make sure you have [@
|
|
37
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
38
38
|
|
|
39
|
-
Blocklet needs
|
|
40
|
-
`npm install -g @
|
|
39
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
40
|
+
`npm install -g @blocklet/cli`
|
|
41
41
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
42
42
|
|
|
43
|
-
2. Init
|
|
43
|
+
2. Init blocklet server & start blocklet server
|
|
44
44
|
|
|
45
|
-
Before starting an
|
|
46
|
-
`
|
|
47
|
-
`
|
|
45
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
46
|
+
`blocklet server init --mode=debug`
|
|
47
|
+
`blocklet server start`
|
|
48
48
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
49
49
|
|
|
50
50
|
3. Go to the project directory `cd [name]`
|
|
@@ -57,12 +57,12 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
57
57
|
|
|
58
58
|
## Deploy
|
|
59
59
|
|
|
60
|
-
- If you want to deploy this blocklet to local
|
|
60
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment).
|
|
61
61
|
> Or you can simply use `npm run deploy` command.
|
|
62
|
-
- If you want to deploy this blocklet to remote
|
|
62
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
63
63
|
|
|
64
64
|
```shell
|
|
65
|
-
blocklet deploy .blocklet/bundle --endpoint {your
|
|
65
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
> Make sure the blocklet is bundled before deployment.
|
|
@@ -83,7 +83,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
83
83
|
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
84
84
|
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
85
85
|
3. A blocklet store started by yourself.
|
|
86
|
-
> Make sure you have installed a `blocklet store` on your own
|
|
86
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
87
87
|
|
|
88
88
|
```shell
|
|
89
89
|
blocklet config set store {store url}
|
|
@@ -145,7 +145,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
145
145
|
## Learn More
|
|
146
146
|
|
|
147
147
|
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
148
|
-
- Full document of
|
|
148
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
149
149
|
|
|
150
150
|
## License
|
|
151
151
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name: template-react
|
|
2
2
|
title: Blocklet Template React
|
|
3
|
-
description:
|
|
3
|
+
description: A Blocklet Server blocklet
|
|
4
4
|
keywords:
|
|
5
5
|
- blocklet
|
|
6
6
|
- react
|
|
@@ -48,11 +48,6 @@ scripts:
|
|
|
48
48
|
preStart: node server/hooks/pre-start.js
|
|
49
49
|
dev: npm run start
|
|
50
50
|
environments:
|
|
51
|
-
- name: CHAIN_ID
|
|
52
|
-
description: What's endpoint of the chain id?
|
|
53
|
-
required: true
|
|
54
|
-
default: 'beta'
|
|
55
|
-
secure: false
|
|
56
51
|
- name: CHAIN_HOST
|
|
57
52
|
description: What's endpoint of the chain?
|
|
58
53
|
required: true
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
require('@blocklet/sdk/lib/error-handler');
|
|
1
2
|
require('dotenv-flow').config();
|
|
2
3
|
|
|
3
4
|
const Client = require('@ocap/client');
|
|
4
5
|
|
|
5
6
|
const env = require('../libs/env');
|
|
6
|
-
const { wallet } = require('../libs/auth');
|
|
7
7
|
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
8
9
|
const { name } = require('../../package.json');
|
|
9
10
|
|
|
10
|
-
const client = new Client(env.chainHost);
|
|
11
|
-
|
|
12
11
|
const ensureAccountDeclared = async () => {
|
|
13
|
-
// Check for application account, skip this if we are running as a child component
|
|
14
12
|
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
15
14
|
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
16
16
|
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
17
|
if (!state) {
|
|
18
18
|
const hash = await client.declare({ moniker: name, wallet });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
3
4
|
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
-
const
|
|
5
|
-
const { types } = require('@ocap/mcrypto');
|
|
6
|
-
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
7
6
|
const logger = require('./logger');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
-
|
|
8
|
+
const wallet = getWallet();
|
|
12
9
|
const authenticator = new WalletAuthenticator();
|
|
13
|
-
|
|
14
|
-
const handlers = new WalletHandlers({
|
|
10
|
+
const handlers = new WalletHandler({
|
|
15
11
|
authenticator,
|
|
16
12
|
tokenGenerator: () => Date.now().toString(),
|
|
17
13
|
tokenStorage: new AuthStorage({
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
-
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
1
|
+
const env = require('@blocklet/sdk/lib/env');
|
|
4
2
|
|
|
5
3
|
module.exports = {
|
|
6
|
-
|
|
4
|
+
...env,
|
|
7
5
|
chainHost: process.env.CHAIN_HOST || '',
|
|
8
|
-
appId: process.env.BLOCKLET_APP_ID || '',
|
|
9
|
-
appName: process.env.APP_NAME || process.env.BLOCKLET_APP_NAME || '',
|
|
10
|
-
appDescription: process.env.APP_DESCRIPTION || process.env.BLOCKLET_APP_DESCRIPTION || '',
|
|
11
|
-
isComponent,
|
|
12
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
1
2
|
const router = require('express').Router();
|
|
2
3
|
const env = require('../libs/env');
|
|
3
4
|
|
|
4
5
|
router.use('/env', (req, res) => res.json(env));
|
|
6
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
5
7
|
|
|
6
8
|
module.exports = router;
|
|
@@ -28,17 +28,17 @@ This blocklet is a static project, which means this is a frontend application. I
|
|
|
28
28
|
|
|
29
29
|
## Development
|
|
30
30
|
|
|
31
|
-
1. Make sure you have [@
|
|
31
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
32
32
|
|
|
33
|
-
Blocklet needs
|
|
34
|
-
`npm install -g @
|
|
33
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
34
|
+
`npm install -g @blocklet/cli`
|
|
35
35
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
36
36
|
|
|
37
|
-
2. Init
|
|
37
|
+
2. Init blocklet server & start blocklet server
|
|
38
38
|
|
|
39
|
-
Before starting an
|
|
40
|
-
`
|
|
41
|
-
`
|
|
39
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
40
|
+
`blocklet server init --mode=debug`
|
|
41
|
+
`blocklet server start`
|
|
42
42
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
43
43
|
|
|
44
44
|
3. Go to the project directory `cd [name]`
|
|
@@ -51,12 +51,12 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
51
51
|
|
|
52
52
|
## Deploy
|
|
53
53
|
|
|
54
|
-
- If you want to deploy this blocklet to local
|
|
54
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
|
|
55
55
|
> Or you can simply use `npm run deploy` command.
|
|
56
|
-
- If you want to deploy this blocklet to remote
|
|
56
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
57
57
|
|
|
58
58
|
```shell
|
|
59
|
-
blocklet deploy .blocklet/bundle --endpoint {your
|
|
59
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
> Make sure the blocklet is bundled before deployment.
|
|
@@ -77,7 +77,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
77
77
|
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
78
78
|
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
79
79
|
3. A blocklet store started by yourself.
|
|
80
|
-
> Make sure you have installed a `blocklet store` on your own
|
|
80
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
81
81
|
|
|
82
82
|
```shell
|
|
83
83
|
blocklet config set store {store url}
|
|
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
139
139
|
## Learn More
|
|
140
140
|
|
|
141
141
|
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
142
|
-
- Full document of
|
|
142
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
143
143
|
|
|
144
144
|
## License
|
|
145
145
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name: template-vue
|
|
2
2
|
title: Blocklet Template Vue
|
|
3
|
-
description:
|
|
3
|
+
description: A Blocklet Server blocklet
|
|
4
4
|
keywords:
|
|
5
5
|
- blocklet
|
|
6
6
|
- vue
|
|
@@ -47,11 +47,6 @@ scripts:
|
|
|
47
47
|
preStart: node server/hooks/pre-start.js
|
|
48
48
|
dev: npm run start
|
|
49
49
|
environments:
|
|
50
|
-
- name: CHAIN_ID
|
|
51
|
-
description: What's endpoint of the chain id?
|
|
52
|
-
required: true
|
|
53
|
-
default: 'beta'
|
|
54
|
-
secure: false
|
|
55
50
|
- name: CHAIN_HOST
|
|
56
51
|
description: What's endpoint of the chain?
|
|
57
52
|
required: true
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
require('@blocklet/sdk/lib/error-handler');
|
|
1
2
|
require('dotenv-flow').config();
|
|
2
3
|
|
|
3
4
|
const Client = require('@ocap/client');
|
|
4
5
|
|
|
5
6
|
const env = require('../libs/env');
|
|
6
|
-
const { wallet } = require('../libs/auth');
|
|
7
7
|
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
8
9
|
const { name } = require('../../package.json');
|
|
9
10
|
|
|
10
|
-
const client = new Client(env.chainHost);
|
|
11
|
-
|
|
12
11
|
const ensureAccountDeclared = async () => {
|
|
13
|
-
// Check for application account, skip this if we are running as a child component
|
|
14
12
|
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
15
14
|
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
16
16
|
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
17
|
if (!state) {
|
|
18
18
|
const hash = await client.declare({ moniker: name, wallet });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
3
4
|
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
-
const
|
|
5
|
-
const { types } = require('@ocap/mcrypto');
|
|
6
|
-
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
7
6
|
const logger = require('./logger');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
-
|
|
8
|
+
const wallet = getWallet();
|
|
12
9
|
const authenticator = new WalletAuthenticator();
|
|
13
|
-
|
|
14
|
-
const handlers = new WalletHandlers({
|
|
10
|
+
const handlers = new WalletHandler({
|
|
15
11
|
authenticator,
|
|
16
12
|
tokenGenerator: () => Date.now().toString(),
|
|
17
13
|
tokenStorage: new AuthStorage({
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
-
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
1
|
+
const env = require('@blocklet/sdk/lib/env');
|
|
4
2
|
|
|
5
3
|
module.exports = {
|
|
6
|
-
|
|
4
|
+
...env,
|
|
7
5
|
chainHost: process.env.CHAIN_HOST || '',
|
|
8
|
-
appId: process.env.BLOCKLET_APP_ID || '',
|
|
9
|
-
appName: process.env.APP_NAME || process.env.BLOCKLET_APP_NAME || '',
|
|
10
|
-
appDescription: process.env.APP_DESCRIPTION || process.env.BLOCKLET_APP_DESCRIPTION || '',
|
|
11
|
-
isComponent,
|
|
12
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
1
2
|
const router = require('express').Router();
|
|
2
3
|
const env = require('../libs/env');
|
|
3
4
|
|
|
4
5
|
router.use('/env', (req, res) => res.json(env));
|
|
6
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
5
7
|
|
|
6
8
|
module.exports = router;
|
|
@@ -28,17 +28,17 @@ This blocklet is a static project, which means this is a frontend application. I
|
|
|
28
28
|
|
|
29
29
|
## Development
|
|
30
30
|
|
|
31
|
-
1. Make sure you have [@
|
|
31
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
32
32
|
|
|
33
|
-
Blocklet needs
|
|
34
|
-
`npm install -g @
|
|
33
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
34
|
+
`npm install -g @blocklet/cli`
|
|
35
35
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
36
36
|
|
|
37
|
-
2. Init
|
|
37
|
+
2. Init blocklet server & start blocklet server
|
|
38
38
|
|
|
39
|
-
Before starting an
|
|
40
|
-
`
|
|
41
|
-
`
|
|
39
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
40
|
+
`blocklet server init --mode=debug`
|
|
41
|
+
`blocklet server start`
|
|
42
42
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
43
43
|
|
|
44
44
|
3. Go to the project directory `cd [name]`
|
|
@@ -51,12 +51,12 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
51
51
|
|
|
52
52
|
## Deploy
|
|
53
53
|
|
|
54
|
-
- If you want to deploy this blocklet to local
|
|
54
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
|
|
55
55
|
> Or you can simply use `npm run deploy` command.
|
|
56
|
-
- If you want to deploy this blocklet to remote
|
|
56
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
57
57
|
|
|
58
58
|
```shell
|
|
59
|
-
blocklet deploy .blocklet/bundle --endpoint {your
|
|
59
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
> Make sure the blocklet is bundled before deployment.
|
|
@@ -77,7 +77,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
77
77
|
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
78
78
|
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
79
79
|
3. A blocklet store started by yourself.
|
|
80
|
-
> Make sure you have installed a `blocklet store` on your own
|
|
80
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
81
81
|
|
|
82
82
|
```shell
|
|
83
83
|
blocklet config set store {store url}
|
|
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
139
139
|
## Learn More
|
|
140
140
|
|
|
141
141
|
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
142
|
-
- Full document of
|
|
142
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
143
143
|
|
|
144
144
|
## License
|
|
145
145
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name: template-vue2
|
|
2
2
|
title: Blocklet Template Vue2
|
|
3
|
-
description:
|
|
3
|
+
description: A Blocklet Server blocklet
|
|
4
4
|
keywords:
|
|
5
5
|
- blocklet
|
|
6
6
|
- vue
|
|
@@ -45,11 +45,6 @@ requirements:
|
|
|
45
45
|
scripts:
|
|
46
46
|
dev: npm run start
|
|
47
47
|
environments:
|
|
48
|
-
- name: CHAIN_ID
|
|
49
|
-
description: What's endpoint of the chain id?
|
|
50
|
-
required: true
|
|
51
|
-
default: 'beta'
|
|
52
|
-
secure: false
|
|
53
48
|
- name: CHAIN_HOST
|
|
54
49
|
description: What's endpoint of the chain?
|
|
55
50
|
required: true
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
require('@blocklet/sdk/lib/error-handler');
|
|
1
2
|
require('dotenv-flow').config();
|
|
2
3
|
|
|
3
4
|
const Client = require('@ocap/client');
|
|
4
5
|
|
|
5
6
|
const env = require('../libs/env');
|
|
6
|
-
const { wallet } = require('../libs/auth');
|
|
7
7
|
const logger = require('../libs/logger');
|
|
8
|
+
const { wallet } = require('../libs/auth');
|
|
8
9
|
const { name } = require('../../package.json');
|
|
9
10
|
|
|
10
|
-
const client = new Client(env.chainHost);
|
|
11
|
-
|
|
12
11
|
const ensureAccountDeclared = async () => {
|
|
13
|
-
// Check for application account, skip this if we are running as a child component
|
|
14
12
|
if (env.isComponent) return;
|
|
13
|
+
if (!env.chainHost) return;
|
|
15
14
|
|
|
15
|
+
const client = new Client(env.chainHost);
|
|
16
16
|
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
17
|
if (!state) {
|
|
18
18
|
const hash = await client.declare({ moniker: name, wallet });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const getWallet = require('@blocklet/sdk/lib/wallet');
|
|
3
4
|
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
-
const
|
|
5
|
-
const { types } = require('@ocap/mcrypto');
|
|
6
|
-
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
5
|
+
const WalletHandler = require('@blocklet/sdk/lib/wallet-handler');
|
|
7
6
|
const logger = require('./logger');
|
|
8
7
|
|
|
9
|
-
const
|
|
10
|
-
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
-
|
|
8
|
+
const wallet = getWallet();
|
|
12
9
|
const authenticator = new WalletAuthenticator();
|
|
13
|
-
|
|
14
|
-
const handlers = new WalletHandlers({
|
|
10
|
+
const handlers = new WalletHandler({
|
|
15
11
|
authenticator,
|
|
16
12
|
tokenGenerator: () => Date.now().toString(),
|
|
17
13
|
tokenStorage: new AuthStorage({
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
-
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
1
|
+
const env = require('@blocklet/sdk/lib/env');
|
|
4
2
|
|
|
5
3
|
module.exports = {
|
|
6
|
-
|
|
4
|
+
...env,
|
|
7
5
|
chainHost: process.env.CHAIN_HOST || '',
|
|
8
|
-
appId: process.env.BLOCKLET_APP_ID || '',
|
|
9
|
-
appName: process.env.APP_NAME || process.env.BLOCKLET_APP_NAME || '',
|
|
10
|
-
appDescription: process.env.APP_DESCRIPTION || process.env.BLOCKLET_APP_DESCRIPTION || '',
|
|
11
|
-
isComponent,
|
|
12
6
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
1
2
|
const router = require('express').Router();
|
|
2
3
|
const env = require('../libs/env');
|
|
3
4
|
|
|
4
5
|
router.use('/env', (req, res) => res.json(env));
|
|
6
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
5
7
|
|
|
6
8
|
module.exports = router;
|
|
@@ -28,17 +28,17 @@ This blocklet is a static project, which means this is a frontend application. I
|
|
|
28
28
|
|
|
29
29
|
## Development
|
|
30
30
|
|
|
31
|
-
1. Make sure you have [@
|
|
31
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
32
32
|
|
|
33
|
-
Blocklet needs
|
|
34
|
-
`npm install -g @
|
|
33
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
34
|
+
`npm install -g @blocklet/cli`
|
|
35
35
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
36
36
|
|
|
37
|
-
2. Init
|
|
37
|
+
2. Init blocklet server & start blocklet server
|
|
38
38
|
|
|
39
|
-
Before starting an
|
|
40
|
-
`
|
|
41
|
-
`
|
|
39
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
40
|
+
`blocklet server init --mode=debug`
|
|
41
|
+
`blocklet server start`
|
|
42
42
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
43
43
|
|
|
44
44
|
3. Go to the project directory `cd [name]`
|
|
@@ -51,12 +51,12 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
51
51
|
|
|
52
52
|
## Deploy
|
|
53
53
|
|
|
54
|
-
- If you want to deploy this blocklet to local
|
|
54
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
|
|
55
55
|
> Or you can simply use `npm run deploy` command.
|
|
56
|
-
- If you want to deploy this blocklet to remote
|
|
56
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
57
57
|
|
|
58
58
|
```shell
|
|
59
|
-
blocklet deploy .blocklet/bundle --endpoint {your
|
|
59
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
> Make sure the blocklet is bundled before deployment.
|
|
@@ -77,7 +77,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
77
77
|
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
78
78
|
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
79
79
|
3. A blocklet store started by yourself.
|
|
80
|
-
> Make sure you have installed a `blocklet store` on your own
|
|
80
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
81
81
|
|
|
82
82
|
```shell
|
|
83
83
|
blocklet config set store {store url}
|
|
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
139
139
|
## Learn More
|
|
140
140
|
|
|
141
141
|
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
142
|
-
- Full document of
|
|
142
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
143
143
|
|
|
144
144
|
## License
|
|
145
145
|
|
|
@@ -28,17 +28,17 @@ This blocklet is a static project, which means this is a frontend application. I
|
|
|
28
28
|
|
|
29
29
|
## Development
|
|
30
30
|
|
|
31
|
-
1. Make sure you have [@
|
|
31
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
32
32
|
|
|
33
|
-
Blocklet needs
|
|
34
|
-
`npm install -g @
|
|
33
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
34
|
+
`npm install -g @blocklet/cli`
|
|
35
35
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
36
36
|
|
|
37
|
-
2. Init
|
|
37
|
+
2. Init blocklet server & start blocklet server
|
|
38
38
|
|
|
39
|
-
Before starting an
|
|
40
|
-
`
|
|
41
|
-
`
|
|
39
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
40
|
+
`blocklet server init --mode=debug`
|
|
41
|
+
`blocklet server start`
|
|
42
42
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
43
43
|
|
|
44
44
|
3. Go to the project directory `cd [name]`
|
|
@@ -51,12 +51,12 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
51
51
|
|
|
52
52
|
## Deploy
|
|
53
53
|
|
|
54
|
-
- If you want to deploy this blocklet to local
|
|
54
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
|
|
55
55
|
> Or you can simply use `npm run deploy` command.
|
|
56
|
-
- If you want to deploy this blocklet to remote
|
|
56
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
57
57
|
|
|
58
58
|
```shell
|
|
59
|
-
blocklet deploy .blocklet/bundle --endpoint {your
|
|
59
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
> Make sure the blocklet is bundled before deployment.
|
|
@@ -77,7 +77,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
77
77
|
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
78
78
|
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
79
79
|
3. A blocklet store started by yourself.
|
|
80
|
-
> Make sure you have installed a `blocklet store` on your own
|
|
80
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
81
81
|
|
|
82
82
|
```shell
|
|
83
83
|
blocklet config set store {store url}
|
|
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
139
139
|
## Learn More
|
|
140
140
|
|
|
141
141
|
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
142
|
-
- Full document of
|
|
142
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
143
143
|
|
|
144
144
|
## License
|
|
145
145
|
|
|
@@ -28,17 +28,17 @@ This blocklet is a static project, which means this is a frontend application. I
|
|
|
28
28
|
|
|
29
29
|
## Development
|
|
30
30
|
|
|
31
|
-
1. Make sure you have [@
|
|
31
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
32
32
|
|
|
33
|
-
Blocklet needs
|
|
34
|
-
`npm install -g @
|
|
33
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
34
|
+
`npm install -g @blocklet/cli`
|
|
35
35
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#use-the-binary-distribution)
|
|
36
36
|
|
|
37
|
-
2. Init
|
|
37
|
+
2. Init blocklet server & start blocklet server
|
|
38
38
|
|
|
39
|
-
Before starting an
|
|
40
|
-
`
|
|
41
|
-
`
|
|
39
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
40
|
+
`blocklet server init --mode=debug`
|
|
41
|
+
`blocklet server start`
|
|
42
42
|
See details in [https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node](https://docs.arcblock.io/abtnode/en/introduction/abtnode-setup#configure-abt-node)
|
|
43
43
|
|
|
44
44
|
3. Go to the project directory `cd [name]`
|
|
@@ -51,12 +51,12 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
51
51
|
|
|
52
52
|
## Deploy
|
|
53
53
|
|
|
54
|
-
- If you want to deploy this blocklet to local
|
|
54
|
+
- If you want to deploy this blocklet to local blocklet server, you can use `blocklet deploy .blocklet/bundle` command(Make sure the blocklet is bundled before deployment.)
|
|
55
55
|
> Or you can simply use `npm run deploy` command.
|
|
56
|
-
- If you want to deploy this blocklet to remote
|
|
56
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
57
57
|
|
|
58
58
|
```shell
|
|
59
|
-
blocklet deploy .blocklet/bundle --endpoint {your
|
|
59
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
> Make sure the blocklet is bundled before deployment.
|
|
@@ -77,7 +77,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
77
77
|
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
78
78
|
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
79
79
|
3. A blocklet store started by yourself.
|
|
80
|
-
> Make sure you have installed a `blocklet store` on your own
|
|
80
|
+
> Make sure you have installed a `blocklet store` on your own blocklet server. Check it on here: [https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ](https://store.blocklet.dev/blocklet/z8ia29UsENBg6tLZUKi2HABj38Cw1LmHZocbQ)
|
|
81
81
|
|
|
82
82
|
```shell
|
|
83
83
|
blocklet config set store {store url}
|
|
@@ -139,7 +139,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
139
139
|
## Learn More
|
|
140
140
|
|
|
141
141
|
- Full specification of `blocklet.yml`: [https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md](https://github.com/blocklet/blocklet-specification/blob/main/docs/meta.md)
|
|
142
|
-
- Full document of
|
|
142
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
143
143
|
|
|
144
144
|
## License
|
|
145
145
|
|
package/CHANGELOG.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
## 0.2.8 (十一月 26, 2021)
|
|
2
|
-
|
|
3
|
-
- feat: rebrand blocklet registry -> blocklet store
|
|
4
|
-
|
|
5
|
-
## 0.2.7 (十一月 21, 2021)
|
|
6
|
-
|
|
7
|
-
- chore: prettier default useTabs: false
|
|
8
|
-
|
|
9
|
-
## 0.2.6 (十一月 20, 2021)
|
|
10
|
-
|
|
11
|
-
- feat: add vue2 + @vue/cli template
|
|
12
|
-
|
|
13
|
-
## 0.2.5 (十一月 20, 2021)
|
|
14
|
-
|
|
15
|
-
- feat: add vite + vue3 template
|
|
16
|
-
|
|
17
|
-
## 0.2.4 (October 28, 2021)
|
|
18
|
-
|
|
19
|
-
- chore: bump deps to latest
|
|
20
|
-
|
|
21
|
-
## 0.2.3 (十一月 08, 2021)
|
|
22
|
-
|
|
23
|
-
- chore: update README.md
|
|
24
|
-
- chore: remove sharp
|
|
25
|
-
|
|
26
|
-
## 0.2.2 (十月 19, 2021)
|
|
27
|
-
|
|
28
|
-
- chore: use blocklet/sdk WalletHandlers
|
|
29
|
-
|
|
30
|
-
## 0.2.1 (十月 15, 2021)
|
|
31
|
-
|
|
32
|
-
- feat: use action-workflow
|
|
33
|
-
|
|
34
|
-
## 0.2.0 (九月 30, 2021)
|
|
35
|
-
|
|
36
|
-
- feat: add npm script "upload"
|
|
37
|
-
- fix #25
|
|
38
|
-
- fix #22
|
|
39
|
-
- fix #21
|
|
40
|
-
- fix #24
|
|
41
|
-
- fix #23
|
|
42
|
-
|
|
43
|
-
## 0.1.7 (八月 12, 2021)
|
|
44
|
-
|
|
45
|
-
- feat: support generate did
|
|
46
|
-
- fix: remove yarn command
|
|
47
|
-
|
|
48
|
-
## 0.1.6 (八月 06, 2021)
|
|
49
|
-
|
|
50
|
-
- fix: [#8](https://github.com/blocklet/create-blocklet/issues/8)
|
|
51
|
-
|
|
52
|
-
## 0.1.5 (八月 03, 2021)
|
|
53
|
-
|
|
54
|
-
- chore: enhanced use of blocklet command
|
|
55
|
-
|
|
56
|
-
## 0.1.4 (八月 02, 2021)
|
|
57
|
-
|
|
58
|
-
- fix: add 'lib' to npm publish files
|
|
59
|
-
|
|
60
|
-
## 0.1.3 (八月 02, 2021)
|
|
61
|
-
|
|
62
|
-
- feat: add react-dom-router
|
|
63
|
-
- fix: #4
|
|
64
|
-
- fix: #3
|
|
65
|
-
- fix: #2
|
|
66
|
-
- fix: #1
|
|
67
|
-
|
|
68
|
-
## 0.1.2 (七月 23, 2021)
|
|
69
|
-
|
|
70
|
-
- fix: dapp npm bundle
|
|
71
|
-
|
|
72
|
-
## 0.1.1 (七月 23, 2021)
|
|
73
|
-
|
|
74
|
-
- fix: add folder to npm publish
|
package/lib/abtnode.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
|
-
import { getOutput } from './index.js';
|
|
3
|
-
|
|
4
|
-
export function checkAbtnodeInstalled() {
|
|
5
|
-
const output = getOutput('which abtnode');
|
|
6
|
-
return !!output;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function getAbtnodeVersion() {
|
|
10
|
-
const output = getOutput('abtnode --version');
|
|
11
|
-
return output.trim();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getAbtnodeStatus() {
|
|
15
|
-
const output = getOutput('abtnode status');
|
|
16
|
-
const [matchStr] = output.match(/ABT Node status:[\s\S]*?\n/gm) || [];
|
|
17
|
-
if (!matchStr) {
|
|
18
|
-
return 'stop';
|
|
19
|
-
}
|
|
20
|
-
const status = matchStr.replace(/ABT Node status:[\s]*([\S]+)\n/gm, '$1');
|
|
21
|
-
return status.toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
export function checkAbtnodeRunning() {
|
|
24
|
-
const status = getAbtnodeStatus();
|
|
25
|
-
return status === 'running';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function checkSatisfiedVersion() {
|
|
29
|
-
const output = getOutput('abtnode --version');
|
|
30
|
-
const version = output.trim();
|
|
31
|
-
return semver.satisfies(version, '>= 1.5.10');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function getAbtnodeDirectory() {
|
|
35
|
-
const output = getOutput('abtnode status');
|
|
36
|
-
const [matchStr] = output.match(/ABT Node Data Directory:[\s\S]*?\n/gm) || [];
|
|
37
|
-
if (!matchStr) return null;
|
|
38
|
-
|
|
39
|
-
const directory = matchStr.replace(/ABT Node Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
|
|
40
|
-
return directory;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const dic = getAbtnodeDirectory();
|
|
44
|
-
|
|
45
|
-
console.log(dic);
|