@uniformdev/transformer 1.1.0 → 1.1.1

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/dist/cli/index.js CHANGED
@@ -2513,11 +2513,16 @@ var ComponentAdderService = class {
2513
2513
  const findOptions = { strict };
2514
2514
  this.logger.info(`Loading parent component: ${parentComponentType}`);
2515
2515
  const { component: parentComponent, filePath: parentComponentFilePath } = await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);
2516
- const slotDef = parentComponent.slots?.find(
2516
+ if (!parentComponent.slots) {
2517
+ parentComponent.slots = [];
2518
+ }
2519
+ let slotDef = parentComponent.slots.find(
2517
2520
  (s) => this.compareIds(s.id, slot, strict)
2518
2521
  );
2519
2522
  if (!slotDef) {
2520
- throw new SlotNotFoundError(slot, parentComponentType);
2523
+ this.logger.info(`Slot "${slot}" not found on component "${parentComponentType}", creating it`);
2524
+ slotDef = { id: slot, name: slot, allowedComponents: [] };
2525
+ parentComponent.slots.push(slotDef);
2521
2526
  }
2522
2527
  this.logger.info(`Validating new component: ${newComponentType}`);
2523
2528
  try {
@@ -2619,11 +2624,16 @@ var ComponentAdderService = class {
2619
2624
  const findOptions = { strict };
2620
2625
  this.logger.info(`Loading parent component: ${parentComponentType}`);
2621
2626
  const { component: parentComponent } = await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);
2622
- const slotDef = parentComponent.slots?.find(
2627
+ if (!parentComponent.slots) {
2628
+ parentComponent.slots = [];
2629
+ }
2630
+ let slotDef = parentComponent.slots.find(
2623
2631
  (s) => this.compareIds(s.id, slot, strict)
2624
2632
  );
2625
2633
  if (!slotDef) {
2626
- throw new SlotNotFoundError(slot, parentComponentType);
2634
+ this.logger.info(`Slot "${slot}" not found on component "${parentComponentType}", creating it`);
2635
+ slotDef = { id: slot, name: slot, allowedComponents: [] };
2636
+ parentComponent.slots.push(slotDef);
2627
2637
  }
2628
2638
  this.logger.info(`Loading component pattern: ${componentPatternId}`);
2629
2639
  const pattern = await this.loadComponentPattern(