create-blocklet 0.7.9 → 0.8.1

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 (255) hide show
  1. package/common/.github/workflows/main.yml +10 -7
  2. package/common/.prettierrc +1 -1
  3. package/common/LICENSE +1 -1
  4. package/common/_gitignore +1 -0
  5. package/common/_npmrc +0 -2
  6. package/common/scripts/build-clean.mjs +7 -0
  7. package/index.js +40 -32
  8. package/lib/arcblock.js +1 -1
  9. package/lib/constant.js +1 -0
  10. package/lib/did.js +2 -1
  11. package/lib/git.js +21 -21
  12. package/lib/server.js +10 -10
  13. package/lib/utils.js +2 -1
  14. package/package.json +16 -16
  15. package/templates/express-api/README.md +3 -3
  16. package/templates/express-api/api/hooks/pre-start.js +2 -1
  17. package/templates/express-api/api/index.js +1 -12
  18. package/templates/express-api/blocklet.yml +1 -1
  19. package/templates/express-api/package.json +20 -17
  20. package/templates/express-api/template-info.json +6 -3
  21. package/templates/html-static/README.md +3 -3
  22. package/templates/html-static/app/index.html +35 -36
  23. package/templates/html-static/app/styles/style.css +9 -1
  24. package/templates/html-static/blocklet.yml +1 -1
  25. package/templates/html-static/package.json +6 -5
  26. package/templates/html-static/template-info.json +2 -2
  27. package/templates/monorepo/.prettierrc +1 -1
  28. package/templates/monorepo/README.md +2 -2
  29. package/templates/monorepo/package.json +21 -13
  30. package/templates/monorepo/scripts/bump-version.mjs +1 -1
  31. package/templates/nestjs-api/.eslintrc.js +27 -3
  32. package/templates/nestjs-api/README.md +3 -3
  33. package/templates/nestjs-api/api/app.controller.ts +3 -1
  34. package/templates/nestjs-api/api/app.service.ts +1 -16
  35. package/templates/nestjs-api/api/hooks/pre-start.js +2 -1
  36. package/templates/nestjs-api/blocklet.yml +1 -1
  37. package/templates/nestjs-api/package.json +29 -26
  38. package/templates/nestjs-api/template-info.json +4 -1
  39. package/templates/nestjs-api/tsconfig.build.json +6 -1
  40. package/templates/nestjs-api/tsconfig.eslint.json +7 -0
  41. package/templates/nextjs-dapp/README.md +3 -3
  42. package/templates/nextjs-dapp/api/hooks/pre-start.js +2 -1
  43. package/templates/nextjs-dapp/blocklet.yml +1 -1
  44. package/templates/nextjs-dapp/package.json +23 -20
  45. package/templates/nextjs-dapp/pages/_app.js +1 -1
  46. package/templates/nextjs-dapp/pages/api/hello.js +1 -1
  47. package/templates/nextjs-dapp/pages/index.js +9 -17
  48. package/templates/nextjs-dapp/styles/Home.module.css +12 -3
  49. package/templates/nextjs-dapp/styles/globals.css +12 -2
  50. package/templates/nextjs-dapp/template-info.json +2 -2
  51. package/templates/react-dapp/README.md +3 -3
  52. package/templates/react-dapp/api/hooks/pre-start.js +2 -1
  53. package/templates/react-dapp/api/index.js +1 -0
  54. package/templates/react-dapp/api/routes/index.js +6 -0
  55. package/templates/react-dapp/blocklet.yml +1 -1
  56. package/templates/react-dapp/index.html +14 -11
  57. package/templates/react-dapp/package.json +32 -28
  58. package/templates/react-dapp/src/app.jsx +1 -5
  59. package/templates/react-dapp/src/assets/blocklet.svg +16 -0
  60. package/templates/react-dapp/src/assets/react.svg +1 -0
  61. package/templates/react-dapp/src/assets/vite.svg +1 -0
  62. package/templates/react-dapp/src/index.css +68 -0
  63. package/templates/react-dapp/src/index.jsx +1 -0
  64. package/templates/react-dapp/src/libs/api.js +5 -12
  65. package/templates/react-dapp/src/pages/home.css +45 -0
  66. package/templates/react-dapp/src/pages/home.jsx +42 -15
  67. package/templates/react-dapp/template-info.json +2 -2
  68. package/templates/react-dapp-ts/.eslintrc.js +3 -0
  69. package/templates/react-dapp-ts/README.md +3 -3
  70. package/templates/react-dapp-ts/api/src/hooks/pre-start.ts +2 -2
  71. package/templates/react-dapp-ts/api/src/routes/index.ts +6 -0
  72. package/templates/react-dapp-ts/blocklet.yml +1 -1
  73. package/templates/react-dapp-ts/index.html +14 -11
  74. package/templates/react-dapp-ts/package.json +38 -34
  75. package/templates/react-dapp-ts/src/app.tsx +1 -6
  76. package/templates/react-dapp-ts/src/assets/blocklet.svg +16 -0
  77. package/templates/react-dapp-ts/src/assets/react.svg +1 -0
  78. package/templates/react-dapp-ts/src/assets/vite.svg +1 -0
  79. package/templates/react-dapp-ts/src/index.css +68 -0
  80. package/templates/react-dapp-ts/src/index.tsx +2 -2
  81. package/templates/react-dapp-ts/src/libs/api.ts +5 -12
  82. package/templates/react-dapp-ts/src/pages/home.css +45 -0
  83. package/templates/react-dapp-ts/src/pages/home.tsx +42 -15
  84. package/templates/react-dapp-ts/tsconfig.api.json +4 -1
  85. package/templates/react-dapp-ts/tsconfig.eslint.json +3 -1
  86. package/templates/react-gun-dapp/README.md +3 -3
  87. package/templates/react-gun-dapp/api/hooks/pre-start.js +2 -1
  88. package/templates/react-gun-dapp/api/index.js +1 -0
  89. package/templates/react-gun-dapp/blocklet.yml +1 -1
  90. package/templates/react-gun-dapp/index.html +14 -11
  91. package/templates/react-gun-dapp/package.json +31 -28
  92. package/templates/react-gun-dapp/src/app.jsx +1 -1
  93. package/templates/react-gun-dapp/src/libs/api.js +1 -1
  94. package/templates/react-gun-dapp/src/pages/about.jsx +5 -1
  95. package/templates/react-gun-dapp/src/pages/home.jsx +5 -1
  96. package/templates/react-static/README.md +3 -3
  97. package/templates/react-static/blocklet.yml +1 -1
  98. package/templates/react-static/index.html +14 -11
  99. package/templates/react-static/package.json +20 -18
  100. package/templates/react-static/src/app.jsx +1 -5
  101. package/templates/react-static/src/assets/blocklet.svg +16 -0
  102. package/templates/react-static/src/assets/react.svg +1 -0
  103. package/templates/react-static/src/assets/vite.svg +1 -0
  104. package/templates/react-static/src/index.css +68 -0
  105. package/templates/react-static/src/index.jsx +1 -0
  106. package/templates/react-static/src/pages/home.css +45 -0
  107. package/templates/react-static/src/pages/home.jsx +30 -15
  108. package/templates/react-static/template-info.json +6 -3
  109. package/templates/solidjs-dapp/.eslintrc.js +2 -1
  110. package/templates/solidjs-dapp/README.md +3 -3
  111. package/templates/solidjs-dapp/api/hooks/pre-start.js +2 -1
  112. package/templates/solidjs-dapp/api/index.js +1 -0
  113. package/templates/solidjs-dapp/api/routes/index.js +6 -0
  114. package/templates/solidjs-dapp/blocklet.yml +4 -2
  115. package/templates/solidjs-dapp/index.html +15 -12
  116. package/templates/solidjs-dapp/package.json +34 -30
  117. package/templates/solidjs-dapp/src/App.jsx +15 -3
  118. package/templates/solidjs-dapp/src/App.module.css +7 -1
  119. package/templates/solidjs-dapp/src/assets/blocklet.svg +16 -0
  120. package/templates/{solidjs-static/src/logo.svg → solidjs-dapp/src/assets/solidjs.svg} +1 -1
  121. package/templates/solidjs-dapp/src/index.css +21 -5
  122. package/templates/solidjs-dapp/src/libs/api.js +7 -0
  123. package/templates/solidjs-dapp/template-info.json +2 -2
  124. package/templates/solidjs-static/.eslintrc.js +4 -0
  125. package/templates/solidjs-static/README.md +3 -3
  126. package/templates/solidjs-static/blocklet.yml +1 -1
  127. package/templates/solidjs-static/index.html +15 -12
  128. package/templates/solidjs-static/package.json +22 -21
  129. package/templates/solidjs-static/src/App.jsx +7 -3
  130. package/templates/solidjs-static/src/App.module.css +7 -1
  131. package/templates/solidjs-static/src/assets/blocklet.svg +16 -0
  132. package/templates/solidjs-static/src/index.css +3 -5
  133. package/templates/solidjs-static/template-info.json +2 -2
  134. package/templates/svelte-dapp/README.md +3 -4
  135. package/templates/svelte-dapp/api/hooks/pre-start.js +2 -1
  136. package/templates/svelte-dapp/api/index.js +1 -0
  137. package/templates/svelte-dapp/api/routes/index.js +6 -0
  138. package/templates/svelte-dapp/blocklet.yml +1 -1
  139. package/templates/svelte-dapp/index.html +13 -10
  140. package/templates/svelte-dapp/jsconfig.json +9 -7
  141. package/templates/svelte-dapp/package.json +29 -29
  142. package/templates/svelte-dapp/src/App.svelte +45 -42
  143. package/templates/svelte-dapp/src/app.css +79 -0
  144. package/templates/svelte-dapp/src/assets/blocklet.svg +16 -0
  145. package/templates/svelte-dapp/src/assets/svelte.svg +1 -0
  146. package/templates/svelte-dapp/src/assets/vite.svg +1 -0
  147. package/templates/svelte-dapp/src/components/Counter.svelte +10 -0
  148. package/templates/svelte-dapp/src/libs/api.js +7 -0
  149. package/templates/svelte-dapp/src/main.js +1 -0
  150. package/templates/svelte-dapp/template-info.json +2 -2
  151. package/templates/svelte-dapp/vite.config.mjs +6 -1
  152. package/templates/svelte-static/README.md +3 -4
  153. package/templates/svelte-static/blocklet.yml +1 -1
  154. package/templates/svelte-static/index.html +13 -10
  155. package/templates/svelte-static/jsconfig.json +9 -7
  156. package/templates/svelte-static/package.json +18 -22
  157. package/templates/svelte-static/src/App.svelte +36 -43
  158. package/templates/svelte-static/src/app.css +79 -0
  159. package/templates/svelte-static/src/assets/blocklet.svg +16 -0
  160. package/templates/svelte-static/src/assets/svelte.svg +1 -0
  161. package/templates/svelte-static/src/assets/vite.svg +1 -0
  162. package/templates/svelte-static/src/components/Counter.svelte +10 -0
  163. package/templates/svelte-static/src/main.js +1 -0
  164. package/templates/svelte-static/template-info.json +6 -3
  165. package/templates/svelte-static/vite.config.mjs +6 -1
  166. package/templates/todo-list-example/.eslintrc.js +1 -1
  167. package/templates/todo-list-example/api/src/hooks/pre-start.ts +2 -1
  168. package/templates/todo-list-example/api/src/routes/todo-list/$get.ts +1 -1
  169. package/templates/todo-list-example/api/src/routes/todo-list/$put.ts +1 -1
  170. package/templates/todo-list-example/blocklet.yml +7 -5
  171. package/templates/todo-list-example/index.html +14 -11
  172. package/templates/todo-list-example/package.json +44 -41
  173. package/templates/todo-list-example/src/components/layout.tsx +1 -1
  174. package/templates/todo-list-example/src/libs/api.ts +5 -12
  175. package/templates/todo-list-example/src/logo.svg +1 -1
  176. package/templates/todo-list-example/src/pages/required-login.tsx +3 -6
  177. package/templates/todo-list-example/src/pages/todo-list.css +72 -68
  178. package/templates/todo-list-example/src/pages/todo-list.tsx +32 -32
  179. package/templates/todo-list-example/template-info.json +1 -1
  180. package/templates/todo-list-example/tsconfig.api.json +4 -1
  181. package/templates/todo-list-example/tsconfig.eslint.json +3 -1
  182. package/templates/vue-dapp/README.md +3 -3
  183. package/templates/vue-dapp/api/hooks/pre-start.js +2 -1
  184. package/templates/vue-dapp/api/index.js +1 -0
  185. package/templates/vue-dapp/api/routes/index.js +6 -0
  186. package/templates/vue-dapp/blocklet.yml +1 -1
  187. package/templates/vue-dapp/index.html +14 -11
  188. package/templates/vue-dapp/package.json +32 -28
  189. package/templates/vue-dapp/src/App.vue +26 -19
  190. package/templates/vue-dapp/src/assets/blocklet.svg +16 -0
  191. package/templates/vue-dapp/src/assets/vite.svg +1 -0
  192. package/templates/vue-dapp/src/assets/vue.svg +1 -0
  193. package/templates/vue-dapp/src/components/HelloWorld.vue +25 -15
  194. package/templates/vue-dapp/src/libs/api.js +5 -12
  195. package/templates/vue-dapp/src/main.js +1 -0
  196. package/templates/vue-dapp/src/style.css +79 -0
  197. package/templates/vue-dapp/template-info.json +2 -2
  198. package/templates/vue-static/README.md +3 -3
  199. package/templates/vue-static/blocklet.yml +1 -1
  200. package/templates/vue-static/index.html +14 -11
  201. package/templates/vue-static/package.json +20 -19
  202. package/templates/vue-static/src/App.vue +27 -12
  203. package/templates/vue-static/src/assets/blocklet.svg +16 -0
  204. package/templates/vue-static/src/assets/vite.svg +1 -0
  205. package/templates/vue-static/src/assets/vue.svg +1 -0
  206. package/templates/vue-static/src/components/HelloWorld.vue +15 -15
  207. package/templates/vue-static/src/main.js +1 -0
  208. package/templates/vue-static/src/style.css +79 -0
  209. package/templates/vue-static/template-info.json +6 -3
  210. package/templates/vue2-dapp/README.md +3 -3
  211. package/templates/vue2-dapp/api/hooks/pre-start.js +2 -1
  212. package/templates/vue2-dapp/api/index.js +1 -0
  213. package/templates/vue2-dapp/blocklet.yml +1 -1
  214. package/templates/vue2-dapp/index.html +14 -11
  215. package/templates/vue2-dapp/package.json +30 -27
  216. package/templates/vue2-dapp/src/libs/api.js +1 -1
  217. package/templates/vue2-dapp/template-info.json +2 -2
  218. package/templates/vue2-static/README.md +3 -3
  219. package/templates/vue2-static/blocklet.yml +1 -1
  220. package/templates/vue2-static/index.html +14 -11
  221. package/templates/vue2-static/package.json +19 -18
  222. package/templates/vue2-static/template-info.json +6 -3
  223. package/common/.husky/pre-commit +0 -4
  224. package/common/scripts/build-clean.js +0 -5
  225. package/templates/express-api/.env +0 -1
  226. package/templates/monorepo/.husky/pre-commit +0 -4
  227. package/templates/react-dapp/src/app.css +0 -30
  228. package/templates/react-dapp/src/logo.svg +0 -1
  229. package/templates/react-dapp/src/pages/about.jsx +0 -16
  230. package/templates/react-dapp-ts/src/app.css +0 -30
  231. package/templates/react-dapp-ts/src/logo.svg +0 -1
  232. package/templates/react-dapp-ts/src/pages/about.tsx +0 -16
  233. package/templates/react-static/src/app.css +0 -30
  234. package/templates/react-static/src/logo.svg +0 -1
  235. package/templates/react-static/src/pages/about.jsx +0 -16
  236. package/templates/svelte-dapp/.eslintrc.js +0 -22
  237. package/templates/svelte-dapp/src/assets/svelte.png +0 -0
  238. package/templates/svelte-dapp/src/lib/Counter.svelte +0 -34
  239. package/templates/svelte-static/.eslintrc.js +0 -22
  240. package/templates/svelte-static/src/assets/svelte.png +0 -0
  241. package/templates/svelte-static/src/lib/Counter.svelte +0 -34
  242. package/templates/todo-list-example/.editorconfig +0 -23
  243. package/templates/todo-list-example/.github/workflows/main.yml +0 -36
  244. package/templates/todo-list-example/.github/workflows/pr-title.yml +0 -21
  245. package/templates/todo-list-example/.github/workflows/version-check.yml +0 -20
  246. package/templates/todo-list-example/.husky/pre-commit +0 -4
  247. package/templates/todo-list-example/.prettierrc +0 -9
  248. package/templates/todo-list-example/logo.png +0 -0
  249. package/templates/todo-list-example/public/.gitkeep +0 -0
  250. package/templates/todo-list-example/screenshots/.gitkeep +0 -0
  251. package/templates/todo-list-example/scripts/build-clean.js +0 -5
  252. package/templates/todo-list-example/scripts/bump-version.mjs +0 -35
  253. package/templates/vue-static/src/assets/logo.png +0 -0
  254. /package/templates/monorepo/{eslintrc.js → .eslintrc.js} +0 -0
  255. /package/templates/{solidjs-dapp/src/logo.svg → solidjs-static/src/assets/solidjs.svg} +0 -0
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
+ - master
7
8
 
8
9
  jobs:
9
10
  Deploy:
@@ -13,20 +14,22 @@ jobs:
13
14
 
14
15
  steps:
15
16
  - name: Checkout repo
16
- uses: actions/checkout@v2
17
+ uses: actions/checkout@v4
17
18
 
18
- - name: Set yarn cache
19
- uses: c-hive/gha-yarn-cache@v2
20
-
21
- - name: Install dependencies
22
- run: yarn
19
+ - uses: pnpm/action-setup@v3
20
+ with:
21
+ version: 9
22
+ - uses: actions/setup-node@v4
23
+ with:
24
+ node-version: '20'
25
+ cache: 'pnpm'
23
26
 
24
27
  - name: Blocklet workflow
25
28
  uses: blocklet/action-workflow@v1
26
29
  with:
27
30
  skip-upload: false
28
31
  skip-deploy: false
29
- bundle-command: yarn bundle
32
+ bundle-command: pnpm bundle
30
33
  store-endpoint: ${{ secrets.STORE_ENDPOINT }}
31
34
  store-access-token: ${{ secrets.STORE_ACCESS_TOKEN }}
32
35
  server-endpoint: ${{ secrets.SERVER_ENDPOINT }}
@@ -2,7 +2,7 @@
2
2
  "printWidth": 120,
3
3
  "useTabs": false,
4
4
  "tabWidth": 2,
5
- "trailingComma": "es5",
5
+ "trailingComma": "all",
6
6
  "bracketSameLine": true,
7
7
  "semi": true,
8
8
  "singleQuote": true
package/common/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2018-2020 ArcBlock
1
+ Copyright 2018-2024 ArcBlock
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
package/common/_gitignore CHANGED
@@ -14,6 +14,7 @@ build
14
14
  dist
15
15
  dist-ssr
16
16
  .blocklet
17
+ .next
17
18
 
18
19
  # local env files
19
20
  *.local
package/common/_npmrc CHANGED
@@ -1,4 +1,2 @@
1
1
  ## force pnpm to hoist
2
2
  shamefully-hoist=true
3
- strict-peer-dependencies=false
4
- node-linker=hoisted
@@ -0,0 +1,7 @@
1
+ /* eslint-disable no-console */
2
+
3
+ import { rimrafSync } from 'rimraf';
4
+
5
+ console.log('clean .blocklet folder');
6
+ rimrafSync('.blocklet');
7
+ console.log('clean .blocklet folder done!');
package/index.js CHANGED
@@ -33,6 +33,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
33
33
  const cwd = process.cwd();
34
34
 
35
35
  const templates = [
36
+ // dapp
36
37
  {
37
38
  name: 'react-dapp',
38
39
  display: '[dapp] react + express.js',
@@ -58,11 +59,11 @@ const templates = [
58
59
  display: '[dapp] vue3 + express.js',
59
60
  color: green,
60
61
  },
61
- {
62
- name: 'vue2-dapp',
63
- display: '[dapp] vue2 + express.js',
64
- color: green,
65
- },
62
+ // {
63
+ // name: 'vue2-dapp',
64
+ // display: '[dapp] vue2 + express.js',
65
+ // color: green,
66
+ // },
66
67
  {
67
68
  name: 'svelte-dapp',
68
69
  display: '[dapp] svelte + express.js',
@@ -73,11 +74,12 @@ const templates = [
73
74
  display: '[dapp] next.js',
74
75
  color: blue,
75
76
  },
76
- {
77
- name: 'react-gun-dapp',
78
- display: '[dapp] react + gun.js + express.js',
79
- color: blue,
80
- },
77
+ // {
78
+ // name: 'react-gun-dapp',
79
+ // display: '[dapp] react + gun.js + express.js',
80
+ // color: blue,
81
+ // },
82
+ // static
81
83
  {
82
84
  name: 'react-static',
83
85
  display: '[static] react',
@@ -93,11 +95,11 @@ const templates = [
93
95
  display: '[static] vue3',
94
96
  color: green,
95
97
  },
96
- {
97
- name: 'vue2-static',
98
- display: '[static] vue2',
99
- color: green,
100
- },
98
+ // {
99
+ // name: 'vue2-static',
100
+ // display: '[static] vue2',
101
+ // color: green,
102
+ // },
101
103
  {
102
104
  name: 'svelte-static',
103
105
  display: '[static] svelte',
@@ -108,6 +110,7 @@ const templates = [
108
110
  display: '[static] html',
109
111
  color: blue,
110
112
  },
113
+ // api
111
114
  {
112
115
  name: 'express-api',
113
116
  display: '[api] express.js',
@@ -120,7 +123,7 @@ const templates = [
120
123
  },
121
124
  ];
122
125
 
123
- //see: https://github.com/npm/npm/issues/3763
126
+ // see: https://github.com/npm/npm/issues/3763
124
127
  const renameFiles = {
125
128
  _gitignore: '.gitignore',
126
129
  _npmrc: '.npmrc',
@@ -145,13 +148,14 @@ async function init() {
145
148
 
146
149
  let targetDir = argv._[0] ? String(argv._[0]) : undefined;
147
150
  const inputTemplateName = argv.template;
148
- const connectUrl = argv.connectUrl;
151
+ const connectUrl = argv?.connectUrl;
149
152
  const inputDid = argv.did;
150
153
  const checkRes = checkDid(inputDid);
151
154
  if (typeof checkRes === 'string') {
152
155
  console.error(checkRes);
153
156
  return;
154
- } else if (checkRes !== true) {
157
+ }
158
+ if (checkRes !== true) {
155
159
  console.error(`Invalid blocklet did: ${inputDid}`);
156
160
  return;
157
161
  }
@@ -255,7 +259,7 @@ async function init() {
255
259
  onCancel: () => {
256
260
  throw new Error(`${red('✖')} Operation cancelled`);
257
261
  },
258
- }
262
+ },
259
263
  );
260
264
  } catch (cancelled) {
261
265
  console.error(cancelled.message);
@@ -333,6 +337,7 @@ async function init() {
333
337
  for (const file of commonFiles) {
334
338
  // 如果选择多个模板,每个子 package 中 只会包含必要的 文件
335
339
  if (mainBlocklet && !['screenshots', 'public', 'logo.png', '.prettierrc', 'LICENSE'].includes(file)) {
340
+ // eslint-disable-next-line no-continue
336
341
  continue;
337
342
  }
338
343
  // html-staic 和 xmark 相关的模板不添加 .husky
@@ -350,7 +355,7 @@ async function init() {
350
355
  // copy template files
351
356
  (() => {
352
357
  // 过滤掉 template-info.json 文件
353
- let files = fs.readdirSync(templateDir).filter((file) => file !== 'template-info.json');
358
+ const files = fs.readdirSync(templateDir).filter((file) => file !== 'template-info.json');
354
359
  for (const file of files) {
355
360
  write(file, null, templateDir, templateName);
356
361
  }
@@ -365,7 +370,7 @@ async function init() {
365
370
  pkg.name = mainBlocklet ? finalTemplateName : name;
366
371
  },
367
372
  templateDir,
368
- templateName
373
+ templateName,
369
374
  );
370
375
  modifyBlockletYaml(
371
376
  (yamlConfig) => {
@@ -373,20 +378,21 @@ async function init() {
373
378
  yamlConfig.title = mainBlocklet ? templateName : name;
374
379
  },
375
380
  templateDir,
376
- templateName
381
+ templateName,
377
382
  );
378
383
 
379
384
  // patch blocklet author
380
385
  modifyBlockletYaml(
381
- async (yamlConfig) => {
386
+ (yamlConfig) => {
382
387
  yamlConfig.author.name = authorName;
383
388
  yamlConfig.author.email = authorEmail;
384
389
  },
385
390
  templateDir,
386
- templateName
391
+ templateName,
387
392
  );
388
393
 
389
394
  // patch did
395
+ // eslint-disable-next-line no-inner-declarations, require-await
390
396
  async function patchDid() {
391
397
  const did = didList[index];
392
398
  modifyBlockletYaml(
@@ -394,7 +400,7 @@ async function init() {
394
400
  yamlConfig.did = did;
395
401
  },
396
402
  templateDir,
397
- templateName
403
+ templateName,
398
404
  );
399
405
  modifyPackage(
400
406
  (pkg) => {
@@ -422,12 +428,13 @@ async function init() {
422
428
  }
423
429
  },
424
430
  templateDir,
425
- templateName
431
+ templateName,
426
432
  );
427
433
  // disabled random logo
428
434
  // const pngIcon = toDidIcon(did, undefined, true);
429
435
  // fs.writeFileSync(path.join(root, 'logo.png'), pngIcon);
430
436
  }
437
+ // eslint-disable-next-line no-await-in-loop
431
438
  await patchDid();
432
439
  }
433
440
 
@@ -462,7 +469,7 @@ async function init() {
462
469
  await initGitRepo(root);
463
470
 
464
471
  let defaultAgent = 'npm';
465
- let agentList = ['npm', 'yarn', 'pnpm'];
472
+ const agentList = ['npm', 'yarn', 'pnpm'];
466
473
 
467
474
  // switch (templateNames) {
468
475
  // case 'react':
@@ -493,7 +500,7 @@ async function init() {
493
500
  padding: 1,
494
501
  margin: 1,
495
502
  float: 'center',
496
- })
503
+ }),
497
504
  );
498
505
  hasStart = true;
499
506
  execSync('blocklet dev', { stdio: 'inherit' });
@@ -540,7 +547,7 @@ async function init() {
540
547
  // console.log(dim('\n start it later by:\n'));
541
548
  if (root !== cwd) console.log(blue(` cd ${bold(related)}`));
542
549
  if (mainBlocklet) {
543
- console.log(blue(`npm run init`));
550
+ console.log(blue('npm run init'));
544
551
  } else {
545
552
  console.log(blue(`${defaultAgent === 'yarn' ? 'yarn' : `${defaultAgent} install`}`));
546
553
  console.log(cyan('blocklet dev'));
@@ -571,20 +578,21 @@ async function init() {
571
578
  return null;
572
579
  }
573
580
 
574
- function modifyPackage(modifyFn = () => {}, templateDir, templateName) {
581
+ function modifyPackage(modifyFn = () => {}, templateDir = '', templateName = '') {
575
582
  const pkg = JSON.parse(read('package.json', templateName));
576
583
  modifyFn(pkg);
577
584
  write('package.json', JSON.stringify(pkg, null, 2), templateDir, templateName);
578
585
  }
579
586
 
580
- function modifyBlockletYaml(modifyFn = () => {}, templateDir, templateName) {
587
+ function modifyBlockletYaml(modifyFn = () => {}, templateDir = '', templateName = '') {
581
588
  const blockletYaml = read('blocklet.yml', templateName);
582
589
  const yamlConfig = YAML.parse(blockletYaml);
583
590
  modifyFn(yamlConfig);
584
591
  write('blocklet.yml', YAML.stringify(yamlConfig, 2), templateDir, templateName);
585
592
  }
586
593
 
587
- function modifyEnv(modifyFn = (...args) => ({ ...args }), templateDir, templateName) {
594
+ // eslint-disable-next-line no-unused-vars
595
+ function modifyEnv(modifyFn = (...args) => ({ ...args }), templateDir = '', templateName = '') {
588
596
  const envContent = read('.env', templateName);
589
597
  if (envContent) {
590
598
  const env = envfile.parse(envContent);
package/lib/arcblock.js CHANGED
@@ -25,7 +25,7 @@ export function echoBrand({ version = '' }) {
25
25
  });
26
26
  }
27
27
  export function echoDocument() {
28
- const url = 'https://developer.blocklet.io/docs/';
28
+ const url = 'https://www.arcblock.io/docs/blocklet-developer';
29
29
  let msg;
30
30
  if (terminalLink.isSupported) {
31
31
  msg = green(terminalLink(`Documentation: ${url}`, url));
package/lib/constant.js CHANGED
@@ -1 +1,2 @@
1
+ /* eslint-disable import/prefer-default-export */
1
2
  export const BLOCKLET_COMMAND = 'blocklet';
package/lib/did.js CHANGED
@@ -18,7 +18,7 @@ export function toDidIcon(did, size = 200, isPng = false) {
18
18
  return isPng ? jdenticon.toPng(did, size) : jdenticon.toSvg(did, size);
19
19
  }
20
20
 
21
- export async function getBlockletDidList(monikerList = [], connectUrl) {
21
+ export async function getBlockletDidList(monikerList = [], connectUrl = '') {
22
22
  try {
23
23
  let command = `${BLOCKLET_COMMAND} init`;
24
24
  if (monikerList.length > 0) {
@@ -28,6 +28,7 @@ export async function getBlockletDidList(monikerList = [], connectUrl) {
28
28
  }
29
29
 
30
30
  if (connectUrl) {
31
+ // eslint-disable-next-line no-unused-vars
31
32
  command += ` --connectUrl=${connectUrl}`;
32
33
  }
33
34
  const runCommand = new Promise((resolve, reject) => {
package/lib/git.js CHANGED
@@ -4,15 +4,6 @@ const { yellow } = chalk;
4
4
 
5
5
  $.verbose = false;
6
6
 
7
- async function canInitGit() {
8
- const isInstalled = await isGitInstalled();
9
- const gitInfo = await getUserInfo();
10
- if (isInstalled && gitInfo.name && gitInfo.email) {
11
- return true;
12
- }
13
- return false;
14
- }
15
-
16
7
  export async function isGitInstalled() {
17
8
  try {
18
9
  await which('git');
@@ -22,18 +13,6 @@ export async function isGitInstalled() {
22
13
  }
23
14
  }
24
15
 
25
- export async function initGitRepo(root) {
26
- const canInstalled = await canInitGit();
27
- if (canInstalled) {
28
- await cd(root);
29
- await $`git init`;
30
- await $`git add .`;
31
- await $`git commit -m 'init'`;
32
- } else {
33
- console.warn(`${yellow('Git is not installed')}`);
34
- }
35
- }
36
-
37
16
  export async function getUserInfo() {
38
17
  try {
39
18
  const { stdout: name } = await $`git config user.name`;
@@ -46,3 +25,24 @@ export async function getUserInfo() {
46
25
  };
47
26
  }
48
27
  }
28
+
29
+ async function canInitGit() {
30
+ const isInstalled = await isGitInstalled();
31
+ const gitInfo = await getUserInfo();
32
+ if (isInstalled && gitInfo.name && gitInfo.email) {
33
+ return true;
34
+ }
35
+ return false;
36
+ }
37
+
38
+ export async function initGitRepo(root) {
39
+ const canInstalled = await canInitGit();
40
+ if (canInstalled) {
41
+ await cd(root);
42
+ await $`git init`;
43
+ await $`git add .`;
44
+ await $`git commit -m 'init'`;
45
+ } else {
46
+ console.warn(`${yellow('Git is not installed')}`);
47
+ }
48
+ }
package/lib/server.js CHANGED
@@ -4,7 +4,16 @@ import { BLOCKLET_COMMAND } from './constant.js';
4
4
 
5
5
  $.verbose = false;
6
6
 
7
- export async function trimServerOutputVersion(output = '', command) {
7
+ export async function getServerVersion() {
8
+ try {
9
+ const { stdout: output } = await $`${BLOCKLET_COMMAND} --version`;
10
+ return output.trim();
11
+ } catch (e) {
12
+ return '0.0.0';
13
+ }
14
+ }
15
+
16
+ export async function trimServerOutputVersion(output = '', command = '') {
8
17
  // 调用 blocklet 命令时,都会在第一行先打印一个 blocklet [command] [version] 的信息,需要把这个信息 trim 掉
9
18
  const version = await getServerVersion();
10
19
  if (command) {
@@ -23,15 +32,6 @@ export async function checkServerInstalled() {
23
32
  }
24
33
  }
25
34
 
26
- export async function getServerVersion() {
27
- try {
28
- const { stdout: output } = await $`${BLOCKLET_COMMAND} --version`;
29
- return output.trim();
30
- } catch (e) {
31
- return '0.0.0';
32
- }
33
- }
34
-
35
35
  export async function getServerStatus() {
36
36
  try {
37
37
  const { stdout: output } = await $`${BLOCKLET_COMMAND} server status`;
package/lib/utils.js CHANGED
@@ -6,6 +6,7 @@ $.verbose = false;
6
6
  export function copy(src, dest) {
7
7
  const stat = fs.statSync(src);
8
8
  if (stat.isDirectory()) {
9
+ // eslint-disable-next-line no-use-before-define
9
10
  copyDir(src, dest);
10
11
  } else {
11
12
  fs.copySync(src, dest);
@@ -56,7 +57,7 @@ export function emptyDir(dir) {
56
57
 
57
58
  export function fuzzyQuery(list = [], keyWord = '') {
58
59
  const arr = [];
59
- for (var i = 0; i < list.length; i++) {
60
+ for (let i = 0; i < list.length; i++) {
60
61
  if (keyWord.includes(list[i])) {
61
62
  arr.push(list[i]);
62
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.7.9",
3
+ "version": "0.8.1",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
@@ -23,31 +23,31 @@
23
23
  },
24
24
  "homepage": "https://github.com/blocklet/create-blocklet/tree/main#readme",
25
25
  "scripts": {
26
- "lint": "eslint .",
26
+ "lint": "eslint index.js lib test",
27
27
  "test": "NODE_ENV=development vitest",
28
28
  "test:ui": "vitest --ui",
29
29
  "test:run": "vitest run"
30
30
  },
31
31
  "dependencies": {
32
- "@arcblock/did": "^1.18.108",
33
- "@ocap/mcrypto": "^1.18.108",
34
- "@ocap/util": "^1.18.108",
35
- "boxen": "^6.2.1",
36
- "ejs": "^3.1.9",
37
- "envfile": "^6.22.0",
32
+ "@arcblock/did": "^1.18.124",
33
+ "@ocap/mcrypto": "^1.18.124",
34
+ "@ocap/util": "^1.18.124",
35
+ "boxen": "^7.1.1",
36
+ "ejs": "^3.1.10",
37
+ "envfile": "^7.1.0",
38
38
  "figlet": "^1.7.0",
39
39
  "gradient-string": "^2.0.2",
40
- "jdenticon": "^3.2.0",
41
- "ora": "^6.3.1",
40
+ "jdenticon": "^3.3.0",
41
+ "ora": "^8.0.1",
42
42
  "prompts": "^2.4.2",
43
- "semver": "^7.5.4",
43
+ "semver": "^7.6.2",
44
44
  "terminal-link": "^3.0.0",
45
- "zx": "7.2.3"
45
+ "zx": "^8.1.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@arcblock/eslint-config-base": "0.2.4",
49
- "eslint": "^8.56.0",
50
- "prettier": "^3.1.1",
51
- "vitest": "^1.1.0"
48
+ "@arcblock/eslint-config-base": "^0.3.2",
49
+ "eslint": "^8.57.0",
50
+ "prettier": "^3.3.2",
51
+ "vitest": "^1.6.0"
52
52
  }
53
53
  }
@@ -31,14 +31,14 @@ This blocklet is a dapp project, which means this is a full-stack application. I
31
31
 
32
32
  Blocklet needs blocklet server as a dependency. So you need to install it first.
33
33
  `npm install -g @blocklet/cli`
34
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution](https://developer.blocklet.io/docs/en/quick-start/blocklet-server#use-the-binary-distribution)
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
35
 
36
36
  2. Init blocklet server & start blocklet server
37
37
 
38
38
  Before starting an blocklet server, you need to init blocklet server.
39
39
  `blocklet server init --mode=debug`
40
40
  `blocklet server start`
41
- See details in [https://developer.blocklet.io/docs/en/quick-start/blocklet-server](https://developer.blocklet.io/docs/en/quick-start/blocklet-server)
41
+ See details in [https://www.arcblock.io/docs/blocklet-developer/getting-started](https://www.arcblock.io/docs/blocklet-developer/getting-started)
42
42
 
43
43
  3. Go to the project directory `cd [name]`
44
44
  4. Install dependencies: `npm install` or `yarn`
@@ -138,7 +138,7 @@ After developing a blocklet, you may need to bundle it. Use `npm run bundle` com
138
138
  ## Learn More
139
139
 
140
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://developer.blocklet.io/docs/en](https://developer.blocklet.io/docs/en)
141
+ - Full document of Blocklet Server & blocklet development: [https://www.arcblock.io/docs/blocklet-developer](https://www.arcblock.io/docs/blocklet-developer)
142
142
 
143
143
  ## License
144
144
 
@@ -25,9 +25,10 @@ const ensureAccountDeclared = async () => {
25
25
  (async () => {
26
26
  try {
27
27
  await ensureAccountDeclared();
28
+ logger.info(`${name} pre-start successfully`);
28
29
  process.exit(0);
29
30
  } catch (err) {
30
- logger.error(`${name} pre-start error`, err.message);
31
+ logger.error(`${name} pre-start error`, err);
31
32
  process.exit(1);
32
33
  }
33
34
  })();
@@ -1,22 +1,11 @@
1
1
  const express = require('express');
2
- const env = require('./libs/env');
3
2
 
4
3
  const app = express();
5
4
 
6
5
  const port = process.env.BLOCKLET_PORT || process.env.PORT || 3030;
7
6
 
8
7
  app.get('/', (req, res) => {
9
- res.send(`
10
- <div style="display:flex;flex-direction:column;align-items:center;padding:64px 0;">
11
- <h1 style="margin:64px 0;">
12
- <span style="display:inline-block;padding:8px 24px;background:#1dc1c7;color:#fff;">Blocklet</span>
13
- <span style="color:#777;">+ Express</span>
14
- </h1>
15
- <pre>
16
- ${JSON.stringify(env, null, 2)}
17
- </pre>
18
- </div>
19
- `);
8
+ res.send('Hello Blocklet!');
20
9
  });
21
10
 
22
11
  app.listen(port, () => {
@@ -13,7 +13,7 @@ author:
13
13
  repository:
14
14
  type: git
15
15
  url: 'git+https://github.com/blocklet/create-blocklet.git'
16
- specVersion: 1.1.1
16
+ specVersion: 1.2.8
17
17
  version: 0.1.0
18
18
  logo: logo.png
19
19
  files:
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "express",
2
+ "name": "template-express-api",
3
3
  "version": "0.1.0",
4
4
  "description": "",
5
5
  "main": "api/index.js",
@@ -8,13 +8,13 @@
8
8
  "lint:fix": "npm run lint -- --fix",
9
9
  "dev": "blocklet dev",
10
10
  "start": "NODE_ENV=development nodemon api/index.js -w api",
11
- "clean": "node scripts/build-clean.js",
12
- "bundle": "npm run clean && blocklet bundle --zip --create-release",
11
+ "clean": "node scripts/build-clean.mjs",
12
+ "bundle": "npm run clean && blocklet bundle --compact --create-release",
13
13
  "deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
14
14
  "upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
15
15
  "deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
16
16
  "dev:child": "blocklet dev --component --app-did=<%= did %>",
17
- "prepare": "husky install",
17
+ "prepare": "npx simple-git-hooks",
18
18
  "bump-version": "zx --quiet scripts/bump-version.mjs"
19
19
  },
20
20
  "lint-staged": {
@@ -31,20 +31,23 @@
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
33
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
34
- "@blocklet/sdk": "^1.16.20",
35
- "@ocap/client": "^1.18.108",
36
- "dotenv-flow": "^3.3.0",
37
- "express": "^4.18.2"
34
+ "@blocklet/sdk": "^1.16.28",
35
+ "@ocap/client": "^1.18.124",
36
+ "dotenv-flow": "^4.1.0",
37
+ "express": "^4.19.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@arcblock/eslint-config-base": "^0.2.4",
41
- "bumpp": "^8.2.1",
42
- "eslint": "^8.56.0",
43
- "husky": "^8.0.3",
44
- "lint-staged": "^12.5.0",
45
- "nodemon": "^3.0.2",
46
- "prettier": "^3.1.1",
47
- "rimraf": "^3.0.2",
48
- "zx": "^7.2.3"
40
+ "@arcblock/eslint-config-base": "^0.3.2",
41
+ "bumpp": "^9.4.1",
42
+ "eslint": "^8.57.0",
43
+ "lint-staged": "^15.2.7",
44
+ "nodemon": "^3.1.4",
45
+ "prettier": "^3.3.2",
46
+ "rimraf": "^5.0.7",
47
+ "simple-git-hooks": "^2.11.1",
48
+ "zx": "^8.1.3"
49
+ },
50
+ "simple-git-hooks": {
51
+ "pre-commit": "npx lint-staged"
49
52
  }
50
53
  }
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "express-api",
3
- "desc": { "en": "A server-side API application built on Express", "zh": "一个基于 Express 构建的服务端 API 应用" },
3
+ "desc": {
4
+ "en": "A server-side API application built on Express",
5
+ "zh": "一个基于 Express 构建的服务端 API 应用"
6
+ },
4
7
  "displayName": "Express API",
5
8
  "blockletType": "dapp",
6
9
  "composable": true,
7
10
  "framework": "Express",
8
11
  "languages": "JavaScript",
9
12
  "useCase": "Server Side Application",
10
- "author": "ZhangHan"
11
- }
13
+ "author": "Blocklet"
14
+ }