create-blocklet 0.2.5 → 0.2.9
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 +5 -5
- package/common/.prettierrc +1 -0
- package/common/Makefile +1 -1
- package/common/_gitignore +1 -0
- package/index.js +35 -21
- package/lib/abtnode.js +8 -8
- package/lib/index.js +0 -0
- package/package.json +1 -1
- package/template-dapp/react/README.md +23 -23
- package/template-dapp/vue/README.md +24 -24
- package/template-dapp/vue/blocklet.yml +11 -1
- package/template-dapp/vue2/.env +1 -0
- package/template-dapp/vue2/README.md +147 -0
- package/template-dapp/vue2/babel.config.js +3 -0
- package/template-dapp/vue2/blocklet.md +3 -0
- package/template-dapp/vue2/blocklet.yml +60 -0
- package/template-dapp/vue2/package.json +68 -0
- package/template-dapp/vue2/public/index.html +24 -0
- package/template-dapp/vue2/server/hooks/pre-start.js +33 -0
- package/template-dapp/vue2/server/index.js +55 -0
- package/template-dapp/vue2/server/libs/auth.js +31 -0
- package/template-dapp/vue2/server/libs/env.js +12 -0
- package/template-dapp/vue2/server/libs/logger.js +3 -0
- package/template-dapp/vue2/server/middlewares/user.js +10 -0
- package/template-dapp/vue2/server/routes/index.js +6 -0
- package/template-dapp/vue2/src/App.vue +22 -0
- package/template-dapp/vue2/src/assets/logo.png +0 -0
- package/template-dapp/vue2/src/components/HelloWorld.vue +74 -0
- package/template-dapp/vue2/src/libs/api.js +14 -0
- package/template-dapp/vue2/src/main.js +10 -0
- package/template-dapp/vue2/src/pages/About.vue +13 -0
- package/template-dapp/vue2/src/pages/Home.vue +37 -0
- package/template-dapp/vue2/src/router.js +24 -0
- package/template-dapp/vue2/vue.config.js +11 -0
- package/template-static/react/README.md +24 -24
- package/template-static/vue/README.md +24 -24
- package/template-static/vue/index.html +3 -3
- package/template-static/vue2/.env +1 -0
- package/template-static/vue2/README.md +147 -0
- package/template-static/vue2/babel.config.js +3 -0
- package/template-static/vue2/blocklet.md +3 -0
- package/template-static/vue2/blocklet.yml +50 -0
- package/template-static/vue2/package.json +48 -0
- package/template-static/vue2/public/index.html +24 -0
- package/template-static/vue2/src/App.vue +22 -0
- package/template-static/vue2/src/assets/logo.png +0 -0
- package/template-static/vue2/src/components/HelloWorld.vue +74 -0
- package/template-static/vue2/src/main.js +10 -0
- package/template-static/vue2/src/pages/About.vue +13 -0
- package/template-static/vue2/src/pages/Home.vue +20 -0
- package/template-static/vue2/src/router.js +24 -0
- package/template-static/vue2/vue.config.js +6 -0
- package/CHANGELOG.md +0 -62
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-vue2",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve",
|
|
7
|
+
"build": "vue-cli-service build",
|
|
8
|
+
"lint": "vue-cli-service lint",
|
|
9
|
+
"start": "npm-run-all --parallel start:*",
|
|
10
|
+
"start:client": "npm run serve",
|
|
11
|
+
"start:server": "NODE_ENV=development nodemon server/index.js -w server",
|
|
12
|
+
"clean": "rm -rf .blocklet",
|
|
13
|
+
"bundle": "npm run bundle:client && npm run bundle:server",
|
|
14
|
+
"bundle:client": "PUBLIC_PATH=/.blocklet/proxy/z8ia5PYHKJaG7LxTiKK74YhN1vkVMf7N7VncW",
|
|
15
|
+
"bundle:server": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
|
+
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@arcblock/did-auth": "latest",
|
|
21
|
+
"@arcblock/did-auth-storage-nedb": "latest",
|
|
22
|
+
"@blocklet/sdk": "latest",
|
|
23
|
+
"@ocap/client": "latest",
|
|
24
|
+
"@ocap/mcrypto": "latest",
|
|
25
|
+
"@ocap/wallet": "latest",
|
|
26
|
+
"axios": "^0.21.1",
|
|
27
|
+
"compression": "^1.7.4",
|
|
28
|
+
"cookie-parser": "^1.4.5",
|
|
29
|
+
"core-js": "^3.6.5",
|
|
30
|
+
"cors": "^2.8.5",
|
|
31
|
+
"dotenv-flow": "^3.2.0",
|
|
32
|
+
"express": "^4.17.1",
|
|
33
|
+
"express-async-errors": "^3.1.1",
|
|
34
|
+
"express-history-api-fallback": "^2.2.1",
|
|
35
|
+
"vue": "^2.6.11",
|
|
36
|
+
"vue-router": "^3.5.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@vue/cli-plugin-babel": "~4.5.0",
|
|
40
|
+
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
41
|
+
"@vue/cli-service": "~4.5.0",
|
|
42
|
+
"babel-eslint": "^10.1.0",
|
|
43
|
+
"eslint": "^6.7.2",
|
|
44
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
45
|
+
"nodemon": "^2.0.12",
|
|
46
|
+
"npm-run-all": "^4.1.5",
|
|
47
|
+
"vue-template-compiler": "^2.6.11"
|
|
48
|
+
},
|
|
49
|
+
"eslintConfig": {
|
|
50
|
+
"root": true,
|
|
51
|
+
"env": {
|
|
52
|
+
"node": true
|
|
53
|
+
},
|
|
54
|
+
"extends": [
|
|
55
|
+
"plugin:vue/essential",
|
|
56
|
+
"eslint:recommended"
|
|
57
|
+
],
|
|
58
|
+
"parserOptions": {
|
|
59
|
+
"parser": "babel-eslint"
|
|
60
|
+
},
|
|
61
|
+
"rules": {}
|
|
62
|
+
},
|
|
63
|
+
"browserslist": [
|
|
64
|
+
"> 1%",
|
|
65
|
+
"last 2 versions",
|
|
66
|
+
"not dead"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="<%= BASE_URL %>favicon.svg" />
|
|
6
|
+
<link rel="alternate icon" href="<%= BASE_URL %>favicon.ico" />
|
|
7
|
+
<link rel="mask-icon" href="<%= BASE_URL %>favicon.svg" color="#4F6AF5" />
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
9
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
10
|
+
<meta name="description" content="Web site created using create-blocklet" />
|
|
11
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
12
|
+
<script src="__meta__.js"></script>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<noscript>
|
|
16
|
+
<strong
|
|
17
|
+
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please
|
|
18
|
+
enable it to continue.</strong
|
|
19
|
+
>
|
|
20
|
+
</noscript>
|
|
21
|
+
<div id="app"></div>
|
|
22
|
+
<!-- built files will be auto injected -->
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require('dotenv-flow').config();
|
|
2
|
+
|
|
3
|
+
const Client = require('@ocap/client');
|
|
4
|
+
|
|
5
|
+
const env = require('../libs/env');
|
|
6
|
+
const { wallet } = require('../libs/auth');
|
|
7
|
+
const logger = require('../libs/logger');
|
|
8
|
+
const { name } = require('../../package.json');
|
|
9
|
+
|
|
10
|
+
const client = new Client(env.chainHost);
|
|
11
|
+
|
|
12
|
+
const ensureAccountDeclared = async () => {
|
|
13
|
+
// Check for application account, skip this if we are running as a child component
|
|
14
|
+
if (env.isComponent) return;
|
|
15
|
+
|
|
16
|
+
const { state } = await client.getAccountState({ address: wallet.toAddress() }, { ignoreFields: ['context'] });
|
|
17
|
+
if (!state) {
|
|
18
|
+
const hash = await client.declare({ moniker: name, wallet });
|
|
19
|
+
logger.log(`app account declared on chain ${env.chainHost}`, hash);
|
|
20
|
+
} else {
|
|
21
|
+
logger.log(`app account already declared on chain ${env.chainHost}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try {
|
|
27
|
+
await ensureAccountDeclared();
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
logger.error(`${name} pre-start error`, err.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
})();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require('dotenv-flow').config();
|
|
2
|
+
require('express-async-errors');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const cors = require('cors');
|
|
5
|
+
const express = require('express');
|
|
6
|
+
const compression = require('compression');
|
|
7
|
+
const cookieParser = require('cookie-parser');
|
|
8
|
+
const fallback = require('express-history-api-fallback');
|
|
9
|
+
|
|
10
|
+
const { name, version } = require('../package.json');
|
|
11
|
+
const logger = require('./libs/logger');
|
|
12
|
+
|
|
13
|
+
const app = express();
|
|
14
|
+
|
|
15
|
+
app.set('trust proxy', true);
|
|
16
|
+
app.use(cookieParser());
|
|
17
|
+
app.use(express.json({ limit: '1 mb' }));
|
|
18
|
+
app.use(express.urlencoded({ extended: true, limit: '1 mb' }));
|
|
19
|
+
|
|
20
|
+
const router = express.Router();
|
|
21
|
+
router.use('/api', require('./routes'));
|
|
22
|
+
|
|
23
|
+
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
24
|
+
const isProduction = process.env.NODE_ENV === 'production' || process.env.ABT_NODE_SERVICE_ENV === 'production';
|
|
25
|
+
|
|
26
|
+
if (isDevelopment) {
|
|
27
|
+
process.env.BLOCKLET_PORT = 3030;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (isProduction) {
|
|
31
|
+
app.use(cors());
|
|
32
|
+
app.use(compression());
|
|
33
|
+
|
|
34
|
+
const staticDir = path.resolve(__dirname, '../', 'dist');
|
|
35
|
+
app.use(express.static(staticDir, { index: 'index.html' }));
|
|
36
|
+
app.use(router);
|
|
37
|
+
app.use(fallback('index.html', { root: staticDir }));
|
|
38
|
+
|
|
39
|
+
app.use((req, res) => {
|
|
40
|
+
res.status(404).send('404 NOT FOUND');
|
|
41
|
+
});
|
|
42
|
+
app.use((err, req, res) => {
|
|
43
|
+
logger.error(err.stack);
|
|
44
|
+
res.status(500).send('Something broke!');
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
app.use(router);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const port = parseInt(process.env.BLOCKLET_PORT || process.env.APP_PORT, 10) || 3030;
|
|
51
|
+
|
|
52
|
+
app.listen(port, (err) => {
|
|
53
|
+
if (err) throw err;
|
|
54
|
+
logger.info(`> ${name} v${version} ready on ${port}`);
|
|
55
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const AuthStorage = require('@arcblock/did-auth-storage-nedb');
|
|
3
|
+
const WalletAuthenticator = require('@blocklet/sdk/lib/wallet-authenticator');
|
|
4
|
+
const WalletHandlers = require('@blocklet/sdk/lib/wallet-handler');
|
|
5
|
+
const { types } = require('@ocap/mcrypto');
|
|
6
|
+
const { fromSecretKey, WalletType } = require('@ocap/wallet');
|
|
7
|
+
const logger = require('./logger');
|
|
8
|
+
|
|
9
|
+
const appSk = process.env.APP_SK || process.env.BLOCKLET_APP_SK;
|
|
10
|
+
const wallet = fromSecretKey(appSk, WalletType({ role: types.RoleType.ROLE_APPLICATION }));
|
|
11
|
+
|
|
12
|
+
const authenticator = new WalletAuthenticator();
|
|
13
|
+
|
|
14
|
+
const handlers = new WalletHandlers({
|
|
15
|
+
authenticator,
|
|
16
|
+
tokenGenerator: () => Date.now().toString(),
|
|
17
|
+
tokenStorage: new AuthStorage({
|
|
18
|
+
dbPath: path.join(process.env.BLOCKLET_DATA_DIR, 'auth.db'),
|
|
19
|
+
onload: (err) => {
|
|
20
|
+
if (err) {
|
|
21
|
+
logger.error(`Failed to load database from ${path.join(process.env.BLOCKLET_DATA_DIR, 'auth.db')}`, err);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
authenticator,
|
|
29
|
+
handlers,
|
|
30
|
+
wallet,
|
|
31
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const blockletRealDid = process.env.BLOCKLET_REAL_DID || '';
|
|
2
|
+
const blockletDid = process.env.BLOCKLET_DID || '';
|
|
3
|
+
const isComponent = blockletRealDid && blockletDid && blockletRealDid !== blockletDid;
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
chainId: process.env.CHAIN_ID || '',
|
|
7
|
+
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
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<router-view />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'App',
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
#app {
|
|
15
|
+
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
16
|
+
-webkit-font-smoothing: antialiased;
|
|
17
|
+
-moz-osx-font-smoothing: grayscale;
|
|
18
|
+
text-align: center;
|
|
19
|
+
color: #2c3e50;
|
|
20
|
+
margin-top: 60px;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
Binary file
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hello">
|
|
3
|
+
<h1>{{ msg }}</h1>
|
|
4
|
+
<p>
|
|
5
|
+
For a guide and recipes on how to configure / customize this project,<br />
|
|
6
|
+
check out the
|
|
7
|
+
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
|
8
|
+
</p>
|
|
9
|
+
<h3>Installed CLI Plugins</h3>
|
|
10
|
+
<ul>
|
|
11
|
+
<li>
|
|
12
|
+
<a
|
|
13
|
+
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
|
|
14
|
+
target="_blank"
|
|
15
|
+
rel="noopener"
|
|
16
|
+
>babel</a
|
|
17
|
+
>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<a
|
|
21
|
+
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
|
|
22
|
+
target="_blank"
|
|
23
|
+
rel="noopener"
|
|
24
|
+
>eslint</a
|
|
25
|
+
>
|
|
26
|
+
</li>
|
|
27
|
+
</ul>
|
|
28
|
+
<h3>Essential Links</h3>
|
|
29
|
+
<ul>
|
|
30
|
+
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
|
31
|
+
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
|
32
|
+
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
|
33
|
+
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
|
34
|
+
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
|
35
|
+
</ul>
|
|
36
|
+
<h3>Ecosystem</h3>
|
|
37
|
+
<ul>
|
|
38
|
+
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
|
39
|
+
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
|
40
|
+
<li>
|
|
41
|
+
<a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a>
|
|
42
|
+
</li>
|
|
43
|
+
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
|
44
|
+
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
|
45
|
+
</ul>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script>
|
|
50
|
+
export default {
|
|
51
|
+
name: 'HelloWorld',
|
|
52
|
+
props: {
|
|
53
|
+
msg: String,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
59
|
+
<style scoped>
|
|
60
|
+
h3 {
|
|
61
|
+
margin: 40px 0 0;
|
|
62
|
+
}
|
|
63
|
+
ul {
|
|
64
|
+
list-style-type: none;
|
|
65
|
+
padding: 0;
|
|
66
|
+
}
|
|
67
|
+
li {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
margin: 0 10px;
|
|
70
|
+
}
|
|
71
|
+
a {
|
|
72
|
+
color: #42b983;
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
axios.interceptors.request.use(
|
|
4
|
+
(config) => {
|
|
5
|
+
const prefix = window.blocklet ? window.blocklet.prefix : '/';
|
|
6
|
+
config.baseURL = prefix || '';
|
|
7
|
+
config.timeout = 200000;
|
|
8
|
+
|
|
9
|
+
return config;
|
|
10
|
+
},
|
|
11
|
+
(error) => Promise.reject(error)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default axios;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<img alt="Vue logo" src="../assets/logo.png" />
|
|
4
|
+
<div>
|
|
5
|
+
<router-link to="/about">About page</router-link>
|
|
6
|
+
</div>
|
|
7
|
+
<HelloWorld msg="Welcome to Your Vue.js App" />
|
|
8
|
+
<div :style="{ display: 'flex', justifyContent: 'center' }">
|
|
9
|
+
<pre :style="{ textAlign: 'left' }">
|
|
10
|
+
<code>{{ JSON.stringify(envData, null, 2) }}</code>
|
|
11
|
+
</pre>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
import HelloWorld from '../components/HelloWorld.vue';
|
|
18
|
+
import api from '../libs/api';
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
components: {
|
|
22
|
+
HelloWorld,
|
|
23
|
+
},
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
envData: {},
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
mounted() {
|
|
30
|
+
api.get('/api/env').then(({ data }) => {
|
|
31
|
+
this.envData = data;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<style></style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
3
|
+
|
|
4
|
+
import Home from './pages/Home';
|
|
5
|
+
import About from './pages/About';
|
|
6
|
+
|
|
7
|
+
Vue.use(VueRouter);
|
|
8
|
+
const basename = window?.blocklet?.prefix || '/';
|
|
9
|
+
|
|
10
|
+
export default new VueRouter({
|
|
11
|
+
base: basename,
|
|
12
|
+
routes: [
|
|
13
|
+
{
|
|
14
|
+
path: '/',
|
|
15
|
+
name: 'home',
|
|
16
|
+
component: Home,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
path: '/about',
|
|
20
|
+
name: 'about',
|
|
21
|
+
component: About,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
});
|
|
@@ -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,19 +51,19 @@ 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.
|
|
63
63
|
|
|
64
|
-
## Upload to blocklet
|
|
64
|
+
## Upload to blocklet store
|
|
65
65
|
|
|
66
|
-
- If you want to upload the blocklet to any
|
|
66
|
+
- If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
|
|
67
67
|
|
|
68
68
|
Bump version at first.
|
|
69
69
|
|
|
@@ -71,22 +71,22 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
71
71
|
make bump-version
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Then config blocklet
|
|
75
|
-
You can use those
|
|
74
|
+
Then config blocklet store url.
|
|
75
|
+
You can use those store url in below.
|
|
76
76
|
|
|
77
|
-
1. [https://
|
|
78
|
-
2. [https://dev.
|
|
79
|
-
3. A blocklet
|
|
80
|
-
> Make sure you have installed a `blocklet
|
|
77
|
+
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
78
|
+
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
79
|
+
3. A blocklet store started by yourself.
|
|
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
|
-
blocklet config set
|
|
83
|
+
blocklet config set store {store url}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
Get a `accessToken` from blocklet
|
|
86
|
+
Get a `accessToken` from blocklet store.
|
|
87
87
|
|
|
88
88
|
> Why we need a `accessToken`?
|
|
89
|
-
> A `accessToken` is genrate by blocklet
|
|
89
|
+
> A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
|
|
90
90
|
|
|
91
91
|
Set `accessToken` to blocklet config
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
94
94
|
blocklet config set accessToken {accessToken}
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
Upload a new version to a
|
|
97
|
+
Upload a new version to a store.
|
|
98
98
|
|
|
99
99
|
> Make sure the blocklet is bundled before upload.
|
|
100
100
|
|
|
@@ -104,7 +104,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
104
104
|
|
|
105
105
|
Or you can simply use `npm run upload` command.
|
|
106
106
|
|
|
107
|
-
- You also can upload a new version to blocklet
|
|
107
|
+
- You also can upload a new version to blocklet store by Github CI.
|
|
108
108
|
Bump version at first.
|
|
109
109
|
|
|
110
110
|
```shell
|
|
@@ -112,7 +112,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
|
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
Push your code to Github main/master branch, or make a pull request to the main/master branch.
|
|
115
|
-
The CI workflow will automatically upload a new version to a
|
|
115
|
+
The CI workflow will automatically upload a new version to a store.
|
|
116
116
|
|
|
117
117
|
## Q & A
|
|
118
118
|
|