pattern-collector-anyjs-story 1.16.2 → 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.
@@ -0,0 +1,104 @@
1
+ export default {
2
+ files: [
3
+ "fromAppJs"
4
+ ],
5
+ fileStory: {
6
+ fromAppJs: {
7
+ importNpmRegex: {
8
+ searchRegex: /^[ \t]*import\b.*from\s+['"](?!\.{1,2}\/|\/)[^'"]+['"];/gm
9
+ },
10
+ importRegex: {
11
+ parseRegex: /import\s*\{[^}]*router\s+as\s+(\w+)[^}]*\}\s*from\s*['"]\.\/([^/]+)\/.*['"]/,
12
+ searchRegex: /^[ \t]*import\b.*from\s+['"]\.[^'"]*['"];/gm
13
+ },
14
+ consumptionRegex: {
15
+ parseRegex: /router\.use\s*\(\s*['"`]\/?([^'"`]+)['"`]\s*,\s*(\w+)/,
16
+ searchRegex: /^[ \t]*router\.use\b.*?;/gm
17
+ },
18
+ exportRegex: {
19
+ searchRegex: /export\s*\{\s*(\w+)\s*\}\s*;?/gm
20
+ }
21
+ }
22
+ },
23
+ searchRules: {
24
+ fromAppJs: {
25
+ importNpmRegex: /^[ \t]*import\b.*from\s+['"](?!\.{1,2}\/|\/)[^'"]+['"];/gm,
26
+ importRegex: /^[ \t]*import\b.*from\s+['"]\.[^'"]*['"];/gm,
27
+ consumptionRegex: /^[ \t]*router\.use\b.*?;/gm,
28
+ exportRegex: /export\s*\{\s*(\w+)\s*\}\s*;?/gm
29
+ }
30
+ },
31
+ parseRules: {
32
+ fromAppJs: {
33
+ importNpmRegex: "",
34
+ importRegex: /import\s*\{[^}]*router\s+as\s+(\w+)[^}]*\}\s*from\s*['"]\.\/([^/]+)\/.*['"]/,
35
+ consumptionRegex: /router\.use\s*\(\s*['"`]\/?([^'"`]+)['"`]\s*,\s*(\w+)/,
36
+ exportRegex: ""
37
+ }
38
+ },
39
+ fromEndPointsJs: {
40
+ importNpmRegex: {
41
+ searchRegex: /^[ \t]*import\b.*from\s+['"](?:(?!\.{1,2}\/|\/)[^'"]+)['"]\s*;?/gm
42
+ },
43
+ importRegex: {
44
+ parseRegex: /import\s+(\w+)\s+from\s*['"]\.\/([^/]+)\/controller\.js['"]/,
45
+ searchRegex: /^[ \t]*import\b.*from\s+['"]\.\/[^'"]+\/controller\.js['"]\s*;?/gm
46
+ },
47
+ consumptionRegex: {
48
+ parseRegex1: /router\.(get|post|put|delete|patch)\s*\(\s*['"]([^'"]+)['"].*?\b(\w+)\s*\(/,
49
+ parseRegex: /router\.\w+\(\s*['"]\/?([^'"]+)['"][\s\S]*?\b(funcFrom\w+)\s*\(/,
50
+ parseRegex2: /router\.\w+\(\s*['"]([^'"]+)['"][\s\S]*?\b(funcFrom\w+)\s*\(/,
51
+ parseRegex3: /router\.(get|post|put|delete|patch)\(\s*['"]\/?([^'"]+)['"][\s\S]*?\b(funcFrom\w+)\s*\(/,
52
+ searchRegex: /^[ \t]*router\.(?:get|post|put|delete|patch)\b.*;?/gm
53
+ },
54
+ exportRegex: {
55
+ searchRegex: /export\s*\{\s*(\w+)\s*\}\s*;?/gm
56
+ }
57
+ },
58
+ fromRoutesJs: {
59
+ parseRules: {
60
+ importNpmRegex: {
61
+ },
62
+ importRegex: {
63
+ parseRegex: /import\s*\{[^}]*router\s+as\s+(\w+)[^}]*\}\s*from\s*['"]\.\/([^/]+)\/.*['"]/,
64
+ nParts: 2
65
+ },
66
+ consumptionRegex: {
67
+ parseRegex: /router\.use\s*\(\s*['"`]\/?([^'"`]+)['"`]\s*,\s*(\w+)/,
68
+ nParts: 2
69
+ },
70
+ exportRegex: {
71
+ }
72
+ },
73
+ searchRules: {
74
+ importNpmRegex: {
75
+ searchRegex: /^[ \t]*import\b.*from\s+['"](?!\.{1,2}\/|\/)[^'"]+['"];/gm
76
+ },
77
+ importRegex: {
78
+ searchRegex: /^[ \t]*import\s*\{[\s\S]*?\brouter\s+as\s+(\w+)[\s\S]*?\}\s*from\s*['"]\.\/([^'"]+)\/routes\.js['"]\s*;/gm
79
+ },
80
+ consumptionRegex: {
81
+ searchRegex: /^[ \t]*router\.use\b.*?;/gm
82
+ },
83
+ exportRegex: {
84
+ searchRegex: /export\s*\{\s*(\w+)\s*\}\s*;?/gm
85
+ }
86
+ }
87
+ },
88
+ fromAppJs: {
89
+ importNpmRegex: {
90
+ searchRegex: /^[ \t]*import\b.*from\s+['"](?!\.{1,2}\/|\/)[^'"]+['"];/gm
91
+ },
92
+ importRegex: {
93
+ parseRegex: /import\s*\{[^}]*router\s+as\s+(\w+)[^}]*\}\s*from\s*['"]\.\/([^/]+)\/.*['"]/,
94
+ searchRegex: /^[ \t]*import\b.*from\s+['"]\.[^'"]*['"];/gm
95
+ },
96
+ consumptionRegex: {
97
+ parseRegex: /router\.use\s*\(\s*['"`]\/?([^'"`]+)['"`]\s*,\s*(\w+)/,
98
+ searchRegex: /^[ \t]*router\.use\b.*?;/gm
99
+ },
100
+ exportRegex: {
101
+ searchRegex: /export\s*\{\s*(\w+)\s*\}\s*;?/gm
102
+ }
103
+ }
104
+ };
package/bin/v16/index.js CHANGED
@@ -3,24 +3,27 @@
3
3
  import pullLines from "./pullLines/index.js";
4
4
  import pullLinesStory from "./pullLinesStory/index.js";
5
5
 
6
- const startFunc = ({ fileContent, searchRules, parseRules
6
+ import extractRegex from './extractRegex.js';
7
+
8
+ const startFunc = ({ fileContent, fileType,
9
+ searchRules, parseRules
7
10
  }) => {
8
- let allLines;
11
+ let lines;
9
12
 
10
- const lines = pullLines({
13
+ lines = pullLines({
11
14
  fileContent,
12
- consumptionSearchRegex: searchRules?.consumptionRegex?.searchRegex,
13
- importSearchRegex: searchRules?.importRegex?.searchRegex,
14
- exportSearchRegex: searchRules?.exportRegex?.searchRegex,
15
- importSearchNpmRegex: searchRules?.importNpmRegex?.searchRegex
15
+ consumptionSearchRegex: extractRegex.searchRules[fileType].consumptionRegex,
16
+ importSearchRegex: extractRegex.searchRules[fileType].importRegex,
17
+ exportSearchRegex: extractRegex.searchRules[fileType].exportRegex,
18
+ importSearchNpmRegex: extractRegex.searchRules[fileType].importNpmRegex,
16
19
  });
17
20
 
18
21
  const linesStory = pullLinesStory({
19
22
  inLines: lines,
20
- importNpmRegex: parseRules?.parseRules?.importNpmRegex,
21
- importRegex: parseRules?.parseRules?.importRegex,
22
- consumptionRegex: parseRules?.parseRules?.consumptionRegex,
23
- exportRegex: parseRules?.parseRules?.exportRegex,
23
+ importNpmRegex: extractRegex.parseRules[fileType]?.importNpmRegex,
24
+ importRegex: extractRegex.parseRules[fileType].importRegex,
25
+ consumptionRegex: extractRegex.parseRules[fileType].consumptionRegex,
26
+ exportRegex: extractRegex.parseRules[fileType]?.exportRegex,
24
27
  });
25
28
 
26
29
  return { lines, linesStory };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pattern-collector-anyjs-story",
3
- "version": "1.16.2",
3
+ "version": "1.16.3",
4
4
  "description": "A powerful, configurable tool to scan JavaScript/ESM files and pull structured line matches using custom regular expressions.",
5
5
  "keywords": [
6
6
  "pattern",