Explorar o código

Replace npm commands with yarn

Nate McMaster %!s(int64=7) %!d(string=hai) anos
pai
achega
5be7d30231

+ 1 - 0
NuGet.config

@@ -9,5 +9,6 @@
     -->
     <add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
     <add key="myget.org aspnetcore-tools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
+    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
   </packageSources>
 </configuration>

+ 2 - 0
build.ps1

@@ -306,6 +306,7 @@ $MSBuildArguments += "/p:TargetOsName=win"
 Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1')
 
 try {
+    $env:KOREBUILD_KEEPGLOBALJSON = 1
     Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $PSScriptRoot -ConfigFile $ConfigFile -CI:$CI
     if ($ForceCoreMsbuild) {
         $global:KoreBuildSettings.MSBuildType = 'core'
@@ -315,4 +316,5 @@ try {
 finally {
     Remove-Module 'KoreBuild' -ErrorAction Ignore
     Remove-Item env:DOTNET_HOME
+    Remove-Item env:KOREBUILD_KEEPGLOBALJSON
 }

+ 1 - 0
build/tasks/RepoTasks.csproj

@@ -14,6 +14,7 @@
     <PackageReference Remove="Internal.AspNetCore.Sdk" />
     <PackageReference Include="NuGet.Build.Tasks" Version="4.9.3" />
     <PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
+    <PackageReference Include="Yarn.MSBuild" Version="1.13.0" />
   </ItemGroup>
 
   <ItemGroup Condition="'$(BuildInstallers)' == 'true' AND '$(TargetOsName)' == 'win'">

+ 10 - 7
eng/targets/Npm.Common.targets

@@ -1,11 +1,15 @@
 <Project DefaultTargets="Build" InitialTargets="_CheckForInvalidConfiguration">
 
+  <!-- Version of this SDK is set in global.json -->
+  <Sdk Name="Yarn.MSBuild" />
+
   <PropertyGroup>
     <NormalizedPackageId>$(PackageId.Replace('@','').Replace('/','-'))</NormalizedPackageId>
     <PackageFileName>$(NormalizedPackageId)-$(PackageVersion).tgz</PackageFileName>
     <PackageJson>$(MSBuildProjectDirectory)\package.json</PackageJson>
     <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(MSBuildProjectDirectory)\obj\</BaseIntermediateOutputPath>
     <IntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(BaseIntermediateOutputPath)'))$(Configuration)\</IntermediateOutputPath>
+    <InstallArgs Condition="'$(RestoreLockedMode)' == 'true'">--frozen-lockfile</InstallArgs>
   </PropertyGroup>
 
   <Target Name="_CheckForInvalidConfiguration">
@@ -13,9 +17,8 @@
   </Target>
 
   <Target Name="Restore">
-    <Message Importance="High" Text="Running npm install on $(MSBuildProjectFullPath)" />
-    <Exec Command="npm ci" Condition="'$(CI)' == 'true'" />
-    <Exec Command="npm install --no-optional" Condition="'$(CI)' != 'true'" />
+    <Message Importance="High" Text="Running yarn install on $(MSBuildProjectFullPath)" />
+    <Yarn Command="install $(InstallArgs)" />
   </Target>
 
   <Target Name="PrepareForBuild">
@@ -28,7 +31,7 @@
   </Target>
 
   <Target Name="Build" DependsOnTargets="PrepareForBuild;ResolveProjectReferences">
-    <Exec Command="npm run build" IgnoreStandardErrorWarningFormat="true" Condition="'$(IsBuildable)' != 'false'" />
+    <Yarn Command="run build" Condition="'$(IsBuildable)' != 'false'" StandardOutputImportance="High" StandardErrorImportance="High" />
   </Target>
 
   <PropertyGroup>
@@ -50,8 +53,8 @@
 
     <Copy SourceFiles="$(PackageJson)" DestinationFiles="$(_BackupPackageJson)" />
 
-    <Exec Command="npm --no-git-tag-version --allow-same-version version $(PackageVersion)" StandardOutputImportance="Normal" StandardErrorImportance="Normal" />
-    <Exec Command="npm pack" StandardOutputImportance="Normal" StandardErrorImportance="Normal" />
+    <Yarn Command="version --no-git-tag-version --new-version $(PackageVersion)" />
+    <Yarn Command="pack --filename $(PackageFileName)" />
 
     <Move SourceFiles="$(_PackageTargetPath)" DestinationFolder="$(PackageOutputPath)" />
     <Message Importance="High" Text="$(MSBuildProjectName) -> $(_PackageTargetPath)" />
@@ -66,7 +69,7 @@
 
   <Target Name="Test" Condition="'$(IsTestProject)' == 'true'">
     <Message Importance="High" Text="Running npm tests for $(MSBuildProjectName)" />
-    <Exec Command="npm $(NpmTestArgs)" IgnoreStandardErrorWarningFormat="true" />
+    <Yarn Command="$(NpmTestArgs)" StandardOutputImportance="High" StandardErrorImportance="High" />
   </Target>
 
 </Project>

+ 1 - 1
global.json

@@ -3,6 +3,6 @@
     "version": "3.0.100-preview-010184"
   },
   "msbuild-sdks": {
-    "Internal.AspNetCore.Sdk": "3.0.0-build-20190219.1"
+    "Yarn.MSBuild": "1.13.0"
   }
 }

+ 2 - 2
src/Components/Browser.JS/src/Microsoft.AspNetCore.Components.Browser.JS.npmproj

@@ -17,8 +17,8 @@
           Inputs="@(WebpackInputs)"
           Outputs="dist\components.webassembly.js;dist\components.server.js">
     <RemoveDir Directories="dist" />
-    <Exec Command="npm run build:debug" Condition="'$(Configuration)' == 'Debug'" />
-    <Exec Command="npm run build:production" Condition="'$(Configuration)' != 'Debug'" />
+    <Yarn Command="run build:debug" Condition="'$(Configuration)' == 'Debug'" />
+    <Yarn Command="run build:production" Condition="'$(Configuration)' != 'Debug'" />
   </Target>
 
 </Project>

+ 1 - 0
src/Components/Browser.JS/src/package.json

@@ -1,5 +1,6 @@
 {
   "name": "microsoft.aspnetcore.components.browser.js",
+  "private": true,
   "version": "0.0.1",
   "description": "",
   "main": "index.js",

+ 6 - 3
src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj

@@ -18,9 +18,12 @@
     <Compile Include="$(SharedSourceRoot)Process\**\*.cs" LinkBase="Shared" />
   </ItemGroup>
 
-  <Target Name="EnsureNpmRestored" BeforeTargets="Build" Condition="!Exists('node_modules') AND '$(BlazorAllTests)'=='true'">
-    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
-    <Exec Command="npm ci" />
+  <!-- Version of this SDK is set in global.json -->
+  <Sdk Name="Yarn.MSBuild" />
+
+  <Target Name="EnsureNodeJSRestored" BeforeTargets="Build" Condition="'$(BlazorAllTests)'=='true'">
+    <Message Text="Running yarn install on $(MSBuildProjectFile)" Importance="High" />
+    <Yarn Command="install" />
   </Target>
 
   <ItemGroup>

+ 1 - 0
src/Components/test/E2ETest/package.json

@@ -3,6 +3,7 @@
   "version": "0.0.1",
   "description": "Not a real package. This file exists only to declare dependencies.",
   "main": "index.js",
+  "private": true,
   "scripts": {
     "selenium-standalone": "selenium-standalone",
     "prepare": "selenium-standalone install"

+ 1 - 1
src/Middleware/CORS/test/FunctionalTests/CORS.FunctionalTests.npmproj

@@ -14,7 +14,7 @@
 
   <Target Name="InstallPuppeteer" BeforeTargets="Restore">
     <!-- Explicitly install puppeteer. This will install the bundled Chromium as part of restore instead of as part of execution -->
-    <Exec Command="npm install puppeteer" />
+    <Yarn Command="add puppeteer" />
   </Target>
 
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />

+ 1 - 0
src/Middleware/CORS/test/FunctionalTests/package.json

@@ -1,4 +1,5 @@
 {
+  "private": true,
   "devDependencies": {
     "jest": "^23.6.0",
     "merge": "^1.2.1",

+ 9 - 2
src/Middleware/NodeServices/src/Microsoft.AspNetCore.NodeServices.csproj

@@ -17,8 +17,15 @@
     <Reference Include="Newtonsoft.Json" />
   </ItemGroup>
 
-  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
-    <Exec Command="npm install" />
+  <!-- Version of this SDK is set in global.json -->
+  <Sdk Name="Yarn.MSBuild" />
+
+  <Target Name="YarnInstall">
+    <Message Text="Running yarn install on $(MSBuildProjectFile)" Importance="High" />
+    <Yarn Command="install" />
+  </Target>
+
+  <Target Name="PrepublishScript" DependsOnTargets="YarnInstall" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
     <Exec Command="node node_modules/webpack/bin/webpack.js" />
   </Target>
 

+ 1 - 0
src/Middleware/NodeServices/src/package.json

@@ -2,6 +2,7 @@
   "name": "nodeservices",
   "version": "1.0.0",
   "description": "This is not really an NPM package and will not be published. This file exists only to reference compilation tools.",
+  "private": true,
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",

+ 9 - 2
src/Middleware/SpaServices/src/Microsoft.AspNetCore.SpaServices.csproj

@@ -20,8 +20,15 @@
     <Reference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" />
   </ItemGroup>
 
-  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
-    <Exec Command="npm install" />
+  <!-- Version of this SDK is set in global.json -->
+  <Sdk Name="Yarn.MSBuild" />
+
+  <Target Name="YarnInstall">
+    <Message Text="Running yarn install on $(MSBuildProjectFile)" Importance="High" />
+    <Yarn Command="install" />
+  </Target>
+
+  <Target Name="PrepublishScript" DependsOnTargets="YarnInstall" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
     <Exec Command="node node_modules/webpack/bin/webpack.js" />
   </Target>
 

+ 1 - 0
src/Middleware/SpaServices/src/package.json

@@ -2,6 +2,7 @@
   "name": "spaservices",
   "version": "1.0.0",
   "description": "This is not really an NPM package and will not be published. This file exists only to reference compilation tools.",
+  "private": true,
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",

+ 6 - 9
src/SignalR/clients/ts/FunctionalTests/SignalR.Npm.FunctionalTests.npmproj

@@ -8,12 +8,10 @@
     <_TestSauceArgs>--verbose --no-color --configuration $(Configuration) --sauce-user "$(SauceUser)" --sauce-key "$(SauceKey)"</_TestSauceArgs>
     <_TestSauceArgs Condition="'$(BrowserTestHostName)' != ''">$(_TestSauceArgs) --use-hostname "$(BrowserTestHostName)"</_TestSauceArgs>
     <NpmTestArgs Condition="'$(DailyTests)' != 'true'">run test:local -- --no-color --configuration $(Configuration)</NpmTestArgs>
-
-
   </PropertyGroup>
 
   <ItemGroup>
-    <ProjectReference Include="FunctionalTests.csproj" Condition="'$(BuildManaged)' != 'false'" />
+    <ProjectReference Include="FunctionalTests.csproj" Condition="'$(BuildManaged)' == 'true'" />
     <ProjectReference Include="..\signalr\signalr.npmproj" />
     <ProjectReference Include="..\signalr-protocol-msgpack\signalr-protocol-msgpack.npmproj" />
   </ItemGroup>
@@ -21,21 +19,20 @@
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
 
   <Target Name="Test" Condition="'$(IsTestProject)' == 'true'">
-    <Message Importance="High" Text="Running npm tests for $(MSBuildProjectName)" />
-    <Exec Condition="'$(DailyTests)' != 'true'" Command="npm $(NpmTestArgs)" IgnoreStandardErrorWarningFormat="true" />
+    <Message Importance="High" Text="Running tests for $(MSBuildProjectName)" />
+    <Yarn Condition="'$(DailyTests)' != 'true'" Command="$(NpmTestArgs)" />
     <CallTarget Condition="'$(DailyTests)' == 'true'" Targets="RunBrowserTests" />
   </Target>
 
   <Target Name="RunBrowserTests">
     <Message Text="Running JavaScript client Browser tests" Importance="high" />
-    <Exec Command="npm run test:inner -- --no-color --configuration $(Configuration)" WorkingDirectory="$(RepositoryRoot)src/SignalR/clients/ts/FunctionalTests" IgnoreStandardErrorWarningFormat="true" />
+    <Yarn Command="run test:inner -- --no-color --configuration $(Configuration)" WorkingDirectory="$(RepositoryRoot)src/SignalR/clients/ts/FunctionalTests" />
     <Message Text="Running JavaScript tests" Importance="high" />
 
     <!-- Skip the "inner" test run when we're running DailyTests -->
-    <Exec Command="npm run test:inner -- --no-color --configuration $(Configuration)"
+    <Yarn Command="run test:inner -- --no-color --configuration $(Configuration)"
           Condition="'$(DailyTests)' != 'true'"
-          WorkingDirectory="$(RepositoryRoot)src/SignalR/clients/ts/FunctionalTests"
-          IgnoreStandardErrorWarningFormat="true" />
+          WorkingDirectory="$(RepositoryRoot)src/SignalR/clients/ts/FunctionalTests" />
 
     <PropertyGroup>
       <BrowserTestHostName Condition="'$(CI)' == 'true'">sauce.local</BrowserTestHostName>

+ 2 - 2
src/SignalR/clients/ts/FunctionalTests/package.json

@@ -5,8 +5,8 @@
   "description": "",
   "main": "index.js",
   "dependencies": {
-    "@aspnet/signalr": "file:../signalr",
-    "@aspnet/signalr-protocol-msgpack": "file:../signalr-protocol-msgpack",
+    "@aspnet/signalr": "link:../signalr",
+    "@aspnet/signalr-protocol-msgpack": "link:../signalr-protocol-msgpack",
     "msgpack5": "^4.0.2"
   },
   "devDependencies": {

+ 4 - 0
src/SignalR/clients/ts/signalr-protocol-msgpack/README.md

@@ -5,6 +5,10 @@ MsgPack support for SignalR for ASP.NET Core
 ```bash
 npm install @aspnet/signalr-protocol-msgpack
 ```
+or
+```bash
+yarn add @aspnet/signalr-protocol-msgpack
+```
 
 ## Usage
 

+ 4 - 0
src/SignalR/clients/ts/signalr/README.md

@@ -5,6 +5,10 @@ JavaScript and TypeScript clients for SignalR for ASP.NET Core
 ```bash
 npm install @aspnet/signalr
 ```
+or
+```bash
+yarn add @aspnet/signalr
+```
 
 ## Usage
 

+ 5 - 5
src/SignalR/clients/ts/signalr/package.json

@@ -39,14 +39,14 @@
     "src/**/*"
   ],
   "devDependencies": {
-    "es6-promise": "^4.2.2",
-    "@types/node": "^10.9.4",
     "@types/eventsource": "^1.0.2",
-    "@types/request": "^2.47.1"
+    "@types/node": "^10.9.4",
+    "@types/request": "^2.47.1",
+    "es6-promise": "^4.2.2"
   },
   "dependencies": {
-    "ws": "^6.0.0",
     "eventsource": "^1.0.7",
-    "request": "^2.88.0"
+    "request": "^2.88.0",
+    "ws": "^6.0.0"
   }
 }

+ 1 - 1
src/SignalR/docs/JSFunctionalTests.md

@@ -13,7 +13,7 @@ Our JavaScript client functional tests are written using [Jasmine](https://jasmi
 
 ### Iterating
 
-The `npm test` command will take a while, because it will build the `clients\ts\signalr`, `clients\ts\signalr-protocol-msgpack` and `clients\ts\FunctionalTests` folders as well as `dotnet build` the `clients\ts\FunctionalTests` folder (to build the server-side components). If you are making changes, it's nice to be able to build only the things you need to build. To skip all the optional build steps, you can run `npm run test:inner` in `clients\ts\FunctionalTests`. This will skip building `clients\ts\signalr` and `clients\signalr-protocol-msgpack` (it will still build the `clients\ts\FunctionalTests` folder). If you make changes to those libraries, you have to manually build those directories.
+The `npm test` command will take a while, because it will build the `clients\ts\signalr`, `clients\ts\signalr-protocol-msgpack` and `clients\ts\FunctionalTests` folders as well as `dotnet build` the `clients\ts\FunctionalTests` folder (to build the server-side components). If you are making changes, it's nice to be able to build only the things you need to build. To skip all the optional build steps, you can run `yarn run test:inner` in `clients\ts\FunctionalTests`. This will skip building `clients\ts\signalr` and `clients\signalr-protocol-msgpack` (it will still build the `clients\ts\FunctionalTests` folder). If you make changes to those libraries, you have to manually build those directories.
 
 ## Running tests from the browser