express-fix-any-js 1.17.4 → 1.24.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.
Files changed (53) hide show
  1. package/README.md +12 -1
  2. package/bin/v23/alterFile/forImportLine/index.js +41 -0
  3. package/bin/v23/alterFile/insertLine/findInsertIndex.js +38 -0
  4. package/bin/v23/alterFile/insertLine/index.js +50 -0
  5. package/bin/v23/alterFile/insertLine/writeToFile.js +8 -0
  6. package/bin/v23/alterFile/start.js +28 -0
  7. package/bin/v23/hookFolder/forImportLine/index.js +41 -0
  8. package/bin/v23/hookFolder/insertLine/findInsertIndex.js +38 -0
  9. package/bin/v23/hookFolder/insertLine/index.js +50 -0
  10. package/bin/v23/hookFolder/insertLine/writeToFile.js +8 -0
  11. package/bin/v23/hookFolder/start.js +23 -0
  12. package/bin/v23/start.js +22 -0
  13. package/bin/v24/alterFile/forImportLine/index.js +41 -0
  14. package/bin/v24/alterFile/insertLine/findInsertIndex.js +38 -0
  15. package/bin/v24/alterFile/insertLine/index.js +50 -0
  16. package/bin/v24/alterFile/insertLine/writeToFile.js +8 -0
  17. package/bin/v24/alterFile/start.js +28 -0
  18. package/bin/v24/fileNames.json +6 -0
  19. package/bin/v24/hookFolder/forImportLine/index.js +41 -0
  20. package/bin/v24/hookFolder/forInsertIndex.js +30 -0
  21. package/bin/v24/hookFolder/insertLine/addLines.js +16 -0
  22. package/bin/v24/hookFolder/insertLine/findInsertIndex.js +38 -0
  23. package/bin/v24/hookFolder/insertLine/index.js +50 -0
  24. package/bin/v24/hookFolder/insertLine/writeToFile.js +8 -0
  25. package/bin/v24/hookFolder/start.js +23 -0
  26. package/bin/v24/start.js +22 -0
  27. package/package.json +2 -2
  28. package/bin/v16/findInsertIndex.js +0 -79
  29. package/bin/v16/forImportLine/index.js +0 -37
  30. package/bin/v16/forImportLine/insertImportLine.js +0 -40
  31. package/bin/v16/forUseLine/index.js +0 -30
  32. package/bin/v16/forUseLine/insertUseLine.js +0 -52
  33. package/bin/v16/start.js +0 -18
  34. package/bin/v17/addTableName/findInsertIndex.js +0 -79
  35. package/bin/v17/addTableName/forImportLine/index.js +0 -37
  36. package/bin/v17/addTableName/forImportLine/insertImportLine.js +0 -40
  37. package/bin/v17/addTableName/forUseLine/index.js +0 -30
  38. package/bin/v17/addTableName/forUseLine/insertUseLine.js +0 -52
  39. package/bin/v17/addTableName/start.js +0 -35
  40. package/bin/v17/hookFolder/findInsertIndex.js +0 -79
  41. package/bin/v17/hookFolder/forImportLine/index.js +0 -37
  42. package/bin/v17/hookFolder/forImportLine/insertImportLine.js +0 -40
  43. package/bin/v17/hookFolder/forUseLine/index.js +0 -30
  44. package/bin/v17/hookFolder/forUseLine/insertUseLine.js +0 -52
  45. package/bin/v17/hookFolder/start.js +0 -18
  46. package/bin/v17/start.js +0 -34
  47. /package/bin/{v16 → v23/alterFile}/forInsertIndex.js +0 -0
  48. /package/bin/{v16 → v23/alterFile/insertLine}/addLines.js +0 -0
  49. /package/bin/{v17 → v23}/fileNames.json +0 -0
  50. /package/bin/{v17/addTableName → v23/hookFolder}/forInsertIndex.js +0 -0
  51. /package/bin/{v17/addTableName → v23/hookFolder/insertLine}/addLines.js +0 -0
  52. /package/bin/{v17/hookFolder → v24/alterFile}/forInsertIndex.js +0 -0
  53. /package/bin/{v17/hookFolder → v24/alterFile/insertLine}/addLines.js +0 -0
package/README.md CHANGED
@@ -113,6 +113,17 @@ For detailed developer notes, architectural mappings, and code analyses:
113
113
 
114
114
  ---
115
115
 
116
+ ## 🌐 Documentation
117
+
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
+ ---
126
+
116
127
  ## ⚖️ License
117
128
 
118
- MIT License. Designed with ❤️ by [KeshavSoft](https://github.com/keshavsoft).
129
+ MIT License. Designed with ❤️ by [KeshavSoft](https://github.com/keshavsoft).
@@ -0,0 +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
+
41
+ // startFunc({ folderNameToInsert, fileType });
@@ -0,0 +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
+
38
+ export default startFunc;
@@ -0,0 +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
+
50
+ export default startFunc;
@@ -0,0 +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
+
8
+ export default startFunc;
@@ -0,0 +1,28 @@
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;
@@ -0,0 +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
+
41
+ // startFunc({ folderNameToInsert, fileType });
@@ -0,0 +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
+
38
+ export default startFunc;
@@ -0,0 +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
+
50
+ export default startFunc;
@@ -0,0 +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
+
8
+ export default startFunc;
@@ -0,0 +1,23 @@
1
+ import forImportLine from "./forImportLine/index.js";
2
+
3
+ const startFunc = ({ inValue, temporaryValue, OutValue,
4
+ inFileType, inTargetPath }) => {
5
+
6
+ const fromImportLine = forImportLine({
7
+ inFileType, regexKey: "import",
8
+ templateKey: "importRegex",
9
+ inTargetPath, presentKey: "importLines",
10
+ inParts: [temporaryValue, inValue]
11
+ });
12
+
13
+ const fromUseLine = forImportLine({
14
+ inParts: [temporaryValue, OutValue],
15
+ inFileType, regexKey: "consumption",
16
+ templateKey: "consumptionRegex",
17
+ inTargetPath, presentKey: "useLines"
18
+ });
19
+
20
+ return { fromImportLine, fromUseLine }
21
+ };
22
+
23
+ export default startFunc;
@@ -0,0 +1,22 @@
1
+ import hookFolder from "./hookFolder/start.js";
2
+ import alterFile from "./alterFile/start.js";
3
+
4
+ const startFunc = ({ inValue, temporaryValue, OutValue,
5
+ inFileType, jsFilePath, inTargetPath, alterArray }) => {
6
+
7
+ let fromInternal;
8
+ let fromAlterFile;
9
+
10
+ if (inValue && temporaryValue && OutValue) {
11
+ fromInternal = hookFolder({
12
+ inValue, temporaryValue, OutValue,
13
+ inFileType, inTargetPath
14
+ });
15
+ };
16
+
17
+ fromAlterFile = alterFile({ alterArray, inFileType, inTargetPath });
18
+
19
+ return { fromInternal, fromAlterFile };
20
+ };
21
+
22
+ export default startFunc;
@@ -0,0 +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
+
41
+ // startFunc({ folderNameToInsert, fileType });
@@ -0,0 +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
+
38
+ export default startFunc;
@@ -0,0 +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
+
50
+ export default startFunc;
@@ -0,0 +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
+
8
+ export default startFunc;
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1,6 @@
1
+ {
2
+ "fromAppJs": "app.js",
3
+ "fromRoutesJs": "routes.js",
4
+ "fromRoutesJsEnd": "routes.js",
5
+ "fromEndPointsJs": "end-points.js"
6
+ }
@@ -0,0 +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
+
41
+ // startFunc({ folderNameToInsert, fileType });
@@ -0,0 +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
30
+ };
@@ -0,0 +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
+
16
+ export default startFunc;
@@ -0,0 +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
+
38
+ export default startFunc;