create-blocklet 0.7.5 → 0.7.7

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 (64) hide show
  1. package/index.js +5 -0
  2. package/package.json +1 -1
  3. package/templates/react-dapp/package.json +1 -1
  4. package/templates/react-dapp-ts/package.json +1 -1
  5. package/templates/react-gun-dapp/package.json +1 -1
  6. package/templates/react-static/package.json +1 -1
  7. package/templates/solidjs-dapp/package.json +1 -1
  8. package/templates/solidjs-static/package.json +1 -1
  9. package/templates/svelte-dapp/package.json +1 -1
  10. package/templates/svelte-static/package.json +1 -1
  11. package/templates/todo-list-example/.editorconfig +23 -0
  12. package/templates/todo-list-example/.eslintrc.js +13 -0
  13. package/templates/todo-list-example/.github/workflows/main.yml +36 -0
  14. package/templates/todo-list-example/.github/workflows/pr-title.yml +21 -0
  15. package/templates/todo-list-example/.github/workflows/version-check.yml +20 -0
  16. package/templates/todo-list-example/.husky/pre-commit +4 -0
  17. package/templates/todo-list-example/.prettierrc +9 -0
  18. package/templates/todo-list-example/LICENSE +13 -0
  19. package/templates/todo-list-example/README.md +28 -0
  20. package/templates/todo-list-example/README.zh.md +28 -0
  21. package/templates/todo-list-example/api/dev.ts +5 -0
  22. package/templates/todo-list-example/api/hooks/pre-start.js +12 -0
  23. package/templates/todo-list-example/api/src/hooks/pre-start.ts +37 -0
  24. package/templates/todo-list-example/api/src/index.ts +49 -0
  25. package/templates/todo-list-example/api/src/libs/auth.ts +19 -0
  26. package/templates/todo-list-example/api/src/libs/env.ts +6 -0
  27. package/templates/todo-list-example/api/src/libs/logger.ts +3 -0
  28. package/templates/todo-list-example/api/src/routes/index.ts +10 -0
  29. package/templates/todo-list-example/api/src/routes/todo-list/$get.ts +31 -0
  30. package/templates/todo-list-example/api/src/routes/todo-list/$put.ts +29 -0
  31. package/templates/todo-list-example/api/src/routes/todo-list/index.ts +12 -0
  32. package/templates/todo-list-example/api/third.d.ts +17 -0
  33. package/templates/todo-list-example/blocklet.md +3 -0
  34. package/templates/todo-list-example/blocklet.yml +51 -0
  35. package/templates/todo-list-example/index.html +14 -0
  36. package/templates/todo-list-example/logo.png +0 -0
  37. package/templates/todo-list-example/package.json +109 -0
  38. package/templates/todo-list-example/public/.gitkeep +0 -0
  39. package/templates/todo-list-example/screenshots/.gitkeep +0 -0
  40. package/templates/todo-list-example/screenshots/1-login.png +0 -0
  41. package/templates/todo-list-example/screenshots/2-ui.png +0 -0
  42. package/templates/todo-list-example/scripts/build-clean.js +5 -0
  43. package/templates/todo-list-example/scripts/bump-version.mjs +35 -0
  44. package/templates/todo-list-example/src/app.css +30 -0
  45. package/templates/todo-list-example/src/app.tsx +32 -0
  46. package/templates/todo-list-example/src/components/layout.tsx +12 -0
  47. package/templates/todo-list-example/src/contexts/session.tsx +11 -0
  48. package/templates/todo-list-example/src/env.d.ts +5 -0
  49. package/templates/todo-list-example/src/index.tsx +6 -0
  50. package/templates/todo-list-example/src/libs/api.ts +14 -0
  51. package/templates/todo-list-example/src/logo.svg +1 -0
  52. package/templates/todo-list-example/src/pages/required-login.tsx +48 -0
  53. package/templates/todo-list-example/src/pages/todo-list.css +260 -0
  54. package/templates/todo-list-example/src/pages/todo-list.tsx +266 -0
  55. package/templates/todo-list-example/template-info.json +12 -0
  56. package/templates/todo-list-example/tsconfig.api.json +9 -0
  57. package/templates/todo-list-example/tsconfig.eslint.json +7 -0
  58. package/templates/todo-list-example/tsconfig.json +102 -0
  59. package/templates/todo-list-example/version +1 -0
  60. package/templates/todo-list-example/vite.config.mts +18 -0
  61. package/templates/vue-dapp/package.json +1 -1
  62. package/templates/vue-static/package.json +1 -1
  63. package/templates/vue2-dapp/package.json +1 -1
  64. package/templates/vue2-static/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "blocklet-project",
3
+ "version": "0.1.0",
4
+ "scripts": {
5
+ "dev": "blocklet dev",
6
+ "eject": "vite eject",
7
+ "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
8
+ "lint:fix": "npm run lint -- --fix",
9
+ "start": "cross-env NODE_ENV=development nodemon api/dev.ts -w api",
10
+ "clean": "node scripts/build-clean.js",
11
+ "bundle": "tsc --noEmit && npm run bundle:client && npm run bundle:api",
12
+ "bundle:client": "vite build",
13
+ "bundle:api": "npm run clean && tsc -p tsconfig.api.json && 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
+ "bump-version": "zx --quiet scripts/bump-version.mjs"
18
+ },
19
+ "lint-staged": {
20
+ "*.{mjs,js,jsx,ts,tsx}": [
21
+ "prettier --write",
22
+ "eslint"
23
+ ],
24
+ "*.{css,less,scss,json,graphql}": [
25
+ "prettier --write"
26
+ ]
27
+ },
28
+ "browserslist": {
29
+ "production": [
30
+ ">0.2%",
31
+ "not dead",
32
+ "not op_mini all"
33
+ ],
34
+ "development": [
35
+ "last 1 chrome version",
36
+ "last 1 firefox version",
37
+ "last 1 safari version"
38
+ ]
39
+ },
40
+ "dependencies": {
41
+ "@arcblock/did-auth": "^1.18.113",
42
+ "@arcblock/did-auth-storage-nedb": "^1.7.1",
43
+ "@arcblock/did-connect": "^2.9.63",
44
+ "@arcblock/ux": "^2.9.63",
45
+ "@blocklet/sdk": "^1.16.24",
46
+ "@blocklet/ui-react": "^2.9.63",
47
+ "@did-space/client": "^0.3.74",
48
+ "@did-space/core": "^0.3.74",
49
+ "@mui/material": "^5.15.14",
50
+ "@ocap/client": "^1.18.113",
51
+ "@ocap/mcrypto": "^1.18.113",
52
+ "@ocap/wallet": "^1.18.113",
53
+ "axios": "^1.6.8",
54
+ "cookie-parser": "^1.4.6",
55
+ "cors": "^2.8.5",
56
+ "dotenv-flow": "^3.3.0",
57
+ "express": "^4.19.2",
58
+ "express-async-errors": "^3.1.1",
59
+ "lodash": "^4.17.21",
60
+ "nanoid": "^5.0.6",
61
+ "react": "^18.2.0",
62
+ "react-dom": "^18.2.0",
63
+ "react-icons": "^5.0.1",
64
+ "react-router-dom": "^6.22.3",
65
+ "react-toastify": "^10.0.5",
66
+ "rimraf": "^3.0.2"
67
+ },
68
+ "devDependencies": {
69
+ "@arcblock/eslint-config": "^0.2.4",
70
+ "@arcblock/eslint-config-ts": "^0.2.4",
71
+ "@types/cookie-parser": "^1.4.7",
72
+ "@types/cors": "^2.8.17",
73
+ "@types/dotenv-flow": "^3.3.3",
74
+ "@types/express": "^4.17.21",
75
+ "@types/lodash": "^4.17.0",
76
+ "@types/node": "^18.19.26",
77
+ "@types/react": "^18.2.73",
78
+ "@types/react-dom": "^18.2.22",
79
+ "@types/react-toastify": "^4.1.0",
80
+ "@vitejs/plugin-react": "^4.2.1",
81
+ "bumpp": "^8.2.1",
82
+ "cross-env": "^7.0.3",
83
+ "eslint": "^8.57.0",
84
+ "eslint-plugin-prettier": "^5.1.3",
85
+ "husky": "^8.0.3",
86
+ "import-sort-style-module": "^6.0.0",
87
+ "lint-staged": "^12.5.0",
88
+ "nodemon": "^3.1.0",
89
+ "npm-run-all": "^4.1.5",
90
+ "prettier": "^3.2.5",
91
+ "prettier-plugin-import-sort": "^0.0.7",
92
+ "ts-node": "^10.9.2",
93
+ "typescript": "^5.4.3",
94
+ "vite": "^5.0.13",
95
+ "vite-plugin-blocklet": "^0.7.7",
96
+ "vite-plugin-svgr": "^4.2.0",
97
+ "zx": "^7.2.3"
98
+ },
99
+ "importSort": {
100
+ ".js, .jsx, .mjs": {
101
+ "parser": "babylon",
102
+ "style": "module"
103
+ },
104
+ ".ts, .tsx": {
105
+ "style": "module",
106
+ "parser": "typescript"
107
+ }
108
+ }
109
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ const rimraf = require('rimraf');
2
+
3
+ console.log('clean .blocklet folder');
4
+ rimraf.sync('.blocklet');
5
+ console.log('clean .blocklet folder done!');
@@ -0,0 +1,35 @@
1
+ /* eslint-disable no-console */
2
+ import { execSync } from 'child_process';
3
+ import { $, chalk, fs } from 'zx';
4
+
5
+ execSync('bumpp --no-tag --no-commit --no-push package.json', { stdio: 'inherit' });
6
+
7
+ const { version } = await fs.readJSON('package.json');
8
+ await fs.writeFileSync('version', version);
9
+
10
+ console.log(chalk.greenBright(`[info]: start to modify blocklet version to ${version}`));
11
+ await $`blocklet version ${version}`;
12
+ console.log(chalk.greenBright('[info]: blocklet version modified.'));
13
+
14
+ let newChangelog = '';
15
+ try {
16
+ const gitRes = await $`git log --pretty=format:"- %s" "main"...HEAD`;
17
+ newChangelog = gitRes.stdout.trim();
18
+ } catch {
19
+ console.error(chalk.redBright('Could not get git log, please write changelog manually.'));
20
+ }
21
+
22
+ const now = new Date();
23
+ const currentDate = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
24
+ const title = `## ${version} (${currentDate})`;
25
+
26
+ await fs.ensureFile('CHANGELOG.md');
27
+ const oldChangelog = await fs.readFile('CHANGELOG.md', 'utf8');
28
+ const changelog = [title, newChangelog, oldChangelog].filter((item) => !!item).join('\n\n');
29
+ await fs.writeFile('CHANGELOG.md', changelog);
30
+
31
+ console.log(`\nNow you can make adjustments to ${chalk.cyan('CHANGELOG.md')} . Then press enter to continue.`);
32
+
33
+ process.stdin.setRawMode(true);
34
+ process.stdin.resume();
35
+ process.stdin.on('data', process.exit.bind(process, 0));
@@ -0,0 +1,30 @@
1
+ html,
2
+ body {
3
+ padding: 0;
4
+ margin: 0;
5
+ }
6
+ .app {
7
+ text-align: center;
8
+ }
9
+
10
+ .app-logo {
11
+ height: 10vmin;
12
+ pointer-events: none;
13
+ }
14
+
15
+ .app-header {
16
+ min-height: 100vh;
17
+ display: flex;
18
+ flex-direction: column;
19
+ align-items: center;
20
+ justify-content: center;
21
+ font-size: calc(10px + 2vmin);
22
+ }
23
+
24
+ pre {
25
+ font-size: 0.75em;
26
+ }
27
+
28
+ .app-link {
29
+ color: #4f6af5;
30
+ }
@@ -0,0 +1,32 @@
1
+ import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
2
+ import { LocaleProvider } from '@arcblock/ux/lib/Locale/context';
3
+ import TodoList from './pages/todo-list';
4
+ import Layout from './components/layout';
5
+ import { SessionProvider } from './contexts/session';
6
+
7
+ function App() {
8
+ return (
9
+ <div className="app">
10
+ <Routes>
11
+ <Route path="/" element={<Layout />}>
12
+ <Route path="" element={<TodoList />} />
13
+ </Route>
14
+ </Routes>
15
+ </div>
16
+ );
17
+ }
18
+
19
+ export default function WrappedApp() {
20
+ // While the blocklet is deploy to a sub path, this will be work properly.
21
+ const basename = window?.blocklet?.prefix || '/';
22
+
23
+ return (
24
+ <SessionProvider>
25
+ <LocaleProvider translations={{}}>
26
+ <Router basename={basename}>
27
+ <App />
28
+ </Router>
29
+ </LocaleProvider>
30
+ </SessionProvider>
31
+ );
32
+ }
@@ -0,0 +1,12 @@
1
+ import Header from '@blocklet/ui-react/lib/Header';
2
+ import { Outlet } from 'react-router-dom';
3
+
4
+ export default function Layout() {
5
+ return (
6
+ <>
7
+ {/* @ts-ignore */}
8
+ <Header brand={null} description={null} maxWidth={false} />
9
+ <Outlet />
10
+ </>
11
+ );
12
+ }
@@ -0,0 +1,11 @@
1
+ import { useContext } from 'react';
2
+ import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session';
3
+
4
+ const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();
5
+
6
+ function useSessionContext() {
7
+ const info = useContext(SessionContext);
8
+ return info as any;
9
+ }
10
+
11
+ export { SessionProvider, SessionContext, SessionConsumer, useSessionContext, withSession };
@@ -0,0 +1,5 @@
1
+ declare var blocklet: { prefix: string } | undefined;
2
+
3
+ declare module '@arcblock/ux/*';
4
+ declare module '@arcblock/did-connect/*';
5
+ declare module '*.svg';
@@ -0,0 +1,6 @@
1
+ import ReactDOM from 'react-dom/client';
2
+
3
+ import App from './app';
4
+
5
+ const root = ReactDOM.createRoot(document.getElementById('app')!);
6
+ root.render(<App />);
@@ -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 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="450" height="520" viewBox="0 0 45 52"><g fill="none" fill-rule="evenodd" stroke="#4F6AF5"><path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"></path><path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"></path></g></svg>
@@ -0,0 +1,48 @@
1
+ import { Alert, Button, Grid } from '@mui/material';
2
+ import { useEffect } from 'react';
3
+ import { useNavigate } from 'react-router-dom';
4
+ import { useSessionContext } from '../contexts/session';
5
+
6
+ type RequiredLoginProps = {
7
+ onLogin?: Function;
8
+ nextUrl?: undefined | string;
9
+ } & import('@mui/material').GridProps;
10
+
11
+ /**
12
+ * @description
13
+ * @param {{
14
+ * onLogin: Function,
15
+ * nextUrl: undefined | string,
16
+ * } & import('@mui/material').GridProps} { onLogin = () => {}, nextUrl = undefined, ...rest }
17
+ * @return {*}
18
+ */
19
+ function RequiredLogin({ onLogin = () => {}, nextUrl = undefined, ...rest }: Readonly<RequiredLoginProps>) {
20
+ const { session } = useSessionContext();
21
+ const navigate = useNavigate();
22
+
23
+ useEffect(() => {
24
+ if (!session.user) {
25
+ session.login(onLogin);
26
+ } else if (session.user && nextUrl) {
27
+ navigate(`${nextUrl}${window.location.search}`, { replace: false });
28
+ }
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ }, [session.user, session.login]);
31
+
32
+ return (
33
+ <Grid container justifyContent="center" {...rest}>
34
+ <Grid item justifyContent="center" textAlign="center" xl={12} lg={12}>
35
+ <Alert severity="warning">Connect to the DID Wallet login to access the website</Alert>
36
+ <Button
37
+ onClick={() => session.login()}
38
+ style={{ marginTop: 16, textTransform: 'none' }}
39
+ variant="contained"
40
+ color="primary">
41
+ Login
42
+ </Button>
43
+ </Grid>
44
+ </Grid>
45
+ );
46
+ }
47
+
48
+ export default RequiredLogin;
@@ -0,0 +1,260 @@
1
+ *{
2
+ margin: 0;
3
+ padding: 0;
4
+ font-family: sans-serif;
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ /* container */
9
+ .container{
10
+ width: 100%;
11
+ min-height: 100vh;
12
+ background: #f6f8fa;
13
+ padding: 10px;
14
+ }
15
+
16
+ .todo-app{
17
+ width: 100%;
18
+ max-width: 540px;
19
+ background: white;
20
+ border: 0.5px solid black;
21
+ margin: 20px auto 20px;
22
+ padding: 40px 30px 70px;
23
+ border-radius: 15px;
24
+ }
25
+
26
+ .todo-app h2{
27
+ display: flex;
28
+ align-items: center;
29
+ margin-bottom: 20px;
30
+ justify-content: center;
31
+ }
32
+
33
+ .todo-app h2 img{
34
+ width: 30px;
35
+ margin-left: 10px;
36
+ }
37
+
38
+ /* input box */
39
+ .row{
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: space-between;
43
+ background: #edeef0;
44
+ border-radius: 30px;
45
+ padding-left: 20px;
46
+ margin-bottom: 25px;
47
+ }
48
+
49
+ input{
50
+ position: relative;
51
+ flex: 1;
52
+ border: none;
53
+ outline: none;
54
+ background: none;
55
+ padding: 10px;
56
+ }
57
+
58
+ button{
59
+ border: none;
60
+ outline: none;
61
+ padding: 16px 50px;
62
+ background: #4CAF50;
63
+ color: white;
64
+ font-size: 16px;
65
+ cursor: pointer;
66
+ border-radius: 40px;
67
+ }
68
+
69
+ /* styling on mid */
70
+ .mid{
71
+ display: flex;
72
+ font-size: 1.2rem;
73
+ margin-left: 20px;
74
+ margin-bottom: 30px;
75
+ /* justify-content: space-between; */
76
+
77
+ }
78
+
79
+ #complete-all{
80
+ margin-left: 10px;
81
+ cursor: pointer;
82
+ }
83
+
84
+ #clear-all{
85
+ margin-left: 90px;
86
+ cursor: pointer;
87
+ }
88
+
89
+
90
+ /* styling on todo list */
91
+
92
+ ul {
93
+ list-style-type: none;
94
+ margin: 0;
95
+ padding: 0;
96
+ /* border: 1px solid #e5e5e5; */
97
+ }
98
+
99
+ ul li {
100
+ padding: 10px;
101
+ /* padding-left: 0; */
102
+ display: flex;
103
+ justify-content: space-between;
104
+ align-items: inherit;
105
+ align-items: center;
106
+ }
107
+
108
+ ul li:hover {
109
+ background: lightyellow;
110
+ }
111
+ #list input {
112
+ padding: 0;
113
+ height: initial;
114
+ width: initial;
115
+ margin-bottom: 0;
116
+ display: none;
117
+ cursor: pointer;
118
+ }
119
+
120
+
121
+ #list label {
122
+ position: relative;
123
+ cursor: pointer;
124
+ }
125
+
126
+ #list label:before {
127
+ content:'';
128
+ -webkit-appearance: none;
129
+ background-color: transparent;
130
+ border: 2px solid #0079bf;
131
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05);
132
+ padding: 10px;
133
+ display: inline-block;
134
+ position: relative;
135
+ vertical-align: middle;
136
+ cursor: pointer;
137
+ margin-right: 10px;
138
+ }
139
+ #list input:checked + label:after {
140
+ content: '';
141
+ display: block;
142
+ position: absolute;
143
+ top: 2px;
144
+ left: 9px;
145
+ width: 6px;
146
+ height: 14px;
147
+ border: solid #fff;
148
+ border-width: 0 2px 2px 0;
149
+ transform: rotate(45deg);
150
+ }
151
+ #list input:checked + label:before {
152
+ background: #0079bf;
153
+ }
154
+ #list input:checked + label {
155
+ text-decoration: line-through;
156
+ }
157
+ .delete {
158
+ height: 25px;
159
+ padding: 5px 0px;
160
+ border-radius: 3px;
161
+ }
162
+ .delete:hover {
163
+ background: #f2f2f2;
164
+ cursor: pointer;
165
+ }
166
+
167
+ .edit{
168
+ height: 25px;
169
+ padding: 5px 0px;
170
+ border-radius: 3px;
171
+ margin-right: 10px;
172
+ }
173
+
174
+ .edit:hover{
175
+ background: #f2f2f2;
176
+ cursor: pointer;
177
+ }
178
+
179
+ h1 {
180
+ text-align: center;
181
+ }
182
+ .add-task {
183
+ width: 100%;
184
+ outline: none;
185
+ font-size: 15px;
186
+ padding: 11px;
187
+ border: 1px solid #f3f3f3;
188
+ margin-bottom: 3px;
189
+ }
190
+
191
+
192
+
193
+
194
+ #total-tasks {
195
+ margin-bottom: 20px;
196
+ font-size: 13px;
197
+ margin-left: 2px;
198
+ color: gray;
199
+ }
200
+
201
+ /*
202
+ dropdown*/
203
+ .filters{
204
+ margin-top: 40px;
205
+ }
206
+ .dropbtn {
207
+ background-color: #4CAF50;
208
+ color: white;
209
+ padding: 10px 16px;
210
+ font-size: 16px;
211
+ border: none;
212
+ cursor: pointer;
213
+ border-radius: 5px;
214
+ }
215
+
216
+ .dropdown {
217
+ position: relative;
218
+ display: inline-block;
219
+ }
220
+
221
+ .dropdown-content {
222
+ display: none;
223
+ position: absolute;
224
+ background-color: #f9f9f9;
225
+ min-width: 160px;
226
+ box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
227
+ z-index: 1;
228
+ }
229
+
230
+ .dropdown-content a {
231
+ color: black;
232
+ padding: 12px 16px;
233
+ text-decoration: none;
234
+ display: block;
235
+ }
236
+
237
+ .dropdown-content a:hover {background-color: #f1f1f1}
238
+
239
+ .dropdown:hover .dropdown-content {
240
+ display: block;
241
+ }
242
+
243
+ .dropdown:hover .dropbtn {
244
+ background-color: #3e8e41;
245
+ }
246
+
247
+ .completed-task{
248
+ display: inline-block;
249
+ margin-left: 100px;
250
+ }
251
+
252
+ .remaining-task{
253
+ display: inline-block;
254
+ margin-left: 80px;
255
+ }
256
+
257
+ /* .remaining-task p{
258
+ font-size: 40px;
259
+ color: black;
260
+ } */