express-fix-any-js 1.3.2 → 1.3.4
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 +21 -21
- package/README.md +77 -77
- package/bin/cli.js +11 -11
- package/bin/core/getLatestVersion.js +12 -12
- package/bin/core/loadRunner.js +8 -8
- package/bin/v2/EndPointsJs/UpdateJs/checkLines.json +17 -17
- package/bin/v2/EndPointsJs/UpdateJs/common/AlterFile/buildUpdatedContent.js +18 -18
- package/bin/v2/EndPointsJs/UpdateJs/common/AlterFile/checkDuplicate.js +20 -20
- package/bin/v2/EndPointsJs/UpdateJs/common/AlterFile/findInsertIndex.js +29 -29
- package/bin/v2/EndPointsJs/UpdateJs/common/AlterFile/index.js +50 -50
- package/bin/v2/EndPointsJs/UpdateJs/common/readFile.js +7 -7
- package/bin/v2/EndPointsJs/UpdateJs/common/writeFile.js +9 -9
- package/bin/v2/EndPointsJs/UpdateJs/index.js +33 -33
- package/bin/v2/EndPointsJs/UpdateJs/validations/validateAppJsPath.js +10 -10
- package/bin/v2/EndPointsJs/UpdateJs/validations/validateEndpoint.js +8 -8
- package/bin/v2/EndPointsJs/index.js +11 -11
- package/bin/v2/UpdateJs/checkLines.json +17 -17
- package/bin/v2/UpdateJs/common/AlterFile/buildUpdatedContent.js +18 -18
- package/bin/v2/UpdateJs/common/AlterFile/checkDuplicate.js +20 -20
- package/bin/v2/UpdateJs/common/AlterFile/findInsertIndex.js +29 -29
- package/bin/v2/UpdateJs/common/AlterFile/index.js +49 -49
- package/bin/v2/UpdateJs/common/readFile.js +7 -7
- package/bin/v2/UpdateJs/common/writeFile.js +9 -9
- package/bin/v2/UpdateJs/index.js +30 -30
- package/bin/v2/core/createFolder.js +33 -33
- package/bin/v2/core/parseInput.js +12 -12
- package/bin/v2/core/showUsage.js +49 -49
- package/bin/v2/start.js +17 -17
- package/bin/v3/UpdateJs/checkLines.json +17 -17
- package/bin/v3/UpdateJs/common/AlterFile/buildUpdatedContent.js +18 -18
- package/bin/v3/UpdateJs/common/AlterFile/checkDuplicate.js +20 -20
- package/bin/v3/UpdateJs/common/AlterFile/findInsertIndex.js +29 -29
- package/bin/v3/UpdateJs/common/AlterFile/index.js +55 -49
- package/bin/v3/UpdateJs/common/readFile.js +7 -7
- package/bin/v3/UpdateJs/common/writeFile.js +9 -9
- package/bin/v3/UpdateJs/index.js +30 -30
- package/bin/v3/core/createFolder.js +33 -33
- package/bin/v3/core/parseInput.js +12 -12
- package/bin/v3/core/showUsage.js +49 -49
- package/bin/v3/start.js +17 -17
- package/index.js +10 -10
- package/package.json +34 -34
package/LICENSE
CHANGED
|
@@ -1,21 +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.
|
|
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
CHANGED
|
@@ -1,77 +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.
|
|
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
CHANGED
|
@@ -1,12 +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
|
-
|
|
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
12
|
run({}).then();
|
|
@@ -1,13 +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);
|
|
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
13
|
};
|
package/bin/core/loadRunner.js
CHANGED
|
@@ -1,9 +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;
|
|
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
9
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
}
|
|
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
18
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const startFunc = ({
|
|
2
|
-
content,
|
|
3
|
-
insertInfo,
|
|
4
|
-
toInsertLine,
|
|
5
|
-
insertAfter
|
|
6
|
-
}) => {
|
|
7
|
-
const before = content.slice(0, insertInfo.index);
|
|
8
|
-
|
|
9
|
-
const isFirstInsert =
|
|
10
|
-
insertInfo.matchedPattern === insertAfter[insertAfter.length - 1];
|
|
11
|
-
|
|
12
|
-
return before +
|
|
13
|
-
(isFirstInsert ? "\n" : "") +
|
|
14
|
-
toInsertLine +
|
|
15
|
-
"\n" +
|
|
16
|
-
content.slice(insertInfo.index);
|
|
17
|
-
};
|
|
18
|
-
|
|
1
|
+
const startFunc = ({
|
|
2
|
+
content,
|
|
3
|
+
insertInfo,
|
|
4
|
+
toInsertLine,
|
|
5
|
+
insertAfter
|
|
6
|
+
}) => {
|
|
7
|
+
const before = content.slice(0, insertInfo.index);
|
|
8
|
+
|
|
9
|
+
const isFirstInsert =
|
|
10
|
+
insertInfo.matchedPattern === insertAfter[insertAfter.length - 1];
|
|
11
|
+
|
|
12
|
+
return before +
|
|
13
|
+
(isFirstInsert ? "\n" : "") +
|
|
14
|
+
toInsertLine +
|
|
15
|
+
"\n" +
|
|
16
|
+
content.slice(insertInfo.index);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
19
|
export default startFunc;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
const checkUseDuplicate = ({
|
|
2
|
-
inContent,
|
|
3
|
-
inFilePath,
|
|
4
|
-
inSearchText
|
|
5
|
-
}) => {
|
|
6
|
-
const lines = inContent.split("\n");
|
|
7
|
-
|
|
8
|
-
const lineIndex = lines.findIndex(line =>
|
|
9
|
-
line.includes(inSearchText)
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
found: lineIndex !== -1,
|
|
14
|
-
filePath: inFilePath,
|
|
15
|
-
lineNumber: lineIndex !== -1
|
|
16
|
-
? lineIndex + 1
|
|
17
|
-
: null
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
1
|
+
const checkUseDuplicate = ({
|
|
2
|
+
inContent,
|
|
3
|
+
inFilePath,
|
|
4
|
+
inSearchText
|
|
5
|
+
}) => {
|
|
6
|
+
const lines = inContent.split("\n");
|
|
7
|
+
|
|
8
|
+
const lineIndex = lines.findIndex(line =>
|
|
9
|
+
line.includes(inSearchText)
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
found: lineIndex !== -1,
|
|
14
|
+
filePath: inFilePath,
|
|
15
|
+
lineNumber: lineIndex !== -1
|
|
16
|
+
? lineIndex + 1
|
|
17
|
+
: null
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
21
|
export default checkUseDuplicate;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const findInsertIndex = ({
|
|
2
|
-
inContent,
|
|
3
|
-
inPatterns = []
|
|
4
|
-
}) => {
|
|
5
|
-
const lines = inContent.split("\n");
|
|
6
|
-
|
|
7
|
-
let lineNumber = -1;
|
|
8
|
-
let matchedPattern = null;
|
|
9
|
-
|
|
10
|
-
lines.forEach((line, index) => {
|
|
11
|
-
const pattern = inPatterns.find(item => line.includes(item));
|
|
12
|
-
|
|
13
|
-
if (pattern) {
|
|
14
|
-
lineNumber = index;
|
|
15
|
-
matchedPattern = pattern;
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
index: lineNumber === -1
|
|
21
|
-
? -1
|
|
22
|
-
: lines
|
|
23
|
-
.slice(0, lineNumber + 1)
|
|
24
|
-
.join("\n")
|
|
25
|
-
.length + 1,
|
|
26
|
-
matchedPattern
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
1
|
+
const findInsertIndex = ({
|
|
2
|
+
inContent,
|
|
3
|
+
inPatterns = []
|
|
4
|
+
}) => {
|
|
5
|
+
const lines = inContent.split("\n");
|
|
6
|
+
|
|
7
|
+
let lineNumber = -1;
|
|
8
|
+
let matchedPattern = null;
|
|
9
|
+
|
|
10
|
+
lines.forEach((line, index) => {
|
|
11
|
+
const pattern = inPatterns.find(item => line.includes(item));
|
|
12
|
+
|
|
13
|
+
if (pattern) {
|
|
14
|
+
lineNumber = index;
|
|
15
|
+
matchedPattern = pattern;
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
index: lineNumber === -1
|
|
21
|
+
? -1
|
|
22
|
+
: lines
|
|
23
|
+
.slice(0, lineNumber + 1)
|
|
24
|
+
.join("\n")
|
|
25
|
+
.length + 1,
|
|
26
|
+
matchedPattern
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
30
|
export default findInsertIndex;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import readFile from "../readFile.js";
|
|
2
|
-
import checkDuplicate from "./checkDuplicate.js";
|
|
3
|
-
import findInsertIndex from "./findInsertIndex.js";
|
|
4
|
-
import writeFile from "../writeFile.js";
|
|
5
|
-
import validateAppJsPath from "../../validations/validateAppJsPath.js";
|
|
6
|
-
|
|
7
|
-
import buildUpdatedContent from "./buildUpdatedContent.js";
|
|
8
|
-
|
|
9
|
-
const validateDuplicate = ({ content, jsFilePath, duplicationCheck }) => {
|
|
10
|
-
return checkDuplicate({
|
|
11
|
-
inContent: content,
|
|
12
|
-
inFilePath: jsFilePath,
|
|
13
|
-
inSearchText: duplicationCheck
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const locateInsertPoint = ({ content, insertAfter }) => {
|
|
18
|
-
return findInsertIndex({
|
|
19
|
-
inContent: content,
|
|
20
|
-
inPatterns: insertAfter
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const alterFile = ({
|
|
25
|
-
jsFilePath,
|
|
26
|
-
toInsertLine,
|
|
27
|
-
duplicationCheck,
|
|
28
|
-
insertAfter = [],
|
|
29
|
-
showLog = false
|
|
30
|
-
}) => {
|
|
31
|
-
const content = readFile(jsFilePath);
|
|
32
|
-
|
|
33
|
-
const duplicateInfo = validateDuplicate({ content, jsFilePath, duplicationCheck });
|
|
34
|
-
|
|
35
|
-
// const index = locateInsertPoint({ content, importInsertAfter });
|
|
36
|
-
const insertInfo = locateInsertPoint({
|
|
37
|
-
content,
|
|
38
|
-
insertAfter
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const updated = buildUpdatedContent({
|
|
42
|
-
content,
|
|
43
|
-
insertInfo,
|
|
44
|
-
toInsertLine,
|
|
45
|
-
insertAfter
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
writeFile(jsFilePath, updated);
|
|
49
|
-
};
|
|
50
|
-
|
|
1
|
+
import readFile from "../readFile.js";
|
|
2
|
+
import checkDuplicate from "./checkDuplicate.js";
|
|
3
|
+
import findInsertIndex from "./findInsertIndex.js";
|
|
4
|
+
import writeFile from "../writeFile.js";
|
|
5
|
+
import validateAppJsPath from "../../validations/validateAppJsPath.js";
|
|
6
|
+
|
|
7
|
+
import buildUpdatedContent from "./buildUpdatedContent.js";
|
|
8
|
+
|
|
9
|
+
const validateDuplicate = ({ content, jsFilePath, duplicationCheck }) => {
|
|
10
|
+
return checkDuplicate({
|
|
11
|
+
inContent: content,
|
|
12
|
+
inFilePath: jsFilePath,
|
|
13
|
+
inSearchText: duplicationCheck
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const locateInsertPoint = ({ content, insertAfter }) => {
|
|
18
|
+
return findInsertIndex({
|
|
19
|
+
inContent: content,
|
|
20
|
+
inPatterns: insertAfter
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const alterFile = ({
|
|
25
|
+
jsFilePath,
|
|
26
|
+
toInsertLine,
|
|
27
|
+
duplicationCheck,
|
|
28
|
+
insertAfter = [],
|
|
29
|
+
showLog = false
|
|
30
|
+
}) => {
|
|
31
|
+
const content = readFile(jsFilePath);
|
|
32
|
+
|
|
33
|
+
const duplicateInfo = validateDuplicate({ content, jsFilePath, duplicationCheck });
|
|
34
|
+
|
|
35
|
+
// const index = locateInsertPoint({ content, importInsertAfter });
|
|
36
|
+
const insertInfo = locateInsertPoint({
|
|
37
|
+
content,
|
|
38
|
+
insertAfter
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const updated = buildUpdatedContent({
|
|
42
|
+
content,
|
|
43
|
+
insertInfo,
|
|
44
|
+
toInsertLine,
|
|
45
|
+
insertAfter
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
writeFile(jsFilePath, updated);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
51
|
export default alterFile;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
const readFile = (inAppJsPath) => {
|
|
4
|
-
const localPath = inAppJsPath;
|
|
5
|
-
return fs.readFileSync(localPath, "utf-8");
|
|
6
|
-
};
|
|
7
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
const readFile = (inAppJsPath) => {
|
|
4
|
+
const localPath = inAppJsPath;
|
|
5
|
+
return fs.readFileSync(localPath, "utf-8");
|
|
6
|
+
};
|
|
7
|
+
|
|
8
8
|
export default readFile;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
const writeFile = (inAppJsPath, inContent) => {
|
|
4
|
-
const localPath = inAppJsPath;
|
|
5
|
-
const localContent = inContent;
|
|
6
|
-
|
|
7
|
-
fs.writeFileSync(localPath, localContent);
|
|
8
|
-
};
|
|
9
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
const writeFile = (inAppJsPath, inContent) => {
|
|
4
|
+
const localPath = inAppJsPath;
|
|
5
|
+
const localContent = inContent;
|
|
6
|
+
|
|
7
|
+
fs.writeFileSync(localPath, localContent);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
10
|
export default writeFile;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
// v2/AppJs/index.js
|
|
2
|
-
|
|
3
|
-
import checkLines from "./checkLines.json" with {type: "json"};
|
|
4
|
-
import validateEndpoint from "./validations/validateEndpoint.js";
|
|
5
|
-
import alterFile from "./common/AlterFile/index.js";
|
|
6
|
-
|
|
7
|
-
const updateAppJs = ({ inJsFilePath, actionName, inCheckLines,
|
|
8
|
-
showLog = false }) => {
|
|
9
|
-
|
|
10
|
-
validateEndpoint({ endpoint: actionName });
|
|
11
|
-
|
|
12
|
-
const localCheckLines = inCheckLines || checkLines;
|
|
13
|
-
// console.log("bbbbbbbbbbbb : ", localCheckLines);
|
|
14
|
-
|
|
15
|
-
alterFile({
|
|
16
|
-
jsFilePath: inJsFilePath,
|
|
17
|
-
toInsertLine: localCheckLines.importLines.toInsertLine,
|
|
18
|
-
duplicationCheck: localCheckLines.importLines.duplicationCheck,
|
|
19
|
-
insertAfter: localCheckLines.importLines.insertAfter,
|
|
20
|
-
showLog
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
alterFile({
|
|
24
|
-
jsFilePath: inJsFilePath,
|
|
25
|
-
toInsertLine: localCheckLines.useLines.toInsertLine,
|
|
26
|
-
duplicationCheck: localCheckLines.useLines.duplicationCheck,
|
|
27
|
-
insertAfter: localCheckLines.useLines.insertAfter,
|
|
28
|
-
showLog
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return false;
|
|
32
|
-
};
|
|
33
|
-
|
|
1
|
+
// v2/AppJs/index.js
|
|
2
|
+
|
|
3
|
+
import checkLines from "./checkLines.json" with {type: "json"};
|
|
4
|
+
import validateEndpoint from "./validations/validateEndpoint.js";
|
|
5
|
+
import alterFile from "./common/AlterFile/index.js";
|
|
6
|
+
|
|
7
|
+
const updateAppJs = ({ inJsFilePath, actionName, inCheckLines,
|
|
8
|
+
showLog = false }) => {
|
|
9
|
+
|
|
10
|
+
validateEndpoint({ endpoint: actionName });
|
|
11
|
+
|
|
12
|
+
const localCheckLines = inCheckLines || checkLines;
|
|
13
|
+
// console.log("bbbbbbbbbbbb : ", localCheckLines);
|
|
14
|
+
|
|
15
|
+
alterFile({
|
|
16
|
+
jsFilePath: inJsFilePath,
|
|
17
|
+
toInsertLine: localCheckLines.importLines.toInsertLine,
|
|
18
|
+
duplicationCheck: localCheckLines.importLines.duplicationCheck,
|
|
19
|
+
insertAfter: localCheckLines.importLines.insertAfter,
|
|
20
|
+
showLog
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
alterFile({
|
|
24
|
+
jsFilePath: inJsFilePath,
|
|
25
|
+
toInsertLine: localCheckLines.useLines.toInsertLine,
|
|
26
|
+
duplicationCheck: localCheckLines.useLines.duplicationCheck,
|
|
27
|
+
insertAfter: localCheckLines.useLines.insertAfter,
|
|
28
|
+
showLog
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
34
|
export default updateAppJs;
|