コード例 #1
0
        BuildConfigurationZipArchive(
            string frontendWebElmMakeCommandAppendix)
        {
            var currentDirectory = Environment.CurrentDirectory;

            Console.WriteLine("The currentDirectory is '" + currentDirectory + "'.");

            var elmAppFilesBeforeLowering =
                ElmApp.ToFlatDictionaryWithPathComparer(
                    ElmApp.FilesFilteredForElmApp(
                        Filesystem.GetAllFilesFromDirectory(Path.Combine(currentDirectory, ElmAppSubdirectoryName)))
                    .Select(filePathAndContent =>
                            ((IImmutableList <string>)filePathAndContent.filePath.Split(new[] { '/', '\\' }).ToImmutableList(),
                             filePathAndContent.fileContent)));

            Console.WriteLine("I found " + elmAppFilesBeforeLowering.Count + " files to build the Elm app.");

            var elmAppContainsFrontend = elmAppFilesBeforeLowering.ContainsKey(FrontendElmAppRootFilePath);

            Console.WriteLine("This Elm app contains " + (elmAppContainsFrontend ? "a" : "no") + " frontend at '" + string.Join("/", FrontendElmAppRootFilePath) + "'.");

            var loweredElmAppFiles = ElmApp.AsCompletelyLoweredElmApp(
                elmAppFilesBeforeLowering, ElmAppInterfaceConfig.Default);

            byte[] frontendWebFile = null;

            if (elmAppContainsFrontend)
            {
                var frontendWebHtml = ProcessFromElm019Code.CompileElmToHtml(
                    loweredElmAppFiles,
                    FrontendElmAppRootFilePath,
                    frontendWebElmMakeCommandAppendix);

                frontendWebFile = Encoding.UTF8.GetBytes(frontendWebHtml);
            }

            WebAppConfigurationJsonStructure jsonStructure = null;

            var jsonFileSearchPath = Path.Combine(currentDirectory, "elm-fullstack.json");

            if (File.Exists(jsonFileSearchPath))
            {
                Console.WriteLine("I found a file at '" + jsonFileSearchPath + "'. I use this to build the configuration.");

                var jsonFile = File.ReadAllBytes(jsonFileSearchPath);

                jsonStructure = JsonConvert.DeserializeObject <WebAppConfigurationJsonStructure>(Encoding.UTF8.GetString(jsonFile));
            }
            else
            {
                Console.WriteLine("I did not find a file at '" + jsonFileSearchPath + "'. I build the configuration without the 'elm-fullstack.json'.");
            }

            var staticFiles =
                frontendWebFile == null?
                Array.Empty <(IImmutableList <string> name, IImmutableList <byte> content)>() :
                    new[] { (name : (IImmutableList <string>)ImmutableList.Create(FrontendWebStaticFileName), (IImmutableList <byte>)frontendWebFile.ToImmutableList()) };
コード例 #2
0
    static public Composition.TreeWithStringPath?LoadSortedTreeFromPath(string path)
    {
        if (File.Exists(path))
        {
            return(Composition.TreeWithStringPath.Blob(blobContent: File.ReadAllBytes(path)));
        }

        if (!Directory.Exists(path))
        {
            return(null);
        }

        var blobs = Filesystem.GetAllFilesFromDirectory(path);

        return(Composition.SortedTreeFromSetOfBlobsWithStringPath(blobs));
    }