@modern-js/main-doc 2.0.0-beta.1 → 2.0.0-beta.2

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 (157) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/build.md +1 -1
  3. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/dev.md +1 -1
  4. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/lint.md +1 -1
  5. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +1 -2
  6. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/start.md +1 -1
  7. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/test.md +1 -1
  8. package/en/docusaurus-plugin-content-docs/current/apis/app/overview.md +1 -1
  9. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/auto-actions.md +1 -1
  10. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/connect.md +1 -1
  11. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-app.md +1 -1
  12. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-store.md +1 -1
  13. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/handle-effect.md +1 -1
  14. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/model_.md +1 -1
  15. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-local-model.md +1 -1
  16. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-model.md +1 -1
  17. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-static-model.md +1 -1
  18. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +1 -1
  19. package/en/docusaurus-plugin-content-docs/current/components/command-tip.md +56 -0
  20. package/en/docusaurus-plugin-content-docs/current/components/reduck-tip.md +5 -0
  21. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-extract.md +12 -0
  22. package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +1 -1
  23. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/_category_.json +4 -0
  24. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/_category_.json +4 -0
  25. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/_category_.json +4 -0
  26. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/app.md +152 -0
  27. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/ejs.md +56 -0
  28. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/fs.md +54 -0
  29. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/git.md +49 -0
  30. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/handlebars.md +58 -0
  31. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/json.md +59 -0
  32. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/npm.md +49 -0
  33. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/develop.md +52 -0
  34. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/introduce.md +46 -0
  35. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/run-in-js.md +48 -0
  36. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/structure.md +87 -0
  37. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/_category_.json +4 -0
  38. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +106 -0
  39. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/module.md +39 -0
  40. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/monorepo.md +28 -0
  41. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/mwa.md +89 -0
  42. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/_category_.json +4 -0
  43. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/abstract.md +26 -0
  44. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/_category_.json +4 -0
  45. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/_category_.json +4 -0
  46. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addFile.md +52 -0
  47. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addHelper.md +26 -0
  48. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addManyFile.md +58 -0
  49. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/addPartial.md +26 -0
  50. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/introduce.md +38 -0
  51. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/rmDir.md +24 -0
  52. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/rmFile.md +24 -0
  53. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +54 -0
  54. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateModernConfig.md +26 -0
  55. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.md +33 -0
  56. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/_category_.json +4 -0
  57. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.md +20 -0
  58. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/initGitRepo.md +16 -0
  59. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/git/isInGitRepo.md +16 -0
  60. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/_category_.json +4 -0
  61. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/afterForged.md +35 -0
  62. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/onForged.md +36 -0
  63. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/_category_.json +4 -0
  64. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/isFileExit.md +22 -0
  65. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/locale.md +17 -0
  66. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/info/readDir.md +22 -0
  67. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/_category_.json +4 -0
  68. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +57 -0
  69. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +56 -0
  70. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInput.md +42 -0
  71. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInputValue.md +30 -0
  72. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/type.md +65 -0
  73. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/introduce.md +91 -0
  74. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/_category_.json +4 -0
  75. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/createElement.md +33 -0
  76. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/createSubProject.md +35 -0
  77. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/enableFunc.md +44 -0
  78. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/new/introduce.md +15 -0
  79. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/npm/_category_.json +4 -0
  80. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/npm/install.md +18 -0
  81. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/develop.md +125 -0
  82. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/use.md +61 -0
  83. package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +118 -0
  84. package/en/docusaurus-plugin-content-docs/current.json +39 -3
  85. package/package.json +3 -3
  86. package/scripts/summary.en.json +1 -1
  87. package/scripts/summary.zh.json +1 -1
  88. package/zh/apis/app/commands/new.md +0 -1
  89. package/zh/apis/app/hooks/server/test.md +2 -2
  90. package/zh/apis/app/runtime/web-server/hook.md +4 -4
  91. package/zh/apis/app/runtime/web-server/middleware.md +4 -4
  92. package/zh/configure/app/output/disable-css-extract.md +12 -0
  93. package/zh/guides/advanced-features/bff/_category_.json +5 -1
  94. package/zh/guides/advanced-features/bff/bff-proxy.md +5 -3
  95. package/zh/guides/advanced-features/bff/frameworks.md +72 -51
  96. package/zh/guides/advanced-features/bff/function.md +16 -30
  97. package/zh/guides/advanced-features/bff/index.md +20 -0
  98. package/zh/guides/advanced-features/bff/type.md +43 -0
  99. package/zh/guides/advanced-features/custom-app.md +63 -1
  100. package/zh/guides/advanced-features/web-server.md +21 -110
  101. package/zh/guides/basic-features/data-fetch.md +61 -0
  102. package/zh/guides/basic-features/env-vars.md +88 -41
  103. package/zh/guides/basic-features/routes.md +267 -0
  104. package/zh/guides/concept/entries.md +112 -0
  105. package/zh/guides/concept/lifecycle.md +10 -0
  106. package/zh/guides/get-started/quick-start.md +199 -1
  107. package/zh/guides/get-started/upgrade.md +75 -1
  108. package/zh/guides/topic-detail/generator/codesmith/api/_category_.json +4 -0
  109. package/zh/guides/topic-detail/generator/codesmith/api/app.md +152 -0
  110. package/zh/guides/topic-detail/generator/codesmith/api/ejs.md +56 -0
  111. package/zh/guides/topic-detail/generator/codesmith/api/fs.md +54 -0
  112. package/zh/guides/topic-detail/generator/codesmith/api/git.md +48 -0
  113. package/zh/guides/topic-detail/generator/codesmith/api/handlebars.md +56 -0
  114. package/zh/guides/topic-detail/generator/codesmith/api/json.md +58 -0
  115. package/zh/guides/topic-detail/generator/codesmith/api/npm.md +45 -0
  116. package/zh/guides/topic-detail/generator/codesmith/develop.md +52 -0
  117. package/zh/guides/topic-detail/generator/codesmith/introduce.md +42 -1
  118. package/zh/guides/topic-detail/generator/codesmith/run-in-js.md +48 -0
  119. package/zh/guides/topic-detail/generator/codesmith/structure.md +86 -0
  120. package/zh/guides/topic-detail/generator/config/mwa.md +4 -8
  121. package/zh/guides/topic-detail/generator/plugin/api/file/addFile.md +1 -1
  122. package/zh/guides/topic-detail/generator/plugin/api/file/addHelper.md +1 -1
  123. package/zh/guides/topic-detail/generator/plugin/api/file/addPartial.md +2 -2
  124. package/zh/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -1
  125. package/zh/guides/topic-detail/generator/plugin/api/file/rmDir.md +1 -1
  126. package/zh/guides/topic-detail/generator/plugin/api/file/rmFile.md +1 -1
  127. package/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +3 -2
  128. package/zh/guides/topic-detail/generator/plugin/api/file/updateModernConfig.md +2 -2
  129. package/zh/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.md +1 -1
  130. package/zh/guides/topic-detail/generator/plugin/api/hook/afterForged.md +3 -3
  131. package/zh/guides/topic-detail/generator/plugin/api/hook/onForged.md +3 -3
  132. package/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +1 -1
  133. package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +1 -1
  134. package/zh/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
  135. package/zh/guides/topic-detail/generator/plugin/api/new/createElement.md +1 -1
  136. package/zh/guides/topic-detail/generator/plugin/api/new/createSubProject.md +1 -1
  137. package/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.md +1 -1
  138. package/zh/guides/topic-detail/generator/plugin/api/npm/install.md +1 -1
  139. package/zh/guides/topic-detail/generator/plugin/develop.md +11 -7
  140. package/zh/guides/topic-detail/monorepo/sub-project-interface.md +0 -2
  141. package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +2 -2
  142. package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +0 -8
  143. package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +15 -7
  144. package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +1 -1
  145. package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +1 -5
  146. package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +0 -8
  147. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/env.md +0 -72
  148. package/zh/apis/app/runtime/env.md +0 -70
  149. package/zh/components/deploy.md +0 -60
  150. package/zh/components/dev-ide.md +0 -1
  151. package/zh/components/entry-name.md +0 -15
  152. package/zh/components/env-prepare.md +0 -1
  153. package/zh/components/launch-bff-choices.md +0 -6
  154. package/zh/guides/advanced-features/bff/bff-server.md +0 -142
  155. package/zh/guides/advanced-features/typescript.md +0 -4
  156. package/zh/guides/concept/integrated.md +0 -4
  157. package/zh/guides/concept/solutions.md +0 -4
@@ -0,0 +1,56 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # addInputBefore
6
+
7
+ Add input question before default input.
8
+
9
+ The method is available directly on the context.
10
+
11
+ Its type is defined as:
12
+
13
+ ```ts
14
+ export interface IPluginContext {
15
+ addInputBefore: (key: string, input: Schema) => void;
16
+ ...
17
+ }
18
+ ```
19
+
20
+ ## key
21
+
22
+ Modern.js the problem keyword of the configuration of the engineering solution, the specific configuration viewable [Generator Configuration](/docs/guides/topic-detail/generator/config/common).
23
+
24
+ ## input
25
+
26
+ Questions that need to be added, specific type definition viewable [Customize input related type definition](/docs/guides/topic-detail/generator/plugin/api/input/type).
27
+
28
+ ## Example
29
+
30
+ Add input before package management tool:
31
+
32
+ ```ts
33
+ context.addInputBefore('packageManager', {
34
+ type: 'object',
35
+ properties: {
36
+ language: {
37
+ type: 'string',
38
+ title: 'Develop Langauge',
39
+ enum: [
40
+ { label: 'TS', value: 'ts' },
41
+ { label: 'ES6+', value: 'js' },
42
+ ],
43
+ },
44
+ },
45
+ })
46
+ ```
47
+
48
+ :::info Notes
49
+ 1. The key of the added question cannot be duplicated with the key of the question of the item type itself provided by the Modern.js.
50
+
51
+
52
+ 2. The priority of adding the problem `addInputAfter` is higher than `addInputBefore`. When adding After problem to one `key` and Before problem to the next key at the same time, After problem will be before Before.
53
+
54
+
55
+ 3. When multiple questions need to be added before or after the same `key`, the method can be called multiple times, and the order of questions will be permutated in the order in which they are called.
56
+ :::
@@ -0,0 +1,42 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # setInput
6
+
7
+ Set the problem attribute.
8
+
9
+ The method is available directly on the context.
10
+
11
+ Its type is defined as:
12
+
13
+ ```ts
14
+ export interface IPluginContext {
15
+ setInput: (key: string, field: string, value: unknown) => void;
16
+ ...
17
+ }
18
+ ```
19
+
20
+ ## key
21
+
22
+ The problem keyword can be the problem keyword of the Modern.js project solution, or the keyword of the new problem in the generator plugin.
23
+
24
+ ## filed
25
+
26
+ he problem field to be set, you can modify other fields except the key of the current Input, Input specific type definition viewable [Customize input related type definition](/docs/guides/topic-detail/generator/plugin/api/input/type).
27
+
28
+ ## value
29
+
30
+ The value of the problem field to be setted. value supports function, the function parameter is the current field value, and the return value needs to be the complete new field value.
31
+
32
+ :::info
33
+ For the input options provided by the Modern.js project type, only delete is temporarily supported, and increase is not supported. The increase will cause problems in the logical judgment in the code.
34
+ :::
35
+
36
+ ## Example
37
+
38
+ Modify the display name of `packageName`:
39
+
40
+ ```ts
41
+ context.setInput('packageName', 'title', "Show title");
42
+ ```
@@ -0,0 +1,30 @@
1
+ ---
2
+ sidebar_position: 7
3
+ ---
4
+
5
+ # setInputValue
6
+
7
+ Sets the input default value.
8
+
9
+ The method is available directly on the context.
10
+
11
+ Its type is defined as:
12
+
13
+ ```ts
14
+ export interface IPluginContext {
15
+ setInputValue: (value: Record<string, unknown>) => void;
16
+ ...
17
+ }
18
+ ```
19
+
20
+ ## Example
21
+
22
+ ```ts
23
+ context.setInputValue({
24
+ moduleRunWay: 'no',
25
+ });
26
+ ```
27
+
28
+ :::warning
29
+ This method only supports setting the configuration parameter value corresponding to the project solution integrated by the generator plugin, and does not support setting the project solution type (solution) and project scene (scenes). These two configurations can be set by the `--config` parameter at execution default value.
30
+ :::
@@ -0,0 +1,65 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Customize input related type definition
6
+
7
+ ## Input
8
+
9
+ Modern.js Input input type uses the open source [Formily](https://formilyjs.org/) Schema, with support for some of its Schema fields.
10
+
11
+ ### type
12
+
13
+ schema types. Currently, the input supported by the generator plugin is of type `string`, `number` and `object`. Where `object` is used for implementation schema nested, it needs to be used in conjunction with `properties`.
14
+
15
+ ### name
16
+
17
+ schema keyword.
18
+
19
+ ### title
20
+
21
+ schema display name.
22
+
23
+ ### default
24
+
25
+ schema default value.
26
+
27
+ ### enum
28
+
29
+ If the schema is selection type, this field is used to define the option content.
30
+
31
+ Each option supports two fields:
32
+
33
+ - value: option value.
34
+
35
+ - label: display name.
36
+
37
+ ### x-validate
38
+
39
+ schema verification rules. Formily's verification method is supported here, for details, please refer to [Formily Validate](https://formilyjs.org/zh-CN/guide/advanced/validate).
40
+
41
+ ### x-reactions
42
+
43
+ schema field linkage. Formily's linkage method is supported here, for details, please refer to [Formily Linkages](https://formilyjs.org/zh-CN/guide/advanced/linkages).
44
+
45
+ ### properties
46
+
47
+ When schema type is `object`, define its subforms.
48
+
49
+ ## Example
50
+
51
+ ```typescript
52
+ const schema = {
53
+ type: 'object',
54
+ properties: {
55
+ language: {
56
+ type: 'string',
57
+ title: 'Develop Langauge',
58
+ enum: [
59
+ { label: 'TS', value: 'ts' },
60
+ { label: 'ES6+', value: 'js' },
61
+ ],
62
+ },
63
+ },
64
+ };
65
+ ```
@@ -0,0 +1,91 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Introduction
6
+
7
+ Modern.js supports the customization of the provided engineering solutions by means of generator plugins or the customization of specific scenarios for engineering solutions.
8
+
9
+ ## Generator plugin composition
10
+
11
+ The generator plugin is a module that can be developed directly using Modern.js module engineering solutions. Of course, Modern.js also provides the corresponding generator plugin (`@modern-js/generator-plugin-plugin`) to directly create a new generator plugin project.
12
+
13
+
14
+ A generator plugin project directory is as follows:
15
+
16
+ ```bash
17
+ .
18
+ ├── README.md
19
+ ├── package.json
20
+ ├── src
21
+ │ ├── index.ts
22
+ │ └── modern-app-env.d.ts
23
+ ├── templates
24
+ └── tsconfig.json
25
+ ```
26
+
27
+ The `src/index.ts` is the source code directory, which is used to develop the generator plugin logic. The plugin exports a function by default, and the function parameter is `context`. Some methods are provided on the `context` to directly operate the current project. These methods will be introduced in detail later in this chapter.
28
+
29
+ The `templates` directory is the template directory used to store template files that need to be used in the generator plugin.
30
+
31
+ ## Classification
32
+
33
+ There are two types of generator plugins:
34
+
35
+ 1. Extended engineering: directly customize the three major engineering provided by default.
36
+
37
+ 2. Create engineering scenes: Create corresponding engineering scenes based on the default three major engineering schemes.
38
+
39
+ ### Type definition
40
+
41
+ The classification of the generator plugin is provided by the meta information in the `package.json`.
42
+
43
+ #### Extended engineering
44
+
45
+ ```json
46
+ {
47
+ "meta": {
48
+ "extend": "mwa" // The three engineering is mwa, module, monorepo
49
+ }
50
+ }
51
+ ```
52
+
53
+ #### Create engineering scenes
54
+
55
+ ```json
56
+ {
57
+ "meta": {
58
+ "key": "new_solution",
59
+ "name": "New Solution",
60
+ "type": "mwa" // In addition to the three major engineering solutions, the type here also supports the customize (custom) type
61
+ }
62
+ }
63
+ ```
64
+
65
+ `key` is the scene scheme name and the value is a character string.
66
+ `name` is the display name of the scene scheme, used for the display of the option when used, and the value is a character string.
67
+ `type` is the project solution type. In addition to supporting three project solutions like `extend`, it also supports the customize (custom) type.
68
+
69
+ ### Custom type
70
+
71
+ The customize type provides the implementation capability of the full custom project solution. When using this type to create a new project solution scenario, only a small amount of code for best practices at the development level is provided, such as `.gitignore`, `.editorConfig` and other files, specifically for the following directory structure:
72
+
73
+ ```
74
+ .
75
+ ├── .editorconfig
76
+ ├── .gitignore
77
+ ├── .idea
78
+ │ ├── codeStyles
79
+ │ │ ├── Project.xml
80
+ │ │ └── codeStyleConfig.xml
81
+ │ ├── inspectionProfiles
82
+ │ │ └── Project_Default.xml
83
+ │ └── jsLinters
84
+ │ └── eslint.xml
85
+ ├── .nvmrc
86
+ └── .vscode
87
+ ├── extensions.json
88
+ └── settings.json
89
+ ```
90
+
91
+ Customized types ensure flexible configuration according to their needs for engineering solutions.
@@ -0,0 +1,4 @@
1
+ {
2
+ "label": "Enable function API",
3
+ "position": 6
4
+ }
@@ -0,0 +1,33 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # createElement
6
+
7
+ Create engineering elements that only support application 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 ActionElement {
15
+ Entry = 'entry',
16
+ Server = 'server',
17
+ }
18
+ export type ForgedAPI = {
19
+ createElement: (
20
+ element: ActionElement,
21
+ params: Record<string, unknown>,
22
+ ) => Promise<void>;
23
+ ...
24
+ };
25
+ ```
26
+
27
+ ## element
28
+
29
+ Project element type, supports entry and server.
30
+
31
+ ## params
32
+
33
+ For other parameters of creating elements, please refer to[MWA New Command](/docs/guides/topic-detail/generator/config/mwa).
@@ -0,0 +1,35 @@
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](/docs/guides/topic-detail/generator/config/monorepo).
@@ -0,0 +1,44 @@
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[MWA New Command](/docs/guides/topic-detail/generator/config/mwa)和[Module New Command](/docs/guides/topic-detail/generator/config/module).
@@ -0,0 +1,15 @@
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
+ - [MWA](/docs/guides/topic-detail/generator/config/mwa)
12
+
13
+ - [Module](/docs/guides/topic-detail/generator/config/module)
14
+
15
+ - [Monorepo](/docs/guides/topic-detail/generator/config/monorepo)
@@ -0,0 +1,18 @@
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 management tool 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
+ ```
@@ -0,0 +1,125 @@
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 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 Module Solution
21
+ ? Please select the scene you want to create 生成器插件
22
+ ? Plugin Package Name plugin
23
+ ? Development Language TS
24
+ ? Package Management Tool pnpm
25
+ ? Plugin Type extend
26
+ ? Plugin Base Type MWA Solution
27
+ ```
28
+
29
+ ### Customized type
30
+
31
+ ```
32
+ ? Plugin Package Name plugin
33
+ ? Development Language TS
34
+ ? Package Management Tool pnpm
35
+ ? Plugin Type custom
36
+ ? Plugin Key mobile-app
37
+ ? Plugin Show Name Mobile App
38
+ ? Plugin Base Type MWA Solution
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/modern-js-dev/modern.js/tree/main/packages/generator/plugins/generator-plugin)
45
+ :::
46
+
47
+ ## Develop plugin logic
48
+
49
+ Complete plugin logic development in `src/index.ts`.
50
+
51
+ 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.
52
+
53
+
54
+ A brief introduction to the provided methods, the complete API list viewable [Generator Plugin API](/docs/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 management tool` question.
61
+
62
+ Specific Modern.js configuration viewable for each problem [Project Solution Configuration](/docs/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](/docs/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] (/docs/guides/topic-detail/generator/plugin/api/hook/afterForged).
@@ -0,0 +1,61 @@
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 --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.