express-fix-any-js 1.13.3 → 1.16.3
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/bin/v15/addLines.js +16 -0
- package/bin/v15/findInsertIndex.js +75 -0
- package/bin/v15/forImportLine/index.js +36 -0
- package/bin/v15/forImportLine/insertImportLine.js +54 -0
- package/bin/{v13/UpdateJs/bothLines → v15}/forUseLine/index.js +1 -1
- package/bin/{v13/UpdateJs/bothLines → v15}/forUseLine/insertUseLine.js +18 -4
- package/bin/v15/start.js +18 -0
- package/bin/v16/addLines.js +16 -0
- package/bin/v16/findInsertIndex.js +79 -0
- package/bin/v16/forImportLine/index.js +37 -0
- package/bin/v16/forImportLine/insertImportLine.js +40 -0
- package/bin/{v12/UpdateJs/bothLines → v16}/forInsertIndex.js +12 -1
- package/bin/{v12/UpdateJs/bothLines → v16}/forUseLine/index.js +3 -2
- package/bin/v16/forUseLine/insertUseLine.js +52 -0
- package/bin/v16/start.js +18 -0
- package/package.json +2 -3
- package/bin/v12/UpdateJs/bothLines/forImportLine/index.js +0 -30
- package/bin/v12/UpdateJs/bothLines/forImportLine/insertImportLine.js +0 -55
- package/bin/v12/UpdateJs/bothLines/forUseLine/insertUseLine.js +0 -39
- package/bin/v12/UpdateJs/bothLines/index.js +0 -11
- package/bin/v12/UpdateJs/index.js +0 -11
- package/bin/v12/start.js +0 -8
- package/bin/v13/UpdateJs/bothLines/forImportLine/index.js +0 -30
- package/bin/v13/UpdateJs/bothLines/forImportLine/insertImportLine.js +0 -55
- package/bin/v13/UpdateJs/bothLines/index.js +0 -11
- package/bin/v13/UpdateJs/index.js +0 -11
- package/bin/v13/start.js +0 -8
- /package/bin/{v13/UpdateJs/bothLines → v15}/forInsertIndex.js +0 -0
|
@@ -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,75 @@
|
|
|
1
|
+
const startFunc1 = ({ onlyIndexesValues, extractRegex, presentKey }) => {
|
|
2
|
+
let insertStory = {};
|
|
3
|
+
|
|
4
|
+
mainLoop: for (const element of extractRegex?.toInsertIndex?.import) {
|
|
5
|
+
const splitValues = element.split(".");
|
|
6
|
+
const firstValue = splitValues[0];
|
|
7
|
+
const secondValue = splitValues[1];
|
|
8
|
+
|
|
9
|
+
if (splitValues.length > 1) {
|
|
10
|
+
if (firstValue in onlyIndexesValues) {
|
|
11
|
+
if (onlyIndexesValues[firstValue]) {
|
|
12
|
+
if (secondValue in onlyIndexesValues[firstValue]) {
|
|
13
|
+
insertStory.index = onlyIndexesValues[firstValue][secondValue];
|
|
14
|
+
|
|
15
|
+
if (presentKey in onlyIndexesValues) {
|
|
16
|
+
if (!onlyIndexesValues[presentKey]) {
|
|
17
|
+
insertStory.gapBefore = true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
break mainLoop;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
switch (element) {
|
|
27
|
+
case "first":
|
|
28
|
+
insertStory.index = 0;
|
|
29
|
+
|
|
30
|
+
break mainLoop;
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return insertStory;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const startFunc = ({ onlyIndexesValues, extractRegex, presentKey }) => {
|
|
43
|
+
const insertStory = {};
|
|
44
|
+
|
|
45
|
+
// Try each preferred location until one exists.
|
|
46
|
+
for (const preference of extractRegex) {
|
|
47
|
+
|
|
48
|
+
const [group, property] = preference.split(".");
|
|
49
|
+
|
|
50
|
+
// Preference like: importLines.firstLineIndex
|
|
51
|
+
if (property) {
|
|
52
|
+
if (onlyIndexesValues[group]?.[property] !== undefined) {
|
|
53
|
+
insertStory.index = onlyIndexesValues[group][property];
|
|
54
|
+
|
|
55
|
+
if (presentKey in onlyIndexesValues && !onlyIndexesValues[presentKey]) {
|
|
56
|
+
insertStory.gapBefore = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Special preference like: first
|
|
66
|
+
if (preference === "firstLineIndex") {
|
|
67
|
+
insertStory.index = 0;
|
|
68
|
+
break;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return insertStory;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default startFunc;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import defaultFunc from 'pattern-collector-anyjs-story';
|
|
4
|
+
import insertImportLine from "./insertImportLine.js";
|
|
5
|
+
|
|
6
|
+
const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
7
|
+
try {
|
|
8
|
+
|
|
9
|
+
const folderNameToInsert = inFolderNameToInsert;
|
|
10
|
+
const localJsPath = inJsPath;
|
|
11
|
+
|
|
12
|
+
const fileContent = fs.readFileSync(localJsPath, 'utf8');
|
|
13
|
+
|
|
14
|
+
const story = defaultFunc({
|
|
15
|
+
fileContent,
|
|
16
|
+
fileType: inFileType
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
insertImportLine({
|
|
20
|
+
inStory: story,
|
|
21
|
+
fileContent, extractRegex: story?.extractRegex,
|
|
22
|
+
filePath: localJsPath, inFolderNameToInsert: folderNameToInsert,
|
|
23
|
+
inTemplate1: story.regexForPullLinesStory.importRegex.reverseTemplate,
|
|
24
|
+
inTemplate: story.reverseTemplates.importRegex,
|
|
25
|
+
inParts: [`${story.variablesConnection}${folderNameToInsert}`, folderNameToInsert]
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.log("error : ", error);
|
|
30
|
+
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default startFunc;
|
|
35
|
+
|
|
36
|
+
// startFunc({ folderNameToInsert, fileType });
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import findInsertIndex from "../findInsertIndex.js";
|
|
3
|
+
import addLines from "../addLines.js";
|
|
4
|
+
|
|
5
|
+
function build(template, parts) {
|
|
6
|
+
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const addLines1 = ({
|
|
10
|
+
inLines,
|
|
11
|
+
inNewLine,
|
|
12
|
+
inInsertAtIndex,
|
|
13
|
+
inGapBefore = false,
|
|
14
|
+
inGapAfter = false
|
|
15
|
+
}) => {
|
|
16
|
+
let line = inNewLine;
|
|
17
|
+
|
|
18
|
+
if (inGapBefore) line = "\n" + line;
|
|
19
|
+
if (inGapAfter) line = line + "\n";
|
|
20
|
+
|
|
21
|
+
inLines.splice(inInsertAtIndex, 0, line);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const startFunc = ({ inStory, fileContent, filePath, extractRegex,
|
|
25
|
+
inFolderNameToInsert, lineType = "importLines", inTemplate, inParts }) => {
|
|
26
|
+
|
|
27
|
+
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
28
|
+
return element.part1 === inFolderNameToInsert;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!foundUseLinesStory) {
|
|
32
|
+
const newLine = build(inTemplate, inParts);
|
|
33
|
+
|
|
34
|
+
const lines = fileContent.split(/\r?\n/);
|
|
35
|
+
|
|
36
|
+
const insertStory = findInsertIndex({
|
|
37
|
+
onlyIndexesValues: inStory?.onlyIndexesValues,
|
|
38
|
+
extractRegex: extractRegex?.toInsertIndex?.import,
|
|
39
|
+
presentKey: lineType
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
addLines({
|
|
43
|
+
inLines: lines, inInsertAtIndex: insertStory?.index,
|
|
44
|
+
inNewLine: newLine, inGapBefore: insertStory?.gapBefore,
|
|
45
|
+
inGapAfter: insertStory?.gapAfter
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// lines.splice(insertAtIndex, 0, newLine);
|
|
49
|
+
|
|
50
|
+
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default startFunc;
|
|
@@ -16,7 +16,7 @@ const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
|
16
16
|
|
|
17
17
|
insertUseLine({
|
|
18
18
|
inStory: story,
|
|
19
|
-
fileContent,
|
|
19
|
+
fileContent, extractRegex: story?.extractRegex,
|
|
20
20
|
filePath: localJsPath, inFolderNameToInsert: folderNameToInsert,
|
|
21
21
|
inTemplate1: story.regexForPullLinesStory.consumptionRegex.reverseTemplate,
|
|
22
22
|
inTemplate: story.reverseTemplates.consumptionRegex,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import findInsertIndex from "../findInsertIndex.js";
|
|
3
|
+
import addLines from "../addLines.js";
|
|
2
4
|
|
|
3
5
|
import {
|
|
4
6
|
findImportLinesFromNpmIndex, findImportLinesIndex,
|
|
5
7
|
findVariablesDeclareHereLinesIndex
|
|
6
8
|
} from "../forInsertIndex.js";
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
const findInsertIndex1 = ({ inStory }) => {
|
|
9
11
|
const importLines = findImportLinesIndex({ inStory });
|
|
10
12
|
const importLinesFromNpm = findImportLinesFromNpmIndex({ inStory });
|
|
11
13
|
const variablesDeclareHereLines = findVariablesDeclareHereLinesIndex({ inStory });
|
|
@@ -18,7 +20,7 @@ function build(template, parts) {
|
|
|
18
20
|
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
const startFunc = ({ inStory, fileContent, filePath,
|
|
23
|
+
const startFunc = ({ inStory, fileContent, filePath, extractRegex,
|
|
22
24
|
inFolderNameToInsert, lineType = "useLines", inTemplate, inParts }) => {
|
|
23
25
|
|
|
24
26
|
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
@@ -33,9 +35,21 @@ const startFunc = ({ inStory, fileContent, filePath,
|
|
|
33
35
|
// const lastUseLine = inStory.lines[lineType][inStory.lines[lineType].length - 1];
|
|
34
36
|
// const insertAtIndex = lastUseLine.lineNumber;
|
|
35
37
|
|
|
36
|
-
const
|
|
38
|
+
const insertStory = findInsertIndex({
|
|
39
|
+
onlyIndexesValues: inStory?.onlyIndexesValues,
|
|
40
|
+
extractRegex: extractRegex?.toInsertIndex?.consumption,
|
|
41
|
+
presentKey: lineType
|
|
42
|
+
});
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
addLines({
|
|
45
|
+
inLines: lines, inInsertAtIndex: insertStory?.index,
|
|
46
|
+
inNewLine: newLine, inGapBefore: insertStory?.gapBefore,
|
|
47
|
+
inGapAfter: insertStory?.gapAfter
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// const insertAtIndex = findInsertIndex({ inStory });
|
|
51
|
+
|
|
52
|
+
// lines.splice(insertAtIndex, 0, newLine);
|
|
39
53
|
|
|
40
54
|
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
41
55
|
};
|
package/bin/v15/start.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import forImportLine from "./forImportLine/index.js";
|
|
2
|
+
import forUseLine from "./forUseLine/index.js";
|
|
3
|
+
|
|
4
|
+
const startFunc = ({ inFolderNameToInsert, inFileType, jsFilePath }) => {
|
|
5
|
+
const fromImportLine = forImportLine({
|
|
6
|
+
inFolderNameToInsert, inFileType,
|
|
7
|
+
inJsPath: jsFilePath
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const fromUseLine = forUseLine({
|
|
11
|
+
inFolderNameToInsert, inFileType,
|
|
12
|
+
inJsPath: jsFilePath
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return { fromImportLine, fromUseLine }
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default startFunc;
|
|
@@ -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,79 @@
|
|
|
1
|
+
const startFunc1 = ({ onlyIndexesValues, extractRegex, presentKey }) => {
|
|
2
|
+
let insertStory = {};
|
|
3
|
+
|
|
4
|
+
mainLoop: for (const element of extractRegex?.toInsertIndex?.import) {
|
|
5
|
+
const splitValues = element.split(".");
|
|
6
|
+
const firstValue = splitValues[0];
|
|
7
|
+
const secondValue = splitValues[1];
|
|
8
|
+
|
|
9
|
+
if (splitValues.length > 1) {
|
|
10
|
+
if (firstValue in onlyIndexesValues) {
|
|
11
|
+
if (onlyIndexesValues[firstValue]) {
|
|
12
|
+
if (secondValue in onlyIndexesValues[firstValue]) {
|
|
13
|
+
insertStory.index = onlyIndexesValues[firstValue][secondValue];
|
|
14
|
+
|
|
15
|
+
if (presentKey in onlyIndexesValues) {
|
|
16
|
+
if (!onlyIndexesValues[presentKey]) {
|
|
17
|
+
insertStory.gapBefore = true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
break mainLoop;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
switch (element) {
|
|
27
|
+
case "first":
|
|
28
|
+
insertStory.index = 0;
|
|
29
|
+
|
|
30
|
+
break mainLoop;
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return insertStory;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const startFunc = ({ onlyIndexesValues, extractRegex, presentKey }) => {
|
|
43
|
+
const insertStory = {};
|
|
44
|
+
|
|
45
|
+
if (!extractRegex) {
|
|
46
|
+
return insertStory;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Try each preferred location until one exists.
|
|
50
|
+
for (const preference of extractRegex) {
|
|
51
|
+
|
|
52
|
+
const [group, property] = preference.split(".");
|
|
53
|
+
|
|
54
|
+
// Preference like: importLines.firstLineIndex
|
|
55
|
+
if (property) {
|
|
56
|
+
if (onlyIndexesValues[group]?.[property] !== undefined) {
|
|
57
|
+
insertStory.index = onlyIndexesValues[group][property];
|
|
58
|
+
|
|
59
|
+
if (presentKey in onlyIndexesValues && !onlyIndexesValues[presentKey]) {
|
|
60
|
+
insertStory.gapBefore = true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Special preference like: first
|
|
70
|
+
if (preference === "firstLineIndex") {
|
|
71
|
+
insertStory.index = 0;
|
|
72
|
+
break;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return insertStory;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default startFunc;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import defaultFunc from 'pattern-collector-anyjs-story';
|
|
4
|
+
import insertImportLine from "./insertImportLine.js";
|
|
5
|
+
|
|
6
|
+
const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
7
|
+
try {
|
|
8
|
+
|
|
9
|
+
const folderNameToInsert = inFolderNameToInsert;
|
|
10
|
+
const localJsPath = inJsPath;
|
|
11
|
+
|
|
12
|
+
const fileContent = fs.readFileSync(localJsPath, 'utf8');
|
|
13
|
+
|
|
14
|
+
const story = defaultFunc({
|
|
15
|
+
fileContent,
|
|
16
|
+
fileType: inFileType
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
insertImportLine({
|
|
20
|
+
inStory: story,
|
|
21
|
+
fileContent, extractRegex: story?.extractRegex,
|
|
22
|
+
filePath: localJsPath, inFolderNameToInsert: folderNameToInsert,
|
|
23
|
+
inTemplate1: story.regexForPullLinesStory.importRegex.reverseTemplate,
|
|
24
|
+
inTemplate: story.reverseTemplates.importRegex,
|
|
25
|
+
inParts: [`${story.variablesConnection}${folderNameToInsert}`, folderNameToInsert],
|
|
26
|
+
fileType: inFileType
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.log("error : ", error);
|
|
31
|
+
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default startFunc;
|
|
36
|
+
|
|
37
|
+
// startFunc({ folderNameToInsert, fileType });
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import findInsertIndex from "../findInsertIndex.js";
|
|
3
|
+
import addLines from "../addLines.js";
|
|
4
|
+
|
|
5
|
+
function build(template, parts) {
|
|
6
|
+
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const startFunc = ({ inStory, fileContent, filePath, extractRegex,
|
|
10
|
+
inFolderNameToInsert, lineType = "importLines", inTemplate,
|
|
11
|
+
inParts, fileType }) => {
|
|
12
|
+
|
|
13
|
+
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
14
|
+
return element.part1 === inFolderNameToInsert;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (!foundUseLinesStory) {
|
|
18
|
+
const newLine = build(inTemplate, inParts);
|
|
19
|
+
|
|
20
|
+
const lines = fileContent.split(/\r?\n/);
|
|
21
|
+
|
|
22
|
+
const insertStory = findInsertIndex({
|
|
23
|
+
onlyIndexesValues: inStory?.onlyIndexesValues,
|
|
24
|
+
extractRegex: extractRegex?.toInsertIndex?.[fileType]?.import,
|
|
25
|
+
presentKey: lineType
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
addLines({
|
|
29
|
+
inLines: lines, inInsertAtIndex: insertStory?.index,
|
|
30
|
+
inNewLine: newLine, inGapBefore: insertStory?.gapBefore,
|
|
31
|
+
inGapAfter: insertStory?.gapAfter
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// lines.splice(insertAtIndex, 0, newLine);
|
|
35
|
+
|
|
36
|
+
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default startFunc;
|
|
@@ -16,4 +16,15 @@ const findImportLinesIndex = ({ inStory }) => {
|
|
|
16
16
|
return lastLine?.lineNumber;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
|
|
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
|
+
};
|
|
@@ -16,11 +16,12 @@ const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
|
16
16
|
|
|
17
17
|
insertUseLine({
|
|
18
18
|
inStory: story,
|
|
19
|
-
fileContent,
|
|
19
|
+
fileContent, extractRegex: story?.extractRegex,
|
|
20
20
|
filePath: localJsPath, inFolderNameToInsert: folderNameToInsert,
|
|
21
21
|
inTemplate1: story.regexForPullLinesStory.consumptionRegex.reverseTemplate,
|
|
22
22
|
inTemplate: story.reverseTemplates.consumptionRegex,
|
|
23
|
-
inParts: [folderNameToInsert, `${story.variablesConnection}${folderNameToInsert}`]
|
|
23
|
+
inParts: [folderNameToInsert, `${story.variablesConnection}${folderNameToInsert}`],
|
|
24
|
+
fileType: inFileType
|
|
24
25
|
});
|
|
25
26
|
};
|
|
26
27
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import findInsertIndex from "../findInsertIndex.js";
|
|
3
|
+
import addLines from "../addLines.js";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
findImportLinesFromNpmIndex, findImportLinesIndex,
|
|
7
|
+
findVariablesDeclareHereLinesIndex
|
|
8
|
+
} from "../forInsertIndex.js";
|
|
9
|
+
|
|
10
|
+
const findInsertIndex1 = ({ inStory }) => {
|
|
11
|
+
const importLines = findImportLinesIndex({ inStory });
|
|
12
|
+
const importLinesFromNpm = findImportLinesFromNpmIndex({ inStory });
|
|
13
|
+
const variablesDeclareHereLines = findVariablesDeclareHereLinesIndex({ inStory });
|
|
14
|
+
|
|
15
|
+
// findVariablesDeclareHereLinesIndex
|
|
16
|
+
return importLines ? importLines : variablesDeclareHereLines;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function build(template, parts) {
|
|
20
|
+
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const startFunc = ({ inStory, fileContent, filePath, extractRegex,
|
|
24
|
+
inFolderNameToInsert, lineType = "useLines", inTemplate, inParts,
|
|
25
|
+
fileType }) => {
|
|
26
|
+
|
|
27
|
+
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
28
|
+
return element.part1 === inFolderNameToInsert;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!foundUseLinesStory) {
|
|
32
|
+
const newLine = build(inTemplate, inParts);
|
|
33
|
+
|
|
34
|
+
const lines = fileContent.split(/\r?\n/);
|
|
35
|
+
|
|
36
|
+
const insertStory = findInsertIndex({
|
|
37
|
+
onlyIndexesValues: inStory?.onlyIndexesValues,
|
|
38
|
+
extractRegex: extractRegex?.toInsertIndex?.[fileType]?.consumption,
|
|
39
|
+
presentKey: lineType
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
addLines({
|
|
43
|
+
inLines: lines, inInsertAtIndex: insertStory?.index,
|
|
44
|
+
inNewLine: newLine, inGapBefore: insertStory?.gapBefore,
|
|
45
|
+
inGapAfter: insertStory?.gapAfter
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default startFunc;
|
package/bin/v16/start.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import forImportLine from "./forImportLine/index.js";
|
|
2
|
+
import forUseLine from "./forUseLine/index.js";
|
|
3
|
+
|
|
4
|
+
const startFunc = ({ inFolderNameToInsert, inFileType, jsFilePath }) => {
|
|
5
|
+
const fromImportLine = forImportLine({
|
|
6
|
+
inFolderNameToInsert, inFileType,
|
|
7
|
+
inJsPath: jsFilePath
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const fromUseLine = forUseLine({
|
|
11
|
+
inFolderNameToInsert, inFileType,
|
|
12
|
+
inJsPath: jsFilePath
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return { fromImportLine, fromUseLine }
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default startFunc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-fix-any-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.3",
|
|
4
4
|
"description": "CLI to build for appjs, the endpoints",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"project-generator"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"
|
|
14
|
-
"pattern-collector-anyjs-story": "^1.19.6"
|
|
13
|
+
"pattern-collector-anyjs-story": "^1.20.4"
|
|
15
14
|
},
|
|
16
15
|
"type": "module",
|
|
17
16
|
"exports": {
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
import defaultFunc from 'pattern-collector-anyjs-story';
|
|
4
|
-
import insertImportLine from "./insertImportLine.js";
|
|
5
|
-
|
|
6
|
-
const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
7
|
-
const folderNameToInsert = inFolderNameToInsert;
|
|
8
|
-
const localJsPath = inJsPath;
|
|
9
|
-
|
|
10
|
-
const fileContent = fs.readFileSync(localJsPath, 'utf8');
|
|
11
|
-
|
|
12
|
-
const story = defaultFunc({
|
|
13
|
-
fileContent,
|
|
14
|
-
fileType: inFileType
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
insertImportLine({
|
|
18
|
-
inStory: story,
|
|
19
|
-
fileContent,
|
|
20
|
-
filePath: localJsPath, inFolderNameToInsert: folderNameToInsert,
|
|
21
|
-
inTemplate1: story.regexForPullLinesStory.importRegex.reverseTemplate,
|
|
22
|
-
inTemplate: story.reverseTemplates.importRegex,
|
|
23
|
-
inParts: [`${story.variablesConnection}${folderNameToInsert}`, folderNameToInsert]
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default startFunc;
|
|
29
|
-
|
|
30
|
-
// startFunc({ folderNameToInsert, fileType });
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
function build(template, parts) {
|
|
4
|
-
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const findImportLinesFromNpmIndex = ({ inStory }) => {
|
|
8
|
-
const importLinesFromNpm = inStory?.linesStory?.importLinesFromNpm;
|
|
9
|
-
|
|
10
|
-
const lastLine = importLinesFromNpm[importLinesFromNpm.length - 1];
|
|
11
|
-
|
|
12
|
-
return lastLine?.lineNumber;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const findImportLinesIndex = ({ inStory }) => {
|
|
16
|
-
const importLines = inStory?.linesStory?.importLines;
|
|
17
|
-
|
|
18
|
-
const lastLine = importLines[importLines.length - 1];
|
|
19
|
-
|
|
20
|
-
return lastLine?.lineNumber;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const findInsertIndex = ({ inStory }) => {
|
|
24
|
-
const importLines = findImportLinesIndex({ inStory });
|
|
25
|
-
const importLinesFromNpm = findImportLinesFromNpmIndex({ inStory });
|
|
26
|
-
|
|
27
|
-
return importLines ? importLines : importLinesFromNpm;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const startFunc = ({ inStory, fileContent, filePath,
|
|
31
|
-
inFolderNameToInsert, lineType = "importLines", inTemplate, inParts }) => {
|
|
32
|
-
|
|
33
|
-
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
34
|
-
return element.part1 === inFolderNameToInsert;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (!foundUseLinesStory) {
|
|
38
|
-
const newLine = build(inTemplate, inParts);
|
|
39
|
-
|
|
40
|
-
const lines = fileContent.split(/\r?\n/);
|
|
41
|
-
|
|
42
|
-
// findInsertIndex({ inStory });
|
|
43
|
-
|
|
44
|
-
// const lastLine = inStory.lines[lineType][inStory.lines[lineType].length - 1];
|
|
45
|
-
// const insertAtIndex = lastLine.lineNumber;
|
|
46
|
-
|
|
47
|
-
const insertAtIndex = findInsertIndex({ inStory });
|
|
48
|
-
|
|
49
|
-
lines.splice(insertAtIndex, 0, newLine);
|
|
50
|
-
|
|
51
|
-
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default startFunc;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
import { findImportLinesFromNpmIndex, findImportLinesIndex } from "../forInsertIndex.js";
|
|
4
|
-
|
|
5
|
-
const findInsertIndex = ({ inStory }) => {
|
|
6
|
-
const importLines = findImportLinesIndex({ inStory });
|
|
7
|
-
const importLinesFromNpm = findImportLinesFromNpmIndex({ inStory });
|
|
8
|
-
|
|
9
|
-
return importLines ? importLines : importLinesFromNpm;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function build(template, parts) {
|
|
13
|
-
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const startFunc = ({ inStory, fileContent, filePath,
|
|
17
|
-
inFolderNameToInsert, lineType = "useLines", inTemplate, inParts }) => {
|
|
18
|
-
|
|
19
|
-
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
20
|
-
return element.part1 === inFolderNameToInsert;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!foundUseLinesStory) {
|
|
24
|
-
const newLine = build(inTemplate, inParts);
|
|
25
|
-
|
|
26
|
-
const lines = fileContent.split(/\r?\n/);
|
|
27
|
-
|
|
28
|
-
// const lastUseLine = inStory.lines[lineType][inStory.lines[lineType].length - 1];
|
|
29
|
-
// const insertAtIndex = lastUseLine.lineNumber;
|
|
30
|
-
|
|
31
|
-
const insertAtIndex = findInsertIndex({ inStory });
|
|
32
|
-
|
|
33
|
-
lines.splice(insertAtIndex, 0, newLine);
|
|
34
|
-
|
|
35
|
-
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default startFunc;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import forImportLine from "./forImportLine/index.js";
|
|
2
|
-
import forUseLine from "./forUseLine/index.js";
|
|
3
|
-
|
|
4
|
-
const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
5
|
-
forImportLine({ inFolderNameToInsert, inFileType, inJsPath })
|
|
6
|
-
forUseLine({ inFolderNameToInsert, inFileType, inJsPath })
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default startFunc;
|
|
10
|
-
|
|
11
|
-
// startFunc({ folderNameToInsert, fileType });
|
package/bin/v12/start.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
import defaultFunc from 'pattern-collector-anyjs-story';
|
|
4
|
-
import insertImportLine from "./insertImportLine.js";
|
|
5
|
-
|
|
6
|
-
const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
7
|
-
const folderNameToInsert = inFolderNameToInsert;
|
|
8
|
-
const localJsPath = inJsPath;
|
|
9
|
-
|
|
10
|
-
const fileContent = fs.readFileSync(localJsPath, 'utf8');
|
|
11
|
-
|
|
12
|
-
const story = defaultFunc({
|
|
13
|
-
fileContent,
|
|
14
|
-
fileType: inFileType
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
insertImportLine({
|
|
18
|
-
inStory: story,
|
|
19
|
-
fileContent,
|
|
20
|
-
filePath: localJsPath, inFolderNameToInsert: folderNameToInsert,
|
|
21
|
-
inTemplate1: story.regexForPullLinesStory.importRegex.reverseTemplate,
|
|
22
|
-
inTemplate: story.reverseTemplates.importRegex,
|
|
23
|
-
inParts: [`${story.variablesConnection}${folderNameToInsert}`, folderNameToInsert]
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default startFunc;
|
|
29
|
-
|
|
30
|
-
// startFunc({ folderNameToInsert, fileType });
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
function build(template, parts) {
|
|
4
|
-
return template.replace(/\{(\d+)\}/g, (_, i) => parts[i]);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const findImportLinesFromNpmIndex = ({ inStory }) => {
|
|
8
|
-
const importLinesFromNpm = inStory?.linesStory?.importLinesFromNpm;
|
|
9
|
-
|
|
10
|
-
const lastLine = importLinesFromNpm[importLinesFromNpm.length - 1];
|
|
11
|
-
|
|
12
|
-
return lastLine?.lineNumber;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const findImportLinesIndex = ({ inStory }) => {
|
|
16
|
-
const importLines = inStory?.linesStory?.importLines;
|
|
17
|
-
|
|
18
|
-
const lastLine = importLines[importLines.length - 1];
|
|
19
|
-
|
|
20
|
-
return lastLine?.lineNumber;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const findInsertIndex = ({ inStory }) => {
|
|
24
|
-
const importLines = findImportLinesIndex({ inStory });
|
|
25
|
-
const importLinesFromNpm = findImportLinesFromNpmIndex({ inStory });
|
|
26
|
-
|
|
27
|
-
return importLines ? importLines : importLinesFromNpm;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const startFunc = ({ inStory, fileContent, filePath,
|
|
31
|
-
inFolderNameToInsert, lineType = "importLines", inTemplate, inParts }) => {
|
|
32
|
-
|
|
33
|
-
const foundUseLinesStory = inStory.linesStory[lineType].find(element => {
|
|
34
|
-
return element.part1 === inFolderNameToInsert;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (!foundUseLinesStory) {
|
|
38
|
-
const newLine = build(inTemplate, inParts);
|
|
39
|
-
|
|
40
|
-
const lines = fileContent.split(/\r?\n/);
|
|
41
|
-
|
|
42
|
-
// findInsertIndex({ inStory });
|
|
43
|
-
|
|
44
|
-
// const lastLine = inStory.lines[lineType][inStory.lines[lineType].length - 1];
|
|
45
|
-
// const insertAtIndex = lastLine.lineNumber;
|
|
46
|
-
|
|
47
|
-
const insertAtIndex = findInsertIndex({ inStory });
|
|
48
|
-
|
|
49
|
-
lines.splice(insertAtIndex, 0, newLine);
|
|
50
|
-
|
|
51
|
-
fs.writeFileSync(filePath, lines.join(fileContent.includes("\r\n") ? "\r\n" : "\n"));
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default startFunc;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import forImportLine from "./forImportLine/index.js";
|
|
2
|
-
import forUseLine from "./forUseLine/index.js";
|
|
3
|
-
|
|
4
|
-
const startFunc = ({ inFolderNameToInsert, inFileType, inJsPath }) => {
|
|
5
|
-
forImportLine({ inFolderNameToInsert, inFileType, inJsPath })
|
|
6
|
-
forUseLine({ inFolderNameToInsert, inFileType, inJsPath })
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default startFunc;
|
|
10
|
-
|
|
11
|
-
// startFunc({ folderNameToInsert, fileType });
|
package/bin/v13/start.js
DELETED
|
File without changes
|