소스 검색

node 更新

林财明 4 달 전
부모
커밋
edbee6d65c
8개의 변경된 파일268개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      corepack
  2. 7 0
      corepack.cmd
  3. 55 0
      install_tools.bat
  4. 24 0
      nodevars.bat
  5. 65 0
      npm
  6. 20 0
      npm.cmd
  7. 65 0
      npx
  8. 20 0
      npx.cmd

+ 12 - 0
corepack

@@ -0,0 +1,12 @@
+#!/bin/sh
+basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
+
+case `uname` in
+    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+esac
+
+if [ -x "$basedir/node" ]; then
+  exec "$basedir/node"  "$basedir/node_modules/corepack/dist/corepack.js" "$@"
+else
+  exec node  "$basedir/node_modules/corepack/dist/corepack.js" "$@"
+fi

+ 7 - 0
corepack.cmd

@@ -0,0 +1,7 @@
+@SETLOCAL
+@IF EXIST "%~dp0\node.exe" (
+  "%~dp0\node.exe"  "%~dp0\node_modules\corepack\dist\corepack.js" %*
+) ELSE (
+  @SET PATHEXT=%PATHEXT:;.JS;=;%
+  node  "%~dp0\node_modules\corepack\dist\corepack.js" %*
+)

+ 55 - 0
install_tools.bat

@@ -0,0 +1,55 @@
+@echo off
+
+setlocal
+title Install Additional Tools for Node.js
+
+cls
+
+echo ====================================================
+echo Tools for Node.js Native Modules Installation Script
+echo ====================================================
+echo.
+echo This script will install Python and the Visual Studio Build Tools, necessary
+echo to compile Node.js native modules. Note that Chocolatey and required Windows
+echo updates will also be installed.
+echo.
+echo This will require about 3 GiB of free disk space, plus any space necessary to
+echo install Windows updates. This will take a while to run.
+echo.
+echo Please close all open programs for the duration of the installation. If the
+echo installation fails, please ensure Windows is fully updated, reboot your
+echo computer and try to run this again. This script can be found in the
+echo Start menu under Node.js.
+echo.
+echo You can close this window to stop now. Detailed instructions to install these
+echo tools manually are available at https://github.com/nodejs/node-gyp#on-windows
+echo.
+pause
+
+cls
+
+REM Adapted from https://github.com/Microsoft/windows-dev-box-setup-scripts/blob/79bbe5bdc4867088b3e074f9610932f8e4e192c2/README.md#legal
+echo Using this script downloads third party software
+echo ------------------------------------------------
+echo This script will direct to Chocolatey to install packages. By using
+echo Chocolatey to install a package, you are accepting the license for the
+echo application, executable(s), or other artifacts delivered to your machine as a
+echo result of a Chocolatey install. This acceptance occurs whether you know the
+echo license terms or not. Read and understand the license terms of the packages
+echo being installed and their dependencies prior to installation:
+echo - https://chocolatey.org/packages/chocolatey
+echo - https://chocolatey.org/packages/python
+echo - https://chocolatey.org/packages/visualstudio2019-workload-vctools
+echo.
+echo This script is provided AS-IS without any warranties of any kind
+echo ----------------------------------------------------------------
+echo Chocolatey has implemented security safeguards in their process to help
+echo protect the community from malicious or pirated software, but any use of this
+echo script is at your own risk. Please read the Chocolatey's legal terms of use
+echo as well as how the community repository for Chocolatey.org is maintained.
+echo.
+pause
+
+cls
+
+"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command Start-Process '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -ArgumentList '-NoProfile -InputFormat None -ExecutionPolicy Bypass -Command [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString(''https://chocolatey.org/install.ps1'')); choco upgrade -y python visualstudio2019-workload-vctools; Read-Host ''Type ENTER to exit'' ' -Verb RunAs

+ 24 - 0
nodevars.bat

@@ -0,0 +1,24 @@
+@echo off
+
+rem Ensure this Node.js and npm are first in the PATH
+set "PATH=%APPDATA%\npm;%~dp0;%PATH%"
+
+setlocal enabledelayedexpansion
+pushd "%~dp0"
+
+rem Figure out the Node.js version.
+set print_version=.\node.exe -p -e "process.versions.node + ' (' + process.arch + ')'"
+for /F "usebackq delims=" %%v in (`%print_version%`) do set version=%%v
+
+rem Print message.
+if exist npm.cmd (
+  echo Your environment has been set up for using Node.js !version! and npm.
+) else (
+  echo Your environment has been set up for using Node.js !version!.
+)
+
+popd
+endlocal
+
+rem If we're in the Node.js directory, change to the user's home dir.
+if "%CD%\"=="%~dp0" cd /d "%HOMEDRIVE%%HOMEPATH%"

+ 65 - 0
npm

@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+
+# This is used by the Node.js installer, which expects the cygwin/mingw
+# shell script to already be present in the npm dependency folder.
+
+(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
+
+basedir=`dirname "$0"`
+
+case `uname` in
+  *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+esac
+
+if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
+  IS_WSL="true"
+fi
+
+function no_node_dir {
+  # if this didn't work, then everything else below will fail
+  echo "Could not determine Node.js install directory" >&2
+  exit 1
+}
+
+NODE_EXE="$basedir/node.exe"
+if ! [ -x "$NODE_EXE" ]; then
+  NODE_EXE="$basedir/node"
+fi
+if ! [ -x "$NODE_EXE" ]; then
+  NODE_EXE=node
+fi
+
+# this path is passed to node.exe, so it needs to match whatever
+# kind of paths Node.js thinks it's using, typically win32 paths.
+CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
+if [ $? -ne 0 ]; then
+  # this fails under WSL 1 so add an additional message. we also suppress stderr above
+  # because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
+  # output redirection properly. See https://github.com/microsoft/WSL/issues/2370
+  if [ "$IS_WSL" == "true" ]; then
+    echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
+  fi
+  no_node_dir
+fi
+NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
+NPM_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-cli.js"
+NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
+if [ $? -ne 0 ]; then
+  no_node_dir
+fi
+NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
+
+# a path that will fail -f test on any posix bash
+NPM_WSL_PATH="/.."
+
+# WSL can run Windows binaries, so we have to give it the win32 path
+# however, WSL bash tests against posix paths, so we need to construct that
+# to know if npm is installed globally.
+if [ "$IS_WSL" == "true" ]; then
+  NPM_WSL_PATH=`wslpath "$NPM_PREFIX_NPM_CLI_JS"`
+fi
+if [ -f "$NPM_PREFIX_NPM_CLI_JS" ] || [ -f "$NPM_WSL_PATH" ]; then
+  NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
+fi
+
+"$NODE_EXE" "$NPM_CLI_JS" "$@"

+ 20 - 0
npm.cmd

@@ -0,0 +1,20 @@
+:: Created by npm, please don't edit manually.
+@ECHO OFF
+
+SETLOCAL
+
+SET "NODE_EXE=%~dp0\node.exe"
+IF NOT EXIST "%NODE_EXE%" (
+  SET "NODE_EXE=node"
+)
+
+SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
+SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
+FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
+  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
+)
+IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
+  SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
+)
+
+"%NODE_EXE%" "%NPM_CLI_JS%" %*

+ 65 - 0
npx

@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+
+# This is used by the Node.js installer, which expects the cygwin/mingw
+# shell script to already be present in the npm dependency folder.
+
+(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
+
+basedir=`dirname "$0"`
+
+case `uname` in
+  *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+esac
+
+if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
+  IS_WSL="true"
+fi
+
+function no_node_dir {
+  # if this didn't work, then everything else below will fail
+  echo "Could not determine Node.js install directory" >&2
+  exit 1
+}
+
+NODE_EXE="$basedir/node.exe"
+if ! [ -x "$NODE_EXE" ]; then
+  NODE_EXE="$basedir/node"
+fi
+if ! [ -x "$NODE_EXE" ]; then
+  NODE_EXE=node
+fi
+
+# this path is passed to node.exe, so it needs to match whatever
+# kind of paths Node.js thinks it's using, typically win32 paths.
+CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
+if [ $? -ne 0 ]; then
+  # this fails under WSL 1 so add an additional message. we also suppress stderr above
+  # because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
+  # output redirection properly. See https://github.com/microsoft/WSL/issues/2370
+  if [ "$IS_WSL" == "true" ]; then
+    echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
+  fi
+  no_node_dir
+fi
+NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
+NPX_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npx-cli.js"
+NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
+if [ $? -ne 0 ]; then
+  no_node_dir
+fi
+NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
+
+# a path that will fail -f test on any posix bash
+NPX_WSL_PATH="/.."
+
+# WSL can run Windows binaries, so we have to give it the win32 path
+# however, WSL bash tests against posix paths, so we need to construct that
+# to know if npm is installed globally.
+if [ "$IS_WSL" == "true" ]; then
+  NPX_WSL_PATH=`wslpath "$NPM_PREFIX_NPX_CLI_JS"`
+fi
+if [ -f "$NPM_PREFIX_NPX_CLI_JS" ] || [ -f "$NPX_WSL_PATH" ]; then
+  NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"
+fi
+
+"$NODE_EXE" "$NPX_CLI_JS" "$@"

+ 20 - 0
npx.cmd

@@ -0,0 +1,20 @@
+:: Created by npm, please don't edit manually.
+@ECHO OFF
+
+SETLOCAL
+
+SET "NODE_EXE=%~dp0\node.exe"
+IF NOT EXIST "%NODE_EXE%" (
+  SET "NODE_EXE=node"
+)
+
+SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
+SET "NPX_CLI_JS=%~dp0\node_modules\npm\bin\npx-cli.js"
+FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
+  SET "NPM_PREFIX_NPX_CLI_JS=%%F\node_modules\npm\bin\npx-cli.js"
+)
+IF EXIST "%NPM_PREFIX_NPX_CLI_JS%" (
+  SET "NPX_CLI_JS=%NPM_PREFIX_NPX_CLI_JS%"
+)
+
+"%NODE_EXE%" "%NPX_CLI_JS%" %*