11cb0ef41Sopenharmony_ci#!/bin/sh 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci# Shell script to update undici in the source tree to the latest release. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci# This script must be in the tools directory when it runs because it uses the 61cb0ef41Sopenharmony_ci# script source file path to determine directories to work in. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciset -ex 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciROOT=$(cd "$(dirname "$0")/../.." && pwd) 111cb0ef41Sopenharmony_ci[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" 121cb0ef41Sopenharmony_ci[ -x "$NODE" ] || NODE=$(command -v node) 131cb0ef41Sopenharmony_ciNPM="$ROOT/deps/npm/bin/npm-cli.js" 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciNEW_VERSION=$("$NODE" "$NPM" view undici dist-tags.latest) 161cb0ef41Sopenharmony_ciCURRENT_VERSION=$("$NODE" -p "require('./deps/undici/src/package.json').version") 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciecho "Comparing $NEW_VERSION with $CURRENT_VERSION" 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciif [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then 211cb0ef41Sopenharmony_ci echo "Skipped because Undici is on the latest version." 221cb0ef41Sopenharmony_ci exit 0 231cb0ef41Sopenharmony_cifi 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cicd "$( dirname "$0" )/../.." || exit 261cb0ef41Sopenharmony_cirm -rf deps/undici/src 271cb0ef41Sopenharmony_cirm -f deps/undici/undici.js 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci( 301cb0ef41Sopenharmony_ci rm -rf undici-tmp 311cb0ef41Sopenharmony_ci mkdir undici-tmp 321cb0ef41Sopenharmony_ci cd undici-tmp || exit 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci "$NODE" "$NPM" init --yes 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "undici@$NEW_VERSION" 371cb0ef41Sopenharmony_ci cd node_modules/undici 381cb0ef41Sopenharmony_ci "$NODE" "$NPM" install --no-bin-link --ignore-scripts 391cb0ef41Sopenharmony_ci "$NODE" "$NPM" run build:node 401cb0ef41Sopenharmony_ci "$NODE" "$NPM" prune --production 411cb0ef41Sopenharmony_ci rm node_modules/.package-lock.json 421cb0ef41Sopenharmony_ci) 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci# update version information in src/undici_version.h 451cb0ef41Sopenharmony_cicat > "$ROOT/src/undici_version.h" <<EOF 461cb0ef41Sopenharmony_ci// This is an auto generated file, please do not edit. 471cb0ef41Sopenharmony_ci// Refer to tools/update-undici.sh 481cb0ef41Sopenharmony_ci#ifndef SRC_UNDICI_VERSION_H_ 491cb0ef41Sopenharmony_ci#define SRC_UNDICI_VERSION_H_ 501cb0ef41Sopenharmony_ci#define UNDICI_VERSION "$NEW_VERSION" 511cb0ef41Sopenharmony_ci#endif // SRC_UNDICI_VERSION_H_ 521cb0ef41Sopenharmony_ciEOF 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_cimv undici-tmp/node_modules/undici deps/undici/src 551cb0ef41Sopenharmony_cimv deps/undici/src/undici-fetch.js deps/undici/undici.js 561cb0ef41Sopenharmony_cicp deps/undici/src/LICENSE deps/undici/LICENSE 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_cirm -rf undici-tmp/ 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ciecho "All done!" 611cb0ef41Sopenharmony_ciecho "" 621cb0ef41Sopenharmony_ciecho "Please git add and commit the new version:" 631cb0ef41Sopenharmony_ciecho "" 641cb0ef41Sopenharmony_ciecho "$ git add -A deps/undici src/undici_version.h" 651cb0ef41Sopenharmony_ciecho "$ git commit -m \"deps: update Undici to $NEW_VERSION\"" 661cb0ef41Sopenharmony_ciecho "" 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci# The last line of the script should always print the new version, 691cb0ef41Sopenharmony_ci# as we need to add it to $GITHUB_ENV variable. 701cb0ef41Sopenharmony_ciecho "NEW_VERSION=$NEW_VERSION" 71