@@ -1550,11 +1550,11 @@ const injectSREConfigs = async ({ app_directory, answers, relativeKrakendDir, kr
1550
1550
break ;
1551
1551
1552
1552
case 'grafana/krakend' :
1553
- writeFile ( join ( current_dir , 'dashboard.json' ) , assets . grafanaKrakendDashboardJsonContent ( ) ) ;
1553
+ writeFile ( join ( current_dir , 'dashboard.json' ) , assets . grafanaKrakendDashboardJsonContent ( { app_name : answers . app_name } ) ) ;
1554
1554
break ;
1555
1555
1556
1556
case 'krakend/partials' :
1557
- writeFile ( join ( current_dir , 'extra_config.tmpl' ) , assets . krakendPartialsExtraConfContent ( ) ) ;
1557
+ writeFile ( join ( current_dir , 'extra_config.tmpl' ) , assets . krakendPartialsExtraConfContent ( { app_name : answers . app_name } ) ) ;
1558
1558
writeFile ( join ( current_dir , 'input_headers.tmpl' ) , assets . krakendPartialsInputHeadersContent ( ) ) ;
1559
1559
writeFile ( join ( current_dir , 'rate_limit_backend.tmpl' ) , assets . krakendPartialsRateLimitBackendContent ( ) ) ;
1560
1560
break ;
@@ -1588,10 +1588,11 @@ const injectSREConfigs = async ({ app_directory, answers, relativeKrakendDir, kr
1588
1588
api_version : answers . api_version ,
1589
1589
gateway_cache_period : answers . gateway_cache_period ,
1590
1590
gateway_timeout : answers . gateway_timeout ,
1591
- relativeKrakendDir
1591
+ relativeKrakendDir,
1592
+ app_name : answers . app_name
1592
1593
} ) ) ;
1593
1594
writeFile ( join ( `${ app_directory } ` , '.env' ) , assets . dockerComposeEnvContent ( ) ) ;
1594
- await downloadAndWriteDashboardFile ( app_directory ) ;
1595
+ await readAndWriteDashboardFile ( app_directory , answers ) ;
1595
1596
1596
1597
}
1597
1598
const scaffoldApp = ( { answers } ) => {
@@ -2146,30 +2147,19 @@ const removeGateway = async ({ gateway, project_root }) => {
2146
2147
}
2147
2148
} ;
2148
2149
2149
- const downloadAndWriteDashboardFile = ( app_directory ) => {
2150
- const fileUrl = 'https://raw.githubusercontent.com/krakend/playground-community/master/config/elastic/dashboard.ndjson' ;
2150
+ const readAndWriteDashboardFile = ( app_directory , answers ) => {
2151
2151
const outputDirectory = path . join ( app_directory , 'telemetry' , 'elastic' ) ;
2152
2152
const filename = 'dashboard.ndjson' ;
2153
2153
const outputPath = path . join ( outputDirectory , filename ) ;
2154
+ // Read the NDJSON file content as a string
2155
+ console . log ( { __dirname :__dirname } )
2156
+ const krakendNdjson = readFileSync ( `${ __dirname } /krakend.ndjson` , 'utf8' ) ;
2154
2157
2155
- return new Promise ( ( resolve , reject ) => {
2156
- const file = fs . createWriteStream ( outputPath ) ;
2157
-
2158
- https . get ( fileUrl , ( response ) => {
2159
- if ( response . statusCode === 200 ) {
2160
- response . pipe ( file ) ;
2161
- file . on ( 'finish' , ( ) => {
2162
- file . close ( ( ) => {
2163
- resolve ( ) ;
2164
- } ) ;
2165
- } ) ;
2166
- } else {
2167
- reject ( new Error ( `Failed to download file: ${ response . statusCode } ${ response . statusMessage } ` ) ) ;
2168
- }
2169
- } ) . on ( 'error' , ( err ) => {
2170
- fs . unlink ( outputPath , ( ) => reject ( err ) ) ;
2171
- } ) ;
2172
- } ) ;
2158
+ // Replace all occurrences of 'KrakenD' with 'SuiteCLI/<appname>'
2159
+ const updatedContent = krakendNdjson . replace ( / K r a k e n D / g, `🦧${ answers . app_name } ` ) ;
2160
+
2161
+ // Write the updated content to the new file
2162
+ writeFileSync ( outputPath , updatedContent ) ;
2173
2163
} ;
2174
2164
2175
2165
module . exports = {
0 commit comments