Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions Nodejs/Product/Nodejs/Project/NodeModulesNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,31 +193,15 @@ private bool HasModules {

#region Logging and status bar updates

#if DEV14_OR_LATER
// This is the package manager pane that ships with VS2015, and we should print there if available.
private static readonly Guid VSPackageManagerPaneGuid = new Guid("C7E31C31-1451-4E05-B6BE-D11B6829E8BB");
#else
private static readonly Guid NpmOutputPaneGuid = new Guid("25764421-33B8-4163-BD02-A94E299D52D8");
#endif

private OutputWindowRedirector GetNpmOutputPane() {
try {
#if DEV14_OR_LATER
return OutputWindowRedirector.Get(_projectNode.Site, VSPackageManagerPaneGuid, "Bower/npm");
#else
return OutputWindowRedirector.Get(_projectNode.Site, NpmOutputPaneGuid, SR.GetString(SR.NpmOutputPaneTitle));
#endif
} catch (InvalidOperationException) {
return null;
private OutputWindowRedirector NpmOutputPane {
get {
return _projectNode.NpmOutputPane;
}
}

private void ConditionallyShowNpmOutputPane() {
if (NodejsPackage.Instance.NpmOptionsPage.ShowOutputWindowWhenExecutingNpm) {
var pane = GetNpmOutputPane();
if (null != pane) {
pane.ShowAndActivate();
}
NpmOutputPane?.ShowAndActivate();
}
}

Expand Down Expand Up @@ -300,10 +284,7 @@ private static string TrimLastNewline(string text) {
}

private void WriteNpmLogToOutputWindow(string logText) {
var pane = GetNpmOutputPane();
if (null != pane) {
pane.WriteLine(logText);
}
NpmOutputPane?.WriteLine(logText);

#if INTEGRATE_WITH_ERROR_LIST
WriteNpmErrorsToErrorList(args);
Expand Down
15 changes: 14 additions & 1 deletion Nodejs/Product/Nodejs/Project/NodejsProjectNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void TryToAcquireTypings(IEnumerable<string> packages) {
var typingsPath = Path.Combine(this.ProjectHome, "typings");
bool hadExistingTypingsFolder = Directory.Exists(typingsPath);
TypingsAcquirer
.AcquireTypings(packages, null /*redirector*/)
.AcquireTypings(packages, NpmOutputPane)
.ContinueWith(x => {
if (NodejsPackage.Instance.IntellisenseOptionsPage.ShowTypingsInfoBar &&
x.Result &&
Expand Down Expand Up @@ -1246,5 +1246,18 @@ public override MSBuildResult Build(string config, string target) {
return base.Build(config, target);
}


// This is the package manager pane that ships with VS2015, and we should print there if available.
private static readonly Guid VSPackageManagerPaneGuid = new Guid("C7E31C31-1451-4E05-B6BE-D11B6829E8BB");

internal OutputWindowRedirector NpmOutputPane {
get {
try {
return OutputWindowRedirector.Get(Site, VSPackageManagerPaneGuid, "Bower/npm");
} catch (InvalidOperationException) {
return null;
}
}
}
}
}
13 changes: 7 additions & 6 deletions Nodejs/Product/Nodejs/Project/ProjectResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal class SR : CommonSR {
internal const string NewVersionPackageCatalogNotRetrieved = "NewVersionPackageCatalogNotRetrieved";
internal const string NewVersionUnknown = "NewVersionUnknown";
internal const string NewVersionYes = "NewVersionYes";
internal const string NoKeywordsInPackage = "NoKeywordsInPackage";
internal const string NodeExeArguments = "NodeExeArguments";
internal const string NodeExeArgumentsDescription = "NodeExeArgumentsDescription";
internal const string NodeExeArgumentsToolTip = "NodeExeArgumentsToolTip";
Expand All @@ -87,7 +88,6 @@ internal class SR : CommonSR {
internal const string NodejsPort = "NodejsPort";
internal const string NodejsPortDescription = "NodejsPortDescription";
internal const string NodejsPortToolTip = "NodejsPortToolTip";
internal const string NoKeywordsInPackage = "NoKeywordsInPackage";
internal const string NpmCancelled = "NpmCancelled";
internal const string NpmCancelledWithErrors = "NpmCancelledWithErrors";
internal const string NpmCompletedWithErrors = "NpmCompletedWithErrors";
Expand Down Expand Up @@ -173,8 +173,8 @@ internal class SR : CommonSR {
internal const string ScriptFileToolTip = "ScriptFileTooltip";
internal const string Seconds = "Seconds";
internal const string StartBrowserToolTip = "StartBrowserToolTip";
internal const string StatusAnalysisLoaded = "StatusAnalysisLoaded";
internal const string StatusAnalysisLoadFailed = "StatusAnalysisLoadFailed";
internal const string StatusAnalysisLoaded = "StatusAnalysisLoaded";
internal const string StatusAnalysisLoading = "StatusAnalysisLoading";
internal const string StatusAnalysisSaved = "StatusAnalysisSaved";
internal const string StatusAnalysisSaving = "StatusAnalysisSaving";
Expand All @@ -187,14 +187,15 @@ internal class SR : CommonSR {
internal const string TypingsInfoBarSpan1 = "TypingsInfoBarSpan1";
internal const string TypingsInfoBarSpan2 = "TypingsInfoBarSpan2";
internal const string TypingsInfoBarSpan3 = "TypingsInfoBarSpan3";
internal const string TypingsToolInstallCompleted = "TypingsToolInstallCompleted";
internal const string TypingsToolInstallErrorOccurred = "TypingsToolInstallErrorOccurred";
internal const string TypingsToolNotInstalledError = "TypingsToolNotInstalledError";
internal const string TypingsOpenOptionsText = "TypingsOpenOptionsText";
internal const string TypingsToolCouldNotStart = "TypingsToolCouldNotStart";
internal const string TypingsToolInstallFailed = "TypingsToolInstallFailed";
internal const string TypingsToolNotInstalledError = "TypingsToolNotInstalledError";
internal const string TypingsToolTypingsInstallCompleted = "TypingsToolTypingsInstallCompleted";
internal const string TypingsToolTypingsInstallErrorOccurred = "TypingsToolTypingsInstallErrorOccurred";
internal const string UpgradedEnvironmentVariables = "UpgradedEnvironmentVariables";
internal const string WorkingDirInvalidOrMissing = "WorkingDirInvalidOrMissing";
internal const string WorkingDirToolTip = "WorkingDirToolTip";

private static readonly Lazy<ResourceManager> _manager = new Lazy<ResourceManager>(
() => new System.Resources.ResourceManager("Microsoft.NodejsTools.Resources", typeof(SR).Assembly),
LazyThreadSafetyMode.ExecutionAndPublication
Expand Down
13 changes: 11 additions & 2 deletions Nodejs/Product/Nodejs/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,14 @@ You will need to restart Visual Studio after installation.</value>
<data name="RemoteDebugProxyFolderDoesNotExist" xml:space="preserve">
<value>Could not find RemoteDebugProxyFolder</value>
</data>
<data name="TypingsToolInstallCompleted" xml:space="preserve">
<data name="TypingsToolTypingsInstallCompleted" xml:space="preserve">
<value>Successfully installed typing files for Intellisense.</value>
</data>
<data name="TypingsToolNotInstalledError" xml:space="preserve">
<value>Could not find Typings package manager tool used for Intellisense.</value>
<value>Could not find Typings package manager tool used for Intellisense</value>
</data>
<data name="TypingsToolTypingsInstallErrorOccurred" xml:space="preserve">
<value>An error occurred installing typings used for IntelliSense.</value>
</data>
<data name="TypingsInfoBarSpan1" xml:space="preserve">
<value>Node.js IntelliSense added a </value>
Expand All @@ -639,4 +642,10 @@ You will need to restart Visual Studio after installation.</value>
<data name="StatusTypingsLoading" xml:space="preserve">
<value>Loading Node.js IntelliSense typings for npm packages...</value>
</data>
<data name="TypingsToolInstallFailed" xml:space="preserve">
<value>Failed to install Typings tool used for IntelliSense. Please make sure Node.js is properly installed</value>
</data>
<data name="TypingsToolCouldNotStart" xml:space="preserve">
<value>Could not start Typings tool used for IntelliSense</value>
</data>
</root>
13 changes: 7 additions & 6 deletions Nodejs/Product/Nodejs/TypingsAcquisition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private IEnumerable<string> GetNewTypingsToAcquire(IEnumerable<string> packages)
}

private async Task<bool> ExecuteTypingsTool(IEnumerable<string> arguments, Redirector redirector) {
string typingsTool = await EnsureTypingsToolInstalled();
string typingsTool = await EnsureTypingsToolInstalled(redirector);
if (string.IsNullOrEmpty(typingsTool)) {
redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolNotInstalledError));
return false;
Expand All @@ -129,22 +129,22 @@ private async Task<bool> ExecuteTypingsTool(IEnumerable<string> arguments, Redir
if (!process.IsStarted) {
// Process failed to start, and any exception message has
// already been sent through the redirector
redirector?.WriteErrorLine("could not start 'typings'");
redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolCouldNotStart));
return false;
}
var i = await process;
if (i == 0) {
redirector?.WriteLine(SR.GetString(SR.TypingsToolInstallCompleted));
redirector?.WriteLine(SR.GetString(SR.TypingsToolTypingsInstallCompleted));
return true;
} else {
process.Kill();
redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolInstallErrorOccurred));
redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolTypingsInstallErrorOccurred));
return false;
}
}
}

private async Task<string> EnsureTypingsToolInstalled() {
private async Task<string> EnsureTypingsToolInstalled(Redirector redirector) {
if (File.Exists(TypingsToolPath)) {
return TypingsToolPath;
}
Expand All @@ -153,9 +153,10 @@ private async Task<string> EnsureTypingsToolInstalled() {
return null;
}
if (!await InstallTypingsTool()) {
redirector?.WriteErrorLine(SR.GetString(SR.TypingsToolInstallFailed));
return null;
}
return await EnsureTypingsToolInstalled();
return await EnsureTypingsToolInstalled(redirector);
}

private async Task<bool> InstallTypingsTool() {
Expand Down
17 changes: 4 additions & 13 deletions Nodejs/Product/Npm/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions Nodejs/Product/Npm/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@
<data name="PackagesDownloadedXOfYMB" xml:space="preserve">
<value>Downloaded {0}MB of the package list ({1}MB total)</value>
</data>
<data name="CannotRetrieveLicenseEmptyCollection" xml:space="preserve">
<value>Cannot retrieve license from empty license collection.</value>
</data>
<data name="CannotRetrieveLicenseInvalidIndex" xml:space="preserve">
<value>Cannot retrieve license for index less than 0.</value>
</data>
<data name="ErrCannotStartNpm" xml:space="preserve">
<value>Error executing npm - unable to start the npm process</value>
</data>
Expand Down Expand Up @@ -204,4 +198,7 @@
<value>Semversion {0} for package {1} is invalid</value>
<comment>args: semantic version, package name</comment>
</data>
<data name="CouldNotFindNpm" xml:space="preserve">
<value>Could not find npm. Please make sure Node.js is installed</value>
</data>
</root>
9 changes: 3 additions & 6 deletions Nodejs/Product/Npm/SPI/NpmCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@
//*********************************************************//

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudioTools.Project;
using Microsoft.Win32;

namespace Microsoft.NodejsTools.Npm.SPI {
internal abstract class NpmCommand : AbstractNpmLogSource {
Expand Down Expand Up @@ -78,12 +73,14 @@ public void CancelCurrentTask() {

public virtual async Task<bool> ExecuteAsync() {
OnCommandStarted();
var redirector = new NpmCommandRedirector(this);

try {
GetPathToNpm();
} catch (NpmNotFoundException) {
redirector.WriteErrorLine(Resources.CouldNotFindNpm);
return false;
}
var redirector = new NpmCommandRedirector(this);
redirector.WriteLine(
string.Format("===={0}====\r\n\r\n",
string.Format(Resources.ExecutingCommand, Arguments)));
Expand Down