mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
tools: add update-npm script
I've had to update this one too many times, and much of it can be automated, so let's do that! The maintenance instructions have also been updated. PR-URL: https://github.com/nodejs/node/pull/35822 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
34d6ca3bef
commit
b19a85ed2a
2 files changed
+64
-39
No files matched your search
@@ -10,52 +10,20 @@ are at the discretion of the release and LTS teams.
|
||||
This process only covers full updates to new versions of npm. Cherry-picked
|
||||
changes can be reviewed and landed via the normal consensus seeking process.
|
||||
|
||||
## Step 1: Clone npm
|
||||
## Step 1: Run the update script
|
||||
|
||||
```console
|
||||
$ git clone https://github.com/npm/cli.git npm
|
||||
$ cd npm
|
||||
$ ./tools/update-npm.sh
|
||||
```
|
||||
|
||||
or if you already have npm cloned make sure the repo is up to date
|
||||
## Step 2: Commit new npm
|
||||
|
||||
```console
|
||||
$ git remote update -p
|
||||
$ git reset --hard origin/latest
|
||||
```
|
||||
|
||||
## Step 2: Build release
|
||||
|
||||
```console
|
||||
$ git checkout vX.Y.Z
|
||||
$ make
|
||||
$ make release
|
||||
```
|
||||
|
||||
Note: please run `npm dist-tag ls npm` and make sure this is the `latest`
|
||||
**dist-tag**. `latest` on git is usually released as `next` when it's time to
|
||||
downstream
|
||||
|
||||
## Step 3: Remove old npm
|
||||
|
||||
```console
|
||||
$ cd /path/to/node
|
||||
$ git remote update -p
|
||||
$ git checkout -b npm-x.y.z origin/master
|
||||
$ cd deps
|
||||
$ rm -rf npm
|
||||
```
|
||||
|
||||
## Step 4: Extract and commit new npm
|
||||
|
||||
```console
|
||||
$ tar zxf /path/to/npm/release/npm-x.y.z.tgz
|
||||
$ git add -A npm
|
||||
$ git add -A deps/npm
|
||||
$ git commit -m "deps: upgrade npm to x.y.z"
|
||||
$ cd ..
|
||||
```
|
||||
|
||||
## Step 5: Update licenses
|
||||
## Step 3: Update licenses
|
||||
|
||||
```console
|
||||
$ ./configure
|
||||
@@ -68,13 +36,13 @@ $ git commit -m "doc: update npm LICENSE using license-builder.sh"
|
||||
|
||||
Note: please ensure you are only making the updates that are changed by npm.
|
||||
|
||||
## Step 6: Apply Whitespace fix
|
||||
## Step 4: Apply Whitespace fix
|
||||
|
||||
```console
|
||||
$ git rebase --whitespace=fix master
|
||||
```
|
||||
|
||||
## Step 7: Test the build
|
||||
## Step 5: Test the build
|
||||
|
||||
```console
|
||||
$ make test-npm
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
# Shell script to update npm in the source tree to a specific version
|
||||
|
||||
BASE_DIR="$( pwd )"/
|
||||
DEPS_DIR="$BASE_DIR"deps/
|
||||
NPM_VERSION=$1
|
||||
|
||||
if [ "$#" -le 0 ]; then
|
||||
echo "Error: please provide an npm version to update to"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WORKSPACE="$TMPDIR"update-npm-$NPM_VERSION/
|
||||
|
||||
if [ -d "$WORKSPACE" ]; then
|
||||
echo "Cleaning up old workspace"
|
||||
rm -rf "$WORKSPACE"
|
||||
fi
|
||||
|
||||
echo "Making temporary workspace"
|
||||
|
||||
mkdir -p "$WORKSPACE"
|
||||
|
||||
cd "$WORKSPACE"
|
||||
|
||||
git clone git@github.com:npm/cli.git
|
||||
cd cli
|
||||
|
||||
echo "Preparing npm release"
|
||||
|
||||
git checkout v"$NPM_VERSION"
|
||||
make
|
||||
make release
|
||||
|
||||
echo "Removing old npm"
|
||||
|
||||
cd "$DEPS_DIR"
|
||||
rm -rf npm/
|
||||
|
||||
echo "Copying new npm"
|
||||
|
||||
tar zxf "$WORKSPACE"cli/release/npm-"$NPM_VERSION".tgz
|
||||
|
||||
echo "Deleting temporary workspace"
|
||||
|
||||
rm -rf "$WORKSPACE"
|
||||
|
||||
echo ""
|
||||
echo "All done!"
|
||||
echo ""
|
||||
echo "Please git add npm, commit the new version, and whitespace-fix:"
|
||||
echo ""
|
||||
echo "$ git add -A deps/npm"
|
||||
echo "$ git commit -m \"deps: upgrade npm to $NPM_VERSION\""
|
||||
echo "$ git rebase --whitespace=fix master"
|
||||
echo ""
|
||||
Reference in new issue
Block a user