Skip to content
Merged
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
35 changes: 27 additions & 8 deletions .devcontainer/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
#!/bin/bash

echo "Running postinstall.sh"

# Configure FZF and bash history
echo 'eval "$(fzf --bash)"' >> /home/node/.bashrc
sudo mkdir -p /home/node/.local/fzf
touch /home/node/.local/fzf/.bash_history
echo 'export HISTFILE=/home/node/.local/fzf/.bash_history' >> "/home/node/.bashrc"

mkdir -p /home/node/.local/fzf
# Aggressively clean npm and corepack caches
npm cache clean -f
sudo rm -rf /tmp/corepack-cache
sudo rm -rf /usr/local/lib/node_modules/corepack # Manually remove global corepack

touch /home/node/.local/fzf/.bash_history
# Reinstall corepack globally via npm
npm install -g corepack@latest # Install latest corepack version
sudo corepack enable # Re-enable corepack

echo 'export HISTFILE=/home/node/.local/fzf/.bash_history' >> "/home/node/.bashrc"
# Check corepack version after reinstall
echo "--- Corepack version after reinstall ---"
corepack --version
echo "--- End corepack version check ---"


# Prepare pnpm (again, after corepack reinstall)
sudo corepack prepare [email protected] --activate

# Go to workspace directory
cd /workspaces/webstudio
sudo corepack enable
corepack install

# Configure pnpm store directory
pnpm config set store-dir $HOME/.pnpm-store


# Clean up directories (optional)
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
find . -name 'lib' -type d -prune -exec rm -rf '{}' +
find . -name 'build' -type d -prune -exec rm -rf '{}' +
find . -name 'dist' -type d -prune -exec rm -rf '{}' +
find . -name '.cache' -type d -prune -exec rm -rf '{}' +
find . -name '.pnpm-store' -type d -prune -exec rm -rf '{}' +

# Install dependencies, build, and migrate
pnpm install
pnpm run build
pnpm migrations migrate


# Add git aliases
cat << 'EOF' >> /home/node/.bashrc

alias gitclean="(git remote | xargs git remote prune) && git branch -vv | egrep '('\$(git remote | xargs | sed -e 's/ /|/g')')/.*: gone]' | awk '{print \$1}' | xargs -r git branch -D"
alias gitrebase="git rebase --interactive main"
EOF


echo "postinstall.sh finished"
Loading