@uxf/scripts 11.69.2 → 11.74.0

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.69.2",
3
+ "version": "11.74.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -93,8 +93,10 @@ async function checkUxfDependencies(excludedPackages = new Set()) {
93
93
  for (const { name, versions } of conflicts) {
94
94
  console.log(`- ${name}: ${versions.join(", ")}`);
95
95
  }
96
+ process.exit(1);
96
97
  } else {
97
98
  console.log("Všechny závislosti UXF balíčků mají jednotnou verzi.");
99
+ process.exit(0);
98
100
  }
99
101
  }
100
102
 
@@ -64,6 +64,80 @@ 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
+ const resolvedFiles = [];
74
+
75
+ if (!fs.existsSync(filePath)) {
76
+ return [filePath];
77
+ }
78
+
79
+ try {
80
+ const content = fs.readFileSync(filePath, "utf8");
81
+
82
+ // Check if this is a re-export file (contains export { } from)
83
+ const reexportMatches = content.match(/export\s*\{[^}]*\}\s*from\s*['"]([^'"]+)['"]/g);
84
+
85
+ if (reexportMatches) {
86
+ const fileDir = path.dirname(filePath);
87
+
88
+ for (const match of reexportMatches) {
89
+ const pathMatch = match.match(/from\s*['"]([^'"]+)['"]/);
90
+ if (pathMatch) {
91
+ let relativePath = pathMatch[1];
92
+
93
+ // Resolve relative path
94
+ let resolvedPath = path.resolve(fileDir, relativePath);
95
+
96
+ // Try different extensions if file doesn't exist
97
+ const extensions = [".ts", ".tsx", ".js", ".jsx"];
98
+ let foundFile = false;
99
+
100
+ for (const ext of extensions) {
101
+ const pathWithExt = resolvedPath + ext;
102
+ if (fs.existsSync(pathWithExt)) {
103
+ resolvedFiles.push(pathWithExt);
104
+ foundFile = true;
105
+ break;
106
+ }
107
+ }
108
+
109
+ // If still not found, check if it's a directory with index file
110
+ if (!foundFile && fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) {
111
+ for (const ext of extensions) {
112
+ const indexPath = path.join(resolvedPath, "index" + ext);
113
+ if (fs.existsSync(indexPath)) {
114
+ // Recursively resolve if the index file also has re-exports
115
+ resolvedFiles.push(...resolveReexports(indexPath));
116
+ foundFile = true;
117
+ break;
118
+ }
119
+ }
120
+ }
121
+
122
+ if (!foundFile) {
123
+ console.warn(`Could not resolve re-export: ${relativePath} from ${filePath}`);
124
+ }
125
+ }
126
+ }
127
+
128
+ // If we found re-exports, don't include the original index file
129
+ if (resolvedFiles.length > 0) {
130
+ return resolvedFiles;
131
+ }
132
+ }
133
+ } catch (error) {
134
+ console.warn(`Error reading file ${filePath}:`, error.message);
135
+ }
136
+
137
+ // If no re-exports found or error occurred, return the original file
138
+ return [filePath];
139
+ }
140
+
67
141
  /**
68
142
  * @param include string[]
69
143
  * @param output string
@@ -83,6 +157,10 @@ function main(include, output, defaultNamespaces, pagesDirectory, fileExtensions
83
157
  tsConfig: TS_CONFIG,
84
158
  excludeRegExp: [searchDirs],
85
159
  fileExtensions: fileExtensions,
160
+ includeNpm: true,
161
+ dependencyFilter: (dependency) => {
162
+ return !dependency.includes("node_modules") || dependency.includes("node_modules/@uxf");
163
+ },
86
164
  }).then((res) => {
87
165
  const tree = res.obj();
88
166
 
@@ -90,14 +168,36 @@ function main(include, output, defaultNamespaces, pagesDirectory, fileExtensions
90
168
  let namespaces = [];
91
169
  const filesOnPath = [];
92
170
 
171
+ // Always include the entry point file itself (for cases when page does not import anything with translations)
172
+ filesOnPath.push(entryPoint);
173
+
93
174
  getTree([entryPoint], tree, filesOnPath);
94
175
 
95
- const flattenFilesOnPath = Array.from(new Set(filesOnPath.flat(Number.POSITIVE_INFINITY)));
176
+ let flattenFilesOnPath = Array.from(new Set(filesOnPath.flat(Number.POSITIVE_INFINITY)));
96
177
 
178
+ // Resolve re-exports to get actual component files
179
+ const resolvedFiles = [];
97
180
  for (const file of flattenFilesOnPath) {
98
- const fileContent = readFileSync(file).toString();
181
+ if (file && typeof file === "string") {
182
+ resolvedFiles.push(...resolveReexports(file));
183
+ }
184
+ }
185
+
186
+ const uniqueResolvedFiles = Array.from(new Set(resolvedFiles));
187
+
188
+ for (const file of uniqueResolvedFiles) {
189
+ if (!file || !fs.existsSync(file)) {
190
+ continue;
191
+ }
192
+
193
+ try {
194
+ const fileContent = readFileSync(file).toString();
195
+ const fileNamespaces = findNamespaces(fileContent);
99
196
 
100
- namespaces = [...namespaces, ...findNamespaces(fileContent)];
197
+ namespaces = [...namespaces, ...fileNamespaces];
198
+ } catch (error) {
199
+ console.warn(`Error reading file ${file}:`, error.message);
200
+ }
101
201
  }
102
202
 
103
203
  namespaces = Array.from(new Set(namespaces)).sort();