@uxf/scripts 11.72.3 → 11.74.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "11.72.3",
3
+ "version": "11.74.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -64,6 +64,85 @@ const filePathToRoute = (filePath) => {
64
64
  return removeTrailingSlash(route);
65
65
  };
66
66
 
67
+ /**
68
+ * Resolves re-exports to find the actual implementation files
69
+ * @param {string} filePath - The file path to check for re-exports
70
+ * @returns {string[]} - Array of resolved file paths
71
+ */
72
+ function resolveReexports(filePath) {
73
+ if (filePath.includes("node_modules") && !filePath.includes("node_modules/@uxf/")) {
74
+ return [];
75
+ }
76
+
77
+ const resolvedFiles = [];
78
+
79
+ if (!fs.existsSync(filePath)) {
80
+ return [filePath];
81
+ }
82
+
83
+ try {
84
+ const content = fs.readFileSync(filePath, "utf8");
85
+
86
+ // Check if this is a re-export file with relative imports (contains export { } from or export * from "./file")
87
+ // Absolute imports (export * from "@package/module") are already handled by madge
88
+ const reexportMatches = content.match(/export\s*(?:\{[^}]*\}|\*)\s*from\s*['"](\.[^'"]+)['"]/g);
89
+
90
+ if (reexportMatches) {
91
+ const fileDir = path.dirname(filePath);
92
+
93
+ for (const match of reexportMatches) {
94
+ const pathMatch = match.match(/from\s*['"]([^'"]+)['"]/);
95
+ if (pathMatch) {
96
+ let relativePath = pathMatch[1];
97
+
98
+ // Resolve relative path
99
+ let resolvedPath = path.resolve(fileDir, relativePath);
100
+
101
+ // Try different extensions if file doesn't exist
102
+ const extensions = [".ts", ".tsx", ".js", ".jsx"];
103
+ let foundFile = false;
104
+
105
+ for (const ext of extensions) {
106
+ const pathWithExt = resolvedPath + ext;
107
+ if (fs.existsSync(pathWithExt)) {
108
+ resolvedFiles.push(pathWithExt);
109
+ foundFile = true;
110
+ break;
111
+ }
112
+ }
113
+
114
+ // If still not found, check if it's a directory with index file
115
+ if (!foundFile && fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) {
116
+ for (const ext of extensions) {
117
+ const indexPath = path.join(resolvedPath, "index" + ext);
118
+ if (fs.existsSync(indexPath)) {
119
+ // Recursively resolve if the index file also has re-exports
120
+ resolvedFiles.push(...resolveReexports(indexPath));
121
+ foundFile = true;
122
+ break;
123
+ }
124
+ }
125
+ }
126
+
127
+ if (!foundFile) {
128
+ console.warn(`Could not resolve re-export: ${relativePath} from ${filePath}`);
129
+ }
130
+ }
131
+ }
132
+
133
+ // If we found re-exports, don't include the original index file
134
+ if (resolvedFiles.length > 0) {
135
+ return resolvedFiles;
136
+ }
137
+ }
138
+ } catch (error) {
139
+ console.warn(`Error reading file ${filePath}:`, error.message);
140
+ }
141
+
142
+ // If no re-exports found or error occurred, return the original file
143
+ return [filePath];
144
+ }
145
+
67
146
  /**
68
147
  * @param include string[]
69
148
  * @param output string
@@ -83,6 +162,10 @@ function main(include, output, defaultNamespaces, pagesDirectory, fileExtensions
83
162
  tsConfig: TS_CONFIG,
84
163
  excludeRegExp: [searchDirs],
85
164
  fileExtensions: fileExtensions,
165
+ includeNpm: true,
166
+ dependencyFilter: (dependency) => {
167
+ return !dependency.includes("node_modules") || dependency.includes("node_modules/@uxf");
168
+ },
86
169
  }).then((res) => {
87
170
  const tree = res.obj();
88
171
 
@@ -90,14 +173,36 @@ function main(include, output, defaultNamespaces, pagesDirectory, fileExtensions
90
173
  let namespaces = [];
91
174
  const filesOnPath = [];
92
175
 
176
+ // Always include the entry point file itself (for cases when page does not import anything with translations)
177
+ filesOnPath.push(entryPoint);
178
+
93
179
  getTree([entryPoint], tree, filesOnPath);
94
180
 
95
- const flattenFilesOnPath = Array.from(new Set(filesOnPath.flat(Number.POSITIVE_INFINITY)));
181
+ let flattenFilesOnPath = Array.from(new Set(filesOnPath.flat(Number.POSITIVE_INFINITY)));
96
182
 
183
+ // Resolve re-exports to get actual component files
184
+ const resolvedFiles = [];
97
185
  for (const file of flattenFilesOnPath) {
98
- const fileContent = readFileSync(file).toString();
186
+ if (file && typeof file === "string") {
187
+ resolvedFiles.push(...resolveReexports(file));
188
+ }
189
+ }
190
+
191
+ const uniqueResolvedFiles = Array.from(new Set(resolvedFiles));
192
+
193
+ for (const file of uniqueResolvedFiles) {
194
+ if (!file || !fs.existsSync(file)) {
195
+ continue;
196
+ }
197
+
198
+ try {
199
+ const fileContent = readFileSync(file).toString();
200
+ const fileNamespaces = findNamespaces(fileContent);
99
201
 
100
- namespaces = [...namespaces, ...findNamespaces(fileContent)];
202
+ namespaces = [...namespaces, ...fileNamespaces];
203
+ } catch (error) {
204
+ console.warn(`Error reading file ${file}:`, error.message);
205
+ }
101
206
  }
102
207
 
103
208
  namespaces = Array.from(new Set(namespaces)).sort();