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
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ jobs:
- name: Bundle with esbuild
run: npm run bundle

- name: Verify bundle output
shell: bash
run: |
test -f dist-bundle/index.cjs || {
echo "dist-bundle/index.cjs was not produced by npm run bundle"
ls -la dist-bundle || true
exit 1
}

- name: Package binary
run: npx pkg dist-bundle/index.cjs --targets ${{ matrix.target }} --out-path dist --no-bytecode --public

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,28 @@ macOS:

```sh
# Apple Silicon
curl -L https://github.com/devinpearson/ipb/releases/download/v0.9.2/ipb-macos-arm64 -o ipb
curl -L https://github.com/devinpearson/ipb/releases/download/v0.9.3/ipb-macos-arm64 -o ipb
chmod +x ipb
sudo mv ipb /usr/local/bin/

# Intel
curl -L https://github.com/devinpearson/ipb/releases/download/v0.9.2/ipb-macos-x64 -o ipb
curl -L https://github.com/devinpearson/ipb/releases/download/v0.9.3/ipb-macos-x64 -o ipb
chmod +x ipb
sudo mv ipb /usr/local/bin/
```

Linux (.deb):

```sh
wget https://github.com/devinpearson/ipb/releases/download/v0.9.2/ipb_0.9.2_amd64.deb
sudo dpkg -i ipb_0.9.2_amd64.deb
wget https://github.com/devinpearson/ipb/releases/download/v0.9.3/ipb_0.9.3_amd64.deb
sudo dpkg -i ipb_0.9.3_amd64.deb
sudo apt-get install -f
```

Linux binary:

```sh
curl -L https://github.com/devinpearson/ipb/releases/download/v0.9.2/ipb-linux-x64 -o ipb
curl -L https://github.com/devinpearson/ipb/releases/download/v0.9.3/ipb-linux-x64 -o ipb
# or: ipb-linux-arm64
chmod +x ipb
sudo mv ipb /usr/local/bin/
Expand Down
7 changes: 4 additions & 3 deletions esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { promises as fs } from 'node:fs';
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { fileURLToPath, pathToFileURL } from 'node:url';
// esbuild configuration for bundling the CLI application
import { build } from 'esbuild';

Expand Down Expand Up @@ -103,8 +103,9 @@ async function buildApp(options = {}) {
}
}

// Run if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
// Run if called directly (pathToFileURL is required for Windows path matching)
const entryHref = process.argv[1] ? pathToFileURL(process.argv[1]).href : '';
if (import.meta.url === entryHref) {
const args = process.argv.slice(2);
const minify = args.includes('--minify');

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "investec-ipb",
"version": "0.9.2",
"version": "0.9.3",
"main": "bin/index.js",
"bin": {
"ipb": "./bin/index.js"
Expand Down
31 changes: 23 additions & 8 deletions scripts/create-snap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
set -euo pipefail

VERSION=${1:-$(node -p "require('./package.json').version")}
# Strip leading v if present (tags are often v0.9.2)
VERSION=${VERSION#v}
SNAPCRAFT_FILE="snap/snapcraft.yaml"

if [ ! -f "$SNAPCRAFT_FILE" ]; then
Expand All @@ -18,21 +20,34 @@ echo "Creating snap package for IPB v${VERSION}..."
if [ ! -f "dist/ipb-linux-x64" ]; then
echo "Linux binary not found, building first..."
npm run pkg:linux
if [ -f "dist/investec-ipb-linux-x64" ]; then
mv dist/investec-ipb-linux-x64 dist/ipb-linux-x64
elif [ -f "dist/index" ]; then
mv dist/index dist/ipb-linux-x64
fi
chmod +x dist/ipb-linux-x64
fi

TMP_FILE=$(mktemp)
cp "$SNAPCRAFT_FILE" "$TMP_FILE"
# Update version in snapcraft.yaml, restore on exit
ORIGINAL_VERSION=$(sed -n "s/^version: ['\"]\\(.*\\)['\"]/\\1/p" "$SNAPCRAFT_FILE" | head -n 1)
restore_version() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^version: .*/version: '${ORIGINAL_VERSION}'/" "$SNAPCRAFT_FILE"
else
sed -i "s/^version: .*/version: '${ORIGINAL_VERSION}'/" "$SNAPCRAFT_FILE"
fi
}
trap restore_version EXIT

if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^version: .*/version: '${VERSION}'/" "$TMP_FILE"
sed -i '' "s/^version: .*/version: '${VERSION}'/" "$SNAPCRAFT_FILE"
else
sed -i "s/^version: .*/version: '${VERSION}'/" "$TMP_FILE"
sed -i "s/^version: .*/version: '${VERSION}'/" "$SNAPCRAFT_FILE"
fi

echo "Running snapcraft build..."
snapcraft --destructive-mode --project-dir "$(pwd)" --snapcraft-yaml "$TMP_FILE"

rm -f "$TMP_FILE"
echo "Running snapcraft pack (destructive mode)..."
# Modern snapcraft requires `pack`; --snapcraft-yaml/--project-dir were removed.
snapcraft pack --destructive-mode

echo ""
echo "Snap build complete."
Expand Down
4 changes: 2 additions & 2 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ipb
version: '0.8.3'
version: '0.9.3'
summary: CLI application to manage Investec Programmable Banking cards
description: |
A command-line interface for managing and deploying code to Investec
Expand All @@ -19,7 +19,7 @@ base: core24

apps:
ipb:
command: ipb
command: usr/bin/ipb
plugs:
- network
- home
Expand Down