ui-fix-add-listeners-js 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,77 @@
1
+ # EndPoints Fix
2
+
3
+ Utility for automatically maintaining Express route files.
4
+
5
+ ## Purpose
6
+
7
+ This module updates `end-points.js` files by:
8
+
9
+ * Adding new route handlers
10
+ * Preventing duplicate routes
11
+ * Preserving route order
12
+ * Maintaining consistent formatting
13
+
14
+ ---
15
+
16
+ ## Generated Structure
17
+
18
+ ```js
19
+ import express from "express";
20
+
21
+ const tableName = "BillsTable";
22
+
23
+ const router = express.Router();
24
+
25
+ router.post("/Alter", express.json(), (req, res) =>
26
+ AlterFunc({ req, res, inTablePath: tablePath })
27
+ );
28
+
29
+ export { router };
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Rules
35
+
36
+ ### First Route
37
+
38
+ When the first route is inserted:
39
+
40
+ * Add one blank line after `const router = express.Router();`
41
+ * Add one blank line before `export { router };`
42
+
43
+ Example:
44
+
45
+ ```js
46
+ const router = express.Router();
47
+
48
+ router.post("/Alter", express.json(), handler);
49
+
50
+ export { router };
51
+ ```
52
+
53
+ ### Additional Routes
54
+
55
+ New routes are always appended after the last route.
56
+
57
+ Example:
58
+
59
+ ```js
60
+ router.post("/Alter", express.json(), handler);
61
+ router.post("/Alter1", express.json(), handler);
62
+ router.post("/Alter2", express.json(), handler);
63
+ ```
64
+
65
+ No blank lines are inserted between routes.
66
+
67
+ ---
68
+
69
+ ## Duplicate Protection
70
+
71
+ If a route already exists, no new route is added.
72
+
73
+ ---
74
+
75
+ ## Goal
76
+
77
+ Produce clean and predictable Express route files automatically.
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({}).then();
@@ -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,58 @@
1
+ {
2
+ "simple": {
3
+ "importLines": {
4
+ "toInsertLine": "import { router as routerFrom${folderName} } from './${folderName}/end-points.js';",
5
+ "toInsertLine_old": "import funcFrom${folderName} from './${folderName}/controller.js';",
6
+ "duplicationCheck": "from './${folderName}/end-points.js'",
7
+ "insertAfter": [
8
+ "import funcFrom",
9
+ "import express"
10
+ ]
11
+ },
12
+ "useLines": {
13
+ "toInsertLine": "router.use('/${endpoint}', routerFrom${endpoint});",
14
+ "toInsertLine_old": "router.get('/${endpoint}', (req, res) => funcFrom${folderName}({ req, res, inTablePath: tablePath }));",
15
+ "duplicationCheck": "router.use('/${endpoint}'",
16
+ "insertAfter": [
17
+ "router.",
18
+ "const router = "
19
+ ]
20
+ }
21
+ },
22
+ "withParams": {
23
+ "importLines": {
24
+ "toInsertLine": "import funcFrom${folderName} from './${folderName}/controller.js';",
25
+ "duplicationCheck": "from './${folderName}/controller.js'",
26
+ "insertAfter": [
27
+ "import funcFrom",
28
+ "import express"
29
+ ]
30
+ },
31
+ "useLines": {
32
+ "toInsertLine": "router.get('/${endpoint}/:pk', (req, res) => funcFrom${folderName}({ req, res, inTablePath: tablePath }));",
33
+ "duplicationCheck": "router.get('/${endpoint}'",
34
+ "insertAfter": [
35
+ "router.",
36
+ "const router = "
37
+ ]
38
+ }
39
+ },
40
+ "withParamsDynamic": {
41
+ "importLines": {
42
+ "toInsertLine": "import funcFrom${folderName} from './${folderName}/controller.js';",
43
+ "duplicationCheck": "from './${folderName}/controller.js'",
44
+ "insertAfter": [
45
+ "import funcFrom",
46
+ "import express"
47
+ ]
48
+ },
49
+ "useLines": {
50
+ "toInsertLine": "router.get('/${endpoint}/:${inColumnName}', (req, res) => funcFrom${folderName}({ req, res, inTablePath: tablePath }));",
51
+ "duplicationCheck": "router.get('/${endpoint}'",
52
+ "insertAfter": [
53
+ "router.",
54
+ "const router = "
55
+ ]
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,56 @@
1
+ import fixAnyJs from "express-fix-any-js";
2
+ import checkLines from "./checkLines.json" with {type: "json"};
3
+
4
+ const checkLinesKeys = Object.keys(checkLines);
5
+
6
+ const alterLines = ({ inActionName, inFolderName, inGetType }) => {
7
+ let checkLinesData = checkLines;
8
+ if (!checkLinesData[inGetType]) {
9
+ throw new Error(`Invalid inGetType: ${inGetType}. Must be one of: ${checkLinesKeys.join(", ")}`);
10
+ };
11
+
12
+ // Deep clone the configuration to avoid mutating the cached JSON import.
13
+ let localCheckLines = JSON.parse(JSON.stringify(checkLinesData[inGetType]));
14
+
15
+ if (localCheckLines.importLines && localCheckLines.importLines.toInsertLine) {
16
+ localCheckLines.importLines.toInsertLine = localCheckLines.importLines.toInsertLine.replaceAll("${folderName}", inFolderName);
17
+ }
18
+ if (localCheckLines.importLines && localCheckLines.importLines.duplicationCheck) {
19
+ localCheckLines.importLines.duplicationCheck = localCheckLines.importLines.duplicationCheck.replaceAll("${folderName}", inFolderName).replaceAll("'", '"');
20
+ }
21
+
22
+ if (localCheckLines.useLines && localCheckLines.useLines.toInsertLine) {
23
+ localCheckLines.useLines.toInsertLine = localCheckLines.useLines.toInsertLine.replaceAll("${endpoint}", inActionName);
24
+ localCheckLines.useLines.toInsertLine = localCheckLines.useLines.toInsertLine.replaceAll("${folderName}", inFolderName);
25
+ };
26
+
27
+ if (localCheckLines.useLines && localCheckLines.useLines.duplicationCheck) {
28
+ localCheckLines.useLines.duplicationCheck = localCheckLines.useLines.duplicationCheck.replaceAll("${endpoint}", inActionName).replaceAll("'", '"');
29
+ };
30
+
31
+ return localCheckLines;
32
+ };
33
+
34
+ const getCheckLinesValue = ({ inKey }) => {
35
+ if (!(inKey in checkLines)) {
36
+ throw new Error(`Invalid inKey: ${inKey}. Must be one of: ${checkLinesKeys.join(", ")}`);
37
+ };
38
+
39
+ return checkLines[inKey];
40
+ };
41
+
42
+ const startFunc = ({ inJsFilePath, inActionName, inFolderName, showLog = false, inGetType }) => {
43
+
44
+ const localCheckLines = alterLines({ inActionName, inFolderName, inGetType });
45
+
46
+ const fromFixAnyJs = fixAnyJs({
47
+ showLog,
48
+ jsFilePath: inJsFilePath,
49
+ inCheckLines: localCheckLines
50
+ });
51
+
52
+ return fromFixAnyJs;
53
+ };
54
+
55
+ export { getCheckLinesValue, checkLinesKeys };
56
+ export default startFunc;
@@ -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,18 @@
1
+ export default function parseInput({ jsFilePath, inGetType = "simple",
2
+ showLog, inActionName = "KeshavSoftAction", inFolderName = "KeshavSoftFolderName",
3
+ inColumnName
4
+ }) {
5
+
6
+ const [...args] = process.argv.slice(2);
7
+
8
+ return {
9
+ cmd: args[0],
10
+ showLog: args[1] === undefined
11
+ ? showLog
12
+ : args[1] === "true",
13
+ inJsFilePath: jsFilePath || process.cwd(),
14
+ inActionName, inFolderName, inGetType,
15
+ inColumnName,
16
+ args
17
+ };
18
+ };
@@ -0,0 +1,55 @@
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}ShowKeys${r} Show the list of supported route types
32
+ ${g}ShowValue <key>${r} Show the configuration details for a specific route type
33
+ ${g}StartEndPoint${r} Initialize a new folder and files
34
+ ${g}AddSubRoute${r} Initialize a new folder and files
35
+ ${g}AddTableName${r} Initialize a new folder and files for TableName
36
+ ${g}ShowAll${r} Initialize a new folder and files for action
37
+
38
+ ${g}CreateApi${r} Creates new end point and hooks to app.js
39
+ ${g}InsertApi${r} Creates new InsertApi end point and hooks to app.js
40
+
41
+ ${y}Examples:${r}
42
+ ${gray}npx @keshavsoft/kschema-api-gen ShowKeys${r}
43
+ ${gray}npx @keshavsoft/kschema-api-gen ShowValue simple${r}
44
+ ${gray}npx @keshavsoft/kschema-api-gen StartEndPoint${r}
45
+ ${gray}npx @keshavsoft/kschema-api-gen AddSubRoute${r}
46
+ ${gray}npx @keshavsoft/kschema-api-gen AddTableName${r}
47
+ ${gray}npx @keshavsoft/kschema-api-gen ShowAll${r}
48
+ ${gray}npx @keshavsoft/kschema-api-gen CreateApi Api/V1/journals/ShowAll${r}
49
+ ${gray}npx @keshavsoft/kschema-api-gen InsertApi Api/V1/journals/Insert${r}
50
+
51
+ ${y}Tip:${r}
52
+ ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
53
+ `);
54
+
55
+ }
@@ -0,0 +1,56 @@
1
+ import parseInput from "./core/parseInput.js";
2
+ import showUsage from './core/showUsage.js';
3
+
4
+ import updateJs, { checkLinesKeys, getCheckLinesValue } from "./UpdateJs/index.js";
5
+
6
+ import pkg from '../../package.json' with { type: 'json' };
7
+
8
+ const version = pkg.version;
9
+
10
+ const run = ({ endPointsJsPath, showLog, inActionName, inFolderName, inGetType,
11
+ inColumnName
12
+ }) => {
13
+
14
+ const input = parseInput({
15
+ jsFilePath: endPointsJsPath, showLog,
16
+ inActionName, inFolderName, inGetType, inColumnName
17
+ });
18
+
19
+ if (!endPointsJsPath) {
20
+ if (!input.cmd || input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") {
21
+ return showUsage(version);
22
+ }
23
+
24
+ const validCommands = ["ShowKeys", "ShowValue"];
25
+ if (!validCommands.includes(input.cmd)) {
26
+ console.error(`\x1b[31mError: Invalid command "${input.cmd}"\x1b[0m`);
27
+ showUsage(version);
28
+ process.exit(1);
29
+ }
30
+ }
31
+
32
+ if (input.cmd === "ShowKeys") {
33
+ console.log(checkLinesKeys);
34
+ return;
35
+ }
36
+
37
+ if (input.cmd === "ShowValue") {
38
+ const key = input.args[1];
39
+ if (!key) {
40
+ console.error(`Error: Please specify a key. Valid keys are: ${checkLinesKeys.join(", ")}`);
41
+ process.exit(1);
42
+ }
43
+ try {
44
+ const val = getCheckLinesValue({ inKey: key });
45
+ console.log(JSON.stringify(val, null, 2));
46
+ } catch (e) {
47
+ console.error(e.message);
48
+ process.exit(1);
49
+ }
50
+ return;
51
+ }
52
+
53
+ return updateJs(input);
54
+ };
55
+
56
+ export default run;
@@ -0,0 +1,21 @@
1
+ {
2
+ "simple": {
3
+ "importLines": {
4
+ "toInsertLine": "import folderName from './${folderName}/start.js';",
5
+ "duplicationCheck": "from './${folderName}/start.js'",
6
+ "insertAfter": [
7
+ "import funcFrom",
8
+ "import express"
9
+ ]
10
+ },
11
+ "useLines": {
12
+ "toInsertLine": "router.use('/${endpoint}', routerFrom${endpoint});",
13
+ "toInsertLine_old": "router.get('/${endpoint}', (req, res) => funcFrom${folderName}({ req, res, inTablePath: tablePath }));",
14
+ "duplicationCheck": "router.use('/${endpoint}'",
15
+ "insertAfter": [
16
+ "router.",
17
+ "const router = "
18
+ ]
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,56 @@
1
+ import fixAnyJs from "express-fix-any-js";
2
+ import checkLines from "./checkLines.json" with {type: "json"};
3
+
4
+ const checkLinesKeys = Object.keys(checkLines);
5
+
6
+ const alterLines = ({ inActionName, inFolderName, inGetType }) => {
7
+ let checkLinesData = checkLines;
8
+ if (!checkLinesData[inGetType]) {
9
+ throw new Error(`Invalid inGetType: ${inGetType}. Must be one of: ${checkLinesKeys.join(", ")}`);
10
+ };
11
+
12
+ // Deep clone the configuration to avoid mutating the cached JSON import.
13
+ let localCheckLines = JSON.parse(JSON.stringify(checkLinesData[inGetType]));
14
+
15
+ if (localCheckLines.importLines && localCheckLines.importLines.toInsertLine) {
16
+ localCheckLines.importLines.toInsertLine = localCheckLines.importLines.toInsertLine.replaceAll("${folderName}", inFolderName);
17
+ }
18
+ if (localCheckLines.importLines && localCheckLines.importLines.duplicationCheck) {
19
+ localCheckLines.importLines.duplicationCheck = localCheckLines.importLines.duplicationCheck.replaceAll("${folderName}", inFolderName).replaceAll("'", '"');
20
+ }
21
+
22
+ if (localCheckLines.useLines && localCheckLines.useLines.toInsertLine) {
23
+ localCheckLines.useLines.toInsertLine = localCheckLines.useLines.toInsertLine.replaceAll("${endpoint}", inActionName);
24
+ localCheckLines.useLines.toInsertLine = localCheckLines.useLines.toInsertLine.replaceAll("${folderName}", inFolderName);
25
+ };
26
+
27
+ if (localCheckLines.useLines && localCheckLines.useLines.duplicationCheck) {
28
+ localCheckLines.useLines.duplicationCheck = localCheckLines.useLines.duplicationCheck.replaceAll("${endpoint}", inActionName).replaceAll("'", '"');
29
+ };
30
+
31
+ return localCheckLines;
32
+ };
33
+
34
+ const getCheckLinesValue = ({ inKey }) => {
35
+ if (!(inKey in checkLines)) {
36
+ throw new Error(`Invalid inKey: ${inKey}. Must be one of: ${checkLinesKeys.join(", ")}`);
37
+ };
38
+
39
+ return checkLines[inKey];
40
+ };
41
+
42
+ const startFunc = ({ inJsFilePath, inActionName, inFolderName, showLog = false, inGetType }) => {
43
+
44
+ const localCheckLines = alterLines({ inActionName, inFolderName, inGetType });
45
+
46
+ const fromFixAnyJs = fixAnyJs({
47
+ showLog,
48
+ jsFilePath: inJsFilePath,
49
+ inCheckLines: localCheckLines
50
+ });
51
+
52
+ return fromFixAnyJs;
53
+ };
54
+
55
+ export { getCheckLinesValue, checkLinesKeys };
56
+ export default startFunc;
@@ -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,18 @@
1
+ export default function parseInput({ jsFilePath, inGetType = "simple",
2
+ showLog, inActionName = "KeshavSoftAction", inFolderName = "KeshavSoftFolderName",
3
+ inColumnName
4
+ }) {
5
+
6
+ const [...args] = process.argv.slice(2);
7
+
8
+ return {
9
+ cmd: args[0],
10
+ showLog: args[1] === undefined
11
+ ? showLog
12
+ : args[1] === "true",
13
+ inJsFilePath: jsFilePath || process.cwd(),
14
+ inActionName, inFolderName, inGetType,
15
+ inColumnName,
16
+ args
17
+ };
18
+ };
@@ -0,0 +1,55 @@
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}ShowKeys${r} Show the list of supported route types
32
+ ${g}ShowValue <key>${r} Show the configuration details for a specific route type
33
+ ${g}StartEndPoint${r} Initialize a new folder and files
34
+ ${g}AddSubRoute${r} Initialize a new folder and files
35
+ ${g}AddTableName${r} Initialize a new folder and files for TableName
36
+ ${g}ShowAll${r} Initialize a new folder and files for action
37
+
38
+ ${g}CreateApi${r} Creates new end point and hooks to app.js
39
+ ${g}InsertApi${r} Creates new InsertApi end point and hooks to app.js
40
+
41
+ ${y}Examples:${r}
42
+ ${gray}npx @keshavsoft/kschema-api-gen ShowKeys${r}
43
+ ${gray}npx @keshavsoft/kschema-api-gen ShowValue simple${r}
44
+ ${gray}npx @keshavsoft/kschema-api-gen StartEndPoint${r}
45
+ ${gray}npx @keshavsoft/kschema-api-gen AddSubRoute${r}
46
+ ${gray}npx @keshavsoft/kschema-api-gen AddTableName${r}
47
+ ${gray}npx @keshavsoft/kschema-api-gen ShowAll${r}
48
+ ${gray}npx @keshavsoft/kschema-api-gen CreateApi Api/V1/journals/ShowAll${r}
49
+ ${gray}npx @keshavsoft/kschema-api-gen InsertApi Api/V1/journals/Insert${r}
50
+
51
+ ${y}Tip:${r}
52
+ ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
53
+ `);
54
+
55
+ }
@@ -0,0 +1,56 @@
1
+ import parseInput from "./core/parseInput.js";
2
+ import showUsage from './core/showUsage.js';
3
+
4
+ import updateJs, { checkLinesKeys, getCheckLinesValue } from "./UpdateJs/index.js";
5
+
6
+ import pkg from '../../package.json' with { type: 'json' };
7
+
8
+ const version = pkg.version;
9
+
10
+ const run = ({ endPointsJsPath, showLog, inActionName, inFolderName, inGetType,
11
+ inColumnName
12
+ }) => {
13
+
14
+ const input = parseInput({
15
+ jsFilePath: endPointsJsPath, showLog,
16
+ inActionName, inFolderName, inGetType, inColumnName
17
+ });
18
+
19
+ if (!endPointsJsPath) {
20
+ if (!input.cmd || input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") {
21
+ return showUsage(version);
22
+ }
23
+
24
+ const validCommands = ["ShowKeys", "ShowValue"];
25
+ if (!validCommands.includes(input.cmd)) {
26
+ console.error(`\x1b[31mError: Invalid command "${input.cmd}"\x1b[0m`);
27
+ showUsage(version);
28
+ process.exit(1);
29
+ }
30
+ }
31
+
32
+ if (input.cmd === "ShowKeys") {
33
+ console.log(checkLinesKeys);
34
+ return;
35
+ }
36
+
37
+ if (input.cmd === "ShowValue") {
38
+ const key = input.args[1];
39
+ if (!key) {
40
+ console.error(`Error: Please specify a key. Valid keys are: ${checkLinesKeys.join(", ")}`);
41
+ process.exit(1);
42
+ }
43
+ try {
44
+ const val = getCheckLinesValue({ inKey: key });
45
+ console.log(JSON.stringify(val, null, 2));
46
+ } catch (e) {
47
+ console.error(e.message);
48
+ process.exit(1);
49
+ }
50
+ return;
51
+ }
52
+
53
+ return updateJs(input);
54
+ };
55
+
56
+ export default run;
package/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import getLatestVersion from "./bin/core/getLatestVersion.js";
2
+
3
+ const load = async ({ endPointsJsPath, inActionName, showLog, inFolderName,
4
+ inGetType, inColumnName }) => {
5
+
6
+ const v = getLatestVersion();
7
+
8
+ const module = await import(`./bin/${v}/start.js`);
9
+
10
+ return await module.default({
11
+ endPointsJsPath, inFolderName,
12
+ inActionName, showLog, inGetType, inColumnName
13
+ });
14
+ };
15
+
16
+ const getCheckLinesKeys = async () => {
17
+ const v = getLatestVersion();
18
+ const { checkLinesKeys } = await import(`./bin/${v}/UpdateJs/index.js`);
19
+ return checkLinesKeys;
20
+ };
21
+
22
+ const getCheckLinesValue = async ({ inKey }) => {
23
+ const v = getLatestVersion();
24
+ const { getCheckLinesValue } = await import(`./bin/${v}/UpdateJs/index.js`);
25
+ return getCheckLinesValue({ inKey });
26
+ };
27
+
28
+ export { getCheckLinesKeys, getCheckLinesValue };
29
+ export default load;
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "ui-fix-add-listeners-js",
3
+ "version": "1.2.2",
4
+ "description": "CLI to build for appjs, the endpoints",
5
+ "keywords": [
6
+ "cli",
7
+ "scaffold",
8
+ "templates",
9
+ "node",
10
+ "project-generator"
11
+ ],
12
+ "dependencies": {
13
+ "express-fix-any-js": "^1.7.7"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": "./index.js"
18
+ },
19
+ "bin": {
20
+ "ui-fix-add-listeners-js": "./bin/cli.js"
21
+ },
22
+ "files": [
23
+ "bin/",
24
+ "index.js",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "homepage": "https://cli.keshavsoft.com",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/keshavsoft/ui-fix-addListeners-js"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/keshavsoft/ui-fix-addListeners-js/issues"
35
+ }
36
+ }