express-fix-any-js 1.26.2 → 1.28.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.
Files changed (39) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +88 -88
  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/{v25 → v27}/alterFile/forImportLine/index.js +40 -40
  7. package/bin/{v26/hookFolder → v27/alterFile}/forInsertIndex.js +29 -29
  8. package/bin/{v26 → v27}/alterFile/insertLine/addLines.js +15 -15
  9. package/bin/{v25/hookFolder → v27/alterFile}/insertLine/findInsertIndex.js +37 -37
  10. package/bin/{v25/hookFolder → v27/alterFile}/insertLine/index.js +49 -49
  11. package/bin/{v25 → v27}/alterFile/insertLine/writeToFile.js +7 -7
  12. package/bin/{v26 → v27}/alterFile/start.js +44 -44
  13. package/bin/{v25 → v27}/fileNames.json +34 -34
  14. package/bin/{v26 → v27}/hookFolder/forImportLine/index.js +40 -40
  15. package/bin/{v25/alterFile → v27/hookFolder}/forInsertIndex.js +29 -29
  16. package/bin/{v25 → v27}/hookFolder/insertLine/addLines.js +15 -15
  17. package/bin/{v26 → v27}/hookFolder/insertLine/findInsertIndex.js +37 -37
  18. package/bin/{v26/alterFile → v27/hookFolder}/insertLine/index.js +49 -49
  19. package/bin/{v26/alterFile → v27/hookFolder}/insertLine/writeToFile.js +7 -7
  20. package/bin/{v26 → v27}/hookFolder/start.js +27 -27
  21. package/bin/{v25 → v27}/start.js +24 -24
  22. package/bin/{v26 → v28}/alterFile/forImportLine/index.js +40 -40
  23. package/bin/{v25/hookFolder → v28/alterFile}/forInsertIndex.js +29 -29
  24. package/bin/{v25 → v28}/alterFile/insertLine/addLines.js +15 -15
  25. package/bin/{v26 → v28}/alterFile/insertLine/findInsertIndex.js +37 -37
  26. package/bin/{v25 → v28}/alterFile/insertLine/index.js +49 -49
  27. package/bin/{v26/hookFolder → v28/alterFile}/insertLine/writeToFile.js +7 -7
  28. package/bin/{v25 → v28}/alterFile/start.js +44 -40
  29. package/bin/{v25 → v28}/hookFolder/forImportLine/index.js +44 -40
  30. package/bin/{v26/alterFile → v28/hookFolder}/forInsertIndex.js +29 -29
  31. package/bin/{v26 → v28}/hookFolder/insertLine/addLines.js +15 -15
  32. package/bin/{v25/alterFile → v28/hookFolder}/insertLine/findInsertIndex.js +37 -37
  33. package/bin/{v26 → v28}/hookFolder/insertLine/index.js +47 -49
  34. package/bin/{v25 → v28}/hookFolder/insertLine/writeToFile.js +7 -7
  35. package/bin/{v25 → v28}/hookFolder/start.js +27 -24
  36. package/bin/{v26 → v28}/start.js +24 -24
  37. package/index.js +13 -13
  38. package/package.json +37 -37
  39. package/bin/v26/fileNames.json +0 -35
@@ -1,41 +1,41 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- import defaultFunc from 'pattern-collector-anyjs-story';
5
- import insertLine from "../insertLine/index.js";
6
-
7
- import fileNamesJson from '../../fileNames.json' with {type: 'json'};
8
-
9
- const startFunc = ({ inParts, inFileType, inTargetPath,
10
- presentKey, regexKey, templateKey
11
- }) => {
12
-
13
- try {
14
- const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]);
15
-
16
- const fileContent = fs.readFileSync(localJsPath, 'utf8');
17
-
18
- const story = defaultFunc({ fileContent, fileType: inFileType });
19
-
20
- const fromInsertLine = insertLine({
21
- presentKey,
22
- linesStory: story.linesStory,
23
- onlyIndexesValues: story?.onlyIndexesValues,
24
- fileContent,
25
- importRegex: story?.extractRegex?.toInsertIndex?.[inFileType]?.[regexKey],
26
- filePath: localJsPath,
27
- inTemplate: story?.reverseTemplates?.[templateKey],
28
- inParts
29
- });
30
-
31
- return fromInsertLine;
32
-
33
- } catch (error) {
34
- console.log("error : ", error);
35
-
36
- };
37
- };
38
-
39
- export default startFunc;
40
-
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import defaultFunc from 'pattern-collector-anyjs-story';
5
+ import insertLine from "../insertLine/index.js";
6
+
7
+ import fileNamesJson from '../../fileNames.json' with {type: 'json'};
8
+
9
+ const startFunc = ({ inParts, inFileType, inTargetPath,
10
+ presentKey, regexKey, templateKey
11
+ }) => {
12
+
13
+ try {
14
+ const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]);
15
+
16
+ const fileContent = fs.readFileSync(localJsPath, 'utf8');
17
+
18
+ const story = defaultFunc({ fileContent, fileType: inFileType });
19
+
20
+ const fromInsertLine = insertLine({
21
+ presentKey,
22
+ linesStory: story.linesStory,
23
+ onlyIndexesValues: story?.onlyIndexesValues,
24
+ fileContent,
25
+ importRegex: story?.extractRegex?.toInsertIndex?.[inFileType]?.[regexKey],
26
+ filePath: localJsPath,
27
+ inTemplate: story?.reverseTemplates?.[templateKey],
28
+ inParts
29
+ });
30
+
31
+ return fromInsertLine;
32
+
33
+ } catch (error) {
34
+ console.log("error : ", error);
35
+
36
+ };
37
+ };
38
+
39
+ export default startFunc;
40
+
41
41
  // startFunc({ folderNameToInsert, fileType });
@@ -1,30 +1,30 @@
1
- import fs from 'fs';
2
-
3
- const findImportLinesFromNpmIndex = ({ inStory }) => {
4
- const importLinesFromNpm = inStory?.linesStory?.importLinesFromNpm;
5
-
6
- const lastLine = importLinesFromNpm[importLinesFromNpm.length - 1];
7
-
8
- return lastLine?.lineNumber;
9
- };
10
-
11
- const findImportLinesIndex = ({ inStory }) => {
12
- const importLines = inStory?.linesStory?.importLines;
13
-
14
- const lastLine = importLines[importLines.length - 1];
15
-
16
- return lastLine?.lineNumber;
17
- };
18
-
19
- const findVariablesDeclareHereLinesIndex = ({ inStory }) => {
20
- const variablesDeclareHereLines = inStory?.lines?.variablesDeclareHereLines;
21
-
22
- const lastLine = variablesDeclareHereLines[variablesDeclareHereLines.length - 1];
23
-
24
- return lastLine?.lineNumber;
25
- };
26
-
27
- export {
28
- findImportLinesFromNpmIndex, findImportLinesIndex,
29
- findVariablesDeclareHereLinesIndex
1
+ import fs from 'fs';
2
+
3
+ const findImportLinesFromNpmIndex = ({ inStory }) => {
4
+ const importLinesFromNpm = inStory?.linesStory?.importLinesFromNpm;
5
+
6
+ const lastLine = importLinesFromNpm[importLinesFromNpm.length - 1];
7
+
8
+ return lastLine?.lineNumber;
9
+ };
10
+
11
+ const findImportLinesIndex = ({ inStory }) => {
12
+ const importLines = inStory?.linesStory?.importLines;
13
+
14
+ const lastLine = importLines[importLines.length - 1];
15
+
16
+ return lastLine?.lineNumber;
17
+ };
18
+
19
+ const findVariablesDeclareHereLinesIndex = ({ inStory }) => {
20
+ const variablesDeclareHereLines = inStory?.lines?.variablesDeclareHereLines;
21
+
22
+ const lastLine = variablesDeclareHereLines[variablesDeclareHereLines.length - 1];
23
+
24
+ return lastLine?.lineNumber;
25
+ };
26
+
27
+ export {
28
+ findImportLinesFromNpmIndex, findImportLinesIndex,
29
+ findVariablesDeclareHereLinesIndex
30
30
  };
@@ -1,16 +1,16 @@
1
- const startFunc = ({
2
- inLines,
3
- inNewLine,
4
- inInsertAtIndex,
5
- inGapBefore = false,
6
- inGapAfter = false
7
- }) => {
8
- let line = inNewLine;
9
-
10
- if (inGapBefore) line = "\n" + line;
11
- if (inGapAfter) line = line + "\n";
12
-
13
- inLines.splice(inInsertAtIndex, 0, line);
14
- };
15
-
1
+ const startFunc = ({
2
+ inLines,
3
+ inNewLine,
4
+ inInsertAtIndex,
5
+ inGapBefore = false,
6
+ inGapAfter = false
7
+ }) => {
8
+ let line = inNewLine;
9
+
10
+ if (inGapBefore) line = "\n" + line;
11
+ if (inGapAfter) line = line + "\n";
12
+
13
+ inLines.splice(inInsertAtIndex, 0, line);
14
+ };
15
+
16
16
  export default startFunc;
@@ -1,38 +1,38 @@
1
- const startFunc = ({ onlyIndexesValues, importRegex, presentKey }) => {
2
- const insertStory = {};
3
-
4
- if (!importRegex) {
5
- return insertStory;
6
- };
7
-
8
- // Try each preferred location until one exists.
9
- for (const preference of importRegex) {
10
-
11
- const [group, property] = preference.split(".");
12
-
13
- // Preference like: importLines.firstLineIndex
14
- if (property) {
15
- if (onlyIndexesValues[group]?.[property] !== undefined) {
16
- insertStory.index = onlyIndexesValues[group][property];
17
-
18
- if (presentKey in onlyIndexesValues && !onlyIndexesValues[presentKey]) {
19
- insertStory.gapBefore = true;
20
- }
21
-
22
- break;
23
- }
24
-
25
- continue;
26
- }
27
-
28
- // Special preference like: first
29
- if (preference === "firstLineIndex") {
30
- insertStory.index = 0;
31
- break;
32
- };
33
- };
34
-
35
- return insertStory;
36
- };
37
-
1
+ const startFunc = ({ onlyIndexesValues, importRegex, presentKey }) => {
2
+ const insertStory = {};
3
+
4
+ if (!importRegex) {
5
+ return insertStory;
6
+ };
7
+
8
+ // Try each preferred location until one exists.
9
+ for (const preference of importRegex) {
10
+
11
+ const [group, property] = preference.split(".");
12
+
13
+ // Preference like: importLines.firstLineIndex
14
+ if (property) {
15
+ if (onlyIndexesValues[group]?.[property] !== undefined) {
16
+ insertStory.index = onlyIndexesValues[group][property];
17
+
18
+ if (presentKey in onlyIndexesValues && !onlyIndexesValues[presentKey]) {
19
+ insertStory.gapBefore = true;
20
+ }
21
+
22
+ break;
23
+ }
24
+
25
+ continue;
26
+ }
27
+
28
+ // Special preference like: first
29
+ if (preference === "firstLineIndex") {
30
+ insertStory.index = 0;
31
+ break;
32
+ };
33
+ };
34
+
35
+ return insertStory;
36
+ };
37
+
38
38
  export default startFunc;
@@ -1,50 +1,50 @@
1
- import findInsertIndex from "./findInsertIndex.js";
2
- import addLines from "./addLines.js";
3
- import writeToFile from "./writeToFile.js";
4
-
5
- function build(template, parts) {
6
- return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
7
- };
8
-
9
- const startFunc = ({ linesStory, fileContent, filePath, importRegex, onlyIndexesValues,
10
- presentKey, inTemplate, inParts }) => {
11
-
12
- const foundUseLinesStory = linesStory[presentKey].find(element => {
13
- return element.part2 === inParts[1];
14
- });
15
-
16
- if (foundUseLinesStory) {
17
- return {
18
- KTF: false,
19
- KReason: foundUseLinesStory
20
- };
21
- };
22
-
23
- const newLine = build(inTemplate, inParts);
24
-
25
- const lines = fileContent.split(/\r?\n/);
26
-
27
- const insertStory = findInsertIndex({
28
- onlyIndexesValues,
29
- importRegex,
30
- presentKey
31
- });
32
-
33
- addLines({
34
- inLines: lines, inInsertAtIndex: insertStory?.index,
35
- inNewLine: newLine, inGapBefore: insertStory?.gapBefore,
36
- inGapAfter: insertStory?.gapAfter
37
- });
38
-
39
- // lines.splice(insertAtIndex, 0, newLine);
40
-
41
- writeToFile({ fileContent, filePath, lines });
42
-
43
- return {
44
- newLine, inParts
45
- };
46
- // fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
47
-
48
- };
49
-
1
+ import findInsertIndex from "./findInsertIndex.js";
2
+ import addLines from "./addLines.js";
3
+ import writeToFile from "./writeToFile.js";
4
+
5
+ function build(template, parts) {
6
+ return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
7
+ };
8
+
9
+ const startFunc = ({ linesStory, fileContent, filePath, importRegex, onlyIndexesValues,
10
+ presentKey, inTemplate, inParts }) => {
11
+
12
+ const foundUseLinesStory = linesStory[presentKey].find(element => {
13
+ return element.part2 === inParts[1];
14
+ });
15
+
16
+ if (foundUseLinesStory) {
17
+ return {
18
+ KTF: false,
19
+ KReason: foundUseLinesStory
20
+ };
21
+ };
22
+
23
+ const newLine = build(inTemplate, inParts);
24
+
25
+ const lines = fileContent.split(/\r?\n/);
26
+
27
+ const insertStory = findInsertIndex({
28
+ onlyIndexesValues,
29
+ importRegex,
30
+ presentKey
31
+ });
32
+
33
+ addLines({
34
+ inLines: lines, inInsertAtIndex: insertStory?.index,
35
+ inNewLine: newLine, inGapBefore: insertStory?.gapBefore,
36
+ inGapAfter: insertStory?.gapAfter
37
+ });
38
+
39
+ // lines.splice(insertAtIndex, 0, newLine);
40
+
41
+ writeToFile({ fileContent, filePath, lines });
42
+
43
+ return {
44
+ newLine, inParts
45
+ };
46
+ // fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
47
+
48
+ };
49
+
50
50
  export default startFunc;
@@ -1,8 +1,8 @@
1
- import fs from 'fs';
2
-
3
- const startFunc = ({ fileContent, filePath, lines }) => {
4
-
5
- fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
6
- };
7
-
1
+ import fs from 'fs';
2
+
3
+ const startFunc = ({ fileContent, filePath, lines }) => {
4
+
5
+ fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
6
+ };
7
+
8
8
  export default startFunc;
@@ -1,41 +1,45 @@
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
-
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileNamesJson as fromNpm } from "pattern-collector-base-files";
4
+
5
+ // import fileNamesJson from '../fileNames.json' with {type: 'json'};
6
+
7
+ const startFunc = ({ alterArray, inFileType, inTargetPath, inValue }) => {
8
+
9
+ try {
10
+
11
+ const fileNamesJson = fromNpm();
12
+
13
+ if (!inFileType in fileNamesJson) {
14
+ return false;
15
+ };
16
+
17
+ if (!"hookTo" in fileNamesJson[inFileType]) {
18
+ return false;
19
+ };
20
+
21
+ if (!"fileName" in fileNamesJson[fileNamesJson[inFileType]?.hookTo]) {
22
+ return false;
23
+ };
24
+
25
+ const jsFileName = fileNamesJson[fileNamesJson[inFileType]?.hookTo]?.fileName;
26
+
27
+ const localJsPath = path.join(inTargetPath, inValue, jsFileName);
28
+
29
+ let fileContent = fs.readFileSync(localJsPath, 'utf8');
30
+
31
+ alterArray.forEach(element => {
32
+ fileContent = fileContent.replaceAll(element.key, element.value);
33
+ });
34
+
35
+ fs.writeFileSync(localJsPath, fileContent);
36
+
37
+ return true;
38
+
39
+ } catch (error) {
40
+ console.log("error : ", error);
41
+
42
+ };
43
+ };
44
+
41
45
  export default startFunc;
@@ -1,41 +1,45 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- import defaultFunc from 'pattern-collector-anyjs-story';
5
- import insertLine from "../insertLine/index.js";
6
-
7
- import fileNamesJson from '../../fileNames.json' with {type: 'json'};
8
-
9
- const startFunc = ({ inParts, inFileType, inTargetPath,
10
- presentKey, regexKey, templateKey
11
- }) => {
12
-
13
- try {
14
- const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]?.fileName);
15
-
16
- const fileContent = fs.readFileSync(localJsPath, 'utf8');
17
-
18
- const story = defaultFunc({ fileContent, fileType: inFileType });
19
-
20
- const fromInsertLine = insertLine({
21
- presentKey,
22
- linesStory: story.linesStory,
23
- onlyIndexesValues: story?.onlyIndexesValues,
24
- fileContent,
25
- importRegex: story?.extractRegex?.toInsertIndex?.[inFileType]?.[regexKey],
26
- filePath: localJsPath,
27
- inTemplate: story?.reverseTemplates?.[templateKey],
28
- inParts
29
- });
30
-
31
- return fromInsertLine;
32
-
33
- } catch (error) {
34
- console.log("error : ", error);
35
-
36
- };
37
- };
38
-
39
- export default startFunc;
40
-
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import defaultFunc from 'pattern-collector-anyjs-story';
5
+ import { fileNamesJson as fromNpm } from "pattern-collector-base-files";
6
+
7
+ import insertLine from "../insertLine/index.js";
8
+
9
+ // import fileNamesJson from '../../fileNames.json' with {type: 'json'};
10
+
11
+ const startFunc = ({ inParts, inFileType, inTargetPath,
12
+ presentKey, regexKey, templateKey, inConsiderKey
13
+ }) => {
14
+
15
+ try {
16
+ const fileNamesJson = fromNpm();
17
+
18
+ const localJsPath = path.join(inTargetPath, fileNamesJson[inFileType]?.fileName);
19
+
20
+ const fileContent = fs.readFileSync(localJsPath, 'utf8');
21
+
22
+ const story = defaultFunc({ fileContent, fileType: inFileType });
23
+
24
+ const fromInsertLine = insertLine({
25
+ presentKey,
26
+ linesStory: story.linesStory,
27
+ onlyIndexesValues: story?.onlyIndexesValues,
28
+ fileContent,
29
+ importRegex: story?.extractRegex?.toInsertIndex?.[inFileType]?.[regexKey],
30
+ filePath: localJsPath,
31
+ inTemplate: story?.reverseTemplates?.[templateKey],
32
+ inParts, inConsiderKey
33
+ });
34
+
35
+ return fromInsertLine;
36
+
37
+ } catch (error) {
38
+ console.log("error : ", error);
39
+
40
+ };
41
+ };
42
+
43
+ export default startFunc;
44
+
41
45
  // startFunc({ folderNameToInsert, fileType });
@@ -1,30 +1,30 @@
1
- import fs from 'fs';
2
-
3
- const findImportLinesFromNpmIndex = ({ inStory }) => {
4
- const importLinesFromNpm = inStory?.linesStory?.importLinesFromNpm;
5
-
6
- const lastLine = importLinesFromNpm[importLinesFromNpm.length - 1];
7
-
8
- return lastLine?.lineNumber;
9
- };
10
-
11
- const findImportLinesIndex = ({ inStory }) => {
12
- const importLines = inStory?.linesStory?.importLines;
13
-
14
- const lastLine = importLines[importLines.length - 1];
15
-
16
- return lastLine?.lineNumber;
17
- };
18
-
19
- const findVariablesDeclareHereLinesIndex = ({ inStory }) => {
20
- const variablesDeclareHereLines = inStory?.lines?.variablesDeclareHereLines;
21
-
22
- const lastLine = variablesDeclareHereLines[variablesDeclareHereLines.length - 1];
23
-
24
- return lastLine?.lineNumber;
25
- };
26
-
27
- export {
28
- findImportLinesFromNpmIndex, findImportLinesIndex,
29
- findVariablesDeclareHereLinesIndex
1
+ import fs from 'fs';
2
+
3
+ const findImportLinesFromNpmIndex = ({ inStory }) => {
4
+ const importLinesFromNpm = inStory?.linesStory?.importLinesFromNpm;
5
+
6
+ const lastLine = importLinesFromNpm[importLinesFromNpm.length - 1];
7
+
8
+ return lastLine?.lineNumber;
9
+ };
10
+
11
+ const findImportLinesIndex = ({ inStory }) => {
12
+ const importLines = inStory?.linesStory?.importLines;
13
+
14
+ const lastLine = importLines[importLines.length - 1];
15
+
16
+ return lastLine?.lineNumber;
17
+ };
18
+
19
+ const findVariablesDeclareHereLinesIndex = ({ inStory }) => {
20
+ const variablesDeclareHereLines = inStory?.lines?.variablesDeclareHereLines;
21
+
22
+ const lastLine = variablesDeclareHereLines[variablesDeclareHereLines.length - 1];
23
+
24
+ return lastLine?.lineNumber;
25
+ };
26
+
27
+ export {
28
+ findImportLinesFromNpmIndex, findImportLinesIndex,
29
+ findVariablesDeclareHereLinesIndex
30
30
  };
@@ -1,16 +1,16 @@
1
- const startFunc = ({
2
- inLines,
3
- inNewLine,
4
- inInsertAtIndex,
5
- inGapBefore = false,
6
- inGapAfter = false
7
- }) => {
8
- let line = inNewLine;
9
-
10
- if (inGapBefore) line = "\n" + line;
11
- if (inGapAfter) line = line + "\n";
12
-
13
- inLines.splice(inInsertAtIndex, 0, line);
14
- };
15
-
1
+ const startFunc = ({
2
+ inLines,
3
+ inNewLine,
4
+ inInsertAtIndex,
5
+ inGapBefore = false,
6
+ inGapAfter = false
7
+ }) => {
8
+ let line = inNewLine;
9
+
10
+ if (inGapBefore) line = "\n" + line;
11
+ if (inGapAfter) line = line + "\n";
12
+
13
+ inLines.splice(inInsertAtIndex, 0, line);
14
+ };
15
+
16
16
  export default startFunc;