customer-map-codex-bridge 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,85 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ VERSION=${1:-}
5
+ case "$VERSION" in
6
+ ''|*[!0-9.]*)
7
+ printf '%s\n' 'Invalid Codex Bridge version.' >&2
8
+ exit 1
9
+ ;;
10
+ esac
11
+
12
+ NPX_PATH=$(command -v npx || true)
13
+ if [ -z "$NPX_PATH" ]; then
14
+ printf '%s\n' 'Could not find npx on PATH. Install Node.js 18+ first.' >&2
15
+ exit 1
16
+ fi
17
+
18
+ CODEX_PATH=$(command -v codex || true)
19
+ if [ -z "$CODEX_PATH" ]; then
20
+ printf '%s\n' 'Could not find codex on PATH. Install and sign in to Codex CLI first.' >&2
21
+ exit 1
22
+ fi
23
+
24
+ APP_DIR="$HOME/Applications"
25
+ APP_PATH="$APP_DIR/Customer Map Codex Bridge.app"
26
+ SOURCE_PATH=$(mktemp "${TMPDIR:-/tmp}/customer-map-codex-bridge.XXXXXX")
27
+ LOG_DIR="$HOME/Library/Logs/CustomerMapCodexBridge"
28
+ LOG_PATH="$LOG_DIR/bridge.log"
29
+ PACKAGE="customer-map-codex-bridge@$VERSION"
30
+ trap 'rm -f "$SOURCE_PATH"' EXIT
31
+
32
+ escape_applescript_string() {
33
+ printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
34
+ }
35
+
36
+ NPX_APPLESCRIPT=$(escape_applescript_string "$NPX_PATH")
37
+ CODEX_APPLESCRIPT=$(escape_applescript_string "$CODEX_PATH")
38
+ PACKAGE_APPLESCRIPT=$(escape_applescript_string "$PACKAGE")
39
+ LOG_APPLESCRIPT=$(escape_applescript_string "$LOG_PATH")
40
+
41
+ mkdir -p "$APP_DIR" "$LOG_DIR"
42
+ if [ -e "$APP_PATH" ]; then
43
+ osascript -e 'tell application id "com.customermap.codexbridge" to quit' >/dev/null 2>&1 || true
44
+ BACKUP_PATH="$APP_DIR/Customer Map Codex Bridge.backup.$(date +%Y%m%d%H%M%S).app"
45
+ mv "$APP_PATH" "$BACKUP_PATH"
46
+ fi
47
+
48
+ cat > "$SOURCE_PATH" <<EOF
49
+ property npxPath : "$NPX_APPLESCRIPT"
50
+ property codexPath : "$CODEX_APPLESCRIPT"
51
+ property bridgePackage : "$PACKAGE_APPLESCRIPT"
52
+ property logPath : "$LOG_APPLESCRIPT"
53
+
54
+ on run
55
+ end run
56
+
57
+ on open location theUrl
58
+ set commandText to "nohup " & quoted form of npxPath & " -y " & quoted form of bridgePackage & " --codex " & quoted form of codexPath & " --uri " & quoted form of theUrl & " >> " & quoted form of logPath & " 2>&1 < /dev/null &"
59
+ do shell script commandText
60
+ end open location
61
+
62
+ on idle
63
+ return 30
64
+ end idle
65
+ EOF
66
+
67
+ osacompile -s -o "$APP_PATH" "$SOURCE_PATH"
68
+ PLIST="$APP_PATH/Contents/Info.plist"
69
+ /usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string com.customermap.codexbridge" "$PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.customermap.codexbridge" "$PLIST"
70
+ /usr/libexec/PlistBuddy -c "Add :CFBundleDisplayName string Customer Map Codex Bridge" "$PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName Customer Map Codex Bridge" "$PLIST"
71
+ /usr/libexec/PlistBuddy -c "Add :CFBundleShortVersionString string $VERSION" "$PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" "$PLIST"
72
+ /usr/libexec/PlistBuddy -c "Add :CFBundleVersion string $VERSION" "$PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" "$PLIST"
73
+ /usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "$PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :LSUIElement true" "$PLIST"
74
+ /usr/libexec/PlistBuddy -c "Add :CFBundleURLTypes array" "$PLIST"
75
+ /usr/libexec/PlistBuddy -c "Add :CFBundleURLTypes:0 dict" "$PLIST"
76
+ /usr/libexec/PlistBuddy -c "Add :CFBundleURLTypes:0:CFBundleURLName string com.customermap.codexbridge" "$PLIST"
77
+ /usr/libexec/PlistBuddy -c "Add :CFBundleURLTypes:0:CFBundleURLSchemes array" "$PLIST"
78
+ /usr/libexec/PlistBuddy -c "Add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string customer-map-codex" "$PLIST"
79
+
80
+ LSREGISTER='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister'
81
+ "$LSREGISTER" -f "$APP_PATH"
82
+ open -gj "$APP_PATH"
83
+
84
+ printf '%s\n' 'Customer Map Codex click-to-authorize is installed for this macOS account.'
85
+ printf '%s\n' 'Return to Customer Map and click Open Codex authorization again.'
@@ -0,0 +1,43 @@
1
+ param(
2
+ [Parameter(Mandatory = $true)]
3
+ [ValidatePattern('^\d+\.\d+\.\d+$')]
4
+ [string]$Version
5
+ )
6
+
7
+ $ErrorActionPreference = 'Stop'
8
+
9
+ $npxPath = (Get-Command npx.cmd -ErrorAction Stop).Source
10
+ $codexPath = (Get-Command codex.cmd -ErrorAction Stop).Source
11
+ $powershellPath = (Get-Command powershell.exe -ErrorAction Stop).Source
12
+ $installDirectory = Join-Path $env:LOCALAPPDATA 'CustomerMapCodexBridge'
13
+ $launcherPath = Join-Path $installDirectory 'launch.ps1'
14
+ $logPath = Join-Path $installDirectory 'bridge.log'
15
+ $protocolKey = 'HKCU:\Software\Classes\customer-map-codex'
16
+ $commandKey = Join-Path $protocolKey 'shell\open\command'
17
+ $package = "customer-map-codex-bridge@$Version"
18
+
19
+ New-Item -ItemType Directory -Path $installDirectory -Force | Out-Null
20
+
21
+ $launcher = @"
22
+ param(
23
+ [Parameter(Mandatory = `$true, Position = 0)]
24
+ [string]`$Uri
25
+ )
26
+
27
+ `$ErrorActionPreference = 'Stop'
28
+ `$logDirectory = '$($installDirectory.Replace("'", "''"))'
29
+ `$logPath = '$($logPath.Replace("'", "''"))'
30
+ New-Item -ItemType Directory -Path `$logDirectory -Force | Out-Null
31
+ & '$($npxPath.Replace("'", "''"))' '-y' '$package' '--codex' '$($codexPath.Replace("'", "''"))' '--uri' `$Uri *>> `$logPath
32
+ exit `$LASTEXITCODE
33
+ "@
34
+
35
+ Set-Content -LiteralPath $launcherPath -Value $launcher -Encoding UTF8
36
+
37
+ New-Item -Path $commandKey -Force | Out-Null
38
+ Set-ItemProperty -Path $protocolKey -Name '(default)' -Value 'URL:Customer Map Codex Bridge'
39
+ Set-ItemProperty -Path $protocolKey -Name 'URL Protocol' -Value ''
40
+ Set-ItemProperty -Path $commandKey -Name '(default)' -Value ('"{0}" -NoLogo -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "{1}" "%1"' -f $powershellPath, $launcherPath)
41
+
42
+ Write-Host 'Customer Map Codex click-to-authorize is installed for this Windows account.'
43
+ Write-Host 'Return to Customer Map and click Open Codex authorization again.'