Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,19 @@ load.utils:

############################## ..: COMMANDS pkg.*:.. ################################

.PHONY: pkg.brew.sync
pkg.brew.sync:
@## npm run sync:brew
@echo -e "\n✨ Update Homebrew formula... ⏳\n"
@cd $(NPM_PKG_DIR) && npm run sync:brew

.PHONY: pkg.npm.bump.pptxdiff
pkg.npm.bump.pptxdiff:
@## npm version patch
@echo -e "\n✨ Bumping NPM package version... ⏳\n"
@cd $(NPM_PKG_DIR) && npm version minor --no-git-tag-version

.PHONY: pkg.npm.build
pkg.npm.build:
@## npm run build:npm
@echo -e "\n✨ Building NPM package... ⏳\n"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"pptxdiff": "bin/cli.js"
},
"scripts": {
"sync:brew" : "cd ./src/packages/pptxdiff-brew/ && source ./sync-formula.sh --package pptxdiff --formula Formula/pptxdiff.rb",
"build:npm": "mkdir -p dist && npm pack --pack-destination dist",
"package:vscode": "cd src/packages/pptxdiff-vscode && mkdir -p dist && vsce package --out dist/pptxdiff-vscode-$(node -p \"require('./package.json').version\").vsix"
},
Expand Down
4 changes: 2 additions & 2 deletions src/packages/pptxdiff-brew/Formula/pptxdiff.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Pptxdiff < Formula
desc "Local-first PowerPoint (.pptx) deck diff tool with CLI and browser UI"
homepage "https://github.com/sugatoray/pptxdiff"
url "https://registry.npmjs.org/pptxdiff/-/pptxdiff-0.7.0.tgz"
sha256 "b7bc10ffee012efa1d4914e53b264b338dfbb15dea0714f31c6f664023bff272"
url "https://registry.npmjs.org/pptxdiff/-/pptxdiff-0.8.0.tgz"
sha256 "6bfcb3535d7c9ea3baacbf7e0e506c52fe63c91f00b692f1928eeb5e21e5c35f"
license "Apache-2.0"

livecheck do
Expand Down
2 changes: 1 addition & 1 deletion src/packages/pptxdiff-brew/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pptxdiff-brew",
"version": "0.7.0-20260809",
"version": "0.8.0",
"description": "Homebrew formula packaging for pptxdiff (Formula/pptxdiff.rb) and its version-bump sync tooling (sync-tap.mjs) — not an npm package itself, just a place to run its Red/Green tests.",
"license": "Apache-2.0",
"private": true,
Expand Down
138 changes: 138 additions & 0 deletions src/packages/pptxdiff-brew/sync-formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env bash
# Bumps a Homebrew formula's `url`/`sha256` pin to match a published npm
# package — the shell-script counterpart to sync-tap.mjs. The formula it
# updates lives at `Formula/<package-name>.rb` relative to this script's
# directory.
#
# Usage:
# ./sync-formula.sh [PACKAGE_NAME] [--version x.y.z] [--formula Formula/name.rb]
# ./sync-formula.sh --package PACKAGE_NAME [--version x.y.z]
#
# PACKAGE_NAME npm package to resolve (default: pptxdiff). The formula
# file updated is `Formula/<PACKAGE_NAME>.rb` by default.
# --version pin an exact version; defaults to npm's dist-tags.latest.
# --formula formula path to update; defaults to Formula/<PACKAGE_NAME>.rb.
#
# Exits 0 whether or not a change was made; prints "already up to date" and
# leaves the file untouched when the pin already matches.

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

usage() {
cat >&2 <<EOF
usage: $0 [PACKAGE_NAME] [--version x.y.z] [--formula Formula/name.rb]
$0 --package PACKAGE_NAME [--version x.y.z] [--formula Formula/name.rb]
EOF
}

PACKAGE_NAME="pptxdiff"
VERSION="latest"
FORMULA_FILE=""

while [[ $# -gt 0 ]]; do
case "$1" in
--package)
[[ $# -ge 2 ]] || { echo "error: --package requires a value" >&2; usage; exit 2; }
PACKAGE_NAME="$2"
shift 2
;;
--version)
[[ $# -ge 2 ]] || { echo "error: --version requires a value" >&2; usage; exit 2; }
VERSION="$2"
shift 2
;;
--formula)
[[ $# -ge 2 ]] || { echo "error: --formula requires a value" >&2; usage; exit 2; }
FORMULA_FILE="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
--*)
echo "error: unknown argument: $1" >&2
usage
exit 2
;;
*)
if [[ "$PACKAGE_NAME" != "pptxdiff" ]]; then
echo "error: package name was provided more than once" >&2
usage
exit 2
fi
PACKAGE_NAME="$1"
shift
;;
esac
done

if [[ -z "$FORMULA_FILE" ]]; then
FORMULA_FILE="$SCRIPT_DIR/Formula/$PACKAGE_NAME.rb"
elif [[ "$FORMULA_FILE" != /* ]]; then
FORMULA_FILE="$SCRIPT_DIR/$FORMULA_FILE"
fi

if [[ ! -f "$FORMULA_FILE" ]]; then
echo "error: formula not found: $FORMULA_FILE" >&2
exit 1
fi

command -v npm >/dev/null 2>&1 || { echo "error: npm is required" >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "error: curl is required" >&2; exit 1; }

resolve_version() {
npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null
}

resolve_tarball() {
npm view "$PACKAGE_NAME@$VERSION" dist.tarball 2>/dev/null
}

sha256_of() {
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$1" | awk '{print $1}'
else
sha256sum "$1" | awk '{print $1}'
fi
}

VERSION="$(resolve_version)"
if [[ -z "$VERSION" ]]; then
echo "error: could not resolve a version for $PACKAGE_NAME" >&2
exit 1
fi

TARBALL_URL="$(resolve_tarball)"
if [[ -z "$TARBALL_URL" ]]; then
echo "error: could not resolve a dist.tarball for $PACKAGE_NAME@$VERSION" >&2
exit 1
fi

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

TARBALL_FILE="$TMP_DIR/$PACKAGE_NAME-$VERSION.tgz"
echo "$PACKAGE_NAME@$VERSION: downloading $TARBALL_URL to compute its real sha256..."
curl -fsSL "$TARBALL_URL" -o "$TARBALL_FILE"
SHA256="$(sha256_of "$TARBALL_FILE")"

CURRENT_URL="$(sed -nE 's/^[[:space:]]*url[[:space:]]+"([^"]+)"/\1/p' "$FORMULA_FILE" | head -n1)"
CURRENT_SHA256="$(sed -nE 's/^[[:space:]]*sha256[[:space:]]+"([^"]+)"/\1/p' "$FORMULA_FILE" | head -n1)"

if [[ "$CURRENT_URL" == "$TARBALL_URL" && "$CURRENT_SHA256" == "$SHA256" ]]; then
echo "$FORMULA_FILE is already up to date with $PACKAGE_NAME@$VERSION."
exit 0
fi

sed -i.bak -E \
-e "s|^([[:space:]]*url[[:space:]]+\")[^\"]+|\1$TARBALL_URL|" \
-e "s|^([[:space:]]*sha256[[:space:]]+\")[^\"]+|\1$SHA256|" \
"$FORMULA_FILE"
rm -f "$FORMULA_FILE.bak"

echo "Updated $FORMULA_FILE:"
echo " url: $CURRENT_URL -> $TARBALL_URL"
echo " sha256: $CURRENT_SHA256 -> $SHA256"
4 changes: 2 additions & 2 deletions src/packages/pptxdiff-chocolatey/pptxdiff.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>pptxdiff</id>
<version>0.7.0</version>
<version>0.8.0</version>
<packageSourceUrl>https://github.com/sugatoray/pptxdiff/tree/master/src/packages/pptxdiff-chocolatey</packageSourceUrl>
<owners>sugatoray</owners>

Expand Down Expand Up @@ -61,7 +61,7 @@ See the project README (https://github.com/sugatoray/pptxdiff) and documentation
<releaseNotes>https://github.com/sugatoray/pptxdiff/blob/master/CHANGELOG.md</releaseNotes>

<dependencies>
<dependency id="nodejs" version="18.0.0" />
<dependency id="nodejs" version="[18.0.0,)" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $npmPackageVersion = $env:chocolateyPackageVersion
if ([string]::IsNullOrWhiteSpace($npmPackageVersion)) {
# Fallback for manual `choco pack`/`choco install -s .` runs where Chocolatey
# doesn't set the package-version environment variable (e.g. local testing).
$npmPackageVersion = '0.7.0'
$npmPackageVersion = '0.8.0'
}

$npmCmd = Get-Command npm -ErrorAction SilentlyContinue
Expand Down
Loading