public static void Main(string[] args) { // get configuration var metadataService = new DotvvmProjectMetadataService(); var metadata = metadataService.FindInDirectory(Directory.GetCurrentDirectory()); if (metadata == null) { Console.WriteLine("No DotVVM project metadata file (.dotvvm.json) was found on current path."); if (ConsoleHelpers.AskForYesNo("Is the current directory the root directory of DotVVM project?")) { Console.WriteLine(); metadata = metadataService.CreateDefaultConfiguration(Directory.GetCurrentDirectory()); metadataService.Save(metadata); } else { Console.WriteLine("There is no DotVVM project metadata file!"); Environment.Exit(1); } } // find applicable command var commands = new CommandBase[] { new AddPageCommand(), new AddMasterPageCommand(), new AddViewModelCommand(), new AddControlCommand(), new AddNswagCommand(), new RegenNswagCommand() //new GenerateUiTestStubCommand() }; var arguments = new Arguments(args); var command = commands.FirstOrDefault(c => c.CanHandle(arguments, metadata)); // execute the command try { if (command != null) { command.Handle(arguments, metadata); // save project metadata metadataService.Save(metadata); } else { throw new InvalidCommandUsageException("Unknown command!"); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); Console.Error.WriteLine(ex.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { // get configuration var metadataService = new DotvvmProjectMetadataService(); var metadata = metadataService.FindInDirectory(Directory.GetCurrentDirectory()); if (metadata == null) { Console.WriteLine("No DotVVM project metadata was found on current path."); Console.WriteLine("Is the current directory the root directory of DotVVM project? [y] or [n]"); if (Console.ReadKey().Key == ConsoleKey.Y) { Console.WriteLine(); metadata = metadataService.CreateDefaultConfiguration(Directory.GetCurrentDirectory()); metadataService.Save(metadata); } else { Console.WriteLine(); Environment.Exit(1); } } // find applicable command var commands = new CommandBase[] { new CreateProjectCommand(), new AddPageCommand(), new AddMasterPageCommand(), new AddViewModelCommand(), new AddControlCommand(), new GenerateUiTestStubCommand() }; var arguments = new Arguments(args); var command = commands.FirstOrDefault(c => c.CanHandle(arguments, metadata)); // execute the command if (command != null) { command.Handle(arguments, metadata); // save project metadata metadataService.Save(metadata); } else { throw new InvalidCommandUsageException("Invalid command!"); } }
private static void ResolveTestProject(DotvvmProjectMetadata dotvvmProjectMetadata) { var metadataService = new DotvvmProjectMetadataService(); if (string.IsNullOrEmpty(dotvvmProjectMetadata.UITestProjectPath)) { var hintProjectName = $"..\\{dotvvmProjectMetadata.ProjectName}.Tests"; if (!Console.IsInputRedirected) { dotvvmProjectMetadata.UITestProjectPath = ConsoleHelpers.AskForValue($"Enter the path to the test project\n(relative to DotVVM project directory, e.g. '{hintProjectName}'): ", hintProjectName); } else { dotvvmProjectMetadata.UITestProjectPath = hintProjectName; } Console.WriteLine($@"Path to test project is set to ""{dotvvmProjectMetadata.UITestProjectPath}"""); } // make sure the test directory exists var testProjectDirectory = dotvvmProjectMetadata.GetUITestProjectFullPath(); if (!Directory.Exists(testProjectDirectory)) { var relativeWebDirectory = Path.GetRelativePath(dotvvmProjectMetadata.GetUITestProjectFullPath(), dotvvmProjectMetadata.ProjectDirectory); GenerateTestProject(testProjectDirectory, relativeWebDirectory); } // make sure we know the test project namespace if (string.IsNullOrEmpty(dotvvmProjectMetadata.UITestProjectRootNamespace)) { dotvvmProjectMetadata.UITestProjectRootNamespace = Path.GetFileName(testProjectDirectory); } // save the metadata metadataService.Save(dotvvmProjectMetadata); }