public void SetUp()
        {
            thePlan = TemplatePlan.CreateClean("copy-references");

            thePlan.FileSystem.WriteStringToFile("ripple.dependencies.config", @"FubuCore
            FubuMVC.Core
            ");

            thePlan.Add(new CreateSolution("References"));
            var originalPlan = new ProjectPlan("References");
            thePlan.Add(originalPlan);
            originalPlan.Add(new SystemReference("System.Data"));
            originalPlan.Add(new SystemReference("System.Configuration"));
            originalPlan.Add(new CopyFileToProject("ripple.dependencies.config", "ripple.dependencies.config"));
            originalPlan.NugetDeclarations.Add("Bottles");
            originalPlan.NugetDeclarations.Add("FubuMVC.Core");
            originalPlan.NugetDeclarations.Add("FubuLocalization");

            testingPlan = new ProjectPlan("References.Testing");
            thePlan.Add(testingPlan);
            thePlan.Add(new CopyProjectReferences("References"));

            thePlan.Execute();

            theOriginalProject = thePlan.Solution.FindProject("References").Project;
            theTestingProject = thePlan.Solution.FindProject("References.Testing").Project;
        }
Пример #2
0
 private void applyTestingTemplates(TemplateRequest request, TemplatePlan plan)
 {
     request.TestingProjects.Each(proj => {
         buildProjectPlan(plan, proj);
         plan.Add(new CopyProjectReferences(proj.OriginalProject));
     });
 }
Пример #3
0
        public void Alter(TemplatePlan plan)
        {
            var solution = Solution.CreateNew(plan.SourceDirectory, _solutionName);
            solution.Version = Version;

            plan.Solution = solution;
        }
Пример #4
0
 public static void ConfigurePlan(TextFile textFile, TemplatePlan plan)
 {
     textFile.ReadLines().Each(line => {
         var parts = line.ToDelimitedArray();
         plan.Add(new GemReference(parts.First(), parts.Last()));
     });
 }
 private void applyTestingTemplates(TemplateRequest request, TemplatePlan plan)
 {
     request.TestingProjects.Each(proj => {
         buildProjectPlan(plan, proj);
         plan.Add(new CopyProjectReferences(proj.OriginalProject));
     });
 }
Пример #6
0
        public void Alter(TemplatePlan plan)
        {
            if (!RemoteOperations.Enabled)
            {
                plan.Logger.WriteSuccess("Remote operations are disabled.");
                return;
            }

            var rake = new ProcessStartInfo
            {
                UseShellExecute = !FubuCore.Platform.IsUnix (),
                FileName = "rake",
                CreateNoWindow = true,
                WorkingDirectory = plan.Root
            };

            Process process = Process.Start(rake);
            process.WaitForExit();

            if (process.ExitCode != 0)
            {
                plan.Logger.WriteWarning("rake script failed!");
            }
            else
            {
                plan.Logger.WriteSuccess("rake succeeded");
            }
        }
Пример #7
0
        private void applySolutionTemplates(TemplateRequest request, TemplatePlan plan)
        {
            var planner = new SolutionPlanner();

            _library.Find(TemplateType.Solution, request.Templates)
            .Each(template => planner.CreatePlan(template, plan));
        }
Пример #8
0
        public void Alter(TemplatePlan plan)
        {
            if (!RemoteOperations.Enabled)
            {
                plan.Logger.WriteSuccess("Remote operations are disabled.");
                return;
            }

            var bundler = new ProcessStartInfo
            {
                UseShellExecute = !FubuCore.Platform.IsUnix (),
                FileName = "bundle",
                Arguments = "install",
                CreateNoWindow = true,
                WorkingDirectory = plan.Root
            };

            var process = Process.Start(bundler);
            process.WaitForExit();

            if (process.ExitCode != 0)
            {
                plan.Logger.WriteWarning("bundler install failed!");
            }
            else
            {
                plan.Logger.WriteSuccess("bundler install was successful");
            }
        }
Пример #9
0
        public static void ExecutePlan(TemplatePlan plan)
        {
            plan.Execute();

            new RakeStep().Alter(plan);

            plan.WriteInstructions();
        }
Пример #10
0
        public void CreatePlan(Template template, TemplatePlan plan)
        {
            configurePlan(template.Path, plan);

            _planners.Each(x => x.DetermineSteps(template.Path, plan));

            plan.CopyUnhandledFiles(template.Path);
        }
 public void DetermineSteps(string directory, TemplatePlan plan)
 {
     TextFile.FileSystem.FindFiles(directory, _matching)
     .Select(x => new TextFile(x, x.PathRelativeTo(directory)))
     .Each(file => {
         _action(file, plan);
         plan.MarkHandled(file.Path);
     });
 }
Пример #12
0
        public void SetUp()
        {
            thePlan = TemplatePlan.CreateClean("gitignore");

            _contents = new Lazy<string[]>(() =>
            {
                return fileSystem.ReadStringFromFile("gitignore", ".gitignore").SplitOnNewLine().ToArray();
            });
        }
Пример #13
0
        public void project_folder_is_substituted()
        {
            thePlan = TemplatePlan.CreateClean("create-solutionProject");
            thePlan.Add(new CreateSolution("MySolution"));
            thePlan.Add(new ProjectPlan("MyProject"));

            thePlan.Execute();

            thePlan.CurrentProject.ApplySubstitutions("*%PROJECT_FOLDER%*")
                   .ShouldEqual("*src/MyProject*");
        }
Пример #14
0
        public void alter_by_creating_new_project_from_default_template()
        {
            thePlan = TemplatePlan.CreateClean("create-solutionProject");
            thePlan.Add(new CreateSolution("MySolution"));
            thePlan.Add(new ProjectPlan("MyProject"));

            thePlan.Execute();

            var file = thePlan.SourceDirectory.AppendPath("MyProject", "MyProject.csproj");
            File.Exists(file).ShouldBeTrue();

            var project = CsProjFile.LoadFrom(file);
            project.ShouldNotBeNull();  // really just a smoke test
        }
Пример #15
0
        // TODO -- do a bulk validation of TemplateRequest against the library
        public TemplatePlan BuildPlan(TemplateRequest request)
        {
            var plan = new TemplatePlan(request.RootDirectory);
            if (request.SolutionName.IsNotEmpty())
            {
                determineSolutionFileHandling(request, plan);
            }

            applySolutionTemplates(request, plan);
            request.Substitutions.CopyTo(plan.Substitutions);

            applyProjectTemplates(request, plan);
            applyTestingTemplates(request, plan);

            return plan;
        }
        public void adds_the_project_file_to_the_csproj_file_as_Content()
        {
            thePlan = TemplatePlan.CreateClean("copy-file-to-project");

            thePlan.Add(new CreateSolution("MySolution"));
            var projectPlan = new ProjectPlan("MyProject");
            thePlan.Add(projectPlan);

            thePlan.FileSystem.WriteStringToFile("foo.txt", "some text");
            projectPlan.Add(new CopyFileToProject("foo.txt", "foo.txt"));

            thePlan.Execute();

            var project = CsProjFile.LoadFrom("copy-file-to-project".AppendPath("src", "MyProject", "MyProject.csproj"));
            project.Find<Content>("foo.txt").ShouldNotBeNull();
        }
        public void copy_a_file_to_the_right_spot()
        {
            thePlan = TemplatePlan.CreateClean("copy-file-to-project");

            thePlan.Add(new CreateSolution("MySolution"));
            var projectPlan = new ProjectPlan("MyProject");
            thePlan.Add(projectPlan);

            thePlan.FileSystem.WriteStringToFile("foo.txt", "some text");
            projectPlan.Add(new CopyFileToProject("foo.txt", "foo.txt"));

            thePlan.Execute();

            var file = FileSystem.Combine(thePlan.SourceDirectory, "MyProject", "foo.txt");
            File.Exists(file).ShouldBeTrue();
        }
        public void applies_substitutions()
        {
            thePlan = TemplatePlan.CreateClean("copy-file-to-project");

            thePlan.Add(new CreateSolution("MySolution"));
            var projectPlan = new ProjectPlan("MyProject");
            thePlan.Add(projectPlan);
            projectPlan.Substitutions.Set("%TEAM%", "Chiefs");

            thePlan.FileSystem.WriteStringToFile("foo.txt", "*%TEAM%*");
            projectPlan.Add(new CopyFileToProject("foo.txt", "foo.txt"));

            thePlan.Execute();

            var file = FileSystem.Combine(thePlan.SourceDirectory, "MyProject", "foo.txt");
            thePlan.FileSystem.ReadStringFromFile(file).ShouldEqual("*Chiefs*");
        }
Пример #19
0
        // TODO -- do a bulk validation of TemplateRequest against the library
        public TemplatePlan BuildPlan(TemplateRequest request)
        {
            var plan = new TemplatePlan(request.RootDirectory);

            if (request.SolutionName.IsNotEmpty())
            {
                determineSolutionFileHandling(request, plan);
            }

            applySolutionTemplates(request, plan);
            request.Substitutions.CopyTo(plan.Substitutions);

            applyProjectTemplates(request, plan);
            applyTestingTemplates(request, plan);

            return(plan);
        }
Пример #20
0
        public void alter_by_creating_a_new_project_with_a_project_template_file()
        {
            thePlan = TemplatePlan.CreateClean("create-solutionProject");
            thePlan.Add(new CreateSolution("MySolution"));
            thePlan.Add(new ProjectPlan("MyProject")
            {
                ProjectTemplateFile = "Project.txt"
            });

            thePlan.Execute();

            var file = thePlan.SourceDirectory.AppendPath("MyProject", "MyProject.csproj");
            File.Exists(file).ShouldBeTrue();

            var project = CsProjFile.LoadFrom(file);
            project.All<AssemblyReference>().Any(x => x.Include == "System.Data")
                .ShouldBeTrue(); // the 'special' testing template has this reference, but the default template does not
        }
Пример #21
0
        private void buildProjectPlan(TemplatePlan plan, ProjectRequest proj)
        {
            var projectPlan = new ProjectPlan(proj.Name)
            {
                DotNetVersion = proj.Version ?? DotNetVersion.V40
            };

            plan.Add(projectPlan);

            proj.Substitutions.CopyTo(projectPlan.Substitutions);

            var planner = new ProjectPlanner();

            if (proj.Template.IsNotEmpty())
            {
                planner.CreatePlan(_library.Find(TemplateType.Project, proj.Template), plan);
            }

            _library.Find(TemplateType.Alteration, proj.Alterations)
            .Each(template => planner.CreatePlan(template, plan));
        }
Пример #22
0
        private static void determineSolutionFileHandling(TemplateRequest request, TemplatePlan plan)
        {
            var sourceDirectory = plan.SourceDirectory;
            var expectedFile = sourceDirectory.AppendPath(request.SolutionName);
            if (Path.GetExtension(expectedFile) != ".sln")
            {
                expectedFile += ".sln";
            }

            if (File.Exists(expectedFile))
            {
                plan.Add(new ReadSolution(expectedFile));
            }
            else
            {
                plan.Add(new CreateSolution(request.SolutionName)
                {
                    Version = request.Version
                });
            }
        }
Пример #23
0
        private static void determineSolutionFileHandling(TemplateRequest request, TemplatePlan plan)
        {
            var sourceDirectory = plan.SourceDirectory;
            var expectedFile    = sourceDirectory.AppendPath(request.SolutionName);

            if (Path.GetExtension(expectedFile) != ".sln")
            {
                expectedFile += ".sln";
            }

            if (File.Exists(expectedFile))
            {
                plan.Add(new ReadSolution(expectedFile));
            }
            else
            {
                plan.Add(new CreateSolution(request.SolutionName)
                {
                    Version = request.Version
                });
            }
        }
Пример #24
0
        private void buildProjectPlan(TemplatePlan plan, ProjectRequest proj)
        {
            var projectPlan = new ProjectPlan(proj.Name) {DotNetVersion = proj.Version ?? DotNetVersion.V40};
            plan.Add(projectPlan);

            proj.Substitutions.CopyTo(projectPlan.Substitutions);

            var planner = new ProjectPlanner();
            if (proj.Template.IsNotEmpty())
            {
                planner.CreatePlan(_library.Find(TemplateType.Project, proj.Template), plan);
            }

            _library.Find(TemplateType.Alteration, proj.Alterations)
                    .Each(template => planner.CreatePlan(template, plan));
        }
Пример #25
0
 protected abstract void configurePlan(string directory, TemplatePlan plan);
Пример #26
0
 private void applySolutionTemplates(TemplateRequest request, TemplatePlan plan)
 {
     var planner = new SolutionPlanner();
     _library.Find(TemplateType.Solution, request.Templates)
         .Each(template => planner.CreatePlan(template, plan));
 }
Пример #27
0
 private void applyProjectTemplates(TemplateRequest request, TemplatePlan plan)
 {
     request.Projects.Each(proj => buildProjectPlan(plan, proj));
 }
Пример #28
0
 public static void ConfigurePlan(TextFile textFile, TemplatePlan plan)
 {
     var ignores = textFile.ReadLines().Where(x => x.IsNotEmpty()).ToArray();
     var step = new GitIgnoreStep(ignores);
     plan.Add(step);
 }
Пример #29
0
 protected override void configurePlan(string directory, TemplatePlan plan)
 {
     var current = plan.Steps.OfType<ProjectPlan>().LastOrDefault();
     ProjectDirectory.PlanForDirectory(directory).Each(x => current.Add(x));
 }
Пример #30
0
 public void Alter(TemplatePlan plan)
 {
     plan.AlterFile(".gitignore", list => _entries.Each(list.Fill));
 }
Пример #31
0
 protected override void configurePlan(string directory, TemplatePlan plan)
 {
     SolutionDirectory.PlanForDirectory(directory).Each(plan.Add);
 }
Пример #32
0
        public void project_plan_applies_the_dot_net_version_2()
        {
            thePlan = TemplatePlan.CreateClean("create-solutionProject");
            thePlan.Add(new CreateSolution("MySolution"));
            var projectPlan = new ProjectPlan("MyProject");
            projectPlan.DotNetVersion = DotNetVersion.V45;

            thePlan.Add(projectPlan);

            thePlan.Execute();

            var file = thePlan.SourceDirectory.AppendPath("MyProject", "MyProject.csproj");
            File.Exists(file).ShouldBeTrue();

            var project = CsProjFile.LoadFrom(file);
            project.DotNetVersion.ShouldEqual(DotNetVersion.V45);
        }
Пример #33
0
        protected override void configurePlan(string directory, TemplatePlan plan)
        {
            var current = plan.Steps.OfType <ProjectPlan>().LastOrDefault();

            ProjectDirectory.PlanForDirectory(directory).Each(x => current.Add(x));
        }
Пример #34
0
 private void applyProjectTemplates(TemplateRequest request, TemplatePlan plan)
 {
     request.Projects.Each(proj => buildProjectPlan(plan, proj));
 }
Пример #35
0
 public void Alter(TemplatePlan plan)
 {
     var solution = Solution.LoadFrom(_solutionFile);
     plan.Solution = solution;
 }
Пример #36
0
 public void Alter(TemplatePlan plan)
 {
     new FileSystem().CreateDirectory(plan.Root, _relativePath);
 }
Пример #37
0
        public void Alter(TemplatePlan plan)
        {
            // Hokey.
            _substitutions.Set(TemplatePlan.INSTRUCTIONS, plan.GetInstructions());

            plan.Logger.StartProject(_alterations.Count);
            plan.StartProject(this);

            _substitutions.Trace(plan.Logger);

            var reference = plan.Solution.FindProject(_projectName);
            if (reference == null)
            {
                if (ProjectTemplateFile.IsEmpty())
                {
                    plan.Logger.Trace("Creating project {0} from the default template", _projectName);
                    reference = plan.Solution.AddProject(_projectName);
                }
                else
                {
                    plan.Logger.Trace("Creating project {0} from template at {1}", _projectName, ProjectTemplateFile);
                    reference = plan.Solution.AddProjectFromTemplate(_projectName, ProjectTemplateFile);
                }

                reference.Project.AssemblyName = reference.Project.RootNamespace = ProjectName;
                if (DotNetVersion != null) reference.Project.DotNetVersion = DotNetVersion;
            }

            var projectDirectory = reference.Project.ProjectDirectory;
            plan.FileSystem.CreateDirectory(projectDirectory);

            _relativePath = reference.Project.FileName.PathRelativeTo(plan.Root).Replace("\\", "/");
            _substitutions.Set(PROJECT_PATH, _relativePath);
            _substitutions.Set(PROJECT_FOLDER, _relativePath.Split('/').Reverse().Skip(1).Reverse().Join("/"));

            _alterations.Each(x => {
                plan.Logger.TraceAlteration(ApplySubstitutions(x.ToString()));
                x.Alter(reference.Project, this);
            });

            Substitutions.WriteTo(projectDirectory.AppendPath(Substitutions.ConfigFile));

            plan.Logger.EndProject();
        }
Пример #38
0
 protected override void configurePlan(string directory, TemplatePlan plan)
 {
     SolutionDirectory.PlanForDirectory(directory).Each(plan.Add);
 }
 public void SetUp()
 {
     plan = TemplatePlan.CreateClean("rake");
     rakefilePath = "rake".AppendPath("rakefile");
 }
Пример #40
0
 public void Alter(TemplatePlan plan)
 {
     plan.AlterFile("Gemfile", Alter);
 }
Пример #41
0
        private void writePreview(Action<TemplateRequest> configure = null)
        {
            if (configure != null)
            {
                configure(theRequest);
            }

            thePlan = new TemplatePlanBuilder(library).BuildPlan(theRequest);

            thePlan.WritePreview();
        }