From bd765076b7be03ddd3af25214609c0f107baa28b Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 25 Dec 2022 18:21:44 +0100 Subject: [PATCH 1/2] tools: fix ESLint upgrade automation --- .github/workflows/tools.yml | 5 ++--- tools/{ => dep_updaters}/update-eslint.sh | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) rename tools/{ => dep_updaters}/update-eslint.sh (62%) diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 91156f6c1cfea6..766a1aa6a88b2e 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -21,12 +21,11 @@ jobs: subsystem: tools label: tools run: | - cd tools NEW_VERSION=$(npm view eslint dist-tags.latest) - CURRENT_VERSION=$(node -p "require('./node_modules/eslint/package.json').version") + CURRENT_VERSION=$(node -p "require('./tools/node_modules/eslint/package.json').version") if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - ./update-eslint.sh + ./tools/deps-updater/update-eslint.sh fi - id: corepack subsystem: deps diff --git a/tools/update-eslint.sh b/tools/dep_updaters/update-eslint.sh similarity index 62% rename from tools/update-eslint.sh rename to tools/dep_updaters/update-eslint.sh index 579b63921e1fd5..26dbfcefedc82b 100755 --- a/tools/update-eslint.sh +++ b/tools/dep_updaters/update-eslint.sh @@ -8,30 +8,37 @@ set -ex cd "$( dirname "$0" )" || exit -rm -rf node_modules/eslint +rm -rf ../node_modules/eslint ( rm -rf eslint-tmp mkdir eslint-tmp cd eslint-tmp || exit - ROOT="$PWD/../.." + ROOT="$PWD/../../.." [ -z "$NODE" ] && NODE="$ROOT/out/Release/node" [ -x "$NODE" ] || NODE=$(command -v node) NPM="$ROOT/deps/npm/bin/npm-cli.js" "$NODE" "$NPM" init --yes - "$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts eslint + "$NODE" "$NPM" install --install-strategy=shallow --no-bin-links --ignore-scripts eslint # Uninstall plugins that we want to install so that they are removed from devDependencies. # Otherwise --production will cause them to be skipped. - (cd node_modules/eslint && "$NODE" "$NPM" uninstall --ignore-scripts eslint-plugin-jsdoc eslint-plugin-markdown @babel/core @babel/eslint-parser @babel/plugin-syntax-import-assertions) - (cd node_modules/eslint && "$NODE" "$NPM" install --no-save --no-bin-links --ignore-scripts --production --omit=peer eslint-plugin-jsdoc eslint-plugin-markdown @babel/core @babel/eslint-parser @babel/plugin-syntax-import-assertions) + (cd node_modules/eslint && "$NODE" "$NPM" uninstall --ignore-scripts \ + eslint eslint-config-eslint eslint-plugin-internal-rules eslint-plugin-jsdoc \ + eslint-plugin-markdown @babel/core @babel/eslint-parser \ + @babel/plugin-syntax-import-assertions) + (cd node_modules/eslint && "$NODE" "$NPM" install --no-save --no-bin-links \ + --ignore-scripts --omit=dev --omit=peer \ + eslint-plugin-jsdoc eslint-plugin-markdown @babel/core \ + @babel/eslint-parser @babel/plugin-syntax-import-assertions) # Use dmn to remove some unneeded files. + mkdir -p "$ROOT/out/lib" "$NODE" "$NPM" exec -- dmn@2.2.2 -f clean # TODO: Get this into dmn. find node_modules -name .package-lock.json -exec rm {} \; find node_modules -name 'README*' -exec rm {} \; ) -mv eslint-tmp/node_modules/eslint node_modules/eslint +mv eslint-tmp/node_modules/eslint ../node_modules/eslint rm -rf eslint-tmp/ From b56d4a3cc68488216708a08f410c4499fe25e1fc Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 25 Dec 2022 23:31:13 +0100 Subject: [PATCH 2/2] Update .github/workflows/tools.yml Co-authored-by: mscdex --- .github/workflows/tools.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 766a1aa6a88b2e..ea96c3cd976f83 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -25,7 +25,7 @@ jobs: CURRENT_VERSION=$(node -p "require('./tools/node_modules/eslint/package.json').version") if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - ./tools/deps-updater/update-eslint.sh + ./tools/dep_updaters/update-eslint.sh fi - id: corepack subsystem: deps