@@ -9,7 +9,12 @@ import { existsSync } from 'node:fs';
99import includes from 'lodash/includes' ;
1010import { v4 as uuid } from 'uuid' ;
1111import { resolve as pResolve , join } from 'node:path' ;
12- import { FsUtility , log , handleAndLogError } from '@contentstack/cli-utilities' ;
12+ import {
13+ FsUtility ,
14+ log ,
15+ handleAndLogError ,
16+ } from '@contentstack/cli-utilities' ;
17+ import { PATH_CONSTANTS } from '../../constants' ;
1318
1419import config from '../../config' ;
1520import { ModuleClassParams } from '../../types' ;
@@ -36,15 +41,23 @@ export default class ImportAssets extends BaseClass {
3641 this . importConfig . context . module = MODULE_CONTEXTS . ASSETS ;
3742 this . currentModuleName = MODULE_NAMES [ MODULE_CONTEXTS . ASSETS ] ;
3843
39- this . assetsPath = join ( this . importConfig . backupDir , 'assets' ) ;
40- this . mapperDirPath = join ( this . importConfig . backupDir , 'mapper' , 'assets' ) ;
41- this . assetUidMapperPath = join ( this . mapperDirPath , 'uid-mapping.json' ) ;
42- this . assetUrlMapperPath = join ( this . mapperDirPath , 'url-mapping.json' ) ;
43- this . assetFolderUidMapperPath = join ( this . mapperDirPath , 'folder-mapping.json' ) ;
44+ this . assetsPath = join ( this . importConfig . backupDir , PATH_CONSTANTS . CONTENT_DIRS . ASSETS ) ;
45+ this . mapperDirPath = join (
46+ this . importConfig . backupDir ,
47+ PATH_CONSTANTS . MAPPER ,
48+ PATH_CONSTANTS . MAPPER_MODULES . ASSETS ,
49+ ) ;
50+ this . assetUidMapperPath = join ( this . mapperDirPath , PATH_CONSTANTS . FILES . UID_MAPPING ) ;
51+ this . assetUrlMapperPath = join ( this . mapperDirPath , PATH_CONSTANTS . FILES . URL_MAPPING ) ;
52+ this . assetFolderUidMapperPath = join ( this . mapperDirPath , PATH_CONSTANTS . FILES . FOLDER_MAPPING ) ;
4453 this . assetsRootPath = join ( this . importConfig . backupDir , this . assetConfig . dirName ) ;
4554 this . fs = new FsUtility ( { basePath : this . mapperDirPath } ) ;
4655 this . environments = this . fs . readFile (
47- join ( this . importConfig . backupDir , 'environments' , 'environments.json' ) ,
56+ join (
57+ this . importConfig . backupDir ,
58+ PATH_CONSTANTS . CONTENT_DIRS . ENVIRONMENTS ,
59+ PATH_CONSTANTS . FILES . ENVIRONMENTS ,
60+ ) ,
4861 true ,
4962 ) as Record < string , unknown > ;
5063 }
@@ -208,7 +221,9 @@ export default class ImportAssets extends BaseClass {
208221 */
209222 async importAssets ( isVersion = false ) : Promise < void > {
210223 const processName = isVersion ? 'import versioned assets' : 'import assets' ;
211- const indexFileName = isVersion ? 'versioned-assets.json' : 'assets.json' ;
224+ const indexFileName = isVersion
225+ ? PATH_CONSTANTS . FILES . VERSIONED_ASSETS
226+ : this . assetConfig . fileName ;
212227 const basePath = isVersion ? join ( this . assetsPath , 'versions' ) : this . assetsPath ;
213228 const progressProcessName = isVersion ? PROCESS_NAMES . ASSET_VERSIONS : PROCESS_NAMES . ASSET_UPLOAD ;
214229
@@ -355,7 +370,10 @@ export default class ImportAssets extends BaseClass {
355370 * @returns {Promise<void> } Promise<void>
356371 */
357372 async publish ( ) {
358- const fs = new FsUtility ( { basePath : this . assetsPath , indexFileName : 'assets.json' } ) ;
373+ const fs = new FsUtility ( {
374+ basePath : this . assetsPath ,
375+ indexFileName : this . assetConfig . fileName ,
376+ } ) ;
359377 if ( isEmpty ( this . assetsUidMap ) ) {
360378 log . debug ( 'Loading asset UID mappings from file' , this . importConfig . context ) ;
361379 this . assetsUidMap = fs . readFile ( this . assetUidMapperPath , true ) as any ;
@@ -563,7 +581,10 @@ export default class ImportAssets extends BaseClass {
563581 }
564582
565583 private async countPublishableAssets ( ) : Promise < number > {
566- const fsUtil = new FsUtility ( { basePath : this . assetsPath , indexFileName : 'assets.json' } ) ;
584+ const fsUtil = new FsUtility ( {
585+ basePath : this . assetsPath ,
586+ indexFileName : this . assetConfig . fileName ,
587+ } ) ;
567588 let count = 0 ;
568589
569590 for ( const _ of values ( fsUtil . indexFileContent ) ) {
0 commit comments