@lakutata/cli 1.0.37 → 2.1.0-alpha.5

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 (234) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +6 -26
  3. package/dist/CLIApp.d.ts +3 -0
  4. package/dist/CLIApp.d.ts.map +1 -0
  5. package/dist/CLIApp.js +75 -0
  6. package/dist/controllers/CommandLineController.d.ts +20 -0
  7. package/dist/controllers/CommandLineController.d.ts.map +1 -0
  8. package/dist/controllers/CommandLineController.js +61 -0
  9. package/dist/lib/ProjectTypeConfig.d.ts +8 -0
  10. package/dist/lib/ProjectTypeConfig.d.ts.map +1 -0
  11. package/dist/lib/ProjectTypeConfig.js +17 -0
  12. package/dist/lib/SpecialChar.d.ts +9 -0
  13. package/dist/lib/SpecialChar.d.ts.map +1 -0
  14. package/dist/lib/SpecialChar.js +11 -0
  15. package/dist/lib/components/DeGitPuller.d.ts +19 -0
  16. package/dist/lib/components/DeGitPuller.d.ts.map +1 -0
  17. package/dist/lib/components/DeGitPuller.js +65 -0
  18. package/dist/lib/components/Spinner.d.ts +23 -0
  19. package/dist/lib/components/Spinner.d.ts.map +1 -0
  20. package/dist/lib/components/Spinner.js +61 -0
  21. package/dist/lib/providers/Creator.d.ts +38 -0
  22. package/dist/lib/providers/Creator.d.ts.map +1 -0
  23. package/dist/lib/providers/Creator.js +142 -0
  24. package/dist/lib/providers/Information.d.ts +91 -0
  25. package/dist/lib/providers/Information.d.ts.map +1 -0
  26. package/dist/lib/providers/Information.js +222 -0
  27. package/dist/options/CreateProjectOptions.d.ts +15 -0
  28. package/dist/options/CreateProjectOptions.d.ts.map +1 -0
  29. package/dist/options/CreateProjectOptions.js +86 -0
  30. package/dist/options/LakutataInfoOptions.d.ts +4 -0
  31. package/dist/options/LakutataInfoOptions.d.ts.map +1 -0
  32. package/dist/options/LakutataInfoOptions.js +7 -0
  33. package/package.json +31 -56
  34. package/tsconfig.json +3 -33
  35. package/.eslintrc.json +0 -47
  36. package/.idea/codeStyles/Project.xml +0 -18
  37. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  38. package/.idea/dbnavigator.xml +0 -457
  39. package/.idea/inspectionProfiles/Project_Default.xml +0 -10
  40. package/.idea/lakutata-cli.iml +0 -14
  41. package/.idea/modules.xml +0 -8
  42. package/.idea/vcs.xml +0 -6
  43. package/LICENSE +0 -21
  44. package/assets/lakutata-banner.png +0 -0
  45. package/assets/lakutata_logo.jpg +0 -0
  46. package/build/CLI.d.ts +0 -2
  47. package/build/CLI.js +0 -13
  48. package/build/CLI.js.map +0 -1
  49. package/build/Deploy.d.ts +0 -1
  50. package/build/Deploy.js +0 -129
  51. package/build/Deploy.js.map +0 -1
  52. package/build/constants/GitIgnore.d.ts +0 -1
  53. package/build/constants/GitIgnore.js +0 -157
  54. package/build/constants/GitIgnore.js.map +0 -1
  55. package/build/constants/LicenseList.d.ts +0 -4
  56. package/build/constants/LicenseList.js +0 -68
  57. package/build/constants/LicenseList.js.map +0 -1
  58. package/build/interfaces/IApplicationInfo.d.ts +0 -4
  59. package/build/interfaces/IApplicationInfo.js +0 -3
  60. package/build/interfaces/IApplicationInfo.js.map +0 -1
  61. package/build/interfaces/IComponentInfo.d.ts +0 -4
  62. package/build/interfaces/IComponentInfo.js +0 -3
  63. package/build/interfaces/IComponentInfo.js.map +0 -1
  64. package/build/interfaces/IGenerator.d.ts +0 -3
  65. package/build/interfaces/IGenerator.js +0 -3
  66. package/build/interfaces/IGenerator.js.map +0 -1
  67. package/build/interfaces/IModuleInfo.d.ts +0 -4
  68. package/build/interfaces/IModuleInfo.js +0 -3
  69. package/build/interfaces/IModuleInfo.js.map +0 -1
  70. package/build/interfaces/IPluginInfo.d.ts +0 -4
  71. package/build/interfaces/IPluginInfo.js +0 -3
  72. package/build/interfaces/IPluginInfo.js.map +0 -1
  73. package/build/interfaces/IPreparePackageConfigOptions.d.ts +0 -19
  74. package/build/interfaces/IPreparePackageConfigOptions.js +0 -3
  75. package/build/interfaces/IPreparePackageConfigOptions.js.map +0 -1
  76. package/build/interfaces/IProjectGeneratorOptions.d.ts +0 -16
  77. package/build/interfaces/IProjectGeneratorOptions.js +0 -3
  78. package/build/interfaces/IProjectGeneratorOptions.js.map +0 -1
  79. package/build/interfaces/IProjectInfo.d.ts +0 -14
  80. package/build/interfaces/IProjectInfo.js +0 -3
  81. package/build/interfaces/IProjectInfo.js.map +0 -1
  82. package/build/lib/LatestVersion.d.ts +0 -1
  83. package/build/lib/LatestVersion.js +0 -13
  84. package/build/lib/LatestVersion.js.map +0 -1
  85. package/build/lib/generators/application/ApplicationGenerator.d.ts +0 -18
  86. package/build/lib/generators/application/ApplicationGenerator.js +0 -84
  87. package/build/lib/generators/application/ApplicationGenerator.js.map +0 -1
  88. package/build/lib/generators/application/files/AppFile.d.ts +0 -8
  89. package/build/lib/generators/application/files/AppFile.js +0 -36
  90. package/build/lib/generators/application/files/AppFile.js.map +0 -1
  91. package/build/lib/generators/application/files/ConfigFile.d.ts +0 -9
  92. package/build/lib/generators/application/files/ConfigFile.js +0 -81
  93. package/build/lib/generators/application/files/ConfigFile.js.map +0 -1
  94. package/build/lib/generators/component/ComponentGenerator.d.ts +0 -17
  95. package/build/lib/generators/component/ComponentGenerator.js +0 -75
  96. package/build/lib/generators/component/ComponentGenerator.js.map +0 -1
  97. package/build/lib/generators/component/files/ComponentFile.d.ts +0 -8
  98. package/build/lib/generators/component/files/ComponentFile.js +0 -45
  99. package/build/lib/generators/component/files/ComponentFile.js.map +0 -1
  100. package/build/lib/generators/component/files/ComponentTestFile.d.ts +0 -8
  101. package/build/lib/generators/component/files/ComponentTestFile.js +0 -35
  102. package/build/lib/generators/component/files/ComponentTestFile.js.map +0 -1
  103. package/build/lib/generators/module/ModuleGenerator.d.ts +0 -17
  104. package/build/lib/generators/module/ModuleGenerator.js +0 -85
  105. package/build/lib/generators/module/ModuleGenerator.js.map +0 -1
  106. package/build/lib/generators/module/files/ModuleFile.d.ts +0 -8
  107. package/build/lib/generators/module/files/ModuleFile.js +0 -116
  108. package/build/lib/generators/module/files/ModuleFile.js.map +0 -1
  109. package/build/lib/generators/module/files/ModuleTestFile.d.ts +0 -8
  110. package/build/lib/generators/module/files/ModuleTestFile.js +0 -35
  111. package/build/lib/generators/module/files/ModuleTestFile.js.map +0 -1
  112. package/build/lib/generators/plugin/PluginGenerator.d.ts +0 -17
  113. package/build/lib/generators/plugin/PluginGenerator.js +0 -75
  114. package/build/lib/generators/plugin/PluginGenerator.js.map +0 -1
  115. package/build/lib/generators/plugin/files/PluginFile.d.ts +0 -8
  116. package/build/lib/generators/plugin/files/PluginFile.js +0 -50
  117. package/build/lib/generators/plugin/files/PluginFile.js.map +0 -1
  118. package/build/lib/generators/plugin/files/PluginTestFile.d.ts +0 -8
  119. package/build/lib/generators/plugin/files/PluginTestFile.js +0 -35
  120. package/build/lib/generators/plugin/files/PluginTestFile.js.map +0 -1
  121. package/build/lib/generators/project/ProjectGenerator.d.ts +0 -27
  122. package/build/lib/generators/project/ProjectGenerator.js +0 -157
  123. package/build/lib/generators/project/ProjectGenerator.js.map +0 -1
  124. package/build/lib/generators/project/ProjectSourceFile.d.ts +0 -5
  125. package/build/lib/generators/project/ProjectSourceFile.js +0 -7
  126. package/build/lib/generators/project/ProjectSourceFile.js.map +0 -1
  127. package/build/lib/generators/project/configs/ProjectEslintrcConfig.d.ts +0 -37
  128. package/build/lib/generators/project/configs/ProjectEslintrcConfig.js +0 -51
  129. package/build/lib/generators/project/configs/ProjectEslintrcConfig.js.map +0 -1
  130. package/build/lib/generators/project/configs/ProjectPackageConfig.d.ts +0 -1
  131. package/build/lib/generators/project/configs/ProjectPackageConfig.js +0 -32
  132. package/build/lib/generators/project/configs/ProjectPackageConfig.js.map +0 -1
  133. package/build/lib/generators/project/configs/ProjectTypescriptConfig.d.ts +0 -25
  134. package/build/lib/generators/project/configs/ProjectTypescriptConfig.js +0 -39
  135. package/build/lib/generators/project/configs/ProjectTypescriptConfig.js.map +0 -1
  136. package/build/lib/manipulators/CreateComponentManipulator.d.ts +0 -3
  137. package/build/lib/manipulators/CreateComponentManipulator.js +0 -71
  138. package/build/lib/manipulators/CreateComponentManipulator.js.map +0 -1
  139. package/build/lib/manipulators/CreateDockerFileManipulator.d.ts +0 -3
  140. package/build/lib/manipulators/CreateDockerFileManipulator.js +0 -124
  141. package/build/lib/manipulators/CreateDockerFileManipulator.js.map +0 -1
  142. package/build/lib/manipulators/CreateModuleManipulator.d.ts +0 -3
  143. package/build/lib/manipulators/CreateModuleManipulator.js +0 -142
  144. package/build/lib/manipulators/CreateModuleManipulator.js.map +0 -1
  145. package/build/lib/manipulators/CreatePluginManipulator.d.ts +0 -3
  146. package/build/lib/manipulators/CreatePluginManipulator.js +0 -76
  147. package/build/lib/manipulators/CreatePluginManipulator.js.map +0 -1
  148. package/build/lib/manipulators/CreateProcessManipulator.d.ts +0 -3
  149. package/build/lib/manipulators/CreateProcessManipulator.js +0 -61
  150. package/build/lib/manipulators/CreateProcessManipulator.js.map +0 -1
  151. package/build/lib/manipulators/CreateThreadManipulator.d.ts +0 -3
  152. package/build/lib/manipulators/CreateThreadManipulator.js +0 -61
  153. package/build/lib/manipulators/CreateThreadManipulator.js.map +0 -1
  154. package/build/lib/manipulators/application/ApplicationIndexManipulator.d.ts +0 -1
  155. package/build/lib/manipulators/application/ApplicationIndexManipulator.js +0 -162
  156. package/build/lib/manipulators/application/ApplicationIndexManipulator.js.map +0 -1
  157. package/build/lib/menus/MainMenu.d.ts +0 -1
  158. package/build/lib/menus/MainMenu.js +0 -160
  159. package/build/lib/menus/MainMenu.js.map +0 -1
  160. package/build/lib/menus/initializeMenus/InitializeApplicationProject.d.ts +0 -1
  161. package/build/lib/menus/initializeMenus/InitializeApplicationProject.js +0 -93
  162. package/build/lib/menus/initializeMenus/InitializeApplicationProject.js.map +0 -1
  163. package/build/lib/menus/initializeMenus/InitializeComponentProject.d.ts +0 -1
  164. package/build/lib/menus/initializeMenus/InitializeComponentProject.js +0 -93
  165. package/build/lib/menus/initializeMenus/InitializeComponentProject.js.map +0 -1
  166. package/build/lib/menus/initializeMenus/InitializeModuleProject.d.ts +0 -1
  167. package/build/lib/menus/initializeMenus/InitializeModuleProject.js +0 -93
  168. package/build/lib/menus/initializeMenus/InitializeModuleProject.js.map +0 -1
  169. package/build/lib/menus/initializeMenus/InitializePluginProject.d.ts +0 -1
  170. package/build/lib/menus/initializeMenus/InitializePluginProject.js +0 -93
  171. package/build/lib/menus/initializeMenus/InitializePluginProject.js.map +0 -1
  172. package/build/lib/menus/manipulateMenus/ManipulateApplicationProject.d.ts +0 -1
  173. package/build/lib/menus/manipulateMenus/ManipulateApplicationProject.js +0 -60
  174. package/build/lib/menus/manipulateMenus/ManipulateApplicationProject.js.map +0 -1
  175. package/build/lib/menus/manipulateMenus/ManipulateComponentProject.d.ts +0 -1
  176. package/build/lib/menus/manipulateMenus/ManipulateComponentProject.js +0 -9
  177. package/build/lib/menus/manipulateMenus/ManipulateComponentProject.js.map +0 -1
  178. package/build/lib/menus/manipulateMenus/ManipulateModuleProject.d.ts +0 -1
  179. package/build/lib/menus/manipulateMenus/ManipulateModuleProject.js +0 -49
  180. package/build/lib/menus/manipulateMenus/ManipulateModuleProject.js.map +0 -1
  181. package/build/lib/menus/manipulateMenus/ManipulatePluginProject.d.ts +0 -1
  182. package/build/lib/menus/manipulateMenus/ManipulatePluginProject.js +0 -9
  183. package/build/lib/menus/manipulateMenus/ManipulatePluginProject.js.map +0 -1
  184. package/src/CLI.ts +0 -7
  185. package/src/Deploy.ts +0 -124
  186. package/src/constants/GitIgnore.ts +0 -153
  187. package/src/constants/LicenseList.ts +0 -64
  188. package/src/interfaces/IApplicationInfo.ts +0 -5
  189. package/src/interfaces/IComponentInfo.ts +0 -5
  190. package/src/interfaces/IGenerator.ts +0 -3
  191. package/src/interfaces/IModuleInfo.ts +0 -5
  192. package/src/interfaces/IPluginInfo.ts +0 -5
  193. package/src/interfaces/IPreparePackageConfigOptions.ts +0 -11
  194. package/src/interfaces/IProjectGeneratorOptions.ts +0 -15
  195. package/src/interfaces/IProjectInfo.ts +0 -10
  196. package/src/lib/LatestVersion.ts +0 -6
  197. package/src/lib/generators/application/ApplicationGenerator.ts +0 -97
  198. package/src/lib/generators/application/files/AppFile.ts +0 -35
  199. package/src/lib/generators/application/files/ConfigFile.ts +0 -82
  200. package/src/lib/generators/component/ComponentGenerator.ts +0 -87
  201. package/src/lib/generators/component/files/ComponentFile.ts +0 -45
  202. package/src/lib/generators/component/files/ComponentTestFile.ts +0 -36
  203. package/src/lib/generators/module/ModuleGenerator.ts +0 -97
  204. package/src/lib/generators/module/files/ModuleFile.ts +0 -116
  205. package/src/lib/generators/module/files/ModuleTestFile.ts +0 -36
  206. package/src/lib/generators/plugin/PluginGenerator.ts +0 -87
  207. package/src/lib/generators/plugin/files/PluginFile.ts +0 -50
  208. package/src/lib/generators/plugin/files/PluginTestFile.ts +0 -36
  209. package/src/lib/generators/project/ProjectGenerator.ts +0 -205
  210. package/src/lib/generators/project/ProjectSourceFile.ts +0 -7
  211. package/src/lib/generators/project/configs/ProjectEslintrcConfig.ts +0 -47
  212. package/src/lib/generators/project/configs/ProjectPackageConfig.ts +0 -28
  213. package/src/lib/generators/project/configs/ProjectTypescriptConfig.ts +0 -35
  214. package/src/lib/manipulators/CreateComponentManipulator.ts +0 -66
  215. package/src/lib/manipulators/CreateDockerFileManipulator.ts +0 -121
  216. package/src/lib/manipulators/CreateModuleManipulator.ts +0 -137
  217. package/src/lib/manipulators/CreatePluginManipulator.ts +0 -71
  218. package/src/lib/manipulators/CreateProcessManipulator.ts +0 -56
  219. package/src/lib/manipulators/CreateThreadManipulator.ts +0 -56
  220. package/src/lib/manipulators/application/ApplicationIndexManipulator.ts +0 -169
  221. package/src/lib/menus/MainMenu.ts +0 -148
  222. package/src/lib/menus/initializeMenus/InitializeApplicationProject.ts +0 -84
  223. package/src/lib/menus/initializeMenus/InitializeComponentProject.ts +0 -84
  224. package/src/lib/menus/initializeMenus/InitializeModuleProject.ts +0 -84
  225. package/src/lib/menus/initializeMenus/InitializePluginProject.ts +0 -84
  226. package/src/lib/menus/manipulateMenus/ManipulateApplicationProject.ts +0 -60
  227. package/src/lib/menus/manipulateMenus/ManipulateComponentProject.ts +0 -13
  228. package/src/lib/menus/manipulateMenus/ManipulateModuleProject.ts +0 -49
  229. package/src/lib/menus/manipulateMenus/ManipulatePluginProject.ts +0 -13
  230. package/src/tests/generators/GenerateApplication.spec.ts +0 -16
  231. package/src/tests/generators/GenerateComponent.spec.ts +0 -16
  232. package/src/tests/generators/GenerateModule.spec.ts +0 -16
  233. package/src/tests/generators/GeneratePlugin.spec.ts +0 -16
  234. package/typings.d.ts +0 -4
@@ -1,169 +0,0 @@
1
- import {
2
- Identifier,
3
- ObjectLiteralExpression,
4
- Project,
5
- PropertyAssignment,
6
- SourceFile, StructureKind,
7
- Symbol
8
- } from 'ts-morph'
9
-
10
- /**
11
- * 更新项目索引
12
- * @param projectPath
13
- * @param tsConfigFilePath
14
- * @param configuration
15
- * @constructor
16
- */
17
- export async function ApplicationIndexManipulator(projectPath: string, tsConfigFilePath: string, configuration: string) {
18
- const project = new Project({
19
- tsConfigFilePath: tsConfigFilePath
20
- })
21
- project.addSourceFilesAtPaths(projectPath)
22
- if (!project.getSourceFile(configuration)) return console.error('项目读取错误: 项目配置文件未找到')
23
- const configFile: SourceFile = project.getSourceFile(configuration) as SourceFile
24
- const moduleDeclaration = configFile.getModule(`'@lakutata/core'`)
25
- if (!moduleDeclaration) return console.error('项目读取错误: 模块声明未找到')
26
- const configFunction = configFile.getFunction('Config')
27
- if (!configFunction) return console.error('项目读取错误: 配置方法未找到')
28
- const applicationInterface = moduleDeclaration.getInterface('Application')
29
- if (!applicationInterface) return console.error('项目读取错误: 程序声明未找到')
30
- moduleDeclaration.removeBody()
31
- const componentMap: Map<string, string> = new Map()
32
- const moduleMap: Map<string, string> = new Map()
33
- configFunction.getChildren().forEach(node => {
34
- if (node.getKindName() === 'Block') {
35
- node.getDescendantStatements().forEach(statement => {
36
- if (statement.getKindName() === 'ReturnStatement') {
37
- statement.forEachChild(childNode => {
38
- if (childNode.getKindName() === 'ObjectLiteralExpression') {
39
- const OLE: ObjectLiteralExpression = childNode as ObjectLiteralExpression
40
- if (OLE.getProperty('components')) {
41
- const components: PropertyAssignment = OLE.getProperty('components') as PropertyAssignment
42
- components.forEachChild(componentNode => {
43
- if (componentNode.getKindName() === 'ObjectLiteralExpression') {
44
- const COLE: ObjectLiteralExpression = componentNode as ObjectLiteralExpression
45
- COLE.forEachChild(COLENode => {
46
- const COLENodePropertyAssignment: PropertyAssignment = COLENode as PropertyAssignment
47
- //组件名称
48
- let componentName: string | null = null
49
- let componentClassName: string | null = null
50
- COLENodePropertyAssignment.forEachChild(COLENodePropertyAssignmentNode => {
51
- if (COLENodePropertyAssignmentNode.getKindName() === 'Identifier') {
52
- const identifier: Identifier = COLENodePropertyAssignmentNode as Identifier
53
- const symbol = identifier.getSymbol() as Symbol
54
- if (!componentName) {
55
- //获取组件名称
56
- componentName = symbol.getName()
57
- } else {
58
- //获取组件类名
59
- componentClassName = symbol.getName()
60
- }
61
- } else if (COLENodePropertyAssignmentNode.getKindName() === 'ObjectLiteralExpression') {
62
- const componentObjectLiteralExpression: ObjectLiteralExpression = COLENodePropertyAssignmentNode as ObjectLiteralExpression
63
- componentObjectLiteralExpression.forEachChild(item => {
64
- if (item.getKindName() === 'PropertyAssignment') {
65
- const componentConfigItem: PropertyAssignment = item as PropertyAssignment
66
- const keyName = (componentConfigItem.getSymbol() as Symbol).getName()
67
- if (keyName === 'class') {
68
- const initializer = componentConfigItem.getStructure().initializer
69
- if (typeof initializer === 'string') {
70
- componentClassName = initializer
71
- }
72
- }
73
- }
74
- })
75
- }
76
- })
77
- if (componentName && componentClassName) {
78
- componentMap.set(componentName, componentClassName)
79
- }
80
- })
81
- }
82
- })
83
- }
84
- if (OLE.getProperty('modules')) {
85
- const modules: PropertyAssignment = OLE.getProperty('modules') as PropertyAssignment
86
- modules.forEachChild(moduleNode => {
87
- if (moduleNode.getKindName() === 'ObjectLiteralExpression') {
88
- const MOLE: ObjectLiteralExpression = moduleNode as ObjectLiteralExpression
89
- MOLE.forEachChild(MOLENode => {
90
- const MOLENodePropertyAssignment: PropertyAssignment = MOLENode as PropertyAssignment
91
- //模块名称
92
- let moduleName: string | null = null
93
- let moduleClassName: string | null = null
94
- MOLENodePropertyAssignment.forEachChild(MOLENodePropertyAssignmentNode => {
95
- if (MOLENodePropertyAssignmentNode.getKindName() === 'Identifier') {
96
- //获取模块名称
97
- const identifier: Identifier = MOLENodePropertyAssignmentNode as Identifier
98
- const symbol = identifier.getSymbol() as Symbol
99
- moduleName = symbol.getName()
100
- } else if (MOLENodePropertyAssignmentNode.getKindName() === 'ObjectLiteralExpression') {
101
- const moduleObjectLiteralExpression: ObjectLiteralExpression = MOLENodePropertyAssignmentNode as ObjectLiteralExpression
102
- moduleObjectLiteralExpression.forEachChild(item => {
103
- if (item.getKindName() === 'PropertyAssignment') {
104
- const moduleConfigItem: PropertyAssignment = item as PropertyAssignment
105
- const keyName = (moduleConfigItem.getSymbol() as Symbol).getName()
106
- if (keyName === 'class') {
107
- const initializer = moduleConfigItem.getStructure().initializer
108
- if (typeof initializer === 'string') {
109
- moduleClassName = initializer
110
- }
111
- }
112
- }
113
- })
114
- }
115
- })
116
- if (moduleName && moduleClassName) {
117
- moduleMap.set(moduleName, moduleClassName)
118
- }
119
- })
120
- }
121
- })
122
- }
123
- }
124
- })
125
- }
126
- })
127
- }
128
- })
129
- moduleDeclaration.addStatements([{
130
- kind: StructureKind.Interface,
131
- name: 'Application',
132
- properties: [
133
- {
134
- name: 'Components()',
135
- kind: StructureKind.PropertySignature,
136
- leadingTrivia: 'get ',
137
- type: writer => {
138
- writer.block(() => {
139
- writer.writeLine('get:<T extends Component = Component>(name: string) => T')
140
- writer.writeLine('has:(name:string)=>boolean')
141
- componentMap.forEach((componentClassName, componentName) => {
142
- writer.writeLine(`${componentName}:${componentClassName}`)
143
- })
144
- })
145
- }
146
- },
147
- {
148
- name: 'Modules()',
149
- kind: StructureKind.PropertySignature,
150
- leadingTrivia: 'get ',
151
- type: writer => {
152
- writer.block(() => {
153
- writer.writeLine('get:<T extends Module = Module>(name: string) => T')
154
- writer.writeLine('has:(name:string)=>boolean')
155
- moduleMap.forEach((moduleClassName, moduleName) => {
156
- writer.writeLine(`${moduleName}:${moduleClassName}`)
157
- })
158
- })
159
- }
160
- }
161
- ]
162
- }])
163
- try {
164
- await project.save()
165
- console.info('索引更新成功')
166
- } catch (e) {
167
- console.error(`索引更新出错: ${(e as Error).message}`)
168
- }
169
- }
@@ -1,148 +0,0 @@
1
- import inquirer from 'inquirer'
2
- import {InitializeApplicationProject} from './initializeMenus/InitializeApplicationProject'
3
- import {InitializeModuleProject} from './initializeMenus/InitializeModuleProject'
4
- import {InitializeComponentProject} from './initializeMenus/InitializeComponentProject'
5
- import {InitializePluginProject} from './initializeMenus/InitializePluginProject'
6
- import {gt} from 'semver'
7
- import path from 'path'
8
- import fs from 'fs'
9
- import {ManipulateApplicationProject} from './manipulateMenus/ManipulateApplicationProject'
10
- import {ManipulateModuleProject} from './manipulateMenus/ManipulateModuleProject'
11
- import {ManipulateComponentProject} from './manipulateMenus/ManipulateComponentProject'
12
- import {ManipulatePluginProject} from './manipulateMenus/ManipulatePluginProject'
13
- import { LatestVersion } from '../LatestVersion'
14
-
15
- export async function MainMenu(packageJson: any) {
16
- const mainMenuOpt = await inquirer.prompt([{
17
- name: 'opr',
18
- message: `请选择需要进行的操作 (Lakutata CLI ${packageJson.version})`,
19
- type: 'list',
20
- choices: [
21
- {
22
- name: '创建Lakutata项目',
23
- value: 'initialize'
24
- },
25
- {
26
- name: '编辑Lakutata项目',
27
- value: 'manipulate'
28
- },
29
- {
30
- name: '关于Lakutata CLI',
31
- value: 'about'
32
- },
33
- {
34
- name: '检查更新',
35
- value: 'check-update'
36
- }
37
- ]
38
- }])
39
- switch (mainMenuOpt.opr) {
40
- case 'initialize': {
41
- const initializeProjectOption = await inquirer.prompt([
42
- {
43
- name: 'type',
44
- message: '请选择生成的项目类型',
45
- type: 'list',
46
- choices: [
47
- {
48
- name: '应用程序',
49
- value: 'application'
50
- },
51
- {
52
- name: '模块',
53
- value: 'module'
54
- },
55
- {
56
- name: '组件',
57
- value: 'component'
58
- },
59
- {
60
- name: '插件',
61
- value: 'plugin'
62
- }
63
- ]
64
- }, {
65
- name: 'path',
66
- message: '项目生成地址',
67
- type: 'input',
68
- default: process.cwd()
69
- }
70
- ])
71
- const projectPath: string = initializeProjectOption.path
72
- switch (initializeProjectOption.type) {
73
- case 'application': {
74
- return await InitializeApplicationProject(projectPath)
75
- }
76
- case 'module': {
77
- return await InitializeModuleProject(projectPath)
78
- }
79
- case 'component': {
80
- return await InitializeComponentProject(projectPath)
81
- }
82
- case 'plugin': {
83
- return await InitializePluginProject(projectPath)
84
- }
85
- default: {
86
- console.warn('不正确的项目类型:', initializeProjectOption.type)
87
- }
88
- }
89
- }
90
- break
91
- case 'manipulate': {
92
- const projectPath: string = process.cwd()
93
- const packageJsonPath: string = path.resolve(projectPath, './package.json')
94
- const tsconfigJsonPath: string = path.resolve(projectPath, './tsconfig.json')
95
- if (!fs.existsSync(packageJsonPath)) {
96
- return console.error('项目信息读取错误: 请在项目根目录执行该指令')
97
- }
98
- try {
99
- const projectPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, {encoding: 'utf-8'}))
100
- if (projectPackageJson.lakutata && projectPackageJson.lakutata.type) {
101
- const projectType: 'application' | 'module' | 'component' | 'plugin' = projectPackageJson.lakutata.type
102
- switch (projectType) {
103
- case 'application': {
104
- return await ManipulateApplicationProject(projectPath, tsconfigJsonPath, projectPackageJson.lakutata)
105
- }
106
- case 'module': {
107
- return await ManipulateModuleProject(projectPath, tsconfigJsonPath, projectPackageJson.lakutata)
108
- }
109
- case 'component': {
110
- return await ManipulateComponentProject(projectPath, tsconfigJsonPath, projectPackageJson.lakutata)
111
- }
112
- case 'plugin': {
113
- return ManipulatePluginProject(projectPath, tsconfigJsonPath, projectPackageJson.lakutata)
114
- }
115
- default: {
116
- return console.error(`项目信息读取错误: 无效的项目类型[${projectType}]`)
117
- }
118
- }
119
- } else {
120
- return console.error('项目信息读取错误: 无法操作非Lakutata框架的项目')
121
- }
122
- } catch (e) {
123
- return console.error(`项目信息读取错误: ${(e as Error).message}`)
124
- }
125
- return
126
- }
127
- case 'about': {
128
- console.log('Lakutata CLI - Lakutata框架辅助工具')
129
- console.log('Version:', packageJson.version)
130
- console.log('Powered by Lakutata')
131
- return
132
- }
133
- case 'check-update': {
134
- try {
135
- const localVersion: string = packageJson.version
136
- const npmVersion: string = await LatestVersion(packageJson.name.toString())
137
- if (gt(npmVersion, localVersion)) {
138
- console.info('有可用更新:', localVersion, '➡', npmVersion)
139
- console.info('执行', `npm install -g ${packageJson.name}`, '进行更新')
140
- } else {
141
- console.info('无可用更新')
142
- }
143
- } catch (e) {
144
- console.error(`检查更新失败: ${(e as Error).message}`)
145
- }
146
- }
147
- }
148
- }
@@ -1,84 +0,0 @@
1
- import inquirer from 'inquirer'
2
- import {ApplicationGenerator} from '../../generators/application/ApplicationGenerator'
3
- import {LicenseList} from '../../../constants/LicenseList'
4
- import shell from 'shelljs'
5
-
6
- export async function InitializeApplicationProject(projectPath: string) {
7
- const options = await inquirer.prompt([
8
- {
9
- name: 'id',
10
- message: '请输入应用的ID[例如:identifier.scope.app]',
11
- type: 'input'
12
- },
13
- {
14
- name: 'name',
15
- message: '请输入应用名称',
16
- type: 'input'
17
- },
18
- {
19
- name: 'author',
20
- message: '请输入作者名称',
21
- type: 'input'
22
- },
23
- {
24
- name: 'description',
25
- message: '请输入应用说明',
26
- type: 'input'
27
- },
28
- {
29
- name: 'keywords',
30
- message: '请输入应用关键词(使用逗号分隔)',
31
- type: 'input'
32
- },
33
- {
34
- name: 'license',
35
- message: '请选择应用开源许可协议',
36
- type: 'list',
37
- default: 'UNLICENSED',
38
- choices: LicenseList
39
- }
40
- ])
41
- console.info('==================================================')
42
- console.info('项目目录:', projectPath)
43
- console.info('应用的ID:', options.id)
44
- console.info('应用名称:', options.name)
45
- console.info('作者名称:', options.author)
46
- console.info('应用说明:', options.description)
47
- console.info('关键词:', options.keywords)
48
- console.info('开源许可协议:', options.license)
49
- console.info('==================================================')
50
- const confirmResult = await inquirer.prompt([
51
- {
52
- name: 'confirm',
53
- message: '请确认信息是否填写正确',
54
- type: 'confirm',
55
- default: 'Y'
56
- }
57
- ])
58
- if (confirmResult.confirm) {
59
- const applicationProject = new ApplicationGenerator({
60
- id: options.id,
61
- name: options.name,
62
- author: options.author,
63
- license: options.license,
64
- description: options.description,
65
- keywords: (() => {
66
- if (options.keywords) {
67
- return options.keywords.toString().split(',')
68
- } else {
69
- return []
70
- }
71
- })(),
72
- path: projectPath
73
- })
74
- try {
75
- console.info('正在生成项目文件')
76
- await applicationProject.generate()
77
- console.info('项目文件生成成功')
78
- shell.cd(projectPath).exec('npm install --build-from-source --unsafe-perm', {silent: true, async: false})
79
- console.info('应用初始化完成!')
80
- } catch (e) {
81
- console.error(`项目生成错误: ${(e as Error).message}`)
82
- }
83
- }
84
- }
@@ -1,84 +0,0 @@
1
- import inquirer from 'inquirer'
2
- import {ComponentGenerator} from '../../generators/component/ComponentGenerator'
3
- import {LicenseList} from '../../../constants/LicenseList'
4
- import shell from 'shelljs'
5
-
6
- export async function InitializeComponentProject(projectPath: string) {
7
- const options = await inquirer.prompt([
8
- {
9
- name: 'className',
10
- message: '请输入组件名称',
11
- type: 'input'
12
- },
13
- {
14
- name: 'name',
15
- message: '请输入项目名称',
16
- type: 'input'
17
- },
18
- {
19
- name: 'author',
20
- message: '请输入作者名称',
21
- type: 'input'
22
- },
23
- {
24
- name: 'description',
25
- message: '请输入项目说明',
26
- type: 'input'
27
- },
28
- {
29
- name: 'keywords',
30
- message: '请输入项目关键词(使用逗号分隔)',
31
- type: 'input'
32
- },
33
- {
34
- name: 'license',
35
- message: '请选择项目开源许可协议',
36
- type: 'list',
37
- default: 'UNLICENSED',
38
- choices: LicenseList
39
- }
40
- ])
41
- console.info('==================================================')
42
- console.info('项目目录:', projectPath)
43
- console.info('组件名称:', options.className)
44
- console.info('项目名称:', options.name)
45
- console.info('作者名称:', options.author)
46
- console.info('项目说明:', options.description)
47
- console.info('关键词:', options.keywords)
48
- console.info('开源许可协议:', options.license)
49
- console.info('==================================================')
50
- const confirmResult = await inquirer.prompt([
51
- {
52
- name: 'confirm',
53
- message: '请确认信息是否填写正确',
54
- type: 'confirm',
55
- default: 'Y'
56
- }
57
- ])
58
- if (confirmResult.confirm) {
59
- const componentGenerator = new ComponentGenerator({
60
- className: options.className,
61
- name: options.name,
62
- author: options.author,
63
- license: options.license,
64
- description: options.description,
65
- keywords: (() => {
66
- if (options.keywords) {
67
- return options.keywords.toString().split(',')
68
- } else {
69
- return []
70
- }
71
- })(),
72
- path: projectPath
73
- })
74
- try {
75
- console.info('正在生成项目文件')
76
- await componentGenerator.generate()
77
- console.info('项目文件生成成功')
78
- shell.cd(projectPath).exec('npm install --build-from-source --unsafe-perm', {silent: true, async: false})
79
- console.info('应用初始化完成!')
80
- } catch (e) {
81
- console.error(`项目生成错误: ${(e as Error).message}`)
82
- }
83
- }
84
- }
@@ -1,84 +0,0 @@
1
- import inquirer from 'inquirer'
2
- import {LicenseList} from '../../../constants/LicenseList'
3
- import {ModuleGenerator} from '../../generators/module/ModuleGenerator'
4
- import shell from 'shelljs'
5
-
6
- export async function InitializeModuleProject(projectPath: string) {
7
- const options = await inquirer.prompt([
8
- {
9
- name: 'className',
10
- message: '请输入模块名称',
11
- type: 'input'
12
- },
13
- {
14
- name: 'name',
15
- message: '请输入项目名称',
16
- type: 'input'
17
- },
18
- {
19
- name: 'author',
20
- message: '请输入作者名称',
21
- type: 'input'
22
- },
23
- {
24
- name: 'description',
25
- message: '请输入项目说明',
26
- type: 'input'
27
- },
28
- {
29
- name: 'keywords',
30
- message: '请输入项目关键词(使用逗号分隔)',
31
- type: 'input'
32
- },
33
- {
34
- name: 'license',
35
- message: '请选择项目开源许可协议',
36
- type: 'list',
37
- default: 'UNLICENSED',
38
- choices: LicenseList
39
- }
40
- ])
41
- console.info('==================================================')
42
- console.info('项目目录:', projectPath)
43
- console.info('模块名称:', options.className)
44
- console.info('项目名称:', options.name)
45
- console.info('作者名称:', options.author)
46
- console.info('项目说明:', options.description)
47
- console.info('关键词:', options.keywords)
48
- console.info('开源许可协议:', options.license)
49
- console.info('==================================================')
50
- const confirmResult = await inquirer.prompt([
51
- {
52
- name: 'confirm',
53
- message: '请确认信息是否填写正确',
54
- type: 'confirm',
55
- default: 'Y'
56
- }
57
- ])
58
- if (confirmResult.confirm) {
59
- const moduleGenerator = new ModuleGenerator({
60
- className: options.className,
61
- name: options.name,
62
- author: options.author,
63
- license: options.license,
64
- description: options.description,
65
- keywords: (() => {
66
- if (options.keywords) {
67
- return options.keywords.toString().split(',')
68
- } else {
69
- return []
70
- }
71
- })(),
72
- path: projectPath
73
- })
74
- try {
75
- console.info('正在生成项目文件')
76
- await moduleGenerator.generate()
77
- console.info('项目文件生成成功')
78
- shell.cd(projectPath).exec('npm install --build-from-source --unsafe-perm', {silent: true, async: false})
79
- console.info('应用初始化完成!')
80
- } catch (e) {
81
- console.error(`项目生成错误: ${(e as Error).message}`)
82
- }
83
- }
84
- }
@@ -1,84 +0,0 @@
1
- import inquirer from 'inquirer'
2
- import {LicenseList} from '../../../constants/LicenseList'
3
- import {PluginGenerator} from '../../generators/plugin/PluginGenerator'
4
- import shell from 'shelljs'
5
-
6
- export async function InitializePluginProject(projectPath: string) {
7
- const options = await inquirer.prompt([
8
- {
9
- name: 'className',
10
- message: '请输入插件名称',
11
- type: 'input'
12
- },
13
- {
14
- name: 'name',
15
- message: '请输入项目名称',
16
- type: 'input'
17
- },
18
- {
19
- name: 'author',
20
- message: '请输入作者名称',
21
- type: 'input'
22
- },
23
- {
24
- name: 'description',
25
- message: '请输入项目说明',
26
- type: 'input'
27
- },
28
- {
29
- name: 'keywords',
30
- message: '请输入项目关键词(使用逗号分隔)',
31
- type: 'input'
32
- },
33
- {
34
- name: 'license',
35
- message: '请选择项目开源许可协议',
36
- type: 'list',
37
- default: 'UNLICENSED',
38
- choices: LicenseList
39
- }
40
- ])
41
- console.info('==================================================')
42
- console.info('项目目录:', projectPath)
43
- console.info('插件名称:', options.className)
44
- console.info('项目名称:', options.name)
45
- console.info('作者名称:', options.author)
46
- console.info('项目说明:', options.description)
47
- console.info('关键词:', options.keywords)
48
- console.info('开源许可协议:', options.license)
49
- console.info('==================================================')
50
- const confirmResult = await inquirer.prompt([
51
- {
52
- name: 'confirm',
53
- message: '请确认信息是否填写正确',
54
- type: 'confirm',
55
- default: 'Y'
56
- }
57
- ])
58
- if (confirmResult.confirm) {
59
- const pluginGenerator = new PluginGenerator({
60
- className: options.className,
61
- name: options.name,
62
- author: options.author,
63
- license: options.license,
64
- description: options.description,
65
- keywords: (() => {
66
- if (options.keywords) {
67
- return options.keywords.toString().split(',')
68
- } else {
69
- return []
70
- }
71
- })(),
72
- path: projectPath
73
- })
74
- try {
75
- console.info('正在生成项目文件')
76
- await pluginGenerator.generate()
77
- console.info('项目文件生成成功')
78
- shell.cd(projectPath).exec('npm install --build-from-source --unsafe-perm', {silent: true, async: false})
79
- console.info('应用初始化完成!')
80
- } catch (e) {
81
- console.error(`项目生成错误: ${(e as Error).message}`)
82
- }
83
- }
84
- }