feat(scripts): sync mobile prototypes using Flutter
feat(scripts): add mobile client and staff prototype sync feat(scripts): use FLUTTER_CMD variable for flutter commands feat(scripts): add FVM support and error handling feat(scripts): patch vite config for relative paths chore(scripts): remove .keep files from mobile prototypes
This commit is contained in:
@@ -6,6 +6,14 @@ POC_REPO_PATH="../client-krow-poc"
|
||||
WEB_POC_SOURCE="$POC_REPO_PATH/prototypes/web/krow_web_application"
|
||||
WEB_DEST="internal/launchpad/prototypes/web"
|
||||
|
||||
MOBILE_CLIENT_SOURCE="$POC_REPO_PATH/prototypes/mobile/client/client_mobile_application"
|
||||
MOBILE_CLIENT_DEST="internal/launchpad/prototypes/mobile/client"
|
||||
MOBILE_CLIENT_HREF="/prototypes/mobile/client/"
|
||||
|
||||
MOBILE_STAFF_SOURCE="$POC_REPO_PATH/prototypes/mobile/staff/staff_mobile_application"
|
||||
MOBILE_STAFF_DEST="internal/launchpad/prototypes/mobile/staff"
|
||||
MOBILE_STAFF_HREF="/prototypes/mobile/staff/"
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
@@ -30,9 +38,33 @@ if [ -d "$WEB_POC_SOURCE" ]; then
|
||||
echo " -> Installing dependencies..."
|
||||
pnpm install --silent
|
||||
|
||||
# Temporarily patch vite.config to enforce relative base path
|
||||
# This is necessary because command line args --base=./ might be ignored by some npm scripts
|
||||
CONFIG_FILE=""
|
||||
if [ -f "vite.config.ts" ]; then CONFIG_FILE="vite.config.ts"; fi
|
||||
if [ -f "vite.config.js" ]; then CONFIG_FILE="vite.config.js"; fi
|
||||
|
||||
if [ -n "$CONFIG_FILE" ]; then
|
||||
echo " -> Patching $CONFIG_FILE for relative paths..."
|
||||
cp "$CONFIG_FILE" "$CONFIG_FILE.bak"
|
||||
# Insert base: './', inside defineConfig({ or export default {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' 's/defineConfig({/defineConfig({ base: "\.\/",/g' "$CONFIG_FILE" || sed -i '' 's/export default {/export default { base: "\.\/",/g' "$CONFIG_FILE"
|
||||
else
|
||||
sed -i 's/defineConfig({/defineConfig({ base: "\.\/",/g' "$CONFIG_FILE" || sed -i 's/export default {/export default { base: "\.\/",/g' "$CONFIG_FILE"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}⚠️ Warning: No vite.config.js/ts found. Build might fail to use relative paths.${NC}"
|
||||
fi
|
||||
|
||||
echo " -> Building dist..."
|
||||
pnpm run build
|
||||
|
||||
# Restore original config
|
||||
if [ -n "$CONFIG_FILE" ]; then
|
||||
mv "$CONFIG_FILE.bak" "$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
# Go back to project root
|
||||
cd - > /dev/null
|
||||
|
||||
@@ -49,8 +81,74 @@ else
|
||||
echo -e "${RED}⚠️ Warning: Web POC source directory not found at $WEB_POC_SOURCE${NC}"
|
||||
fi
|
||||
|
||||
# --- Future: Sync Mobile Prototypes ---
|
||||
# Add logic here when mobile prototypes are ready to be built for web (Flutter Web)
|
||||
# --- Determine Flutter Command ---
|
||||
|
||||
# Helper: Add FVM default to PATH if it exists (fixes Make environment missing user PATH)
|
||||
if [ -d "$HOME/fvm/default/bin" ]; then
|
||||
export PATH="$HOME/fvm/default/bin:$PATH"
|
||||
fi
|
||||
|
||||
if command -v flutter &> /dev/null; then
|
||||
FLUTTER_CMD="flutter"
|
||||
echo -e "${BLUE}ℹ️ Using Flutter: $(which flutter)${NC}"
|
||||
elif command -v fvm &> /dev/null; then
|
||||
FLUTTER_CMD="fvm flutter"
|
||||
echo -e "${BLUE}ℹ️ Using FVM: $FLUTTER_CMD${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Error: 'flutter' command not found. Please ensure Flutter is in your PATH or FVM is configured.${NC}"
|
||||
# Try to provide a helpful hint based on user environment
|
||||
if [ -d "$HOME/fvm/versions" ]; then
|
||||
echo -e "${BLUE}💡 Hint: You seem to have FVM versions. Try running 'fvm global <version>' to set a default.${NC}"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Sync Mobile Client (Flutter) ---
|
||||
echo -e "${BLUE}📱 Building Mobile Client Prototype (Flutter)...${NC}"
|
||||
|
||||
if [ -d "$MOBILE_CLIENT_SOURCE" ]; then
|
||||
cd "$MOBILE_CLIENT_SOURCE"
|
||||
|
||||
echo " -> Getting packages..."
|
||||
$FLUTTER_CMD pub get
|
||||
|
||||
echo " -> Building web bundle (base-href: $MOBILE_CLIENT_HREF)..."
|
||||
$FLUTTER_CMD build web --base-href "$MOBILE_CLIENT_HREF" --release
|
||||
|
||||
cd - > /dev/null
|
||||
|
||||
echo " -> Deploying to Launchpad..."
|
||||
rm -rf "$MOBILE_CLIENT_DEST"/*
|
||||
mkdir -p "$MOBILE_CLIENT_DEST"
|
||||
cp -R "$MOBILE_CLIENT_SOURCE/build/web/"* "$MOBILE_CLIENT_DEST/"
|
||||
|
||||
echo -e "${GREEN}✅ Mobile Client synced successfully.${NC}"
|
||||
else
|
||||
echo -e "${RED}⚠️ Warning: Mobile Client source not found at $MOBILE_CLIENT_SOURCE${NC}"
|
||||
fi
|
||||
|
||||
# --- Sync Mobile Staff (Flutter) ---
|
||||
echo -e "${BLUE}🍳 Building Mobile Staff Prototype (Flutter)...${NC}"
|
||||
if [ -d "$MOBILE_STAFF_SOURCE" ]; then
|
||||
cd "$MOBILE_STAFF_SOURCE"
|
||||
|
||||
echo " -> Getting packages..."
|
||||
$FLUTTER_CMD pub get
|
||||
|
||||
echo " -> Building web bundle (base-href: $MOBILE_STAFF_HREF)..."
|
||||
$FLUTTER_CMD build web --base-href "$MOBILE_STAFF_HREF" --release
|
||||
|
||||
cd - > /dev/null
|
||||
|
||||
echo " -> Deploying to Launchpad..."
|
||||
rm -rf "$MOBILE_STAFF_DEST"/*
|
||||
mkdir -p "$MOBILE_STAFF_DEST"
|
||||
cp -R "$MOBILE_STAFF_SOURCE/build/web/"* "$MOBILE_STAFF_DEST/"
|
||||
|
||||
echo -e "${GREEN}✅ Mobile Staff synced successfully.${NC}"
|
||||
else
|
||||
echo -e "${RED}⚠️ Warning: Mobile Staff source not found at $MOBILE_STAFF_SOURCE${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}🎉 Synchronization complete!${NC}"
|
||||
echo "You can now verify the prototypes in internal/launchpad/prototypes/ and commit the changes."
|
||||
|
||||
Reference in New Issue
Block a user