-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: remove npm install from acorn update #50473
Merged
nodejs-github-bot
merged 4 commits into
nodejs:main
from
marco-ippolito:feat/remove-npm-i
Nov 5, 2023
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,36 +7,53 @@ | |
|
||
set -ex | ||
|
||
ROOT=$(cd "$(dirname "$0")/../.." && pwd) | ||
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" | ||
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) | ||
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node" | ||
[ -x "$NODE" ] || NODE=$(command -v node) | ||
NPM="$ROOT/deps/npm/bin/npm-cli.js" | ||
NPM="$BASE_DIR/deps/npm/bin/npm-cli.js" | ||
DEPS_DIR="$BASE_DIR/deps" | ||
|
||
# shellcheck disable=SC1091 | ||
. "$ROOT/tools/dep_updaters/utils.sh" | ||
. "$BASE_DIR/tools/dep_updaters/utils.sh" | ||
|
||
NEW_VERSION=$("$NODE" "$NPM" view acorn dist-tags.latest) | ||
CURRENT_VERSION=$("$NODE" -p "require('./deps/acorn/acorn/package.json').version") | ||
CURRENT_VERSION=$("$NODE" "$NPM" --prefix './deps/acorn/acorn/' pkg get version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
|
||
# This function exit with 0 if new version and current version are the same | ||
compare_dependency_version "acorn" "$NEW_VERSION" "$CURRENT_VERSION" | ||
|
||
cd "$( dirname "$0" )/../.." || exit | ||
|
||
rm -rf deps/acorn/acorn | ||
echo "Making temporary workspace..." | ||
|
||
( | ||
rm -rf acorn-tmp | ||
mkdir acorn-tmp | ||
cd acorn-tmp || exit | ||
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') | ||
|
||
"$NODE" "$NPM" init --yes | ||
cleanup () { | ||
EXIT_CODE=$? | ||
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" | ||
exit $EXIT_CODE | ||
} | ||
|
||
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "acorn@$NEW_VERSION" | ||
) | ||
trap cleanup INT TERM EXIT | ||
|
||
cd "$WORKSPACE" | ||
|
||
echo "Fetching acorn source archive..." | ||
|
||
"$NODE" "$NPM" pack "acorn@$NEW_VERSION" | ||
|
||
ACORN_TGZ="acorn-$NEW_VERSION.tgz" | ||
|
||
log_and_verify_sha256sum "acorn" "$ACORN_TGZ" | ||
|
||
rm -r "$DEPS_DIR/acorn/acorn"/* | ||
|
||
tar -xf "$ACORN_TGZ" | ||
|
||
mv package/* "$DEPS_DIR/acorn/acorn" | ||
|
||
# update version information in src/acorn_version.h | ||
cat > "$ROOT/src/acorn_version.h" <<EOF | ||
cat > "$BASE_DIR/src/acorn_version.h" <<EOF | ||
// This is an auto generated file, please do not edit. | ||
// Refer to tools/dep_updaters/update-acorn.sh | ||
#ifndef SRC_ACORN_VERSION_H_ | ||
|
@@ -45,9 +62,14 @@ cat > "$ROOT/src/acorn_version.h" <<EOF | |
#endif // SRC_ACORN_VERSION_H_ | ||
EOF | ||
|
||
mv acorn-tmp/node_modules/acorn deps/acorn | ||
|
||
rm -rf acorn-tmp/ | ||
echo "All done!" | ||
echo "" | ||
echo "Please git add acorn, commit the new version:" | ||
echo "" | ||
echo "$ git add -A deps/acorn/acorn" | ||
echo "$ git add $BASE_DIR/src/acorn_version.h" | ||
echo "$ git commit -m \"deps: update acorn to $NEW_VERSION\"" | ||
echo "" | ||
|
||
# Update the version number on maintaining-dependencies.md | ||
# and print the new version as the last line of the script as we need | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this? Using npm seems overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a particular reason, it feels more clean since its npm pkg get does exactly that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the original one and it's faster.