Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
fix: Issue #713 (#715) Avoid removing userlicence when running reconc…
Browse files Browse the repository at this point in the history
…ile with source only flag

* fix: Issue #713
Avoid removing userlicence when running reconcile with source only flag
  • Loading branch information
genoud committed Aug 23, 2022
1 parent 12dd59c commit 308f702
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/impl/source/profiles/profileComponentReconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Profile, { ProfileFieldLevelSecurity } from '../../metadata/schema';
export default class ProfileComponentReconciler {
//rivate profileRetriever;

public constructor(private conn: Connection) {}
public constructor(private conn: Connection, private isSourceOnly: boolean) {}

public async reconcileProfileComponents(profileObj: Profile, profileName: string): Promise<Profile> {
SFPLogger.log(`Reconciling App: ${profileName}`, LoggerLevel.DEBUG);
Expand Down Expand Up @@ -90,7 +90,7 @@ export default class ProfileComponentReconciler {
}

private async cleanupUserLicenses(profileObj: Profile) {
if (!MetadataFiles.sourceOnly) {
if (!this.isSourceOnly) {
//Manage licences
let userLicenseRetriever = new MetadataRetriever(this.conn, 'UserLicense');
const isSupportedLicence = await userLicenseRetriever.isComponentExistsInTheOrg(profileObj.userLicense);
Expand Down
7 changes: 6 additions & 1 deletion src/impl/source/profiles/profileReconcile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FileUtils from '../../../utils/fileutils';
import * as fs from 'fs-extra';
import { Worker } from 'worker_threads';
import SFPLogger, {LoggerLevel} from '@dxatscale/sfp-logger';
import MetadataFiles from '../../../impl/metadata/metadataFiles';

export default class ProfileReconcile extends ProfileActions {
public async reconcile(srcFolders: string[], profileList: string[], destFolder: string): Promise<string[]> {
Expand Down Expand Up @@ -72,6 +73,7 @@ export default class ProfileReconcile extends ProfileActions {
targetOrg: this.org?.getUsername(), //Org can be null during source only reconcile
loglevel: SFPLogger.logLevel,
isJsonFormatEnabled: Sfpowerkit.isJsonFormatEnabled,
isSourceOnly: MetadataFiles.sourceOnly,
path: reconcileWorkerFile,
},
});
Expand All @@ -86,7 +88,10 @@ export default class ProfileReconcile extends ProfileActions {
result.push(...data);
});

worker.on('error', reject);
worker.on('error', (err)=> {
Sfpowerkit.log(`Error while running worker ${err}`, LoggerLevel.ERROR);
reject(err);
});
worker.on('exit', (code) => {
finishedWorkerCount++;
if (code !== 0)
Expand Down
6 changes: 3 additions & 3 deletions src/impl/source/profiles/reconcileWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ProfileSourceFile } from './profileActions';

export default class ReconcileWorker {
private conn: Connection;
public constructor(private targetOrg: string) {}
public constructor(private targetOrg: string, private isSourceOnly: boolean) {}

public async reconcile(profilesToReconcile: ProfileSourceFile[], destFolder) {
//Init Cache for each worker thread from file system
Expand Down Expand Up @@ -75,7 +75,7 @@ export default class ReconcileWorker {
return profileObj;
})
.then((profileObj) => {
return new ProfileComponentReconciler(this.conn).reconcileProfileComponents(
return new ProfileComponentReconciler(this.conn, this.isSourceOnly).reconcileProfileComponents(
profileObj,
profileComponent.name
);
Expand Down Expand Up @@ -105,7 +105,7 @@ export default class ReconcileWorker {

Sfpowerkit.setLogLevel(workerData.loglevel, workerData.isJsonFormatEnabled);

let reconcileWorker = new ReconcileWorker(workerData.targetOrg);
let reconcileWorker = new ReconcileWorker(workerData.targetOrg, workerData.isSourceOnly);
reconcileWorker.reconcile(workerData.profileChunk, workerData.destFolder).then((result) => {
parentPort.postMessage(result);
});

0 comments on commit 308f702

Please sign in to comment.