/// <summary> /// Parses XML from WizardData and installs required npm packages /// </summary> /// <example> /// <![CDATA[ /// <NodeJS> /// <npm-package id="grunt"/> /// <npm-package id="grunt-cli" /> /// <npm-package id="gulp" /> /// <npm-package id="bower" /> /// </NodeJS>]]> /// </example> /// <param name="automationObject"></param> /// <param name="replacementsDictionary"></param> /// <param name="runKind"></param> /// <param name="customParams"></param> public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { _dte = (DTE)automationObject; using (var serviceProvider = new ServiceProvider((IServiceProvider)automationObject)) { var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); using (var container = new CompositionContainer(componentModel.DefaultExportProvider)) { container.ComposeParts(this); } } var wizardData = replacementsDictionary["$wizarddata$"]; //HACK WizardData looks like root node, but not passed to this arg so we wrap it. //Problem is that only one SHARED WizardData node is supported and multiple wizards might use it. var element = XElement.Parse("<WizardData>" + wizardData + "</WizardData>"); _npmPackages = element.Descendants() .Where(x => x.Name.LocalName.EqualsIgnoreCase("npm-package")) .Select(x => new NpmPackage { Id = x.Attribute("id").Value }) .ToList(); if (NodePackageUtils.TryRegisterNpmFromDefaultLocation()) { if (!NodePackageUtils.HasBowerOnPath()) { UpdateStatusMessage("Installing bower..."); NodePackageUtils.InstallNpmPackageGlobally("bower"); } } }
/// <summary> /// Parses XML from WizardData and installs required npm packages /// </summary> /// <example> /// <![CDATA[ /// <NodeJS> /// <npm-package id="grunt"/> /// <npm-package id="grunt-cli" /> /// <npm-package id="gulp" /> /// <npm-package id="bower" /> /// </NodeJS>]]> /// </example> /// <param name="automationObject"></param> /// <param name="replacementsDictionary"></param> /// <param name="runKind"></param> /// <param name="customParams"></param> public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = (DTE)automationObject; string wizardData = replacementsDictionary["$wizarddata$"]; //HACK WizardData looks like root node, but not passed to this arg so we wrap it. //Problem is that only one SHARED WizardData node is supported and multiple extensions might use it. XElement element = XElement.Parse("<WizardData>" + wizardData + "</WizardData>"); npmPackages = element.Descendants() .Where(x => x.Name.LocalName.EqualsIgnoreCase("npm-package")) .Select(x => new NpmPackage { Id = x.Attribute("id").Value }) .ToList(); if (NodePackageUtils.TryRegisterNpmFromDefaultLocation()) { if (!NodePackageUtils.HasBowerOnPath()) { UpdateStatusMessage("Installing bower..."); NodePackageUtils.InstallNpmPackageGlobally("bower"); } } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { if (runKind == WizardRunKind.AsMultiProject) { if (!NodePackageUtils.TryRegisterNpmFromDefaultLocation()) { var form = new NodeJSInstallationPrompt(); form.ShowDialog(); if (!form.NodeFoundOnPath) { //Advise to restart VS and backout? throw new WizardBackoutException("Node.js installation required"); } } } }