private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); string workingDirectory = Path.GetDirectoryName(configPath); var scripts = TaskParser.LoadTasks(configPath); Telemetry.TrackEvent("Tasks loaded"); if (scripts == null) return root; TaskRunnerNode tasks = new TaskRunnerNode("Scripts"); tasks.Description = "Scripts specified in the \"scripts\" JSON element."; root.Children.Add(tasks); foreach (string script in scripts) { TaskRunnerNode task = new TaskRunnerNode(script, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", $"/c npm run {script} --color=always"), Description = $"Runs the '{script}' script", }; tasks.Children.Add(task); } return root; }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); string rootDir = Path.GetDirectoryName(configPath); var commands = TaskParser.LoadTasks(configPath); if (commands == null) { return(root); } TaskRunnerNode tasks = new TaskRunnerNode("Commands"); tasks.Description = "A list of command to execute"; root.Children.Add(tasks); foreach (CommandTask command in commands.OrderBy(k => k.Name)) { string cwd = command.WorkingDirectory ?? rootDir; // Add zero width space string commandName = command.Name += "\u200B"; SetDynamicTaskName(commandName); TaskRunnerNode task = new TaskRunnerNode(commandName, true) { Command = new TaskRunnerCommand(cwd, command.FileName, command.Arguments), Description = $"Filename:\t {command.FileName}\r\nArguments:\t {command.Arguments}" }; tasks.Children.Add(task); } return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode("Broccoli Commands"); string workingDirectory = Path.GetDirectoryName(configPath); Dictionary<string, string> scripts = TaskParser.LoadTasks(configPath); if (scripts == null) return root; TaskRunnerNode tasks = new TaskRunnerNode("Commands"); tasks.Description = "Broccoli CLI commands."; root.Children.Add(tasks); foreach (var key in scripts.Keys.OrderBy(k => k)) { TaskRunnerNode task = new TaskRunnerNode(key, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", "/c " + scripts[key]), Description = scripts[key], }; tasks.Children.Add(task); } return root; }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); string workingDirectory = Path.GetDirectoryName(configPath); Dictionary <string, string> scripts = TaskParser.LoadTasks(configPath); if (scripts == null) { return(root); } TaskRunnerNode tasks = new TaskRunnerNode("Scripts"); tasks.Description = "Scripts specified in the \"scripts\" JSON element."; root.Children.Add(tasks); foreach (var key in scripts.Keys.OrderBy(k => k)) { TaskRunnerNode task = new TaskRunnerNode(key, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", "/c " + scripts[key]), Description = scripts[key], }; tasks.Children.Add(task); } return(root); }
private ITaskRunnerNode GetFileType(string configPath, string extension) { var configs = ConfigHandler.GetConfigs(configPath); var types = configs?.Where(c => Path.GetExtension(c.InputFile).Equals(extension, StringComparison.OrdinalIgnoreCase)); if (types == null || !types.Any()) { return(null); } string cwd = Path.GetDirectoryName(configPath); string friendlyName = GetFriendlyName(extension); TaskRunnerNode type = new TaskRunnerNode(friendlyName, true) { Command = GetCommand(cwd, $"\"{configPath}\" *{extension}") }; foreach (var config in types) { TaskRunnerNode child = new TaskRunnerNode(config.InputFile, true) { Command = GetCommand(cwd, $"\"{configPath}\" \"{config.InputFile}\"") }; type.Children.Add(child); } return(type); }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); string workingDirectory = Path.GetDirectoryName(configPath); var scripts = TaskParser.LoadTasks(configPath); Telemetry.TrackEvent("Tasks loaded"); if (scripts == null) { return(root); } TaskRunnerNode tasks = new TaskRunnerNode("Scripts"); tasks.Description = "Scripts specified in the \"scripts\" JSON element."; root.Children.Add(tasks); foreach (string script in scripts) { TaskRunnerNode task = new TaskRunnerNode(script, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", $"/c npm run {script} --color=always"), Description = $"Runs the '{script}' script", }; tasks.Children.Add(task); } return(root); }
public TaskRunnerConfig( ITaskRunnerCommandContext context, IEnumerable <ITaskRunnerNode> nodes, ImageSource icon, string temporaryDirectory) { Context = context; Icon = icon; TaskHierarchy = new TaskRunnerNode("NUKE_ROOT"); TaskHierarchy.Children.AddRange(nodes); if (Directory.Exists(temporaryDirectory)) { _watcher = new FileSystemWatcher(temporaryDirectory, "visual-studio-debug.log") { EnableRaisingEvents = true }; _watcher.Changed += (s, e) => { ThreadHelper.JoinableTaskFactory.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); AttachToBuild(e.FullPath); }); }; } }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); string workingDirectory = Path.GetDirectoryName(configPath); Dictionary<string, string> scripts = TaskParser.LoadTasks(configPath); if (scripts == null) return root; TaskRunnerNode tasks = new TaskRunnerNode("Scripts"); tasks.Description = "Scripts specified in the \"scripts\" JSON element."; root.Children.Add(tasks); foreach (var key in scripts.Keys.OrderBy(k => k)) { TaskRunnerNode task = new TaskRunnerNode(key, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", "/c " + scripts[key]), Description = scripts[key], }; tasks.Children.Add(task); } return root; }
private ITaskRunnerNode LoadHierarchy(string configPath) { string configFileName = Path.GetFileName(configPath); string cwd = Path.GetDirectoryName(configPath); ITaskRunnerNode root = new TaskRunnerNode("Brunch"); // Build TaskRunnerNode build = new TaskRunnerNode("Build", false); TaskRunnerNode buildDev = CreateTask(cwd, "build", "Runs 'brunch build'", "/c brunch build"); build.Children.Add(buildDev); TaskRunnerNode buildProd = CreateTask(cwd, "build production", "Runs 'brunch build --production'", "/c brunch build -p"); build.Children.Add(buildProd); root.Children.Add(build); // Watch TaskRunnerNode watch = new TaskRunnerNode("Watch", false); TaskRunnerNode watchDev = CreateTask(cwd, "watch", "Runs 'brunch watch'", "/c brunch watch"); watch.Children.Add(watchDev); TaskRunnerNode watchProd = CreateTask(cwd, "watch production", "Runs 'brunch watch --production'", "/c brunch watch -p"); watch.Children.Add(watchProd); root.Children.Add(watch); return root; }
private ITaskRunnerNode LoadHierarchy(string configPath) { string configFileName = Path.GetFileName(configPath); string cwd = Path.GetDirectoryName(configPath); Telemetry.TrackEvent(configFileName.ToLowerInvariant()); ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); // Build TaskRunnerNode build = new TaskRunnerNode("Build", false); TaskRunnerNode buildDev = CreateTask(cwd, "build", "Runs 'brunch build'", "/c brunch build"); build.Children.Add(buildDev); TaskRunnerNode buildProd = CreateTask(cwd, "build production", "Runs 'brunch build --production'", "/c brunch build -P"); build.Children.Add(buildProd); root.Children.Add(build); // Watch TaskRunnerNode watch = new TaskRunnerNode("Watch", false); TaskRunnerNode watchDev = CreateTask(cwd, "watch", "Runs 'brunch watch'", "/c brunch watch"); watch.Children.Add(watchDev); TaskRunnerNode watchProd = CreateTask(cwd, "watch production", "Runs 'brunch watch --production'", "/c brunch watch -P"); watch.Children.Add(watchProd); root.Children.Add(watch); return root; }
private ITaskRunnerNode LoadHierarchy(string configPath) { string cwd = Path.GetDirectoryName(configPath); IEnumerable <string> configFiles = GetConfigFileNames(cwd); var rollup = new TaskRunnerNode("Rollup") { Description = "Executes the \"rollup\" command", }; foreach (string config in configFiles) { rollup.Children.Add(new TaskRunnerNode(GenerateTaskName("Rollup", config), true) { Description = $"Execute the \"rollup\" for the {config} configuration file", Command = new TaskRunnerCommand(cwd, "cmd.exe", $"/c rollup -c {config}") }); } var watch = new TaskRunnerNode("Watch") { Description = "Executes the \"rollup -w\" command", }; foreach (string config in configFiles) { watch.Children.Add(new TaskRunnerNode(GenerateTaskName("Watch", config), true) { Description = $"Execute the \"rollup -w\" for the {config} configuration file", Command = new TaskRunnerCommand(cwd, "cmd.exe", $"/c rollup -w -c {config}") }); } return(CreateRoot(rollup, watch)); }
private ITaskRunnerNode LoadHierarchy(string configPath) { string configFileName = Path.GetFileName(configPath); string cwd = Path.GetDirectoryName(configPath); Telemetry.TrackEvent(configFileName.ToLowerInvariant()); ITaskRunnerNode root = new TaskRunnerNode("Brunch"); // Build TaskRunnerNode build = new TaskRunnerNode("Build", false); TaskRunnerNode buildDev = CreateTask(cwd, "build", "Runs 'brunch build'", "/c brunch build"); build.Children.Add(buildDev); TaskRunnerNode buildProd = CreateTask(cwd, "build production", "Runs 'brunch build --production'", "/c brunch build -p"); build.Children.Add(buildProd); root.Children.Add(build); // Watch TaskRunnerNode watch = new TaskRunnerNode("Watch", false); TaskRunnerNode watchDev = CreateTask(cwd, "watch", "Runs 'brunch watch'", "/c brunch watch"); watch.Children.Add(watchDev); TaskRunnerNode watchProd = CreateTask(cwd, "watch production", "Runs 'brunch watch --production'", "/c brunch watch -p"); watch.Children.Add(watchProd); root.Children.Add(watch); return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { string configFileName = Path.GetFileName(configPath); string cwd = Path.GetDirectoryName(configPath); ITaskRunnerNode root = new TaskRunnerNode("WebPack"); const string DEVELOPMENT_TASK_NAME = "Development"; const string PRODUCTION_TASK_NAME = "Production"; // Run TaskRunnerNode build = new TaskRunnerNode("Run", false); TaskRunnerNode buildDev = CreateTask(cwd, $"{build.Name} - {DEVELOPMENT_TASK_NAME}", "Runs 'webpack -d'", "/c SET NODE_ENV=development&& webpack -d --color"); build.Children.Add(buildDev); TaskRunnerNode buildProd = CreateTask(cwd, $"{build.Name} - {PRODUCTION_TASK_NAME}", "Runs 'webpack -p'", "/c SET NODE_ENV=production&& webpack -p --color"); build.Children.Add(buildProd); root.Children.Add(build); // Profile TaskRunnerNode profile = new TaskRunnerNode("Profile", false); TaskRunnerNode profileDev = CreateTask(cwd, $"{profile.Name} - {DEVELOPMENT_TASK_NAME}", "Runs 'webpack -d --profile'", "/c SET NODE_ENV=development&& webpack -d --profile --json > stats.json && echo \x1B[32mThe analyse tool JSON file can be found at ./stats.json. Upload the file at http://webpack.github.io/analyse/."); profile.Children.Add(profileDev); TaskRunnerNode profileProd = CreateTask(cwd, $"{profile.Name} - {PRODUCTION_TASK_NAME}", "Runs 'webpack -p --profile'", "/c SET NODE_ENV=production&& webpack -p --profile --json > stats.json && echo \x1B[32mThe analyse tool JSON file can be found at ./stats.json. Upload the file at http://webpack.github.io/analyse/."); profile.Children.Add(profileProd); root.Children.Add(profile); // Start TaskRunnerNode start = new TaskRunnerNode("Serve", false); TaskRunnerNode startDev = CreateTask(cwd, "Hot", "Runs 'webpack-dev-server --hot'", "/c SET NODE_ENV=development&& webpack-dev-server --hot --color"); start.Children.Add(startDev); TaskRunnerNode startProd = CreateTask(cwd, "Cold", "Runs 'webpack-dev-server'", "/c SET NODE_ENV=development&& webpack-dev-server --color"); start.Children.Add(startProd); root.Children.Add(start); // Watch TaskRunnerNode watch = new TaskRunnerNode("Watch", false); TaskRunnerNode watchDev = CreateTask(cwd, $"{watch.Name} - {DEVELOPMENT_TASK_NAME}", "Runs 'webpack -d --watch'", "/c SET NODE_ENV=development&& webpack -d --watch --color"); watch.Children.Add(watchDev); TaskRunnerNode watchProd = CreateTask(cwd, $"{watch.Name} - {PRODUCTION_TASK_NAME}", "Runs 'webpack -p --watch'", "/c SET NODE_ENV=production&& webpack -p --watch --color"); watch.Children.Add(watchProd); root.Children.Add(watch); return(root); }
private void ApplyOverrides(string configFileName, ITaskRunnerNode parent) { var currentExtensionMatch = Regex.Match(configFileName, "webpack\\.config\\.(?<ext>.+)$"); var currentExtension = currentExtensionMatch.Groups["ext"]; var files = Directory .EnumerateFiles(parent.Command.WorkingDirectory) .Where(f => f.Contains("webpack.") && f.EndsWith($".config.{currentExtension}", StringComparison.OrdinalIgnoreCase)); foreach (string file in files) { string fileName = Path.GetFileName(file); Match match = Regex.Match(fileName, $"webpack\\.(?<env>[^\\.]+)\\.config\\.{currentExtension}"); if (!match.Success) { continue; } var task = new TaskRunnerNode($"config: {match.Groups["env"].Value}", true) { Description = $"Runs '{parent.Name} --config {fileName}'", Command = GetCommand(parent.Command.WorkingDirectory, $"{parent.Command.Args.Replace("webpack ", $"webpack --config {fileName} ")}") }; parent.Children.Add(task); } }
private ITaskRunnerNode LoadHierarchy(string configPath) { var root = new TaskRunnerNode(Vsix.Name); var cwd = Path.GetDirectoryName(configPath); root.Children.Add(new TaskRunnerNode(Resources.Text.TaskUpdateAllFilesName, true) { Description = Resources.Text.TaskUpdateAllFilesDescription.AddParams(Constants.CONFIG_FILENAME), Command = GetCommand(cwd, $"\"{configPath}\"") }); root.Children.Add(new TaskRunnerNode(Resources.Text.TaskCleanOutputFilesName, true) { Description = Resources.Text.TaskCleanOutputFilesDescription, Command = GetCommand(cwd, $"clean \"{configPath}\"") }); var list = new List <ITaskRunnerNode> { GetFileType(configPath, ".js"), GetFileType(configPath, ".css"), GetFileType(configPath, ".html"), GetFileType(configPath, ".htm"), }; root.Children.AddRange(list.Where(i => i != null)); return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); var scripts = TaskParser.LoadTasks(configPath); var hierarchy = GetHierarchy(scripts.Keys); if (hierarchy == null) { return(root); } var defaults = hierarchy.Where(h => Constants.ALL_DEFAULT_TASKS.Contains(h.Key)); TaskRunnerNode defaultTasks = new TaskRunnerNode("Defaults"); defaultTasks.Description = "Default predefined npm commands."; root.Children.Add(defaultTasks); AddCommands(configPath, scripts, defaults, defaultTasks); if (hierarchy.Count != defaults.Count()) { var customs = hierarchy.Except(defaults); TaskRunnerNode customTasks = new TaskRunnerNode("Custom"); customTasks.Description = "Custom npm commands."; root.Children.Add(customTasks); AddCommands(configPath, scripts, customs, customTasks); } Telemetry.TrackEvent("Tasks loaded"); return(root); }
private ITaskRunnerNode GetFileType(string configPath, string extension) { var configs = BundleHandler.GetBundles(configPath); var types = configs?.Where(c => Path.GetExtension(c.OutputFileName).Equals(extension, StringComparison.OrdinalIgnoreCase)); if (types == null || !types.Any()) return null; string cwd = Path.GetDirectoryName(configPath); string friendlyName = GetFriendlyName(extension); TaskRunnerNode type = new TaskRunnerNode(friendlyName, true) { Command = GetCommand(cwd, $"\"{configPath}\" *{extension}") }; foreach (var config in types) { TaskRunnerNode child = new TaskRunnerNode(config.OutputFileName, true) { Command = GetCommand(cwd, $"\"{configPath}\" \"{config.OutputFileName}\"") }; type.Children.Add(child); } return type; }
/// <summary> /// Construct any task hierarchy that you need. /// </summary> ITaskRunnerNode LoadHierarchy(string configPath) { string cwd = Path.GetDirectoryName(configPath); var root = new TaskRunnerNode("My Config"); root.Children.Add(new TaskRunnerNode("TSC watch", true) { Description = "Executes Task 1.", Command = new TaskRunnerCommand(cwd, "tsc", "-p /Users/matt/Projects/Tests/tsc-test3234234 --watch") }); root.Children.Add(new TaskRunnerNode("Task 2", true) { Description = "Executes Task 2.", Command = new TaskRunnerCommand(cwd, "bash", "-c \"echo Task 2\"") }); root.Children.Add(new TaskRunnerNode("Task 3", true) { Description = "Executes Task 3.", Command = new TaskRunnerCommand(cwd, "bash", "-c \"echo Task 3\"") }); return(root); }
private ITaskRunnerNode NotFoundNode(string configPath) { var root = new TaskRunnerNode("Cake"); var message = GettextCatalog.GetString("Could not find Cake.exe in local folder or in PATH"); Logger.Log(message); //CakePackage.Dte.ShowStatusBarText(message); var node = new TaskRunnerNode(GettextCatalog.GetString("Cake.exe not found"), true) { Description = message, Command = new TaskRunnerCommand(Path.GetDirectoryName(configPath), "echo", message), }; root.Children.Add(node); /* * return new TaskRunnerNode("Cake") * { * Children = * { * new TaskRunnerNode("Cake.exe not found", true) * { * Description = message, * Command = new TaskRunnerCommand(Path.GetDirectoryName(configPath), "echo", message), * } * } * }; */ return(root); }
private void AppendCommands(ref ITaskRunnerNode root, string configPath, string name, string description) { string rootDir = Path.GetDirectoryName(configPath); IEnumerable <CommandTask> commands = TaskParser.LoadTasks(configPath); if (commands == null) { return; } var tasks = new TaskRunnerNode(name); tasks.Description = description; root.Children.Add(tasks); foreach (CommandTask command in commands.OrderBy(k => k.Name)) { command.Name = SetVariables(command.Name, rootDir); command.WorkingDirectory = SetVariables(command.WorkingDirectory, rootDir); string cwd = command.WorkingDirectory ?? rootDir; // Add zero width space string commandName = command.Name; var task = new TaskRunnerNode(commandName, true) { Command = new DynamicTaskRunnerCommand(this, rootDir, cwd, command.FileName, command.Arguments), Description = $"Filename:\t {command.FileName}\r\nArguments:\t {command.Arguments}" }; tasks.Children.Add(task); } }
private ITaskRunnerNode LoadHierarchy(string configPath, string userConfigPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); AppendCommands(ref root, configPath, "Commands", "A list of commands to execute"); AppendCommands(ref root, userConfigPath, "User Commands", "A list of user commands to execute"); return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { string configFileName = Path.GetFileName(configPath); string cwd = Path.GetDirectoryName(configPath); Telemetry.TrackEvent(configFileName.ToLowerInvariant()); ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); const string DEVELOPMENT_TASK_NAME = "Development"; const string PRODUCTION_TASK_NAME = "Production"; // Run TaskRunnerNode build = new TaskRunnerNode("Run", false); TaskRunnerNode buildDev = CreateTask(cwd, $"{build.Name} - {DEVELOPMENT_TASK_NAME}", "Runs 'webpack -d'", "/c SET NODE_ENV=development&& webpack -d --colors"); build.Children.Add(buildDev); TaskRunnerNode buildProd = CreateTask(cwd, $"{build.Name} - {PRODUCTION_TASK_NAME}", "Runs 'webpack -p'", "/c SET NODE_ENV=production&& webpack -p --colors"); build.Children.Add(buildProd); root.Children.Add(build); // Profile TaskRunnerNode profile = new TaskRunnerNode("Profile", false); TaskRunnerNode profileDev = CreateTask(cwd, $"{profile.Name} - {DEVELOPMENT_TASK_NAME}", "Runs 'webpack --profile'", "/c SET NODE_ENV=development&& webpack -d --profile --json > stats.json && echo \x1B[32mThe analyse tool JSON file can be found at ./stats.json. Upload the file at http://webpack.github.io/analyse/."); profile.Children.Add(profileDev); TaskRunnerNode profileProd = CreateTask(cwd, $"{profile.Name} - {PRODUCTION_TASK_NAME}", "Runs 'webpack --profile'", "/c SET NODE_ENV=production&& webpack -p --profile --json > stats.json && echo \x1B[32mThe analyse tool JSON file can be found at ./stats.json. Upload the file at http://webpack.github.io/analyse/."); profile.Children.Add(profileProd); root.Children.Add(profile); // Start TaskRunnerNode start = new TaskRunnerNode("Serve", false); TaskRunnerNode startDev = CreateTask(cwd, "Hot", "Runs 'webpack-dev-server --hot'", "/c SET NODE_ENV=development&& webpack-dev-server --hot --colors"); start.Children.Add(startDev); TaskRunnerNode startProd = CreateTask(cwd, "Cold", "Runs 'webpack-dev-server'", "/c SET NODE_ENV=development&& webpack-dev-server --colors"); start.Children.Add(startProd); root.Children.Add(start); // Watch TaskRunnerNode watch = new TaskRunnerNode("Watch", false); TaskRunnerNode watchDev = CreateTask(cwd, $"{watch.Name} - {DEVELOPMENT_TASK_NAME}", "Runs 'webpack -d --watch'", "/c SET NODE_ENV=development&& webpack -d --watch --colors"); watch.Children.Add(watchDev); TaskRunnerNode watchProd = CreateTask(cwd, $"{watch.Name} - {PRODUCTION_TASK_NAME}", "Runs 'webpack -p --watch'", "/c SET NODE_ENV=production&& webpack -p --watch --colors"); watch.Children.Add(watchProd); root.Children.Add(watch); return root; }
private TaskRunnerNode CreateTask(string cwd, string name, string desc, string args) { var task = new TaskRunnerNode(name, true) { Description = desc, Command = GetCommand(cwd, args) }; //ApplyOverrides(task); return(task); }
private TaskRunnerNode CreateRoot(params TaskRunnerNode[] nodes) { var root = new TaskRunnerNode(Vsix.Name); foreach (TaskRunnerNode node in nodes) { var children = node.Children.OrderBy(c => c.Name).ToList(); node.Children.Clear(); node.Children.AddRange(children); root.Children.Add(node); } return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.TASK_CATEGORY); string workingDirectory = Path.GetDirectoryName(configPath); Dictionary <string, string[]> scripts = TaskParser.LoadTasks(configPath); if (scripts == null) { return(root); } TaskRunnerNode tasks = new TaskRunnerNode("Scripts"); tasks.Description = "Scripts specified in the \"scripts\" JSON element."; root.Children.Add(tasks); foreach (var key in scripts.Keys.OrderBy(k => k)) { // Add zero width space string commandName = GenerateCommandName(key);// key + "\u200B"; SetDynamicTaskName(commandName); TaskRunnerNode task = new TaskRunnerNode(commandName, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", "/c " + string.Join(" && ", scripts[key])), Description = string.Join(", ", scripts[key]), }; foreach (string child in scripts[key]) { TaskRunnerNode childTask = new TaskRunnerNode(child, true) { Command = new TaskRunnerCommand(workingDirectory, "cmd.exe", "/c " + child), }; task.Children.Add(childTask); } tasks.Children.Add(task); } return(root); }
private void ApplyOverrides(ITaskRunnerNode parent) { var files = Directory.EnumerateFiles(parent.Command.WorkingDirectory).Where(f => f.Contains(".overrides.")); foreach (string file in files) { int dot = file.LastIndexOf('.'); string name = file.Substring(dot + 1); var task = new TaskRunnerNode($"env: {name}", true) { Description = $"Runs '{parent.Name} --env {name}'", Command = GetCommand(parent.Command.WorkingDirectory, $"{parent.Command.Args} --env {name}") }; parent.Children.Add(task); } }
private ITaskRunnerNode LoadHierarchy(string configPath) { ThreadHelper.ThrowIfNotOnUIThread(); ITaskRunnerNode root = new TaskRunnerNode("Commands"); string rootDir = Path.GetDirectoryName(configPath); IEnumerable <CommandTask> commands = TaskParser.LoadTasks(configPath); if (commands == null) { return(root); } var tasks = new TaskRunnerNode("Commands") { Description = "A list of command to execute" }; root.Children.Add(tasks); foreach (CommandTask command in commands.OrderBy(k => k.TaskName)) { command.Args.ForEach(a => SetVariables(a, rootDir)); command.Command = SetVariables(command.Command, rootDir); command.TaskName = SetVariables(command.TaskName, rootDir); command.EnvVars.VSCMD_START_DIR = SetVariables(command.EnvVars.VSCMD_START_DIR, rootDir); string cwd = command.EnvVars.VSCMD_START_DIR ?? rootDir; // Add zero width space string commandName = command.TaskName += "\u200B"; SetDynamicTaskName(commandName); var task = new TaskRunnerNode(commandName, true) { Command = new TaskRunnerCommand(cwd, command.Command, string.Join(" ", command.Args)), Description = $"Filename:\t {command.Command}\r\nArguments:\t {command.Args}" }; tasks.Children.Add(task); } return(root); }
/// <summary> /// Construct any task hierarchy that you need. /// Task Runner Explorer will automatically have node.exe and npm.cmd on the PATH /// and you can control that in Tools -> Options -> Projects & Solutions -> External Web Tools /// </summary> private ITaskRunnerNode LoadHierarchy(string configPath) { string cwd = Path.GetDirectoryName(configPath); var root = new TaskRunnerNode("My Config"); root.Children.Add(new TaskRunnerNode("Task 1", true) { Description = "Executes Task 1.", Command = new TaskRunnerCommand(cwd, "cmd.exe", "/c echo Task 1") }); root.Children.Add(new TaskRunnerNode("Task 2", true) { Description = "Executes Task 2.", Command = new TaskRunnerCommand(cwd, "cmd.exe", "/c echo Task 2") }); return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { //Custom ITaskRunnerNode root = new TaskRunnerNode("Geoffrey"); string workingDirectory = Path.GetDirectoryName(configPath); foreach (string taskName in Geoffrey.DiscoverTasksIn(configPath)) { string args = @"-NoProfile -NoLogo -NonInteractive -ExecutionPolicy RemoteSigned -Command ""Import-Module '" + Geoffrey.ModulePath + "' 3>$null; Invoke-Geoffrey -scriptPath '" + configPath + "' -taskName " + taskName + @""""; ITaskRunnerNode task = new TaskRunnerNode(taskName, true) { Command = new TaskRunnerCommand(workingDirectory, "powershell.exe", args) }; root.Children.Add(task); } return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { //Custom ITaskRunnerNode root = new TaskRunnerNode("Geoffrey"); string workingDirectory = Path.GetDirectoryName(configPath); foreach (string taskName in Geoffrey.DiscoverTasksIn(configPath)) { string args = @"-NoProfile -NoLogo -NonInteractive -ExecutionPolicy RemoteSigned -Command ""Import-Module '" + Geoffrey.ModulePath + "' 3>$null; Invoke-Geoffrey -scriptPath '" + configPath + "' -taskName " + taskName + @""""; ITaskRunnerNode task = new TaskRunnerNode(taskName, true) { Command = new TaskRunnerCommand(workingDirectory, "powershell.exe", args) }; root.Children.Add(task); } return root; }
ITaskRunnerNode LoadHierarchy(string configPath) { string workingDirectory = Path.GetDirectoryName(configPath); var root = new TaskRunnerNode("TypeScript Task Runner"); root.Children.Add(new TaskRunnerNode("tcs build", true) { Description = "Runs 'tsc build'", Command = new TypeScriptTaskRunnerCommand(workingDirectory) }); root.Children.Add(new TaskRunnerNode("tcs watch", true) { Description = "Runs 'tsc watch'", Command = new TypeScriptTaskRunnerCommand(workingDirectory, isWatch: true) }); return(root); }
async Task <ITaskRunnerNode> LoadHierarchy(string configPath) { string workingDirectory = Path.GetDirectoryName(configPath); var root = new TaskRunnerNode("Grunt Task Runner"); var tasksNode = new TaskRunnerNode(GettextCatalog.GetString("Tasks", false)); root.Children.Add(tasksNode); foreach (GruntTaskInformation task in await GruntCommandRunner.FindGruntTasks(workingDirectory)) { tasksNode.Children.Add(new TaskRunnerNode(task.Name, true) { Description = task.Info, Command = new TaskRunnerCommand(workingDirectory, "grunt", task.Name + " --no-color") }); } return(root); }
private void AddDependencies(TaskRunnerNode uninstallNode, string configPath, string cwd) { var tasks = TaskParser.LoadDependencies(configPath); string allPackages = string.Join(" ", tasks.Values.SelectMany(t => t)); uninstallNode.Command.Args = $"/c npm uninstall {allPackages} --color=always"; foreach (var dep in tasks.Keys) { var depPackages = string.Join(" ", tasks[dep]); var depNode = CreateTask(cwd, dep, $"npm uninstall {depPackages}"); foreach (var package in tasks[dep]) { var child = CreateTask(cwd, $"uninstall {package}", $"npm uninstall {package}"); depNode.Children.Add(child); } uninstallNode.Children.Add(depNode); } }
async Task <ITaskRunnerNode> LoadHierarchy(string configPath) { string workingDirectory = Path.GetDirectoryName(configPath); var root = new TaskRunnerNode("Gulp Task Runner"); var tasksNode = new TaskRunnerNode(GettextCatalog.GetString("Tasks", false)); root.Children.Add(tasksNode); foreach (string task in await GulpCommandRunner.FindGulpTasks(workingDirectory)) { tasksNode.Children.Add(new TaskRunnerNode(task, true) { Description = GettextCatalog.GetString("Runs Gulp task {0}", task), Command = new TaskRunnerCommand(workingDirectory, "gulp", task) }); } return(root); }
private ITaskRunnerNode LoadHierarchy(string configPath) { string configFileName = Path.GetFileName(configPath); string cwd = Path.GetDirectoryName(configPath); ITaskRunnerNode root = new TaskRunnerNode("Cake"); // Build TaskRunnerNode buildDev = CreateTask(cwd, $"Default ({configFileName})", "Runs 'cake build.cake'", configFileName); var tasks = TaskParser.LoadTasks(configPath); var commands = tasks.Select( t => CreateTask(cwd, t.Key, $"Runs {configFileName} with the \"{t.Key}\" target", buildDev.Command.Args + $" {t.Value}")); buildDev.Children.AddRange(commands); root.Children.Add(buildDev); return(root); }
public Task <ITaskRunnerConfig> ParseConfig(ITaskRunnerCommandContext context, string configPath) { var rootDir = Path.GetDirectoryName(configPath); var rootNode = new TaskRunnerNode("VSIX Manifest"); var ipConfigNode = new TaskRunnerNode("IPConfig", true) { Command = new TaskRunnerCommand(rootDir, "ipconfig", "all") }; rootNode.Children.Add(ipConfigNode); var traceNode = new TaskRunnerNode("Trace Route", true) { Command = new TaskRunnerCommand(rootDir, "tracert", "visualstudio.com") }; rootNode.Children.Add(traceNode); var config = new ManifestTaskRunnerConfig(rootNode); return(Task.FromResult <ITaskRunnerConfig>(config)); }
private ITaskRunnerNode LoadHierarchy(string configPath) { var configFileName = Path.GetFileName(configPath); var cwd = Path.GetDirectoryName(configPath); ITaskRunnerNode root = new TaskRunnerNode("Cake"); // Build var buildDev = CreateTask(cwd, $"Default ({configFileName})", "Runs 'cake build.cake'", configFileName); var tasks = TaskParser.LoadTasks(configPath); var commands = tasks.Select( t => CreateTask(cwd, t.Key, $"Runs {configFileName} with the \"{t.Key}\" target", buildDev.Command.Args + $" {t.Value}")); var nodes = commands as IList <TaskRunnerNode> ?? commands.ToList(); buildDev.Children.AddRange(nodes); root.Children.Add(buildDev); CakePackage.Dte.ShowStatusBarText($"Loaded {nodes.Count} tasks from {configFileName}"); return(root); }
private void AddCommands(string configPath, SortedList <string, string> scripts, IEnumerable <KeyValuePair <string, IEnumerable <string> > > commands, TaskRunnerNode tasks) { string cwd = Path.GetDirectoryName(configPath); foreach (var parent in commands) { TaskRunnerNode parentTask = CreateTask(cwd, parent.Key, scripts[parent.Key]); if (parent.Key == "uninstall") { AddDependencies(parentTask, configPath, cwd); } foreach (var child in parent.Value) { TaskRunnerNode childTask = CreateTask(cwd, child, scripts[child]); parentTask.Children.Add(childTask); } tasks.Children.Add(parentTask); } }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.VSIX_NAME); TaskRunnerNode tasks = new TaskRunnerNode("All files", true) { Description = $"Compile all files listed in {Constants.CONFIG_FILENAME}", Command = GetCommand(Path.GetDirectoryName(configPath), $"\"{configPath}\"") }; tasks.Description = $"Compiler configs specified in {Constants.CONFIG_FILENAME}."; root.Children.Add(tasks); var list = new List<ITaskRunnerNode>(); foreach (string ext in WebCompiler.CompilerService.AllowedExtensions) { list.Add(GetFileType(configPath, ext)); } root.Children.AddRange(list.Where(i => i != null)); return root; }
private ITaskRunnerNode LoadHierarchy(string configPath) { ITaskRunnerNode root = new TaskRunnerNode(Constants.VSIX_NAME); TaskRunnerNode tasks = new TaskRunnerNode("All files", true) { Description = $"Bundles all files listed in {Constants.CONFIG_FILENAME}", Command = GetCommand(Path.GetDirectoryName(configPath), $"\"{configPath}\"") }; tasks.Description = $"Bundle configs specified in {Constants.CONFIG_FILENAME}."; root.Children.Add(tasks); var list = new List<ITaskRunnerNode> { GetFileType(configPath, ".js"), GetFileType(configPath, ".css"), GetFileType(configPath, ".html"), GetFileType(configPath, ".htm"), }; root.Children.AddRange(list.Where(i => i != null)); return root; }
private TaskRunnerNode CreateTask(string cwd, string name, string desc, string args) { var task = new TaskRunnerNode(name, true) { Description = desc, Command = GetCommand(cwd, args) }; ApplyOverrides(task); return task; }
private void ApplyOverrides(ITaskRunnerNode parent) { var files = Directory.EnumerateFiles(parent.Command.WorkingDirectory).Where(f => f.Contains("webpack.") && f.EndsWith(".config.js")); foreach (string file in files) { string fileName = Path.GetFileName(file); Match match = Regex.Match(fileName, "webpack\\.(?<env>[^\\.]+)\\.config(\\.babel)?\\.js"); if (!match.Success) continue; var task = new TaskRunnerNode($"config: {match.Groups["env"].Value}", true) { Description = $"Runs '{parent.Name} --config {fileName}'", Command = GetCommand(parent.Command.WorkingDirectory, $"{parent.Command.Args.Replace("webpack ", $"webpack --config {fileName} ")}") }; parent.Children.Add(task); } }