create-blocklet 0.9.4 → 0.9.6

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.
Files changed (75) hide show
  1. package/index.js +70 -0
  2. package/package.json +1 -1
  3. package/templates/base-readme.md +103 -0
  4. package/templates/did-wallet-dapp/.eslintrc.js +7 -0
  5. package/templates/did-wallet-dapp/README.md +32 -0
  6. package/templates/did-wallet-dapp/api/dev.js +8 -0
  7. package/templates/did-wallet-dapp/api/functions/app.js +65 -0
  8. package/templates/did-wallet-dapp/api/index.js +13 -0
  9. package/templates/did-wallet-dapp/api/libs/constant.js +1 -0
  10. package/templates/did-wallet-dapp/api/routes/user.js +30 -0
  11. package/templates/did-wallet-dapp/blocklet.md +3 -0
  12. package/templates/did-wallet-dapp/blocklet.yml +59 -0
  13. package/templates/did-wallet-dapp/index.html +16 -0
  14. package/templates/did-wallet-dapp/package.json +84 -0
  15. package/templates/did-wallet-dapp/src/app.jsx +38 -0
  16. package/templates/did-wallet-dapp/src/assets/blocklet.svg +16 -0
  17. package/templates/did-wallet-dapp/src/assets/react.svg +1 -0
  18. package/templates/did-wallet-dapp/src/assets/vite.svg +1 -0
  19. package/templates/did-wallet-dapp/src/assets/wallet.png +0 -0
  20. package/templates/did-wallet-dapp/src/components/layout.jsx +28 -0
  21. package/templates/did-wallet-dapp/src/global.css +79 -0
  22. package/templates/did-wallet-dapp/src/index.jsx +6 -0
  23. package/templates/did-wallet-dapp/src/libs/api.js +7 -0
  24. package/templates/did-wallet-dapp/src/libs/session.js +13 -0
  25. package/templates/did-wallet-dapp/src/locales/en.js +13 -0
  26. package/templates/did-wallet-dapp/src/locales/index.js +4 -0
  27. package/templates/did-wallet-dapp/src/locales/zh.js +13 -0
  28. package/templates/did-wallet-dapp/src/pages/home/index.css +39 -0
  29. package/templates/did-wallet-dapp/src/pages/home/index.jsx +57 -0
  30. package/templates/did-wallet-dapp/src/pages/profile.jsx +136 -0
  31. package/templates/did-wallet-dapp/template-info.json +12 -0
  32. package/templates/did-wallet-dapp/vite.config.js +14 -0
  33. package/templates/did-wallet-dapp/vite.config.server.js +9 -0
  34. package/templates/express-api/README.md +2 -124
  35. package/templates/html-static/README.md +3 -125
  36. package/templates/monorepo/README.md +8 -8
  37. package/templates/nestjs-api/README.md +2 -123
  38. package/templates/nextjs-dapp/README.md +2 -125
  39. package/templates/react-dapp/README.md +2 -124
  40. package/templates/react-dapp/package.json +1 -1
  41. package/templates/react-dapp-ts/README.md +2 -125
  42. package/templates/react-dapp-ts/package.json +1 -1
  43. package/templates/react-gun-dapp/README.md +2 -125
  44. package/templates/react-gun-dapp/package.json +1 -1
  45. package/templates/react-static/README.md +2 -125
  46. package/templates/react-static/package.json +1 -1
  47. package/templates/solidjs-dapp/README.md +2 -125
  48. package/templates/solidjs-dapp/package.json +1 -1
  49. package/templates/solidjs-static/README.md +2 -123
  50. package/templates/solidjs-static/package.json +1 -1
  51. package/templates/svelte-dapp/README.md +2 -124
  52. package/templates/svelte-dapp/package.json +1 -1
  53. package/templates/svelte-static/README.md +2 -125
  54. package/templates/svelte-static/package.json +1 -1
  55. package/templates/todo-list-example/api/src/index.ts +1 -1
  56. package/templates/todo-list-example/api/src/libs/auth.ts +1 -1
  57. package/templates/todo-list-example/api/src/routes/index.ts +1 -0
  58. package/templates/todo-list-example/api/src/routes/todo-list/$get.ts +17 -14
  59. package/templates/todo-list-example/api/src/routes/todo-list/$put.ts +9 -3
  60. package/templates/todo-list-example/api/src/routes/todo-list/index.ts +1 -0
  61. package/templates/todo-list-example/package.json +27 -27
  62. package/templates/todo-list-example/src/app.tsx +3 -2
  63. package/templates/todo-list-example/src/contexts/session.tsx +1 -1
  64. package/templates/todo-list-example/src/pages/required-login.tsx +1 -0
  65. package/templates/todo-list-example/src/pages/todo-list.tsx +16 -6
  66. package/templates/vue-dapp/README.md +2 -125
  67. package/templates/vue-dapp/package.json +1 -1
  68. package/templates/vue-static/README.md +2 -125
  69. package/templates/vue-static/package.json +1 -1
  70. package/templates/vue-ts-static/README.md +2 -124
  71. package/templates/vue-ts-static/package.json +1 -1
  72. package/templates/vue2-dapp/README.md +2 -125
  73. package/templates/vue2-dapp/package.json +1 -1
  74. package/templates/vue2-static/README.md +2 -125
  75. package/templates/vue2-static/package.json +1 -1
@@ -0,0 +1,79 @@
1
+ body {
2
+ background-color: #fff;
3
+ width: 100%;
4
+ height: 100vh;
5
+ }
6
+
7
+ #app {
8
+ height: 100%;
9
+ display: flex;
10
+ flex-direction: column;
11
+ }
12
+
13
+ .container {
14
+ max-width: 1280px;
15
+ margin: 0 auto;
16
+ padding: 2rem;
17
+ }
18
+
19
+ :root {
20
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
21
+ line-height: 1.5;
22
+ font-weight: 400;
23
+
24
+ color-scheme: light dark;
25
+ color: rgba(255, 255, 255, 0.87);
26
+ background-color: #242424;
27
+
28
+ font-synthesis: none;
29
+ text-rendering: optimizeLegibility;
30
+ -webkit-font-smoothing: antialiased;
31
+ -moz-osx-font-smoothing: grayscale;
32
+ }
33
+
34
+ a {
35
+ font-weight: 500;
36
+ color: #646cff;
37
+ text-decoration: inherit;
38
+ }
39
+ a:hover {
40
+ color: #535bf2;
41
+ }
42
+
43
+
44
+ h1 {
45
+ font-size: 3.2em;
46
+ line-height: 1.1;
47
+ }
48
+
49
+ button {
50
+ border-radius: 8px;
51
+ border: 1px solid transparent;
52
+ padding: 0.6em 1.2em;
53
+ font-size: 1em;
54
+ font-weight: 500;
55
+ font-family: inherit;
56
+ background-color: #1a1a1a;
57
+ cursor: pointer;
58
+ transition: border-color 0.25s;
59
+ }
60
+ button:hover {
61
+ border-color: #646cff;
62
+ }
63
+ button:focus,
64
+ button:focus-visible {
65
+ outline: 4px auto -webkit-focus-ring-color;
66
+ }
67
+
68
+ @media (prefers-color-scheme: light) {
69
+ :root {
70
+ color: #213547;
71
+ background-color: #ffffff;
72
+ }
73
+ a:hover {
74
+ color: #747bff;
75
+ }
76
+ button {
77
+ background-color: #f9f9f9;
78
+ }
79
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import App from './app';
4
+
5
+ const root = createRoot(document.getElementById('app'));
6
+ root.render(<App />);
@@ -0,0 +1,7 @@
1
+ import { createAxios } from '@blocklet/js-sdk';
2
+
3
+ const api = createAxios({
4
+ baseURL: window?.blocklet?.prefix || '/',
5
+ });
6
+
7
+ export default api;
@@ -0,0 +1,13 @@
1
+ /* eslint-disable object-curly-newline */
2
+ import { useContext } from 'react';
3
+ import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session';
4
+
5
+ const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();
6
+
7
+ function useSessionContext() {
8
+ // get session info, see more: https://www.arcblock.io/docs/blocklet-developer/blocklet-sdk#session
9
+ const info = useContext(SessionContext);
10
+ return info;
11
+ }
12
+
13
+ export { SessionProvider, SessionContext, SessionConsumer, useSessionContext, withSession };
@@ -0,0 +1,13 @@
1
+ import { flatten } from 'flat';
2
+
3
+ export default flatten({
4
+ name: 'Name',
5
+ avatar: 'Avatar',
6
+ did: 'DID',
7
+ email: 'Email',
8
+ role: 'Role',
9
+ lastLogin: 'Last Login',
10
+ createdAt: 'Created At',
11
+ passports: 'Passports',
12
+ profile: 'Profile',
13
+ });
@@ -0,0 +1,4 @@
1
+ import en from './en';
2
+ import zh from './zh';
3
+
4
+ export const translations = { zh, en };
@@ -0,0 +1,13 @@
1
+ import { flatten } from 'flat';
2
+
3
+ export default flatten({
4
+ name: '姓名',
5
+ avatar: '头像',
6
+ did: 'DID',
7
+ email: '邮箱',
8
+ role: '角色',
9
+ lastLogin: '上次登录',
10
+ createdAt: '创建时间',
11
+ passports: '通行证',
12
+ profile: '个人信息',
13
+ });
@@ -0,0 +1,39 @@
1
+
2
+ .logo {
3
+ height: 6em;
4
+ padding: 1.5em;
5
+ will-change: filter;
6
+ transition: filter 300ms;
7
+ }
8
+ .logo:hover {
9
+ filter: drop-shadow(0 0 2em #646cffaa);
10
+ }
11
+ .logo.react:hover {
12
+ filter: drop-shadow(0 0 2em #61dafbaa);
13
+ }
14
+ .logo.blocklet:hover {
15
+ filter: drop-shadow(0 0 2em #22cdcdaa);
16
+ }
17
+
18
+ @keyframes logo-spin {
19
+ from {
20
+ transform: rotate(0deg);
21
+ }
22
+ to {
23
+ transform: rotate(360deg);
24
+ }
25
+ }
26
+
27
+ @media (prefers-reduced-motion: no-preference) {
28
+ a:nth-of-type(2) .logo {
29
+ animation: logo-spin infinite 20s linear;
30
+ }
31
+ }
32
+
33
+ .card {
34
+ padding: 2em;
35
+ }
36
+
37
+ .read-the-docs {
38
+ color: #888;
39
+ }
@@ -0,0 +1,57 @@
1
+ import { useState } from 'react';
2
+ import { Stack } from '@mui/material';
3
+ import reactLogo from '../../assets/react.svg';
4
+ import blockletLogo from '../../assets/blocklet.svg';
5
+ import viteLogo from '../../assets/vite.svg';
6
+ import walletLogo from '../../assets/wallet.png';
7
+ import api from '../../libs/api';
8
+ import './index.css';
9
+
10
+ function Home() {
11
+ const [count, setCount] = useState(0);
12
+
13
+ async function getApiData() {
14
+ const { data } = await api.get('/api/data');
15
+ const { message } = data;
16
+ alert(`Message from api: ${message}`);
17
+ }
18
+
19
+ return (
20
+ <Stack sx={{ textAlign: 'center', mt: '10%'}}>
21
+ <div>
22
+ <a href="https://vitejs.dev" target="_blank" rel="noreferrer">
23
+ <img src={viteLogo} className="logo" alt="Vite logo" />
24
+ </a>
25
+ <a href="https://react.dev" target="_blank" rel="noreferrer">
26
+ <img src={reactLogo} className="logo react" alt="React logo" />
27
+ </a>
28
+ <a href="https://www.arcblock.io/docs/blocklet-developer/getting-started" target="_blank" rel="noreferrer">
29
+ <img src={blockletLogo} className="logo blocklet" alt="Blocklet logo" />
30
+ </a>
31
+ <a href="https://www.didwallet.io/en" target="_blank" rel="noreferrer">
32
+ <img src={walletLogo} className="logo wallet" alt="Wallet logo" />
33
+ </a>
34
+ </div>
35
+ <h1>Vite + React + Blocklet + DID Wallet</h1>
36
+ <p>
37
+ This is a demo app for DID Wallet.You can use DID Wallet to sign in and get API data.
38
+ </p>
39
+ <div className="card">
40
+ <button type="button" onClick={() => setCount((currentCount) => currentCount + 1)}>
41
+ count is {count}
42
+ </button>
43
+ <br />
44
+ <br />
45
+ <button type="button" onClick={getApiData}>
46
+ Get API Data
47
+ </button>
48
+ <p>
49
+ Edit <code>src/app.jsx</code> and save to test HMR
50
+ </p>
51
+ </div>
52
+ <p className="read-the-docs">Click on the logo to learn more details</p>
53
+ </Stack>
54
+ );
55
+ }
56
+
57
+ export default Home;
@@ -0,0 +1,136 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import dayjs from 'dayjs';
3
+ import { Avatar, Box, Button, Stack, Typography } from '@mui/material';
4
+
5
+ import InfoRow from '@arcblock/ux/lib/InfoRow';
6
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
7
+ import Tag from '@arcblock/ux/lib/Tag';
8
+ import DID from '@arcblock/ux/lib/DID';
9
+ import uniqBy from 'lodash/uniqBy';
10
+
11
+ import { useSessionContext } from '../libs/session';
12
+
13
+ const formatToDatetime = (date) => {
14
+ if (!date) {
15
+ return '-';
16
+ }
17
+
18
+ return dayjs(date).format('YYYY-MM-DD hh:mm:ss');
19
+ };
20
+
21
+ export default function Main() {
22
+ const { session, api } = useSessionContext();
23
+ const [user, setUser] = useState();
24
+ // function t to translate the text
25
+ const { t } = useLocaleContext();
26
+ const { preferences } = window.blocklet;
27
+
28
+ useEffect(() => {
29
+ getData();
30
+ }, [session.user]); //eslint-disable-line
31
+
32
+ const getData = () => {
33
+ api
34
+ .get('/api/user')
35
+ .then((res) => {
36
+ setUser(res.data.user);
37
+ })
38
+ .catch(() => {
39
+ window.location.reload();
40
+ });
41
+ };
42
+
43
+ const rows = !!user
44
+ ? [
45
+ { name: t('name'), value: <Box display="flex" alignItems="center" gap={2}><Avatar src={user.avatar}/>{user.fullName}</Box> },
46
+ preferences.displayAvatar ? { name: t('avatar'), value: <Avatar alt="" src={user.avatar}></Avatar> } : null,
47
+ { name: t('did'), value: <DID did={user.did} showQrcode locale="zh" /> },
48
+ { name: t('email'), value: user.email },
49
+ {
50
+ name: t('passports'),
51
+ value: user.passports ? (
52
+ <Box sx={{ display: 'flex', gap: 1 }}>
53
+ {uniqBy(user.passports, 'name').map((passport) => (
54
+ <Tag key={passport.name} type={passport.name === 'owner' ? 'success' : 'primary'}>
55
+ {passport.title}
56
+ </Tag>
57
+ ))}
58
+ </Box>
59
+ ) : (
60
+ '--'
61
+ ),
62
+ },
63
+ {
64
+ name: t('role'),
65
+ value: <Tag type={user.role === 'owner' ? 'success' : 'primary'}>{user.role}</Tag>,
66
+ },
67
+ { name: t('lastLogin'), value: formatToDatetime(user.updatedAt) },
68
+ { name: t('createdAt'), value: formatToDatetime(user.createdAt) },
69
+ ].filter(Boolean)
70
+ : [];
71
+
72
+ return (
73
+ <Stack className="container" sx={{ maxWidth: 500, mt: 8 }}>
74
+ {/* Current Page: {pathname} */}
75
+ {!user && (
76
+ <Box
77
+ sx={{
78
+ textAlign: 'center',
79
+ fontSize: '18px',
80
+ color: '#888',
81
+ py: 5,
82
+ }}>
83
+ <Typography>
84
+ You are not logged in yet! {preferences.welcome}
85
+ </Typography>
86
+ <Button
87
+ onClick={() => session.login()}
88
+ style={{ marginTop: 16, textTransform: 'none' }}
89
+ variant="contained"
90
+ color="primary">
91
+ Login
92
+ </Button>
93
+ </Box>
94
+ )}
95
+ {!!user && (
96
+ <Box
97
+ sx={{
98
+ display: 'flex',
99
+ flexDirection: 'column',
100
+ gap: 2,
101
+ '&>div': {
102
+ mb: 0,
103
+ },
104
+ '.info-row__name': {
105
+ fontWeight: 'bold',
106
+ color: 'grey.800',
107
+ },
108
+ }}>
109
+ <Typography variant="h3" mb={3}>
110
+ {t('profile')}
111
+ </Typography>
112
+ {rows.map((row) => {
113
+ if (row.name === t('did')) {
114
+ return (
115
+ <InfoRow
116
+ valueComponent="div"
117
+ key={row.name}
118
+ nameWidth={120}
119
+ name={row.name}
120
+ nameFormatter={() => t('did')}>
121
+ {row.value}
122
+ </InfoRow>
123
+ );
124
+ }
125
+
126
+ return (
127
+ <InfoRow valueComponent="div" key={row.name} nameWidth={120} name={row.name}>
128
+ {row.value}
129
+ </InfoRow>
130
+ );
131
+ })}
132
+ </Box>
133
+ )}
134
+ </Stack>
135
+ );
136
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "did-wallet-dapp",
3
+ "desc": {
4
+ "en": "A simple DID wallet dapp",
5
+ "zh": "一个简单的 DID 钱包 Dapp"
6
+ },
7
+ "blockletType": "dapp",
8
+ "composable": true,
9
+ "languages": "JavaScript",
10
+ "useCase": "Starter",
11
+ "author": "Blocklet"
12
+ }
@@ -0,0 +1,14 @@
1
+ import react from '@vitejs/plugin-react';
2
+ import { defineConfig } from 'vite';
3
+ import { createBlockletPlugin } from 'vite-plugin-blocklet';
4
+ import svgr from 'vite-plugin-svgr';
5
+
6
+ // https://vitejs.dev/config/
7
+ export default defineConfig(() => {
8
+ return {
9
+ plugins: [react(), createBlockletPlugin(), svgr()],
10
+ optimizeDeps: {
11
+ force: process.env.NODE_ENV === 'production',
12
+ },
13
+ };
14
+ });
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'vite';
2
+ import vitePluginRequire from 'vite-plugin-require';
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig(() => {
6
+ return {
7
+ plugins: [vitePluginRequire()],
8
+ };
9
+ });
@@ -1,10 +1,8 @@
1
- # Getting Started with Create Blocklet
2
-
3
- This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
1
+ ## PROJECT_DESCRIPTION
4
2
 
5
3
  This blocklet is a dapp project, which means this is a full-stack application. It's contained both `server` and `client` code.
6
4
 
7
- ## File Structure
5
+ ## FILE_STRUCTURE
8
6
 
9
7
  - screenshots/ - Screenshots
10
8
  - api/ - Api side code
@@ -24,123 +22,3 @@ This blocklet is a dapp project, which means this is a full-stack application. I
24
22
  - package.json - Npm package file
25
23
  - README.md - A guide for this blocklet
26
24
  - 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://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
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://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
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://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
142
-
143
- ## License
144
-
145
- The code is licensed under the Apache 2.0 license found in the
146
- [LICENSE](LICENSE) file.
@@ -1,10 +1,8 @@
1
- # Getting Started with Create Blocklet
2
-
3
- This project was bootstrapped with [Create Blocklet](https://github.com/blocklet/create-blocklet).
1
+ ## PROJECT_DESCRIPTION
4
2
 
5
3
  This blocklet is a static project, which means this is a frontend application. It's contained `client` code.
6
4
 
7
- ## File Structure
5
+ ## FILE_STRUCTURE
8
6
 
9
7
  - app/ - Client side code (A static html project structure)
10
8
  - .env - Environment variables
@@ -19,124 +17,4 @@ This blocklet is a static project, which means this is a frontend application. I
19
17
  - Makefile - Makefile
20
18
  - package.json - Npm package file
21
19
  - README.md - A guide for this blocklet
22
- - version - Version file
23
-
24
- ## Development
25
-
26
- 1. Make sure you have [@blocklet/cli](https://www.npmjs.com/package/@blocklet/cli) installed
27
-
28
- Blocklet needs blocklet server as a dependency. So you need to install it first.
29
- `npm install -g @blocklet/cli`
30
- See details in [https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli](https://www.arcblock.io/docs/blocklet-developer/install-blocklet-cli)
31
-
32
- 2. Init blocklet server & start blocklet server
33
-
34
- Before starting an blocklet server, you need to init blocklet server.
35
- `blocklet server init --mode=debug`
36
- `blocklet server start`
37
- See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
38
-
39
- 3. Go to the project directory `cd [name]`
40
- 4. Install dependencies: `npm install` or `yarn`
41
- 5. Start development server: `blocklet dev`
42
-
43
- ## Bundle
44
-
45
- After developing a blocklet, you may need to bundle it. Use `npm run bundle` command.
46
-
47
- ## Deploy
48
-
49
- - 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.)
50
- > Or you can simply use `npm run deploy` command.
51
- - If you want to deploy this blocklet to remote blocklet server, you can use the command below.
52
-
53
- ```shell
54
- blocklet deploy .blocklet/bundle --endpoint {your blocklet server url} --access-key {blocklet server access key} --access-secret {blocklet server access secret}
55
- ```
56
-
57
- > Make sure the blocklet is bundled before deployment.
58
-
59
- ## Upload to blocklet store
60
-
61
- - If you want to upload the blocklet to any store for other users to download and use, you can following the following instructions.
62
-
63
- Bump version at first.
64
-
65
- ```shell
66
- make bump-version
67
- ```
68
-
69
- Then config blocklet store url.
70
- You can use those store url in below.
71
-
72
- 1. [https://store.blocklet.dev/](https://store.blocklet.dev/)
73
- 2. [https://dev.store.blocklet.dev/](https://dev.store.blocklet.dev/)
74
- 3. A blocklet store started by yourself.
75
- > 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)
76
-
77
- ```shell
78
- blocklet config set store {store url}
79
- ```
80
-
81
- Get a `accessToken` from blocklet store.
82
-
83
- > Why we need a `accessToken`?
84
- > A `accessToken` is genrate by blocklet store, which help us upload our blocklet to any store.
85
-
86
- Set `accessToken` to blocklet config
87
-
88
- ```shell
89
- blocklet config set accessToken {accessToken}
90
- ```
91
-
92
- Upload a new version to a store.
93
-
94
- > Make sure the blocklet is bundled before upload.
95
-
96
- ```shell
97
- blocklet upload
98
- ```
99
-
100
- Or you can simply use `npm run upload` command.
101
-
102
- - You also can upload a new version to blocklet store by Github CI.
103
- Bump version at first.
104
-
105
- ```shell
106
- make bump-version
107
- ```
108
-
109
- Push your code to Github main/master branch, or make a pull request to the main/master branch.
110
- The CI workflow will automatically upload a new version to a store.
111
-
112
- ## Q & A
113
-
114
- 1. Q: How to change a blocklet's name?
115
-
116
- A: Change the `name` field in the `package.json` file, change the `name` field in the `blocklet.yml` file.
117
-
118
- You can also change the `title` field and `description` field in the `blocklet.yml` file.
119
-
120
- Run `blocklet meta` command, you will get a `did` config, copy the `did` value.
121
-
122
- Replace this command `"bundle": "PUBLIC_URL='/.blocklet/proxy/{did}' npm run build",` in `package.json`
123
-
124
- Replace `did` field in the `blocklet.yml`
125
-
126
- 2. Q: How to change a blocklet's logo?
127
-
128
- Change the `logo.png` file root folder.
129
-
130
- Or you can change the `logo` field in the `blocklet.yml` file.
131
-
132
- > Make sure you have added the logo path to the `blocklet.yml` file `files` field.
133
-
134
- ## Learn More
135
-
136
- - 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)
137
- - Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
138
-
139
- ## License
140
-
141
- The code is licensed under the Apache 2.0 license found in the
142
- [LICENSE](LICENSE) file.
20
+ - version - Version file