json-crud-ui 1.1.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 (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +225 -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/v10/commands/exportCommands/endPointsJs.js +5 -0
  7. package/bin/v10/core/createFolder.js +34 -0
  8. package/bin/v10/core/parseInput.js +9 -0
  9. package/bin/v10/core/resolveCommand.js +13 -0
  10. package/bin/v10/core/showUsage.js +39 -0
  11. package/bin/v10/start.js +22 -0
  12. package/bin/v10/tasks/actions/EndPointsJs/Distinct/index.js +32 -0
  13. package/bin/v10/tasks/actions/EndPointsJs/Distinct/insertImport.js +15 -0
  14. package/bin/v10/tasks/actions/EndPointsJs/Distinct/insertUsage.js +15 -0
  15. package/bin/v10/tasks/actions/EndPointsJs/Insert/index.js +33 -0
  16. package/bin/v10/tasks/actions/EndPointsJs/Insert/insertImport.js +15 -0
  17. package/bin/v10/tasks/actions/EndPointsJs/Insert/insertUsage.js +15 -0
  18. package/bin/v10/tasks/actions/EndPointsJs/ShowAll/index.js +33 -0
  19. package/bin/v10/tasks/actions/EndPointsJs/ShowAll/insertImport.js +15 -0
  20. package/bin/v10/tasks/actions/EndPointsJs/ShowAll/insertUsage.js +15 -0
  21. package/bin/v10/tasks/actions/EndPointsJs/index.js +37 -0
  22. package/bin/v10/tasks/actions/EndPointsJs/showUsage.js +38 -0
  23. package/bin/v10/tasks/actions/appJs.js +6 -0
  24. package/bin/v10/tasks/common/SourceEditor.js +66 -0
  25. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
  26. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  27. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
  28. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  29. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  30. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  31. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
  32. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
  33. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  34. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  35. package/bin/v10/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
  36. package/bin/v10/tasks/tables/AddTableName/steps/announce.js +9 -0
  37. package/bin/v10/tasks/tables/AddTableName/steps/createFolder.js +7 -0
  38. package/bin/v10/tasks/tables/AddTableName/steps/decideTemplate.js +3 -0
  39. package/bin/v10/tasks/tables/AddTableName/steps/locateDestination.js +6 -0
  40. package/bin/v10/tasks/tables/AddTableName/steps/locateSource.js +13 -0
  41. package/bin/v10/tasks/tables/AddTableName/steps/resolveFolderName.js +20 -0
  42. package/bin/v10/tasks/tables/AddTableName/steps/updateConfig.js +16 -0
  43. package/bin/v10/tasks/tables/AddTableName/steps/updateEndPointsFile.js +30 -0
  44. package/bin/v10/tasks/tables/AddTableName/steps/updateTableName.js +30 -0
  45. package/bin/v10/tasks/tables/AddTableName/template/Config/schema.json +3 -0
  46. package/bin/v10/tasks/tables/AddTableName/template/end-points.js +7 -0
  47. package/bin/v10/tasks/tables/addTableName.js +56 -0
  48. package/bin/v11/commands/loadCommand.js +7 -0
  49. package/bin/v11/config/actions.json +35 -0
  50. package/bin/v11/config/actionsV1.json +20 -0
  51. package/bin/v11/config/actionsV2.json +27 -0
  52. package/bin/v11/core/createFolder.js +34 -0
  53. package/bin/v11/core/parseInput.js +8 -0
  54. package/bin/v11/core/resolveCommand.js +13 -0
  55. package/bin/v11/core/showUsage.js +39 -0
  56. package/bin/v11/start.js +29 -0
  57. package/bin/v11/tasks/actions/EndPointsJs/AlterJsFile/index.js +31 -0
  58. package/bin/v11/tasks/actions/EndPointsJs/AlterJsFile/insertImport.js +15 -0
  59. package/bin/v11/tasks/actions/EndPointsJs/AlterJsFile/insertUsage.js +15 -0
  60. package/bin/v11/tasks/actions/EndPointsJs/Distinct/index.js +32 -0
  61. package/bin/v11/tasks/actions/EndPointsJs/Distinct/insertImport.js +15 -0
  62. package/bin/v11/tasks/actions/EndPointsJs/Distinct/insertUsage.js +15 -0
  63. package/bin/v11/tasks/actions/EndPointsJs/Insert/index.js +33 -0
  64. package/bin/v11/tasks/actions/EndPointsJs/Insert/insertImport.js +15 -0
  65. package/bin/v11/tasks/actions/EndPointsJs/Insert/insertUsage.js +15 -0
  66. package/bin/v11/tasks/actions/EndPointsJs/ShowAll/index.js +33 -0
  67. package/bin/v11/tasks/actions/EndPointsJs/ShowAll/insertImport.js +15 -0
  68. package/bin/v11/tasks/actions/EndPointsJs/ShowAll/insertUsage.js +15 -0
  69. package/bin/v11/tasks/actions/EndPointsJs/index.js +19 -0
  70. package/bin/v11/tasks/actions/EndPointsJs/showUsage.js +38 -0
  71. package/bin/v11/tasks/actions/appJs.js +6 -0
  72. package/bin/v11/tasks/common/SourceEditor.js +66 -0
  73. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
  74. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  75. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
  76. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  77. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  78. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  79. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
  80. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
  81. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  82. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  83. package/bin/v11/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
  84. package/bin/v11/tasks/tables/AddTableName/steps/announce.js +9 -0
  85. package/bin/v11/tasks/tables/AddTableName/steps/createFolder.js +7 -0
  86. package/bin/v11/tasks/tables/AddTableName/steps/decideTemplate.js +3 -0
  87. package/bin/v11/tasks/tables/AddTableName/steps/locateDestination.js +6 -0
  88. package/bin/v11/tasks/tables/AddTableName/steps/locateSource.js +13 -0
  89. package/bin/v11/tasks/tables/AddTableName/steps/resolveFolderName.js +20 -0
  90. package/bin/v11/tasks/tables/AddTableName/steps/updateConfig.js +16 -0
  91. package/bin/v11/tasks/tables/AddTableName/steps/updateEndPointsFile.js +30 -0
  92. package/bin/v11/tasks/tables/AddTableName/steps/updateTableName.js +30 -0
  93. package/bin/v11/tasks/tables/AddTableName/template/Config/schema.json +3 -0
  94. package/bin/v11/tasks/tables/AddTableName/template/end-points.js +7 -0
  95. package/bin/v11/tasks/tables/addTableName.js +56 -0
  96. package/bin/v12/commands/loadCommand.js +7 -0
  97. package/bin/v12/config/actions.json +46 -0
  98. package/bin/v12/config/actionsV1.json +20 -0
  99. package/bin/v12/config/actionsV2.json +27 -0
  100. package/bin/v12/config/actionsV3.json +35 -0
  101. package/bin/v12/config/actionsV4.json +35 -0
  102. package/bin/v12/core/createFolder.js +34 -0
  103. package/bin/v12/core/parseInput.js +8 -0
  104. package/bin/v12/core/resolveCommand.js +13 -0
  105. package/bin/v12/core/showUsage.js +39 -0
  106. package/bin/v12/start.js +21 -0
  107. package/bin/v12/tasks/actions/EndPointsJs/AlterJsFile/index.js +31 -0
  108. package/bin/v12/tasks/actions/EndPointsJs/AlterJsFile/insertImport.js +15 -0
  109. package/bin/v12/tasks/actions/EndPointsJs/AlterJsFile/insertUsage.js +15 -0
  110. package/bin/v12/tasks/actions/EndPointsJs/index.js +19 -0
  111. package/bin/v12/tasks/actions/EndPointsJs/showUsage.js +38 -0
  112. package/bin/v12/tasks/actions/appJs.js +6 -0
  113. package/bin/v12/tasks/common/SourceEditor.js +66 -0
  114. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/readFile.js +8 -0
  115. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/common/writeFile.js +10 -0
  116. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/index.js +9 -0
  117. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/buildImport.js +9 -0
  118. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/checkDuplicate.js +8 -0
  119. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/findInsertIndex.js +10 -0
  120. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateImports/index.js +41 -0
  121. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/buildUseLine.js +11 -0
  122. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/checkDuplicate.js +8 -0
  123. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/findInsertIndex.js +10 -0
  124. package/bin/v12/tasks/tables/AddTableName/steps/UpdateRoutesJs/updateUse/index.js +42 -0
  125. package/bin/v12/tasks/tables/AddTableName/steps/announce.js +9 -0
  126. package/bin/v12/tasks/tables/AddTableName/steps/createFolder.js +7 -0
  127. package/bin/v12/tasks/tables/AddTableName/steps/decideTemplate.js +3 -0
  128. package/bin/v12/tasks/tables/AddTableName/steps/locateDestination.js +6 -0
  129. package/bin/v12/tasks/tables/AddTableName/steps/locateSource.js +13 -0
  130. package/bin/v12/tasks/tables/AddTableName/steps/resolveFolderName.js +20 -0
  131. package/bin/v12/tasks/tables/AddTableName/steps/updateConfig.js +16 -0
  132. package/bin/v12/tasks/tables/AddTableName/steps/updateEndPointsFile.js +30 -0
  133. package/bin/v12/tasks/tables/AddTableName/steps/updateTableName.js +30 -0
  134. package/bin/v12/tasks/tables/AddTableName/template/Config/schema.json +3 -0
  135. package/bin/v12/tasks/tables/AddTableName/template/end-points.js +7 -0
  136. package/bin/v12/tasks/tables/addTableName.js +56 -0
  137. package/index.js +5 -0
  138. package/package.json +35 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KeshavSoft
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to do so, subject to the
10
+ following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ ````md
2
+ # KSchema API Check
3
+
4
+ A lightweight CLI utility to validate and inspect `end-points.js` files inside KSchema-based projects.
5
+
6
+ Built for fast development workflows, clean architecture, and reusable tooling.
7
+
8
+ ---
9
+
10
+ ## Installation
11
+
12
+ ### Run directly with npx
13
+
14
+ ```bash
15
+ npx kschema-api-check
16
+ ````
17
+
18
+ ### Global install
19
+
20
+ ```bash
21
+ npm i -g kschema-api-check
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Purpose
27
+
28
+ This package helps developers:
29
+
30
+ * Validate `end-points.js`
31
+ * Inspect API route structure
32
+ * Automate repetitive checks
33
+ * Build scalable CLI workflows
34
+ * Extend command-based tooling cleanly
35
+
36
+ ---
37
+
38
+ # Features
39
+
40
+ * Clean command architecture
41
+ * Action-based execution
42
+ * Modular structure
43
+ * Easy to extend
44
+ * Lightweight
45
+ * ES Modules support
46
+ * Zero framework dependency
47
+
48
+ ---
49
+
50
+ # Commands
51
+
52
+ ## endPointsJs
53
+
54
+ Checks and processes `end-points.js`.
55
+
56
+ ### Usage
57
+
58
+ ```bash
59
+ npx kschema-api-check endPointsJs
60
+ ```
61
+
62
+ ---
63
+
64
+ # Actions
65
+
66
+ ## ShowAll
67
+
68
+ Displays all detected endpoints.
69
+
70
+ ### Usage
71
+
72
+ ```bash
73
+ npx kschema-api-check endPointsJs ShowAll
74
+ ```
75
+
76
+ ---
77
+
78
+ # Example
79
+
80
+ Suppose your project contains:
81
+
82
+ ```txt
83
+ /end-points.js
84
+ ```
85
+
86
+ Running:
87
+
88
+ ```bash
89
+ npx kschema-api-check endPointsJs ShowAll
90
+ ```
91
+
92
+ will analyze the file and display endpoint information.
93
+
94
+ ---
95
+
96
+ # Project Structure
97
+
98
+ ```txt
99
+ bin/
100
+ └── v10/
101
+ ├── commands/
102
+ ├── core/
103
+ ├── tasks/
104
+ │ ├── actions/
105
+ │ ├── common/
106
+ │ └── tables/
107
+ └── start.js
108
+ ```
109
+
110
+ ---
111
+
112
+ # Architecture
113
+
114
+ The CLI follows a layered architecture:
115
+
116
+ ## Core
117
+
118
+ Responsible for:
119
+
120
+ * parsing input
121
+ * resolving commands
122
+ * showing usage
123
+ * bootstrapping execution
124
+
125
+ ## Commands
126
+
127
+ Responsible for:
128
+
129
+ * command routing
130
+ * command validation
131
+
132
+ ## Actions
133
+
134
+ Responsible for:
135
+
136
+ * feature execution
137
+ * business logic
138
+
139
+ This separation keeps the codebase maintainable and scalable.
140
+
141
+ ---
142
+
143
+ # Why This Project Exists
144
+
145
+ Most projects repeatedly write the same API inspection logic.
146
+
147
+ This tool centralizes:
148
+
149
+ * validation
150
+ * inspection
151
+ * command execution
152
+ * reusable CLI workflows
153
+
154
+ into one clean developer utility.
155
+
156
+ ---
157
+
158
+ # Development
159
+
160
+ Clone repository:
161
+
162
+ ```bash
163
+ git clone https://github.com/keshavsoft/kschema-api-check.git
164
+ ```
165
+
166
+ Install dependencies:
167
+
168
+ ```bash
169
+ npm install
170
+ ```
171
+
172
+ Run locally:
173
+
174
+ ```bash
175
+ node test/insert.js
176
+ ```
177
+
178
+ ---
179
+
180
+ # Future Plans
181
+
182
+ * Insert endpoint templates
183
+ * Auto route generation
184
+ * Schema validation
185
+ * API documentation generation
186
+ * Interactive CLI prompts
187
+ * Multi-project scanning
188
+
189
+ ---
190
+
191
+ # Tech Stack
192
+
193
+ * Node.js
194
+ * ES Modules
195
+ * JavaScript
196
+
197
+ ---
198
+
199
+ # Philosophy
200
+
201
+ > Simple tools. Clean architecture. Fast development.
202
+
203
+ ---
204
+
205
+ # Author
206
+
207
+ KeshavSoft
208
+
209
+ GitHub:
210
+ https://github.com/keshavsoft
211
+
212
+ ---
213
+
214
+ # Repository
215
+
216
+ https://github.com/keshavsoft/kschema-api-check
217
+
218
+ ---
219
+
220
+ # License
221
+
222
+ MIT
223
+
224
+ ```
225
+ ```
package/bin/cli.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ import getLatestVersion from "./core/getLatestVersion.js";
4
+ import loadRunner from "./core/loadRunner.js";
5
+
6
+ const run = async () => {
7
+ const version = getLatestVersion();
8
+ const runner = await loadRunner(version);
9
+ await runner();
10
+ };
11
+
12
+ run();
@@ -0,0 +1,13 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+
7
+ export default function getLatestVersion() {
8
+ const versions = fs.readdirSync(path.join(__dirname, ".."))
9
+ .filter(n => /^v\d+$/.test(n))
10
+ .sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
11
+
12
+ return versions.at(-1);
13
+ };
@@ -0,0 +1,9 @@
1
+ export default async function loadRunner(version) {
2
+ const mod = await import(`../${version}/start.js`);
3
+
4
+ if (typeof mod.default !== "function") {
5
+ throw new Error(`Invalid start.js in ${version}`);
6
+ }
7
+
8
+ return mod.default;
9
+ };
@@ -0,0 +1,5 @@
1
+ // bin/v9/commands/exportCommands/endPointsJs.js
2
+
3
+ import endPointsJs from "../../tasks/actions/EndPointsJs/index.js";
4
+
5
+ export default endPointsJs;
@@ -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,9 @@
1
+ export default function parseInput() {
2
+ const [cmd, action] = process.argv.slice(2);
3
+
4
+ return {
5
+ cmd: cmd || null,
6
+ action: action || null,
7
+ toPath: process.cwd()
8
+ };
9
+ };
@@ -0,0 +1,13 @@
1
+ // import endPointsJs from "../tasks/actions/EndPointsJs/ShowAll/index.js";
2
+ import appJs from "../tasks/actions/appJs.js";
3
+ import endPointsJs from "../tasks/actions/EndPointsJs/index.js";
4
+
5
+ // resolveCommand.js
6
+ const map = {
7
+ endPointsJs,
8
+ appJs
9
+ };
10
+
11
+ export default function resolveCommand(cmd) {
12
+ return map[cmd] || null;
13
+ };
@@ -0,0 +1,39 @@
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}endPointsJs${r} Checks for end-points.js file in that location
32
+
33
+ ${y}Examples:${r}
34
+ ${gray}npx @keshavsoft/kschema-api-gen endPointsJs ShowAll${r}
35
+
36
+ ${y}Tip:${r}
37
+ ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
38
+ `);
39
+ }
@@ -0,0 +1,22 @@
1
+ import parseInput from "./core/parseInput.js";
2
+ import resolveCommand from "./core/resolveCommand.js";
3
+ import showUsage from './core/showUsage.js';
4
+ import pkg from '../../package.json' with { type: 'json' };
5
+
6
+ const version = pkg.version;
7
+
8
+ const run = async () => {
9
+ const input = parseInput();
10
+
11
+ if (!input.cmd) return showUsage(version);
12
+
13
+ if (input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") return showUsage(version);
14
+
15
+ const command = resolveCommand(input.cmd);
16
+
17
+ if (!command) return (console.log(`Unknown command: ${input.cmd}\n`), showUsage(version));
18
+
19
+ await command(input);
20
+ };
21
+
22
+ export default run;
@@ -0,0 +1,32 @@
1
+ import SourceEditor from "../../../common/SourceEditor.js";
2
+
3
+ import insertImport from "./insertImport.js";
4
+ import insertUsage from "./insertUsage.js";
5
+
6
+ export default ({ action = "", toPath }) => {
7
+ const funcName = "getFunc";
8
+
9
+ const path = `${toPath}/end-points.js`;
10
+
11
+ const editor = new SourceEditor(path);
12
+
13
+ const importLine =
14
+ `import { ${funcName} } from "./${action}/controller.js";`;
15
+
16
+ const usageLine =
17
+ `router.get('/${action}/:columnName', (req, res) => ${funcName}({ req, res, inTableName: tableName }));`
18
+
19
+ insertImport({
20
+ editor,
21
+ importLine
22
+ });
23
+
24
+ editor.save();
25
+
26
+ insertUsage({
27
+ editor,
28
+ usageLine
29
+ });
30
+
31
+ editor.save();
32
+ };
@@ -0,0 +1,15 @@
1
+ // insertImport.js
2
+
3
+ export default ({ editor, importLine }) => {
4
+
5
+ if (!editor.hasLine(importLine)) {
6
+
7
+ const lastImportLine =
8
+ editor.findLastLine("import ");
9
+
10
+ editor.insertAfter({
11
+ line: lastImportLine,
12
+ content: importLine
13
+ });
14
+ };
15
+ };
@@ -0,0 +1,15 @@
1
+ // insertUsage.js
2
+ export default ({ editor, usageLine }) => {
3
+
4
+ if (!editor.hasLine(usageLine)) {
5
+
6
+ const exportLine =
7
+ editor.findLastLine("const router = ");
8
+ console.log("exportLine : ", exportLine);
9
+
10
+ editor.insertAfter({
11
+ line: exportLine,
12
+ content: usageLine
13
+ });
14
+ };
15
+ };
@@ -0,0 +1,33 @@
1
+ // bin/v9/tasks/actions/EndPointsJs/index.js
2
+
3
+ import SourceEditor from "../../../common/SourceEditor.js";
4
+
5
+ import insertImport from "./insertImport.js";
6
+ import insertUsage from "./insertUsage.js";
7
+
8
+ export default ({ action = "", toPath }) => {
9
+
10
+ const path = `${toPath}/end-points.js`;
11
+
12
+ const editor = new SourceEditor(path);
13
+
14
+ const importLine =
15
+ `import { postFunc } from "./${action}/controller.js";`;
16
+
17
+ const usageLine =
18
+ `router.post('/${action}', express.json(), (req, res) => postFunc({ req, res, inTableName: tableName }));`
19
+
20
+ insertImport({
21
+ editor,
22
+ importLine
23
+ });
24
+
25
+ editor.save();
26
+
27
+ insertUsage({
28
+ editor,
29
+ usageLine
30
+ });
31
+
32
+ editor.save();
33
+ };
@@ -0,0 +1,15 @@
1
+ // insertImport.js
2
+
3
+ export default ({ editor, importLine }) => {
4
+
5
+ if (!editor.hasLine(importLine)) {
6
+
7
+ const lastImportLine =
8
+ editor.findLastLine("import ");
9
+
10
+ editor.insertAfter({
11
+ line: lastImportLine,
12
+ content: importLine
13
+ });
14
+ };
15
+ };
@@ -0,0 +1,15 @@
1
+ // insertUsage.js
2
+ export default ({ editor, usageLine }) => {
3
+
4
+ if (!editor.hasLine(usageLine)) {
5
+
6
+ const exportLine =
7
+ editor.findLastLine("const router = ");
8
+ console.log("exportLine : ", exportLine);
9
+
10
+ editor.insertAfter({
11
+ line: exportLine,
12
+ content: usageLine
13
+ });
14
+ };
15
+ };
@@ -0,0 +1,33 @@
1
+ // bin/v9/tasks/actions/EndPointsJs/index.js
2
+
3
+ import SourceEditor from "../../../common/SourceEditor.js";
4
+
5
+ import insertImport from "./insertImport.js";
6
+ import insertUsage from "./insertUsage.js";
7
+
8
+ export default ({ action = "", toPath }) => {
9
+
10
+ const path = `${toPath}/end-points.js`;
11
+
12
+ const editor = new SourceEditor(path);
13
+
14
+ const importLine =
15
+ `import { getFunc } from "./${action}/controller.js";`;
16
+
17
+ const usageLine =
18
+ `router.get('/${action}', (req, res) => getFunc({ res, inTableName : tableName}));`;
19
+
20
+ insertImport({
21
+ editor,
22
+ importLine
23
+ });
24
+
25
+ editor.save();
26
+
27
+ insertUsage({
28
+ editor,
29
+ usageLine
30
+ });
31
+
32
+ editor.save();
33
+ };
@@ -0,0 +1,15 @@
1
+ // insertImport.js
2
+
3
+ export default ({ editor, importLine }) => {
4
+
5
+ if (!editor.hasLine(importLine)) {
6
+
7
+ const lastImportLine =
8
+ editor.findLastLine("import ");
9
+
10
+ editor.insertAfter({
11
+ line: lastImportLine,
12
+ content: importLine
13
+ });
14
+ };
15
+ };
@@ -0,0 +1,15 @@
1
+ // insertUsage.js
2
+ export default ({ editor, usageLine }) => {
3
+
4
+ if (!editor.hasLine(usageLine)) {
5
+
6
+ const exportLine =
7
+ editor.findLastLine("const router = ");
8
+ console.log("exportLine : ", exportLine);
9
+
10
+ editor.insertAfter({
11
+ line: exportLine,
12
+ content: usageLine
13
+ });
14
+ };
15
+ };
@@ -0,0 +1,37 @@
1
+ // bin/v9/tasks/actions/EndPointsJs/index.js
2
+
3
+ import showUsage from "./showUsage.js";
4
+
5
+ import forShowAll from "./ShowAll/index.js";
6
+ import forInsert from "./Insert/index.js";
7
+ import forDistinct from "./Distinct/index.js";
8
+
9
+ export default ({ action, toPath }) => {
10
+ switch (action) {
11
+ case undefined:
12
+ case null:
13
+ showUsage();
14
+
15
+ break;
16
+
17
+ case "ShowAll":
18
+ forShowAll({ action: "ShowAll", toPath });
19
+
20
+ break;
21
+
22
+ case "Insert":
23
+ forInsert({ action: "Insert", toPath });
24
+
25
+ break;
26
+
27
+ case "Distinct":
28
+ forDistinct({ action: "Distinct", toPath });
29
+
30
+ break;
31
+
32
+ default:
33
+ console.log(`Unknown action : ${action}`);
34
+
35
+ break;
36
+ };
37
+ };
@@ -0,0 +1,38 @@
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() {
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
+ ${y}Usage:${r}
26
+ ${g}npx kschema-api-gen endPointsJs${r} [options]
27
+
28
+ ${y}options:${r}
29
+ ${g}ShowAll${r} the action for get
30
+ ${g}Insert${r} the action for post
31
+ ${g}Distinct${r} the action for get and request param columnName
32
+
33
+ ${y}Examples:${r}
34
+ ${gray}npx kschema-api-gen endPointsJs ShowAll${r}
35
+ ${gray}npx kschema-api-gen endPointsJs Insert${r}
36
+ ${gray}npx kschema-api-gen endPointsJs Distinct${r}
37
+ `);
38
+ }
@@ -0,0 +1,6 @@
1
+ import path from "path";
2
+
3
+ export default ({ action = "", toPath, cmd, isAnnounce = true, checkBeforeCreate = true }) => {
4
+ const localToPath = toPath;
5
+ console.log(" aaaaaaaaa :", cmd, action, toPath);
6
+ };