@qelos/plugins-cli 0.0.25 → 0.0.28

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.25",
3
+ "version": "0.0.28",
4
4
  "description": "CLI to manage QELOS plugins",
5
5
  "main": "cli.mjs",
6
6
  "bin": {
@@ -228,47 +228,58 @@ function classifyFiles(files, basePath) {
228
228
  }
229
229
  }
230
230
  } else if (ext === '.html') {
231
- // Find plugins that contain this HTML file (micro-frontends)
232
- classified.microFrontends.push(fullPath);
231
+ // HTML files can be in different contexts:
232
+ // 1. In plugins directory -> micro-frontends (part of a plugin)
233
+ // 2. In configs directory -> standalone HTML configs
234
+ // 3. Other locations -> treat as micro-frontends
233
235
 
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');
248
- }
236
+ if (relativePath.includes('configs/') || relativePath.includes('configs\\')) {
237
+ // HTML file in configs directory - treat as a config file
238
+ classified.configs.push(fullPath);
239
+ logger.debug(`Found HTML config file: ${relativePath}`);
240
+ } else {
241
+ // Find plugins that contain this HTML file (micro-frontends)
242
+ classified.microFrontends.push(fullPath);
249
243
 
250
- // If still not found, try searching for plugin.json in parent directories
244
+ // For HTML files, we need to find which plugin contains them
245
+ // HTML files in plugins are typically part of the plugin structure
246
+ let pluginDir = path.dirname(fullPath);
247
+ let pluginJson = path.join(pluginDir, 'plugin.json');
248
+
249
+ // If the file is in a temp path or unusual location, try to find the actual plugin
251
250
  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;
251
+ // Check if we're in a micro-frontends subdirectory
252
+ if (path.basename(pluginDir) === 'micro-frontends' ||
253
+ relativePath.includes('micro-frontends/') ||
254
+ relativePath.includes('micro-frontends\\')) {
255
+ // Go up one more level to find the plugin directory
256
+ pluginDir = path.dirname(pluginDir);
257
+ pluginJson = path.join(pluginDir, 'plugin.json');
258
+ }
259
+
260
+ // If still not found, try searching for plugin.json in parent directories
261
+ if (!fs.existsSync(pluginJson)) {
262
+ let searchDir = pluginDir;
263
+ for (let i = 0; i < 3; i++) { // Search up to 3 levels up
264
+ searchDir = path.dirname(searchDir);
265
+ const testPluginJson = path.join(searchDir, 'plugin.json');
266
+ if (fs.existsSync(testPluginJson)) {
267
+ pluginJson = testPluginJson;
268
+ break;
269
+ }
259
270
  }
260
271
  }
261
272
  }
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)}`);
273
+
274
+ if (fs.existsSync(pluginJson)) {
275
+ // This HTML file is part of a plugin
276
+ if (!classified.plugins.includes(pluginJson)) {
277
+ classified.plugins.push(pluginJson);
278
+ logger.debug(`Found plugin containing HTML ${relativePath}: ${path.basename(pluginJson)}`);
279
+ }
280
+ } else {
281
+ logger.warning(`Could not find plugin.json for HTML file: ${relativePath}`);
269
282
  }
270
- } else {
271
- logger.warning(`Could not find plugin.json for HTML file: ${relativePath}`);
272
283
  }
273
284
  } else {
274
285
  logger.debug(`Unclassified file: ${relativePath}`);
@@ -302,8 +313,10 @@ export function getGitFiles(type, basePath) {
302
313
  // Log what we found
303
314
  Object.entries(classified).forEach(([key, value]) => {
304
315
  if (value.length > 0) {
305
- if (key === 'prompts' || key === 'microFrontends') {
316
+ if (key === 'prompts') {
306
317
  logger.info(` ${key}: ${value.length} file(s) (will be pushed via parent)`);
318
+ } else if (key === 'microFrontends') {
319
+ logger.info(` ${key}: ${value.length} file(s) (will be pushed via parent plugin)`);
307
320
  } else {
308
321
  logger.info(` ${key}: ${value.length} file(s)`);
309
322
  }
@@ -377,6 +390,43 @@ export function prepareTempDirectories(classifiedFiles, tempDir) {
377
390
  logger.debug(`Failed to process refs for ${path.basename(file)}: ${error.message}`);
378
391
  }
379
392
  }
393
+
394
+ // If this is a plugin, check for micro-frontend HTML files and copy them too
395
+ if (type === 'plugins' && file.endsWith('.plugin.json')) {
396
+ try {
397
+ const content = fs.readFileSync(dest, 'utf-8');
398
+ const plugin = JSON.parse(content);
399
+
400
+ // Check if plugin has micro-frontends
401
+ if (plugin.microFrontends && plugin.microFrontends.length > 0) {
402
+ // Create micro-frontends directory in temp
403
+ const mfTempDir = path.join(tempDir, 'plugins', 'micro-frontends');
404
+ fs.mkdirSync(mfTempDir, { recursive: true });
405
+
406
+ for (const mf of plugin.microFrontends) {
407
+ if (mf.structure && mf.structure.$ref) {
408
+ const refPath = mf.structure.$ref;
409
+
410
+ // Resolve the ref path relative to the original plugin file location
411
+ const originalDir = path.dirname(file);
412
+ const mfSourcePath = path.resolve(originalDir, refPath);
413
+
414
+ if (fs.existsSync(mfSourcePath)) {
415
+ const mfFileName = path.basename(refPath);
416
+ const mfDestPath = path.join(mfTempDir, mfFileName);
417
+
418
+ fs.copyFileSync(mfSourcePath, mfDestPath);
419
+ logger.debug(`Copied micro-frontend ${refPath} from ${mfSourcePath} to ${mfDestPath}`);
420
+ } else {
421
+ logger.debug(`Micro-frontend file not found: ${mfSourcePath}`);
422
+ }
423
+ }
424
+ }
425
+ }
426
+ } catch (error) {
427
+ logger.debug(`Failed to process micro-frontends for ${path.basename(file)}: ${error.message}`);
428
+ }
429
+ }
380
430
  }
381
431
  }
382
432