express-fix-any-js 1.24.4 → 1.25.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # express-fix-any-js 🚀
2
2
 
3
- > **Instantly repair, structure, and align Express.js routing files with automated idempotency & formatting safeguards.**
3
+ **Instantly repair, structure, and align Express.js routing files with automated idempotency and strict formatting safeguards.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/express-fix-any-js.svg?style=flat-square&color=38bdf8)](https://www.npmjs.com/package/express-fix-any-js)
6
6
  [![license](https://img.shields.io/npm/l/express-fix-any-js.svg?style=flat-square&color=34d399)](LICENSE)
@@ -10,42 +10,18 @@
10
10
 
11
11
  ## 📖 Overview
12
12
 
13
- `express-fix-any-js` is a lightweight, high-performance JS AST and file modifier utility. It automatically injects missing Express.js route declarations, import statements, and export configurations into your JavaScript files while ensuring complete protection against code duplication.
13
+ `express-fix-any-js` is a lightweight, high-performance AST and file-modifier utility. It dynamically injects missing Express.js route declarations, import statements, and export configurations into your JavaScript files while ensuring complete protection against code duplication.
14
14
 
15
- This module acts as the foundation layer for the **KeshavSoft API Generation Suite**, dynamically structuring routes generated via CLI or VS Code extensions.
15
+ It acts as the foundational engine for the **KeshavSoft API Generation Suite**, seamlessly structuring routes generated via CLI tools or VS Code extensions.
16
16
 
17
17
  ---
18
18
 
19
19
  ## ✨ Features
20
20
 
21
- * **🔒 Duplicate Prevention (Idempotency)**: Checks files before altering them. If a route or pattern already exists, it skips execution silently to avoid code corruption.
22
- * **📐 Strict Route Formatting**:
23
- * Inserts clean line spaces after `express.Router()` initialization.
24
- * Maintains zero-line spacing between consecutive route definitions.
25
- * Appends spacing cleanly before the `export` keyword.
26
- * **⚡ Multiple File Versions (V1 - V6)**: Supports legacy configuration modifications alongside cutting-edge AST-based insertions.
27
- * **🛠️ Developer-First Diagnostics**: Provides clear inline logging of file updates and duplicate line match warnings.
28
-
29
- ---
30
-
31
- ## 📁 Repository Integration Map
32
-
33
- `express-fix-any-js` is part of a larger cascading developer ecosystem:
34
-
35
- ```mermaid
36
- graph TD
37
- ext["vs-code-ext-express-api-gen-get-actions<br/><i>VS Code Extension</i>"]
38
-
39
- gen["kschema-fs-api-gen-get-actions<br/><i>API Generator Actions</i>"]
40
-
41
- endpoints["express-fix-endpoints-get-js<br/><i>Endpoint Logic Builder</i>"]
42
-
43
- anyjs["express-fix-any-js<br/><i>This Core Utility</i>"]
44
-
45
- ext -->|delegates to| gen
46
- gen -->|invokes| endpoints
47
- endpoints -->|relies on| anyjs
48
- ```
21
+ * 🔒 **Idempotent Injection:** Checks files before altering; skips execution silently if a duplicate pattern or route already exists.
22
+ * 📐 **Strict Aesthetics:** Enforces zero-line spacing between consecutive routes while maintaining ideal breathing space after router initializations.
23
+ * **Versatile Versioning:** Supports legacy structure modifications alongside cutting-edge AST-based insertions (V1 to V6).
24
+ * 🛠️ **Developer Diagnostics:** Emits clean, explicit inline logging for file updates and duplicate line match warnings.
49
25
 
50
26
  ---
51
27
 
@@ -59,7 +35,7 @@ npm install express-fix-any-js
59
35
 
60
36
  ### Programmatic Usage
61
37
 
62
- You can use the core `alterFile` function to modify local routes files safely:
38
+ Safely append or insert local routes using the core `alterFile` API:
63
39
 
64
40
  ```javascript
65
41
  import alterFile from 'express-fix-any-js/bin/v6/UpdateJs/common/AlterFile/index.js';
@@ -70,7 +46,7 @@ alterFile({
70
46
  duplicationCheck: 'router.post("/Create"',
71
47
  insertAfter: [
72
48
  'const router = express.Router();',
73
- 'router.post("/Alter"' // Inserts immediately after this line if found, otherwise after Router init
49
+ 'router.post("/Alter"' // Inserts here if found, otherwise falls back to router initialization
74
50
  ],
75
51
  showLog: true
76
52
  });
@@ -78,52 +54,35 @@ alterFile({
78
54
 
79
55
  ---
80
56
 
81
- ## 📜 Structuring Rules
57
+ ## 📐 Formatting Standards
82
58
 
83
- The utility operates under strict structural rules to preserve route aesthetics:
84
-
85
- ### 1. First Route Placement
86
- When the first route is inserted into an empty routing structure, the file is formatted with breathing space:
59
+ The utility ensures your routing logic remains pristine by applying strict formatting:
87
60
 
61
+ ### 1. First Route Base Layout
88
62
  ```javascript
89
63
  const router = express.Router();
90
64
 
91
- router.post("/Alter", express.json(), handler);
65
+ router.post("/Alter", express.json(), handler); // Injected with clean top margin
92
66
 
93
67
  export { router };
94
68
  ```
95
69
 
96
- ### 2. Multi-Route Appending
97
- Subsequent routes are appended directly after the last matching route with no empty line spacing between them:
98
-
70
+ ### 2. Multi-Route Append Strategy
99
71
  ```javascript
100
72
  router.post("/Alter", express.json(), handler);
101
- router.post("/Alter1", express.json(), handler);
73
+ router.post("/Alter1", express.json(), handler); // Appended flush below previous route
102
74
  router.post("/Alter2", express.json(), handler);
103
75
  ```
104
76
 
105
77
  ---
106
78
 
107
- ## 🛠️ Developer & API Reference
108
-
109
- For detailed developer notes, architectural mappings, and code analyses:
110
- * [Developer Docs Home](./docs/index.html)
111
- * [Code Style & Readability Analysis](./docs/code_style_and_readability.md)
112
- * [AlterFile Workflow Analysis](./docs/alter_file_analysis.md)
113
-
114
- ---
115
-
116
- ## 🌐 Documentation
79
+ ## 🌐 Documentation & Guides
117
80
 
118
- Visit the official documentation portal for detailed guides, workflow diagrams, architecture explanations, and API references.
119
-
120
- [![Documentation](https://img.shields.io/badge/📘-Developer_Documentation-2563eb?style=for-the-badge)](https://keshavsoft.github.io/express-fix-any-js/)
121
-
122
- **Documentation Portal:**
123
- https://keshavsoft.github.io/express-fix-any-js/
124
-
125
- ---
81
+ Explore the [Official Documentation Portal](https://keshavsoft.github.io/express-fix-any-js/) for interactive guides and deeper architectural workflows:
126
82
 
127
- ## ⚖️ License
83
+ * 📄 **App.js Route Generation** – Automates app-level router registration.
84
+ * 📄 **Version Route Generation** – Easily sets up `/v1` or `/v2` routing scopes.
85
+ * 📄 **Table Route Generation** – Generates structured relational endpoints like `/doctors`.
86
+ * 📄 **Endpoint Generation** – Scaffolds foundational GET, POST, PUT, and DELETE methods.
128
87
 
129
- MIT License. Designed with ❤️ by [KeshavSoft](https://github.com/keshavsoft).
88
+ Developed with by [KeshavSoft](https://github.com/keshavsoft). Distributed under the **MIT License**.
@@ -0,0 +1,41 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import fileNamesJson from '../fileNames.json' with {type: 'json'};
5
+
6
+ const startFunc = ({ alterArray, inFileType, inTargetPath, inValue }) => {
7
+
8
+ try {
9
+ if (!inFileType in fileNamesJson) {
10
+ return false;
11
+ };
12
+
13
+ if (!"hookTo" in fileNamesJson[inFileType]) {
14
+ return false;
15
+ };
16
+
17
+ if (!"fileName" in fileNamesJson[fileNamesJson[inFileType]?.hookTo]) {
18
+ return false;
19
+ };
20
+
21
+ const jsFileName = fileNamesJson[fileNamesJson[inFileType]?.hookTo]?.fileName;
22
+
23
+ const localJsPath = path.join(inTargetPath, inValue, jsFileName);
24
+
25
+ let fileContent = fs.readFileSync(localJsPath, 'utf8');
26
+
27
+ alterArray.forEach(element => {
28
+ fileContent = fileContent.replaceAll(element.key, element.value);
29
+ });
30
+
31
+ fs.writeFileSync(localJsPath, fileContent);
32
+
33
+ return true;
34
+
35
+ } catch (error) {
36
+ console.log("error : ", error);
37
+
38
+ };
39
+ };
40
+
41
+ export default startFunc;
@@ -0,0 +1,35 @@
1
+ {
2
+ "version": "25.2",
3
+ "fromAppJs": {
4
+ "fileName": "app.js",
5
+ "temporaryValue": "routerFrom"
6
+ },
7
+ "fromRoutesJs": {
8
+ "fileName": "routes.js",
9
+ "temporaryValue": "routerFrom"
10
+ },
11
+ "fromRoutesJsEnd": {
12
+ "fileName": "routes.js",
13
+ "temporaryValue": "routerFrom",
14
+ "hookTo": "fromEndPointsJs"
15
+ },
16
+ "fromEndPointsJs": {
17
+ "fileName": "end-points.js",
18
+ "temporaryValue": "funcFrom",
19
+ "hookTo": "fromControllerJs"
20
+ },
21
+ "tableGetShowAll": {
22
+ "fileName": "end-points.js",
23
+ "temporaryValue": "funcFrom",
24
+ "hookTo": "fromControllerJs"
25
+ },
26
+ "tableGetFind": {
27
+ "fileName": "end-points.js",
28
+ "temporaryValue": "funcFrom",
29
+ "hookTo": "fromControllerJs"
30
+ },
31
+ "fromControllerJs": {
32
+ "fileName": "controller.js",
33
+ "temporaryValue": "controllerFrom"
34
+ }
35
+ }
@@ -11,7 +11,7 @@ const startFunc = ({ inParts, inFileType, inTargetPath,
11
11
  }) => {
12
12
 
13
13
  try {
14
- const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]);
14
+ const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]?.fileName);
15
15
 
16
16
  const fileContent = fs.readFileSync(localJsPath, 'utf8');
17
17
 
@@ -1,17 +1,19 @@
1
1
  import forImportLine from "./forImportLine/index.js";
2
2
 
3
- const startFunc = ({ inValue, temporaryValue, OutValue,
3
+ import fileNamesJson from '../fileNames.json' with {type: 'json'};
4
+
5
+ const startFunc = ({ inValue, OutValue,
4
6
  inFileType, inTargetPath }) => {
5
7
 
6
8
  const fromImportLine = forImportLine({
7
9
  inFileType, regexKey: "import",
8
10
  templateKey: "importRegex",
9
11
  inTargetPath, presentKey: "importLines",
10
- inParts: [temporaryValue, inValue]
12
+ inParts: [`${fileNamesJson[inFileType]?.temporaryValue}${inValue}`, inValue]
11
13
  });
12
14
 
13
15
  const fromUseLine = forImportLine({
14
- inParts: [temporaryValue, OutValue],
16
+ inParts: [`${fileNamesJson[inFileType]?.temporaryValue}${inValue}`, OutValue],
15
17
  inFileType, regexKey: "consumption",
16
18
  templateKey: "consumptionRegex",
17
19
  inTargetPath, presentKey: "useLines"
@@ -1,20 +1,23 @@
1
1
  import hookFolder from "./hookFolder/start.js";
2
2
  import alterFile from "./alterFile/start.js";
3
3
 
4
- const startFunc = ({ inValue, temporaryValue, OutValue,
4
+ const startFunc = ({ inValue, OutValue,
5
5
  inFileType, jsFilePath, inTargetPath, alterArray }) => {
6
6
 
7
7
  let fromInternal;
8
8
  let fromAlterFile;
9
9
 
10
- if (inValue && temporaryValue && OutValue) {
10
+ if (inValue && OutValue) {
11
11
  fromInternal = hookFolder({
12
- inValue, temporaryValue, OutValue,
12
+ inValue, OutValue,
13
13
  inFileType, inTargetPath
14
14
  });
15
15
  };
16
16
 
17
- fromAlterFile = alterFile({ alterArray, inFileType, inTargetPath });
17
+ fromAlterFile = alterFile({
18
+ alterArray, inFileType, inValue,
19
+ inTargetPath
20
+ });
18
21
 
19
22
  return { fromInternal, fromAlterFile };
20
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-fix-any-js",
3
- "version": "1.24.4",
3
+ "version": "1.25.2",
4
4
  "description": "CLI to build for appjs, the endpoints",
5
5
  "keywords": [
6
6
  "cli",
@@ -10,7 +10,7 @@
10
10
  "project-generator"
11
11
  ],
12
12
  "dependencies": {
13
- "pattern-collector-anyjs-story": "^1.21.2"
13
+ "pattern-collector-anyjs-story": "^1.21.4"
14
14
  },
15
15
  "type": "module",
16
16
  "exports": {
@@ -1,28 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- import fileNamesJson from '../fileNames.json' with {type: 'json'};
5
-
6
- const startFunc = ({ alterArray, inFileType, inTargetPath
7
- }) => {
8
-
9
- try {
10
- const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]);
11
-
12
- let fileContent = fs.readFileSync(localJsPath, 'utf8');
13
-
14
- alterArray.forEach(element => {
15
- fileContent = fileContent.replaceAll(element.key, element.value);
16
- });
17
-
18
- fs.writeFileSync(localJsPath, fileContent);
19
-
20
- return true;
21
-
22
- } catch (error) {
23
- console.log("error : ", error);
24
-
25
- };
26
- };
27
-
28
- export default startFunc;
@@ -1,6 +0,0 @@
1
- {
2
- "fromAppJs": "app.js",
3
- "fromRoutesJs": "routes.js",
4
- "fromRoutesJsEnd": "routes.js",
5
- "fromEndPointsJs": "end-points.js"
6
- }
File without changes
File without changes
File without changes
File without changes