diff --git a/.devcontainer/onCreateCommand.d/00-configure-locale b/.devcontainer/onCreateCommand.d/00-configure-locale deleted file mode 100755 index e5aac50..0000000 --- a/.devcontainer/onCreateCommand.d/00-configure-locale +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/zsh -eu - -run_sys() { - if [[ "$EUID" -ne 0 ]]; then - sudo "$@" - else - "$@" - fi -} - -if ! dpkg -s locales >/dev/null 2>&1; then - run_sys apt-get update -qq - run_sys DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends locales -fi - -run_sys sed -i "s/^# *zh_CN.UTF-8/zh_CN.UTF-8/" /etc/locale.gen -if ! locale -a | grep -qi "^zh_CN\.utf8$"; then - run_sys locale-gen zh_CN.UTF-8 -fi - -zshrc="$HOME/.zshrc" -mkdir -p "${zshrc:h}" -touch "$zshrc" - -if ! grep -q '^export LANG=zh_CN.UTF-8$' "$zshrc" 2>/dev/null; then - printf '\nexport LANG=zh_CN.UTF-8\n' >>"$zshrc" -fi - -if ! grep -q '^export LC_ALL=zh_CN.UTF-8$' "$zshrc" 2>/dev/null; then - printf 'export LC_ALL=zh_CN.UTF-8\n' >>"$zshrc" -fi -run_sys update-locale LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 diff --git a/.devcontainer/onCreateCommand.d/00-fix-permission b/.devcontainer/onCreateCommand.d/00-fix-permission deleted file mode 100755 index 025bd43..0000000 --- a/.devcontainer/onCreateCommand.d/00-fix-permission +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/zsh -eu - -sudo chown -R $(whoami):$(whoami) node_modules || true diff --git a/.devcontainer/onCreateCommand.d/00-setup-full-environment b/.devcontainer/onCreateCommand.d/00-setup-full-environment new file mode 100755 index 0000000..7e33685 --- /dev/null +++ b/.devcontainer/onCreateCommand.d/00-setup-full-environment @@ -0,0 +1,8 @@ +#!/bin/zsh -eu + +# 修复 node_modules 权限问题: +sudo chown -R $(whoami):$(whoami) node_modules || true + +h-setup-locale +h-setup-zsh +h-setup-bun diff --git a/.devcontainer/onCreateCommand.d/01-configure-zsh b/.devcontainer/onCreateCommand.d/01-configure-zsh deleted file mode 100755 index e06e31b..0000000 --- a/.devcontainer/onCreateCommand.d/01-configure-zsh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/zsh -eu - -TARGET_USER="usr_vscode" -if [[ "$EUID" -eq 0 ]]; then - target_home="/home/${TARGET_USER}" -else - target_home="$HOME" -fi - -zshrc="${target_home}/.zshrc" -mkdir -p "${zshrc:h}" -touch "$zshrc" - -vscode_marker='if [[ "$TERM_PROGRAM" == "vscode" ]]; then' -if ! grep -Fq "$vscode_marker" "$zshrc" 2>/dev/null; then - cat <<'EOF' >>"$zshrc" - -if [[ "$TERM_PROGRAM" == "vscode" ]]; then - local vscode_executable - if command -v code >/dev/null 2>&1; then - vscode_executable="code" - elif command -v code-insiders >/dev/null 2>&1; then - vscode_executable="code-insiders" - fi - - if [ -n "$vscode_executable" ]; then - . "$($vscode_executable --locate-shell-integration-path zsh)" - fi -fi -EOF -fi - -alias_snippet="alias clean-node-modules='setopt rm_star_silent; rm -rf node_modules/.*; rm -rf node_modules/*'; unsetopt rm_star_silent" -if ! grep -Fqx -- "$alias_snippet" "$zshrc" 2>/dev/null; then - printf '\n%s\n' "$alias_snippet" >>"$zshrc" -fi diff --git a/.devcontainer/onCreateCommand.d/10-00-install-bun b/.devcontainer/onCreateCommand.d/10-00-install-bun deleted file mode 100755 index 988c95d..0000000 --- a/.devcontainer/onCreateCommand.d/10-00-install-bun +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/zsh -eu - -# >>>>> 一些参考资料 -# https://github.com/oven-sh/bun/blob/277fc558e2039e3ab25ecebecc5a3f04c5c3199a/dockerhub/debian-slim/Dockerfile -# COPY --chown=usr_vscode:usr_vscode --from=oven/bun:1-debian /usr/local/bin/bun /usr/local/bin -# IS_BUN_AUTO_UPDATE=true SHELL=zsh bun completions -# bun install -g 将会安装到 ENV BUN_INSTALL_BIN -# ENV PATH "${BUN_INSTALL_BIN}:${PATH}" -# RUN sudo mkdir -p /usr/local/bun-node-fallback-bin && sudo ln -s /usr/local/bin/bun /usr/local/bun-node-fallback-bin/node -# ENV PATH "${PATH}:/usr/local/bun-node-fallback-bin" -# <<<<< - -# fix permission -# 有可能这个目录是 volume 挂载过来的,权限会有问题。 -sudo mkdir -p ~/.bun || true -sudo chown -R $(whoami):$(whoami) ~/.bun || true - -curl -fsSL https://bun.com/install | bash - -# https://bun.sh/docs/runtime/nodejs-compat -mkdir -p ~/.bun/bin/bun-node-fallback-bin || true -ln -sf ~/.bun/bin/bun ~/.bun/bin/bun-node-fallback-bin/node - -which -a bun -bun --version -which -a bunx -bunx --version -which -a node - -# >>>>> pnpm -bun add -g pnpm@latest -# echo "alias pnpm='bunx pnpm'" >> ~/.zshrc -# echo "alias pnpx='bunx pnpx'" >> ~/.zshrc -bunx pnpm config set store-dir ~/.pnpm-store -sudo chown -R $(whoami):$(whoami) ~/.pnpm-store || true - -# >>>>> npm -bun add -g npm@latest - -# >>>>> Claude Code 工具 -bun add -g @anthropic-ai/claude-code@latest -echo "alias claude='bunx claude --dangerously-skip-permissions'" >> ~/.zshrc -# 参考: https://github.com/anthropics/claude-code/blob/1fe9e369a7c30805189cbbb72eb69c15ed4ec96b/.devcontainer/Dockerfile#L42 -echo "export DEVCONTAINER=true" >> ~/.zshrc - -# >>>>>> Gemini CLI 工具 -bun add -g @google/gemini-cli@latest -echo "alias gemini='bunx -g gemini --yolo -m gemini-2.5-pro'" >> ~/.zshrc -echo "export SANDBOX=bun-devcontainer" >> ~/.zshrc