From 3f1a0535c56ac20710a0a5ced670d56073401af2 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 21 Dec 2018 11:41:03 -0500 Subject: [PATCH 1/2] Bump to latest node-build-update-defs with scripty scripts --- package-lock.json | 8 ++++---- package.json | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f4317f1d..f010d2b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@nodenv/node-build-update-defs": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@nodenv/node-build-update-defs/-/node-build-update-defs-2.7.0.tgz", - "integrity": "sha512-llNo/6VLGIHIEU+tXhznoeZUzSJVWxnNl6/nhunJaeAYuXsYuNwdUxWhaQHNtPJW+nU4jXVW0LQ/RJEtzS+ZXg==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@nodenv/node-build-update-defs/-/node-build-update-defs-2.8.0.tgz", + "integrity": "sha512-gzAFKCo+n83ui1SQCwJHfS9rm3DknC9TEjSdFDKCAZoRQVj3qAIRIP9YQ0QiJpsRJGVoDyB18/AXUTF4Q86oiw==", "dev": true }, "async": { @@ -115,7 +115,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, diff --git a/package.json b/package.json index 39b932ef..bee7380f 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,14 @@ "publish:github": "scripty" }, "devDependencies": { - "@nodenv/node-build-update-defs": "^2.7.0", + "@nodenv/node-build-update-defs": "^2.8.0", "bats": "^0.4.2", "brew-publish": "^2.3.1", "scripty": "^2.0.0-0" + }, + "scripty": { + "modules": [ + "@nodenv/node-build-update-defs" + ] } } From c647f611dceaa26a6530b320896dbdc585236809 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Fri, 21 Dec 2018 11:41:22 -0500 Subject: [PATCH 2/2] Now can use scripts from node-build-update-defs via scripty --- script/submit-definitions | 61 ------------------------- script/verify-definitions | 96 --------------------------------------- 2 files changed, 157 deletions(-) delete mode 100755 script/submit-definitions delete mode 100755 script/verify-definitions diff --git a/script/submit-definitions b/script/submit-definitions deleted file mode 100755 index 688d6fac..00000000 --- a/script/submit-definitions +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash - -# scrapes, commits, pushes, and pull-requests new node definitions -# -# Usage: script/update-nodes [-o ORIGIN] [-r FORK] -# -# Options: -# -o ORIGIN The remote to which the pull-request will be opened. -# [default: origin] -# -r FORK The remote to which scraped definitions will be pushed. -# [default: derived from hub-fork] -# (Empty-string is a shortcut for 'origin': `-r ''`.) -# -# Notes: inspired by https://github.com/jasonkarns/brew-publish - -set -eufo pipefail -IFS=$'\n\t' - -abort() { - echo "$1" >&2 - exit 1 -} - -if ! type -p hub >/dev/null; then - abort "ERROR: You have to install hub to proceed." -fi - -while getopts ":o:r:" opt; do - case $opt in - o) origin="${OPTARG}" ;; - r) fork="${OPTARG:-origin}" ;; - :) abort "Option -$OPTARG requires an argument." ;; - \?) abort "Invalid option: -$OPTARG" ;; - esac -done - -: "${origin:=origin}" -# hackish way of getting the git remote name for user's fork -: "${fork:=$(hub fork 2>&1 | grep -oE 'remote:? \S+' | tail -1 | awk '{print $2}')}" - -# This returns 'HEAD' if in detached HEAD state. Useless in that case. -orig_branch=$(git rev-parse --abbrev-ref HEAD) - -git fetch --quiet --unshallow "$origin" master 2>/dev/null || git fetch --quiet "$origin" master - -git checkout --quiet "$origin"/master - -npm run-script scrape-definitions - -for node_def in $(git ls-files --others --exclude-standard -- share/node-build/); do - node_name="$(basename "$node_def")" - - git checkout --quiet -B "node/$node_name" "$origin"/master - git add -- "$node_def" - git commit --message "$node_name" --message "Created with \`npm run submit-definitions\`." --only -- "$node_def" - git push --set-upstream "$fork" HEAD - hub pull-request --message="$(git log -1 --format='%B')" - git checkout --quiet - -done - -git checkout --quiet "$orig_branch" diff --git a/script/verify-definitions b/script/verify-definitions deleted file mode 100755 index 1f85ab4f..00000000 --- a/script/verify-definitions +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -# Usage: script/verify-definitions (- | -- FILES... | COMMIT_RANGE) -# script/verify-definitions - # verify definition files listed on STDIN -# script/verify-definitions -- foo # verify specific files by name -# script/verify-definitions COMMIT_RANGE # verify definitions modified in COMMIT_RANGE - -set -eufo pipefail -IFS=$'\n\t' - -help_text() { - sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0" -} - -compute_sha2() { - local output - output="$(openssl dgst -sha256)" - echo "${output##* }" | tr '[:upper:]' '[:lower:]' -} - -download_package() { - curl -qsSfL -o "$2" "$1" -} - -download_and_verify() { - local checksum - local url="$1" - local file="$2" - local expected="$3" - download_package "$url" "$file" || return $? - checksum="$(compute_sha2 < "$file")" - if [ "$checksum" != "$expected" ]; then - { - echo "Error: $url doesn't match its checksum:" - echo " expected: $expected" - echo " actual: $checksum" - } >&2 - return 1 - fi -} - -changed_files() { - local commit_range="$1" - git diff --name-only --diff-filter=ACMR "$commit_range" -- ./share/node-build -} - -extract_urls() { - $(type -p ggrep grep | head -1) -hoEe 'http[^"]+#[^"]*' | sort | uniq -} - -verify_files() { - xargs cat | extract_urls -} - -potentially_new_packages() { - local commit_range="$1" - - changed_files "$commit_range" -} - -verify() { - local url checksum file status=0 - while read -r url; do - checksum="${url#*#}" - url="${url%#*}" - echo "Verifying checksum for $url" - file="${TMPDIR:-/tmp}/$checksum" - download_and_verify "$url" "$file" "$checksum" || (( status += 1)) - done < <(xargs cat | extract_urls) - - if [ "$status" != 0 ]; then - echo "failures: $status" - return 1 - fi -} - -case "${1-}" in - '' ) - { echo "COMMIT_RANGE or FILES required" - help_text - } >&2 - exit 1;; - -h | --help ) - help_text - ;; - - ) - verify - ;; - -- ) - echo "$@" | verify - ;; - * ) - echo "Verifying changes from $1" - changed_files "$1" - potentially_new_packages "$1" | verify - ;; -esac