express-fix-any-js 1.24.4 → 1.25.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.
@@ -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,19 @@
1
+ {
2
+ "fromAppJs": {
3
+ "fileName": "app.js",
4
+ "temporaryValue": "routerFrom"
5
+ },
6
+ "fromRoutesJs": {
7
+ "fileName": "routes.js",
8
+ "temporaryValue": "routerFrom"
9
+ },
10
+ "fromRoutesJsEnd": {
11
+ "fileName": "routes.js",
12
+ "temporaryValue": "routerFrom",
13
+ "hookTo": "fromEndPointsJs"
14
+ },
15
+ "fromEndPointsJs": {
16
+ "fileName": "end-points.js",
17
+ "temporaryValue": "funcFrom"
18
+ }
19
+ }
@@ -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.1",
4
4
  "description": "CLI to build for appjs, the endpoints",
5
5
  "keywords": [
6
6
  "cli",
@@ -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