@modern-js/main-doc 2.21.1 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (292) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/docs/en/apis/app/commands.mdx +5 -5
  3. package/docs/en/apis/app/hooks/api/api.mdx +80 -0
  4. package/docs/en/apis/app/hooks/api/app.mdx +12 -0
  5. package/docs/en/apis/app/hooks/api/lambda.mdx +57 -0
  6. package/docs/en/apis/app/hooks/api/test.mdx +1 -1
  7. package/docs/en/apis/app/hooks/config/html.mdx +2 -2
  8. package/docs/en/apis/app/hooks/config/icon.mdx +19 -19
  9. package/docs/en/apis/app/hooks/config/mock.mdx +1 -1
  10. package/docs/en/apis/app/hooks/config/public.mdx +10 -10
  11. package/docs/en/apis/app/hooks/config/storybook.mdx +3 -3
  12. package/docs/en/apis/app/hooks/config/upload.mdx +13 -13
  13. package/docs/en/apis/app/hooks/modern-config.mdx +4 -4
  14. package/docs/en/apis/app/hooks/server/index_.mdx +2 -9
  15. package/docs/en/apis/app/hooks/server/test.mdx +5 -2
  16. package/docs/en/apis/app/hooks/shared.mdx +1 -1
  17. package/docs/en/apis/app/hooks/src/app.mdx +17 -27
  18. package/docs/en/apis/app/hooks/src/index_.mdx +6 -6
  19. package/docs/en/apis/app/hooks/src/pages.mdx +41 -37
  20. package/docs/en/apis/app/hooks/src/routes.mdx +16 -36
  21. package/docs/en/apis/app/hooks/src/server.mdx +1 -1
  22. package/docs/en/apis/app/hooks/src/stories.mdx +6 -3
  23. package/docs/en/apis/app/hooks/src/test.mdx +4 -3
  24. package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +5 -1
  25. package/docs/en/apis/app/runtime/web-server/hook.mdx +2 -2
  26. package/docs/en/apis/app/runtime/web-server/middleware.mdx +2 -2
  27. package/docs/en/components/debug-app.mdx +1 -1
  28. package/docs/en/components/deploy.mdx +1 -0
  29. package/docs/en/components/entry-mode.mdx +0 -0
  30. package/docs/en/components/init-app.mdx +6 -10
  31. package/docs/en/components/init-rspack-app.mdx +4 -4
  32. package/docs/en/components/language-config.mdx +9 -0
  33. package/docs/en/components/package-manager.mdx +11 -0
  34. package/docs/en/components/release-note.mdx +1 -0
  35. package/docs/en/components/ua-polyfill.mdx +2 -2
  36. package/docs/en/configure/app/output/css-modules.mdx +13 -0
  37. package/docs/en/configure/app/source/config-dir.mdx +1 -1
  38. package/docs/en/configure/app/source/design-system.mdx +67 -67
  39. package/docs/en/configure/app/source/disable-default-entries.mdx +6 -5
  40. package/docs/en/configure/app/source/disable-entry-dirs.mdx +5 -5
  41. package/docs/en/configure/app/source/enable-async-entry.mdx +9 -9
  42. package/docs/en/configure/app/source/entries-dir.mdx +3 -3
  43. package/docs/en/configure/app/source/entries.mdx +21 -19
  44. package/docs/en/configure/app/tools/swc.mdx +2 -16
  45. package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -2
  46. package/docs/en/guides/advanced-features/bff/function.mdx +4 -4
  47. package/docs/en/guides/advanced-features/bff/type.mdx +5 -5
  48. package/docs/en/guides/advanced-features/rspack-start.mdx +7 -8
  49. package/docs/en/guides/advanced-features/ssg.mdx +2 -2
  50. package/docs/en/guides/advanced-features/testing.mdx +2 -2
  51. package/docs/en/guides/advanced-features/web-server.mdx +2 -2
  52. package/docs/en/guides/basic-features/css.mdx +2 -2
  53. package/docs/en/guides/basic-features/mock.mdx +1 -1
  54. package/docs/en/guides/basic-features/routes.mdx +11 -7
  55. package/docs/en/guides/concept/builder.mdx +15 -15
  56. package/docs/en/guides/concept/entries.mdx +50 -49
  57. package/docs/en/guides/get-started/glossary.mdx +12 -12
  58. package/docs/en/guides/get-started/introduction.mdx +17 -20
  59. package/docs/en/guides/get-started/quick-start.mdx +21 -37
  60. package/docs/en/guides/get-started/upgrade.mdx +15 -13
  61. package/docs/en/guides/topic-detail/changesets/_category_.json +4 -0
  62. package/docs/en/guides/topic-detail/changesets/add.mdx +125 -0
  63. package/docs/en/guides/topic-detail/changesets/changelog.mdx +238 -0
  64. package/docs/en/guides/topic-detail/changesets/commit.mdx +269 -0
  65. package/docs/en/guides/topic-detail/changesets/config.mdx +147 -0
  66. package/docs/en/guides/topic-detail/changesets/github.mdx +175 -0
  67. package/docs/en/guides/topic-detail/changesets/introduce.mdx +56 -0
  68. package/docs/en/guides/topic-detail/changesets/release-note.mdx +273 -0
  69. package/docs/en/guides/topic-detail/changesets/release-pre.mdx +49 -0
  70. package/docs/en/guides/topic-detail/changesets/release.mdx +229 -0
  71. package/docs/en/guides/topic-detail/generator/create/_category_.json +4 -0
  72. package/docs/en/guides/topic-detail/generator/create/config.mdx +75 -0
  73. package/docs/en/guides/topic-detail/generator/create/option.md +151 -0
  74. package/docs/en/guides/topic-detail/generator/create/use.mdx +66 -0
  75. package/docs/en/guides/topic-detail/generator/new/_category_.json +4 -0
  76. package/docs/en/guides/topic-detail/generator/new/config.md +155 -0
  77. package/docs/en/guides/topic-detail/generator/new/option.md +67 -0
  78. package/docs/en/guides/topic-detail/generator/new/use.md +95 -0
  79. package/docs/en/guides/topic-detail/generator/plugin/_category_.json +2 -2
  80. package/docs/en/guides/topic-detail/generator/plugin/api/_category_.json +1 -1
  81. package/docs/en/guides/topic-detail/generator/plugin/api/afterForged.md +49 -0
  82. package/docs/en/guides/topic-detail/generator/plugin/api/context.md +184 -0
  83. package/docs/en/guides/topic-detail/generator/plugin/api/input.md +124 -0
  84. package/docs/en/guides/topic-detail/generator/plugin/api/onForged.md +310 -0
  85. package/docs/en/guides/topic-detail/generator/plugin/category.md +88 -0
  86. package/docs/en/guides/topic-detail/generator/plugin/context.md +104 -0
  87. package/docs/en/guides/topic-detail/generator/plugin/structure.md +106 -0
  88. package/docs/en/guides/topic-detail/generator/plugin/use.md +33 -0
  89. package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +8 -8
  90. package/docs/en/guides/troubleshooting/builder.mdx +8 -0
  91. package/docs/en/tutorials/first-app/c03-css.mdx +2 -2
  92. package/docs/en/tutorials/first-app/c08-entries.mdx +3 -3
  93. package/docs/zh/apis/app/commands.mdx +3 -3
  94. package/docs/zh/apis/app/hooks/api/{functions/api.mdx → api.mdx} +4 -4
  95. package/docs/zh/apis/app/hooks/api/app.mdx +12 -0
  96. package/docs/zh/apis/app/hooks/api/{framework/lambda.mdx → lambda.mdx} +5 -5
  97. package/docs/zh/apis/app/hooks/api/test.mdx +3 -3
  98. package/docs/zh/apis/app/hooks/config/icon.mdx +15 -15
  99. package/docs/zh/apis/app/hooks/config/mock.mdx +1 -1
  100. package/docs/zh/apis/app/hooks/config/public.mdx +3 -3
  101. package/docs/zh/apis/app/hooks/config/upload.mdx +1 -1
  102. package/docs/zh/apis/app/hooks/modern-config.mdx +3 -3
  103. package/docs/zh/apis/app/hooks/server/index_.mdx +1 -6
  104. package/docs/zh/apis/app/hooks/shared.mdx +1 -1
  105. package/docs/zh/apis/app/hooks/src/app.mdx +15 -25
  106. package/docs/zh/apis/app/hooks/src/index_.mdx +6 -6
  107. package/docs/zh/apis/app/hooks/src/pages.mdx +7 -3
  108. package/docs/zh/apis/app/hooks/src/routes.mdx +4 -4
  109. package/docs/zh/apis/app/hooks/src/stories.mdx +1 -1
  110. package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +5 -1
  111. package/docs/zh/community/blog/v2-release-note.mdx +1 -1
  112. package/docs/zh/community/contributing-guide.mdx +1 -1
  113. package/docs/zh/components/entry-mode.mdx +0 -0
  114. package/docs/zh/components/init-app.mdx +5 -9
  115. package/docs/zh/components/language-config.mdx +9 -0
  116. package/docs/zh/components/package-manager.mdx +11 -0
  117. package/docs/zh/components/ua-polyfill.mdx +1 -1
  118. package/docs/zh/configure/app/output/css-modules.mdx +13 -0
  119. package/docs/zh/configure/app/source/design-system.mdx +3 -4
  120. package/docs/zh/configure/app/source/enable-async-entry.mdx +2 -5
  121. package/docs/zh/configure/app/source/entries.mdx +2 -2
  122. package/docs/zh/configure/app/tools/swc.mdx +2 -16
  123. package/docs/zh/guides/advanced-features/rspack-start.mdx +7 -8
  124. package/docs/zh/guides/advanced-features/ssg.mdx +1 -1
  125. package/docs/zh/guides/advanced-features/testing.mdx +2 -2
  126. package/docs/zh/guides/advanced-features/web-server.mdx +1 -1
  127. package/docs/zh/guides/basic-features/css.mdx +1 -1
  128. package/docs/zh/guides/basic-features/mock.mdx +1 -1
  129. package/docs/zh/guides/basic-features/routes.mdx +7 -4
  130. package/docs/zh/guides/concept/builder.mdx +1 -1
  131. package/docs/zh/guides/concept/entries.mdx +21 -17
  132. package/docs/zh/guides/get-started/quick-start.mdx +7 -10
  133. package/docs/zh/guides/get-started/upgrade.mdx +1 -1
  134. package/docs/zh/guides/topic-detail/changesets/add.mdx +15 -13
  135. package/docs/zh/guides/topic-detail/changesets/changelog.mdx +20 -20
  136. package/docs/zh/guides/topic-detail/changesets/commit.mdx +12 -14
  137. package/docs/zh/guides/topic-detail/changesets/config.mdx +5 -5
  138. package/docs/zh/guides/topic-detail/changesets/github.mdx +38 -27
  139. package/docs/zh/guides/topic-detail/changesets/introduce.mdx +12 -12
  140. package/docs/zh/guides/topic-detail/changesets/release-note.mdx +84 -70
  141. package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +9 -9
  142. package/docs/zh/guides/topic-detail/changesets/release.mdx +29 -29
  143. package/docs/zh/guides/topic-detail/generator/create/_category_.json +4 -0
  144. package/docs/zh/guides/topic-detail/generator/create/config.mdx +76 -0
  145. package/docs/zh/guides/topic-detail/generator/create/option.md +151 -0
  146. package/docs/zh/guides/topic-detail/generator/create/use.mdx +66 -0
  147. package/docs/zh/guides/topic-detail/generator/new/_category_.json +4 -0
  148. package/docs/zh/guides/topic-detail/generator/new/config.md +153 -0
  149. package/docs/zh/guides/topic-detail/generator/new/option.md +67 -0
  150. package/docs/zh/guides/topic-detail/generator/new/use.md +94 -0
  151. package/docs/zh/guides/topic-detail/generator/plugin/_category_.json +2 -2
  152. package/docs/zh/guides/topic-detail/generator/plugin/api/_category_.json +1 -1
  153. package/docs/zh/guides/topic-detail/generator/plugin/api/afterForged.md +50 -0
  154. package/docs/zh/guides/topic-detail/generator/plugin/api/context.md +184 -0
  155. package/docs/zh/guides/topic-detail/generator/plugin/api/input.md +124 -0
  156. package/docs/zh/guides/topic-detail/generator/plugin/api/onForged.md +310 -0
  157. package/docs/zh/guides/topic-detail/generator/plugin/category.md +93 -0
  158. package/docs/zh/guides/topic-detail/generator/plugin/context.md +105 -0
  159. package/docs/zh/guides/topic-detail/generator/plugin/structure.md +106 -0
  160. package/docs/zh/guides/topic-detail/generator/plugin/use.md +33 -0
  161. package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +4 -4
  162. package/docs/zh/guides/topic-detail/model/test-model.mdx +1 -1
  163. package/docs/zh/guides/troubleshooting/builder.mdx +8 -0
  164. package/docs/zh/tutorials/first-app/c03-css.mdx +1 -1
  165. package/docs/zh/tutorials/first-app/c08-entries.mdx +1 -1
  166. package/package.json +5 -5
  167. package/docs/en/apis/app/hooks/api/framework/_category_.json +0 -4
  168. package/docs/en/apis/app/hooks/api/framework/lambda.mdx +0 -57
  169. package/docs/en/apis/app/hooks/api/functions/_category_.json +0 -4
  170. package/docs/en/apis/app/hooks/api/functions/api.mdx +0 -81
  171. package/docs/en/apis/app/hooks/api/functions/app.mdx +0 -12
  172. package/docs/en/apis/app/hooks/api/functions/common.mdx +0 -9
  173. package/docs/en/guides/topic-detail/generator/codesmith/_category_.json +0 -4
  174. package/docs/en/guides/topic-detail/generator/codesmith/api/_category_.json +0 -4
  175. package/docs/en/guides/topic-detail/generator/codesmith/api/app.mdx +0 -152
  176. package/docs/en/guides/topic-detail/generator/codesmith/api/ejs.mdx +0 -56
  177. package/docs/en/guides/topic-detail/generator/codesmith/api/fs.mdx +0 -54
  178. package/docs/en/guides/topic-detail/generator/codesmith/api/git.mdx +0 -50
  179. package/docs/en/guides/topic-detail/generator/codesmith/api/handlebars.mdx +0 -57
  180. package/docs/en/guides/topic-detail/generator/codesmith/api/json.mdx +0 -56
  181. package/docs/en/guides/topic-detail/generator/codesmith/api/npm.mdx +0 -48
  182. package/docs/en/guides/topic-detail/generator/codesmith/develop.mdx +0 -53
  183. package/docs/en/guides/topic-detail/generator/codesmith/introduce.mdx +0 -47
  184. package/docs/en/guides/topic-detail/generator/codesmith/run-in-js.mdx +0 -47
  185. package/docs/en/guides/topic-detail/generator/codesmith/structure.mdx +0 -89
  186. package/docs/en/guides/topic-detail/generator/config/_category_.json +0 -4
  187. package/docs/en/guides/topic-detail/generator/config/app.mdx +0 -82
  188. package/docs/en/guides/topic-detail/generator/config/common.mdx +0 -100
  189. package/docs/en/guides/topic-detail/generator/config/module.mdx +0 -42
  190. package/docs/en/guides/topic-detail/generator/config/monorepo.mdx +0 -28
  191. package/docs/en/guides/topic-detail/generator/plugin/abstract.mdx +0 -23
  192. package/docs/en/guides/topic-detail/generator/plugin/api/file/_category_.json +0 -4
  193. package/docs/en/guides/topic-detail/generator/plugin/api/file/addFile.mdx +0 -52
  194. package/docs/en/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +0 -26
  195. package/docs/en/guides/topic-detail/generator/plugin/api/file/addManyFile.mdx +0 -58
  196. package/docs/en/guides/topic-detail/generator/plugin/api/file/addPartial.mdx +0 -26
  197. package/docs/en/guides/topic-detail/generator/plugin/api/file/introduce.mdx +0 -39
  198. package/docs/en/guides/topic-detail/generator/plugin/api/file/rmDir.mdx +0 -24
  199. package/docs/en/guides/topic-detail/generator/plugin/api/file/rmFile.mdx +0 -24
  200. package/docs/en/guides/topic-detail/generator/plugin/api/file/updateJSONFile.mdx +0 -54
  201. package/docs/en/guides/topic-detail/generator/plugin/api/file/updateModernConfig.mdx +0 -27
  202. package/docs/en/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.mdx +0 -33
  203. package/docs/en/guides/topic-detail/generator/plugin/api/git/_category_.json +0 -4
  204. package/docs/en/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.mdx +0 -20
  205. package/docs/en/guides/topic-detail/generator/plugin/api/git/initGitRepo.mdx +0 -16
  206. package/docs/en/guides/topic-detail/generator/plugin/api/git/isInGitRepo.mdx +0 -16
  207. package/docs/en/guides/topic-detail/generator/plugin/api/hook/_category_.json +0 -4
  208. package/docs/en/guides/topic-detail/generator/plugin/api/hook/afterForged.mdx +0 -35
  209. package/docs/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +0 -35
  210. package/docs/en/guides/topic-detail/generator/plugin/api/info/_category_.json +0 -4
  211. package/docs/en/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +0 -22
  212. package/docs/en/guides/topic-detail/generator/plugin/api/info/locale.mdx +0 -17
  213. package/docs/en/guides/topic-detail/generator/plugin/api/info/readDir.mdx +0 -22
  214. package/docs/en/guides/topic-detail/generator/plugin/api/input/_category_.json +0 -4
  215. package/docs/en/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +0 -55
  216. package/docs/en/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +0 -55
  217. package/docs/en/guides/topic-detail/generator/plugin/api/input/setInput.mdx +0 -43
  218. package/docs/en/guides/topic-detail/generator/plugin/api/input/setInputValue.mdx +0 -31
  219. package/docs/en/guides/topic-detail/generator/plugin/api/input/type.mdx +0 -65
  220. package/docs/en/guides/topic-detail/generator/plugin/api/introduce.mdx +0 -90
  221. package/docs/en/guides/topic-detail/generator/plugin/api/new/_category_.json +0 -4
  222. package/docs/en/guides/topic-detail/generator/plugin/api/new/createElement.mdx +0 -33
  223. package/docs/en/guides/topic-detail/generator/plugin/api/new/createSubProject.mdx +0 -35
  224. package/docs/en/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +0 -44
  225. package/docs/en/guides/topic-detail/generator/plugin/api/new/introduce.mdx +0 -15
  226. package/docs/en/guides/topic-detail/generator/plugin/api/npm/_category_.json +0 -4
  227. package/docs/en/guides/topic-detail/generator/plugin/api/npm/install.mdx +0 -18
  228. package/docs/en/guides/topic-detail/generator/plugin/develop.mdx +0 -125
  229. package/docs/en/guides/topic-detail/generator/plugin/use.mdx +0 -61
  230. package/docs/en/guides/topic-detail/generator/project.mdx +0 -118
  231. package/docs/zh/apis/app/hooks/api/framework/_category_.json +0 -4
  232. package/docs/zh/apis/app/hooks/api/functions/_category_.json +0 -4
  233. package/docs/zh/apis/app/hooks/api/functions/app.mdx +0 -12
  234. package/docs/zh/apis/app/hooks/api/functions/common.mdx +0 -9
  235. package/docs/zh/guides/topic-detail/generator/codesmith/_category_.json +0 -4
  236. package/docs/zh/guides/topic-detail/generator/codesmith/api/_category_.json +0 -4
  237. package/docs/zh/guides/topic-detail/generator/codesmith/api/app.mdx +0 -152
  238. package/docs/zh/guides/topic-detail/generator/codesmith/api/ejs.mdx +0 -56
  239. package/docs/zh/guides/topic-detail/generator/codesmith/api/fs.mdx +0 -54
  240. package/docs/zh/guides/topic-detail/generator/codesmith/api/git.mdx +0 -49
  241. package/docs/zh/guides/topic-detail/generator/codesmith/api/handlebars.mdx +0 -56
  242. package/docs/zh/guides/topic-detail/generator/codesmith/api/json.mdx +0 -56
  243. package/docs/zh/guides/topic-detail/generator/codesmith/api/npm.mdx +0 -47
  244. package/docs/zh/guides/topic-detail/generator/codesmith/develop.mdx +0 -53
  245. package/docs/zh/guides/topic-detail/generator/codesmith/introduce.mdx +0 -59
  246. package/docs/zh/guides/topic-detail/generator/codesmith/run-in-js.mdx +0 -47
  247. package/docs/zh/guides/topic-detail/generator/codesmith/structure.mdx +0 -89
  248. package/docs/zh/guides/topic-detail/generator/config/_category_.json +0 -4
  249. package/docs/zh/guides/topic-detail/generator/config/app.mdx +0 -82
  250. package/docs/zh/guides/topic-detail/generator/config/common.mdx +0 -100
  251. package/docs/zh/guides/topic-detail/generator/config/module.mdx +0 -42
  252. package/docs/zh/guides/topic-detail/generator/config/monorepo.mdx +0 -28
  253. package/docs/zh/guides/topic-detail/generator/plugin/abstract.mdx +0 -23
  254. package/docs/zh/guides/topic-detail/generator/plugin/api/file/_category_.json +0 -4
  255. package/docs/zh/guides/topic-detail/generator/plugin/api/file/addFile.mdx +0 -52
  256. package/docs/zh/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +0 -26
  257. package/docs/zh/guides/topic-detail/generator/plugin/api/file/addManyFile.mdx +0 -55
  258. package/docs/zh/guides/topic-detail/generator/plugin/api/file/addPartial.mdx +0 -26
  259. package/docs/zh/guides/topic-detail/generator/plugin/api/file/introduce.mdx +0 -39
  260. package/docs/zh/guides/topic-detail/generator/plugin/api/file/rmDir.mdx +0 -24
  261. package/docs/zh/guides/topic-detail/generator/plugin/api/file/rmFile.mdx +0 -24
  262. package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.mdx +0 -54
  263. package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateModernConfig.mdx +0 -27
  264. package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.mdx +0 -33
  265. package/docs/zh/guides/topic-detail/generator/plugin/api/git/_category_.json +0 -4
  266. package/docs/zh/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.mdx +0 -20
  267. package/docs/zh/guides/topic-detail/generator/plugin/api/git/initGitRepo.mdx +0 -16
  268. package/docs/zh/guides/topic-detail/generator/plugin/api/git/isInGitRepo.mdx +0 -16
  269. package/docs/zh/guides/topic-detail/generator/plugin/api/hook/_category_.json +0 -4
  270. package/docs/zh/guides/topic-detail/generator/plugin/api/hook/afterForged.mdx +0 -35
  271. package/docs/zh/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +0 -35
  272. package/docs/zh/guides/topic-detail/generator/plugin/api/info/_category_.json +0 -4
  273. package/docs/zh/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +0 -22
  274. package/docs/zh/guides/topic-detail/generator/plugin/api/info/locale.mdx +0 -17
  275. package/docs/zh/guides/topic-detail/generator/plugin/api/info/readDir.mdx +0 -22
  276. package/docs/zh/guides/topic-detail/generator/plugin/api/input/_category_.json +0 -4
  277. package/docs/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +0 -57
  278. package/docs/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +0 -56
  279. package/docs/zh/guides/topic-detail/generator/plugin/api/input/setInput.mdx +0 -43
  280. package/docs/zh/guides/topic-detail/generator/plugin/api/input/setInputValue.mdx +0 -29
  281. package/docs/zh/guides/topic-detail/generator/plugin/api/input/type.mdx +0 -65
  282. package/docs/zh/guides/topic-detail/generator/plugin/api/introduce.mdx +0 -92
  283. package/docs/zh/guides/topic-detail/generator/plugin/api/new/_category_.json +0 -4
  284. package/docs/zh/guides/topic-detail/generator/plugin/api/new/createElement.mdx +0 -33
  285. package/docs/zh/guides/topic-detail/generator/plugin/api/new/createSubProject.mdx +0 -35
  286. package/docs/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +0 -44
  287. package/docs/zh/guides/topic-detail/generator/plugin/api/new/introduce.mdx +0 -15
  288. package/docs/zh/guides/topic-detail/generator/plugin/api/npm/_category_.json +0 -4
  289. package/docs/zh/guides/topic-detail/generator/plugin/api/npm/install.mdx +0 -16
  290. package/docs/zh/guides/topic-detail/generator/plugin/develop.mdx +0 -125
  291. package/docs/zh/guides/topic-detail/generator/plugin/use.mdx +0 -61
  292. package/docs/zh/guides/topic-detail/generator/project.mdx +0 -118
@@ -1,35 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- ---
4
-
5
- # createSubProject
6
-
7
- Create subprojects and only support Monorepo engineering solutions.
8
-
9
- This method is available on the `onForged` API parameter.
10
-
11
- Its type is defined as:
12
-
13
- ```ts
14
- export enum SubSolution {
15
- MWA = 'mwa',
16
- MWATest = 'mwa_test',
17
- Module = 'module',
18
- InnerModule = 'inner_module',
19
- }
20
- export type ForgedAPI = {
21
- createSubProject: (
22
- solution: SubSolution,
23
- params: Record<string, unknown>,
24
- ) => Promise<void>;
25
- ...
26
- };
27
- ```
28
-
29
- ## solution
30
-
31
- Sub-project engineering solution name.
32
-
33
- ## params
34
-
35
- For other parameters of creating subprojects, please refer to[Monorepo Create Sub Project](/guides/topic-detail/generator/config/monorepo).
@@ -1,44 +0,0 @@
1
- ---
2
- sidebar_position: 3
3
- ---
4
-
5
- # enableFunc
6
-
7
- Enable functionality to support application and module engineering scenarios.
8
-
9
- This method is available on the `onForged` API parameter.
10
-
11
- Its type is defined as:
12
-
13
- ```ts
14
- export enum ActionFunction {
15
- UnBundle = 'unbundle',
16
- TailwindCSS = 'tailwindcss',
17
- BFF = 'bff',
18
- MicroFrontend = 'micro_frontend',
19
- I18n = 'i18n',
20
- Test = 'test',
21
- E2ETest = 'e2e_test',
22
- Doc = 'doc',
23
- Storybook = 'storybook',
24
- RuntimeApi = 'runtimeApi',
25
- SSG = 'ssg',
26
- Polyfill = 'polyfill',
27
- Deploy = 'deploy',
28
- }
29
- export type ForgedAPI = {
30
- enableFunc: (
31
- func: ActionFunction,
32
- params?: Record<string, unknown> | undefined,
33
- ) => Promise<void>;
34
- ...
35
- };
36
- ```
37
-
38
- ## func
39
-
40
- The function name is passed according to the functions supported by the different engineering solutions.
41
-
42
- ## params
43
-
44
- For other parameters when the function is enabled, please refer to [App New Command](/guides/topic-detail/generator/config/app) and [Module New Command](/guides/topic-detail/generator/config/module).
@@ -1,15 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # Introduction
6
-
7
- The three engineering solutions provided by the Modern.js support executing the new command in the project to create elements and enable functions. In the generator plugin, the relevant API can be directly called to create some elements and enable supported functions by default.
8
-
9
- Different engineering solutions to support new operations:
10
-
11
- - [Web App](/guides/topic-detail/generator/config/app)
12
-
13
- - [Module](/guides/topic-detail/generator/config/module)
14
-
15
- - [Monorepo](/guides/topic-detail/generator/config/monorepo)
@@ -1,4 +0,0 @@
1
- {
2
- "label": "NPM API",
3
- "position": 7
4
- }
@@ -1,18 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # install
6
-
7
- Install dependency in the project root directory.
8
-
9
- In the install function, the dependency will be installed using the corresponding package manager based on the value of `packageManager`.
10
-
11
- Its type is defined as:
12
-
13
- ```ts
14
- export type AfterForgedAPI = {
15
- install: () => Promise<void>;
16
- ...
17
- };
18
- ```
@@ -1,125 +0,0 @@
1
- ---
2
- sidebar_position: 3
3
- ---
4
-
5
- # How to develop generator plugins
6
-
7
- ## Create project
8
-
9
- Modern.js provides a generator plugin to create a generator plugin project, you can directly execute the following command to create:
10
-
11
- ```bash
12
- npx @modern-js/create@latest plugin --plugin @modern-js/generator-plugin-plugin
13
- ```
14
-
15
- Different plugin types will ask different questions. You can choose the plugin type according to your needs.
16
-
17
- ### Extension type
18
-
19
- ```
20
- ? Please select the solution you want to create: Npm Module
21
- ? Please select the scene you want to create: Generator Plugin
22
- ? Plugin Package Name: plugin
23
- ? Development Language: TS
24
- ? Package Manager: pnpm
25
- ? Plugin Type: extend
26
- ? Plugin Base Type: Web App
27
- ```
28
-
29
- ### Customized type
30
-
31
- ```
32
- ? Plugin Package Name: plugin
33
- ? Development Language: TS
34
- ? Package Manager: pnpm
35
- ? Plugin Type: custom
36
- ? Plugin Key: mobile-app
37
- ? Plugin Show Name: Mobile App
38
- ? Plugin Base Type: Web App
39
- ```
40
-
41
- After the execution of the create project command is completed, a project for developing the generator plugin will be generated accordingly, and the `meta` information will also be generated according to your selection in the `package.json`.
42
-
43
- :::info
44
- For generator plugin development, please refer to `@modern-js/generator-plugin-plugin`. [Source Code](https://github.com/web-infra-dev/modern.js/tree/main/packages/generator/plugins/generator-plugin)
45
-
46
- :::
47
-
48
- ## Develop plugin logic
49
-
50
- Complete plugin logic development in `src/index.ts`.
51
-
52
- The plugin exports a function by default, the function parameter is `context`, and some methods are provided on `context` to directly operate on the current project.
53
-
54
- A brief introduction to the provided methods, the complete API list viewable [Generator Plugin API](/guides/topic-detail/generator/plugin/api/introduce).
55
-
56
- ### Customize input
57
-
58
- - addInputBefore
59
-
60
- Add input before the default input, such as adding questions before the `Select package manager` question.
61
-
62
- Specific Modern.js configuration viewable for each problem [Project Solution Configuration](/guides/topic-detail/generator/config/common).
63
-
64
- ```ts
65
- context.addInputBefore('input2', {
66
- type: 'object',
67
- properties: {
68
- 'input1.2': {
69
- type: 'string',
70
- title: 'input1.2',
71
- },
72
- },
73
- });
74
- ```
75
-
76
- - setInput
77
-
78
- Set attributes of existing problems.
79
-
80
- ```ts
81
- context.setInput('test', 'type', 'number');
82
- context.setInput('test', 'enum', [{ value: 'option1', label: '选项一' }]);
83
- ```
84
-
85
- ### onForged
86
-
87
- After the implementation of the hook related operations of the project plan type file is completed, multiple extended inspection will execute its `onForged` function in sequence according to the `plugin` parameter order.
88
-
89
- The `onForged` parameter is a callback function, and the function parameters are `api` and `input`.
90
-
91
- Some file manipulation related methods are provided on the `api`, which can operate on the current template file in this hook.
92
-
93
- `input` is the current user input, which can be used to obtain the current input information and configuration information of the user.
94
-
95
- When you need a new template file, you can add it directly in the `templates` directory. In the `onForged` function, you can directly operate the `templates` directory file. For example, the `templateFile` parameter in the `addFile` below is the file in the `templates` directory. There is no need to display the declaration `templates` here, just write the relative path relative to `templates`.
96
-
97
- API functions supported in `onForged` can also be found in [Generator Plugin API](/guides/topic-detail/generator/plugin/api/hook/onForged).
98
-
99
- ```ts
100
- context.onForged(async (api: ForgedAPI, input: Record<string, unknown>) => {
101
- const { language } = input;
102
- api.addFile({
103
- type: FileType.Text,
104
- file: `src/index.${language as string}`,
105
- templateFile: `index.${language as string}.handlebars`,
106
- force: true,
107
- });
108
- });
109
- ```
110
-
111
- ### afterForged
112
-
113
- After the `onForged` function is executed, it can mainly install dependencies, Git operations, etc.
114
-
115
- If your project plan is based on the three projects provided by the Modern.js, this hook function may not be required. The default project plan will automatically include the installation dependency and commit code logic.
116
-
117
- The generator plugin also supports a customized `custom` type, which only provides a small amount of development-level best practice code, such as `.gitignore`, `editorConfig` and other files. In this case, you need to manually supplement the installation dependency and Git operation logic in the `afterForged` function.
118
-
119
- The `afterForged` parameter is also a callback function, and the function parameters are `api` and `input`.
120
-
121
- The `api` will provide some npm, Git and other methods, which can install dependency and Git operations in this hook.
122
-
123
- `input` is the current user input, which can be used to obtain the current input information and configuration information of the user.
124
-
125
- The API functions supported in `afterForged` can also be found in [Generator Plugin API](/guides/topic-detail/generator/plugin/api/hook/afterForged).
@@ -1,61 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- ---
4
-
5
- # How to use the generator plugin
6
-
7
- `@modern-js/create` provides the `--plugin` parameter to declare the generator plugin used.
8
-
9
- You can use the generator plugin directly by executing the following command:
10
-
11
- ```bash
12
- npx @modern-js/create@latest --plugin <pluginName>
13
- ```
14
-
15
- The plugin parameter supports multiple declarations, which means that multiple generator plugins are used at the same time.
16
-
17
- ## Classification
18
-
19
- There are two types of generator plugins:
20
-
21
- 1. Extended engineering: directly customize the three major engineering provided by default.
22
-
23
- 2. Create engineering scenes: Create corresponding engineering scenes based on the default three major engineering schemes.
24
-
25
- ### Type definition
26
-
27
- The classification of the generator plugin is provided by the meta information in the `package.json`.
28
-
29
- #### Extended engineering
30
-
31
- ```json
32
- {
33
- "meta": {
34
- "extend": "mwa" // The three engineering is mwa, module, monorepo
35
- }
36
- }
37
- ```
38
-
39
- #### Create engineering scenes
40
-
41
- ```json
42
- {
43
- "meta": {
44
- "key": "new_solution",
45
- "name": "New Solution",
46
- "type": "mwa" // In addition to the three major engineering solutions, the type here also supports the customize (custom) type
47
- }
48
- }
49
- ```
50
-
51
- ### Execution timing
52
-
53
- The execution timing of different types of custom engineering solutions is different.
54
-
55
- #### Extended engineering
56
-
57
- The generator plugin of the extended engineering type will execute in sequence according to the declaration order of the plugin parameter after selecting the corresponding extended project scheme.
58
-
59
- #### Create engineering scenes
60
-
61
- The generator plugin that create engineering scenes will have the option to select the scene after selecting the project solution type. The option list includes the current default project scenes and the project scenes defined by the plugin. If you select the corresponding scene, the corresponding generator will be executed plugin.
@@ -1,118 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- ---
4
-
5
- # Project Generator
6
-
7
- Modern.js provides `@modern-js/create` as a project generator for Modern.js project creation.
8
-
9
- ## Use
10
-
11
- There is no need to install `@modern-js/create` globally, just execute the tool directly with npx:
12
-
13
- ```bash
14
- npx @modern-js/create@latest [projectDir]
15
- ```
16
-
17
- :::info
18
- Use npx to get the latest version of `@modern-js/create` every time.
19
-
20
- :::
21
-
22
- ## Params
23
-
24
- ### [projectDir]
25
-
26
- Project directory name.
27
-
28
- When executing the above command, the `projectDir` folder will be created in the current directory by default, and the initialization project will be in this folder. When this parameter is empty, the initialization project will be directly generated in the current directory.
29
-
30
- ### --version
31
-
32
- Get the `@modern-js/create` tool version.
33
-
34
- ```bash
35
- $ npx @modern-js/create@latest --version
36
-
37
- [INFO] @modern-js/create v2.0.0
38
- ```
39
-
40
- ### --lang
41
-
42
- Specifies the execution language, supports `zh` and `en`.
43
-
44
- By default, `@modern-js/create` will automatically identify the user's system language, choose to use Chinese or English, if the recognition fails or you want to specify the language manually, you can use this parameter.
45
-
46
- ### -c, --config
47
-
48
- Specifies the project default configuration.
49
-
50
- By default, `@modern-js/create` will have interaction problems such as language selection and package managers during execution. When you need to specify these configuration contents in advance, you can pass in this field.
51
-
52
- This field is a JSON character string, for example when running a package manager:
53
-
54
- ```bash
55
- npx @modern-js/create@latest --config '{"packageManager": "pnpm"}'
56
- ```
57
-
58
- Specific configuration information viewable [Project Configuration](/guides/topic-detail/generator/config/common).
59
-
60
- ### --no-need-install
61
-
62
- By default, `@modern-js/create` automatically installs dependency after the project is created, use this parameter to ignore the install dependency step.
63
-
64
- ### --dist-tag \<distTag\>
65
-
66
- Specifies the generator and Modern.js dependency versions.
67
-
68
- A smaller micro-generator will be executed during the execution of `@modern-js/create`, and the version number of the micro-generator that can be executed with this parameter and the version number of the corresponding installation Modern.js related dependencies.
69
-
70
- ### --registry \<registry/>
71
-
72
- Execute the npm registry to get the generator and npm packages.
73
-
74
- ### --debug
75
-
76
- Displays debug log information during generator execution.
77
-
78
- ### --mwa
79
-
80
- One-click to create an application engineering solution project.
81
-
82
- With this parameter, `@modern-js/create` will create the application project with the configuration default value.
83
-
84
- ### --module
85
-
86
- One-click to create a module engineering solution project.
87
-
88
- With this parameter, `@modern-js/create` will create the module project with the configuration default value.
89
-
90
- ### --monorepo
91
-
92
- One-click to create a Monorepo engineering solution project.
93
-
94
- With this parameter, `@modern-js/create` will create the Monorepo project with the configuration default value.
95
-
96
- ### --plugin \<plugin\>
97
-
98
- Specifies the generator plugin.
99
-
100
- Modern.js support the use of the generator plug-in custom Modern.js the default project type or add the project type scenes, the parameter user specifies the customized generator plugin.
101
-
102
- For custom generator plugins, please refer to [Development Generator Plugin](/guides/topic-detail/generator/plugin/abstract).
103
-
104
- ### --generator \<generator\>
105
-
106
- Specifies the microgenerator.
107
-
108
- By default, `@modern-js/create` will execute the microgenerator Modern.js framework build-in. If you need to execute a customized microgenerator, and you need to use the posture of `npx @modern-js/create@latest`, you can use this parameter directly.
109
-
110
- For custom microgenerators, please refer to [Develop Microgenerator](/guides/topic-detail/generator/codesmith/introduce).
111
-
112
- ### --packages \<packages\>
113
-
114
- A project is created by specifying a specific package version dependency.
115
-
116
- If you need to specify a specific package version when creating a project, you can use this parameter. This parameter will lock the package version number in the `package.json` of the project root directory by configuration `pnpm.overrides` (package manager selects pnpm) or `resolutions`.
117
-
118
- The parameter value is a JSON character string.
@@ -1,4 +0,0 @@
1
- {
2
- "label": "Framework Mode",
3
- "position": 2
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "label": "Function Mode",
3
- "position": 1
4
- }
@@ -1,12 +0,0 @@
1
- ---
2
- title: _app.[tj]s
3
- sidebar_position: 3
4
- ---
5
- # _app.[tj]s
6
-
7
- 在函数写法下,该文件可以为 [BFF 函数](/apis/app/hooks/api/functions/api)添加前置中间件。
8
-
9
- :::note
10
- 具体示例请参考 [hook](/apis/app/runtime/bff/hook)
11
-
12
- :::
@@ -1,9 +0,0 @@
1
- ---
2
- title: '**/_*.[tj]s, _*/**'
3
- sidebar_position: 2
4
- ---
5
- # **/_*.[tj]s, _*/**
6
-
7
- 在 BFF 函数写法下,这些文件不会注册为路由。
8
-
9
- 你可以在这种目录或文件下放任意项目中需要的代码,文件等。
@@ -1,4 +0,0 @@
1
- {
2
- "label": "开发微生成器",
3
- "position": 5
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "label": "API",
3
- "position": 5
4
- }
@@ -1,152 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # @modern-js/codesmith-api-app
6
-
7
- 微生成器开发过程中常用 API 的组合封装,包含 fs、git、npm 等其他包的 API 封装,在能满足需求时,推荐使用该 npm 包的 API。
8
-
9
- ## 使用姿势
10
-
11
- ```ts
12
- import { AppAPI } from '@modern-js/codesmith-api-app';
13
-
14
- export default async (context: GeneratorContext, generator: GeneratorCore) => {
15
- const appApi = new AppAPI(context, generator);
16
- await appApi.runInstall();
17
- };
18
- ```
19
-
20
- - 创建 AppAPI 实例,参数和微生成器函数参数一致,为 context 和 generator,具体介绍请看[微生成器项目组成](/guides/topic-detail/generator/codesmith/structure)。
21
- - 调用其实例上 API 即可。
22
-
23
- ## API
24
-
25
- ### checkEnvironment
26
-
27
- 检查当前生成器运行环境,检查项为:
28
-
29
- 1. node 及 node 版本,默认大于 12.22.12,可传递参数执行 node 版本。
30
- 2. 可使用 yarn、pnpm 或者 npm。
31
-
32
- 参数:
33
-
34
- - nodeVersion?: `string` 校验的 node 版本。
35
-
36
- ### runInstall
37
-
38
- 安装依赖,可传入安装依赖命令,默认根据 config 中的 `packageManager` 值进行。
39
-
40
- 参数:
41
-
42
- - command?: `string` 安装依赖命令。
43
-
44
- ### runGitAndInstall
45
-
46
- 该函数完成以下动作:
47
-
48
- 1. 校验当前生成器执行目录是否为一个 git 仓库。
49
- 2. 如果不是一个 git 仓库,初始化为一个 git 仓库。
50
- 3. 安装依赖。
51
- 4. 在非 monorepo 项目(判断条件,config 中 `isMonorepoSubProject` 不存在或者为 false)中提交初始 commit,commit 信息为 feat: init,支持自定义。
52
-
53
- 参数:
54
-
55
- - commitMessage?: `string` 初始化 commit message 信息。
56
- - installFunc?: `() => Promise<void>` 安装依赖函数。
57
-
58
- ### forgeTemplate
59
-
60
- 渲染生成器模板文件。
61
-
62
- 参数:
63
-
64
- - templatePattern: string 模板文件匹配正则,例如: `templates/base-templates/**/*` 。
65
- - filter?: `(resourceKey: string) => boolean` 过滤函数,参数为 templatePattern 匹配的文件路径,返回 true 表示渲染该文件,返回 false 表示不渲染该文件。
66
- - rename?: `(resourceKey: string) => string` 重命名函数,参数为 templatePattern 匹配的文件路径,返回新文件名。默认会替换 resourceKey 开头的 templates 目录和结尾的 .handlebars 后缀。
67
- - parameters?: `Record<string, any>` 渲染参数,当模板中存在 handlebars 或者 ejs 变量时,使用其传递对应变量值。
68
- - type?: `'handlebars' | 'ejs'` 模板文件类型,默认为 handlebars。
69
-
70
- 例如:
71
-
72
- ```ts
73
- await appApi.forgeTemplate(
74
- 'templates/base-templates/**/*',
75
- undefined,
76
- resourceKey =>
77
- resourceKey
78
- .replace('templates/base-templates/', '')
79
- .replace('.handlebars', ''),
80
- );
81
-
82
- await appApi.forgeTemplate(
83
- 'templates/base-template/**/*',
84
- resourceKey => !resourceKey.include('eslintrc.json'),
85
- resourceKey =>
86
- resourceKey
87
- .replace('templates/base-template/', projectPath)
88
- .replace('language', language as string)
89
- .replace('.handlebars', ''),
90
- {
91
- name: packageName as string,
92
- language,
93
- isTs: language === Language.TS,
94
- packageManager: getPackageManagerText(packageManager as any),
95
- },
96
- );
97
- ```
98
-
99
- ### showSuccessInfo
100
-
101
- 展示成功信息。
102
-
103
- 参数:
104
-
105
- - successInfo?: `string`,默认为 Success || 成功。
106
-
107
- ### runSubGenerator
108
-
109
- 运行子生成器。
110
-
111
- 参数:
112
-
113
- - subGenerator: `string` 子生成器名称或者路径。
114
- - relativePwdPath?: `string` 子生成器运行的相对路径。
115
- - config?: `Record<string, unknown>` 子生成器运行的默认 config 配置。
116
-
117
- 例如:
118
-
119
- ```ts
120
- await appApi.runSubGenerator(
121
- getGeneratorPath('@modern-js/repo-generator', context.config.distTag),
122
- undefined,
123
- { ...context.config, hasPlugin: false },
124
- );
125
- ```
126
-
127
- ### getInputBySchema
128
-
129
- 通过 schema 完成用户交互输入。
130
-
131
- 参数:
132
-
133
- - schema: `FormilySchema | Question[]` 问题列表,支持 Formily schema 和 inquirer 类型。
134
- - type: `'formily' | 'inquirer'` 类型,默认值为 formily。
135
- - configValue: `Record<string, unknown> = {}` schema 默认值,传入该值的 schema 字段对应的问题将不再和用户交互。
136
- - validateMap?: `Record<string, (input: unknown, data?: Record<string, unknown>) => { success: boolean; error?: string }>` schema 中特殊字段的验证函数。
137
- - initValue?: `Record<string, any>` schema 中字段的初始化值。
138
-
139
- Formily Schema 类型支持方式可参考[自定义输入相关类型定义](/guides/topic-detail/generator/plugin/api/input/type)。
140
-
141
- ### getInputBySchemaFunc
142
-
143
- 通过 schema 完成用户交互输入,schema 参数值为函数,用户处理国际化问题,仅支持 Formily schema。
144
-
145
- 参数:
146
-
147
- - schema: `config?: Record<string, any>) => FormilySchema` 获取问题列表函数,config 参数为当前生成器中的 config 配置信息。
148
- - configValue: `Record<string, unknown> = {}` schema 默认值,传入该值的 schema 字段对应的问题将不再和用户交互。
149
- - validateMap?: `Record<string, (input: unknown, data?: Record<string, unknown>) => { success: boolean; error?: string }>` schema 中特殊字段的验证函数。
150
- - initValue?: `Record<string, any>` schema 中字段的初始化值。
151
-
152
- Formily Schema 类型支持方式可参考[自定义输入相关类型定义](/guides/topic-detail/generator/plugin/api/input/type)。
@@ -1,56 +0,0 @@
1
- ---
2
- sidebar_position: 6
3
- ---
4
-
5
- # @modern-js/codesmith-api-ejs
6
-
7
- 微生成器中使用 [ejs](https://ejs.co/) 进行文件操作的 API 封装,提供渲染单个模板文件和文件夹的方法。
8
-
9
- ## 使用姿势
10
-
11
- ```ts
12
- import { EjsAPI } from '@modern-js/codesmith-api-ejs';
13
-
14
- export default async (context: GeneratorContext, generator: GeneratorCore) => {
15
- const ejsAPI = new EjsAPI(generator);
16
- await ejsAPI.renderTemplate(
17
- material.get('templates/a.js'),
18
- target: 'b.js',
19
- { data: "data" }
20
- );
21
- }
22
- ```
23
-
24
- - 创建 EjsAPI 实例,参数为微生成器函数参数的 generator,具体介绍请看微生成器项目组成 。
25
- - 调用其实例上 API 即可。
26
-
27
- ## API
28
-
29
- ### renderTemplate
30
-
31
- 渲染单个模板文件。
32
-
33
- 参数:
34
-
35
- - templateResource: `FsResource` 模板文件资源,通过 `context.materials.get(<filename>)` 使用。
36
- - target: `string` 目标文件路径名称。
37
- - parameters?: `Record<string, string>` 渲染参数。
38
-
39
- ### renderTemplateDir
40
-
41
- 渲染模板文件夹。
42
-
43
- 参数:
44
-
45
- - material: `FsMaterial` 当前微生成器执行的 material 上下文。
46
- - findGlob: `string` 模板文件匹配正则。
47
- - target: `(globMatch: string) => string` 目标文件路径生成函数,参数为 `resourceKey。`
48
- - options?: `RenderTemplateDirOptions` glob 查找文件配置,具体函数可查看这里 [glob](https://www.npmjs.com/package/glob)。
49
-
50
- ```ts
51
- type RenderTemplateDirOptions = {
52
- nodir?: boolean;
53
- dot?: boolean;
54
- ignore?: string | readonly string[];
55
- };
56
- ```