@qelos/plugins-cli 0.0.27 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qelos/plugins-cli",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "CLI to manage QELOS plugins",
5
5
  "main": "cli.mjs",
6
6
  "bin": {
@@ -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)
@@ -228,47 +272,69 @@ function classifyFiles(files, basePath) {
228
272
  }
229
273
  }
230
274
  } else if (ext === '.html') {
231
- // Find plugins that contain this HTML file (micro-frontends)
232
- classified.microFrontends.push(fullPath);
275
+ // HTML files can be in different contexts:
276
+ // 1. In plugins directory -> micro-frontends (part of a plugin)
277
+ // 2. In configs directory -> These are typically referenced by configs, not pushed directly
278
+ // 3. Other locations -> treat as micro-frontends
233
279
 
234
- // For HTML files, we need to find which plugin contains them
235
- // HTML files in plugins are typically part of the plugin structure
236
- let pluginDir = path.dirname(fullPath);
237
- let pluginJson = path.join(pluginDir, 'plugin.json');
238
-
239
- // If the file is in a temp path or unusual location, try to find the actual plugin
240
- if (!fs.existsSync(pluginJson)) {
241
- // Check if we're in a micro-frontends subdirectory
242
- if (path.basename(pluginDir) === 'micro-frontends' ||
243
- relativePath.includes('micro-frontends/') ||
244
- relativePath.includes('micro-frontends\\')) {
245
- // Go up one more level to find the plugin directory
246
- pluginDir = path.dirname(pluginDir);
247
- pluginJson = path.join(pluginDir, 'plugin.json');
280
+ if (relativePath.includes('configs/') || relativePath.includes('configs\\')) {
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
+ }
248
294
  }
295
+ } else {
296
+ // Find plugins that contain this HTML file (micro-frontends)
297
+ classified.microFrontends.push(fullPath);
249
298
 
250
- // If still not found, try searching for plugin.json in parent directories
299
+ // For HTML files, we need to find which plugin contains them
300
+ // HTML files in plugins are typically part of the plugin structure
301
+ let pluginDir = path.dirname(fullPath);
302
+ let pluginJson = path.join(pluginDir, 'plugin.json');
303
+
304
+ // If the file is in a temp path or unusual location, try to find the actual plugin
251
305
  if (!fs.existsSync(pluginJson)) {
252
- let searchDir = pluginDir;
253
- for (let i = 0; i < 3; i++) { // Search up to 3 levels up
254
- searchDir = path.dirname(searchDir);
255
- const testPluginJson = path.join(searchDir, 'plugin.json');
256
- if (fs.existsSync(testPluginJson)) {
257
- pluginJson = testPluginJson;
258
- break;
306
+ // Check if we're in a micro-frontends subdirectory
307
+ if (path.basename(pluginDir) === 'micro-frontends' ||
308
+ relativePath.includes('micro-frontends/') ||
309
+ relativePath.includes('micro-frontends\\')) {
310
+ // Go up one more level to find the plugin directory
311
+ pluginDir = path.dirname(pluginDir);
312
+ pluginJson = path.join(pluginDir, 'plugin.json');
313
+ }
314
+
315
+ // If still not found, try searching for plugin.json in parent directories
316
+ if (!fs.existsSync(pluginJson)) {
317
+ let searchDir = pluginDir;
318
+ for (let i = 0; i < 3; i++) { // Search up to 3 levels up
319
+ searchDir = path.dirname(searchDir);
320
+ const testPluginJson = path.join(searchDir, 'plugin.json');
321
+ if (fs.existsSync(testPluginJson)) {
322
+ pluginJson = testPluginJson;
323
+ break;
324
+ }
259
325
  }
260
326
  }
261
327
  }
262
- }
263
-
264
- if (fs.existsSync(pluginJson)) {
265
- // This HTML file is part of a plugin
266
- if (!classified.plugins.includes(pluginJson)) {
267
- classified.plugins.push(pluginJson);
268
- logger.debug(`Found plugin containing HTML ${relativePath}: ${path.basename(pluginJson)}`);
328
+
329
+ if (fs.existsSync(pluginJson)) {
330
+ // This HTML file is part of a plugin
331
+ if (!classified.plugins.includes(pluginJson)) {
332
+ classified.plugins.push(pluginJson);
333
+ logger.debug(`Found plugin containing HTML ${relativePath}: ${path.basename(pluginJson)}`);
334
+ }
335
+ } else {
336
+ logger.warning(`Could not find plugin.json for HTML file: ${relativePath}`);
269
337
  }
270
- } else {
271
- logger.warning(`Could not find plugin.json for HTML file: ${relativePath}`);
272
338
  }
273
339
  } else {
274
340
  logger.debug(`Unclassified file: ${relativePath}`);
@@ -302,8 +368,10 @@ export function getGitFiles(type, basePath) {
302
368
  // Log what we found
303
369
  Object.entries(classified).forEach(([key, value]) => {
304
370
  if (value.length > 0) {
305
- if (key === 'prompts' || key === 'microFrontends') {
371
+ if (key === 'prompts') {
306
372
  logger.info(` ${key}: ${value.length} file(s) (will be pushed via parent)`);
373
+ } else if (key === 'microFrontends') {
374
+ logger.info(` ${key}: ${value.length} file(s) (will be pushed via parent plugin)`);
307
375
  } else {
308
376
  logger.info(` ${key}: ${value.length} file(s)`);
309
377
  }