未验证 提交 99898388 编写于 作者: M Marek Fišera 提交者: GitHub

[wasm] Refactor script to load NPM modules for NodeJS on Helix (#65774)

- Refactor script to load NPM modules for NodeJS on Helix to tests.wasm.targets.
- Move NODE_TLS_REJECT_UNAUTHORIZED=0 to LocalEchoServer.props.
上级 96cd39d8
......@@ -252,4 +252,25 @@
RelativePath="%(_PdbFilesToCheck.FileName)%(_PdbFilesToCheck.Extension)" />
</ItemGroup>
</Target>
<Target Name="ProvideNodeNpmRestoreScripts" BeforeTargets="GenerateRunScript">
<!-- Combine optional alias on all NodeNpmModule and trim separator where alias is empty -->
<ItemGroup>
<_NodeNpmModuleString Include="%(NodeNpmModule.Identity):%(NodeNpmModule.Alias)" />
<_NodeNpmModuleStringTrimmed Include="@(_NodeNpmModuleString->Trim(':'))" />
</ItemGroup>
<PropertyGroup>
<NodeNpmModuleString>@(_NodeNpmModuleStringTrimmed, ',')</NodeNpmModuleString>
</PropertyGroup>
<!-- Restore NPM packages -->
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
<SetScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then export WasmXHarnessMonoArgs=&quot;$WasmXHarnessMonoArgs --setenv=NPM_MODULES=$(NodeNpmModuleString)&quot;; fi" />
<RunScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then npm ci; fi" />
</ItemGroup>
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;WasmXHarnessMonoArgs=%WasmXHarnessMonoArgs% --setenv=NPM_MODULES^=$(NodeNpmModuleString)&quot; )" />
<RunScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( call npm ci )" />
</ItemGroup>
</Target>
</Project>
......@@ -15,4 +15,14 @@
<WasmXHarnessArgs>$(WasmXHarnessArgs) --web-server-middleware=$(_RemoteLoopMiddleware)/RemoteLoopServer.dll,GenericHandler</WasmXHarnessArgs>
<WasmXHarnessArgs>$(WasmXHarnessArgs) --web-server-middleware=$(_TestEchoMiddleware)/NetCoreServer.dll,GenericHandler</WasmXHarnessArgs>
</PropertyGroup>
<!-- Tests use self-signed certificates that are refused by NodeJS -->
<Target Name="AcceptUnauthorizedOnNodeJS" BeforeTargets="GenerateRunScript">
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
<SetScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then export NODE_TLS_REJECT_UNAUTHORIZED=0; fi" />
</ItemGroup>
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;NODE_TLS_REJECT_UNAUTHORIZED=0&quot; )" />
</ItemGroup>
</Target>
</Project>
......@@ -30,24 +30,11 @@
<ItemGroup>
<WasmExtraFilesToDeploy Include="package.json" />
<WasmExtraFilesToDeploy Include="package-lock.json" />
</ItemGroup>
<Target Name="ProvideNpmRestoreScripts" BeforeTargets="GenerateRunScript">
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
<!-- WebSocket tests use self-signed certificates for wss protocol that are refused by NodeJS -->
<SetScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then export NODE_TLS_REJECT_UNAUTHORIZED=0; fi" />
<SetScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then export WasmXHarnessMonoArgs=&quot;$WasmXHarnessMonoArgs --setenv=NPM_MODULES=ws:WebSocket,node-fetch,node-abort-controller&quot;; fi" />
<!-- Restore NPM packages -->
<RunScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then npm ci; fi" />
</ItemGroup>
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<!-- WebSocket tests use self-signed certificates for wss protocol that are refused by NodeJS -->
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;NODE_TLS_REJECT_UNAUTHORIZED=0&quot; )" />
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;WasmXHarnessMonoArgs=%WasmXHarnessMonoArgs% --setenv=NPM_MODULES^=ws:WebSocket,node-fetch,node-abort-controller&quot; )" />
<!-- Restore NPM packages -->
<RunScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( call npm ci )" />
</ItemGroup>
</Target>
<NodeNpmModule Include="ws" Alias="WebSocket" />
<NodeNpmModule Include="node-fetch" />
<NodeNpmModule Include="node-abort-controller" />
</ItemGroup>
<Import Condition="'$(TargetOS)' == 'Browser'" Project="$(CommonTestPath)System/Net/Prerequisites/LocalEchoServer.props" />
......
......@@ -18,24 +18,9 @@
<ItemGroup>
<WasmExtraFilesToDeploy Include="package.json" />
<WasmExtraFilesToDeploy Include="package-lock.json" />
</ItemGroup>
<Target Name="ProvideNpmRestoreScripts" BeforeTargets="GenerateRunScript">
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
<!-- WebSocket tests use self-signed certificates for wss protocol that are refused by NodeJS -->
<SetScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then export NODE_TLS_REJECT_UNAUTHORIZED=0; fi" />
<SetScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then export WasmXHarnessMonoArgs=&quot;$WasmXHarnessMonoArgs --setenv=NPM_MODULES=ws:WebSocket&quot;; fi" />
<!-- Restore NPM packages -->
<RunScriptCommands Include="if [[ &quot;$SCENARIO&quot; == &quot;WasmTestOnNodeJs&quot; || &quot;$SCENARIO&quot; == &quot;wasmtestonnodejs&quot; ]]; then npm ci; fi" />
</ItemGroup>
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<!-- WebSocket tests use self-signed certificates for wss protocol that are refused by NodeJS -->
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;NODE_TLS_REJECT_UNAUTHORIZED=0&quot; )" />
<SetScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( set &quot;WasmXHarnessMonoArgs=%WasmXHarnessMonoArgs% --setenv=NPM_MODULES^=ws:WebSocket&quot; )" />
<!-- Restore NPM packages -->
<RunScriptCommands Include="if /I [%SCENARIO%]==[WasmTestOnNodeJS] ( call npm ci )" />
</ItemGroup>
</Target>
<NodeNpmModule Include="ws" Alias="WebSocket" />
</ItemGroup>
<!-- Browser specific files -->
<ItemGroup Condition="'$(TargetOS)' == 'Browser'">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册