express-fix-any-js 1.18.2 → 1.24.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 (54) hide show
  1. package/bin/v23/alterFile/forImportLine/index.js +41 -0
  2. package/bin/v23/alterFile/insertLine/findInsertIndex.js +38 -0
  3. package/bin/v23/alterFile/insertLine/index.js +50 -0
  4. package/bin/v23/alterFile/insertLine/writeToFile.js +8 -0
  5. package/bin/v23/alterFile/start.js +28 -0
  6. package/bin/v23/hookFolder/forImportLine/index.js +41 -0
  7. package/bin/v23/hookFolder/insertLine/findInsertIndex.js +38 -0
  8. package/bin/v23/hookFolder/insertLine/index.js +50 -0
  9. package/bin/v23/hookFolder/insertLine/writeToFile.js +8 -0
  10. package/bin/v23/hookFolder/start.js +23 -0
  11. package/bin/v23/start.js +22 -0
  12. package/bin/v24/alterFile/forImportLine/index.js +41 -0
  13. package/bin/v24/alterFile/insertLine/findInsertIndex.js +38 -0
  14. package/bin/v24/alterFile/insertLine/index.js +50 -0
  15. package/bin/v24/alterFile/insertLine/writeToFile.js +8 -0
  16. package/bin/v24/alterFile/start.js +28 -0
  17. package/bin/v24/fileNames.json +18 -0
  18. package/bin/v24/hookFolder/forImportLine/index.js +41 -0
  19. package/bin/v24/hookFolder/forInsertIndex.js +30 -0
  20. package/bin/v24/hookFolder/insertLine/addLines.js +16 -0
  21. package/bin/v24/hookFolder/insertLine/findInsertIndex.js +38 -0
  22. package/bin/v24/hookFolder/insertLine/index.js +50 -0
  23. package/bin/v24/hookFolder/insertLine/writeToFile.js +8 -0
  24. package/bin/v24/hookFolder/start.js +25 -0
  25. package/bin/v24/start.js +22 -0
  26. package/package.json +2 -2
  27. package/bin/v17/addTableName/findInsertIndex.js +0 -79
  28. package/bin/v17/addTableName/forImportLine/index.js +0 -37
  29. package/bin/v17/addTableName/forImportLine/insertImportLine.js +0 -40
  30. package/bin/v17/addTableName/forUseLine/index.js +0 -30
  31. package/bin/v17/addTableName/forUseLine/insertUseLine.js +0 -52
  32. package/bin/v17/addTableName/start.js +0 -35
  33. package/bin/v17/hookFolder/findInsertIndex.js +0 -79
  34. package/bin/v17/hookFolder/forImportLine/index.js +0 -37
  35. package/bin/v17/hookFolder/forImportLine/insertImportLine.js +0 -40
  36. package/bin/v17/hookFolder/forUseLine/index.js +0 -30
  37. package/bin/v17/hookFolder/forUseLine/insertUseLine.js +0 -52
  38. package/bin/v17/hookFolder/start.js +0 -18
  39. package/bin/v17/start.js +0 -34
  40. package/bin/v18/fileNames.json +0 -6
  41. package/bin/v18/hookFolder/findInsertIndex.js +0 -79
  42. package/bin/v18/hookFolder/forImportLine/index.js +0 -37
  43. package/bin/v18/hookFolder/forImportLine/insertImportLine.js +0 -40
  44. package/bin/v18/hookFolder/forUseLine/index.js +0 -30
  45. package/bin/v18/hookFolder/forUseLine/insertUseLine.js +0 -52
  46. package/bin/v18/hookFolder/start.js +0 -18
  47. package/bin/v18/start.js +0 -16
  48. /package/bin/{v17/addTableName → v23/alterFile}/forInsertIndex.js +0 -0
  49. /package/bin/{v17/addTableName → v23/alterFile/insertLine}/addLines.js +0 -0
  50. /package/bin/{v17 → v23}/fileNames.json +0 -0
  51. /package/bin/{v17 → v23}/hookFolder/forInsertIndex.js +0 -0
  52. /package/bin/{v17/hookFolder → v23/hookFolder/insertLine}/addLines.js +0 -0
  53. /package/bin/{v18/hookFolder → v24/alterFile}/forInsertIndex.js +0 -0
  54. /package/bin/{v18/hookFolder → v24/alterFile/insertLine}/addLines.js +0 -0
@@ -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,18 @@
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
+ },
14
+ "fromEndPointsJs": {
15
+ "fileName": "end-points.js",
16
+ "temporaryValue": "funcFrom"
17
+ }
18
+ }
@@ -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]?.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
+
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;