@uniformdev/transformer 1.1.49 → 1.1.50

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
@@ -4044,6 +4044,7 @@ var ComponentAdderService = class {
4044
4044
  parentComponentType,
4045
4045
  slot,
4046
4046
  componentPatternId,
4047
+ compositionIds,
4047
4048
  whatIf,
4048
4049
  strict
4049
4050
  } = options;
@@ -4137,7 +4138,8 @@ var ComponentAdderService = class {
4137
4138
  newInstance,
4138
4139
  whatIf,
4139
4140
  strict,
4140
- "composition"
4141
+ "composition",
4142
+ compositionIds
4141
4143
  );
4142
4144
  const compositionPatternsResult = await this.addComponentToDirectory(
4143
4145
  fullCompositionPatternsDir,
@@ -4146,7 +4148,8 @@ var ComponentAdderService = class {
4146
4148
  newInstance,
4147
4149
  whatIf,
4148
4150
  strict,
4149
- "compositionPattern"
4151
+ "compositionPattern",
4152
+ compositionIds
4150
4153
  );
4151
4154
  const componentPatternsResult = await this.addComponentToDirectory(
4152
4155
  fullComponentPatternsDir,
@@ -4210,7 +4213,7 @@ var ComponentAdderService = class {
4210
4213
  }
4211
4214
  return raw;
4212
4215
  }
4213
- async addComponentToDirectory(directory, parentTypes, slot, newInstance, whatIf, strict, dirType) {
4216
+ async addComponentToDirectory(directory, parentTypes, slot, newInstance, whatIf, strict, dirType, compositionIds) {
4214
4217
  const exists = await this.fileSystem.fileExists(directory);
4215
4218
  if (!exists) {
4216
4219
  this.logger.detail(`${dirType} directory does not exist, skipping`);
@@ -4242,6 +4245,12 @@ var ComponentAdderService = class {
4242
4245
  continue;
4243
4246
  }
4244
4247
  const rootInstance = composition.composition;
4248
+ if (compositionIds && compositionIds.length > 0) {
4249
+ const compositionId = rootInstance._id;
4250
+ if (!compositionId || !compositionIds.some((id) => this.compareIds(compositionId, id, strict))) {
4251
+ continue;
4252
+ }
4253
+ }
4245
4254
  const rootPath = `${rootInstance._id ?? ""}${rootInstance.type}`;
4246
4255
  let modified = false;
4247
4256
  if (this.matchesAnyParentType(rootInstance.type, parentTypes, strict)) {
@@ -4400,7 +4409,7 @@ function createAddComponentCommand() {
4400
4409
  import { Command as Command8 } from "commander";
4401
4410
  function createAddComponentPatternCommand() {
4402
4411
  const command = new Command8("add-component-pattern");
4403
- command.description("Adds a component pattern instance to existing component slots across all compositions.").option("--parentComponentType <type>", "The component type that owns the slot").option("--slot <slotId>", "The slot ID where the component pattern will be added").option("--componentPatternId <id>", "The component pattern ID to add").hook("preAction", (thisCommand) => {
4412
+ command.description("Adds a component pattern instance to existing component slots across all compositions.").option("--parentComponentType <type>", "The component type that owns the slot").option("--slot <slotId>", "The slot ID where the component pattern will be added").option("--componentPatternId <id>", "The component pattern ID to add").option("--compositionIds <ids>", "Comma, semicolon, or pipe-separated list of composition IDs to limit the operation to").hook("preAction", (thisCommand) => {
4404
4413
  const opts = thisCommand.opts();
4405
4414
  const requiredOptions = [
4406
4415
  { name: "parentComponentType", flag: "--parentComponentType" },
@@ -4418,12 +4427,20 @@ function createAddComponentPatternCommand() {
4418
4427
  ...globalOpts,
4419
4428
  parentComponentType: opts.parentComponentType,
4420
4429
  slot: opts.slot,
4421
- componentPatternId: opts.componentPatternId
4430
+ componentPatternId: opts.componentPatternId,
4431
+ compositionIds: opts.compositionIds
4422
4432
  };
4423
4433
  const logger = new Logger();
4434
+ logger.info(`parentComponentType: ${options.parentComponentType}`);
4435
+ logger.info(`slot: ${options.slot}`);
4436
+ logger.info(`componentPatternId: ${options.componentPatternId}`);
4437
+ if (options.compositionIds) {
4438
+ logger.info(`compositionIds: ${options.compositionIds}`);
4439
+ }
4424
4440
  const fileSystem = new FileSystemService();
4425
4441
  const componentService = new ComponentService(fileSystem);
4426
4442
  const adder = new ComponentAdderService(fileSystem, componentService, logger);
4443
+ const parsedCompositionIds = options.compositionIds ? splitList(options.compositionIds) : void 0;
4427
4444
  try {
4428
4445
  const result = await adder.addComponentPattern({
4429
4446
  rootDir: options.rootDir,
@@ -4434,6 +4451,7 @@ function createAddComponentPatternCommand() {
4434
4451
  parentComponentType: options.parentComponentType,
4435
4452
  slot: options.slot,
4436
4453
  componentPatternId: options.componentPatternId,
4454
+ compositionIds: parsedCompositionIds,
4437
4455
  whatIf: options.whatIf ?? false,
4438
4456
  strict: options.strict ?? false
4439
4457
  });
@@ -7476,7 +7494,7 @@ function createPropagateRootSlotCommand() {
7476
7494
  // package.json
7477
7495
  var package_default = {
7478
7496
  name: "@uniformdev/transformer",
7479
- version: "1.1.49",
7497
+ version: "1.1.50",
7480
7498
  description: "CLI tool for transforming Uniform.dev serialization files offline",
7481
7499
  type: "module",
7482
7500
  bin: {