Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
* @salesforcecli/metadata-intelligence

# Techical writers will be added as reviewers on markdown changes.
*.md @salesforcecli/cli-docs

# Comment line immediately above ownership line is reserved for related other information. Please be careful while editing.
#ECCN:Open Source
#GUSINFO:Open Source,Open Source Workflow
#GUSINFO:Metadata Intelligence,Metadata Delivery
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ DESCRIPTION
This command currently supports the following metadata types:

- LightningComponentBundle
- FlexiPage
- CustomObject
- LightningTypeBundle

Your org must be eligible for metadata enrichment. Your Salesforce admin can help with that.

Expand Down
4 changes: 0 additions & 4 deletions messages/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

Component not found in project.

# errors.lwc.only

Only Lightning Web Components are currently supported for enrichment.

# errors.lwc.configuration.not.found

The Lightning Web Component configuration file doesn't exist (\*.js-meta.xml).
Expand Down
2 changes: 0 additions & 2 deletions messages/metadata.enrich.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ Even though this command updates only local files in your DX project, you're sti
This command currently supports the following metadata types:

- LightningComponentBundle
- FlexiPage
- CustomObject
- LightningTypeBundle

Your org must be eligible for metadata enrichment. Your Salesforce admin can help with that.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@oclif/table": "^0.5.1",
"@salesforce/core": "^8.24.3",
"@salesforce/kit": "^3.2.4",
"@salesforce/metadata-enrichment": "^0.0.14",
"@salesforce/metadata-enrichment": "^0.0.15",
"@salesforce/sf-plugins-core": "^12",
"@salesforce/source-deploy-retrieve": "^12.31.14"
},
Expand Down
10 changes: 8 additions & 2 deletions src/commands/metadata/enrich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import { MultiStageOutput } from '@oclif/multi-stage-output';
import { Messages, SfProject } from '@salesforce/core';
import { Flags, SfCommand, Ux } from '@salesforce/sf-plugins-core';
import { ComponentSetBuilder } from '@salesforce/source-deploy-retrieve';
import { SourceComponentProcessor, EnrichmentHandler, EnrichmentMetrics, EnrichmentRecords, FileProcessor } from '@salesforce/metadata-enrichment';
import {
SourceComponentProcessor,
EnrichmentHandler,
EnrichmentMetrics,
EnrichmentRecords,
FileProcessor,
} from '@salesforce/metadata-enrichment';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const commandMessages = Messages.loadMessages('@salesforce/plugin-metadata-enrichment', 'metadata.enrich');
Expand Down Expand Up @@ -49,7 +55,7 @@ export default class MetadataEnrich extends SfCommand<EnrichmentMetrics> {

const STAGES_MSO = [
commandMessages.getMessage('stage.setup'),
commandMessages.getMessage('stage.executing'),
commandMessages.getMessage('stage.executing'),
commandMessages.getMessage('stage.updating.files'),
];

Expand Down
36 changes: 27 additions & 9 deletions test/unit/componentProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,55 @@ describe('ComponentProcessor', () => {

it('should return empty set when requested LWC exists in source with xml', () => {
const source = [createSourceComponent('MyCmp', 'LightningComponentBundle', { xml: 'mycmp.js-meta.xml' })];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['LightningComponentBundle:MyCmp'], undefined);
const result = SourceComponentProcessor.getComponentsToSkip(
source,
['LightningComponentBundle:MyCmp'],
undefined
);
expect(result.size).to.equal(0);
});

it('should include requested component when not in source (missing)', () => {
const source = [createSourceComponent('OtherCmp', 'LightningComponentBundle', { xml: 'other.js-meta.xml' })];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['LightningComponentBundle:MissingCmp'], undefined);
const result = SourceComponentProcessor.getComponentsToSkip(
source,
['LightningComponentBundle:MissingCmp'],
undefined
);
expect(result.size).to.be.greaterThan(0);
const skipNames = Array.from(result).map((r) => r.componentName);
expect(skipNames).to.include('MissingCmp');
});

it('should include non-LWC component in skip set', () => {
const source = [createSourceComponent('MyClass', 'ApexClass')];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['ApexClass:MyClass'], undefined);
it('should include requested CustomObject in skip set when missing from source', () => {
const source = [createSourceComponent('OtherObject', 'CustomObject')];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['CustomObject:MissingObject'], undefined);
expect(result.size).to.be.greaterThan(0);
const skipEntries = Array.from(result);
expect(skipEntries.some((r) => r.componentName === 'MyClass' && r.componentType.name === 'ApexClass')).to.be.true;
const skipNames = Array.from(result).map((r) => r.componentName);
expect(skipNames).to.include('MissingObject');
});

it('should include LWC without xml in skip set', () => {
const source = [createSourceComponent('NoMetaCmp', 'LightningComponentBundle')];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['LightningComponentBundle:NoMetaCmp'], undefined);
const result = SourceComponentProcessor.getComponentsToSkip(
source,
['LightningComponentBundle:NoMetaCmp'],
undefined
);
expect(result.size).to.be.greaterThan(0);
expect(Array.from(result).some((r) => r.componentName === 'NoMetaCmp')).to.be.true;
});

it('should not include wildcard metadata entries in requested (no missing from wildcard)', () => {
it('should not parse wildcard as an entry for LWC components to skip', () => {
const source: SourceComponent[] = [];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['LightningComponentBundle:*'], undefined);
expect(result.size).to.equal(0);
});

it('should not parse wildcard as an entry for CustomObject components to skip', () => {
const source: SourceComponent[] = [];
const result = SourceComponentProcessor.getComponentsToSkip(source, ['CustomObject:*'], undefined);
expect(result.size).to.equal(0);
});
});
});
Loading