@@ -16,6 +16,7 @@ import { getSafePath } from '../utils/sanitize-path.utils.js';
1616const append = 'a' ;
1717const baseDirName = MIGRATION_DATA_CONFIG . DATA ;
1818const {
19+ ENVIRONMENTS_DIR_NAME ,
1920 ENTRIES_DIR_NAME ,
2021 LOCALE_DIR_NAME ,
2122 LOCALE_MASTER_LOCALE ,
@@ -24,6 +25,7 @@ const {
2425 ASSETS_DIR_NAME ,
2526 ASSETS_FILE_NAME ,
2627 ASSETS_SCHEMA_FILE ,
28+ ENVIRONMENTS_FILE_NAME
2729} = MIGRATION_DATA_CONFIG ;
2830
2931const idCorrector = ( { id } : any ) => {
@@ -159,7 +161,7 @@ const createAssets = async ({
159161 const blobPath : any = path . join ( packagePath , 'blob' , 'master' ) ;
160162 const assetsPath = read ( blobPath ) ;
161163 if ( assetsPath ?. length ) {
162- const isIdPresent = assetsPath ?. find ( ( ast ) => {
164+ const isIdPresent = assetsPath ?. find ( ( ast ) => {
163165 return ast ?. includes ( metaData ?. id )
164166 }
165167 ) ;
@@ -307,8 +309,7 @@ const createEntry = async ({
307309 for await ( const ctType of contentTypes ) {
308310 const message = getLogMessage (
309311 srcFunc ,
310- `Transforming entries of Content Type ${
311- keyMapper ?. [ ctType ?. contentstackUid ] ?? ctType ?. contentstackUid
312+ `Transforming entries of Content Type ${ keyMapper ?. [ ctType ?. contentstackUid ] ?? ctType ?. contentstackUid
312313 } has begun.`,
313314 { }
314315 ) ;
@@ -407,7 +408,7 @@ const createEntry = async ({
407408 ) ;
408409 const mapperCt : string =
409410 keyMapper ?. [ ctType ?. contentstackUid ] !== '' &&
410- keyMapper ?. [ ctType ?. contentstackUid ] !== undefined
411+ keyMapper ?. [ ctType ?. contentstackUid ] !== undefined
411412 ? keyMapper ?. [ ctType ?. contentstackUid ]
412413 : ctType ?. contentstackUid ;
413414 const fileMeta = { '1' : `${ newLocale } .json` } ;
@@ -422,8 +423,7 @@ const createEntry = async ({
422423 } else {
423424 const message = getLogMessage (
424425 srcFunc ,
425- `No entries found for the content type ${
426- keyMapper ?. [ ctType ?. contentstackUid ] ?? ctType ?. contentstackUid
426+ `No entries found for the content type ${ keyMapper ?. [ ctType ?. contentstackUid ] ?? ctType ?. contentstackUid
427427 } .`,
428428 { }
429429 ) ;
@@ -530,9 +530,22 @@ const createVersionFile = async (destinationStackId: string) => {
530530 ) ;
531531} ;
532532
533+ const createEnvironment = async ( destinationStackId : string ) => {
534+ const baseDir = path . join ( baseDirName , destinationStackId ) ;
535+ const environmentSave = path . join ( baseDir , ENVIRONMENTS_DIR_NAME ) ;
536+ const environmentFile = path . join ( environmentSave , ENVIRONMENTS_FILE_NAME ) ;
537+
538+ // Ensure the directory exists
539+ await fs . promises . mkdir ( environmentSave , { recursive : true } ) ;
540+
541+ // Write an empty environments file (or replace {} with your actual data)
542+ await fs . promises . writeFile ( environmentFile , JSON . stringify ( { } ) , 'utf8' ) ;
543+ }
544+
533545export const siteCoreService = {
534546 createEntry,
535547 createAssets,
536548 createLocale,
537549 createVersionFile,
550+ createEnvironment
538551} ;
0 commit comments