Skip to content

Commit

Permalink
Merge branch 'staging' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Dec 11, 2024
2 parents 280ceba + 9d95550 commit 7223d6a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
14 changes: 7 additions & 7 deletions packages/contentstack-import-setup/src/import/modules/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {};
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ContentstackMarketplaceClient,
NodeCrypto,
createDeveloperHubUrl,
sanitizePath,
} from '@contentstack/cli-utilities';

export default class marketplaceAppImportSetup {
Expand All @@ -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: {} };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {};
}
Expand Down

0 comments on commit 7223d6a

Please sign in to comment.