Exemplo n.º 1
0
        public static TemplateRequest BuildTemplateRequest(AddInput input, string solutionFile)
        {
            var request = new TemplateRequest
            {
                RootDirectory = Environment.CurrentDirectory,
                SolutionName  = solutionFile
            };

            var shortName = input.DetermineShortName();

            request.Substitutions.Set(ProjectPlan.SHORT_NAME, shortName);

            var choices = input.ToChoices();

            var project = Templating.Library.Graph.BuildProjectRequest(choices);

            if (input.DotNetFlag.IsNotEmpty())
            {
                project.Version = input.DotNetFlag;
            }

            project.Version = project.Version ?? DotNetVersion.V40;



            request.AddProjectRequest(project);
            if (!input.NoTestsFlag)
            {
                request.AddMatchingTestingProject(project);
            }

            return(request);
        }
Exemplo n.º 2
0
        private static ProjectRequest addApplicationProject(NewCommandInput input, TemplateRequest request)
        {
            var project = new ProjectRequest(input.SolutionName, "baseline");

            project.AddAlteration("structuremap");
            project.AddAlteration("fubumvc-empty");

            if (input.OptionsFlag != null)
            {
                input.OptionsFlag.Each(x => project.AddAlteration(x));
            }

            // TODO -- duplication!
            if (input.ShortNameFlag.IsNotEmpty())
            {
                project.Substitutions.Set(ProjectPlan.SHORT_NAME, input.ShortNameFlag);
            }

            // TODO -- Will need to check for razor too!
            if (!project.Alterations.Contains("spark"))
            {
                project.AddAlteration("no-views");
            }

            request.AddProjectRequest(project);

            return(project);
        }
Exemplo n.º 3
0
        public override bool Execute(NewStorytellerInput input)
        {
            // TODO -- duplication here
            string solutionFile = SolutionFinder.FindSolutionFile();

            if (solutionFile == null)
            {
                return(false);
            }

            var projectRequest = new ProjectRequest(input.Name, "baseline");

            projectRequest.AddAlteration("storyteller");

            var request = new TemplateRequest
            {
                RootDirectory = Environment.CurrentDirectory,
                SolutionName  = solutionFile
            };

            request.AddProjectRequest(projectRequest);


            // TODO -- add an option to copy references from the parent project
            var plan = NewCommand.BuildTemplatePlan(request);

            NewCommand.ExecutePlan(plan);

            return(true);
        }
Exemplo n.º 4
0
        public TemplateRequest CreateRequestForSolution()
        {
            var request = new TemplateRequest
            {
                RootDirectory = SolutionDirectory(),
                SolutionName  = SolutionName,
                Version       = VersionFlag
            };

            request.AddTemplate("baseline");

            request.AddTemplate(_rippleTemplates[RippleFlag]);

            determineShortName(request);

            if (!Profile.EqualsIgnoreCase("empty"))
            {
                var choices = ToTemplateChoices();
                var project = Templating.Library.Graph.BuildProjectRequest(choices);
                if (DotNetFlag.IsNotEmpty())
                {
                    project.Version = DotNetFlag;
                }

                project.Version = project.Version ?? DotNetVersion.V40;

                request.AddProjectRequest(project);
                if (!NoTestsFlag)
                {
                    request.AddMatchingTestingProject(project);
                }
            }

            return(request);
        }
Exemplo n.º 5
0
        // SAMPLE: building-template-request
        private static TemplateRequest buildTemplateRequest()
        {
            var request = new TemplateRequest
            {
                RootDirectory = "root directory",
                SolutionName  = "MySolution.sln"
            };

            // Add a project named "MyProject" using a project template named "basic-new-project"
            request.AddProjectRequest("MyProject", "basic-new-project", project => {
                // Add some extra templates from the /alterations folder
                project.Alterations.Add("raven");
                project.Alterations.Add("spark");

                // Add some substitution values for the templating if desired
                // See the topic page for subsitutions and inputs
                project.Substitutions.Set("%SHORT_NAME%", "MyProj");
            });

            // Add a testing project related to our first project using the "unit-testing" project template
            // See the topic about testing projects
            request.AddTestingRequest(new ProjectRequest("MyProject.Testing", "unit-testing", "MyProject"));

            return(request);
        }
Exemplo n.º 6
0
        public void validate_missing_project_template()
        {
            var request = new TemplateRequest();

            request.AddTemplate("Simple");
            request.AddProjectRequest(new ProjectRequest("foo", "NonExistent"));

            var missing = request.Validate(theTemplates).Single();

            missing.Name.ShouldEqual("NonExistent");
            missing.TemplateType.ShouldEqual(TemplateType.Project);
            missing.ValidChoices.ShouldHaveTheSameElementsAs("MvcApp", "MvcBottle");
        }
Exemplo n.º 7
0
        public static TemplateRequest BuildTemplateRequest(EnhanceInput input, string solutionFile)
        {
            var request = new TemplateRequest
            {
                RootDirectory = Environment.CurrentDirectory.ToFullPath(),
                SolutionName  = Path.GetFileNameWithoutExtension(solutionFile)
            };

            var projectRequest = new ProjectRequest(input.Project, "baseline");

            request.AddProjectRequest(projectRequest);
            input.Options.Each(o => projectRequest.Alterations.Add(o));
            return(request);
        }
Exemplo n.º 8
0
        public void validate_missing_alteration_template()
        {
            var request = new TemplateRequest();

            request.AddTemplate("Simple");
            request.AddProjectRequest(new ProjectRequest("foo", "MvcApp"));
            request.Projects.Last().Alterations.Add("NonExistent");

            var missing = request.Validate(theTemplates).Single();

            missing.Name.ShouldEqual("NonExistent");
            missing.TemplateType.ShouldEqual(TemplateType.Alteration);
            missing.ValidChoices.ShouldHaveTheSameElementsAs("Assets", "HtmlConventions");
        }
Exemplo n.º 9
0
        public void validate_when_everything_matches()
        {
            var request = new TemplateRequest();

            request.AddTemplate("Simple");

            request.Validate(theTemplates).Any().ShouldBeFalse();

            request.AddProjectRequest(new ProjectRequest("foo", "MvcApp"));

            request.Validate(theTemplates).Any().ShouldBeFalse();

            request.Projects.Single().Alterations.Add("Assets");

            request.AddTestingRequest(new ProjectRequest("foo", "MvcApp", "original"));

            request.Validate(theTemplates).Any().ShouldBeFalse();
        }
Exemplo n.º 10
0
        public static TemplateRequest BuildTemplateRequest(BottleInput input, string solutionFile)
        {
            var request = new TemplateRequest
            {
                RootDirectory = Environment.CurrentDirectory.ToFullPath(),
                SolutionName  = solutionFile
            };

            var projectRequest = new ProjectRequest(input.Name, "baseline");

            // TODO -- duplication!
            if (input.ShortNameFlag.IsNotEmpty())
            {
                projectRequest.Substitutions.Set(ProjectPlan.SHORT_NAME, input.ShortNameFlag);
            }

            request.AddProjectRequest(projectRequest);
            projectRequest.AddAlteration("fubu-bottle");

            // TODO -- some duplication here.
            if (input.TestsFlag)
            {
                var testing = new TestProjectRequest(projectRequest.Name + ".Testing", "baseline",
                                                     projectRequest.Name);

                testing.AddAlteration("unit-testing");

                request.AddTestingRequest(testing);
            }

            if (input.OptionsFlag != null)
            {
                input.OptionsFlag.Each(projectRequest.AddAlteration);
            }

            return(request);
        }