diff --git a/packages/contentstack-import-setup/src/import/modules/assets.ts b/packages/contentstack-import-setup/src/import/modules/assets.ts index 654026ee96..2811126538 100644 --- a/packages/contentstack-import-setup/src/import/modules/assets.ts +++ b/packages/contentstack-import-setup/src/import/modules/assets.ts @@ -3,7 +3,7 @@ import { log, fsUtil } from '../../utils'; import { join } from 'path'; import { AssetRecord, ImportConfig, ModuleClassParams } from '../../types'; import { isEmpty, orderBy, values } from 'lodash'; -import { formatError, FsUtility } from '@contentstack/cli-utilities'; +import { formatError, FsUtility, sanitizePath } from '@contentstack/cli-utilities'; import BaseImportSetup from './base-setup'; export default class AssetImportSetup extends BaseImportSetup { @@ -20,13 +20,13 @@ export default class AssetImportSetup extends BaseImportSetup { constructor({ config, stackAPIClient, dependencies }: ModuleClassParams) { super({ config, stackAPIClient, dependencies }); - this.assetsFolderPath = join(this.config.contentDir, 'assets'); - this.assetsFilePath = join(this.config.contentDir, 'assets', 'assets.json'); + this.assetsFolderPath = join(sanitizePath(this.config.contentDir), 'assets'); + this.assetsFilePath = join(sanitizePath(this.config.contentDir), 'assets', 'assets.json'); this.assetsConfig = config.modules.assets; - this.mapperDirPath = join(this.config.backupDir, 'mapper', 'assets'); - this.assetUidMapperPath = join(this.config.backupDir, 'mapper', 'assets', 'uid-mapping.json'); - this.assetUrlMapperPath = join(this.config.backupDir, 'mapper', 'assets', 'url-mapping.json'); - this.duplicateAssetPath = join(this.config.backupDir, 'mapper', 'assets', 'duplicate-assets.json'); + this.mapperDirPath = join(sanitizePath(this.config.backupDir), 'mapper', 'assets'); + this.assetUidMapperPath = join(sanitizePath(this.config.backupDir), 'mapper', 'assets', 'uid-mapping.json'); + this.assetUrlMapperPath = join(sanitizePath(this.config.backupDir), 'mapper', 'assets', 'url-mapping.json'); + this.duplicateAssetPath = join(sanitizePath(this.config.backupDir), 'mapper', 'assets', 'duplicate-assets.json'); this.assetUidMapper = {}; this.assetUrlMapper = {}; this.duplicateAssets = {}; diff --git a/packages/contentstack-import-setup/src/import/modules/extensions.ts b/packages/contentstack-import-setup/src/import/modules/extensions.ts index f3b1587cd3..59da2f86a2 100644 --- a/packages/contentstack-import-setup/src/import/modules/extensions.ts +++ b/packages/contentstack-import-setup/src/import/modules/extensions.ts @@ -3,7 +3,7 @@ import { log, fsUtil } from '../../utils'; import { join } from 'path'; import { ImportConfig, ModuleClassParams } from '../../types'; import { isEmpty } from 'lodash'; -import { formatError } from '@contentstack/cli-utilities'; +import { formatError, sanitizePath } from '@contentstack/cli-utilities'; export default class ExtensionImportSetup { private config: ImportConfig; @@ -19,9 +19,9 @@ export default class ExtensionImportSetup { constructor({ config, stackAPIClient }: ModuleClassParams) { this.config = config; this.stackAPIClient = stackAPIClient; - this.extensionsFilePath = join(this.config.contentDir, 'extensions', 'extensions.json'); + this.extensionsFilePath = join(sanitizePath(this.config.contentDir), 'extensions', 'extensions.json'); this.extensionsConfig = config.modules.extensions; - this.extUidMapperPath = join(this.config.backupDir, 'mapper', 'extensions', 'uid-mapping.json'); + this.extUidMapperPath = join(sanitizePath(this.config.backupDir), 'mapper', 'extensions', 'uid-mapping.json'); this.extensionMapper = {}; } @@ -35,7 +35,7 @@ export default class ExtensionImportSetup { const extensions: any = await fsUtil.readFile(this.extensionsFilePath); if (!isEmpty(extensions)) { // 2. Create mapper directory - const mapperFilePath = join(this.config.backupDir, 'mapper', 'extensions'); + const mapperFilePath = join(sanitizePath(this.config.backupDir), 'mapper', 'extensions'); fsUtil.makeDirectory(mapperFilePath); // Use fsUtil for (const extension of Object.values(extensions) as any) { diff --git a/packages/contentstack-import-setup/src/import/modules/marketplace-apps.ts b/packages/contentstack-import-setup/src/import/modules/marketplace-apps.ts index 0c81128628..14dc195c9f 100644 --- a/packages/contentstack-import-setup/src/import/modules/marketplace-apps.ts +++ b/packages/contentstack-import-setup/src/import/modules/marketplace-apps.ts @@ -9,6 +9,7 @@ import { ContentstackMarketplaceClient, NodeCrypto, createDeveloperHubUrl, + sanitizePath, } from '@contentstack/cli-utilities'; export default class marketplaceAppImportSetup { @@ -29,9 +30,13 @@ export default class marketplaceAppImportSetup { constructor({ config, stackAPIClient }: ModuleClassParams) { this.config = config; this.stackAPIClient = stackAPIClient; - this.marketplaceAppsFilePath = join(this.config.contentDir, 'marketplace_apps', 'marketplace_apps.json'); + this.marketplaceAppsFilePath = join( + sanitizePath(this.config.contentDir), + 'marketplace_apps', + 'marketplace_apps.json', + ); this.marketplaceAppsConfig = config.modules['marketplace-apps']; - this.marketplaceAppsUidMapperPath = join(this.config.backupDir, 'mapper', 'marketplace_apps'); + this.marketplaceAppsUidMapperPath = join(sanitizePath(this.config.backupDir), 'mapper', 'marketplace_apps'); this.marketplaceAppMapper = { app_uid: {}, installation_uid: {}, extension_uid: {} }; } diff --git a/packages/contentstack-import-setup/src/import/modules/taxonomies.ts b/packages/contentstack-import-setup/src/import/modules/taxonomies.ts index 0f70268782..253b707849 100644 --- a/packages/contentstack-import-setup/src/import/modules/taxonomies.ts +++ b/packages/contentstack-import-setup/src/import/modules/taxonomies.ts @@ -4,6 +4,7 @@ import isEmpty from 'lodash/isEmpty'; import { log, fsUtil } from '../../utils'; import { ImportConfig, ModuleClassParams, TaxonomyQueryParams } from '../../types'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default class TaxonomiesImportSetup { private config: ImportConfig; @@ -21,12 +22,12 @@ export default class TaxonomiesImportSetup { constructor({ config, stackAPIClient }: ModuleClassParams) { this.config = config; this.stackAPIClient = stackAPIClient; - this.taxonomiesFilePath = join(this.config.contentDir, 'taxonomies', 'taxonomies.json'); + this.taxonomiesFilePath = join(sanitizePath(this.config.contentDir), 'taxonomies', 'taxonomies.json'); this.taxonomiesConfig = config.modules.taxonomies; - this.taxonomiesMapperDirPath = join(this.config.backupDir, 'mapper', 'taxonomies'); - this.taxSuccessPath = join(this.taxonomiesMapperDirPath, 'success.json'); - this.termsMapperDirPath = join(this.taxonomiesMapperDirPath, 'terms'); - this.termsSuccessPath = join(this.termsMapperDirPath, 'success.json'); + this.taxonomiesMapperDirPath = join(sanitizePath(this.config.backupDir), 'mapper', 'taxonomies'); + this.taxSuccessPath = join(sanitizePath(this.taxonomiesMapperDirPath), 'success.json'); + this.termsMapperDirPath = join(sanitizePath(this.taxonomiesMapperDirPath), 'terms'); + this.termsSuccessPath = join(sanitizePath(this.termsMapperDirPath), 'success.json'); this.taxonomiesMapper = {}; this.termsMapper = {}; }