mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2025-09-05 02:37:43 +08:00
Initial export of the repository
Signed-off-by: Ryan McCue <me@ryanmccue.info>
This commit is contained in:
commit
583d434505
76 changed files with 39023 additions and 0 deletions
69
bin/bundle.sh
Executable file
69
bin/bundle.sh
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash -e
|
||||
#
|
||||
# Create our distribution zips.
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
# Prepare the distribution directory.
|
||||
DIST_DIR="/tmp/fair-dist"
|
||||
[ -d "$DIST_DIR" ] && rm -rf "$DIST_DIR"
|
||||
mkdir "$DIST_DIR"
|
||||
touch /tmp/fair-dist/MD5SUMS
|
||||
touch /tmp/fair-dist/SHA1SUMS
|
||||
touch /tmp/fair-dist/SHA256SUMS
|
||||
touch /tmp/fair-dist/SHA384SUMS
|
||||
|
||||
# Bundle our plugin first.
|
||||
[ -d /tmp/fair-temp ] && rm -rf /tmp/fair-temp
|
||||
mkdir -p /tmp/fair-temp/wordpress/wp-content/plugins/fair
|
||||
rsync -a --exclude-from="$SCRIPT_DIR/../.distignore" "$SCRIPT_DIR/.." /tmp/fair-temp/wordpress/wp-content/plugins/fair
|
||||
|
||||
echo "Fetching WordPress version data" >&2
|
||||
VERSION_DATA=$(curl -s https://api.wordpress.org/core/version-check/1.7/)
|
||||
AVAILABLE_VERSIONS=$(echo "$VERSION_DATA" | jq -r '.offers[] | .version')
|
||||
|
||||
# For each available version, download WP and add our plugin to the WP zip.
|
||||
for VERSION in $AVAILABLE_VERSIONS; do
|
||||
# Skip repeat versions via the API.
|
||||
if [ -f "$DIST_DIR/wordpress-$VERSION-fair.zip" ]; then
|
||||
echo "Skipping $VERSION (already bundled)" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Bundling $VERSION..." >&2
|
||||
# Download the WP zip.
|
||||
WP_ZIP_URL="https://wordpress.org/wordpress-$VERSION.zip"
|
||||
WP_ZIP_FILE="/tmp/fair-temp/wordpress-$VERSION.zip"
|
||||
echo " Downloading $WP_ZIP_URL..." >&2
|
||||
curl -sSL "$WP_ZIP_URL" -o "$WP_ZIP_FILE"
|
||||
EXPECTED_HASH=$(curl -sSL "$WP_ZIP_URL.sha1")
|
||||
|
||||
# Verify the checksum.
|
||||
# (sha1 is suboptimal, but it's all we've got.)
|
||||
echo " Verifying checksum" >&2
|
||||
echo "$EXPECTED_HASH *$WP_ZIP_FILE" | sha1sum -c --status - || { echo "Checksum verification failed!" >&2; exit 1; }
|
||||
|
||||
# Add the plugin into the existing zip.
|
||||
echo " Adding plugin" >&2
|
||||
cd /tmp/fair-temp
|
||||
zip -r /tmp/fair-temp/wordpress-$VERSION.zip wordpress/ >&2
|
||||
cd - > /dev/null
|
||||
|
||||
# Rename altered zip.
|
||||
mv /tmp/fair-temp/wordpress-$VERSION.zip "$DIST_DIR/wordpress-$VERSION-fair.zip"
|
||||
|
||||
# Recalculate hashes.
|
||||
echo " Calculating hashes" >&2
|
||||
cd "$DIST_DIR"
|
||||
md5sum -b "wordpress-$VERSION-fair.zip" >> /tmp/fair-dist/MD5SUMS
|
||||
sha1sum -b "wordpress-$VERSION-fair.zip" >> /tmp/fair-dist/SHA1SUMS
|
||||
sha256sum -b "wordpress-$VERSION-fair.zip" >> /tmp/fair-dist/SHA256SUMS
|
||||
sha384sum -b "wordpress-$VERSION-fair.zip" >> /tmp/fair-dist/SHA384SUMS
|
||||
cd - > /dev/null
|
||||
|
||||
# Output filename.
|
||||
echo $DIST_DIR/wordpress-$VERSION-fair.zip
|
||||
done
|
||||
|
||||
# Clean up.
|
||||
rm -rf /tmp/fair-temp
|
26
bin/update-browsers.sh
Executable file
26
bin/update-browsers.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Update the browser regex in the version check script.
|
||||
#
|
||||
# Uses a browserslist query to generate this data.
|
||||
set -eo pipefail
|
||||
|
||||
BROWSER_QUERY="defaults, unreleased versions"
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
VERSION_CHECK_FOO="$SCRIPT_DIR/../inc/version-check/foo.txt"
|
||||
VERSION_CHECK_FILE="$SCRIPT_DIR/../inc/version-check/namespace.php"
|
||||
|
||||
LINE_START="const BROWSER_REGEX = ";
|
||||
|
||||
echo "Fetching regex for query: '$BROWSER_QUERY'" >&2
|
||||
REGEX=$(npx browserslist-useragent-regexp "$BROWSER_QUERY")
|
||||
echo " $REGEX" >&2
|
||||
|
||||
# Double-escape backslashes.
|
||||
ESCAPED="$(printf '%s\n' "$REGEX" | sed 's/\\/\\\\/g')"
|
||||
|
||||
# Replace the line in the file.
|
||||
echo "Updating $VERSION_CHECK_FILE" >&2
|
||||
sed -i.bak "s#$LINE_START.*#$LINE_START'$ESCAPED';#g" "$VERSION_CHECK_FILE"
|
||||
echo "Updated! (Backup saved to $VERSION_CHECK_FILE.bak)" >&2
|
Loading…
Add table
Add a link
Reference in a new issue