express-fix-any-js 1.4.2 → 1.5.3

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 (31) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +79 -79
  3. package/bin/cli.js +11 -11
  4. package/bin/core/getLatestVersion.js +12 -12
  5. package/bin/core/loadRunner.js +8 -8
  6. package/bin/v4/UpdateJs/checkLines.json +17 -17
  7. package/bin/v4/UpdateJs/common/AlterFile/buildUpdatedContent.js +18 -18
  8. package/bin/v4/UpdateJs/common/AlterFile/checkDuplicate.js +20 -20
  9. package/bin/v4/UpdateJs/common/AlterFile/findInsertIndex.js +29 -29
  10. package/bin/v4/UpdateJs/common/AlterFile/index.js +54 -54
  11. package/bin/v4/UpdateJs/common/readFile.js +7 -7
  12. package/bin/v4/UpdateJs/common/writeFile.js +9 -9
  13. package/bin/v4/UpdateJs/index.js +55 -55
  14. package/bin/v4/core/parseInput.js +12 -12
  15. package/bin/v4/core/showUsage.js +49 -49
  16. package/bin/v4/start.js +17 -17
  17. package/bin/{v3 → v5}/UpdateJs/common/AlterFile/buildUpdatedContent.js +26 -18
  18. package/bin/{v3 → v5}/UpdateJs/common/AlterFile/checkDuplicate.js +20 -20
  19. package/bin/{v3 → v5}/UpdateJs/common/AlterFile/findInsertIndex.js +29 -29
  20. package/bin/{v3 → v5}/UpdateJs/common/AlterFile/index.js +54 -55
  21. package/bin/{v3 → v5}/UpdateJs/common/readFile.js +7 -7
  22. package/bin/{v3 → v5}/UpdateJs/common/writeFile.js +9 -9
  23. package/bin/{v3 → v5}/UpdateJs/index.js +29 -30
  24. package/bin/v5/UpdateJs/validateCheckLines.js +31 -0
  25. package/bin/{v3 → v5}/core/parseInput.js +12 -12
  26. package/bin/{v3 → v5}/core/showUsage.js +49 -49
  27. package/bin/{v3 → v5}/start.js +17 -17
  28. package/index.js +10 -10
  29. package/package.json +33 -33
  30. package/bin/v3/UpdateJs/checkLines.json +0 -18
  31. package/bin/v3/core/createFolder.js +0 -34
@@ -1,13 +1,13 @@
1
- export default function parseInput({ jsFilePath,
2
- inCheckLines = {}, showLog }) {
3
-
4
- const [...args] = process.argv.slice(2);
5
-
6
- return {
7
- showLog: args[1] === undefined
8
- ? showLog
9
- : args[1] === "true",
10
- inJsFilePath: jsFilePath || process.cwd(),
11
- inCheckLines
12
- };
1
+ export default function parseInput({ jsFilePath,
2
+ inCheckLines = {}, showLog }) {
3
+
4
+ const [...args] = process.argv.slice(2);
5
+
6
+ return {
7
+ showLog: args[1] === undefined
8
+ ? showLog
9
+ : args[1] === "true",
10
+ inJsFilePath: jsFilePath || process.cwd(),
11
+ inCheckLines
12
+ };
13
13
  };
@@ -1,50 +1,50 @@
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}AddSubRoute${r} Initialize a new folder and files
33
- ${g}AddTableName${r} Initialize a new folder and files for TableName
34
- ${g}ShowAll${r} Initialize a new folder and files for action
35
-
36
- ${g}CreateApi${r} Creates new end point and hooks to app.js
37
- ${g}InsertApi${r} Creates new InsertApi end point and hooks to app.js
38
-
39
- ${y}Examples:${r}
40
- ${gray}npx @keshavsoft/kschema-api-gen StartEndPoint${r}
41
- ${gray}npx @keshavsoft/kschema-api-gen AddSubRoute${r}
42
- ${gray}npx @keshavsoft/kschema-api-gen AddTableName${r}
43
- ${gray}npx @keshavsoft/kschema-api-gen ShowAll${r}
44
- ${gray}npx @keshavsoft/kschema-api-gen CreateApi Api/V1/journals/ShowAll${r}
45
- ${gray}npx @keshavsoft/kschema-api-gen InsertApi Api/V1/journals/Insert${r}
46
-
47
- ${y}Tip:${r}
48
- ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
49
- `);
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}AddSubRoute${r} Initialize a new folder and files
33
+ ${g}AddTableName${r} Initialize a new folder and files for TableName
34
+ ${g}ShowAll${r} Initialize a new folder and files for action
35
+
36
+ ${g}CreateApi${r} Creates new end point and hooks to app.js
37
+ ${g}InsertApi${r} Creates new InsertApi end point and hooks to app.js
38
+
39
+ ${y}Examples:${r}
40
+ ${gray}npx @keshavsoft/kschema-api-gen StartEndPoint${r}
41
+ ${gray}npx @keshavsoft/kschema-api-gen AddSubRoute${r}
42
+ ${gray}npx @keshavsoft/kschema-api-gen AddTableName${r}
43
+ ${gray}npx @keshavsoft/kschema-api-gen ShowAll${r}
44
+ ${gray}npx @keshavsoft/kschema-api-gen CreateApi Api/V1/journals/ShowAll${r}
45
+ ${gray}npx @keshavsoft/kschema-api-gen InsertApi Api/V1/journals/Insert${r}
46
+
47
+ ${y}Tip:${r}
48
+ ${gray}npm i -g @keshavsoft/kschema-api-gen${r}
49
+ `);
50
50
  }
@@ -1,18 +1,18 @@
1
- import parseInput from "./core/parseInput.js";
2
- import showUsage from './core/showUsage.js';
3
-
4
- import updateJs from "./UpdateJs/index.js";
5
-
6
- import pkg from '../../package.json' with { type: 'json' };
7
-
8
- const version = pkg.version;
9
-
10
- const run = ({ jsFilePath, inCheckLines, showLog }) => {
11
- const input = parseInput({ jsFilePath, inCheckLines, showLog });
12
-
13
- if (input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") return showUsage(version);
14
-
15
- updateJs(input);
16
- };
17
-
1
+ import parseInput from "./core/parseInput.js";
2
+ import showUsage from './core/showUsage.js';
3
+
4
+ import updateJs from "./UpdateJs/index.js";
5
+
6
+ import pkg from '../../package.json' with { type: 'json' };
7
+
8
+ const version = pkg.version;
9
+
10
+ const run = ({ jsFilePath, inCheckLines, showLog }) => {
11
+ const input = parseInput({ jsFilePath, inCheckLines, showLog });
12
+
13
+ if (input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") return showUsage(version);
14
+
15
+ updateJs(input);
16
+ };
17
+
18
18
  export default run;
package/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import getLatestVersion from "./bin/core/getLatestVersion.js";
2
-
3
- const load = async ({ jsFilePath, inCheckLines, showLog }) => {
4
- const v = getLatestVersion();
5
-
6
- const module = await import(`./bin/${v}/start.js`);
7
-
8
- await module.default({ jsFilePath, inCheckLines, showLog });
9
- };
10
-
1
+ import getLatestVersion from "./bin/core/getLatestVersion.js";
2
+
3
+ const load = async ({ jsFilePath, inCheckLines, showLog }) => {
4
+ const v = getLatestVersion();
5
+
6
+ const module = await import(`./bin/${v}/start.js`);
7
+
8
+ await module.default({ jsFilePath, inCheckLines, showLog });
9
+ };
10
+
11
11
  export default load;
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "name": "express-fix-any-js",
3
- "version": "1.4.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
- "type": "module",
14
- "exports": {
15
- ".": "./index.js"
16
- },
17
- "bin": {
18
- "express-fix-any-js": "./bin/cli.js"
19
- },
20
- "files": [
21
- "bin/",
22
- "index.js",
23
- "README.md",
24
- "LICENSE"
25
- ],
26
- "homepage": "https://cli.keshavsoft.com",
27
- "repository": {
28
- "type": "git",
29
- "url": "https://github.com/keshavsoft/express-fix-any-js"
30
- },
31
- "bugs": {
32
- "url": "https://github.com/keshavsoft/express-fix-any-js/issues"
33
- }
1
+ {
2
+ "name": "express-fix-any-js",
3
+ "version": "1.5.3",
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
+ "type": "module",
14
+ "exports": {
15
+ ".": "./index.js"
16
+ },
17
+ "bin": {
18
+ "express-fix-any-js": "./bin/cli.js"
19
+ },
20
+ "files": [
21
+ "bin/",
22
+ "index.js",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "homepage": "https://cli.keshavsoft.com",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/keshavsoft/express-fix-any-js"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/keshavsoft/express-fix-any-js/issues"
33
+ }
34
34
  }
@@ -1,18 +0,0 @@
1
- {
2
- "importLines": {
3
- "toInsertLine": "import funcFrom${endpoint} from './${endpoint}/controller.js';",
4
- "duplicationCheck": "from './${endpoint}/controller.js'",
5
- "insertAfter": [
6
- "import funcFrom",
7
- "import express"
8
- ]
9
- },
10
- "useLines": {
11
- "toInsertLine": "router.post('/${endpoint}', express.json(), (req, res) => funcFrom${endpoint}({ req, res, inTablePath: tablePath }));",
12
- "duplicationCheck": "router.use('/${endpoint}'",
13
- "insertAfter": [
14
- "router.",
15
- "const router = "
16
- ]
17
- }
18
- }
@@ -1,34 +0,0 @@
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
- };