create-blocklet 0.2.18 → 0.3.2
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/.husky/pre-commit +4 -0
- package/common/_eslintignore +10 -0
- package/common/_eslintrc.js +1 -0
- package/common/_gitignore +15 -9
- package/common/logo.png +0 -0
- package/common/public/favicon.ico +0 -0
- package/index.js +200 -77
- package/lib/arcblock.js +11 -7
- package/lib/git.js +25 -0
- package/lib/index.js +17 -5
- package/lib/npm.js +7 -9
- package/lib/server.js +26 -20
- package/package.json +18 -16
- package/template-api/express/README.md +146 -0
- package/{template-dapp/react/server → template-api/express/api}/hooks/pre-start.js +0 -0
- package/template-api/express/api/index.js +13 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/auth.js +0 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/env.js +0 -0
- package/{template-dapp/react/server → template-api/express/api}/libs/logger.js +0 -0
- package/template-api/express/blocklet.md +3 -0
- package/template-api/express/blocklet.yml +57 -0
- package/template-api/express/package.json +26 -0
- package/template-api/express/screenshots/.gitkeep +0 -0
- package/template-dapp/nextjs/.eslintrc.js +4 -0
- package/template-dapp/nextjs/README.md +153 -0
- package/template-dapp/{vue/server → nextjs/api}/hooks/pre-start.js +0 -0
- package/template-dapp/nextjs/api/index.js +24 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/auth.js +0 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/env.js +0 -0
- package/template-dapp/{vue/server → nextjs/api}/libs/logger.js +0 -0
- package/template-dapp/{vue2/server → nextjs/api}/routes/index.js +1 -1
- package/template-dapp/nextjs/blocklet.md +3 -0
- package/template-dapp/nextjs/blocklet.yml +58 -0
- package/template-dapp/nextjs/next.config.js +6 -0
- package/template-dapp/nextjs/package.json +48 -0
- package/template-dapp/nextjs/pages/_app.js +21 -0
- package/template-dapp/nextjs/pages/api/hello.js +5 -0
- package/template-dapp/nextjs/pages/index.js +69 -0
- package/template-dapp/nextjs/styles/Home.module.css +116 -0
- package/template-dapp/nextjs/styles/globals.css +16 -0
- package/template-dapp/react/README.md +5 -5
- package/template-dapp/{vue2/server → react/api}/hooks/pre-start.js +0 -0
- package/template-dapp/react/{server → api}/index.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/auth.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/env.js +0 -0
- package/template-dapp/{vue2/server → react/api}/libs/logger.js +0 -0
- package/template-dapp/react/{server → api}/routes/index.js +1 -1
- package/template-dapp/react/blocklet.yml +6 -6
- package/template-dapp/react/package.json +35 -23
- package/template-dapp/react/public/index.html +1 -3
- package/template-dapp/react/src/app.js +8 -8
- package/template-dapp/vue/.browserslistrc +4 -0
- package/template-dapp/vue/.eslintrc.js +25 -0
- package/template-dapp/vue/api/hooks/pre-start.js +33 -0
- package/template-dapp/vue/{server → api}/index.js +0 -0
- package/template-dapp/vue/api/libs/auth.js +22 -0
- package/template-dapp/vue/api/libs/env.js +6 -0
- package/template-dapp/vue/api/libs/logger.js +3 -0
- package/template-dapp/vue/{server → api}/routes/index.js +1 -1
- package/template-dapp/vue/blocklet.yml +6 -5
- package/template-dapp/vue/index.html +2 -3
- package/template-dapp/vue/package.json +39 -21
- package/template-dapp/vue/src/App.vue +4 -2
- package/template-dapp/vue/vite.config.js +10 -6
- package/template-dapp/vue2/.browserslistrc +4 -0
- package/template-dapp/vue2/.eslintrc.js +14 -0
- package/template-dapp/vue2/api/hooks/pre-start.js +33 -0
- package/template-dapp/vue2/{server → api}/index.js +0 -0
- package/template-dapp/vue2/api/libs/auth.js +22 -0
- package/template-dapp/vue2/api/libs/env.js +6 -0
- package/template-dapp/vue2/api/libs/logger.js +3 -0
- package/template-dapp/vue2/api/routes/index.js +6 -0
- package/template-dapp/vue2/blocklet.yml +7 -5
- package/template-dapp/vue2/jsconfig.json +19 -0
- package/template-dapp/vue2/package.json +38 -43
- package/template-dapp/vue2/public/index.html +2 -9
- package/template-dapp/vue2/src/App.vue +17 -1
- package/template-dapp/vue2/src/main.js +0 -2
- package/template-dapp/vue2/vue.config.js +0 -1
- package/template-static/blocklet-page/package.json +5 -5
- package/template-static/react/blocklet.yml +2 -2
- package/template-static/react/package.json +21 -9
- package/template-static/react/public/index.html +1 -3
- package/template-static/react/src/app.js +8 -8
- package/template-static/vue/.browserslistrc +4 -0
- package/template-static/vue/.eslintrc.js +25 -0
- package/template-static/vue/blocklet.yml +2 -2
- package/template-static/vue/index.html +2 -3
- package/template-static/vue/package.json +26 -8
- package/template-static/vue/vite.config.js +10 -6
- package/template-static/vue2/.browserslistrc +4 -0
- package/template-static/vue2/.eslintrc.js +14 -0
- package/template-static/vue2/blocklet.yml +2 -2
- package/template-static/vue2/jsconfig.json +19 -0
- package/template-static/vue2/package.json +25 -30
- package/template-static/vue2/public/index.html +2 -9
- package/template-static/vue2/src/App.vue +7 -1
- package/template-static/vue2/src/main.js +0 -2
- package/template-static/vue2/vue.config.js +0 -3
- package/common/public/favicon.svg +0 -1
- package/template-dapp/vue2/src/pages/About.vue +0 -13
- package/template-dapp/vue2/src/pages/Home.vue +0 -27
- package/template-dapp/vue2/src/router.js +0 -24
- package/template-static/vue2/src/pages/About.vue +0 -13
- package/template-static/vue2/src/pages/Home.vue +0 -20
- package/template-static/vue2/src/router.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-blocklet",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"exports": "./index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:blocklet/create-blocklet.git",
|
|
@@ -13,36 +13,37 @@
|
|
|
13
13
|
"index.js",
|
|
14
14
|
"common",
|
|
15
15
|
"lib",
|
|
16
|
+
"template-api",
|
|
16
17
|
"template-dapp",
|
|
17
18
|
"template-static"
|
|
18
19
|
],
|
|
19
20
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
21
|
+
"node": ">=16.0.0"
|
|
21
22
|
},
|
|
22
23
|
"bugs": {
|
|
23
24
|
"url": "https://github.com/blocklet/create-blocklet/issues"
|
|
24
25
|
},
|
|
25
26
|
"homepage": "https://github.com/blocklet/create-blocklet/tree/main#readme",
|
|
26
27
|
"scripts": {
|
|
27
|
-
"lint": "eslint ."
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"test": "vitest",
|
|
30
|
+
"test:ui": "vitest --ui",
|
|
31
|
+
"test:run": "vitest run"
|
|
28
32
|
},
|
|
29
33
|
"dependencies": {
|
|
30
|
-
"@arcblock/did": "^1.
|
|
31
|
-
"@ocap/mcrypto": "^1.
|
|
32
|
-
"@ocap/util": "^1.
|
|
34
|
+
"@arcblock/did": "^1.14.25",
|
|
35
|
+
"@ocap/mcrypto": "^1.14.25",
|
|
36
|
+
"@ocap/util": "^1.14.25",
|
|
37
|
+
"boxen": "^6.2.1",
|
|
33
38
|
"ejs": "^3.1.6",
|
|
34
|
-
"envfile": "^6.
|
|
35
|
-
"figlet": "^1.5.
|
|
36
|
-
"gradient-string": "^
|
|
39
|
+
"envfile": "^6.17.0",
|
|
40
|
+
"figlet": "^1.5.2",
|
|
41
|
+
"gradient-string": "^2.0.0",
|
|
37
42
|
"jdenticon": "^3.1.1",
|
|
38
|
-
"
|
|
39
|
-
"minimist": "^1.2.5",
|
|
40
|
-
"prompts": "^2.4.1",
|
|
41
|
-
"rc": "^1.2.8",
|
|
43
|
+
"prompts": "^2.4.2",
|
|
42
44
|
"semver": "^7.3.5",
|
|
43
|
-
"shelljs": "^0.8.5",
|
|
44
45
|
"terminal-link": "^3.0.0",
|
|
45
|
-
"
|
|
46
|
+
"zx": "^6.0.6"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@arcblock/eslint-config": "0.1.8",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"eslint-plugin-react": "^7.24.0",
|
|
57
58
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
58
59
|
"eslint-plugin-unicorn": "^34.0.1",
|
|
59
|
-
"prettier": "^2.3.2"
|
|
60
|
+
"prettier": "^2.3.2",
|
|
61
|
+
"vitest": "^0.7.6"
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Getting Started with Create Blocklet
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
|
|
4
|
+
|
|
5
|
+
This blocklet is a dapp project, which means this is a full-stack application. It's contained both `server` and `client` code.
|
|
6
|
+
|
|
7
|
+
## File Structure
|
|
8
|
+
|
|
9
|
+
- screenshots/ - Screenshots
|
|
10
|
+
- api/ - Api side code
|
|
11
|
+
- hooks/ - blocklet lifecycle hooks
|
|
12
|
+
- libs/ - Api side libraries
|
|
13
|
+
- middlewares/ - Api side middlewares
|
|
14
|
+
- routes/ - Api side routes
|
|
15
|
+
- index.js - Api side entry point
|
|
16
|
+
- .env - Environment variables
|
|
17
|
+
- .env.local - Local environment variables
|
|
18
|
+
- .prettierrc - Prettier configuration
|
|
19
|
+
- blocklet.md - Blocklet README
|
|
20
|
+
- blocklet.yml - Blocklet configuration
|
|
21
|
+
- LICENSE - License file
|
|
22
|
+
- logo.png - Blocklet logo file
|
|
23
|
+
- Makefile - Makefile
|
|
24
|
+
- package.json - Npm package file
|
|
25
|
+
- README.md - A guide for this blocklet
|
|
26
|
+
- version - Version file
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
31
|
+
|
|
32
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
33
|
+
`npm install -g @blocklet/cli`
|
|
34
|
+
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)
|
|
35
|
+
|
|
36
|
+
2. Init blocklet server & start blocklet server
|
|
37
|
+
|
|
38
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
39
|
+
`blocklet server init --mode=debug`
|
|
40
|
+
`blocklet server start`
|
|
41
|
+
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)
|
|
42
|
+
|
|
43
|
+
3. Go to the project directory `cd [name]`
|
|
44
|
+
4. Install dependencies: `npm install` or `yarn`
|
|
45
|
+
5. Start development server: `blocklet dev`
|
|
46
|
+
|
|
47
|
+
## Bundle
|
|
48
|
+
|
|
49
|
+
After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
|
|
50
|
+
|
|
51
|
+
## Deploy
|
|
52
|
+
|
|
53
|
+
- 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).
|
|
54
|
+
> Or you can simply use `npm run deploy` command.
|
|
55
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
56
|
+
|
|
57
|
+
```shell
|
|
58
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> Make sure the blocklet is bundled before deployment.
|
|
62
|
+
|
|
63
|
+
## Upload to blocklet store
|
|
64
|
+
|
|
65
|
+
- If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
|
|
66
|
+
|
|
67
|
+
Bump version at first.
|
|
68
|
+
|
|
69
|
+
```shell
|
|
70
|
+
make bump-version
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then config blocklet store url.
|
|
74
|
+
You can use those store url in below.
|
|
75
|
+
|
|
76
|
+
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
77
|
+
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
78
|
+
3. A blocklet store started by yourself.
|
|
79
|
+
> 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)
|
|
80
|
+
|
|
81
|
+
```shell
|
|
82
|
+
blocklet config set store {store url}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Get a `accessToken` by using this command.
|
|
86
|
+
|
|
87
|
+
> Why we need a `accessToken`?
|
|
88
|
+
> A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
|
|
89
|
+
|
|
90
|
+
Set `accessToken` to blocklet config
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
blocklet config set accessToken {accessToken}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Upload a new version to a store.
|
|
97
|
+
|
|
98
|
+
> Make sure the blocklet is bundled before upload.
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
blocklet upload
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Or you can simply use `npm run upload` command.
|
|
105
|
+
|
|
106
|
+
- You also can upload a new version to a store by Github CI.
|
|
107
|
+
Bump version at first.
|
|
108
|
+
|
|
109
|
+
```shell
|
|
110
|
+
make bump-version
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Push your code to Github main/master branch, or make a pull request to the main/master branch.
|
|
114
|
+
The CI workflow will automatically upload a new version to a store.
|
|
115
|
+
|
|
116
|
+
## Q & A
|
|
117
|
+
|
|
118
|
+
1. Q: How to change a blocklet's name?
|
|
119
|
+
|
|
120
|
+
A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
|
|
121
|
+
|
|
122
|
+
You can also change the `title` field and `description` field in the `blocklet.yml` file.
|
|
123
|
+
|
|
124
|
+
Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
|
|
125
|
+
|
|
126
|
+
Replace this command `"bundle:client": "PUBLIC_URL='/.blocklet/proxy/{did}' npm run build",` in `package.json`
|
|
127
|
+
|
|
128
|
+
Replace `did` field in the `blocklet.yml`
|
|
129
|
+
|
|
130
|
+
2. Q: How to change a blocklet's logo?
|
|
131
|
+
|
|
132
|
+
Change the `logo.png` file root folder.
|
|
133
|
+
|
|
134
|
+
Or you can change the `logo` field in the `blocklet.yml` file.
|
|
135
|
+
|
|
136
|
+
> Make sure you have added the logo path to the `blocklet.yml` file `files` field.
|
|
137
|
+
|
|
138
|
+
## Learn More
|
|
139
|
+
|
|
140
|
+
- 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)
|
|
141
|
+
- Full document of Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
The code is licensed under the Apache 2.0 license found in the
|
|
146
|
+
[LICENSE](LICENSE) file.
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
|
|
3
|
+
const app = express();
|
|
4
|
+
|
|
5
|
+
const port = process.env.BLOCKLET_PORT || 3030;
|
|
6
|
+
|
|
7
|
+
app.get('/', (req, res) => {
|
|
8
|
+
res.send('Hello World, Blocklet!');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
app.listen(port, () => {
|
|
12
|
+
console.log(`Blocklet app listening on port ${port}`);
|
|
13
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: template-express
|
|
2
|
+
title: Blocklet Template Express
|
|
3
|
+
description: A Blocklet Api blocklet
|
|
4
|
+
keywords:
|
|
5
|
+
- blocklet
|
|
6
|
+
- react
|
|
7
|
+
group: dapp
|
|
8
|
+
did: ''
|
|
9
|
+
main: api/index.js
|
|
10
|
+
author:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
|
+
repository:
|
|
14
|
+
type: git
|
|
15
|
+
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
16
|
+
specVersion: 1.1.1
|
|
17
|
+
version: 0.1.0
|
|
18
|
+
logo: logo.png
|
|
19
|
+
files:
|
|
20
|
+
- logo.png
|
|
21
|
+
- README.md
|
|
22
|
+
- blocklet.md
|
|
23
|
+
- screenshots
|
|
24
|
+
- api/hooks/pre-start.js
|
|
25
|
+
interfaces:
|
|
26
|
+
- type: web
|
|
27
|
+
name: publicUrl
|
|
28
|
+
path: /
|
|
29
|
+
prefix: '*'
|
|
30
|
+
port: BLOCKLET_PORT
|
|
31
|
+
protocol: http
|
|
32
|
+
community: ''
|
|
33
|
+
documentation: ''
|
|
34
|
+
homepage: ''
|
|
35
|
+
license: ''
|
|
36
|
+
charging:
|
|
37
|
+
price: 0
|
|
38
|
+
tokens: []
|
|
39
|
+
shares: []
|
|
40
|
+
timeout:
|
|
41
|
+
start: 60
|
|
42
|
+
requirements:
|
|
43
|
+
server: '>=1.6.29'
|
|
44
|
+
os: '*'
|
|
45
|
+
cpu: '*'
|
|
46
|
+
scripts:
|
|
47
|
+
preStart: node api/hooks/pre-start.js
|
|
48
|
+
dev: npm run start
|
|
49
|
+
environments:
|
|
50
|
+
- name: CHAIN_HOST
|
|
51
|
+
description: What's endpoint of the chain?
|
|
52
|
+
required: true
|
|
53
|
+
default: 'https://beta.abtnetwork.io/api/'
|
|
54
|
+
secure: false
|
|
55
|
+
capabilities: {}
|
|
56
|
+
screenshots: []
|
|
57
|
+
children: []
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "express",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "api/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "NODE_ENV=development nodemon api/index.js -w api",
|
|
8
|
+
"clean": "rm -rf .blocklet",
|
|
9
|
+
"bundle": "npm run clean && blocklet bundle --zip --create-release",
|
|
10
|
+
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
11
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
18
|
+
"@blocklet/sdk": "^1.7.0",
|
|
19
|
+
"@ocap/client": "^1.15.2",
|
|
20
|
+
"dotenv-flow": "^3.2.0",
|
|
21
|
+
"express": "^4.17.3"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"nodemon": "^2.0.15"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Getting Started with Create Blocklet
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
|
|
4
|
+
|
|
5
|
+
This blocklet is a dapp project, which means this is a full-stack application. It's contained both `api` and `client` code.
|
|
6
|
+
|
|
7
|
+
## File Structure
|
|
8
|
+
|
|
9
|
+
- public/ - static files
|
|
10
|
+
- favicon.ico - favicon
|
|
11
|
+
- screenshots/ - Screenshots
|
|
12
|
+
- api/ - Api side code
|
|
13
|
+
- hooks/ - blocklet lifecycle hooks
|
|
14
|
+
- libs/ - Api side libraries
|
|
15
|
+
- middlewares/ - Api side middlewares
|
|
16
|
+
- routes/ - Api side routes
|
|
17
|
+
- index.js - Api side entry point
|
|
18
|
+
- pages/ - next.js pages folder
|
|
19
|
+
- styles/ - next.js styles folder
|
|
20
|
+
- .env - Environment variables
|
|
21
|
+
- .env.local - Local environment variables
|
|
22
|
+
- .eslintrc.js - ESLint configuration
|
|
23
|
+
- .gitignore - Git ignore file
|
|
24
|
+
- .prettierrc - Prettier configuration
|
|
25
|
+
- blocklet.md - Blocklet README
|
|
26
|
+
- blocklet.yml - Blocklet configuration
|
|
27
|
+
- LICENSE - License file
|
|
28
|
+
- logo.png - Blocklet logo file
|
|
29
|
+
- Makefile - Makefile
|
|
30
|
+
- next.config.js - next.js config file
|
|
31
|
+
- package.json - Npm package file
|
|
32
|
+
- README.md - A guide for this blocklet
|
|
33
|
+
- version - Version file
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
|
|
38
|
+
|
|
39
|
+
Blocklet needs blocklet server as a dependency. So you need to install it first.
|
|
40
|
+
`npm install -g @blocklet/cli`
|
|
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
|
+
|
|
43
|
+
2. Init blocklet server & start blocklet server
|
|
44
|
+
|
|
45
|
+
Before starting an blocklet server, you need to init blocklet server.
|
|
46
|
+
`blocklet server init --mode=debug`
|
|
47
|
+
`blocklet server start`
|
|
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
|
+
|
|
50
|
+
3. Go to the project directory `cd [name]`
|
|
51
|
+
4. Install dependencies: `npm install` or `yarn`
|
|
52
|
+
5. Start development server: `blocklet dev`
|
|
53
|
+
|
|
54
|
+
## Bundle
|
|
55
|
+
|
|
56
|
+
After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
|
|
57
|
+
|
|
58
|
+
## Deploy
|
|
59
|
+
|
|
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
|
+
> Or you can simply use `npm run deploy` command.
|
|
62
|
+
- If you want to deploy this blocklet to remote blocklet server, you can use the command below.
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
> Make sure the blocklet is bundled before deployment.
|
|
69
|
+
|
|
70
|
+
## Upload to blocklet store
|
|
71
|
+
|
|
72
|
+
- If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
|
|
73
|
+
|
|
74
|
+
Bump version at first.
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
make bump-version
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then config blocklet store url.
|
|
81
|
+
You can use those store url in below.
|
|
82
|
+
|
|
83
|
+
1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
|
|
84
|
+
2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
|
|
85
|
+
3. A blocklet store started by yourself.
|
|
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
|
+
|
|
88
|
+
```shell
|
|
89
|
+
blocklet config set store {store url}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Get a `accessToken` by using this command.
|
|
93
|
+
|
|
94
|
+
> Why we need a `accessToken`?
|
|
95
|
+
> A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
|
|
96
|
+
|
|
97
|
+
Set `accessToken` to blocklet config
|
|
98
|
+
|
|
99
|
+
```shell
|
|
100
|
+
blocklet config set accessToken {accessToken}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Upload a new version to a store.
|
|
104
|
+
|
|
105
|
+
> Make sure the blocklet is bundled before upload.
|
|
106
|
+
|
|
107
|
+
```shell
|
|
108
|
+
blocklet upload
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Or you can simply use `npm run upload` command.
|
|
112
|
+
|
|
113
|
+
- You also can upload a new version to a store by Github CI.
|
|
114
|
+
Bump version at first.
|
|
115
|
+
|
|
116
|
+
```shell
|
|
117
|
+
make bump-version
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Push your code to Github main/master branch, or make a pull request to the main/master branch.
|
|
121
|
+
The CI workflow will automatically upload a new version to a store.
|
|
122
|
+
|
|
123
|
+
## Q & A
|
|
124
|
+
|
|
125
|
+
1. Q: How to change a blocklet's name?
|
|
126
|
+
|
|
127
|
+
A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
|
|
128
|
+
|
|
129
|
+
You can also change the `title` field and `description` field in the `blocklet.yml` file.
|
|
130
|
+
|
|
131
|
+
Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
|
|
132
|
+
|
|
133
|
+
Replace this command `"bundle:client": "PUBLIC_URL='/.blocklet/proxy/{did}' npm run build",` in `package.json`
|
|
134
|
+
|
|
135
|
+
Replace `did` field in the `blocklet.yml`
|
|
136
|
+
|
|
137
|
+
2. Q: How to change a blocklet's logo?
|
|
138
|
+
|
|
139
|
+
Change the `logo.png` file root folder.
|
|
140
|
+
|
|
141
|
+
Or you can change the `logo` field in the `blocklet.yml` file.
|
|
142
|
+
|
|
143
|
+
> Make sure you have added the logo path to the `blocklet.yml` file `files` field.
|
|
144
|
+
|
|
145
|
+
## Learn More
|
|
146
|
+
|
|
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 Blocklet Server & blocklet development: [https://docs.arcblock.io/abtnode/en/introduction](https://docs.arcblock.io/abtnode/en/introduction)
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
The code is licensed under the Apache 2.0 license found in the
|
|
153
|
+
[LICENSE](LICENSE) file.
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const next = require('next');
|
|
3
|
+
|
|
4
|
+
const port = parseInt(process.env.BLOCKLET_PORT, 10) || 3000;
|
|
5
|
+
const dev = process.env.NODE_ENV !== 'production';
|
|
6
|
+
const app = next({ dev });
|
|
7
|
+
const handle = app.getRequestHandler();
|
|
8
|
+
|
|
9
|
+
app.prepare().then(() => {
|
|
10
|
+
const server = express();
|
|
11
|
+
|
|
12
|
+
const router = express.Router();
|
|
13
|
+
router.use('/api', require('./routes'));
|
|
14
|
+
server.use(router);
|
|
15
|
+
|
|
16
|
+
server.all('*', (req, res) => {
|
|
17
|
+
return handle(req, res);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
server.listen(port, (err) => {
|
|
21
|
+
if (err) throw err;
|
|
22
|
+
console.log(`> Ready on http://localhost:${port}`);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const middleware = require('@blocklet/sdk/lib/middlewares');
|
|
2
2
|
const router = require('express').Router();
|
|
3
3
|
|
|
4
|
-
router.use('/user', middleware.user(), (req, res) => res.json(req.user));
|
|
4
|
+
router.use('/user', middleware.user(), (req, res) => res.json(req.user || {}));
|
|
5
5
|
|
|
6
6
|
module.exports = router;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: template-nextjs
|
|
2
|
+
title: Blocklet Template Next.js
|
|
3
|
+
description: A Blocklet DAPP blocklet
|
|
4
|
+
keywords:
|
|
5
|
+
- blocklet
|
|
6
|
+
- react
|
|
7
|
+
group: dapp
|
|
8
|
+
did: ''
|
|
9
|
+
main: api/index.js
|
|
10
|
+
author:
|
|
11
|
+
name: Blocklet
|
|
12
|
+
email: blocklet@arcblock.io
|
|
13
|
+
repository:
|
|
14
|
+
type: git
|
|
15
|
+
url: 'git+https://github.com/blocklet/create-blocklet.git'
|
|
16
|
+
specVersion: 1.1.1
|
|
17
|
+
version: 0.1.0
|
|
18
|
+
logo: logo.png
|
|
19
|
+
files:
|
|
20
|
+
- .next
|
|
21
|
+
- logo.png
|
|
22
|
+
- README.md
|
|
23
|
+
- blocklet.md
|
|
24
|
+
- screenshots
|
|
25
|
+
- api/hooks/pre-start.js
|
|
26
|
+
interfaces:
|
|
27
|
+
- type: web
|
|
28
|
+
name: publicUrl
|
|
29
|
+
path: /
|
|
30
|
+
prefix: '*'
|
|
31
|
+
port: BLOCKLET_PORT
|
|
32
|
+
protocol: http
|
|
33
|
+
community: ''
|
|
34
|
+
documentation: ''
|
|
35
|
+
homepage: ''
|
|
36
|
+
license: ''
|
|
37
|
+
charging:
|
|
38
|
+
price: 0
|
|
39
|
+
tokens: []
|
|
40
|
+
shares: []
|
|
41
|
+
timeout:
|
|
42
|
+
start: 60
|
|
43
|
+
requirements:
|
|
44
|
+
server: '>=1.6.29'
|
|
45
|
+
os: '*'
|
|
46
|
+
cpu: '*'
|
|
47
|
+
scripts:
|
|
48
|
+
preStart: node api/hooks/pre-start.js
|
|
49
|
+
dev: npm run dev
|
|
50
|
+
environments:
|
|
51
|
+
- name: CHAIN_HOST
|
|
52
|
+
description: What's endpoint of the chain?
|
|
53
|
+
required: true
|
|
54
|
+
default: 'https://beta.abtnetwork.io/api/'
|
|
55
|
+
secure: false
|
|
56
|
+
capabilities: {}
|
|
57
|
+
screenshots: []
|
|
58
|
+
children: []
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nextjs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "nodemon -w api api/index.js",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "NODE_ENV=production node api/index.js",
|
|
9
|
+
"lint": "next lint",
|
|
10
|
+
"clean": "rm -rf .blocklet",
|
|
11
|
+
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
12
|
+
"bundle:client": "PUBLIC_URL='/.blocklet/proxy/<%= did %>' npm run build",
|
|
13
|
+
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
14
|
+
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
15
|
+
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
16
|
+
"prepare": "husky install"
|
|
17
|
+
},
|
|
18
|
+
"lint-staged": {
|
|
19
|
+
"*.{mjs,js,jsx,ts,tsx}": [
|
|
20
|
+
"prettier --write",
|
|
21
|
+
"eslint"
|
|
22
|
+
],
|
|
23
|
+
"*.{css,less,scss,json,graphql}": [
|
|
24
|
+
"prettier --write"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@arcblock/did-auth": "^1.15.2",
|
|
29
|
+
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
30
|
+
"@blocklet/sdk": "^1.7.0",
|
|
31
|
+
"@ocap/client": "^1.15.2",
|
|
32
|
+
"@ocap/mcrypto": "^1.15.2",
|
|
33
|
+
"@ocap/wallet": "^1.15.2",
|
|
34
|
+
"dotenv-flow": "^3.2.0",
|
|
35
|
+
"express": "^4.17.3",
|
|
36
|
+
"next": "12.1.0",
|
|
37
|
+
"react": "17.0.2",
|
|
38
|
+
"react-dom": "17.0.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"eslint": "8.11.0",
|
|
42
|
+
"eslint-config-next": "12.1.0",
|
|
43
|
+
"husky": "^7.0.4",
|
|
44
|
+
"lint-staged": "^12.3.7",
|
|
45
|
+
"nodemon": "^2.0.15",
|
|
46
|
+
"npm-run-all": "^4.1.5"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Head from 'next/head';
|
|
2
|
+
import Script from 'next/script';
|
|
3
|
+
import '../styles/globals.css';
|
|
4
|
+
|
|
5
|
+
function MyApp({ Component, pageProps }) {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Head>
|
|
9
|
+
<title>{process.env.APP_TITLE}</title>
|
|
10
|
+
<link rel="icon" href={`${process.env.PUBLIC_URL || ''}/favicon.ico`} />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
12
|
+
<meta name="theme-color" content="#4F6AF5" />
|
|
13
|
+
<meta name="description" content="Web site created using create-blocklet" />
|
|
14
|
+
</Head>
|
|
15
|
+
<Script src="__meta__.js" />
|
|
16
|
+
<Component {...pageProps} />
|
|
17
|
+
</>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default MyApp;
|