@@ -2,7 +2,7 @@ import { join, resolve } from 'path';
22import { existsSync } from 'fs' ;
33import values from 'lodash/values' ;
44import cloneDeep from 'lodash/cloneDeep' ;
5-
5+ import { sanitizePath } from '@contentstack/cli-utilities' ;
66import { PersonalizationAdapter , fsUtil , lookUpAudiences , lookUpEvents } from '../utils' ;
77import { APIConfig , ImportConfig , ExperienceStruct , CreateExperienceInput , LogType } from '../types' ;
88
@@ -46,38 +46,38 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
4646 super ( Object . assign ( config , conf ) ) ;
4747 this . personalizationConfig = this . config . modules . personalization ;
4848 this . experiencesDirPath = resolve (
49- this . config . data ,
50- this . personalizationConfig . dirName ,
51- this . personalizationConfig . experiences . dirName ,
49+ sanitizePath ( this . config . data ) ,
50+ sanitizePath ( this . personalizationConfig . dirName ) ,
51+ sanitizePath ( this . personalizationConfig . experiences . dirName ) ,
5252 ) ;
53- this . experiencesPath = join ( this . experiencesDirPath , this . personalizationConfig . experiences . fileName ) ;
53+ this . experiencesPath = join ( sanitizePath ( this . experiencesDirPath ) , sanitizePath ( this . personalizationConfig . experiences . fileName ) ) ;
5454 this . experienceConfig = this . personalizationConfig . experiences ;
5555 this . audienceConfig = this . personalizationConfig . audiences ;
56- this . mapperDirPath = resolve ( this . config . backupDir , 'mapper' , this . personalizationConfig . dirName ) ;
57- this . expMapperDirPath = resolve ( this . mapperDirPath , this . experienceConfig . dirName ) ;
58- this . experiencesUidMapperPath = resolve ( this . expMapperDirPath , 'uid-mapping.json' ) ;
59- this . cmsVariantGroupPath = resolve ( this . expMapperDirPath , 'cms-variant-groups.json' ) ;
60- this . cmsVariantPath = resolve ( this . expMapperDirPath , 'cms-variants.json' ) ;
61- this . audiencesMapperPath = resolve ( this . mapperDirPath , this . audienceConfig . dirName , 'uid-mapping.json' ) ;
62- this . eventsMapperPath = resolve ( this . mapperDirPath , 'events' , 'uid-mapping.json' ) ;
63- this . failedCmsExpPath = resolve ( this . expMapperDirPath , 'failed-cms-experience.json' ) ;
64- this . failedCmsExpPath = resolve ( this . expMapperDirPath , 'failed-cms-experience.json' ) ;
65- this . experienceCTsPath = resolve ( this . experiencesDirPath , 'experiences-content-types.json' ) ;
56+ this . mapperDirPath = resolve ( sanitizePath ( this . config . backupDir ) , 'mapper' , sanitizePath ( this . personalizationConfig . dirName ) ) ;
57+ this . expMapperDirPath = resolve ( sanitizePath ( this . mapperDirPath ) , sanitizePath ( this . experienceConfig . dirName ) ) ;
58+ this . experiencesUidMapperPath = resolve ( sanitizePath ( this . expMapperDirPath ) , 'uid-mapping.json' ) ;
59+ this . cmsVariantGroupPath = resolve ( sanitizePath ( this . expMapperDirPath ) , 'cms-variant-groups.json' ) ;
60+ this . cmsVariantPath = resolve ( sanitizePath ( this . expMapperDirPath ) , 'cms-variants.json' ) ;
61+ this . audiencesMapperPath = resolve ( sanitizePath ( this . mapperDirPath ) , sanitizePath ( this . audienceConfig . dirName ) , 'uid-mapping.json' ) ;
62+ this . eventsMapperPath = resolve ( sanitizePath ( this . mapperDirPath ) , 'events' , 'uid-mapping.json' ) ;
63+ this . failedCmsExpPath = resolve ( sanitizePath ( this . expMapperDirPath ) , 'failed-cms-experience.json' ) ;
64+ this . failedCmsExpPath = resolve ( sanitizePath ( this . expMapperDirPath ) , 'failed-cms-experience.json' ) ;
65+ this . experienceCTsPath = resolve ( sanitizePath ( this . experiencesDirPath ) , 'experiences-content-types.json' ) ;
6666 this . experienceVariantsIdsPath = resolve (
67- this . config . data ,
68- this . personalizationConfig . dirName ,
69- this . experienceConfig . dirName ,
67+ sanitizePath ( this . config . data ) ,
68+ sanitizePath ( this . personalizationConfig . dirName ) ,
69+ sanitizePath ( this . experienceConfig . dirName ) ,
7070 'experiences-variants-ids.json' ,
7171 ) ;
72- this . variantUidMapperFilePath = resolve ( this . expMapperDirPath , 'variants-uid-mapping.json' ) ;
72+ this . variantUidMapperFilePath = resolve ( sanitizePath ( this . expMapperDirPath ) , 'variants-uid-mapping.json' ) ;
7373 this . experiencesUidMapper = { } ;
7474 this . cmsVariantGroups = { } ;
7575 this . cmsVariants = { } ;
7676 this . expThresholdTimer = this . experienceConfig ?. thresholdTimer ?? 30000 ;
7777 this . expCheckIntervalDuration = this . experienceConfig ?. checkIntervalDuration ?? 5000 ;
7878 this . maxValidateRetry = Math . round ( this . expThresholdTimer / this . expCheckIntervalDuration ) ;
7979 this . pendingVariantAndVariantGrpForExperience = [ ] ;
80- this . cTsSuccessPath = resolve ( this . config . backupDir , 'mapper' , 'content_types' , 'success.json' ) ;
80+ this . cTsSuccessPath = resolve ( sanitizePath ( this . config . backupDir ) , 'mapper' , 'content_types' , 'success.json' ) ;
8181 this . createdCTs = [ ] ;
8282 }
8383
0 commit comments