create-blocklet 0.3.4 → 0.3.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 (170) hide show
  1. package/README.md +14 -0
  2. package/common/.prettierrc +1 -1
  3. package/index.js +10 -5
  4. package/lib/git.js +21 -5
  5. package/lib/index.js +8 -3
  6. package/lib/npm.js +1 -1
  7. package/lib/server.js +23 -11
  8. package/package.json +8 -10
  9. package/{template-static/blocklet-page → templates/blocklet-page-static}/README.md +0 -0
  10. package/{template-static/blocklet-page → templates/blocklet-page-static}/blocklet.md +0 -0
  11. package/{template-static/blocklet-page → templates/blocklet-page-static}/blocklet.yml +0 -0
  12. package/{template-static/blocklet-page → templates/blocklet-page-static}/package.json +1 -1
  13. package/{template-static/blocklet-page → templates/blocklet-page-static}/site/blocks/CustomBlock.mdx +0 -0
  14. package/{template-static/blocklet-page → templates/blocklet-page-static}/site/composes/MyLayout.mdx +0 -0
  15. package/{template-static/blocklet-page → templates/blocklet-page-static}/site/pages/index.mdx +0 -0
  16. package/{template-static/blocklet-page → templates/blocklet-page-static}/xmark.yml +0 -0
  17. package/{template-api/express → templates/express-api}/README.md +0 -0
  18. package/{template-api/express → templates/express-api}/api/hooks/pre-start.js +0 -0
  19. package/{template-api/express → templates/express-api}/api/index.js +0 -0
  20. package/{template-api/express → templates/express-api}/api/libs/auth.js +0 -0
  21. package/{template-api/express → templates/express-api}/api/libs/env.js +0 -0
  22. package/{template-api/express → templates/express-api}/api/libs/logger.js +0 -0
  23. package/{template-api/express → templates/express-api}/blocklet.md +0 -0
  24. package/{template-api/express → templates/express-api}/blocklet.yml +0 -0
  25. package/{template-api/express → templates/express-api}/package.json +0 -0
  26. package/{template-api/express → templates/express-api}/screenshots/.gitkeep +0 -0
  27. package/{template-dapp/nextjs → templates/nextjs-dapp}/.eslintrc.js +0 -0
  28. package/{template-dapp/nextjs → templates/nextjs-dapp}/README.md +0 -0
  29. package/{template-dapp/nextjs → templates/nextjs-dapp}/api/hooks/pre-start.js +0 -0
  30. package/{template-dapp/nextjs → templates/nextjs-dapp}/api/index.js +0 -0
  31. package/{template-dapp/nextjs → templates/nextjs-dapp}/api/libs/auth.js +0 -0
  32. package/{template-dapp/nextjs → templates/nextjs-dapp}/api/libs/env.js +0 -0
  33. package/{template-dapp/nextjs → templates/nextjs-dapp}/api/libs/logger.js +0 -0
  34. package/{template-dapp/nextjs → templates/nextjs-dapp}/api/routes/index.js +0 -0
  35. package/{template-dapp/nextjs → templates/nextjs-dapp}/blocklet.md +0 -0
  36. package/{template-dapp/nextjs → templates/nextjs-dapp}/blocklet.yml +0 -0
  37. package/{template-dapp/nextjs → templates/nextjs-dapp}/next.config.js +0 -0
  38. package/{template-dapp/nextjs → templates/nextjs-dapp}/package.json +5 -5
  39. package/{template-dapp/nextjs → templates/nextjs-dapp}/pages/_app.js +0 -0
  40. package/{template-dapp/nextjs → templates/nextjs-dapp}/pages/api/hello.js +0 -0
  41. package/{template-dapp/nextjs → templates/nextjs-dapp}/pages/index.js +0 -0
  42. package/{template-dapp/nextjs → templates/nextjs-dapp}/styles/Home.module.css +0 -0
  43. package/{template-dapp/nextjs → templates/nextjs-dapp}/styles/globals.css +0 -0
  44. package/{template-dapp/react → templates/react-dapp}/.env +0 -0
  45. package/{template-dapp/react → templates/react-dapp}/.env.local +0 -0
  46. package/{template-dapp/react → templates/react-dapp}/README.md +0 -0
  47. package/{template-dapp/react → templates/react-dapp}/api/hooks/pre-start.js +0 -0
  48. package/{template-dapp/react → templates/react-dapp}/api/index.js +0 -0
  49. package/{template-dapp/react → templates/react-dapp}/api/libs/auth.js +0 -0
  50. package/{template-dapp/react → templates/react-dapp}/api/libs/env.js +0 -0
  51. package/{template-dapp/react → templates/react-dapp}/api/libs/logger.js +0 -0
  52. package/{template-dapp/react → templates/react-dapp}/api/routes/index.js +0 -0
  53. package/{template-dapp/react → templates/react-dapp}/blocklet.md +0 -0
  54. package/{template-dapp/react → templates/react-dapp}/blocklet.yml +0 -0
  55. package/templates/react-dapp/craco.config.js +17 -0
  56. package/{template-dapp/react → templates/react-dapp}/package.json +8 -8
  57. package/{template-dapp/react → templates/react-dapp}/public/index.html +0 -0
  58. package/{template-static/react → templates/react-dapp}/src/app.css +5 -3
  59. package/{template-dapp/react → templates/react-dapp}/src/app.js +0 -0
  60. package/{template-dapp/react → templates/react-dapp}/src/index.js +0 -0
  61. package/{template-dapp/react → templates/react-dapp}/src/libs/api.js +0 -0
  62. package/{template-dapp/react → templates/react-dapp}/src/logo.svg +0 -0
  63. package/{template-dapp/react → templates/react-dapp}/src/pages/about.js +0 -0
  64. package/{template-dapp/react → templates/react-dapp}/src/pages/home.js +1 -1
  65. package/templates/react-gun-dapp/.env +3 -0
  66. package/templates/react-gun-dapp/README.md +153 -0
  67. package/{template-dapp/vue → templates/react-gun-dapp}/api/hooks/pre-start.js +0 -0
  68. package/templates/react-gun-dapp/api/index.js +65 -0
  69. package/{template-dapp/vue → templates/react-gun-dapp}/api/libs/auth.js +0 -0
  70. package/{template-dapp/vue → templates/react-gun-dapp}/api/libs/env.js +0 -0
  71. package/{template-dapp/vue → templates/react-gun-dapp}/api/libs/logger.js +0 -0
  72. package/{template-dapp/vue → templates/react-gun-dapp}/api/routes/index.js +0 -0
  73. package/{template-static/react → templates/react-gun-dapp}/blocklet.md +0 -0
  74. package/templates/react-gun-dapp/blocklet.yml +57 -0
  75. package/templates/react-gun-dapp/craco.config.js +30 -0
  76. package/templates/react-gun-dapp/package.json +81 -0
  77. package/{template-static/react → templates/react-gun-dapp}/public/index.html +0 -0
  78. package/templates/react-gun-dapp/src/app.css +41 -0
  79. package/{template-static/react → templates/react-gun-dapp}/src/app.js +0 -0
  80. package/{template-static/react → templates/react-gun-dapp}/src/index.js +0 -0
  81. package/{template-dapp/vue → templates/react-gun-dapp}/src/libs/api.js +0 -0
  82. package/templates/react-gun-dapp/src/logo.svg +1 -0
  83. package/templates/react-gun-dapp/src/pages/about.js +26 -0
  84. package/templates/react-gun-dapp/src/pages/home.js +61 -0
  85. package/{template-static/react → templates/react-static}/.env +0 -0
  86. package/{template-static/react → templates/react-static}/README.md +0 -0
  87. package/templates/react-static/blocklet.md +3 -0
  88. package/{template-static/react → templates/react-static}/blocklet.yml +0 -0
  89. package/templates/react-static/craco.config.js +11 -0
  90. package/{template-static/react → templates/react-static}/package.json +3 -2
  91. package/templates/react-static/public/index.html +35 -0
  92. package/{template-dapp/react → templates/react-static}/src/app.css +5 -3
  93. package/templates/react-static/src/app.js +32 -0
  94. package/templates/react-static/src/index.js +5 -0
  95. package/{template-static/react → templates/react-static}/src/logo.svg +0 -0
  96. package/{template-static/react → templates/react-static}/src/pages/about.js +0 -0
  97. package/{template-static/react → templates/react-static}/src/pages/home.js +4 -0
  98. package/{template-dapp/vue → templates/vue-dapp}/.browserslistrc +0 -0
  99. package/{template-dapp/vue → templates/vue-dapp}/.env +0 -0
  100. package/{template-dapp/vue → templates/vue-dapp}/.eslintrc.js +0 -0
  101. package/{template-dapp/vue → templates/vue-dapp}/README.md +0 -0
  102. package/{template-dapp/vue2 → templates/vue-dapp}/api/hooks/pre-start.js +0 -0
  103. package/{template-dapp/vue → templates/vue-dapp}/api/index.js +0 -0
  104. package/{template-dapp/vue2 → templates/vue-dapp}/api/libs/auth.js +0 -0
  105. package/{template-dapp/vue2 → templates/vue-dapp}/api/libs/env.js +0 -0
  106. package/{template-dapp/vue2 → templates/vue-dapp}/api/libs/logger.js +0 -0
  107. package/{template-dapp/vue2 → templates/vue-dapp}/api/routes/index.js +0 -0
  108. package/{template-dapp/vue → templates/vue-dapp}/blocklet.md +0 -0
  109. package/{template-dapp/vue → templates/vue-dapp}/blocklet.yml +0 -0
  110. package/{template-dapp/vue → templates/vue-dapp}/index.html +0 -0
  111. package/{template-dapp/vue → templates/vue-dapp}/package.json +7 -7
  112. package/{template-dapp/vue → templates/vue-dapp}/src/App.vue +0 -0
  113. package/{template-dapp/vue → templates/vue-dapp}/src/assets/logo.png +0 -0
  114. package/{template-dapp/vue → templates/vue-dapp}/src/components/HelloWorld.vue +0 -0
  115. package/{template-dapp/vue2 → templates/vue-dapp}/src/libs/api.js +0 -0
  116. package/{template-dapp/vue → templates/vue-dapp}/src/main.js +0 -0
  117. package/{template-dapp/vue → templates/vue-dapp}/vite.config.js +0 -0
  118. package/{template-dapp/vue2 → templates/vue-static}/.browserslistrc +0 -0
  119. package/{template-dapp/vue2 → templates/vue-static}/.env +0 -0
  120. package/{template-static/vue → templates/vue-static}/.eslintrc.js +0 -0
  121. package/{template-static/vue → templates/vue-static}/README.md +0 -0
  122. package/{template-static/vue → templates/vue-static}/blocklet.md +0 -0
  123. package/{template-static/vue → templates/vue-static}/blocklet.yml +0 -0
  124. package/{template-static/vue → templates/vue-static}/index.html +0 -0
  125. package/{template-static/vue → templates/vue-static}/package.json +1 -1
  126. package/{template-static/vue → templates/vue-static}/src/App.vue +0 -0
  127. package/{template-dapp/vue2 → templates/vue-static}/src/assets/logo.png +0 -0
  128. package/{template-static/vue → templates/vue-static}/src/components/HelloWorld.vue +0 -0
  129. package/{template-static/vue → templates/vue-static}/src/main.js +0 -0
  130. package/{template-static/vue → templates/vue-static}/vite.config.js +0 -0
  131. package/{template-static/vue → templates/vue2-dapp}/.browserslistrc +0 -0
  132. package/{template-static/vue → templates/vue2-dapp}/.env +0 -0
  133. package/{template-dapp/vue2 → templates/vue2-dapp}/.eslintrc.js +0 -0
  134. package/{template-dapp/vue2 → templates/vue2-dapp}/README.md +0 -0
  135. package/templates/vue2-dapp/api/hooks/pre-start.js +33 -0
  136. package/{template-dapp/vue2 → templates/vue2-dapp}/api/index.js +0 -0
  137. package/templates/vue2-dapp/api/libs/auth.js +22 -0
  138. package/templates/vue2-dapp/api/libs/env.js +6 -0
  139. package/templates/vue2-dapp/api/libs/logger.js +3 -0
  140. package/templates/vue2-dapp/api/routes/index.js +6 -0
  141. package/{template-dapp/vue2 → templates/vue2-dapp}/babel.config.js +0 -0
  142. package/{template-dapp/vue2 → templates/vue2-dapp}/blocklet.md +0 -0
  143. package/{template-dapp/vue2 → templates/vue2-dapp}/blocklet.yml +1 -0
  144. package/{template-dapp/vue2 → templates/vue2-dapp}/jsconfig.json +0 -0
  145. package/{template-dapp/vue2 → templates/vue2-dapp}/package.json +6 -6
  146. package/{template-dapp/vue2 → templates/vue2-dapp}/public/index.html +0 -0
  147. package/{template-dapp/vue2 → templates/vue2-dapp}/src/App.vue +0 -0
  148. package/{template-static/vue → templates/vue2-dapp}/src/assets/logo.png +0 -0
  149. package/{template-dapp/vue2 → templates/vue2-dapp}/src/components/HelloWorld.vue +0 -0
  150. package/templates/vue2-dapp/src/libs/api.js +14 -0
  151. package/{template-dapp/vue2 → templates/vue2-dapp}/src/main.js +0 -0
  152. package/templates/vue2-dapp/vue.config.js +18 -0
  153. package/{template-static/vue2 → templates/vue2-static}/.browserslistrc +0 -0
  154. package/{template-static/vue2 → templates/vue2-static}/.env +0 -0
  155. package/{template-static/vue2 → templates/vue2-static}/.eslintrc.js +0 -0
  156. package/{template-static/vue2 → templates/vue2-static}/README.md +0 -0
  157. package/{template-static/vue2 → templates/vue2-static}/babel.config.js +0 -0
  158. package/{template-static/vue2 → templates/vue2-static}/blocklet.md +0 -0
  159. package/{template-static/vue2 → templates/vue2-static}/blocklet.yml +0 -0
  160. package/{template-static/vue2 → templates/vue2-static}/jsconfig.json +0 -0
  161. package/{template-static/vue2 → templates/vue2-static}/package.json +0 -0
  162. package/{template-static/vue2 → templates/vue2-static}/public/index.html +0 -0
  163. package/{template-static/vue2 → templates/vue2-static}/src/App.vue +0 -0
  164. package/{template-static/vue2 → templates/vue2-static}/src/assets/logo.png +0 -0
  165. package/{template-static/vue2 → templates/vue2-static}/src/components/HelloWorld.vue +0 -0
  166. package/{template-static/vue2 → templates/vue2-static}/src/main.js +0 -0
  167. package/templates/vue2-static/vue.config.js +13 -0
  168. package/template-dapp/react/src/setupProxy.js +0 -12
  169. package/template-dapp/vue2/vue.config.js +0 -10
  170. package/template-static/vue2/vue.config.js +0 -3
package/README.md CHANGED
@@ -36,6 +36,8 @@ Currently supported template presets include:
36
36
  - `react`
37
37
  - `vue3 + vite`
38
38
  - `vue2 + @vue/cli`
39
+ - `next.js`
40
+ - `react + gunjs`
39
41
 
40
42
  **static**
41
43
 
@@ -44,6 +46,9 @@ Currently supported template presets include:
44
46
  - `vue2 + @vue/cli`
45
47
  - `blocklet page`
46
48
 
49
+ **api**
50
+ - `express`
51
+
47
52
  ## Community Templates
48
53
 
49
54
  create-blocklet is a tool to quickly start a blocklet from a basic template for popular frameworks. You can use a tool like [degit](https://github.com/Rich-Harris/degit) to scaffold your blocklet with github repository template.
@@ -61,3 +66,12 @@ If the blocklet uses `main` as the default branch, suffix the blocklet repo with
61
66
  ```bash
62
67
  npx degit user/blocklet#main my-blocklet
63
68
  ```
69
+
70
+ ## Development
71
+ Use `node /pathToCreateBlockletRepo/index.js` to create a blocklet, or you can use
72
+ ``` bash
73
+ ln -s /pathToCreateBlockletRepo/index.js /usr/local/bin/cb
74
+
75
+ cb
76
+ ```
77
+ to create a blocklet
@@ -3,7 +3,7 @@
3
3
  "useTabs": false,
4
4
  "tabWidth": 2,
5
5
  "trailingComma": "es5",
6
- "jsxBracketSameLine": true,
6
+ "bracketSameLine": true,
7
7
  "semi": true,
8
8
  "singleQuote": true
9
9
  }
package/index.js CHANGED
@@ -15,7 +15,7 @@ import { checkServerInstalled, checkServerRunning, checkSatisfiedVersion, getSer
15
15
  import { toBlockletDid } from './lib/did.js';
16
16
  import { initGitRepo } from './lib/git.js';
17
17
 
18
- const { yellow, red, green, cyan, blue, bold, dim } = chalk;
18
+ const { yellow, red, green, cyan, blue, bold } = chalk;
19
19
 
20
20
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
21
21
 
@@ -46,6 +46,11 @@ const TYPES = [
46
46
  display: 'next.js',
47
47
  color: blue,
48
48
  },
49
+ {
50
+ name: 'react-gun',
51
+ display: 'react + gunjs',
52
+ color: blue,
53
+ },
49
54
  ],
50
55
  },
51
56
  {
@@ -229,15 +234,16 @@ async function init() {
229
234
 
230
235
  const scaffoldSpinner = ora('Creating project...').start();
231
236
 
232
- const templateDir = path.join(__dirname, `template-${type}/${framework}`);
237
+ const templateDir = path.join(__dirname, `templates/${framework}-${type}`);
233
238
  const name = packageName || targetDir;
234
239
 
240
+ // TODO: 需要把 common file copy 的逻辑移除,不同的 template 之间的差异越来越多,就会需要越来越多特殊处理的代码,违背了初衷,移除这部分逻辑可能是更好的选择
235
241
  // copy common files
236
242
  (() => {
237
243
  const commonDir = path.join(__dirname, 'common');
238
244
  const commonFiles = fs.readdirSync(commonDir);
239
245
  for (const file of commonFiles) {
240
- if (framework !== 'react' && file === '_eslintrc.js') {
246
+ if (!['react', 'react-gun'].includes(framework) && file === '_eslintrc.js') {
241
247
  // eslint-disable-next-line no-continue
242
248
  continue;
243
249
  }
@@ -417,11 +423,10 @@ async function init() {
417
423
  }
418
424
 
419
425
  if (!hasStart) {
420
- console.log(dim('\n start it later by:\n'));
426
+ // console.log(dim('\n start it later by:\n'));
421
427
  if (root !== cwd) console.log(blue(` cd ${bold(related)}`));
422
428
 
423
429
  console.log(blue(` ${defaultAgent === 'yarn' ? 'yarn' : `${defaultAgent} install`}`));
424
- console.log(blue(` ${defaultAgent === 'yarn' ? 'yarn dev' : `${defaultAgent} run dev`}`));
425
430
  console.log(cyan('blocklet dev'));
426
431
  console.log('\n', `Find more usage in ${green('README.md')}`, '\n');
427
432
  }
package/lib/git.js CHANGED
@@ -1,7 +1,18 @@
1
- import { $, which, cd } from 'zx';
1
+ import { $, which, cd, chalk } from 'zx';
2
+
3
+ const { yellow } = chalk;
2
4
 
3
5
  $.verbose = false;
4
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
+
5
16
  export async function isGitInstalled() {
6
17
  try {
7
18
  await which('git');
@@ -12,10 +23,15 @@ export async function isGitInstalled() {
12
23
  }
13
24
 
14
25
  export async function initGitRepo(root) {
15
- await cd(root);
16
- await $`git init`;
17
- await $`git add .`;
18
- await $`git commit -m 'init'`;
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
+ }
19
35
  }
20
36
 
21
37
  export async function getUserInfo() {
package/lib/index.js CHANGED
@@ -11,9 +11,14 @@ export async function getOutput(cmd) {
11
11
  }
12
12
 
13
13
  export async function getUser() {
14
+ function purifyString(str) {
15
+ return [undefined, 'undefined', null, 'null'].includes(str) ? '' : str;
16
+ }
17
+
14
18
  const [npmAuthor, gitUser, serverUser] = await Promise.all([getAuthor(), getUserInfo(), getServerUserInfo()]);
15
- return {
16
- name: serverUser.name || npmAuthor.name || gitUser.name || '',
17
- email: serverUser.email || npmAuthor.email || gitUser.email || '',
19
+ const info = {
20
+ name: purifyString(serverUser.name) || purifyString(npmAuthor.name) || purifyString(gitUser.name) || '',
21
+ email: purifyString(serverUser.email) || purifyString(npmAuthor.email) || purifyString(gitUser.email) || '',
18
22
  };
23
+ return info;
19
24
  }
package/lib/npm.js CHANGED
@@ -8,7 +8,7 @@ export async function getAuthor() {
8
8
  const { stdout: name } = await $`npm config get init.author.name`;
9
9
  const { stdout: email } = await $`npm config get init.author.email`;
10
10
 
11
- return { name: name.trim(), email: email.trim() };
11
+ return { name: name?.trim(), email: email?.trim() };
12
12
  } catch {
13
13
  return {
14
14
  name: '',
package/lib/server.js CHANGED
@@ -3,6 +3,10 @@ import semver from 'semver';
3
3
 
4
4
  $.verbose = false;
5
5
 
6
+ function trimServerOutputVersion(output = '') {
7
+ return output?.replace(/blocklet \S+ v\d+\.\d+\.\d\n+/g, '');
8
+ }
9
+
6
10
  export async function checkServerInstalled() {
7
11
  try {
8
12
  await which('blocklet');
@@ -13,8 +17,12 @@ export async function checkServerInstalled() {
13
17
  }
14
18
 
15
19
  export async function getServerVersion() {
16
- const { stdout: output } = await $`blocklet --version`;
17
- return output.trim();
20
+ try {
21
+ const { stdout: output } = await $`blocklet --version`;
22
+ return output.trim();
23
+ } catch (e) {
24
+ return '0.0.0';
25
+ }
18
26
  }
19
27
 
20
28
  export async function getServerStatus() {
@@ -38,25 +46,29 @@ export async function checkSatisfiedVersion() {
38
46
  }
39
47
 
40
48
  export async function getServerDirectory() {
41
- const { stdout: output } = await $`blocklet server status`;
42
- const [matchStr] = output.match(/Blocklet Server Data Directory:[\s\S]*?\n/gm) || [];
43
- if (!matchStr) return null;
49
+ try {
50
+ const { stdout: output } = await $`blocklet server status`;
51
+ const [matchStr] = output.match(/Blocklet Server Data Directory:[\s\S]*?\n/gm) || [];
52
+ if (!matchStr) return null;
44
53
 
45
- const directory = matchStr.replace(/Blocklet Server Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
46
- return directory;
54
+ const directory = matchStr.replace(/Blocklet Server Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
55
+ return directory;
56
+ } catch {
57
+ return null;
58
+ }
47
59
  }
48
60
 
49
61
  export async function getUserInfo() {
50
62
  try {
51
- const { stdout: user } = await $`blocklet config get user`;
63
+ const { stdout: name } = await $`blocklet config get name`;
52
64
  const { stdout: email } = await $`blocklet config get email`;
53
65
  return {
54
- user: user?.trim(),
55
- email: email?.trim(),
66
+ name: trimServerOutputVersion(name?.trim()),
67
+ email: trimServerOutputVersion(email?.trim()),
56
68
  };
57
69
  } catch {
58
70
  return {
59
- user: '',
71
+ name: '',
60
72
  email: '',
61
73
  };
62
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.3.4",
3
+ "version": "0.3.7",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
@@ -13,9 +13,7 @@
13
13
  "index.js",
14
14
  "common",
15
15
  "lib",
16
- "template-api",
17
- "template-dapp",
18
- "template-static"
16
+ "templates"
19
17
  ],
20
18
  "engines": {
21
19
  "node": ">=16.0.0"
@@ -31,9 +29,9 @@
31
29
  "test:run": "vitest run"
32
30
  },
33
31
  "dependencies": {
34
- "@arcblock/did": "^1.14.25",
35
- "@ocap/mcrypto": "^1.14.25",
36
- "@ocap/util": "^1.14.25",
32
+ "@arcblock/did": "^1.16.0",
33
+ "@ocap/mcrypto": "^1.16.0",
34
+ "@ocap/util": "^1.16.0",
37
35
  "boxen": "^6.2.1",
38
36
  "ejs": "^3.1.6",
39
37
  "envfile": "^6.17.0",
@@ -42,9 +40,9 @@
42
40
  "jdenticon": "^3.1.1",
43
41
  "ora": "^6.1.0",
44
42
  "prompts": "^2.4.2",
45
- "semver": "^7.3.5",
43
+ "semver": "^7.3.6",
46
44
  "terminal-link": "^3.0.0",
47
- "zx": "^6.0.6"
45
+ "zx": "^6.0.7"
48
46
  },
49
47
  "devDependencies": {
50
48
  "@arcblock/eslint-config": "0.1.8",
@@ -59,6 +57,6 @@
59
57
  "eslint-plugin-react-hooks": "^4.2.0",
60
58
  "eslint-plugin-unicorn": "^34.0.1",
61
59
  "prettier": "^2.3.2",
62
- "vitest": "^0.7.6"
60
+ "vitest": "^0.9.0"
63
61
  }
64
62
  }
@@ -11,6 +11,6 @@
11
11
  "upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json"
12
12
  },
13
13
  "dependencies": {
14
- "@xmark/cli": "^2.0.28"
14
+ "@xmark/cli": "^2.0.31"
15
15
  }
16
16
  }
@@ -25,12 +25,12 @@
25
25
  ]
26
26
  },
27
27
  "dependencies": {
28
- "@arcblock/did-auth": "^1.15.2",
28
+ "@arcblock/did-auth": "^1.16.0",
29
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",
30
+ "@blocklet/sdk": "^1.7.6",
31
+ "@ocap/client": "^1.16.0",
32
+ "@ocap/mcrypto": "^1.16.0",
33
+ "@ocap/wallet": "^1.16.0",
34
34
  "dotenv-flow": "^3.2.0",
35
35
  "express": "^4.17.3",
36
36
  "next": "12.1.0",
@@ -0,0 +1,17 @@
1
+ const port = process.env.BLOCKLET_PORT || process.env.PORT || 8080;
2
+ const dappPort = process.env.APP_PORT || 3030;
3
+
4
+ module.exports = {
5
+ devServer: {
6
+ port,
7
+ client: {
8
+ // If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
9
+ webSocketURL: 'wss://0.0.0.0/ws',
10
+ },
11
+ proxy: {
12
+ '/api': {
13
+ target: `http://127.0.0.1:${dappPort}`,
14
+ },
15
+ },
16
+ },
17
+ };
@@ -2,8 +2,8 @@
2
2
  "name": "template-react",
3
3
  "version": "0.1.0",
4
4
  "scripts": {
5
- "dev": "react-scripts start",
6
- "build": "react-scripts build",
5
+ "dev": "craco start",
6
+ "build": "craco build",
7
7
  "eject": "react-scripts eject",
8
8
  "lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
9
9
  "start": "npm-run-all --parallel start:*",
@@ -39,12 +39,13 @@
39
39
  ]
40
40
  },
41
41
  "dependencies": {
42
- "@arcblock/did-auth": "^1.15.2",
42
+ "@arcblock/did-auth": "^1.16.0",
43
43
  "@arcblock/did-auth-storage-nedb": "^1.6.3",
44
- "@blocklet/sdk": "^1.7.0",
45
- "@ocap/client": "^1.15.2",
46
- "@ocap/mcrypto": "^1.15.2",
47
- "@ocap/wallet": "^1.15.2",
44
+ "@blocklet/sdk": "^1.7.6",
45
+ "@craco/craco": "^6.4.3",
46
+ "@ocap/client": "^1.16.0",
47
+ "@ocap/mcrypto": "^1.16.0",
48
+ "@ocap/wallet": "^1.16.0",
48
49
  "axios": "^0.26.1",
49
50
  "compression": "^1.7.4",
50
51
  "cookie-parser": "^1.4.6",
@@ -70,7 +71,6 @@
70
71
  "eslint-plugin-react": "^7.24.0",
71
72
  "eslint-plugin-react-hooks": "^4.2.0",
72
73
  "eslint-plugin-unicorn": "^34.0.1",
73
- "http-proxy-middleware": "^2.0.4",
74
74
  "husky": "^7.0.4",
75
75
  "lint-staged": "^12.3.7",
76
76
  "nodemon": "^2.0.15",
@@ -8,19 +8,21 @@ body {
8
8
  }
9
9
 
10
10
  .app-logo {
11
- height: 40vmin;
11
+ height: 10vmin;
12
12
  pointer-events: none;
13
13
  }
14
14
 
15
15
  .app-header {
16
- background-color: #282c34;
17
16
  min-height: 100vh;
18
17
  display: flex;
19
18
  flex-direction: column;
20
19
  align-items: center;
21
20
  justify-content: center;
22
21
  font-size: calc(10px + 2vmin);
23
- color: white;
22
+ }
23
+
24
+ pre {
25
+ font-size: 0.75em;
24
26
  }
25
27
 
26
28
  .app-link {
@@ -8,7 +8,7 @@ const Home = () => {
8
8
  <header className="app-header">
9
9
  <img src={logo} className="app-logo" alt="logo" />
10
10
  <pre style={{ textAlign: 'left' }}>
11
- <code>{JSON.stringify(window.blocklet, null, 2)}</code>
11
+ <code>window.blocklet = {JSON.stringify(window.blocklet, null, 2)}</code>
12
12
  </pre>
13
13
  <Link className="app-link" to="/about">
14
14
  About
@@ -0,0 +1,3 @@
1
+ GENERATE_SOURCEMAP=false
2
+ APP_PORT=3030
3
+ REACT_APP_TITLE=''