Skip to content

Commit

Permalink
Support static files with default build command
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Apr 17, 2020
1 parent 0e0ecb0 commit fdf5e30
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ static public class BuildConfigurationFromArguments

public const string ElmAppSubdirectoryName = "elm-app";

static string StaticFilesSubdirectoryName => WebAppConfiguration.staticFilesDirectoryName;

public static IImmutableList<string> FrontendElmAppRootFilePath =>
ImmutableList.Create("src", "FrontendWeb", "Main.elm");

Expand Down Expand Up @@ -75,11 +77,27 @@ static public (Func<byte[]> compileConfigZipArchive, IImmutableDictionary<IImmut
Console.WriteLine("I did not find a file at '" + jsonFileSearchPath + "'. I build the configuration without the 'elm-fullstack.json'.");
}

var staticFiles =
var staticFilesFromFrontendWeb =
frontendWebFile == null ?
Array.Empty<(IImmutableList<string> name, IImmutableList<byte> content)>() :
new[] { (name: (IImmutableList<string>)ImmutableList.Create(FrontendWebStaticFileName), (IImmutableList<byte>)frontendWebFile.ToImmutableList()) };

var staticFilesSourceDirectory = Path.Combine(currentDirectory, StaticFilesSubdirectoryName);

var staticFilesFromDirectory =
Directory.Exists(staticFilesSourceDirectory)
?
Filesystem.GetAllFilesFromDirectory(staticFilesSourceDirectory)
.Select(nameAndContent => (name: (IImmutableList<string>)nameAndContent.name.Split(new[] { '/', '\\' }).ToImmutableList(), content: nameAndContent.content))
.ToImmutableList()
:
ImmutableList<(IImmutableList<string> name, IImmutableList<byte> content)>.Empty;

Console.WriteLine("I found " + staticFilesFromDirectory.Count + " static files to include.");

var staticFiles =
staticFilesFromDirectory.AddRange(staticFilesFromFrontendWeb);

var webAppConfig =
new WebAppConfiguration()
.WithElmApp(loweredElmAppFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class WebAppConfiguration

static string jsonFileName => "elm-fullstack.json";

static string staticFilesDirectoryName => "static-files";
static public string staticFilesDirectoryName => "static-files";

static string elmAppDirectoryName => "elm-app";

Expand Down
2 changes: 1 addition & 1 deletion implement/elm-fullstack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace elm_fullstack
{
class Program
{
static string AppVersionId => "2020-04-09";
static string AppVersionId => "2020-04-17";

static int Main(string[] args)
{
Expand Down
4 changes: 2 additions & 2 deletions implement/elm-fullstack/elm-fullstack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>elm_fullstack</RootNamespace>
<AssemblyName>elm-fullstack</AssemblyName>
<AssemblyVersion>2020.0409.0.0</AssemblyVersion>
<FileVersion>2020.0409.0.0</FileVersion>
<AssemblyVersion>2020.0417.0.0</AssemblyVersion>
<FileVersion>2020.0417.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit fdf5e30

Please sign in to comment.