@@ -123,30 +123,11 @@ async function ensureDistDkrRepo(branch = 'develop') {
123123 console . log ( `🔀 Checking out branch '${ branch } '` ) ;
124124 await git . checkout ( branch ) ;
125125 }
126+ git . pull ( ) ;
126127
127128 return distDkrRepoPath ;
128129}
129130
130- // Generate the compose.yml based on the solutionName or any specific config
131- function generateComposeYml ( solutionName ) {
132- const composeConfig = {
133- include : [
134- { path : 'compose.base.yml' } ,
135- { path : `compose.mssql.yml` } ,
136- { path : `compose.postgresql.yml` } ,
137- { path : 'compose.openSearch.yml' } ,
138- { path : 'compose.cache.yml' }
139- ]
140- } ;
141-
142- const composeContent = yaml . dump ( composeConfig ) ;
143- const composeFilePath = path . resolve ( `./solution/compose.yml` ) ;
144-
145- // Write the generated compose.yml to the solution directory
146- fs . writeFileSync ( composeFilePath , composeContent , 'utf8' ) ;
147- console . log ( `✔️ Generated compose.yml for solution: ${ solutionName } ` ) ;
148- return composeFilePath ;
149- }
150131
151132// Get the paths from compose.yml
152133function getComposeFilePaths ( composePath ) {
@@ -167,30 +148,19 @@ function getComposeFilePaths(composePath) {
167148}
168149
169150// Copy files defined in compose.yml from the dist-dkr repo
170- async function copyDistDkrAssetsFromCompose ( composeFilePath , branch = 'develop' ) {
171- if ( ! fs . existsSync ( composeFilePath ) ) {
172- console . warn ( '⚠️ compose.yml not found in the solution folder, skipping...' ) ;
173- return { } ;
174- }
151+ async function copyDistDkrAssetsFromCompose ( composeContent , branch = 'develop' ) {
152+
153+ // Read and parse the compose content to get the file paths
175154
176- // Read and parse the compose.yml to get the file paths
177- const composeFile = fs . readFileSync ( composeFilePath , 'utf8' ) ;
178- let composeConfig ;
179- try {
180- composeConfig = yaml . load ( composeFile ) ; // Parse the YAML file
181- } catch ( error ) {
182- console . error ( '⚠️ Error reading compose.yml' , error ) ;
183- return { } ;
184- }
185155
186156 // Ensure dist-dkr repo is cloned and checked out to the right branch
187157 const distDkrRepoPath = await ensureDistDkrRepo ( branch ) ;
188158
189159 const outputFiles = { } ;
190160
191161 // Ensure we are getting the paths from composeConfig
192- if ( composeConfig . include && Array . isArray ( composeConfig . include ) ) {
193- for ( const item of composeConfig . include ) {
162+ if ( composeContent . include && Array . isArray ( composeContent . include ) ) {
163+ for ( const item of composeContent . include ) {
194164 if ( item . path ) {
195165 // Resolve path within dist-dkr repo
196166 const filePath = item . path . replace ( '${DB_DEFAULT:-postgresql}' , 'postgresql' ) ; // Resolve dynamic paths
@@ -209,7 +179,22 @@ async function copyDistDkrAssetsFromCompose(composeFilePath, branch = 'develop')
209179 console . warn ( `⚠️ File ${ item . path } not found at path: ${ srcPath } ` ) ;
210180 }
211181 }
182+ // Handle env files and their .example equivalents
183+ if ( item . env_file && Array . isArray ( item . env_file ) ) {
184+ for ( const envFile of item . env_file ) {
185+ // Process the .env file itself
186+ const envSrcPath = path . join ( distDkrRepoPath , envFile + '.example' ) ;
187+ if ( fs . existsSync ( envSrcPath ) ) {
188+ const envContent = fs . readFileSync ( envSrcPath , 'utf8' ) ;
189+ outputFiles [ envFile ] = envContent ;
190+ console . log ( `✔️ Copied ${ envFile } from dist-dkr` ) ;
191+ } else {
192+ console . warn ( `⚠️ File ${ envFile } not found at path: ${ envSrcPath } ` ) ;
193+ }
194+ }
195+ }
212196 }
197+
213198 } else {
214199 console . warn ( '⚠️ No include array found in compose.yml.' ) ;
215200 }
@@ -269,7 +254,6 @@ async function main() {
269254 const permission = fs . readFileSync ( './solution/permissions_map.json' , 'utf8' ) ;
270255 const permissionMap = JSON . parse ( permission ) ;
271256
272- const composeFilePath = generateComposeYml ( solutionName ) ;
273257
274258 const output = await processSolutions (
275259 solution_path ,
@@ -278,7 +262,7 @@ async function main() {
278262 ) ;
279263
280264 // Get dist-dkr files from compose.yml and merge them into output
281- const composeFiles = await copyDistDkrAssetsFromCompose ( composeFilePath , 'develop' ) ;
265+ const composeFiles = await copyDistDkrAssetsFromCompose ( output [ 'compose.yml' ] , 'develop' ) ;
282266 Object . assign ( output , composeFiles ) ;
283267
284268 // Create zip
0 commit comments