orbgen-training / scripts /bundle_kflow.sh
javasop's picture
Upload folder using huggingface_hub
9791706 verified
#!/bin/bash
# Bundle kflow CLI into a single file for distribution
# Run from builder/ directory
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILDER_DIR="$SCRIPT_DIR/../../../../builder"
OUTPUT_DIR="$SCRIPT_DIR/../bin"
echo "Bundling kflow CLI..."
echo "Builder dir: $BUILDER_DIR"
cd "$BUILDER_DIR"
# Ensure dependencies are installed
npm install --workspace=@kflow-builder/compiler --workspace=@kflow-builder/shared
# Build shared first
npm run build:shared
# Bundle kflow CLI with esbuild
mkdir -p "$OUTPUT_DIR"
npx esbuild packages/compiler/src/cli/index.ts \
--bundle \
--platform=node \
--target=node18 \
--outfile="$OUTPUT_DIR/kflow-bundle.js" \
--external:esbuild \
--external:typescript \
--external:@swc/core \
--format=esm \
--sourcemap
# Create wrapper script
cat > "$OUTPUT_DIR/kflow" << 'EOF'
#!/usr/bin/env node
import('./kflow-bundle.js');
EOF
chmod +x "$OUTPUT_DIR/kflow"
echo "Bundle created at: $OUTPUT_DIR/kflow-bundle.js"
echo "Wrapper at: $OUTPUT_DIR/kflow"
# Get size
ls -lh "$OUTPUT_DIR/kflow-bundle.js"