@keshavsoft/kschema-api-gen-actions 1.14.1

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 (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +320 -0
  3. package/bin/cli.js +12 -0
  4. package/bin/core/getLatestVersion.js +13 -0
  5. package/bin/core/loadRunner.js +9 -0
  6. package/bin/v13/commands/loadCommand.js +11 -0
  7. package/bin/v13/config/actions.json +20 -0
  8. package/bin/v13/core/createFolder.js +34 -0
  9. package/bin/v13/core/parseInput.js +8 -0
  10. package/bin/v13/core/resolveCommand.js +11 -0
  11. package/bin/v13/core/showUsage.js +50 -0
  12. package/bin/v13/start.js +22 -0
  13. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/common/readFile.js +8 -0
  14. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  15. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  16. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  17. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  18. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/index.js +45 -0
  19. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/buildUseLine.js +9 -0
  20. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  21. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  22. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/index.js +46 -0
  23. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/announce.js +9 -0
  24. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/createFolder.js +7 -0
  25. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/createHttpFile.js +12 -0
  26. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/decideTemplate.js +3 -0
  27. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/locateDestination.js +7 -0
  28. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/locateSource.js +13 -0
  29. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/resolveFolderName.js +20 -0
  30. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/updateAppJs.js +7 -0
  31. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/updateEndPointsFile.js +30 -0
  32. package/bin/v13/tasks/actions/GetMethods/Distinct/steps/updateEndPointsJs.js +16 -0
  33. package/bin/v13/tasks/actions/GetMethods/Distinct/template/controller.js +21 -0
  34. package/bin/v13/tasks/actions/GetMethods/Distinct/template/errors.js +11 -0
  35. package/bin/v13/tasks/actions/GetMethods/Distinct/template/service.js +9 -0
  36. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/common/readFile.js +8 -0
  37. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  38. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  39. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  40. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  41. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/index.js +45 -0
  42. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/buildUseLine.js +9 -0
  43. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  44. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  45. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/index.js +46 -0
  46. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/announce.js +9 -0
  47. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/createFolder.js +7 -0
  48. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/createHttpFile.js +12 -0
  49. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/decideTemplate.js +3 -0
  50. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/locateDestination.js +7 -0
  51. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/locateSource.js +13 -0
  52. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/resolveFolderName.js +20 -0
  53. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/updateAppJs.js +7 -0
  54. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/updateEndPointsFile.js +30 -0
  55. package/bin/v13/tasks/actions/GetMethods/ShowAll/steps/updateEndPointsJs.js +16 -0
  56. package/bin/v13/tasks/actions/GetMethods/ShowAll/template/controller.js +21 -0
  57. package/bin/v13/tasks/actions/GetMethods/ShowAll/template/errors.js +11 -0
  58. package/bin/v13/tasks/actions/GetMethods/ShowAll/template/service.js +9 -0
  59. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/common/readFile.js +8 -0
  60. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  61. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  62. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  63. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  64. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/index.js +47 -0
  65. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
  66. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
  67. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  68. package/bin/v13/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/index.js +56 -0
  69. package/bin/v13/tasks/actions/PostMethods/Insert/steps/announce.js +9 -0
  70. package/bin/v13/tasks/actions/PostMethods/Insert/steps/createFolder.js +7 -0
  71. package/bin/v13/tasks/actions/PostMethods/Insert/steps/createHttpFile.js +12 -0
  72. package/bin/v13/tasks/actions/PostMethods/Insert/steps/decideTemplate.js +3 -0
  73. package/bin/v13/tasks/actions/PostMethods/Insert/steps/locateDestination.js +7 -0
  74. package/bin/v13/tasks/actions/PostMethods/Insert/steps/locateSource.js +13 -0
  75. package/bin/v13/tasks/actions/PostMethods/Insert/steps/resolveFolderName.js +20 -0
  76. package/bin/v13/tasks/actions/PostMethods/Insert/steps/updateAppJs.js +7 -0
  77. package/bin/v13/tasks/actions/PostMethods/Insert/steps/updateEndPointsFile.js +30 -0
  78. package/bin/v13/tasks/actions/PostMethods/Insert/steps/updateEndPointsJs.js +16 -0
  79. package/bin/v13/tasks/actions/PostMethods/Insert/template/controller.js +24 -0
  80. package/bin/v13/tasks/actions/PostMethods/Insert/template/errors.js +11 -0
  81. package/bin/v13/tasks/actions/PostMethods/Insert/template/middleware.js +19 -0
  82. package/bin/v13/tasks/actions/PostMethods/Insert/template/service.js +11 -0
  83. package/bin/v13/tasks/actions/distinct.js +59 -0
  84. package/bin/v13/tasks/actions/insert.js +59 -0
  85. package/bin/v13/tasks/actions/showAll.js +59 -0
  86. package/bin/v13/tasks/core/createFolder.js +34 -0
  87. package/bin/v13/tasks/core/parseInput.js +12 -0
  88. package/bin/v13/tasks/core/resolveCommand.js +24 -0
  89. package/bin/v13/tasks/core/showUsage.js +43 -0
  90. package/bin/v14/commands/loadCommand.js +11 -0
  91. package/bin/v14/config/actions.json +23 -0
  92. package/bin/v14/config/actionsV1.json +20 -0
  93. package/bin/v14/core/createFolder.js +34 -0
  94. package/bin/v14/core/parseInput.js +8 -0
  95. package/bin/v14/core/resolveCommand.js +11 -0
  96. package/bin/v14/core/showUsage.js +49 -0
  97. package/bin/v14/start.js +22 -0
  98. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/common/readFile.js +8 -0
  99. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  100. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  101. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  102. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  103. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateImports/index.js +45 -0
  104. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/buildUseLine.js +9 -0
  105. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  106. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  107. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/UpdateRoutesJs/updateUse/index.js +46 -0
  108. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/announce.js +9 -0
  109. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/createFolder.js +7 -0
  110. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/createHttpFile.js +12 -0
  111. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/decideTemplate.js +3 -0
  112. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/locateDestination.js +7 -0
  113. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/locateSource.js +13 -0
  114. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/resolveFolderName.js +20 -0
  115. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/updateAppJs.js +7 -0
  116. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/updateEndPointsFile.js +30 -0
  117. package/bin/v14/tasks/actions/GetMethods/Distinct/steps/updateEndPointsJs.js +16 -0
  118. package/bin/v14/tasks/actions/GetMethods/Distinct/template/controller.js +21 -0
  119. package/bin/v14/tasks/actions/GetMethods/Distinct/template/errors.js +11 -0
  120. package/bin/v14/tasks/actions/GetMethods/Distinct/template/service.js +9 -0
  121. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/common/readFile.js +8 -0
  122. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  123. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  124. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  125. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  126. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateImports/index.js +45 -0
  127. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/buildUseLine.js +9 -0
  128. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  129. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  130. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/UpdateRoutesJs/updateUse/index.js +46 -0
  131. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/announce.js +9 -0
  132. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/createFolder.js +7 -0
  133. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/createHttpFile.js +12 -0
  134. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/decideTemplate.js +3 -0
  135. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/locateDestination.js +7 -0
  136. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/locateSource.js +13 -0
  137. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/resolveFolderName.js +20 -0
  138. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/updateAppJs.js +7 -0
  139. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/updateEndPointsFile.js +30 -0
  140. package/bin/v14/tasks/actions/GetMethods/ShowAll/steps/updateEndPointsJs.js +16 -0
  141. package/bin/v14/tasks/actions/GetMethods/ShowAll/template/controller.js +21 -0
  142. package/bin/v14/tasks/actions/GetMethods/ShowAll/template/errors.js +11 -0
  143. package/bin/v14/tasks/actions/GetMethods/ShowAll/template/service.js +9 -0
  144. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/common/readFile.js +8 -0
  145. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  146. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  147. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  148. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  149. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateImports/index.js +47 -0
  150. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/buildUseLine.js +5 -0
  151. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +9 -0
  152. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  153. package/bin/v14/tasks/actions/PostMethods/Insert/steps/UpdateRoutesJs/updateUse/index.js +56 -0
  154. package/bin/v14/tasks/actions/PostMethods/Insert/steps/announce.js +9 -0
  155. package/bin/v14/tasks/actions/PostMethods/Insert/steps/createFolder.js +7 -0
  156. package/bin/v14/tasks/actions/PostMethods/Insert/steps/createHttpFile.js +12 -0
  157. package/bin/v14/tasks/actions/PostMethods/Insert/steps/decideTemplate.js +3 -0
  158. package/bin/v14/tasks/actions/PostMethods/Insert/steps/locateDestination.js +7 -0
  159. package/bin/v14/tasks/actions/PostMethods/Insert/steps/locateSource.js +13 -0
  160. package/bin/v14/tasks/actions/PostMethods/Insert/steps/resolveFolderName.js +20 -0
  161. package/bin/v14/tasks/actions/PostMethods/Insert/steps/updateAppJs.js +7 -0
  162. package/bin/v14/tasks/actions/PostMethods/Insert/steps/updateEndPointsFile.js +30 -0
  163. package/bin/v14/tasks/actions/PostMethods/Insert/steps/updateEndPointsJs.js +16 -0
  164. package/bin/v14/tasks/actions/PostMethods/Insert/template/controller.js +24 -0
  165. package/bin/v14/tasks/actions/PostMethods/Insert/template/errors.js +11 -0
  166. package/bin/v14/tasks/actions/PostMethods/Insert/template/middleware.js +19 -0
  167. package/bin/v14/tasks/actions/PostMethods/Insert/template/service.js +11 -0
  168. package/bin/v14/tasks/actions/distinct.js +59 -0
  169. package/bin/v14/tasks/actions/insert.js +59 -0
  170. package/bin/v14/tasks/actions/showAll.js +59 -0
  171. package/bin/v14/tasks/core/createFolder.js +34 -0
  172. package/bin/v14/tasks/core/parseInput.js +12 -0
  173. package/bin/v14/tasks/core/resolveCommand.js +24 -0
  174. package/bin/v14/tasks/core/showUsage.js +43 -0
  175. package/index.js +8 -0
  176. package/package.json +37 -0
@@ -0,0 +1,59 @@
1
+ import path from "path";
2
+ import { endPointsJs } from "@keshavsoft/kschema-api-check";
3
+
4
+ import { locateSource } from "./GetMethods/ShowAll/steps/locateSource.js";
5
+ import { locateDestination } from "./GetMethods/ShowAll/steps/locateDestination.js";
6
+ import { createFolder } from "../core/createFolder.js";
7
+
8
+ // import updateEndPointsJs from "./ShowAll/steps/updateEndPointsJs.js";
9
+ import createHttpFile from "./GetMethods/ShowAll/steps/createHttpFile.js";
10
+
11
+ import { announce } from "./GetMethods/ShowAll/steps/announce.js";
12
+
13
+ import resolveFolderName from "./GetMethods/ShowAll/steps/resolveFolderName.js";
14
+
15
+ export default ({ cmd = "", toPath, isAnnounce = true, checkBeforeCreate = true }) => {
16
+ const localToPath = toPath;
17
+
18
+ const resolvedFolderName = resolveFolderName({
19
+ name: cmd
20
+ });
21
+
22
+ if (resolvedFolderName.KTF === false) {
23
+ console.log(resolvedFolderName.KReason);
24
+
25
+ return;
26
+ };
27
+
28
+ const source = locateSource();
29
+ const destination = locateDestination({
30
+ inResolvedFolderName: resolvedFolderName,
31
+ toPath: localToPath
32
+ });
33
+
34
+ const createFolderResponse = createFolder({
35
+ source, destination,
36
+ isAnnounce, checkBeforeCreate
37
+ });
38
+
39
+ if (createFolderResponse.KTF) {
40
+ endPointsJs({
41
+ toPath: localToPath,
42
+ action: resolvedFolderName
43
+ });
44
+
45
+ // updateEndPointsJs({
46
+ // appJsPath: `${localToPath}/end-points.js`,
47
+ // endpoint: resolvedFolderName
48
+ // });
49
+
50
+ createHttpFile({
51
+ inTargetPath: path.join(localToPath, resolvedFolderName),
52
+ toPath: process.cwd()
53
+ });
54
+ };
55
+
56
+ if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
57
+
58
+ return resolveFolderName;
59
+ };
@@ -0,0 +1,59 @@
1
+ import path from "path";
2
+ import { endPointsJs } from "@keshavsoft/kschema-api-check";
3
+
4
+ import { locateSource } from "./PostMethods/Insert/steps/locateSource.js";
5
+ import { locateDestination } from "./PostMethods/Insert/steps/locateDestination.js";
6
+ import { createFolder } from "../../core/createFolder.js";
7
+
8
+ import updateEndPointsJs from "./PostMethods/Insert/steps/updateEndPointsJs.js";
9
+ import createHttpFile from "./PostMethods/Insert/steps/createHttpFile.js";
10
+
11
+ import { announce } from "./PostMethods/Insert/steps/announce.js";
12
+
13
+ import resolveFolderName from "./PostMethods/Insert/steps/resolveFolderName.js";
14
+
15
+ export default ({ cmd = "", toPath, isAnnounce = true, checkBeforeCreate = true }) => {
16
+ const localToPath = toPath;
17
+
18
+ const resolvedFolderName = resolveFolderName({
19
+ name: cmd
20
+ });
21
+
22
+ if (resolvedFolderName.KTF === false) {
23
+ console.log(resolvedFolderName.KReason);
24
+
25
+ return;
26
+ };
27
+
28
+ const source = locateSource();
29
+ const destination = locateDestination({
30
+ inResolvedFolderName: resolvedFolderName,
31
+ toPath: localToPath
32
+ });
33
+
34
+ const createFolderResponse = createFolder({
35
+ source, destination,
36
+ isAnnounce, checkBeforeCreate
37
+ });
38
+
39
+ if (createFolderResponse.KTF) {
40
+ endPointsJs({
41
+ toPath: localToPath,
42
+ action: resolvedFolderName
43
+ });
44
+
45
+ // updateEndPointsJs({
46
+ // appJsPath: `${localToPath}/end-points.js`,
47
+ // endpoint: resolvedFolderName
48
+ // });
49
+
50
+ createHttpFile({
51
+ inTargetPath: path.join(localToPath, resolvedFolderName),
52
+ toPath: process.cwd()
53
+ });
54
+ };
55
+
56
+ if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
57
+
58
+ return resolvedFolderName;
59
+ };
@@ -0,0 +1,59 @@
1
+ import path from "path";
2
+ import { endPointsJs } from "@keshavsoft/kschema-api-check";
3
+
4
+ import { locateSource } from "./GetMethods/ShowAll/steps/locateSource.js";
5
+ import { locateDestination } from "./GetMethods/ShowAll/steps/locateDestination.js";
6
+ import { createFolder } from "../core/createFolder.js";
7
+
8
+ // import updateEndPointsJs from "./ShowAll/steps/updateEndPointsJs.js";
9
+ import createHttpFile from "./GetMethods/ShowAll/steps/createHttpFile.js";
10
+
11
+ import { announce } from "./GetMethods/ShowAll/steps/announce.js";
12
+
13
+ import resolveFolderName from "./GetMethods/ShowAll/steps/resolveFolderName.js";
14
+
15
+ export default ({ cmd = "", toPath, isAnnounce = true, checkBeforeCreate = true }) => {
16
+ const localToPath = toPath;
17
+
18
+ const resolvedFolderName = resolveFolderName({
19
+ name: cmd
20
+ });
21
+
22
+ if (resolvedFolderName.KTF === false) {
23
+ console.log(resolvedFolderName.KReason);
24
+
25
+ return;
26
+ };
27
+
28
+ const source = locateSource();
29
+ const destination = locateDestination({
30
+ inResolvedFolderName: resolvedFolderName,
31
+ toPath: localToPath
32
+ });
33
+
34
+ const createFolderResponse = createFolder({
35
+ source, destination,
36
+ isAnnounce, checkBeforeCreate
37
+ });
38
+
39
+ if (createFolderResponse.KTF) {
40
+ endPointsJs({
41
+ toPath: localToPath,
42
+ action: resolvedFolderName
43
+ });
44
+
45
+ // updateEndPointsJs({
46
+ // appJsPath: `${localToPath}/end-points.js`,
47
+ // endpoint: resolvedFolderName
48
+ // });
49
+
50
+ createHttpFile({
51
+ inTargetPath: path.join(localToPath, resolvedFolderName),
52
+ toPath: process.cwd()
53
+ });
54
+ };
55
+
56
+ if (isAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
57
+
58
+ return resolveFolderName;
59
+ };
@@ -0,0 +1,34 @@
1
+ import fs from "fs";
2
+
3
+ export const createFolder = ({ source, destination, checkBeforeCreate = false, isAnnounce = true }) => {
4
+ if (checkBeforeCreate) {
5
+ return createFolderWithCheck({ source, destination, isAnnounce });
6
+ } else {
7
+ return createOnly({ source, destination });
8
+ };
9
+ };
10
+
11
+ const createOnly = ({ source, destination }) => {
12
+ fs.mkdirSync(destination, { recursive: true });
13
+
14
+ fs.cpSync(source, destination, { recursive: true });
15
+
16
+ return {
17
+ KTF: true
18
+ };
19
+ };
20
+
21
+ const createFolderWithCheck = ({ source, destination, isAnnounce }) => {
22
+ if (fs.existsSync(destination)) {
23
+ if (isAnnounce) console.log("Folder already exists :", destination);
24
+
25
+ return {
26
+ KTF: false,
27
+ KReason: "Folder already exists"
28
+ };
29
+ };
30
+
31
+ if (isAnnounce) console.log("Folder created :", destination);
32
+
33
+ return createOnly({ source, destination });
34
+ };
@@ -0,0 +1,12 @@
1
+ export default function parseInput() {
2
+ const [cmd, ...args] = process.argv.slice(2);
3
+
4
+ return {
5
+ cmd: cmd || null,
6
+ args,
7
+ template: cmd || null,
8
+ folderName: args[0] || null,
9
+ argsAsIs: args[0] || null,
10
+ toPath: process.cwd()
11
+ };
12
+ };
@@ -0,0 +1,24 @@
1
+ import StartEndPoint from "../commands/startEndPoint.js";
2
+ import AddSubRoute from "../commands/addSubRoute.js";
3
+ import AddTableName from "../tasks/tables/addTableName.js";
4
+ // import ShowAll from "../commands/showAll.js";
5
+ import Insert from "../tasks/actions/insert.js";
6
+ import ShowAll from "../tasks/actions/showAll.js";
7
+
8
+ import CreateApi from "../Orchestration/CreateApi/createApi.js";
9
+ import InsertApi from "../Orchestration/InsertApi/insertApi.js";
10
+
11
+ // resolveCommand.js
12
+ const map = {
13
+ StartEndPoint,
14
+ AddSubRoute,
15
+ AddTableName,
16
+ ShowAll,
17
+ CreateApi,
18
+ InsertApi,
19
+ Insert
20
+ };
21
+
22
+ export default function resolveCommand(cmd) {
23
+ return map[cmd] || null;
24
+ };
@@ -0,0 +1,43 @@
1
+ /*
2
+ KSchema CLI – Entry Flow
3
+
4
+ 1. Read user input from terminal (parseInput)
5
+ 2. If no command → show usage (first-time user safety)
6
+ 3. If help flags → show usage (quick guidance)
7
+ 4. Resolve command dynamically (no hardcoding logic)
8
+ 5. If command not found → inform + guide back to usage
9
+ 6. Execute command with parsed input
10
+
11
+ Goal:
12
+ - Zero confusion for user
13
+ - Single source of truth (showUsage)
14
+ - Easy to extend (just add commands, no core changes)
15
+ */
16
+
17
+ export default function showUsage(version) {
18
+ const g = "\x1b[32m";
19
+ const y = "\x1b[33m";
20
+ const c = "\x1b[36m";
21
+ const gray = "\x1b[90m";
22
+ const r = "\x1b[0m";
23
+
24
+ console.log(`
25
+ ${c}🚀 KSchema Api Generator v${version}${r}
26
+
27
+ ${y}Usage:${r}
28
+ ${g}npx @keshavsoft/kschema-api-gen${r} <command> [options]
29
+
30
+ ${y}Commands:${r}
31
+ ${g}StartEndPoint${r} Initialize a new folder and files
32
+ ${g}CreateApi${r} Creates new end point and hooks to app.js
33
+ ${g}InsertApi${r} Creates new InsertApi end point and hooks to app.js
34
+
35
+ ${y}Examples:${r}
36
+ ${gray}npx @keshavsoft/kschema-api-gen StartEndPoint${r}
37
+ ${gray}npx @keshavsoft/kschema-api-gen CreateApi Api/V1/journals/ShowAll${r}
38
+ ${gray}npx @keshavsoft/kschema-api-gen InsertApi Api/V1/journals/Insert${r}
39
+
40
+ ${y}Tip:${r}
41
+ ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
42
+ `);
43
+ }
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import getLatestVersion from "./bin/core/getLatestVersion.js";
2
+
3
+ const load = async (cmd) => {
4
+ const v = getLatestVersion();
5
+ return (await import(`./bin/${v}/commands/exportCommands/${cmd}.js`)).default;
6
+ };
7
+
8
+ export const showAll = async (...a) => (await load("showAll"))(...a);
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@keshavsoft/kschema-api-gen-actions",
3
+ "version": "1.14.1",
4
+ "description": "CLI to scaffold projects using templates",
5
+ "keywords": [
6
+ "cli",
7
+ "scaffold",
8
+ "templates",
9
+ "node",
10
+ "project-generator"
11
+ ],
12
+ "dependencies": {
13
+ "@keshavsoft/kschema": "^1.17.8",
14
+ "@keshavsoft/kschema-api-check": "^1.10.3"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ ".": "./index.js"
19
+ },
20
+ "bin": {
21
+ "kschema-api-gen-actions": "./bin/cli.js"
22
+ },
23
+ "files": [
24
+ "bin/",
25
+ "index.js",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "homepage": "https://cli.keshavsoft.com",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/keshavsoft/kschema-cli"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/keshavsoft/kschema-cli/issues"
36
+ }
37
+ }