create-blocklet 0.4.78 → 0.4.80

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 (282) hide show
  1. package/README.md +5 -1
  2. package/index.js +48 -61
  3. package/lib/utils.js +14 -5
  4. package/package.json +1 -1
  5. package/{common → templates/docsite}/.editorconfig +0 -0
  6. package/{common → templates/docsite}/.github/workflows/main.yml +0 -0
  7. package/{common → templates/docsite}/.github/workflows/pr-title.yml +0 -0
  8. package/{common → templates/docsite}/.github/workflows/version-check.yml +0 -0
  9. package/{common → templates/docsite}/.prettierrc +0 -0
  10. package/{common → templates/docsite}/LICENSE +0 -0
  11. package/{common → templates/docsite}/_gitignore +0 -0
  12. package/{common → templates/docsite}/_npmrc +0 -0
  13. package/{common → templates/docsite}/logo.png +0 -0
  14. package/templates/docsite/package.json +7 -3
  15. package/{common → templates/docsite}/public/favicon.ico +0 -0
  16. package/{common → templates/docsite}/public/robots.txt +0 -0
  17. package/{common → templates/docsite}/screenshots/.gitkeep +0 -0
  18. package/templates/docsite/scripts/build-clean.js +6 -0
  19. package/{common → templates/docsite}/scripts/bump-version.mjs +0 -0
  20. package/{common → templates/docsite}/version +0 -0
  21. package/templates/express-api/.editorconfig +23 -0
  22. package/templates/express-api/.github/workflows/main.yml +36 -0
  23. package/templates/express-api/.github/workflows/pr-title.yml +21 -0
  24. package/templates/express-api/.github/workflows/version-check.yml +20 -0
  25. package/{common → templates/express-api}/.husky/pre-commit +0 -0
  26. package/templates/express-api/.prettierrc +9 -0
  27. package/templates/express-api/LICENSE +13 -0
  28. package/templates/express-api/_gitignore +28 -0
  29. package/templates/express-api/_npmrc +3 -0
  30. package/templates/express-api/logo.png +0 -0
  31. package/templates/express-api/package.json +7 -3
  32. package/templates/express-api/public/favicon.ico +0 -0
  33. package/templates/express-api/public/robots.txt +3 -0
  34. package/{common → templates/express-api}/scripts/build-clean.js +0 -0
  35. package/templates/express-api/scripts/bump-version.mjs +33 -0
  36. package/templates/express-api/version +1 -0
  37. package/templates/html-static/.editorconfig +23 -0
  38. package/templates/html-static/.github/workflows/main.yml +36 -0
  39. package/templates/html-static/.github/workflows/pr-title.yml +21 -0
  40. package/templates/html-static/.github/workflows/version-check.yml +20 -0
  41. package/templates/html-static/.prettierrc +9 -0
  42. package/templates/html-static/LICENSE +13 -0
  43. package/templates/html-static/_gitignore +28 -0
  44. package/templates/html-static/_npmrc +3 -0
  45. package/templates/html-static/logo.png +0 -0
  46. package/templates/html-static/package.json +9 -3
  47. package/templates/html-static/public/favicon.ico +0 -0
  48. package/templates/html-static/public/robots.txt +3 -0
  49. package/templates/html-static/screenshots/.gitkeep +0 -0
  50. package/templates/html-static/scripts/build-clean.js +5 -0
  51. package/templates/html-static/scripts/bump-version.mjs +33 -0
  52. package/templates/html-static/version +1 -0
  53. package/templates/monorepo/README.md +1 -1
  54. package/templates/monorepo/package.json +1 -0
  55. package/templates/monorepo/scripts/bump-version.mjs +10 -5
  56. package/templates/nextjs-dapp/.editorconfig +23 -0
  57. package/templates/nextjs-dapp/.github/workflows/main.yml +36 -0
  58. package/templates/nextjs-dapp/.github/workflows/pr-title.yml +21 -0
  59. package/templates/nextjs-dapp/.github/workflows/version-check.yml +20 -0
  60. package/templates/nextjs-dapp/.husky/pre-commit +4 -0
  61. package/templates/nextjs-dapp/.prettierrc +9 -0
  62. package/templates/nextjs-dapp/LICENSE +13 -0
  63. package/templates/nextjs-dapp/_gitignore +28 -0
  64. package/templates/nextjs-dapp/_npmrc +3 -0
  65. package/templates/nextjs-dapp/logo.png +0 -0
  66. package/templates/nextjs-dapp/package.json +7 -3
  67. package/templates/nextjs-dapp/public/favicon.ico +0 -0
  68. package/templates/nextjs-dapp/public/robots.txt +3 -0
  69. package/templates/nextjs-dapp/screenshots/.gitkeep +0 -0
  70. package/templates/nextjs-dapp/scripts/build-clean.js +5 -0
  71. package/templates/nextjs-dapp/scripts/bump-version.mjs +33 -0
  72. package/templates/nextjs-dapp/version +1 -0
  73. package/templates/react-dapp/.editorconfig +23 -0
  74. package/templates/react-dapp/.github/workflows/main.yml +36 -0
  75. package/templates/react-dapp/.github/workflows/pr-title.yml +21 -0
  76. package/templates/react-dapp/.github/workflows/version-check.yml +20 -0
  77. package/templates/react-dapp/.husky/pre-commit +4 -0
  78. package/templates/react-dapp/.prettierrc +9 -0
  79. package/templates/react-dapp/LICENSE +13 -0
  80. package/templates/react-dapp/_gitignore +28 -0
  81. package/templates/react-dapp/_npmrc +3 -0
  82. package/templates/react-dapp/logo.png +0 -0
  83. package/templates/react-dapp/package.json +1 -1
  84. package/templates/react-dapp/public/favicon.ico +0 -0
  85. package/templates/react-dapp/public/robots.txt +3 -0
  86. package/templates/react-dapp/screenshots/.gitkeep +0 -0
  87. package/templates/react-dapp/scripts/build-clean.js +5 -0
  88. package/templates/react-dapp/scripts/bump-version.mjs +33 -0
  89. package/templates/react-dapp/version +1 -0
  90. package/templates/react-gun-dapp/.editorconfig +23 -0
  91. package/templates/react-gun-dapp/.github/workflows/main.yml +36 -0
  92. package/templates/react-gun-dapp/.github/workflows/pr-title.yml +21 -0
  93. package/templates/react-gun-dapp/.github/workflows/version-check.yml +20 -0
  94. package/templates/react-gun-dapp/.husky/pre-commit +4 -0
  95. package/templates/react-gun-dapp/.prettierrc +9 -0
  96. package/templates/react-gun-dapp/LICENSE +13 -0
  97. package/templates/react-gun-dapp/_gitignore +28 -0
  98. package/templates/react-gun-dapp/_npmrc +3 -0
  99. package/templates/react-gun-dapp/logo.png +0 -0
  100. package/templates/react-gun-dapp/package.json +8 -4
  101. package/templates/react-gun-dapp/public/favicon.ico +0 -0
  102. package/templates/react-gun-dapp/public/robots.txt +3 -0
  103. package/templates/react-gun-dapp/screenshots/.gitkeep +0 -0
  104. package/templates/react-gun-dapp/scripts/build-clean.js +5 -0
  105. package/templates/react-gun-dapp/scripts/bump-version.mjs +33 -0
  106. package/templates/react-gun-dapp/version +1 -0
  107. package/templates/react-static/.editorconfig +23 -0
  108. package/templates/react-static/.github/workflows/main.yml +36 -0
  109. package/templates/react-static/.github/workflows/pr-title.yml +21 -0
  110. package/templates/react-static/.github/workflows/version-check.yml +20 -0
  111. package/templates/react-static/.husky/pre-commit +4 -0
  112. package/templates/react-static/.prettierrc +9 -0
  113. package/templates/react-static/LICENSE +13 -0
  114. package/templates/react-static/_gitignore +28 -0
  115. package/templates/react-static/_npmrc +3 -0
  116. package/templates/react-static/logo.png +0 -0
  117. package/templates/react-static/package.json +8 -4
  118. package/templates/react-static/public/favicon.ico +0 -0
  119. package/templates/react-static/public/robots.txt +3 -0
  120. package/templates/react-static/screenshots/.gitkeep +0 -0
  121. package/templates/react-static/scripts/build-clean.js +5 -0
  122. package/templates/react-static/scripts/bump-version.mjs +33 -0
  123. package/templates/react-static/version +1 -0
  124. package/templates/solidjs-dapp/.editorconfig +23 -0
  125. package/templates/solidjs-dapp/.github/workflows/main.yml +36 -0
  126. package/templates/solidjs-dapp/.github/workflows/pr-title.yml +21 -0
  127. package/templates/solidjs-dapp/.github/workflows/version-check.yml +20 -0
  128. package/templates/solidjs-dapp/.husky/pre-commit +4 -0
  129. package/templates/solidjs-dapp/.prettierrc +9 -0
  130. package/templates/solidjs-dapp/LICENSE +13 -0
  131. package/templates/solidjs-dapp/_gitignore +28 -0
  132. package/templates/solidjs-dapp/_npmrc +3 -0
  133. package/templates/solidjs-dapp/logo.png +0 -0
  134. package/templates/solidjs-dapp/package.json +8 -4
  135. package/templates/solidjs-dapp/public/favicon.ico +0 -0
  136. package/templates/solidjs-dapp/public/robots.txt +3 -0
  137. package/templates/solidjs-dapp/screenshots/.gitkeep +0 -0
  138. package/templates/solidjs-dapp/scripts/build-clean.js +5 -0
  139. package/templates/solidjs-dapp/scripts/bump-version.mjs +33 -0
  140. package/templates/solidjs-dapp/version +1 -0
  141. package/templates/solidjs-static/.editorconfig +23 -0
  142. package/templates/solidjs-static/.github/workflows/main.yml +36 -0
  143. package/templates/solidjs-static/.github/workflows/pr-title.yml +21 -0
  144. package/templates/solidjs-static/.github/workflows/version-check.yml +20 -0
  145. package/templates/solidjs-static/.husky/pre-commit +4 -0
  146. package/templates/solidjs-static/.prettierrc +9 -0
  147. package/templates/solidjs-static/LICENSE +13 -0
  148. package/templates/solidjs-static/_gitignore +28 -0
  149. package/templates/solidjs-static/_npmrc +3 -0
  150. package/templates/solidjs-static/logo.png +0 -0
  151. package/templates/solidjs-static/package.json +8 -4
  152. package/templates/solidjs-static/public/favicon.ico +0 -0
  153. package/templates/solidjs-static/public/robots.txt +3 -0
  154. package/templates/solidjs-static/screenshots/.gitkeep +0 -0
  155. package/templates/solidjs-static/scripts/build-clean.js +5 -0
  156. package/templates/solidjs-static/scripts/bump-version.mjs +33 -0
  157. package/templates/solidjs-static/version +1 -0
  158. package/templates/svelte-dapp/.editorconfig +23 -0
  159. package/templates/svelte-dapp/.github/workflows/main.yml +36 -0
  160. package/templates/svelte-dapp/.github/workflows/pr-title.yml +21 -0
  161. package/templates/svelte-dapp/.github/workflows/version-check.yml +20 -0
  162. package/templates/svelte-dapp/.husky/pre-commit +4 -0
  163. package/templates/svelte-dapp/.prettierrc +9 -0
  164. package/templates/svelte-dapp/LICENSE +13 -0
  165. package/templates/svelte-dapp/_gitignore +28 -0
  166. package/templates/svelte-dapp/_npmrc +3 -0
  167. package/templates/svelte-dapp/logo.png +0 -0
  168. package/templates/svelte-dapp/package.json +8 -4
  169. package/templates/svelte-dapp/public/favicon.ico +0 -0
  170. package/templates/svelte-dapp/public/robots.txt +3 -0
  171. package/templates/svelte-dapp/screenshots/.gitkeep +0 -0
  172. package/templates/svelte-dapp/scripts/build-clean.js +5 -0
  173. package/templates/svelte-dapp/scripts/bump-version.mjs +33 -0
  174. package/templates/svelte-dapp/version +1 -0
  175. package/templates/svelte-static/.editorconfig +23 -0
  176. package/templates/svelte-static/.github/workflows/main.yml +36 -0
  177. package/templates/svelte-static/.github/workflows/pr-title.yml +21 -0
  178. package/templates/svelte-static/.github/workflows/version-check.yml +20 -0
  179. package/templates/svelte-static/.husky/pre-commit +4 -0
  180. package/templates/svelte-static/.prettierrc +9 -0
  181. package/templates/svelte-static/LICENSE +13 -0
  182. package/templates/svelte-static/_gitignore +28 -0
  183. package/templates/svelte-static/_npmrc +3 -0
  184. package/templates/svelte-static/logo.png +0 -0
  185. package/templates/svelte-static/package.json +8 -4
  186. package/templates/svelte-static/public/favicon.ico +0 -0
  187. package/templates/svelte-static/public/robots.txt +3 -0
  188. package/templates/svelte-static/screenshots/.gitkeep +0 -0
  189. package/templates/svelte-static/scripts/build-clean.js +5 -0
  190. package/templates/svelte-static/scripts/bump-version.mjs +33 -0
  191. package/templates/svelte-static/version +1 -0
  192. package/templates/vue-dapp/.editorconfig +23 -0
  193. package/templates/vue-dapp/.github/workflows/main.yml +36 -0
  194. package/templates/vue-dapp/.github/workflows/pr-title.yml +21 -0
  195. package/templates/vue-dapp/.github/workflows/version-check.yml +20 -0
  196. package/templates/vue-dapp/.husky/pre-commit +4 -0
  197. package/templates/vue-dapp/.prettierrc +9 -0
  198. package/templates/vue-dapp/LICENSE +13 -0
  199. package/templates/vue-dapp/_gitignore +28 -0
  200. package/templates/vue-dapp/_npmrc +3 -0
  201. package/templates/vue-dapp/logo.png +0 -0
  202. package/templates/vue-dapp/package.json +7 -3
  203. package/templates/vue-dapp/public/favicon.ico +0 -0
  204. package/templates/vue-dapp/public/robots.txt +3 -0
  205. package/templates/vue-dapp/screenshots/.gitkeep +0 -0
  206. package/templates/vue-dapp/scripts/build-clean.js +5 -0
  207. package/templates/vue-dapp/scripts/bump-version.mjs +33 -0
  208. package/templates/vue-dapp/version +1 -0
  209. package/templates/vue-static/.editorconfig +23 -0
  210. package/templates/vue-static/.github/workflows/main.yml +36 -0
  211. package/templates/vue-static/.github/workflows/pr-title.yml +21 -0
  212. package/templates/vue-static/.github/workflows/version-check.yml +20 -0
  213. package/templates/vue-static/.husky/pre-commit +4 -0
  214. package/templates/vue-static/.prettierrc +9 -0
  215. package/templates/vue-static/LICENSE +13 -0
  216. package/templates/vue-static/_gitignore +28 -0
  217. package/templates/vue-static/_npmrc +3 -0
  218. package/templates/vue-static/logo.png +0 -0
  219. package/templates/vue-static/package.json +8 -4
  220. package/templates/vue-static/public/favicon.ico +0 -0
  221. package/templates/vue-static/public/robots.txt +3 -0
  222. package/templates/vue-static/screenshots/.gitkeep +0 -0
  223. package/templates/vue-static/scripts/build-clean.js +5 -0
  224. package/templates/vue-static/scripts/bump-version.mjs +33 -0
  225. package/templates/vue-static/version +1 -0
  226. package/templates/vue2-dapp/.editorconfig +23 -0
  227. package/templates/vue2-dapp/.github/workflows/main.yml +36 -0
  228. package/templates/vue2-dapp/.github/workflows/pr-title.yml +21 -0
  229. package/templates/vue2-dapp/.github/workflows/version-check.yml +20 -0
  230. package/templates/vue2-dapp/.husky/pre-commit +4 -0
  231. package/templates/vue2-dapp/.prettierrc +9 -0
  232. package/templates/vue2-dapp/LICENSE +13 -0
  233. package/templates/vue2-dapp/_gitignore +28 -0
  234. package/templates/vue2-dapp/_npmrc +3 -0
  235. package/templates/vue2-dapp/logo.png +0 -0
  236. package/templates/vue2-dapp/package.json +7 -3
  237. package/templates/vue2-dapp/public/favicon.ico +0 -0
  238. package/templates/vue2-dapp/public/robots.txt +3 -0
  239. package/templates/vue2-dapp/screenshots/.gitkeep +0 -0
  240. package/templates/vue2-dapp/scripts/build-clean.js +5 -0
  241. package/templates/vue2-dapp/scripts/bump-version.mjs +33 -0
  242. package/templates/vue2-dapp/version +1 -0
  243. package/templates/vue2-static/.editorconfig +23 -0
  244. package/templates/vue2-static/.github/workflows/main.yml +36 -0
  245. package/templates/vue2-static/.github/workflows/pr-title.yml +21 -0
  246. package/templates/vue2-static/.github/workflows/version-check.yml +20 -0
  247. package/templates/vue2-static/.husky/pre-commit +4 -0
  248. package/templates/vue2-static/.prettierrc +9 -0
  249. package/templates/vue2-static/LICENSE +13 -0
  250. package/templates/vue2-static/_gitignore +28 -0
  251. package/templates/vue2-static/_npmrc +3 -0
  252. package/templates/vue2-static/logo.png +0 -0
  253. package/templates/vue2-static/package.json +7 -3
  254. package/templates/vue2-static/public/favicon.ico +0 -0
  255. package/templates/vue2-static/public/robots.txt +3 -0
  256. package/templates/vue2-static/screenshots/.gitkeep +0 -0
  257. package/templates/vue2-static/scripts/build-clean.js +5 -0
  258. package/templates/vue2-static/scripts/bump-version.mjs +33 -0
  259. package/templates/vue2-static/version +1 -0
  260. package/templates/website/.editorconfig +23 -0
  261. package/templates/website/.github/workflows/main.yml +36 -0
  262. package/templates/website/.github/workflows/pr-title.yml +21 -0
  263. package/templates/website/.github/workflows/version-check.yml +20 -0
  264. package/templates/website/.prettierrc +9 -0
  265. package/templates/website/LICENSE +13 -0
  266. package/templates/website/_gitignore +28 -0
  267. package/templates/website/_npmrc +3 -0
  268. package/templates/website/logo.png +0 -0
  269. package/templates/website/package.json +7 -3
  270. package/templates/website/public/favicon.ico +0 -0
  271. package/templates/website/public/robots.txt +3 -0
  272. package/templates/website/screenshots/.gitkeep +0 -0
  273. package/templates/website/scripts/build-clean.js +6 -0
  274. package/templates/website/scripts/bump-version.mjs +33 -0
  275. package/templates/website/version +1 -0
  276. package/common/.makefiles/bump_blocklet_version.sh +0 -5
  277. package/common/.makefiles/bump_node_version.sh +0 -9
  278. package/common/.makefiles/bump_version.sh +0 -51
  279. package/common/.makefiles/release.mk +0 -31
  280. package/common/.vscode/settings.json +0 -5
  281. package/common/Makefile +0 -21
  282. package/templates/monorepo/Makefile +0 -22
package/README.md CHANGED
@@ -53,6 +53,7 @@ Currently supported template presets include:
53
53
  - `html`
54
54
 
55
55
  **api**
56
+
56
57
  - `express`
57
58
 
58
59
  ## Community Templates
@@ -74,12 +75,15 @@ npx degit user/blocklet#main my-blocklet
74
75
  ```
75
76
 
76
77
  ## Development
78
+
77
79
  Use `node /pathToCreateBlockletRepo/index.js` to create a blocklet, or you can use
78
- ``` bash
80
+
81
+ ```bash
79
82
  ln -s /pathToCreateBlockletRepo/index.js /usr/local/bin/cb
80
83
 
81
84
  cb
82
85
  ```
86
+
83
87
  to create a blocklet
84
88
 
85
89
  ## Docs
package/index.js CHANGED
@@ -121,6 +121,8 @@ const renameFiles = {
121
121
  _npmrc: '.npmrc',
122
122
  };
123
123
 
124
+ const excludeFiles = ['.github', '.husky', '.vscode', '.editorconfig', '_gitignore', '_npmrc', 'version']
125
+
124
126
  async function init() {
125
127
  const { version } = await fs.readJSONSync(path.resolve(__dirname, 'package.json'));
126
128
  await echoBrand({ version });
@@ -153,8 +155,7 @@ async function init() {
153
155
  type: () => (!fs.existsSync(targetDir) || isEmpty(targetDir) ? null : 'confirm'),
154
156
  name: 'overwrite',
155
157
  message: () =>
156
- `${
157
- targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`
158
+ `${targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`
158
159
  } is not empty. Remove existing files and continue?`,
159
160
  },
160
161
  {
@@ -176,39 +177,38 @@ async function init() {
176
177
  ...(inputTemplateName
177
178
  ? []
178
179
  : [
179
- {
180
- type: 'autocompleteMultiselect',
181
- name: 'templateNames',
182
- message: 'Choose one or more blocklet templates:',
183
- choices: templates.map((template) => {
184
- const templateColor = template.color;
180
+ {
181
+ type: 'autocompleteMultiselect',
182
+ name: 'templateNames',
183
+ message: 'Choose one or more blocklet templates:',
184
+ choices: templates.map((template) => {
185
+ const templateColor = template.color;
186
+ return {
187
+ title: templateColor(template.display),
188
+ value: template.name,
189
+ };
190
+ }),
191
+ min: 1,
192
+ suggest: (input, choices) => Promise.resolve(choices.filter((i) => i.title.includes(input))),
193
+ },
194
+ {
195
+ type: (templateNames = []) => {
196
+ return templateNames.length > 1 ? 'select' : null;
197
+ },
198
+ name: 'mainBlocklet',
199
+ message: 'Please choose the main blocklet',
200
+ //
201
+ choices: (templateNames = []) =>
202
+ templateNames.map((templateName) => {
203
+ const template = templates.find((x) => x.name === templateName);
185
204
  return {
186
- title: templateColor(template.display),
205
+ title: template.display,
187
206
  value: template.name,
188
207
  };
189
208
  }),
190
- min: 1,
191
- suggest: (input, choices) => Promise.resolve(choices.filter((i) => i.title.includes(input))),
192
- },
193
- // 这里需要添加一步 如果选择了 多项 就要提示用户设置主应用
194
- {
195
- type: (templateNames = []) => {
196
- return templateNames.length > 1 ? 'select' : null;
197
- },
198
- name: 'mainBlocklet',
199
- message: 'Please choose the main blocklet',
200
- //
201
- choices: (templateNames = []) =>
202
- templateNames.map((templateName) => {
203
- const template = templates.find((x) => x.name === templateName);
204
- return {
205
- title: template.display,
206
- value: template.name,
207
- };
208
- }),
209
- initial: 1,
210
- },
211
- ]),
209
+ initial: 1,
210
+ },
211
+ ]),
212
212
  {
213
213
  type: 'text',
214
214
  name: 'authorName',
@@ -267,17 +267,17 @@ async function init() {
267
267
  console.log(`\nScaffolding project in ${cyan(root)}`);
268
268
 
269
269
  const scaffoldSpinner = ora('Creating project...').start();
270
- // name 是用户输入的项目名称,当有
270
+ // name 是用户输入的项目名称
271
271
  const name = packageName || targetDir;
272
272
 
273
- // 如果选中了多个则说明时 monorepo 类型的模板
273
+ // 如果选中了多个则说明是 monorepo 类型的模板
274
274
  if (mainBlocklet) {
275
275
  await checkLerna();
276
276
  await checkYarn();
277
277
  const monorepoDir = path.join(__dirname, 'templates', 'monorepo');
278
278
  const monorepoFiles = fs.readdirSync(monorepoDir);
279
279
  for (const file of monorepoFiles) {
280
- const targetPath = path.join(root, renameFiles[file]||file);
280
+ const targetPath = path.join(root, renameFiles[file] || file);
281
281
  copy(path.join(monorepoDir, file), targetPath);
282
282
  }
283
283
  }
@@ -285,36 +285,20 @@ async function init() {
285
285
  for (const templateName of templateNames) {
286
286
  const templateDir = path.join(__dirname, `templates/${templateName}`);
287
287
  const finalTemplateName = `${name}-${templateName}`;
288
- // TODO: 需要把 common file copy 的逻辑移除,不同的 template 之间的差异越来越多,就会需要越来越多特殊处理的代码,违背了初衷,移除这部分逻辑可能是更好的选择
289
- // copy common files
290
- (() => {
291
- const commonDir = path.join(__dirname, 'common');
292
- const commonFiles = fs.readdirSync(commonDir);
293
- for (const file of commonFiles) {
294
- // 如果选择多个模板,每个子 package 中 只会包含必要的 文件
295
- if (mainBlocklet && !['screenshots', 'public', 'logo.png', '.prettierrc', 'LICENSE'].includes(file)) {
296
- continue;
297
- }
298
- // xmark 相关的模板不添加 .husky
299
- if (fuzzyQuery(['website', 'docsite'], templateName) && ['.husky'].includes(file)) {
300
- // eslint-disable-next-line no-continue
301
- continue;
302
- }
303
- const targetPath = renameFiles[file]
304
- ? path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', renameFiles[file])
305
- : path.join(root, mainBlocklet ? `blocklets/${templateName}` : '', file);
306
-
307
- copy(path.join(commonDir, file), targetPath);
308
- }
309
- })();
310
-
311
288
  // copy template files
312
289
  (() => {
313
290
  // 过滤掉 template-info.json 文件
314
- const files = fs.readdirSync(templateDir).filter((file) => file !== 'template-info.json');
291
+ let files = fs.readdirSync(templateDir).filter((file) => file !== 'template-info.json');
292
+ // 如果选择了多个模板,每个子 package 中应该过滤掉一些文件
293
+ if (mainBlocklet) {
294
+ files = files.filter((file) => !fuzzyQuery(excludeFiles, file));
295
+ }
315
296
  for (const file of files) {
316
297
  write(file, null, templateDir, templateName);
317
298
  }
299
+ if (mainBlocklet) {
300
+ fs.removeSync(path.join(root, `blocklets/${templateName}`, 'scripts/bump-version.mjs'))
301
+ }
318
302
  })();
319
303
 
320
304
  modifyPackage(
@@ -385,6 +369,9 @@ async function init() {
385
369
  } else if (templateName.includes('static')) {
386
370
  pkg.scripts.bundle = ejs.render(pkg.scripts.bundle, { did });
387
371
  }
372
+ if (mainBlocklet) {
373
+ delete pkg.scripts['bump-version'];
374
+ }
388
375
  // 如果用户选了多个模板,为其他应用配置好 dev:child 和 deploy:child
389
376
  if (mainBlocklet && templateName !== mainBlocklet) {
390
377
  const mainBlockletDid = toBlockletDid(`${name}-${mainBlocklet}`);
@@ -517,7 +504,7 @@ async function init() {
517
504
  // console.log(dim('\n start it later by:\n'));
518
505
  if (root !== cwd) console.log(blue(` cd ${bold(related)}`));
519
506
  if (mainBlocklet) {
520
- console.log(blue(`make init`));
507
+ console.log(blue(`npm run init`));
521
508
  } else {
522
509
  console.log(blue(`${defaultAgent === 'yarn' ? 'yarn' : `${defaultAgent} install`}`));
523
510
  console.log(cyan('blocklet dev'));
@@ -548,13 +535,13 @@ async function init() {
548
535
  return null;
549
536
  }
550
537
 
551
- function modifyPackage(modifyFn = () => {}, templateDir, templateName) {
538
+ function modifyPackage(modifyFn = () => { }, templateDir, templateName) {
552
539
  const pkg = JSON.parse(read('package.json', templateName));
553
540
  modifyFn(pkg);
554
541
  write('package.json', JSON.stringify(pkg, null, 2), templateDir, templateName);
555
542
  }
556
543
 
557
- function modifyBlockletYaml(modifyFn = () => {}, templateDir, templateName) {
544
+ function modifyBlockletYaml(modifyFn = () => { }, templateDir, templateName) {
558
545
  const blockletYaml = read('blocklet.yml', templateName);
559
546
  const yamlConfig = YAML.parse(blockletYaml);
560
547
  modifyFn(yamlConfig);
package/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { fs, path, $, echo, chalk } from 'zx';
1
+ import { fs, path, $, echo, chalk, which } from 'zx';
2
2
 
3
3
  $.verbose = false;
4
4
 
@@ -64,9 +64,18 @@ export function fuzzyQuery(list = [], keyWord = '') {
64
64
  return arr.length > 0;
65
65
  }
66
66
 
67
+ export async function checkCLIInstall(name) {
68
+ try {
69
+ await which(name);
70
+ return true;
71
+ } catch (e) {
72
+ return false;
73
+ }
74
+ }
75
+
67
76
  export async function checkLerna() {
68
- const checkResult = await $`type lerna >/dev/null 2>&1 || echo "false"`;
69
- if (checkResult.stdout.trim() === 'false') {
77
+ const learn = await checkCLIInstall('lerna');
78
+ if (!learn) {
70
79
  console.log(`\n ${chalk.cyan('install lerna...')}`);
71
80
  const output = await $`npm install -g lerna`;
72
81
  echo(output);
@@ -74,8 +83,8 @@ export async function checkLerna() {
74
83
  }
75
84
 
76
85
  export async function checkYarn() {
77
- const checkResult = await $`type yarn >/dev/null 2>&1 || echo "false"`;
78
- if (checkResult.stdout.trim() === 'false') {
86
+ const yarn = await checkCLIInstall('yarn');
87
+ if (!yarn) {
79
88
  console.log(`\n ${chalk.cyan('install yarn...')}`);
80
89
  const output = await $`npm install -g yarn`;
81
90
  echo(output);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-blocklet",
3
- "version": "0.4.78",
3
+ "version": "0.4.80",
4
4
  "exports": "./index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:blocklet/create-blocklet.git",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -5,16 +5,20 @@
5
5
  "scripts": {
6
6
  "dev": "blocklet dev",
7
7
  "start": "xmark start",
8
- "clean": "rm -rf .blocklet && rm -rf node_modules/.vite",
8
+ "clean": "node scripts/build-clean.js",
9
9
  "build": "xmark build",
10
10
  "bundle": "npm run clean && xmark build && blocklet bundle --zip --create-release",
11
11
  "deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
12
12
  "upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
13
13
  "deploy:child": "npm run bundle && blocklet deploy .blocklet/bundle --app-did=<%= did %>",
14
- "dev:child": "blocklet dev --component --app-did=<%= did %>"
14
+ "dev:child": "blocklet dev --component --app-did=<%= did %>",
15
+ "bump-version": "zx scripts/bump-version.mjs"
15
16
  },
16
17
  "dependencies": {
17
18
  "@xmark/cli": "^2.4.83",
18
- "@xmark/theme-docs": "^2.4.83"
19
+ "@xmark/theme-docs": "^2.4.83",
20
+ "zx": "^7.1.1",
21
+ "rimraf": "^3.0.2",
22
+ "bumpp": "^8.2.1"
19
23
  }
20
24
  }
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ const rimraf = require('rimraf');
2
+
3
+ console.log('clean .blocklet folder && node_modules/.vite');
4
+ rimraf.sync('.blocklet');
5
+ rimraf.sync('node_modules/.vite');
6
+ console.log('clean .blocklet folder && node_modules/.vite done!');
File without changes
@@ -0,0 +1,23 @@
1
+ # For more information about the properties used in
2
+ # this file, please see the EditorConfig documentation:
3
+ # http://editorconfig.org/
4
+ #
5
+ # Sensible EditorConfig defaults
6
+ # https://gist.github.com/matijs/662bf45dd4ec37b3a068
7
+ root = true
8
+
9
+ [*]
10
+ charset = utf-8
11
+ end_of_line = lf
12
+ indent_size = 2
13
+ indent_style = space
14
+ insert_final_newline = true
15
+ trim_trailing_whitespace = true
16
+
17
+ # Make sure package.json always uses 2 spaces to indent
18
+ [{package.json}]
19
+ indent_size = 2
20
+ indent_style = space
21
+
22
+ [{makefile, Makefile}]
23
+ indent_style = tab
@@ -0,0 +1,36 @@
1
+ name: Deploy
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ Deploy:
10
+ runs-on: ubuntu-latest
11
+
12
+ if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
13
+
14
+ steps:
15
+ - name: Checkout repo
16
+ uses: actions/checkout@v2
17
+
18
+ - name: Set yarn cache
19
+ uses: c-hive/gha-yarn-cache@v2
20
+
21
+ - name: Install dependencies
22
+ run: yarn
23
+
24
+ - name: Blocklet workflow
25
+ uses: blocklet/action-workflow@v1
26
+ with:
27
+ skip-upload: false
28
+ skip-deploy: false
29
+ bundle-command: yarn bundle
30
+ store-endpoint: ${{ secrets.STORE_ENDPOINT }}
31
+ store-access-token: ${{ secrets.STORE_ACCESS_TOKEN }}
32
+ server-endpoint: ${{ secrets.SERVER_ENDPOINT }}
33
+ server-access-key: ${{ secrets.SERVER_ACCESS_KEY }}
34
+ server-access-secret: ${{ secrets.SERVER_ACCESS_SECRET }}
35
+ slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
36
+ github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: 'Lint PR Title'
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - edited
9
+ - synchronize
10
+ branches:
11
+ - main
12
+ - dev
13
+ - master
14
+
15
+ jobs:
16
+ lint-title:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: ArcBlock/action-lint-pull-request-title@master
20
+ env:
21
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,20 @@
1
+ name: 'Version Check'
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - edited
9
+ - synchronize
10
+ branches:
11
+ - main
12
+ - master
13
+ jobs:
14
+ main:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: action-version-check
18
+ uses: arcblock/action-version-check@master
19
+ env:
20
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,9 @@
1
+ {
2
+ "printWidth": 120,
3
+ "useTabs": false,
4
+ "tabWidth": 2,
5
+ "trailingComma": "es5",
6
+ "bracketSameLine": true,
7
+ "semi": true,
8
+ "singleQuote": true
9
+ }
@@ -0,0 +1,13 @@
1
+ Copyright 2018-2020 ArcBlock
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,28 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ .pnp
5
+ .pnp.js
6
+ .DS_Store
7
+ node_modules
8
+
9
+ # testing
10
+ coverage
11
+
12
+ # production
13
+ build
14
+ dist
15
+ dist-ssr
16
+ .blocklet
17
+
18
+ # local env files
19
+ *.local
20
+
21
+ # Log files
22
+ logs
23
+ *.log
24
+ npm-debug.log*
25
+ yarn-debug.log*
26
+ yarn-error.log*
27
+ pnpm-debug.log*
28
+ lerna-debug.log*
@@ -0,0 +1,3 @@
1
+ ## force pnpm to hoist
2
+ shamefully-hoist=true
3
+ strict-peer-dependencies=false
Binary file
@@ -8,13 +8,14 @@
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": "rm -rf .blocklet",
11
+ "clean": "node scripts/build-clean.js",
12
12
  "bundle": "npm run clean && blocklet bundle --zip --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": "husky install",
18
+ "bump-version": "zx scripts/bump-version.mjs"
18
19
  },
19
20
  "lint-staged": {
20
21
  "*.{mjs,js,ts}": [
@@ -41,6 +42,9 @@
41
42
  "husky": "^8.0.1",
42
43
  "lint-staged": "^12.5.0",
43
44
  "nodemon": "^2.0.20",
44
- "prettier": "^2.7.1"
45
+ "prettier": "^2.7.1",
46
+ "zx": "^7.1.1",
47
+ "rimraf": "^3.0.2",
48
+ "bumpp": "^8.2.1"
45
49
  }
46
50
  }
@@ -0,0 +1,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
@@ -0,0 +1,33 @@
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
+
9
+ let newChangelog = '';
10
+
11
+ try {
12
+ const gitRes = await $`git log --pretty=format:"- %s" "master"...HEAD`;
13
+ newChangelog = gitRes.stdout.trim();
14
+ } catch {
15
+ console.error(chalk.redBright('Could not get git log, please write changelog manually.'));
16
+ }
17
+
18
+ const now = new Date();
19
+ const currentDate = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
20
+ const title = `## ${version} (${currentDate})`;
21
+
22
+ await fs.ensureFile('CHANGELOG.md');
23
+ const oldChangelog = await fs.readFile('CHANGELOG.md', 'utf8');
24
+ const changelog = [title, newChangelog, oldChangelog].filter((item) => !!item).join('\n\n');
25
+ await fs.writeFile('CHANGELOG.md', changelog);
26
+
27
+ console.log(`\nNow you can make adjustments to ${chalk.cyan('CHANGELOG.md')}. Then press enter to continue.`);
28
+
29
+ process.stdin.setRawMode(true);
30
+ process.stdin.resume();
31
+ process.stdin.on('data', process.exit.bind(process, 0));
32
+
33
+ await fs.writeFileSync('version', version);
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,23 @@
1
+ # For more information about the properties used in
2
+ # this file, please see the EditorConfig documentation:
3
+ # http://editorconfig.org/
4
+ #
5
+ # Sensible EditorConfig defaults
6
+ # https://gist.github.com/matijs/662bf45dd4ec37b3a068
7
+ root = true
8
+
9
+ [*]
10
+ charset = utf-8
11
+ end_of_line = lf
12
+ indent_size = 2
13
+ indent_style = space
14
+ insert_final_newline = true
15
+ trim_trailing_whitespace = true
16
+
17
+ # Make sure package.json always uses 2 spaces to indent
18
+ [{package.json}]
19
+ indent_size = 2
20
+ indent_style = space
21
+
22
+ [{makefile, Makefile}]
23
+ indent_style = tab
@@ -0,0 +1,36 @@
1
+ name: Deploy
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ Deploy:
10
+ runs-on: ubuntu-latest
11
+
12
+ if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
13
+
14
+ steps:
15
+ - name: Checkout repo
16
+ uses: actions/checkout@v2
17
+
18
+ - name: Set yarn cache
19
+ uses: c-hive/gha-yarn-cache@v2
20
+
21
+ - name: Install dependencies
22
+ run: yarn
23
+
24
+ - name: Blocklet workflow
25
+ uses: blocklet/action-workflow@v1
26
+ with:
27
+ skip-upload: false
28
+ skip-deploy: false
29
+ bundle-command: yarn bundle
30
+ store-endpoint: ${{ secrets.STORE_ENDPOINT }}
31
+ store-access-token: ${{ secrets.STORE_ACCESS_TOKEN }}
32
+ server-endpoint: ${{ secrets.SERVER_ENDPOINT }}
33
+ server-access-key: ${{ secrets.SERVER_ACCESS_KEY }}
34
+ server-access-secret: ${{ secrets.SERVER_ACCESS_SECRET }}
35
+ slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
36
+ github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: 'Lint PR Title'
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - edited
9
+ - synchronize
10
+ branches:
11
+ - main
12
+ - dev
13
+ - master
14
+
15
+ jobs:
16
+ lint-title:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: ArcBlock/action-lint-pull-request-title@master
20
+ env:
21
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}