Adapt command
This commit is contained in:
		| @@ -39,14 +39,13 @@ class ServicesGenerate extends Command | |||||||
|     { |     { | ||||||
|         $content = file_get_contents(base_path("templates/compose/$file")); |         $content = file_get_contents(base_path("templates/compose/$file")); | ||||||
| 
 | 
 | ||||||
|         preg_match_all( |         $data = collect(explode(PHP_EOL, $content))->mapWithKeys(function ($line): array { | ||||||
|             '/#\s*(documentation|env_file|ignore|logo|minversion|port|slogan|tags)\s*:\s*(.+)\s*/', |             preg_match('/^#(?<key>.*):(?<value>.*)$/U', $line, $m); | ||||||
|             $content, $matches |  | ||||||
|         ); |  | ||||||
| 
 | 
 | ||||||
|         $data = array_combine($matches[1], $matches[2]); |             return $m ? [trim($m['key']) => trim($m['value'])] : []; | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         if (str($data['ignore'] ?? false)->toBoolean()) { |         if (str($data->get('ignore'))->toBoolean()) { | ||||||
|             $this->info("Ignoring $file"); |             $this->info("Ignoring $file"); | ||||||
| 
 | 
 | ||||||
|             return false; |             return false; | ||||||
| @@ -54,30 +53,30 @@ class ServicesGenerate extends Command | |||||||
| 
 | 
 | ||||||
|         $this->info("Processing $file"); |         $this->info("Processing $file"); | ||||||
| 
 | 
 | ||||||
|         $documentation = $data['documentation'] ?? null; |         $documentation = $data->get('documentation'); | ||||||
|         $documentation = $documentation ? $documentation.'?utm_source=coolify.io' : 'https://coolify.io/docs'; |         $documentation = $documentation ? $documentation.'?utm_source=coolify.io' : 'https://coolify.io/docs'; | ||||||
| 
 | 
 | ||||||
|         $json = Yaml::parse($content); |         $json = Yaml::parse($content); | ||||||
|         $compose = base64_encode(Yaml::dump($json, 10, 2)); |         $compose = base64_encode(Yaml::dump($json, 10, 2)); | ||||||
| 
 | 
 | ||||||
|         $tags = str($data['tags'] ?? '')->lower()->explode(',')->map(fn ($tag) => trim($tag))->filter(); |         $tags = str($data->get('tags'))->lower()->explode(',')->map(fn ($tag) => trim($tag))->filter(); | ||||||
|         $tags = $tags->isEmpty() ? null : $tags->all(); |         $tags = $tags->isEmpty() ? null : $tags->all(); | ||||||
| 
 | 
 | ||||||
|         $payload = [ |         $payload = [ | ||||||
|             'name' => pathinfo($file, PATHINFO_FILENAME), |             'name' => pathinfo($file, PATHINFO_FILENAME), | ||||||
|             'documentation' => $documentation, |             'documentation' => $documentation, | ||||||
|             'slogan' => $data['slogan'] ?? str($file)->headline(), |             'slogan' => $data->get('slogan', str($file)->headline()), | ||||||
|             'compose' => $compose, |             'compose' => $compose, | ||||||
|             'tags' => $tags, |             'tags' => $tags, | ||||||
|             'logo' => $data['logo'] ?? 'svgs/coolify.png', |             'logo' => $data->get('logo', 'svgs/coolify.png'), | ||||||
|             'minversion' => $data['minversion'] ?? '0.0.0', |             'minversion' => $data->get('minversion', '0.0.0'), | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|         if ($port = $data['port'] ?? null) { |         if ($port = $data->get('port')) { | ||||||
|             $payload['port'] = $port; |             $payload['port'] = $port; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if ($envFile = $data['env_file'] ?? null) { |         if ($envFile = $data->get('env_file')) { | ||||||
|             $envFileContent = file_get_contents(base_path("templates/compose/$envFile")); |             $envFileContent = file_get_contents(base_path("templates/compose/$envFile")); | ||||||
|             $payload['envs'] = base64_encode($envFileContent); |             $payload['envs'] = base64_encode($envFileContent); | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lucas Michot
					Lucas Michot