Skip to content

Commit b03eea5

Browse files
authored
Merge pull request #566 from hknokh/master
feat: Different target dirs for each ObjectSet
2 parents 8cf218e + 6aabbc5 commit b03eea5

5 files changed

Lines changed: 32 additions & 16 deletions

File tree

messages/resources.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"csvFilesWereUpdated": "Amount of updated source CSV files: %s.",
121121
"validationCsvFileCompleted": "Processing the source CSV files has been completed.",
122122
"unableToDeleteTargetDirectory" : "Unable to clean-up the target directory: '%s'. It's probably locked by another application.",
123-
"unableToDeleteSourceDirectory": "Unable to clean-up the souce directory: '%s'. It's probably locked by another application.",
123+
"unableToDeleteSourceDirectory": "Unable to clean-up the source directory: '%s'. It's probably locked by another application.",
124124
"unableToDeleteCacheDirectory": "Unable to clean-up the cache directory: '%s'. It's probably locked by another application.",
125125
"canModifyPrompt": "NOTE! The Plugin has detected that you are about to modify the Production org.\nTo confirm that you really want to modify this org, please type: ",
126126

src/modules/commands_processors/runCommand.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,21 @@ export class RunCommand {
118118
}
119119

120120
try {
121+
121122
let jsonObject = JSON.parse(json);
123+
122124
jsonObject.objects = jsonObject.objects || [];
123125
jsonObject.objectSets = jsonObject.objectSets || [];
126+
124127
if (jsonObject.objects.length) {
125128
jsonObject.objectSets.unshift(new ScriptObjectSet(jsonObject.objects));
126129
}
130+
127131
this.workingJson = JSON.stringify(jsonObject);
128132
jsonObject.objects = [];
129133
this.script = plainToClass(models.Script, jsonObject);
130-
this.setupGlobalParameters();
134+
135+
this._setupGlobalScriptParameters();
131136

132137
} catch (ex: any) {
133138
throw new CommandInitializationError(this.logger.getResourceString(RESOURCES.incorrectExportJsonFormat, ex.message));
@@ -137,12 +142,6 @@ export class RunCommand {
137142

138143
}
139144

140-
141-
setupGlobalParameters() {
142-
Common.csvReadFileDelimiter = this.script.csvReadFileDelimiter;
143-
Common.csvWriteFileDelimiter = this.script.csvWriteFileDelimiter;
144-
}
145-
146145

147146
/**
148147
* Setup the Command
@@ -269,6 +268,13 @@ export class RunCommand {
269268
this.script = plainToClass(models.Script, JSON.parse(this.workingJson));
270269
this.job = undefined;
271270
this.script.objects = this.script.objectSets[objectSetIndex].objects || this.script.objects;
271+
this.script.objectSetIndex = objectSetIndex;
272+
}
273+
274+
275+
private _setupGlobalScriptParameters() {
276+
Common.csvReadFileDelimiter = this.script.csvReadFileDelimiter;
277+
Common.csvWriteFileDelimiter = this.script.csvWriteFileDelimiter;
272278
}
273279

274280
}

src/modules/components/common_components/common.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,13 +1269,13 @@ export class Common {
12691269
* Remove folder with all files
12701270
*
12711271
* @static
1272-
* @param {string} path Path to the folder to remove
1272+
* @param {string} pth Path to the folder to remove
12731273
* @memberof Common
12741274
*/
1275-
public static deleteFolderRecursive(path: string, throwIOErrors?: boolean, removeSelfDirectory: boolean = true) {
1276-
if (fs.existsSync(path)) {
1277-
fs.readdirSync(path).forEach(file => {
1278-
var curPath = path + "/" + file;
1275+
public static deleteFolderRecursive(pth: string, throwIOErrors?: boolean, removeSelfDirectory: boolean = true) {
1276+
if (fs.existsSync(pth)) {
1277+
fs.readdirSync(pth).forEach(file => {
1278+
var curPath = path.join(pth, file);
12791279
if (fs.lstatSync(curPath).isDirectory()) {
12801280
// Recursive call
12811281
this.deleteFolderRecursive(curPath, throwIOErrors);
@@ -1292,7 +1292,7 @@ export class Common {
12921292
});
12931293
try {
12941294
if (removeSelfDirectory) {
1295-
fs.rmdirSync(path);
1295+
fs.rmdirSync(pth);
12961296
}
12971297
} catch (ex) {
12981298
if (throwIOErrors) {

src/modules/components/common_components/statics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const CONSTANTS = {
5252

5353
CSV_SOURCE_SUB_DIRECTORY: "source",
5454
CSV_TARGET_SUB_DIRECTORY: "target",
55+
OBJECT_SET_SUBDIRECTORY_PREFIX : '/object-set-',
5556
BINARY_CACHE_SUB_DIRECTORY: "binary_cache",
5657
SOURCE_RECORDS_CACHE_SUB_DIRECTORY: "source_records_cache",
5758
CSV_SOURCE_FILE_SUFFIX: "_source",

src/modules/models/script_models/script.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export default class Script implements IAppScript, ISfdmuRunScript {
132132
addonManager: SfdmuRunAddonManager;
133133
runInfo: ICommandRunInfo;
134134
canModify: string;
135+
objectSetIndex: number;
135136

136137

137138
// Additional sobject descriptions for sobject which were nbot included into the export.json
@@ -156,7 +157,11 @@ export default class Script implements IAppScript, ISfdmuRunScript {
156157
}
157158

158159
get targetDirectoryPath(): string {
159-
return path.join(this.basePath, CONSTANTS.CSV_TARGET_SUB_DIRECTORY);
160+
return path.join(
161+
this.basePath,
162+
CONSTANTS.CSV_TARGET_SUB_DIRECTORY +
163+
(!this.objectSetIndex ? '' : `${CONSTANTS.OBJECT_SET_SUBDIRECTORY_PREFIX}${this.objectSetIndex}`)
164+
);
160165
}
161166

162167
get targetDirectory(): string {
@@ -167,7 +172,11 @@ export default class Script implements IAppScript, ISfdmuRunScript {
167172
}
168173

169174
get sourceDirectoryPath(): string {
170-
return path.join(this.basePath, CONSTANTS.CSV_SOURCE_SUB_DIRECTORY);
175+
return path.join(
176+
this.basePath,
177+
CONSTANTS.CSV_SOURCE_SUB_DIRECTORY +
178+
(!this.objectSetIndex ? '' : `${CONSTANTS.OBJECT_SET_SUBDIRECTORY_PREFIX}${this.objectSetIndex}`)
179+
);
171180
}
172181

173182
get sourceDirectory(): string {

0 commit comments

Comments
 (0)