11import map from 'lodash/map' ;
2+ import fs from 'fs' ;
23import { join , resolve } from 'path' ;
3- import { existsSync , readFileSync , writeFileSync } from 'fs' ;
44
55import { FsUtility , Locale , sanitizePath , cliux , log } from '@contentstack/cli-utilities' ;
66
@@ -95,7 +95,7 @@ export default class FieldRule extends BaseClass {
9595 log . debug ( `Field rules folder path: ${ this . folderPath } ` , this . config . auditContext ) ;
9696 log . debug ( `Fix mode: ${ this . fix } ` , this . config . auditContext ) ;
9797
98- if ( ! existsSync ( this . folderPath ) ) {
98+ if ( ! fs . existsSync ( this . folderPath ) ) {
9999 log . debug ( `Skipping ${ this . moduleName } audit - path does not exist` , this . config . auditContext ) ;
100100 log . warn ( `Skipping ${ this . moduleName } audit` , this . config . auditContext ) ;
101101 cliux . print ( $t ( auditMsg . NOT_VALID_PATH , { path : this . folderPath } ) , { color : 'yellow' } ) ;
@@ -412,10 +412,10 @@ export default class FieldRule extends BaseClass {
412412 log . debug ( `Extensions path: ${ extensionPath } ` , this . config . auditContext ) ;
413413 log . debug ( `Marketplace apps path: ${ marketplacePath } ` , this . config . auditContext ) ;
414414
415- if ( existsSync ( extensionPath ) ) {
415+ if ( fs . existsSync ( extensionPath ) ) {
416416 log . debug ( `Loading extensions from file` , this . config . auditContext ) ;
417417 try {
418- this . extensions = Object . keys ( JSON . parse ( readFileSync ( extensionPath , 'utf8' ) ) ) ;
418+ this . extensions = Object . keys ( JSON . parse ( fs . readFileSync ( extensionPath , 'utf8' ) ) ) ;
419419 log . debug ( `Loaded ${ this . extensions . length } extensions` , this . config . auditContext ) ;
420420 } catch ( error ) {
421421 log . debug ( `Error loading extensions: ${ error } ` , this . config . auditContext ) ;
@@ -424,10 +424,10 @@ export default class FieldRule extends BaseClass {
424424 log . debug ( `Extensions file not found` , this . config . auditContext ) ;
425425 }
426426
427- if ( existsSync ( marketplacePath ) ) {
427+ if ( fs . existsSync ( marketplacePath ) ) {
428428 log . debug ( `Loading marketplace apps from file` , this . config . auditContext ) ;
429429 try {
430- const marketplaceApps : MarketplaceAppsInstallationData [ ] = JSON . parse ( readFileSync ( marketplacePath , 'utf8' ) ) ;
430+ const marketplaceApps : MarketplaceAppsInstallationData [ ] = JSON . parse ( fs . readFileSync ( marketplacePath , 'utf8' ) ) ;
431431 log . debug ( `Found ${ marketplaceApps . length } marketplace apps` , this . config . auditContext ) ;
432432
433433 for ( const app of marketplaceApps ) {
@@ -490,7 +490,7 @@ export default class FieldRule extends BaseClass {
490490 continue ;
491491 }
492492 const filePath = join ( this . folderPath , `${ schema . uid } .json` ) ;
493- writeFileSync ( filePath , JSON . stringify ( schema ) ) ;
493+ fs . writeFileSync ( filePath , JSON . stringify ( schema ) ) ;
494494 log . debug ( `Wrote fixed schema: ${ schema . uid } → ${ filePath } ` , this . config . auditContext ) ;
495495 }
496496 } else {
@@ -635,12 +635,12 @@ export default class FieldRule extends BaseClass {
635635 log . debug ( `Master locales path: ${ masterLocalesPath } ` , this . config . auditContext ) ;
636636
637637 log . debug ( `Loading master locales` , this . config . auditContext ) ;
638- this . locales = existsSync ( masterLocalesPath ) ? values ( JSON . parse ( readFileSync ( masterLocalesPath , 'utf8' ) ) ) : [ ] ;
638+ this . locales = fs . existsSync ( masterLocalesPath ) ? values ( JSON . parse ( fs . readFileSync ( masterLocalesPath , 'utf8' ) ) ) : [ ] ;
639639 log . debug ( `Loaded ${ this . locales . length } master locales` , this . config . auditContext ) ;
640640
641- if ( existsSync ( localesPath ) ) {
641+ if ( fs . existsSync ( localesPath ) ) {
642642 log . debug ( `Loading additional locales from file` , this . config . auditContext ) ;
643- this . locales . push ( ...values ( JSON . parse ( readFileSync ( localesPath , 'utf8' ) ) ) ) ;
643+ this . locales . push ( ...values ( JSON . parse ( fs . readFileSync ( localesPath , 'utf8' ) ) ) ) ;
644644 log . debug ( `Total locales after loading: ${ this . locales . length } ` , this . config . auditContext ) ;
645645 } else {
646646 log . debug ( `Additional locales file not found` , this . config . auditContext ) ;
0 commit comments