Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevents pre and post deployer error on vbt datapacks with xmls #116

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/core/package/SfpPackageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@

sfpPackage.isTriggerAllTests = this.isAllTestsToBeTriggered(sfpPackage, logger);

const isDataPackage = sfpPackage.packageType == PackageType.Data;

Check warning on line 123 in src/core/package/SfpPackageBuilder.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/package/SfpPackageBuilder.ts#L123

The two values in this comparison do not have a shared enum type.
//Load component Set
let componentSet = ComponentSet.fromSource(
let componentSet = isDataPackage? undefined:ComponentSet.fromSource(

Check failure on line 125 in src/core/package/SfpPackageBuilder.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/package/SfpPackageBuilder.ts#L125

Unsafe assignment of an error typed value.

Check failure on line 125 in src/core/package/SfpPackageBuilder.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/package/SfpPackageBuilder.ts#L125

Unsafe call of an `error` type typed value.

Check failure on line 125 in src/core/package/SfpPackageBuilder.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/package/SfpPackageBuilder.ts#L125

Unsafe member access .fromSource on an `error` typed value.
path.resolve(sfpPackage.workingDirectory, sfpPackage.projectDirectory, sfpPackage.packageDirectory)
);

//Run through all analyzers
let analyzers = AnalyzerRegistry.getAnalyzers();
for (const analyzer of analyzers) {
if (analyzer.isEnabled(sfpPackage, logger)) sfpPackage = await analyzer.analyze(sfpPackage,componentSet, logger);
if (analyzer.isEnabled(sfpPackage, logger)) sfpPackage = await analyzer.analyze(sfpPackage, logger, componentSet);

Check failure on line 132 in src/core/package/SfpPackageBuilder.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/package/SfpPackageBuilder.ts#L132

Expected non-Promise value in a boolean conditional.
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/package/analyser/FHTAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class FHTAnalyser implements PackageAnalyzer {



public async analyze(sfpPackage: SfpPackage, componentSet:ComponentSet, logger:Logger): Promise<SfpPackage> {
public async analyze(sfpPackage: SfpPackage, logger: Logger, componentSet: ComponentSet): Promise<SfpPackage> {
try {

let fhtFields: { [key: string]: Array<string> } = {};
Expand Down
2 changes: 1 addition & 1 deletion src/core/package/analyser/FTAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class FTAnalyser implements PackageAnalyzer {
return "Feed Tracking Analyzer";
}

public async analyze(sfpPackage: SfpPackage, componentSet:ComponentSet, logger:Logger): Promise<SfpPackage> {
public async analyze(sfpPackage: SfpPackage, logger: Logger, componentSet: ComponentSet): Promise<SfpPackage> {
try {

let ftFields: { [key: string]: Array<string> } = {};
Expand Down
2 changes: 1 addition & 1 deletion src/core/package/analyser/PackageAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SfpPackage from "../SfpPackage";
export interface PackageAnalyzer
{
getName();
analyze(sfpPackage: SfpPackage,componentSet:ComponentSet,logger:Logger): Promise<SfpPackage>
analyze(sfpPackage: SfpPackage, logger: Logger, componentSet?: ComponentSet): Promise<SfpPackage>
isEnabled(sfpPackage: SfpPackage,logger:Logger): Promise<boolean>


Expand Down
2 changes: 1 addition & 1 deletion src/core/package/analyser/PicklistAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class PicklistAnalyzer implements PackageAnalyzer {



public async analyze(sfpPackage: SfpPackage, componentSet:ComponentSet, logger:Logger): Promise<SfpPackage> {
public async analyze(sfpPackage: SfpPackage, logger: Logger, componentSet: ComponentSet): Promise<SfpPackage> {
try {
let sourceComponents = componentSet.getSourceComponents().toArray();
let components = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
getDeploymentOptions( target_org: string, waitTime: string, apiVersion: string):Promise<DeploymentOptions>
getName():string
execute(sfpPackage: SfpPackage,
componentSet: ComponentSet,
sfpOrg:SFPOrg,
logger: Logger,
deploymentContext:DeploymentContext
deploymentContext:DeploymentContext,

Check failure on line 24 in src/core/package/deploymentCustomizers/DeploymentCustomizer.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/package/deploymentCustomizers/DeploymentCustomizer.ts#L24

'deploymentContext' is defined but never used.
componentSet?: ComponentSet,
):Promise<DeploySourceResult>
}
4 changes: 2 additions & 2 deletions src/core/package/deploymentCustomizers/FlowActivator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const Table = require('cli-table');
export default class FlowActivator implements DeploymentCustomizer {
async execute(
sfpPackage: SfpPackage,
componentSet: ComponentSet,
sfpOrg: SFPOrg,
logger: Logger,
deploymentContext: DeploymentContext
deploymentContext: DeploymentContext,
componentSet: ComponentSet
): Promise<DeploySourceResult> {
let sourceComponents = componentSet.getSourceComponents().toArray();
let masterLabelsOfAllFlowsInPackage = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export abstract class MetdataDeploymentCustomizer implements DeploymentCustomize


async execute(sfpPackage: SfpPackage,
componentSet: ComponentSet,
sfpOrg:SFPOrg,
logger: Logger,
deploymentContext:DeploymentContext
deploymentContext:DeploymentContext,
componentSet: ComponentSet
):Promise<DeploySourceResult>
{
if (await this.isEnabled(sfpPackage, sfpOrg.getConnection(), logger)) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/package/deploymentCustomizers/PicklistEnabler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default class PicklistEnabler implements DeploymentCustomizer {

async execute(
sfpPackage: SfpPackage,
componentSet: ComponentSet,
sfpOrg: SFPOrg,
logger: Logger,
deploymentContext: DeploymentContext
deploymentContext: DeploymentContext,
componentSet?: ComponentSet
): Promise<DeploySourceResult> {
try {
let sourceComponents = componentSet.getSourceComponents().toArray();
Expand Down
16 changes: 9 additions & 7 deletions src/core/package/packageInstallers/InstallPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ export abstract class InstallPackage {
private async executePostDeployers() {
SFPLogger.log(`Executing Post Deployers`, LoggerLevel.INFO, this.logger);

const isDataPackage = this.sfpPackage.packageType == PackageType.Data;
//Gather componentSet
let componentSet = ComponentSet.fromSource(
let componentSet = isDataPackage? undefined:ComponentSet.fromSource(
path.join(this.sfpPackage.projectDirectory, this.sfpPackage.packageDirectory)
);

Expand All @@ -325,10 +326,10 @@ export abstract class InstallPackage {

await postDeployer.execute(
this.sfpPackage,
componentSet,
this.sfpOrg,
this.logger,
{apiVersion:this.options.apiVersion,waitTime:this.options.waitTime}
{apiVersion:this.options.apiVersion,waitTime:this.options.waitTime},
componentSet
);

} else {
Expand Down Expand Up @@ -356,8 +357,9 @@ export abstract class InstallPackage {
private async executePreDeployers() {
SFPLogger.log(`Executing Pre Deployers`, LoggerLevel.INFO, this.logger);

const isDataPackage = this.sfpPackage.packageType == PackageType.Data;
//Gather componentSet
let componentSet = ComponentSet.fromSource(
let componentSet = isDataPackage? undefined : ComponentSet.fromSource(
path.join(this.sfpPackage.projectDirectory, this.sfpPackage.packageDirectory)
);

Expand All @@ -366,7 +368,7 @@ export abstract class InstallPackage {
if(await analyzer.isEnabled(this.sfpPackage, this.logger))
{
SFPLogger.log(`Executing ${COLOR_KEY_MESSAGE(analyzer.getName())}`, LoggerLevel.INFO, this.logger);
this.sfpPackage = await analyzer.analyze(this.sfpPackage,componentSet, this.logger);
this.sfpPackage = await analyzer.analyze(this.sfpPackage, this.logger, componentSet);
}
else
{
Expand All @@ -385,10 +387,10 @@ export abstract class InstallPackage {

await preDeployer.execute(
this.sfpPackage,
componentSet,
this.sfpOrg,
this.logger,
{apiVersion:this.options.apiVersion,waitTime:this.options.waitTime}
{apiVersion:this.options.apiVersion,waitTime:this.options.waitTime},
componentSet
);

} else {
Expand Down
8 changes: 4 additions & 4 deletions tests/core/package/analysers/FHTAnalyzer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('FHT Analyzer', () => {
return '';
},
};
sfpPackage = await fhtAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await fhtAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFHTFieldFound']).toBe(true);
expect(sfpPackage['fhtFields']).toBeDefined();
let fhtFields = sfpPackage['fhtFields'];
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('FHT Analyzer', () => {
return '';
},
};
sfpPackage = await fhtAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await fhtAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFHTFieldFound']).toBe(true);
expect(sfpPackage['fhtFields']).toBeDefined();
let fhtFields = sfpPackage['fhtFields'];
Expand Down Expand Up @@ -272,7 +272,7 @@ describe('FHT Analyzer', () => {
return '';
},
};
sfpPackage = await fhtAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await fhtAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFHTFieldFound']).toBe(true);
expect(sfpPackage['fhtFields']).toBeDefined();
let fhtFields = sfpPackage['fhtFields'];
Expand Down Expand Up @@ -351,7 +351,7 @@ describe('FHT Analyzer', () => {
return '';
},
};
sfpPackage = await fhtAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await fhtAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFHTFieldFound']).toBe(true);
expect(sfpPackage['fhtFields']).toBeDefined();
let fhtFields = sfpPackage['fhtFields'];
Expand Down
8 changes: 4 additions & 4 deletions tests/core/package/analysers/FTAnalyzer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('FT Analyzer', () => {
return '';
},
};
sfpPackage = await ftAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await ftAnalyzer.analyze(sfpPackage,new VoidLogger(),set);
expect(sfpPackage['isFTFieldFound']).toBe(true);
expect(sfpPackage['ftFields']).toBeDefined();
let ftFields = sfpPackage['ftFields'];
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('FT Analyzer', () => {
return '';
},
};
sfpPackage = await ftAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await ftAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFTFieldFound']).toBe(true);
expect(sfpPackage['ftFields']).toBeDefined();
let ftFields = sfpPackage['ftFields'];
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('FT Analyzer', () => {
return '';
},
};
sfpPackage = await ftAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await ftAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFTFieldFound']).toBe(true);
expect(sfpPackage['ftFields']).toBeDefined();
let ftFields = sfpPackage['ftFields'];
Expand Down Expand Up @@ -354,7 +354,7 @@ describe('FT Analyzer', () => {
return '';
},
};
sfpPackage = await ftAnalyzer.analyze(sfpPackage,set,new VoidLogger());
sfpPackage = await ftAnalyzer.analyze(sfpPackage, new VoidLogger(), set);
expect(sfpPackage['isFTFieldFound']).toBe(true);
expect(sfpPackage['ftFields']).toBeDefined();
let ftFields = sfpPackage['ftFields'];
Expand Down
Loading