Repository: railwayapp/nixpacks
Pull request #669 (2022-11-11 04:30:30)

rename providers to c# and f#
^



Patch:
diff --git a/src/lib.rs b/src/lib.rs
index 31a5c84..9ca714b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -32,7 +32,7 @@ use crate::nixpacks::{
         BuildPlan, PlanGenerator,
     },
 };
-use anyhow::Result;
+use anyhow::{bail, Result};
 use providers::{
     clojure::ClojureProvider, cobol::CobolProvider, crystal::CrystalProvider,
     csharp::CSharpProvider, dart::DartProvider, deno::DenoProvider, elixir::ElixirProvider,
@@ -112,6 +112,31 @@ pub async fn create_docker_image(
 
     let logger = Logger::new();
     let builder = DockerImageBuilder::new(logger, build_options.clone());
+
+    let phase_count = plan.phases.clone().map_or(0, |phases| phases.len());
+    if phase_count > 0 {
+        println!("{}", plan.get_build_string()?);
+
+        let start = plan.start_phase.clone().unwrap_or_default();
+        if start.cmd.is_none() && !build_options.no_error_without_start {
+            bail!("No start command could be found")
+        }
+    } else {
+        println!("\nNixpacks was unable to generate a build plan for this app.\nPlease check the documentation for supported languages: https://nixpacks.com");
+        println!("\nThe contents of the app directory are:\n");
+
+        for file in &app.paths {
+            let path = app.strip_source_path(file.as_path())?;
+            println!(
+                "  {}{}",
+                path.display(),
+                if file.is_dir() { "/" } else { "" }
+            );
+        }
+
+        std::process::exit(1);
+    }
+
     builder
         .create_image(app.source.to_str().unwrap(), &plan, &environment)
         .await?;
diff --git a/src/nixpacks/app.rs b/src/nixpacks/app.rs
index dc8bf0b..4cc34ce 100644
--- a/src/nixpacks/app.rs
+++ b/src/nixpacks/app.rs
@@ -35,7 +35,6 @@ impl App {
     }
 
     /// Check if a file exists
-
     pub fn includes_file(&self, name: &str) -> bool {
         self.source.join(name).is_file()
     }
@@ -94,7 +93,6 @@ impl App {
     }
 
     /// Check if a path matching a glob exists
-
     pub fn has_match(&self, pattern: &str) -> bool {
         match self.find_files(pattern) {
             Ok(v) => !v.is_empty(),
@@ -139,7 +137,6 @@ impl App {
     }
 
     /// Check if a directory exists
-
     pub fn includes_directory(&self, name: &str) -> bool {
         self.source.join(name).is_dir()
     }
@@ -195,7 +192,6 @@ impl App {
     }
 
     /// Get the path in the container to an asset defined in `static_assets`.
-
     pub fn asset_path(&self, name: &str) -> String {
         format!("{}{}", ASSETS_DIR, name)
     }
diff --git a/src/nixpacks/builder/docker/docker_image_builder.rs b/src/nixpacks/builder/docker/docker_image_builder.rs
index e533d9f..a5b2ffb 100644
--- a/src/nixpacks/builder/docker/docker_image_builder.rs
+++ b/src/nixpacks/builder/docker/docker_image_builder.rs
@@ -68,19 +68,6 @@ impl ImageBuilder for DockerImageBuilder {
             return Ok(());
         }
 
-        let phase_count = plan.phases.clone().map_or(0, |phases| phases.len());
-        if phase_count > 0 {
-            println!("{}", plan.get_build_string()?);
-
-            let start = plan.start_phase.clone().unwrap_or_default();
-            if start.cmd.is_none() && !self.options.no_error_without_start {
-                bail!("No start command could be found")
-            }
-        } else {
-            println!("\nNixpacks was unable to generate a build plan for this app.\nPlease check the documentation for supported languages: https://nixpacks.com");
-            std::process::exit(1);
-        }
-
         self.write_app(app_src, &output).context("Writing app")?;
         self.write_dockerfile(dockerfile, &output)
             .context("Writing Dockerfile")?;
diff --git a/src/providers/csharp.rs b/src/providers/csharp.rs
index 7437ad9..908c216 100644
--- a/src/providers/csharp.rs
+++ b/src/providers/csharp.rs
@@ -16,7 +16,7 @@ pub const ARTIFACT_DIR: &str = "out";
 
 impl Provider for CSharpProvider {
     fn name(&self) -> &str {
-        "csharp"
+        "c#"
     }
 
     fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {
diff --git a/src/providers/fsharp.rs b/src/providers/fsharp.rs
index 891d8e6..d66a254 100644
--- a/src/providers/fsharp.rs
+++ b/src/providers/fsharp.rs
@@ -16,7 +16,7 @@ pub const ARTIFACT_DIR: &str = "out";
 
 impl Provider for FSharpProvider {
     fn name(&self) -> &str {
-        "fsharp"
+        "f#"
     }
 
     fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {


Test patch:
diff --git a/tests/snapshots/generate_plan_tests__csharp_api.snap b/tests/snapshots/generate_plan_tests__csharp_api.snap
index b34c482..1077ce9 100644
--- a/tests/snapshots/generate_plan_tests__csharp_api.snap
+++ b/tests/snapshots/generate_plan_tests__csharp_api.snap
@@ -9,7 +9,7 @@ expression: plan
     "ASPNETCORE_ENVIRONMENT": "Production",
     "ASPNETCORE_URLS": "http://0.0.0.0:3000",
     "DOTNET_ROOT": "/nix/var/nix/profiles/default/",
-    "NIXPACKS_METADATA": "csharp"
+    "NIXPACKS_METADATA": "c#"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__csharp_cli.snap b/tests/snapshots/generate_plan_tests__csharp_cli.snap
index f845360..d82f746 100644
--- a/tests/snapshots/generate_plan_tests__csharp_cli.snap
+++ b/tests/snapshots/generate_plan_tests__csharp_cli.snap
@@ -9,7 +9,7 @@ expression: plan
     "ASPNETCORE_ENVIRONMENT": "Production",
     "ASPNETCORE_URLS": "http://0.0.0.0:3000",
     "DOTNET_ROOT": "/nix/var/nix/profiles/default/",
-    "NIXPACKS_METADATA": "csharp"
+    "NIXPACKS_METADATA": "c#"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__fsharp_api.snap b/tests/snapshots/generate_plan_tests__fsharp_api.snap
index e318e0b..4ec3fd2 100644
--- a/tests/snapshots/generate_plan_tests__fsharp_api.snap
+++ b/tests/snapshots/generate_plan_tests__fsharp_api.snap
@@ -9,7 +9,7 @@ expression: plan
     "ASPNETCORE_ENVIRONMENT": "Production",
     "ASPNETCORE_URLS": "http://0.0.0.0:3000",
     "DOTNET_ROOT": "/nix/var/nix/profiles/default/",
-    "NIXPACKS_METADATA": "fsharp"
+    "NIXPACKS_METADATA": "f#"
   },
   "phases": {
     "build": {
diff --git a/tests/snapshots/generate_plan_tests__fsharp_cli.snap b/tests/snapshots/generate_plan_tests__fsharp_cli.snap
index 4235e46..ce1b3a5 100644
--- a/tests/snapshots/generate_plan_tests__fsharp_cli.snap
+++ b/tests/snapshots/generate_plan_tests__fsharp_cli.snap
@@ -9,7 +9,7 @@ expression: plan
     "ASPNETCORE_ENVIRONMENT": "Production",
     "ASPNETCORE_URLS": "http://0.0.0.0:3000",
     "DOTNET_ROOT": "/nix/var/nix/profiles/default/",
-    "NIXPACKS_METADATA": "fsharp"
+    "NIXPACKS_METADATA": "f#"
   },
   "phases": {
     "build": {