11cb0ef41Sopenharmony_ci#!/bin/sh 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci# Shell script to update minimatch 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 minimatch dist-tags.latest) 161cb0ef41Sopenharmony_ciCURRENT_VERSION=$("$NODE" -p "require('./deps/minimatch/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 minimatch is on the latest version." 221cb0ef41Sopenharmony_ci exit 0 231cb0ef41Sopenharmony_cifi 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cicd "$( dirname "$0" )/../.." || exit 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cirm -rf deps/minimatch/src 281cb0ef41Sopenharmony_cirm -rf deps/minimatch/index.js 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci( 311cb0ef41Sopenharmony_ci rm -rf minimatch-tmp 321cb0ef41Sopenharmony_ci mkdir minimatch-tmp 331cb0ef41Sopenharmony_ci cd minimatch-tmp || exit 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci "$NODE" "$NPM" init --yes 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts "minimatch@$NEW_VERSION" 381cb0ef41Sopenharmony_ci cd node_modules/minimatch 391cb0ef41Sopenharmony_ci "$NODE" "$NPM" exec --package=esbuild@0.17.15 --yes -- esbuild ./dist/cjs/index.js --bundle --platform=node --outfile=minimatch.js 401cb0ef41Sopenharmony_ci) 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_cils -l minimatch-tmp 431cb0ef41Sopenharmony_cimv minimatch-tmp/node_modules/minimatch deps/minimatch/src 441cb0ef41Sopenharmony_cimv deps/minimatch/src/minimatch.js deps/minimatch/index.js 451cb0ef41Sopenharmony_cicp deps/minimatch/src/LICENSE deps/minimatch/LICENSE 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_cirm -rf minimatch-tmp/ 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciecho "All done!" 501cb0ef41Sopenharmony_ciecho "" 511cb0ef41Sopenharmony_ciecho "Please git add minimatch, commit the new version:" 521cb0ef41Sopenharmony_ciecho "" 531cb0ef41Sopenharmony_ciecho "$ git add -A deps/minimatch" 541cb0ef41Sopenharmony_ciecho "$ git commit -m \"deps: update minimatch to $NEW_VERSION\"" 551cb0ef41Sopenharmony_ciecho "" 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci# The last line of the script should always print the new version, 581cb0ef41Sopenharmony_ci# as we need to add it to $GITHUB_ENV variable. 591cb0ef41Sopenharmony_ciecho "NEW_VERSION=$NEW_VERSION" 60