@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
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Creator = void 0;
16
+ const Information_js_1 = require("./Information.js");
17
+ const DeGitPuller_js_1 = require("../components/DeGitPuller.js");
18
+ const Spinner_js_1 = require("../components/Spinner.js");
19
+ const CreateProjectOptions_js_1 = require("../../options/CreateProjectOptions.js");
20
+ const ProjectTypeConfig_js_1 = require("../ProjectTypeConfig.js");
21
+ const node_path_1 = __importDefault(require("node:path"));
22
+ const promises_1 = require("node:fs/promises");
23
+ const SpecialChar_js_1 = require("../SpecialChar.js");
24
+ const lakutata_1 = require("lakutata");
25
+ const di_1 = require("lakutata/decorator/di");
26
+ const logger_1 = require("lakutata/com/logger");
27
+ const helper_1 = require("lakutata/helper");
28
+ const dto_1 = require("lakutata/decorator/dto");
29
+ const ansis_1 = __importDefault(require("ansis"));
30
+ const cli_table3_1 = __importDefault(require("cli-table3"));
31
+ class Creator extends lakutata_1.Provider {
32
+ /**
33
+ * Check if the target path exists
34
+ * @param targetDirectory
35
+ * @param initOnly
36
+ * @protected
37
+ */
38
+ async checkTargetPathExistence(targetDirectory, initOnly) {
39
+ const exists = await (0, helper_1.IsExists)(targetDirectory);
40
+ if (!exists && initOnly) {
41
+ this.log.error(`${SpecialChar_js_1.charCross} The target path does not exist.`);
42
+ return this.app.exit(1);
43
+ }
44
+ await (0, promises_1.mkdir)(targetDirectory, { recursive: true });
45
+ this.log.info(`${SpecialChar_js_1.charCheck} The target path does not exist.`);
46
+ }
47
+ /**
48
+ * Check target path is a valid directory
49
+ * @param targetDirectory
50
+ * @protected
51
+ */
52
+ async checkTargetPathIsDirectory(targetDirectory) {
53
+ const targetInfo = await (0, promises_1.stat)(targetDirectory);
54
+ if (!targetInfo.isDirectory()) {
55
+ this.log.error(`${SpecialChar_js_1.charCross} The target path is not a valid directory.`);
56
+ return this.app.exit(1);
57
+ }
58
+ this.log.info(`${SpecialChar_js_1.charCheck} The target path is a valid directory.`);
59
+ }
60
+ /**
61
+ * Check target directory is empty, if the target directory is not empty, throw error and exit
62
+ * @param targetDirectory
63
+ * @protected
64
+ */
65
+ async checkTargetDirectoryIsEmpty(targetDirectory) {
66
+ const files = await (0, promises_1.readdir)(targetDirectory);
67
+ if (files.length) {
68
+ this.log.error(`${SpecialChar_js_1.charCross} The target directory is not empty.`);
69
+ return this.app.exit(1);
70
+ }
71
+ this.log.info(`${SpecialChar_js_1.charCheck} The target directory is empty.`);
72
+ }
73
+ /**
74
+ * Exec create
75
+ * @param options
76
+ */
77
+ async create(options) {
78
+ const appName = options.name;
79
+ const appId = options.id;
80
+ const appDescription = options.description;
81
+ const packageName = appId;
82
+ const authorName = options.author;
83
+ const licenseName = options.license;
84
+ const appType = options.type;
85
+ const targetPath = options.initOnly ? node_path_1.default.resolve(options.path) : node_path_1.default.resolve(options.path, options.name);
86
+ const { branch } = ProjectTypeConfig_js_1.ProjectTypeConfig[appType];
87
+ const table = new cli_table3_1.default();
88
+ table.push([{ content: ansis_1.default.bold.cyan('Project Creation Information'), colSpan: 2, hAlign: 'center' }], [ansis_1.default.blue('APP ID & Project Name'), appId], [ansis_1.default.blue('APP Name'), appName], [ansis_1.default.blue('APP Description'), appDescription], [ansis_1.default.blue('Project Create Target Path'), targetPath], [ansis_1.default.blue('Project Create Mode'), options.initOnly ? ansis_1.default.yellow('Initialize project in an existing directory') : ansis_1.default.green('Create a new folder for the project')], [ansis_1.default.blue('Project Author Name'), authorName], [ansis_1.default.blue('Project License'), licenseName], [ansis_1.default.blue('Project Template Branch'), this.puller.getGitSource(branch)]);
89
+ console.log(table.toString());
90
+ await new Promise(resolve => {
91
+ let timeLeft = 15;
92
+ const interval = setInterval(() => {
93
+ timeLeft -= 1;
94
+ if (!timeLeft) {
95
+ clearInterval(interval);
96
+ this.spinner.stop();
97
+ return resolve();
98
+ }
99
+ }, 1000);
100
+ this.spinner.start(() => `Please confirm the project creation information; the creation process will commence in ${timeLeft} seconds.`);
101
+ });
102
+ await this.checkTargetPathExistence(targetPath, options.initOnly);
103
+ await this.checkTargetPathIsDirectory(targetPath);
104
+ await this.checkTargetDirectoryIsEmpty(targetPath);
105
+ this.log.info('Begin project creation');
106
+ //TODO
107
+ }
108
+ }
109
+ exports.Creator = Creator;
110
+ __decorate([
111
+ (0, di_1.Inject)(lakutata_1.Application),
112
+ __metadata("design:type", lakutata_1.Application)
113
+ ], Creator.prototype, "app", void 0);
114
+ __decorate([
115
+ (0, di_1.Inject)('log'),
116
+ __metadata("design:type", logger_1.Logger)
117
+ ], Creator.prototype, "log", void 0);
118
+ __decorate([
119
+ (0, di_1.Inject)('spinner'),
120
+ __metadata("design:type", Spinner_js_1.Spinner)
121
+ ], Creator.prototype, "spinner", void 0);
122
+ __decorate([
123
+ (0, di_1.Inject)('puller'),
124
+ __metadata("design:type", DeGitPuller_js_1.DeGitPuller)
125
+ ], Creator.prototype, "puller", void 0);
126
+ __decorate([
127
+ (0, di_1.Inject)('info'),
128
+ __metadata("design:type", Information_js_1.Information
129
+ /**
130
+ * Check if the target path exists
131
+ * @param targetDirectory
132
+ * @param initOnly
133
+ * @protected
134
+ */
135
+ )
136
+ ], Creator.prototype, "frameworkInfo", void 0);
137
+ __decorate([
138
+ (0, dto_1.Accept)(CreateProjectOptions_js_1.CreateProjectOptions.required()),
139
+ __metadata("design:type", Function),
140
+ __metadata("design:paramtypes", [CreateProjectOptions_js_1.CreateProjectOptions]),
141
+ __metadata("design:returntype", Promise)
142
+ ], Creator.prototype, "create", null);
@@ -0,0 +1,91 @@
1
+ import { Provider } from 'lakutata';
2
+ export declare class Information extends Provider {
3
+ protected readonly name: string;
4
+ protected readonly version: string;
5
+ protected readonly description: string;
6
+ protected readonly license: string;
7
+ protected readonly currentDirectory: string;
8
+ protected readonly workingDirectory: string;
9
+ protected packageDirectory: (options?: any) => Promise<string | undefined>;
10
+ protected installPath: string;
11
+ protected projectRoot: string | null;
12
+ /**
13
+ * Initializer
14
+ * @protected
15
+ */
16
+ protected init(): Promise<void>;
17
+ /**
18
+ * To find the root path of the project where the working directory is located
19
+ * @param path
20
+ * @private
21
+ */
22
+ private findProjectRoot;
23
+ /**
24
+ * To locate the root path containing the package.json file
25
+ * @param path
26
+ * @private
27
+ */
28
+ private findLocalRoot;
29
+ /**
30
+ * Convert string first char to upper case
31
+ * @param str
32
+ * @private
33
+ */
34
+ private stringFirstCharUpperCase;
35
+ /**
36
+ * Format framework ascii logo
37
+ * @protected
38
+ */
39
+ protected formatFrameworkAsciiLogo(): string;
40
+ /**
41
+ * Format framework description
42
+ * @protected
43
+ */
44
+ protected formatFrameworkDescription(): string;
45
+ /**
46
+ * Format version text
47
+ * @protected
48
+ */
49
+ protected formatVersionText(): string;
50
+ /**
51
+ * Format framework installation path
52
+ * @protected
53
+ */
54
+ protected formatInstallationPath(): string;
55
+ /**
56
+ * Format current running level
57
+ * @protected
58
+ */
59
+ protected formatRunningLevel(): string;
60
+ /**
61
+ * Format license
62
+ * @protected
63
+ */
64
+ protected formatLicense(): string;
65
+ /**
66
+ * Format copyright
67
+ * @protected
68
+ */
69
+ protected formatCopyright(): string;
70
+ /**
71
+ * To retrieve the hierarchy level of the project containing the package under the current command
72
+ */
73
+ getLevel(): 'PROJECT' | 'GLOBAL';
74
+ /**
75
+ * Locate the root path of the project
76
+ */
77
+ getRoot(): string | null;
78
+ /**
79
+ * Locate the installation directory
80
+ */
81
+ getInstallPath(): string;
82
+ /**
83
+ * Retrieve the framework installation version at the project level
84
+ */
85
+ getProjectLevelInstalledFrameworkVersion(): Promise<string | null>;
86
+ /**
87
+ * Print infos
88
+ */
89
+ print(): Promise<void>;
90
+ }
91
+ //# sourceMappingURL=Information.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Information.d.ts","sourceRoot":"","sources":["../../../src/lib/providers/Information.ts"],"names":[],"mappings":"AAGA,OAAO,EAAM,QAAQ,EAAO,MAAM,UAAU,CAAA;AAI5C,qBAAa,WAAY,SAAQ,QAAQ;IAGrC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAG/B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAGtC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAGlC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IAG3C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IAE3C,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAE1E,SAAS,CAAC,WAAW,EAAE,MAAM,CAAA;IAE7B,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAEpC;;;OAGG;cACa,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BrC;;;;OAIG;YACW,eAAe;IAY7B;;;;OAIG;YACW,aAAa;IAS3B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAIhC;;;OAGG;IACH,SAAS,CAAC,wBAAwB,IAAI,MAAM;IAY5C;;;OAGG;IACH,SAAS,CAAC,0BAA0B,IAAI,MAAM;IAI9C;;;OAGG;IACH,SAAS,CAAC,iBAAiB,IAAI,MAAM;IAIrC;;;OAGG;IACH,SAAS,CAAC,sBAAsB,IAAI,MAAM;IAI1C;;;OAGG;IACH,SAAS,CAAC,kBAAkB,IAAI,MAAM;IAItC;;;OAGG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IAIjC;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,MAAM;IAInC;;OAEG;IACI,QAAQ,IAAI,SAAS,GAAG,QAAQ;IAIvC;;OAEG;IACI,OAAO,IAAI,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACU,wCAAwC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa/E;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAYtC"}
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Information = void 0;
16
+ const ansis_1 = __importDefault(require("ansis"));
17
+ const node_path_1 = require("node:path");
18
+ const promises_1 = require("node:fs/promises");
19
+ const lakutata_1 = require("lakutata");
20
+ const di_1 = require("lakutata/decorator/di");
21
+ const helper_1 = require("lakutata/helper");
22
+ class Information extends lakutata_1.Provider {
23
+ /**
24
+ * Initializer
25
+ * @protected
26
+ */
27
+ async init() {
28
+ const { packageDirectory } = await import('pkg-dir');
29
+ this.packageDirectory = packageDirectory;
30
+ const installPath = await packageDirectory({ cwd: this.currentDirectory });
31
+ this.installPath = installPath ? installPath : 'UNKNOWN';
32
+ const projectRoot = await this.findProjectRoot(this.workingDirectory);
33
+ if (projectRoot) {
34
+ const packageJsonPath = (0, node_path_1.resolve)(projectRoot, './package.json');
35
+ try {
36
+ const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, { encoding: 'utf-8' }));
37
+ const dependenciesKeyRegExp = new RegExp('dependencies'.toUpperCase());
38
+ Object.keys(packageJson).forEach((key) => {
39
+ if (dependenciesKeyRegExp.test(key.toUpperCase())) {
40
+ Object.keys(packageJson[key]).forEach((dependencyName) => {
41
+ if (dependencyName === this.name) {
42
+ this.projectRoot = projectRoot;
43
+ }
44
+ });
45
+ }
46
+ });
47
+ }
48
+ catch (e) {
49
+ (0, helper_1.DevNull)(e);
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * To find the root path of the project where the working directory is located
55
+ * @param path
56
+ * @private
57
+ */
58
+ async findProjectRoot(path) {
59
+ let localRootPath = null;
60
+ while (true) {
61
+ const _localRootPath = await this.findLocalRoot(localRootPath ? (0, node_path_1.dirname)(localRootPath) : path);
62
+ if (!_localRootPath)
63
+ break;
64
+ else
65
+ localRootPath = _localRootPath;
66
+ }
67
+ return localRootPath;
68
+ }
69
+ /**
70
+ * To locate the root path containing the package.json file
71
+ * @param path
72
+ * @private
73
+ */
74
+ async findLocalRoot(path) {
75
+ try {
76
+ const dir = await this.packageDirectory({ cwd: path });
77
+ return dir ? dir : null;
78
+ }
79
+ catch (e) {
80
+ return null;
81
+ }
82
+ }
83
+ /**
84
+ * Convert string first char to upper case
85
+ * @param str
86
+ * @private
87
+ */
88
+ stringFirstCharUpperCase(str) {
89
+ return str.charAt(0).toUpperCase() + str.slice(1);
90
+ }
91
+ /**
92
+ * Format framework ascii logo
93
+ * @protected
94
+ */
95
+ formatFrameworkAsciiLogo() {
96
+ const asciiLogo = '' +
97
+ ' _ _ _ \n' +
98
+ '| | _ | | | | \n' +
99
+ '| | __ _ | | _ _ _ | |_ __ _ | |_ __ _ \n' +
100
+ '| | / _` | | |/ / | | | | | __| / _` | | __| / _` | \n' +
101
+ '| |____ | (_| | | < | |_| | \\ |_ | (_| | \\ |_ | (_| | \n' +
102
+ '|______| \\__,_| |_|\\_\\ \\__,_| \\__| \\__,_| \\__| \\__,_| \n' +
103
+ ' ';
104
+ return `${ansis_1.default.yellow(asciiLogo)}`;
105
+ }
106
+ /**
107
+ * Format framework description
108
+ * @protected
109
+ */
110
+ formatFrameworkDescription() {
111
+ return `${ansis_1.default.bold(this.stringFirstCharUpperCase(this.name))} is ${ansis_1.default.blue(this.description)}`;
112
+ }
113
+ /**
114
+ * Format version text
115
+ * @protected
116
+ */
117
+ formatVersionText() {
118
+ return `The current version is ${ansis_1.default.bold(this.version)}`;
119
+ }
120
+ /**
121
+ * Format framework installation path
122
+ * @protected
123
+ */
124
+ formatInstallationPath() {
125
+ return `The installation directory path is ${ansis_1.default.underline(this.getInstallPath())}`;
126
+ }
127
+ /**
128
+ * Format current running level
129
+ * @protected
130
+ */
131
+ formatRunningLevel() {
132
+ return `Currently running at ${ansis_1.default.bold(this.getLevel())} level`;
133
+ }
134
+ /**
135
+ * Format license
136
+ * @protected
137
+ */
138
+ formatLicense() {
139
+ return `${this.stringFirstCharUpperCase(this.name)} is ${ansis_1.default.cyan(this.license)} licensed.`;
140
+ }
141
+ /**
142
+ * Format copyright
143
+ * @protected
144
+ */
145
+ formatCopyright() {
146
+ return `Copyright (c) ${new lakutata_1.Time().format('YYYY')} ${ansis_1.default.bold(this.stringFirstCharUpperCase(this.name))}. All rights reserved.`;
147
+ }
148
+ /**
149
+ * To retrieve the hierarchy level of the project containing the package under the current command
150
+ */
151
+ getLevel() {
152
+ return this.projectRoot ? 'PROJECT' : 'GLOBAL';
153
+ }
154
+ /**
155
+ * Locate the root path of the project
156
+ */
157
+ getRoot() {
158
+ return this.projectRoot;
159
+ }
160
+ /**
161
+ * Locate the installation directory
162
+ */
163
+ getInstallPath() {
164
+ return this.installPath;
165
+ }
166
+ /**
167
+ * Retrieve the framework installation version at the project level
168
+ */
169
+ async getProjectLevelInstalledFrameworkVersion() {
170
+ const projectRoot = this.getRoot();
171
+ if (projectRoot) {
172
+ try {
173
+ const version = JSON.parse(await (0, promises_1.readFile)((0, node_path_1.resolve)(projectRoot, './node_modules', `./${this.name}/package.json`), { encoding: 'utf-8' })).version;
174
+ return version ? version : null;
175
+ }
176
+ catch (e) {
177
+ return null;
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+ /**
183
+ * Print infos
184
+ */
185
+ async print() {
186
+ const texts = [
187
+ this.formatFrameworkAsciiLogo(),
188
+ this.formatFrameworkDescription(),
189
+ this.formatVersionText(),
190
+ this.formatInstallationPath(),
191
+ this.formatRunningLevel(),
192
+ this.formatLicense(),
193
+ this.formatCopyright()
194
+ ];
195
+ console.info(texts.join('\n'));
196
+ }
197
+ }
198
+ exports.Information = Information;
199
+ __decorate([
200
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
201
+ __metadata("design:type", String)
202
+ ], Information.prototype, "name", void 0);
203
+ __decorate([
204
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
205
+ __metadata("design:type", String)
206
+ ], Information.prototype, "version", void 0);
207
+ __decorate([
208
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
209
+ __metadata("design:type", String)
210
+ ], Information.prototype, "description", void 0);
211
+ __decorate([
212
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
213
+ __metadata("design:type", String)
214
+ ], Information.prototype, "license", void 0);
215
+ __decorate([
216
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
217
+ __metadata("design:type", String)
218
+ ], Information.prototype, "currentDirectory", void 0);
219
+ __decorate([
220
+ (0, di_1.Configurable)(lakutata_1.DTO.String().required()),
221
+ __metadata("design:type", String)
222
+ ], Information.prototype, "workingDirectory", void 0);
@@ -0,0 +1,15 @@
1
+ import { DTO } from 'lakutata';
2
+ /**
3
+ * Create project options
4
+ */
5
+ export declare class CreateProjectOptions extends DTO {
6
+ name: string;
7
+ id: string;
8
+ type: string;
9
+ path: string;
10
+ initOnly: boolean;
11
+ description: string;
12
+ author: string;
13
+ license: string;
14
+ }
15
+ //# sourceMappingURL=CreateProjectOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateProjectOptions.d.ts","sourceRoot":"","sources":["../../src/options/CreateProjectOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAG5B;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,GAAG;IASlC,IAAI,EAAE,MAAM,CAAA;IASZ,EAAE,EAAE,MAAM,CAAA;IASV,IAAI,EAAE,MAAM,CAAA;IASZ,IAAI,EAAE,MAAM,CAAA;IAUZ,QAAQ,EAAE,OAAO,CAAA;IASjB,WAAW,EAAE,MAAM,CAAA;IASnB,MAAM,EAAE,MAAM,CAAA;IASd,OAAO,EAAE,MAAM,CAAA;CACzB"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CreateProjectOptions = void 0;
13
+ const ProjectTypeConfig_1 = require("../lib/ProjectTypeConfig");
14
+ const lakutata_1 = require("lakutata");
15
+ const dto_1 = require("lakutata/decorator/dto");
16
+ /**
17
+ * Create project options
18
+ */
19
+ class CreateProjectOptions extends lakutata_1.DTO {
20
+ }
21
+ exports.CreateProjectOptions = CreateProjectOptions;
22
+ __decorate([
23
+ (0, dto_1.Expect)(lakutata_1.DTO
24
+ .String()
25
+ .required()
26
+ .pattern(/^(\w+\.?)*\w+$/)
27
+ .description('specify the name of the project and application')),
28
+ __metadata("design:type", String)
29
+ ], CreateProjectOptions.prototype, "name", void 0);
30
+ __decorate([
31
+ (0, dto_1.Expect)(lakutata_1.DTO
32
+ .String()
33
+ .required()
34
+ .pattern(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/) //Match package json name regex
35
+ .description('specify the ID of the application')),
36
+ __metadata("design:type", String)
37
+ ], CreateProjectOptions.prototype, "id", void 0);
38
+ __decorate([
39
+ (0, dto_1.Expect)(lakutata_1.DTO
40
+ .String()
41
+ .required()
42
+ .valid(...Object.keys(ProjectTypeConfig_1.ProjectTypeConfig))
43
+ .description(`select the type of the project (choices: ${Object.keys(ProjectTypeConfig_1.ProjectTypeConfig).map((type) => `"${type}"`).join(',')})`)),
44
+ __metadata("design:type", String)
45
+ ], CreateProjectOptions.prototype, "type", void 0);
46
+ __decorate([
47
+ (0, dto_1.Expect)(lakutata_1.DTO
48
+ .String()
49
+ .optional()
50
+ .default(process.cwd())
51
+ .description(`specify the path for creating the project (default: "${process.cwd()}")`)),
52
+ __metadata("design:type", String)
53
+ ], CreateProjectOptions.prototype, "path", void 0);
54
+ __decorate([
55
+ (0, dto_1.Expect)(lakutata_1.DTO
56
+ .Boolean()
57
+ .strict(false)
58
+ .optional()
59
+ .default(false)
60
+ .description('initialize project only in specified directory without creating a new folder (default: false)')),
61
+ __metadata("design:type", Boolean)
62
+ ], CreateProjectOptions.prototype, "initOnly", void 0);
63
+ __decorate([
64
+ (0, dto_1.Expect)(lakutata_1.DTO
65
+ .String()
66
+ .optional()
67
+ .default('none')
68
+ .description('specify the description of the application (default: "none")')),
69
+ __metadata("design:type", String)
70
+ ], CreateProjectOptions.prototype, "description", void 0);
71
+ __decorate([
72
+ (0, dto_1.Expect)(lakutata_1.DTO
73
+ .String()
74
+ .optional()
75
+ .default('Anonymous')
76
+ .description('specify the name of the author of the application (default: "Anonymous")')),
77
+ __metadata("design:type", String)
78
+ ], CreateProjectOptions.prototype, "author", void 0);
79
+ __decorate([
80
+ (0, dto_1.Expect)(lakutata_1.DTO
81
+ .String()
82
+ .optional()
83
+ .default('UNLICENSED')
84
+ .description('specify the name of the license for the application (default: "UNLICENSED")')),
85
+ __metadata("design:type", String)
86
+ ], CreateProjectOptions.prototype, "license", void 0);
@@ -0,0 +1,4 @@
1
+ import { DTO } from 'lakutata';
2
+ export declare class LakutataInfoOptions extends DTO {
3
+ }
4
+ //# sourceMappingURL=LakutataInfoOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LakutataInfoOptions.d.ts","sourceRoot":"","sources":["../../src/options/LakutataInfoOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAE5B,qBAAa,mBAAoB,SAAQ,GAAG;CAC3C"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LakutataInfoOptions = void 0;
4
+ const lakutata_1 = require("lakutata");
5
+ class LakutataInfoOptions extends lakutata_1.DTO {
6
+ }
7
+ exports.LakutataInfoOptions = LakutataInfoOptions;