@qelos/plugins-cli 0.0.28 → 0.0.29
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 +1 -1
- package/services/git-files.mjs +59 -4
package/package.json
CHANGED
package/services/git-files.mjs
CHANGED
|
@@ -86,6 +86,50 @@ function getStagedFiles() {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Find configuration files that reference a specific HTML file via $ref
|
|
91
|
+
* @param {string} refPath - The referenced file path (relative)
|
|
92
|
+
* @param {string} basePath - Base path to search for configurations
|
|
93
|
+
* @returns {string[]} Array of configuration file paths that reference the HTML file
|
|
94
|
+
*/
|
|
95
|
+
function findReferencingConfigs(refPath, basePath) {
|
|
96
|
+
const referencingConfigs = [];
|
|
97
|
+
const configsDir = path.join(basePath, 'configs');
|
|
98
|
+
|
|
99
|
+
if (!fs.existsSync(configsDir)) {
|
|
100
|
+
return referencingConfigs;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const configFiles = fs.readdirSync(configsDir)
|
|
104
|
+
.filter(file => file.endsWith('.config.json'));
|
|
105
|
+
|
|
106
|
+
for (const file of configFiles) {
|
|
107
|
+
const filePath = path.join(configsDir, file);
|
|
108
|
+
try {
|
|
109
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
110
|
+
const config = JSON.parse(content);
|
|
111
|
+
|
|
112
|
+
// Check all $ref references in the config
|
|
113
|
+
const refs = findAllRefs(config);
|
|
114
|
+
|
|
115
|
+
// Check if any ref matches our target HTML file
|
|
116
|
+
// Normalize paths for comparison (handle ./ and different separators)
|
|
117
|
+
const normalizedRefPath = refPath.replace(/^\.\//, '').replace(/\\/g, '/');
|
|
118
|
+
|
|
119
|
+
if (refs.some(ref => {
|
|
120
|
+
const normalizedRef = ref.replace(/^\.\//, '').replace(/\\/g, '/');
|
|
121
|
+
return normalizedRef === normalizedRefPath;
|
|
122
|
+
})) {
|
|
123
|
+
referencingConfigs.push(filePath);
|
|
124
|
+
}
|
|
125
|
+
} catch (error) {
|
|
126
|
+
logger.debug(`Failed to parse config ${file}: ${error.message}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return referencingConfigs;
|
|
131
|
+
}
|
|
132
|
+
|
|
89
133
|
/**
|
|
90
134
|
* Find integration files that reference a specific file via $ref
|
|
91
135
|
* @param {string} refPath - The referenced file path (relative)
|
|
@@ -230,13 +274,24 @@ function classifyFiles(files, basePath) {
|
|
|
230
274
|
} else if (ext === '.html') {
|
|
231
275
|
// HTML files can be in different contexts:
|
|
232
276
|
// 1. In plugins directory -> micro-frontends (part of a plugin)
|
|
233
|
-
// 2. In configs directory ->
|
|
277
|
+
// 2. In configs directory -> These are typically referenced by configs, not pushed directly
|
|
234
278
|
// 3. Other locations -> treat as micro-frontends
|
|
235
279
|
|
|
236
280
|
if (relativePath.includes('configs/') || relativePath.includes('configs\\')) {
|
|
237
|
-
// HTML file in configs directory -
|
|
238
|
-
|
|
239
|
-
|
|
281
|
+
// HTML file in configs directory - these are usually referenced by config files, not pushed directly
|
|
282
|
+
logger.debug(`Found HTML file in configs directory (will be pushed via referencing config): ${relativePath}`);
|
|
283
|
+
|
|
284
|
+
// Find configs that reference this HTML file
|
|
285
|
+
const refPath = './' + path.relative('configs', relativePath);
|
|
286
|
+
const referencingConfigs = findReferencingConfigs(refPath, basePath);
|
|
287
|
+
|
|
288
|
+
// Add the referencing configs to the configs list
|
|
289
|
+
for (const configPath of referencingConfigs) {
|
|
290
|
+
if (!classified.configs.includes(configPath)) {
|
|
291
|
+
classified.configs.push(configPath);
|
|
292
|
+
logger.debug(`Found config referencing HTML ${relativePath}: ${path.basename(configPath)}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
240
295
|
} else {
|
|
241
296
|
// Find plugins that contain this HTML file (micro-frontends)
|
|
242
297
|
classified.microFrontends.push(fullPath);
|