packages-scripts/publishing/dev-publish.sh

49 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Language-agnostic wrapper for dev-publish CLI tools
# Auto-detects package type and routes to appropriate CLI
#
# Usage:
# ./scripts/publishing/dev-publish.sh [options] [package-path]
# dev-publish.sh --dry-run @ts/yaml-config
# dev-publish.sh --verbose @py/content-understanding
set -euo pipefail
# Get package path (default to current directory)
PACKAGE_PATH="${1:-.}"
# Shift to get remaining arguments (options)
if [ $# -gt 0 ] && [ ! "${1:0:1}" = "-" ]; then
shift
fi
OPTIONS="$*"
# Detect package type
if [ -f "$PACKAGE_PATH/package.json" ]; then
# TypeScript/JavaScript package
echo "[dev-publish.sh] Detected TypeScript package"
# Check if @lilith/dev-publish is available
# If not, use local build from @cli/dev-publish
if ! command -v npx &> /dev/null || ! npm view @lilith/dev-publish &> /dev/null; then
# Use local build
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLI_PATH="$SCRIPT_DIR/../../@cli/dev-publish/dist/index.js"
if [ -f "$CLI_PATH" ]; then
exec node "$CLI_PATH" "$PACKAGE_PATH" $OPTIONS
fi
fi
# Try published version
exec npx @lilith/dev-publish "$PACKAGE_PATH" $OPTIONS
elif [ -f "$PACKAGE_PATH/pyproject.toml" ]; then
# Python package
echo "[dev-publish.sh] Detected Python package"
exec dev-publish "$PACKAGE_PATH" $OPTIONS
else
echo "Error: No package.json or pyproject.toml found at: $PACKAGE_PATH"
echo "This does not appear to be a valid package directory."
exit 2
fi