public void Execute(TemplatePlanContext context) { var dir = AppDomain.CurrentDomain.BaseDirectory; var registry = _fileSystem.LoadFromFile<GitAliasRegistry>(dir, GitAliasRegistry.ALIAS_FILE); var url = context.Input.GitFlag; var token = registry.AliasFor(url); if(token != null) { url = token.Url; } var gitProcess = _processFactory .Create(p => { p.UseShellExecute = false; p.FileName = "git"; p.Arguments = "clone {0} {1}".ToFormat(url, context.TempDir); }); gitProcess.Start(); gitProcess.WaitForExit(); if (gitProcess.ExitCode != 0) { throw new FubuException(gitProcess.ExitCode, "Command finished with a non-zero exit code"); } }
public void should_add_each_project_found() { var solutionFile = FileSystem.Combine("Templating", "data", "myproject.txt"); var input = new NewCommandInput { SolutionFlag = solutionFile }; var context = new TemplatePlanContext { Input = input, TempDir = "Test" }; var projects = new List <CsProj>(); for (var i = 0; i < 5; i++) { projects.Add(new CsProj()); } MockFor <ICsProjGatherer>() .Expect(g => g.GatherProjects(context.TempDir)) .Return(projects); projects.Each(project => MockFor <ISolutionFileService>() .Expect(s => s.AddProject(solutionFile, project))); ClassUnderTest.Execute(context); VerifyCallsFor <ISolutionFileService>(); }
public void Execute(TemplatePlanContext context) { var dir = AppDomain.CurrentDomain.BaseDirectory; var registry = _fileSystem.LoadFromFile <GitAliasRegistry>(dir, GitAliasRegistry.ALIAS_FILE); var url = context.Input.GitFlag; var token = registry.AliasFor(url); if (token != null) { url = token.Url; } var gitProcess = _processFactory .Create(p => { p.UseShellExecute = false; p.FileName = "git"; p.Arguments = "clone {0} {1}".ToFormat(url, context.TempDir); }); gitProcess.Start(); gitProcess.WaitForExit(); if (gitProcess.ExitCode != 0) { throw new FubuException(gitProcess.ExitCode, "Command finished with a non-zero exit code"); } }
public void Execute(TemplatePlanContext context) { var tempFile = FileSystem.Combine(context.TempDir, "{0}.rb".ToFormat(Guid.NewGuid())); using (var runner = GetType().Assembly.GetManifestResourceStream(GetType(), "rakerunner.rb")) { using (var stream = File.Create(tempFile)) { runner.CopyTo(stream); stream.Close(); } } var rakeProcess = _processFactory .Create(s => { s.FileName = "ruby"; s.UseShellExecute = false; s.WorkingDirectory = context.TempDir; s.EnvironmentVariables.Add("FUBUPROJECTNAME", context.Input.ProjectName); s.Arguments = "{0} --rakefile {1}".ToFormat(tempFile, context.Input.RakeFlag); }); rakeProcess.Start(); rakeProcess.WaitForExit(); _fileSystem.DeleteFile(tempFile); if (rakeProcess.ExitCode != 0) { var message = new StringBuilder() .AppendLine("Command finished with a non-zero exit code") .AppendLine(rakeProcess.GetErrors()); throw new FubuException(rakeProcess.ExitCode, message.ToString()); } }
public void Execute(TemplatePlanContext context) { if(shouldExecute(context)) { _rakeRunner.Run(context, getRakeFile(context)); } }
public void Execute(TemplatePlanContext context) { var solutionFile = context.Input.SolutionFlag; _projGatherer .GatherProjects(context.TempDir) .Each(project => _solutionFileService.AddProject(solutionFile, project)); }
public void Execute(TemplatePlanContext context) { _keywordReplacer.SetToken("FUBUPROJECTNAME", context.Input.ProjectName); _keywordReplacer.SetToken("FUBUPROJECTSHORTNAME", context.Input.ProjectName.Split('.').Last()); _keywordReplacer.SetToken("FACEFACE-FACE-FACE-FACE-FACEFACEFACE", Guid.NewGuid().ToString().ToUpper()); ParseDirectory(context.TempDir); }
public void Execute(TemplatePlanContext context) { var zipPath = context.Input.ZipFlag; var templateZip = string.IsNullOrEmpty(zipPath) ? TemplateZip : Path.Combine(Environment.CurrentDirectory, zipPath); _zipFileService.ExtractTo(templateZip, context.TempDir, ExplodeOptions.PreserveDestination); }
public string Describe(TemplatePlanContext context) { if(!shouldExecute(context)) { return null; } return "rake {0}".ToFormat(getRakeFile(context)); }
protected override void beforeEach() { _input = new NewCommandInput(); _context = new TemplatePlanContext { TargetPath = "Test", Input = _input }; }
protected override void beforeEach() { _input = new NewCommandInput(); _context = new TemplatePlanContext { TargetPath = "Test", Input = _input, TempDir = Guid.NewGuid().ToString() }; }
public void Execute(TemplatePlanContext context) { var fileSet = new FileSet { DeepSearch = false, Include = "*.*", Exclude = "*.exe;*.dll;.git;{0};{1};".ToFormat(FubuIgnoreFile, AutoRunFubuRake.FubuRakeFile) }; var fubuIgnore = FileSystem.Combine(context.TempDir, FubuIgnoreFile); if (_fileSystem.FileExists(fubuIgnore)) { _fileSystem .ReadStringFromFile(fubuIgnore) .SplitOnNewLine() .Each(ignore => { fileSet.Exclude += "{0};".ToFormat(ignore); }); } var excludedFiles = fileSet.ExcludedFilesFor(context.TempDir); _fileSystem .FindFiles(context.TempDir, fileSet) .Where(file => !excludedFiles.Contains(file)) .Each(from => { var destination = Path.Combine(context.TargetPath, _fileSystem.GetFileName(from)); if (_fileSystem.FileExists(destination)) { _fileSystem.DeleteFile(destination); } _fileSystem.MoveFile(from, destination); }); _fileSystem .ChildDirectoriesFor(context.TempDir) .Each(directory => { var destinationName = _fileSystem.GetFileName(directory); if (destinationName == ".git") { return; } var destination = Path.Combine(context.TargetPath, destinationName); if (_fileSystem.DirectoryExists(destination)) { _fileSystem.DeleteDirectory(destination); } _fileSystem.MoveDirectory(directory, destination); }); }
public void Execute(TemplatePlanContext context) { var fileSet = new FileSet { DeepSearch = false, Include = "*.*", Exclude = "*.exe;*.dll;.git;*{0};".ToFormat(FubuIgnoreFile) }; var fubuIgnore = FileSystem.Combine(context.TempDir, FubuIgnoreFile); if(_fileSystem.FileExists(fubuIgnore)) { _fileSystem .ReadStringFromFile(fubuIgnore) .SplitOnNewLine() .Each(ignore => { fileSet.Exclude += "{0};".ToFormat(ignore); }); } var excludedFiles = fileSet.ExcludedFilesFor(context.TempDir); _fileSystem .FindFiles(context.TempDir, fileSet) .Where(file => !excludedFiles.Contains(file)) .Each(from => { var destination = Path.Combine(context.TargetPath, _fileSystem.GetFileName(from)); if (_fileSystem.FileExists(destination)) _fileSystem.DeleteFile(destination); _fileSystem.MoveFile(from, destination); }); _fileSystem .ChildDirectoriesFor(context.TempDir) .Each(directory => { var destinationName = _fileSystem.GetFileName(directory); if(destinationName == ".git") { return; } var destination = Path.Combine(context.TargetPath, destinationName); if (_fileSystem.DirectoryExists(destination)) { _fileSystem.DeleteDirectory(destination); } _fileSystem.MoveDirectory(directory, destination); }); var info = new DirectoryInfo(context.TempDir); info.SafeDelete(); }
public void should_invoke_callback_on_context() { _plan.AddStep(MockFor <ITemplateStep>()); MockFor <ITemplateStep>() .Expect(s => s.Execute(null)) .IgnoreArguments() .WhenCalled(mi => { _context = (TemplatePlanContext)mi.Arguments[0]; }); ClassUnderTest.Execute(_input, _plan, ctx => ctx.ShouldEqual(_context)); }
private void execute() { _plan.AddStep(MockFor <ITemplateStep>()); MockFor <ITemplateStep>() .Expect(s => s.Execute(null)) .IgnoreArguments() .WhenCalled(mi => { _context = (TemplatePlanContext)mi.Arguments[0]; }); ClassUnderTest.Execute(_input, _plan, ctx => { }); }
public void Execute(TemplatePlanContext context) { var solutionFile = context.Input.SolutionFlag; var sln = new Sln(solutionFile); _projGatherer .GatherProjects(context.TempDir) .Each(project => { sln.AddProject(project); sln.RegisterPostSolutionConfigurations(project.ProjectGuid, Configurations); }); _solutionFileService.Save(sln); }
protected override void beforeEach() { _input = new NewCommandInput(); _context = new TemplatePlanContext { TargetPath = "Test", Input = _input, TempDir = Guid.NewGuid().ToString() }; _registry = new GitAliasRegistry(); var dir = AppDomain.CurrentDomain.BaseDirectory; MockFor <IFileSystem>() .Expect(f => f.LoadFromFile <GitAliasRegistry>(dir, GitAliasRegistry.ALIAS_FILE)) .Return(_registry); }
public void Execute(TemplatePlanContext context) { var gitProcess = _processFactory .Create(p => { p.UseShellExecute = false; p.FileName = "git"; p.Arguments = "clone {0} {1}".ToFormat(context.Input.GitFlag, context.TempDir); }); gitProcess.Start(); gitProcess.WaitForExit(); if (gitProcess.ExitCode != 0) { throw new FubuException(gitProcess.ExitCode, "Command finished with a non-zero exit code"); } }
public void should_register_error_for_an_exception_thrown_in_a_step() { var error = "123"; _plan.AddStep(MockFor <ITemplateStep>()); MockFor <ITemplateStep>() .Expect(s => s.Execute(null)) .IgnoreArguments() .WhenCalled(mi => { _context = (TemplatePlanContext)mi.Arguments[0]; throw new ArgumentException(error); }); ClassUnderTest.Execute(_input, _plan, ctx => { }); _context .Errors .ShouldContain(error); }
public void Run(TemplatePlanContext context, string rakeFile) { var tempFile = FileSystem.Combine(context.TempDir, "{0}.rb".ToFormat(Guid.NewGuid())); using (var runner = GetType().Assembly.GetManifestResourceStream(GetType(), "rakerunner.rb")) { using (var fileStream = File.Create(tempFile)) { runner.CopyTo(fileStream); using (var writer = new StreamWriter(fileStream)) { writer.WriteLine("FUBU_PROJECT_NAME = \"{0}\"".ToFormat(context.Input.ProjectName)); writer.WriteLine("Rake.application.run"); writer.Close(); } } } var rakeProcess = _processFactory .Create(s => { s.FileName = "ruby"; s.UseShellExecute = false; s.WorkingDirectory = context.TargetPath; s.Arguments = "{0} --rakefile {1}".ToFormat(tempFile, rakeFile); }); rakeProcess.Start(); rakeProcess.WaitForExit(); _fileSystem.DeleteFile(tempFile); if (rakeProcess.ExitCode != 0) { var message = new StringBuilder() .AppendLine("Command finished with a non-zero exit code") .AppendLine(rakeProcess.GetErrors()); throw new FubuException(rakeProcess.ExitCode, message.ToString()); } }
public string Describe(TemplatePlanContext context) { return("Replace all keywords in file content and file names"); }
public string Describe(TemplatePlanContext context) { return("Unzip {0}".ToFormat(context.Input.ZipFlag)); }
public string Describe(TemplatePlanContext context) { return "rake {0}".ToFormat(getRakeFile(context)); }
private string getRakeFile(TemplatePlanContext context) { return _fileSystem.GetFullPath(FileSystem.Combine(context.TempDir, context.Input.RakeFlag)); }
public string Describe(TemplatePlanContext context) { return("Move templated content to {0}".ToFormat(context.TargetPath)); }
private bool shouldExecute(TemplatePlanContext context) { return _fileSystem.FileExists(getRakeFile(context)); }
public string Describe(TemplatePlanContext context) { return("Remove temporary directory {0}".ToFormat(context.TempDir)); }
public string Describe(TemplatePlanContext context) { return("Modify {0} to include project templates".ToFormat(context.Input.SolutionFlag)); }
public string Describe(TemplatePlanContext context) { return("Clone git repository from {0}".ToFormat(context.Input.GitFlag)); }
public void Execute(TemplatePlanContext context) { new DirectoryInfo(context.TempDir).SafeDelete(); }
public string Describe(TemplatePlanContext context) { return "Move templated content to {0}".ToFormat(context.TargetPath); }
public string Describe(TemplatePlanContext context) { return "Remove temporary directory {0}".ToFormat(context.TempDir); }
private string getRakeFile(TemplatePlanContext context) { return(_fileSystem.GetFullPath(FileSystem.Combine(context.TempDir, context.Input.RakeFlag))); }
public string Describe(TemplatePlanContext context) { return "Modify {0} to include project templates".ToFormat(context.Input.SolutionFlag); }
public string Describe(TemplatePlanContext context) { return(""); }
public void Execute(TemplatePlanContext context) { }
public string Describe(TemplatePlanContext context) { return "Replace all keywords in file content and file names"; }
public string Describe(TemplatePlanContext context) { return "rake {0}".ToFormat(context.Input.RakeFlag); }
public string Describe(TemplatePlanContext context) { return "Clone git repository from {0}".ToFormat(context.Input.GitFlag); }
private string getRakeFile(TemplatePlanContext context) { return _fileSystem.GetFullPath(FileSystem.Combine(context.TempDir, FubuRakeFile)); }
public string Describe(TemplatePlanContext context) { return("rake {0}".ToFormat(getRakeFile(context))); }