Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add update-npm script #35822

Merged
merged 1 commit into from Oct 29, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 7 additions & 39 deletions doc/guides/maintaining-npm.md
Expand Up @@ -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"
MylesBorins marked this conversation as resolved.
Show resolved Hide resolved
$ cd ..
```

## Step 5: Update licenses
## Step 3: Update licenses

```console
$ ./configure
Expand All @@ -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
Expand Down
57 changes: 57 additions & 0 deletions tools/update-npm.sh
@@ -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 ""