@uniformdev/transformer 1.1.31 → 1.1.33
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 +145 -80
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +96 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -346,18 +346,31 @@ var ComponentService = class {
|
|
|
346
346
|
}
|
|
347
347
|
return component;
|
|
348
348
|
}
|
|
349
|
+
resolveRemoveIds(component, parameterId, options = {}) {
|
|
350
|
+
const param = this.findParameter(component, parameterId, options);
|
|
351
|
+
if (!param) return [];
|
|
352
|
+
if (!this.isGroupParameter(param)) {
|
|
353
|
+
return [param.id];
|
|
354
|
+
}
|
|
355
|
+
const ids = [param.id];
|
|
356
|
+
for (const childId of param.typeConfig?.childrenParams ?? []) {
|
|
357
|
+
ids.push(...this.resolveRemoveIds(component, childId, options));
|
|
358
|
+
}
|
|
359
|
+
return ids;
|
|
360
|
+
}
|
|
349
361
|
removeParameter(component, parameterId, options = {}) {
|
|
350
362
|
const { strict = false } = options;
|
|
351
363
|
if (!component.parameters) {
|
|
352
364
|
return component;
|
|
353
365
|
}
|
|
366
|
+
const idsToRemove = this.resolveRemoveIds(component, parameterId, options);
|
|
354
367
|
component.parameters = component.parameters.filter(
|
|
355
|
-
(p) => !this.compareIds(p.id,
|
|
368
|
+
(p) => !idsToRemove.some((id) => this.compareIds(p.id, id, strict))
|
|
356
369
|
);
|
|
357
370
|
for (const param of component.parameters) {
|
|
358
371
|
if (this.isGroupParameter(param) && param.typeConfig?.childrenParams) {
|
|
359
372
|
param.typeConfig.childrenParams = param.typeConfig.childrenParams.filter(
|
|
360
|
-
(id) => !this.compareIds(id,
|
|
373
|
+
(id) => !idsToRemove.some((removeId) => this.compareIds(id, removeId, strict))
|
|
361
374
|
);
|
|
362
375
|
}
|
|
363
376
|
}
|
|
@@ -4520,11 +4533,20 @@ var ParameterRemoverService = class {
|
|
|
4520
4533
|
if (!param) {
|
|
4521
4534
|
throw new PropertyNotFoundError(parameterId, componentType);
|
|
4522
4535
|
}
|
|
4536
|
+
const allIdsToRemove = this.componentService.resolveRemoveIds(component, parameterId, findOptions);
|
|
4537
|
+
const childIds = allIdsToRemove.filter((id) => !this.compareIds(id, parameterId, strict));
|
|
4523
4538
|
this.logger.action(
|
|
4524
4539
|
whatIf,
|
|
4525
4540
|
"REMOVE",
|
|
4526
4541
|
`Parameter "${parameterId}" from component/${this.fileSystem.getBasename(componentFilePath)}`
|
|
4527
4542
|
);
|
|
4543
|
+
if (childIds.length > 0) {
|
|
4544
|
+
this.logger.action(
|
|
4545
|
+
whatIf,
|
|
4546
|
+
"REMOVE",
|
|
4547
|
+
`Cascade-removing ${childIds.length} child parameter(s) [${childIds.join(", ")}] from component/${this.fileSystem.getBasename(componentFilePath)}`
|
|
4548
|
+
);
|
|
4549
|
+
}
|
|
4528
4550
|
let modifiedComponent = this.componentService.removeParameter(component, parameterId, findOptions);
|
|
4529
4551
|
const beforeGroupCount = modifiedComponent.parameters?.filter(
|
|
4530
4552
|
(p) => this.componentService.isGroupParameter(p)
|
|
@@ -4547,7 +4569,7 @@ var ParameterRemoverService = class {
|
|
|
4547
4569
|
const compositionsResult = await this.removeParameterInDirectory(
|
|
4548
4570
|
fullCompositionsDir,
|
|
4549
4571
|
componentType,
|
|
4550
|
-
|
|
4572
|
+
allIdsToRemove,
|
|
4551
4573
|
whatIf,
|
|
4552
4574
|
strict,
|
|
4553
4575
|
"composition"
|
|
@@ -4555,7 +4577,7 @@ var ParameterRemoverService = class {
|
|
|
4555
4577
|
const compositionPatternsResult = await this.removeParameterInDirectory(
|
|
4556
4578
|
fullCompositionPatternsDir,
|
|
4557
4579
|
componentType,
|
|
4558
|
-
|
|
4580
|
+
allIdsToRemove,
|
|
4559
4581
|
whatIf,
|
|
4560
4582
|
strict,
|
|
4561
4583
|
"compositionPattern"
|
|
@@ -4563,7 +4585,7 @@ var ParameterRemoverService = class {
|
|
|
4563
4585
|
const componentPatternsResult = await this.removeParameterInDirectory(
|
|
4564
4586
|
fullComponentPatternsDir,
|
|
4565
4587
|
componentType,
|
|
4566
|
-
|
|
4588
|
+
allIdsToRemove,
|
|
4567
4589
|
whatIf,
|
|
4568
4590
|
strict,
|
|
4569
4591
|
"componentPattern"
|
|
@@ -4582,7 +4604,7 @@ var ParameterRemoverService = class {
|
|
|
4582
4604
|
instancesUpdated: totalInstances
|
|
4583
4605
|
};
|
|
4584
4606
|
}
|
|
4585
|
-
async removeParameterInDirectory(directory, componentType,
|
|
4607
|
+
async removeParameterInDirectory(directory, componentType, parameterIds, whatIf, strict, label) {
|
|
4586
4608
|
let files;
|
|
4587
4609
|
try {
|
|
4588
4610
|
files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
|
|
@@ -4607,13 +4629,13 @@ var ParameterRemoverService = class {
|
|
|
4607
4629
|
const count = this.removeParameterFromTree(
|
|
4608
4630
|
composition.composition,
|
|
4609
4631
|
componentType,
|
|
4610
|
-
|
|
4632
|
+
parameterIds,
|
|
4611
4633
|
strict
|
|
4612
4634
|
);
|
|
4613
4635
|
const overridesCount = this.removeParameterFromOverrides(
|
|
4614
4636
|
composition,
|
|
4615
4637
|
componentType,
|
|
4616
|
-
|
|
4638
|
+
parameterIds,
|
|
4617
4639
|
strict
|
|
4618
4640
|
);
|
|
4619
4641
|
const totalCount = count + overridesCount;
|
|
@@ -4633,11 +4655,11 @@ var ParameterRemoverService = class {
|
|
|
4633
4655
|
}
|
|
4634
4656
|
return { filesModified, instancesUpdated };
|
|
4635
4657
|
}
|
|
4636
|
-
removeParameterFromTree(node, componentType,
|
|
4658
|
+
removeParameterFromTree(node, componentType, parameterIds, strict) {
|
|
4637
4659
|
let count = 0;
|
|
4638
4660
|
if (this.compareIds(node.type, componentType, strict) && node.parameters) {
|
|
4639
|
-
const removed = this.
|
|
4640
|
-
if (removed) {
|
|
4661
|
+
const removed = this.removeKeysFromMap(node.parameters, parameterIds, strict);
|
|
4662
|
+
if (removed > 0) {
|
|
4641
4663
|
count++;
|
|
4642
4664
|
}
|
|
4643
4665
|
}
|
|
@@ -4645,13 +4667,13 @@ var ParameterRemoverService = class {
|
|
|
4645
4667
|
for (const slotInstances of Object.values(node.slots)) {
|
|
4646
4668
|
if (!Array.isArray(slotInstances)) continue;
|
|
4647
4669
|
for (const instance of slotInstances) {
|
|
4648
|
-
count += this.removeParameterFromTree(instance, componentType,
|
|
4670
|
+
count += this.removeParameterFromTree(instance, componentType, parameterIds, strict);
|
|
4649
4671
|
}
|
|
4650
4672
|
}
|
|
4651
4673
|
}
|
|
4652
4674
|
return count;
|
|
4653
4675
|
}
|
|
4654
|
-
removeParameterFromOverrides(composition, componentType,
|
|
4676
|
+
removeParameterFromOverrides(composition, componentType, parameterIds, strict) {
|
|
4655
4677
|
if (!composition.composition._overrides) {
|
|
4656
4678
|
return 0;
|
|
4657
4679
|
}
|
|
@@ -4660,8 +4682,8 @@ var ParameterRemoverService = class {
|
|
|
4660
4682
|
const rootId = composition.composition._id;
|
|
4661
4683
|
const rootOverrides = composition.composition._overrides[rootId];
|
|
4662
4684
|
if (rootOverrides?.parameters) {
|
|
4663
|
-
const removed = this.
|
|
4664
|
-
if (removed) {
|
|
4685
|
+
const removed = this.removeKeysFromMap(rootOverrides.parameters, parameterIds, strict);
|
|
4686
|
+
if (removed > 0) {
|
|
4665
4687
|
count++;
|
|
4666
4688
|
}
|
|
4667
4689
|
}
|
|
@@ -4671,14 +4693,14 @@ var ParameterRemoverService = class {
|
|
|
4671
4693
|
composition.composition,
|
|
4672
4694
|
composition.composition._overrides,
|
|
4673
4695
|
componentType,
|
|
4674
|
-
|
|
4696
|
+
parameterIds,
|
|
4675
4697
|
strict,
|
|
4676
4698
|
counter
|
|
4677
4699
|
);
|
|
4678
4700
|
count += counter.count;
|
|
4679
4701
|
return count;
|
|
4680
4702
|
}
|
|
4681
|
-
removeOverridesForMatchingInstances(node, overrides, componentType,
|
|
4703
|
+
removeOverridesForMatchingInstances(node, overrides, componentType, parameterIds, strict, counter) {
|
|
4682
4704
|
if (node.slots) {
|
|
4683
4705
|
for (const slotInstances of Object.values(node.slots)) {
|
|
4684
4706
|
if (!Array.isArray(slotInstances)) continue;
|
|
@@ -4686,8 +4708,8 @@ var ParameterRemoverService = class {
|
|
|
4686
4708
|
if (this.compareIds(instance.type, componentType, strict) && instance._id) {
|
|
4687
4709
|
const instanceOverrides = overrides[instance._id];
|
|
4688
4710
|
if (instanceOverrides?.parameters) {
|
|
4689
|
-
const removed = this.
|
|
4690
|
-
if (removed) {
|
|
4711
|
+
const removed = this.removeKeysFromMap(instanceOverrides.parameters, parameterIds, strict);
|
|
4712
|
+
if (removed > 0) {
|
|
4691
4713
|
counter.count++;
|
|
4692
4714
|
}
|
|
4693
4715
|
}
|
|
@@ -4696,7 +4718,7 @@ var ParameterRemoverService = class {
|
|
|
4696
4718
|
instance,
|
|
4697
4719
|
overrides,
|
|
4698
4720
|
componentType,
|
|
4699
|
-
|
|
4721
|
+
parameterIds,
|
|
4700
4722
|
strict,
|
|
4701
4723
|
counter
|
|
4702
4724
|
);
|
|
@@ -4704,15 +4726,16 @@ var ParameterRemoverService = class {
|
|
|
4704
4726
|
}
|
|
4705
4727
|
}
|
|
4706
4728
|
}
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4729
|
+
removeKeysFromMap(map, keys, strict) {
|
|
4730
|
+
let removed = 0;
|
|
4731
|
+
for (const key of keys) {
|
|
4732
|
+
const matchingKey = Object.keys(map).find((k) => this.compareIds(k, key, strict));
|
|
4733
|
+
if (matchingKey) {
|
|
4734
|
+
delete map[matchingKey];
|
|
4735
|
+
removed++;
|
|
4736
|
+
}
|
|
4713
4737
|
}
|
|
4714
|
-
|
|
4715
|
-
return true;
|
|
4738
|
+
return removed;
|
|
4716
4739
|
}
|
|
4717
4740
|
};
|
|
4718
4741
|
|
|
@@ -4743,20 +4766,31 @@ function createRemoveParameterCommand() {
|
|
|
4743
4766
|
const fileSystem = new FileSystemService();
|
|
4744
4767
|
const componentService = new ComponentService(fileSystem);
|
|
4745
4768
|
const remover = new ParameterRemoverService(fileSystem, componentService, logger);
|
|
4769
|
+
const componentTypes = options.componentType.split("|").map((t) => t.trim()).filter(Boolean);
|
|
4770
|
+
const aggregate = {
|
|
4771
|
+
compositionsModified: 0,
|
|
4772
|
+
compositionPatternsModified: 0,
|
|
4773
|
+
componentPatternsModified: 0
|
|
4774
|
+
};
|
|
4746
4775
|
try {
|
|
4747
|
-
const
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4776
|
+
for (const componentType of componentTypes) {
|
|
4777
|
+
const result = await remover.remove({
|
|
4778
|
+
rootDir: options.rootDir,
|
|
4779
|
+
componentsDir: options.componentsDir,
|
|
4780
|
+
compositionsDir: options.compositionsDir,
|
|
4781
|
+
compositionPatternsDir: options.compositionPatternsDir,
|
|
4782
|
+
componentPatternsDir: options.componentPatternsDir,
|
|
4783
|
+
componentType,
|
|
4784
|
+
parameterId: options.parameterId,
|
|
4785
|
+
whatIf: options.whatIf ?? false,
|
|
4786
|
+
strict: options.strict ?? false
|
|
4787
|
+
});
|
|
4788
|
+
aggregate.compositionsModified += result.compositionsModified;
|
|
4789
|
+
aggregate.compositionPatternsModified += result.compositionPatternsModified;
|
|
4790
|
+
aggregate.componentPatternsModified += result.componentPatternsModified;
|
|
4791
|
+
}
|
|
4758
4792
|
logger.success(
|
|
4759
|
-
`Removed parameter: ${
|
|
4793
|
+
`Removed parameter: ${aggregate.compositionsModified} composition(s), ${aggregate.compositionPatternsModified} composition pattern(s), ${aggregate.componentPatternsModified} component pattern(s) updated`
|
|
4760
4794
|
);
|
|
4761
4795
|
} catch (error) {
|
|
4762
4796
|
if (error instanceof TransformError) {
|
|
@@ -4774,8 +4808,9 @@ import { Command as Command12 } from "commander";
|
|
|
4774
4808
|
|
|
4775
4809
|
// src/core/services/field-remover.service.ts
|
|
4776
4810
|
var FieldRemoverService = class {
|
|
4777
|
-
constructor(fileSystem, logger) {
|
|
4811
|
+
constructor(fileSystem, componentService, logger) {
|
|
4778
4812
|
this.fileSystem = fileSystem;
|
|
4813
|
+
this.componentService = componentService;
|
|
4779
4814
|
this.logger = logger;
|
|
4780
4815
|
}
|
|
4781
4816
|
compareIds(id1, id2, strict) {
|
|
@@ -4787,6 +4822,7 @@ var FieldRemoverService = class {
|
|
|
4787
4822
|
async remove(options) {
|
|
4788
4823
|
const {
|
|
4789
4824
|
rootDir,
|
|
4825
|
+
componentsDir,
|
|
4790
4826
|
compositionsDir,
|
|
4791
4827
|
compositionPatternsDir,
|
|
4792
4828
|
componentPatternsDir,
|
|
@@ -4795,14 +4831,29 @@ var FieldRemoverService = class {
|
|
|
4795
4831
|
whatIf,
|
|
4796
4832
|
strict
|
|
4797
4833
|
} = options;
|
|
4834
|
+
const findOptions = { strict };
|
|
4835
|
+
const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);
|
|
4798
4836
|
const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);
|
|
4799
4837
|
const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);
|
|
4800
4838
|
const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);
|
|
4839
|
+
let allIdsToRemove = [parameterId];
|
|
4840
|
+
try {
|
|
4841
|
+
const { component } = await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);
|
|
4842
|
+
const resolved = this.componentService.resolveRemoveIds(component, parameterId, findOptions);
|
|
4843
|
+
if (resolved.length > 0) {
|
|
4844
|
+
allIdsToRemove = resolved;
|
|
4845
|
+
}
|
|
4846
|
+
} catch {
|
|
4847
|
+
}
|
|
4848
|
+
const childIds = allIdsToRemove.filter((id) => id.toLowerCase() !== parameterId.toLowerCase());
|
|
4849
|
+
if (childIds.length > 0) {
|
|
4850
|
+
this.logger.info(`Cascade-removing ${childIds.length} child field(s) [${childIds.join(", ")}] along with "${parameterId}"`);
|
|
4851
|
+
}
|
|
4801
4852
|
this.logger.info(`Removing field "${parameterId}" from instances of ${componentType}`);
|
|
4802
4853
|
const compositionsResult = await this.removeFieldInDirectory(
|
|
4803
4854
|
fullCompositionsDir,
|
|
4804
4855
|
componentType,
|
|
4805
|
-
|
|
4856
|
+
allIdsToRemove,
|
|
4806
4857
|
whatIf,
|
|
4807
4858
|
strict,
|
|
4808
4859
|
"composition"
|
|
@@ -4810,7 +4861,7 @@ var FieldRemoverService = class {
|
|
|
4810
4861
|
const compositionPatternsResult = await this.removeFieldInDirectory(
|
|
4811
4862
|
fullCompositionPatternsDir,
|
|
4812
4863
|
componentType,
|
|
4813
|
-
|
|
4864
|
+
allIdsToRemove,
|
|
4814
4865
|
whatIf,
|
|
4815
4866
|
strict,
|
|
4816
4867
|
"compositionPattern"
|
|
@@ -4818,7 +4869,7 @@ var FieldRemoverService = class {
|
|
|
4818
4869
|
const componentPatternsResult = await this.removeFieldInDirectory(
|
|
4819
4870
|
fullComponentPatternsDir,
|
|
4820
4871
|
componentType,
|
|
4821
|
-
|
|
4872
|
+
allIdsToRemove,
|
|
4822
4873
|
whatIf,
|
|
4823
4874
|
strict,
|
|
4824
4875
|
"componentPattern"
|
|
@@ -4836,7 +4887,7 @@ var FieldRemoverService = class {
|
|
|
4836
4887
|
instancesUpdated: totalInstances
|
|
4837
4888
|
};
|
|
4838
4889
|
}
|
|
4839
|
-
async removeFieldInDirectory(directory, componentType,
|
|
4890
|
+
async removeFieldInDirectory(directory, componentType, parameterIds, whatIf, strict, label) {
|
|
4840
4891
|
let files;
|
|
4841
4892
|
try {
|
|
4842
4893
|
files = await this.fileSystem.findFiles(directory, "**/*.{json,yaml,yml}");
|
|
@@ -4861,13 +4912,13 @@ var FieldRemoverService = class {
|
|
|
4861
4912
|
const treeCount = this.removeFieldFromTree(
|
|
4862
4913
|
composition.composition,
|
|
4863
4914
|
componentType,
|
|
4864
|
-
|
|
4915
|
+
parameterIds,
|
|
4865
4916
|
strict
|
|
4866
4917
|
);
|
|
4867
4918
|
const overridesCount = this.removeFieldFromOverrides(
|
|
4868
4919
|
composition,
|
|
4869
4920
|
componentType,
|
|
4870
|
-
|
|
4921
|
+
parameterIds,
|
|
4871
4922
|
strict
|
|
4872
4923
|
);
|
|
4873
4924
|
const totalCount = treeCount + overridesCount;
|
|
@@ -4887,11 +4938,11 @@ var FieldRemoverService = class {
|
|
|
4887
4938
|
}
|
|
4888
4939
|
return { filesModified, instancesUpdated };
|
|
4889
4940
|
}
|
|
4890
|
-
removeFieldFromTree(node, componentType,
|
|
4941
|
+
removeFieldFromTree(node, componentType, parameterIds, strict) {
|
|
4891
4942
|
let count = 0;
|
|
4892
4943
|
if (this.compareIds(node.type, componentType, strict) && node.parameters) {
|
|
4893
|
-
const removed = this.
|
|
4894
|
-
if (removed) {
|
|
4944
|
+
const removed = this.removeKeysFromMap(node.parameters, parameterIds, strict);
|
|
4945
|
+
if (removed > 0) {
|
|
4895
4946
|
count++;
|
|
4896
4947
|
}
|
|
4897
4948
|
}
|
|
@@ -4899,13 +4950,13 @@ var FieldRemoverService = class {
|
|
|
4899
4950
|
for (const slotInstances of Object.values(node.slots)) {
|
|
4900
4951
|
if (!Array.isArray(slotInstances)) continue;
|
|
4901
4952
|
for (const instance of slotInstances) {
|
|
4902
|
-
count += this.removeFieldFromTree(instance, componentType,
|
|
4953
|
+
count += this.removeFieldFromTree(instance, componentType, parameterIds, strict);
|
|
4903
4954
|
}
|
|
4904
4955
|
}
|
|
4905
4956
|
}
|
|
4906
4957
|
return count;
|
|
4907
4958
|
}
|
|
4908
|
-
removeFieldFromOverrides(composition, componentType,
|
|
4959
|
+
removeFieldFromOverrides(composition, componentType, parameterIds, strict) {
|
|
4909
4960
|
if (!composition.composition._overrides) {
|
|
4910
4961
|
return 0;
|
|
4911
4962
|
}
|
|
@@ -4914,8 +4965,8 @@ var FieldRemoverService = class {
|
|
|
4914
4965
|
const rootId = composition.composition._id;
|
|
4915
4966
|
const rootOverrides = composition.composition._overrides[rootId];
|
|
4916
4967
|
if (rootOverrides?.parameters) {
|
|
4917
|
-
const removed = this.
|
|
4918
|
-
if (removed) {
|
|
4968
|
+
const removed = this.removeKeysFromMap(rootOverrides.parameters, parameterIds, strict);
|
|
4969
|
+
if (removed > 0) {
|
|
4919
4970
|
count++;
|
|
4920
4971
|
}
|
|
4921
4972
|
}
|
|
@@ -4924,12 +4975,12 @@ var FieldRemoverService = class {
|
|
|
4924
4975
|
composition.composition,
|
|
4925
4976
|
composition.composition._overrides,
|
|
4926
4977
|
componentType,
|
|
4927
|
-
|
|
4978
|
+
parameterIds,
|
|
4928
4979
|
strict
|
|
4929
4980
|
);
|
|
4930
4981
|
return count;
|
|
4931
4982
|
}
|
|
4932
|
-
removeOverridesForMatchingInstances(node, overrides, componentType,
|
|
4983
|
+
removeOverridesForMatchingInstances(node, overrides, componentType, parameterIds, strict) {
|
|
4933
4984
|
let count = 0;
|
|
4934
4985
|
if (node.slots) {
|
|
4935
4986
|
for (const slotInstances of Object.values(node.slots)) {
|
|
@@ -4938,8 +4989,8 @@ var FieldRemoverService = class {
|
|
|
4938
4989
|
if (this.compareIds(instance.type, componentType, strict) && instance._id) {
|
|
4939
4990
|
const instanceOverrides = overrides[instance._id];
|
|
4940
4991
|
if (instanceOverrides?.parameters) {
|
|
4941
|
-
const removed = this.
|
|
4942
|
-
if (removed) {
|
|
4992
|
+
const removed = this.removeKeysFromMap(instanceOverrides.parameters, parameterIds, strict);
|
|
4993
|
+
if (removed > 0) {
|
|
4943
4994
|
count++;
|
|
4944
4995
|
}
|
|
4945
4996
|
}
|
|
@@ -4948,7 +4999,7 @@ var FieldRemoverService = class {
|
|
|
4948
4999
|
instance,
|
|
4949
5000
|
overrides,
|
|
4950
5001
|
componentType,
|
|
4951
|
-
|
|
5002
|
+
parameterIds,
|
|
4952
5003
|
strict
|
|
4953
5004
|
);
|
|
4954
5005
|
}
|
|
@@ -4956,15 +5007,16 @@ var FieldRemoverService = class {
|
|
|
4956
5007
|
}
|
|
4957
5008
|
return count;
|
|
4958
5009
|
}
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
5010
|
+
removeKeysFromMap(map, keys, strict) {
|
|
5011
|
+
let removed = 0;
|
|
5012
|
+
for (const key of keys) {
|
|
5013
|
+
const matchingKey = Object.keys(map).find((k) => this.compareIds(k, key, strict));
|
|
5014
|
+
if (matchingKey) {
|
|
5015
|
+
delete map[matchingKey];
|
|
5016
|
+
removed++;
|
|
5017
|
+
}
|
|
4965
5018
|
}
|
|
4966
|
-
|
|
4967
|
-
return true;
|
|
5019
|
+
return removed;
|
|
4968
5020
|
}
|
|
4969
5021
|
};
|
|
4970
5022
|
|
|
@@ -4993,20 +5045,33 @@ function createRemoveFieldCommand() {
|
|
|
4993
5045
|
};
|
|
4994
5046
|
const logger = new Logger();
|
|
4995
5047
|
const fileSystem = new FileSystemService();
|
|
4996
|
-
const
|
|
5048
|
+
const componentService = new ComponentService(fileSystem);
|
|
5049
|
+
const remover = new FieldRemoverService(fileSystem, componentService, logger);
|
|
5050
|
+
const componentTypes = options.componentType.split("|").map((t) => t.trim()).filter(Boolean);
|
|
5051
|
+
const aggregate = {
|
|
5052
|
+
compositionsModified: 0,
|
|
5053
|
+
compositionPatternsModified: 0,
|
|
5054
|
+
componentPatternsModified: 0
|
|
5055
|
+
};
|
|
4997
5056
|
try {
|
|
4998
|
-
const
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5057
|
+
for (const componentType of componentTypes) {
|
|
5058
|
+
const result = await remover.remove({
|
|
5059
|
+
rootDir: options.rootDir,
|
|
5060
|
+
componentsDir: options.componentsDir,
|
|
5061
|
+
compositionsDir: options.compositionsDir,
|
|
5062
|
+
compositionPatternsDir: options.compositionPatternsDir,
|
|
5063
|
+
componentPatternsDir: options.componentPatternsDir,
|
|
5064
|
+
componentType,
|
|
5065
|
+
parameterId: options.parameterId,
|
|
5066
|
+
whatIf: options.whatIf ?? false,
|
|
5067
|
+
strict: options.strict ?? false
|
|
5068
|
+
});
|
|
5069
|
+
aggregate.compositionsModified += result.compositionsModified;
|
|
5070
|
+
aggregate.compositionPatternsModified += result.compositionPatternsModified;
|
|
5071
|
+
aggregate.componentPatternsModified += result.componentPatternsModified;
|
|
5072
|
+
}
|
|
5008
5073
|
logger.success(
|
|
5009
|
-
`Removed field: ${
|
|
5074
|
+
`Removed field: ${aggregate.compositionsModified} composition(s), ${aggregate.compositionPatternsModified} composition pattern(s), ${aggregate.componentPatternsModified} component pattern(s) updated`
|
|
5010
5075
|
);
|
|
5011
5076
|
} catch (error) {
|
|
5012
5077
|
if (error instanceof TransformError) {
|
|
@@ -5749,7 +5814,7 @@ function createFlattenBlockFieldCommand() {
|
|
|
5749
5814
|
// package.json
|
|
5750
5815
|
var package_default = {
|
|
5751
5816
|
name: "@uniformdev/transformer",
|
|
5752
|
-
version: "1.1.
|
|
5817
|
+
version: "1.1.33",
|
|
5753
5818
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
5754
5819
|
type: "module",
|
|
5755
5820
|
bin: {
|