diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af5228..e973348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# [1.2.0](https://github.com/leoli0605/npm-env-setup/compare/v1.1.0...v1.2.0) (2024-05-09) + + +### Features + +* migrate the installation method to asdf, close [#16](https://github.com/leoli0605/npm-env-setup/issues/16) ([e8ad820](https://github.com/leoli0605/npm-env-setup/commit/e8ad820ac85ad95ccd0fce1f6f318bff927ea7c0)) +* use asdf to install latest gohugo, close [#14](https://github.com/leoli0605/npm-env-setup/issues/14) ([88371a0](https://github.com/leoli0605/npm-env-setup/commit/88371a041c0aa57236816e7c9b1af2835320726d)) +* use script to install dotnet-sdk, close [#15](https://github.com/leoli0605/npm-env-setup/issues/15) ([964cfd8](https://github.com/leoli0605/npm-env-setup/commit/964cfd85fb50f5323ccc89cd84c95ea976825c07)) + + + # [1.1.0](https://github.com/leoli0605/npm-env-setup/compare/v1.0.2...v1.1.0) (2024-04-16) diff --git a/README.md b/README.md index bb6e14b..a31a23c 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Open `powershell` and run the following command. This will start setting up your ```shell -powershell.exe -Command "Invoke-WebRequest -Uri https://github.com/leoli0605/npm-env-setup/releases/download/v1.1.0/env-setup-win-x64.exe -OutFile env-setup-win-x64.exe; Start-Process env-setup-win-x64.exe -Wait; Remove-Item env-setup-win-x64.exe -Force" +powershell.exe -Command "Invoke-WebRequest -Uri https://github.com/leoli0605/npm-env-setup/releases/download/v1.2.0/env-setup-win-x64.exe -OutFile env-setup-win-x64.exe; Start-Process env-setup-win-x64.exe -Wait; Remove-Item env-setup-win-x64.exe -Force" ``` @@ -47,7 +47,7 @@ For Mac users, the process is just as simple. Depending on the type of chip your ```shell -curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.1.0/env-setup-macos-x64 -o env-setup-macos-x64 && chmod +x env-setup-macos-x64 && ./env-setup-macos-x64 && rm -f env-setup-macos-x64 +curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.2.0/env-setup-macos-x64 -o env-setup-macos-x64 && chmod +x env-setup-macos-x64 && ./env-setup-macos-x64 && rm -f env-setup-macos-x64 ``` @@ -55,7 +55,7 @@ curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.1.0/env- ```shell -curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.1.0/env-setup-macos-arm64 -o env-setup-macos-arm64 && chmod +x env-setup-macos-arm64 && ./env-setup-macos-arm64 && rm -f env-setup-macos-arm64 +curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.2.0/env-setup-macos-arm64 -o env-setup-macos-arm64 && chmod +x env-setup-macos-arm64 && ./env-setup-macos-arm64 && rm -f env-setup-macos-arm64 ``` @@ -65,7 +65,7 @@ For Linux users running Ubuntu 18.04 LTS or newer versions, execute the followin ```shell -curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.1.0/env-setup-linux-x64 -o env-setup-linux-x64 && chmod +x env-setup-linux-x64 && ./env-setup-linux-x64 && rm -f env-setup-linux-x64 +curl -L https://github.com/leoli0605/npm-env-setup/releases/download/v1.2.0/env-setup-linux-x64 -o env-setup-linux-x64 && chmod +x env-setup-linux-x64 && ./env-setup-linux-x64 && rm -f env-setup-linux-x64 ``` @@ -83,17 +83,17 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t |------------------------------|----------------------------------------------------------------------------------------------------|------------| | Android Studio | - | disable | | Beyond Compare | 用來做檔案差異比較的 GUI 軟體 | **enable** | +| CMake | 跨平台的建構系統產生工具 | disable | | Cuda | 控制 NVIDIA GPU 的 CLI 工具 | disable | | DevToys | 開發者工具集合,包含了許多常用的開發者工具 | disable | | Docker | 虛擬化容器工具,會同時安裝 docker & docker-compose | **enable** | | FileZilla | 免費的 FTP 用戶端軟體 | disable | | Flutter | - | disable | | Git | - | `force` | -| Golang | - | disable | +| Golang | - | **enable** | | ImageJ | 基於 Java 的圖像處理軟體 | **enable** | | KiCad | 繪製電路原理圖和印刷電路板設計的自由軟體 | disable | | LINQPad 7 | 一款強大的 .NET 程式碼編輯器 | **enable** | -| LazyDocker | 一個簡單的終端機使用者介面,適用於 docker 與 docker-compose | **enable** | | Miniconda 3 | - | disable | | MobaXTerm | 終端機工具,類似於 PuTTY | **enable** | | Node.js | - | `force` | @@ -107,19 +107,20 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Sublime Text 4 | 高效、多功能的文本編輯器 | **enable** | | Tera Term | - | disable | | TypeScript | - | **enable** | -| VSCode Extension Development | VSCode 擴充套件開發工具 | disable | +| VSCode Extension Development | VSCode 擴充套件開發工具 | **enable** | | Virtual Box | 自由及開放原始碼的虛擬機器軟體 | **enable** | | Visual Studio 2022 Community | - | disable | | Visual Studio Code | - | **enable** | -| act-cli | GitHub Actions 的 CLI 工具 | disable | +| act-cli | GitHub Actions 的本地模擬工具 | disable | | commitizen | Git Commit 規範工具 | **enable** | | dotnet-sdk | - | **enable** | | gcc | C / C++ 編譯器 | **enable** | -| gcc-arm-none-eabi | ARM 編譯器 (推薦使用 Docker 以避免環境問題) | disable | +| gcc-arm-none-eabi | ARM 編譯器 | **enable** | | ilspy | C# 反編譯工具 | **enable** | +| lazydocker | 一個簡單的終端機使用者介面,適用於 docker 與 docker-compose | **enable** | | make | - | **enable** | -| pyOCD | Python OpenOCD | disable | -| usbipd-win | USB over IP 的 Windows 版本 | disable | +| pyOCD | Python OpenOCD | **enable** | +| usbipd-win | USB over IP 的 Windows 版本 | **enable** | | 7-Zip | 壓縮/解壓縮軟體 | disable | | Adobe Reader | PDF 閱讀器 | **enable** | | Anydesk | 遠端桌面軟體 | **enable** | @@ -132,6 +133,7 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Folder Size | 資料夾大小檢視工具 | disable | | Google Drive | - | **enable** | | Hugo | 靜態網站產生器 | **enable** | +| ImageMagick | 圖像處理工具 | **enable** | | Inkscape | 免費向量繪圖軟體,類似 Adobe Illustrator | disable | | Keyviz | 按鍵可視化工具,它可以實時顯示用戶當前按下的按鍵。 | **enable** | | Krita | 免費的數位繪圖軟體,類似 Adobe Photoshop | disable | @@ -159,12 +161,12 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t |------------------------------|----------------------------------------------------------------------------------------------------|------------| | Android Studio | - | disable | | Beyond Compare | 用來做檔案差異比較的 GUI 軟體 | **enable** | +| CMake | 跨平台的建構系統產生工具 | disable | | Docker | 虛擬化容器工具,會同時安裝 docker & docker-compose | **enable** | | Flutter | - | disable | | Git | - | `force` | -| Golang | - | disable | +| Golang | - | **enable** | | KiCad | 繪製電路原理圖和印刷電路板設計的自由軟體 | disable | -| LazyDocker | 一個簡單的終端機使用者介面,適用於 docker 與 docker-compose | **enable** | | Node.js | - | `force` | | Pandoc | 文件轉換工具 | **enable** | | PySide6 | - | disable | @@ -173,15 +175,17 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Setuptools | Python tool that helps you easily download, build, install, upgrade, and uninstall Python packages | disable | | Sourcetree | Git GUI 軟體 | disable | | TypeScript | - | **enable** | -| VSCode Extension Development | VSCode 擴充套件開發工具 | disable | +| VSCode Extension Development | VSCode 擴充套件開發工具 | **enable** | | Visual Studio Code | - | **enable** | -| act-cli | GitHub Actions 的 CLI 工具 | disable | +| act-cli | GitHub Actions 的本地模擬工具 | disable | | commitizen | Git Commit 規範工具 | **enable** | | dotnet-sdk | - | **enable** | -| gcc-arm-none-eabi | ARM 編譯器 (推薦使用 Docker 以避免環境問題) | disable | +| gcc-arm-none-eabi | ARM 編譯器 | **enable** | +| lazydocker | 一個簡單的終端機使用者介面,適用於 docker 與 docker-compose | **enable** | +| lazygit | 一個簡單的終端機使用者介面,適用於 git | **enable** | | make | - | **enable** | | minicom | Linux/Unix 系統的終端機通訊程式 | **enable** | -| pyOCD | Python OpenOCD | disable | +| pyOCD | Python OpenOCD | **enable** | | 7-Zip | 壓縮/解壓縮軟體 | disable | | Adobe Creative Cloud | Adobe 軟體管理工具 | **enable** | | Adobe Reader | PDF 閱讀器 | **enable** | @@ -190,6 +194,7 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Fira Code | 好看的程式碼字型 | `force` | | Google Drive | - | **enable** | | Hugo | 靜態網站產生器 | **enable** | +| ImageMagick | 圖像處理工具 | **enable** | | Inkscape | 免費向量繪圖軟體,類似 Adobe Illustrator | disable | | Krita | 免費的數位繪圖軟體,類似 Adobe Photoshop | disable | | Logi Options+ | - | disable | @@ -197,7 +202,6 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Microsoft Edge | - | **enable** | | Notion | - | disable | | OBS Studio | 開源的串流軟體 | **enable** | -| PotPlayer | - | **enable** | | Spotify | - | **enable** | | Telegram | - | **enable** | | The Unarchiver | macOS 的壓縮/解壓縮軟體 | **enable** | @@ -213,12 +217,12 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Package | Description | Default | |------------------------------|----------------------------------------------------------------------------------------------------|------------| +| CMake | 跨平台的建構系統產生工具 | disable | | Docker | 虛擬化容器工具,會同時安裝 docker & docker-compose | **enable** | | Flutter | - | disable | | Git | - | `force` | -| Golang | - | disable | +| Golang | - | **enable** | | KiCad | 繪製電路原理圖和印刷電路板設計的自由軟體 | disable | -| LazyDocker | 一個簡單的終端機使用者介面,適用於 docker 與 docker-compose | **enable** | | Node.js | - | `force` | | OpenSSH | - | **enable** | | Pandoc | 文件轉換工具 | **enable** | @@ -227,14 +231,18 @@ Additionally, it sets up some useful programming tools and utilities, ensuring t | Rust | - | `force` | | Setuptools | Python tool that helps you easily download, build, install, upgrade, and uninstall Python packages | disable | | TypeScript | - | **enable** | -| VSCode Extension Development | VSCode 擴充套件開發工具 | disable | +| VSCode Extension Development | VSCode 擴充套件開發工具 | **enable** | +| act-cli | GitHub Actions 的本地模擬工具 | disable | | commitizen | Git Commit 規範工具 | **enable** | | dotnet-sdk | - | **enable** | -| gcc-arm-none-eabi | ARM 編譯器 (推薦使用 Docker 以避免環境問題) | disable | +| gcc-arm-none-eabi | ARM 編譯器 | **enable** | +| lazydocker | 一個簡單的終端機使用者介面,適用於 docker 與 docker-compose | **enable** | +| lazygit | 一個簡單的終端機使用者介面,適用於 git | **enable** | | make | - | **enable** | | minicom | Linux/Unix 系統的終端機通訊程式 | **enable** | -| pyOCD | Python OpenOCD | disable | +| pyOCD | Python OpenOCD | **enable** | | Hugo | 靜態網站產生器 | **enable** | +| ImageMagick | 圖像處理工具 | **enable** | | Inkscape | 免費向量繪圖軟體,類似 Adobe Illustrator | disable | | Noto Sans CJK | Google 開發的中文字型 | **enable** | | OBS Studio | 開源的串流軟體 | **enable** | diff --git a/cspell.json b/cspell.json index 94bd944..18c7b92 100644 --- a/cspell.json +++ b/cspell.json @@ -16,6 +16,7 @@ "crystaldiskmark", "cuda", "czrc", + "devtoys", "dorssel", "eabi", "ffmepg", @@ -30,6 +31,7 @@ "kicad", "krita", "lazydocker", + "lazygit", "leoli", "linqpad", "logi", @@ -59,6 +61,7 @@ "Tera", "teraterm", "texlive", + "tinytex", "Unarchiver", "usbipd", "virtualenvs", diff --git a/package.json b/package.json index dc60e13..78444cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@leoli0605/env-setup", - "version": "1.1.0", + "version": "1.2.0", "description": "\"\"", "main": "./src/index.mjs", "files": [ diff --git a/packageData.json b/packageData.json index c1dd8d7..d2c720e 100644 --- a/packageData.json +++ b/packageData.json @@ -18,6 +18,15 @@ }, "type": "enable" }, + "CMake": { + "description": "跨平台的建構系統產生工具", + "install": { + "linux": "asdf plugin add cmake && asdf install cmake latest && asdf global cmake latest", + "mac": "asdf plugin add cmake && asdf install cmake latest && asdf global cmake latest", + "windows": "choco install cmake -y" + }, + "type": "disable" + }, "Cuda": { "description": "控制 NVIDIA GPU 的 CLI 工具", "install": { @@ -75,11 +84,11 @@ "Golang": { "description": "", "install": { - "linux": "asdf plugin add golang && asdf install golang 1.20 && asdf global golang 1.20", - "mac": "brew install coreutils && asdf plugin add golang && asdf install golang 1.20 && asdf global golang 1.20", + "linux": "asdf plugin add golang && asdf install golang latest && asdf global golang latest", + "mac": "brew install coreutils && asdf plugin add golang && asdf install golang latest && asdf global golang latest", "windows": "choco install golang -y" }, - "type": "disable" + "type": "enable" }, "ImageJ": { "description": "基於 Java 的圖像處理軟體", @@ -108,15 +117,6 @@ }, "type": "enable" }, - "LazyDocker": { - "description": "一個簡單的終端機使用者介面,適用於 docker 與 docker-compose", - "install": { - "linux": "asdf install lazydocker latest && asdf global lazydocker latest", - "mac": "asdf install lazydocker latest && asdf global lazydocker latest", - "windows": "choco install lazydocker -y" - }, - "type": "enable" - }, "Miniconda 3": { "description": "", "install": { @@ -156,9 +156,9 @@ "Pandoc": { "description": "文件轉換工具", "install": { - "linux": "sudo apt install -y pandoc texlive-full", - "mac": "brew install pandoc && brew install --cask mactex-no-gui", - "windows": "choco install pandoc miktex -y" + "linux": "asdf plugin add pandoc && asdf install pandoc latest && asdf global pandoc latest && asdf plugin add tinytex && asdf install tinytex latest && asdf global tinytex latest", + "mac": "asdf plugin add pandoc && asdf install pandoc latest && asdf global pandoc latest && asdf plugin add tinytex && asdf install tinytex latest && asdf global tinytex latest", + "windows": "choco install pandoc tinytex -y" }, "type": "enable" }, @@ -250,7 +250,7 @@ "mac": "npm install -g yo generator-code vsce esbuild", "windows": "npm install -g yo generator-code vsce esbuild" }, - "type": "disable" + "type": "enable" }, "Virtual Box": { "description": "自由及開放原始碼的虛擬機器軟體", @@ -280,10 +280,10 @@ "type": "enable" }, "act-cli": { - "description": "GitHub Actions 的 CLI 工具", + "description": "GitHub Actions 的本地模擬工具", "install": { - "linux": "", - "mac": "brew install act", + "linux": "asdf plugin add act && asdf install act latest && asdf global act latest", + "mac": "asdf plugin add act && asdf install act latest && asdf global act latest", "windows": "choco install act-cli -y" }, "type": "disable" @@ -300,9 +300,9 @@ "dotnet-sdk": { "description": "", "install": { - "linux": "sudo apt install dotnet-sdk -y", - "mac": "brew install --cask dotnet-sdk", - "windows": "choco install dotnet-sdk -y" + "linux": "curl -sSL https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash && echo -e '\nexport PATH=\"$HOME/.dotnet:$PATH\"' >> ~/.bashrc && source ~/.bashrc", + "mac": "curl -sSL https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash && echo -e '\nexport PATH=\"$HOME/.dotnet:$PATH\"' >> ~/.bashrc && source ~/.bashrc", + "windows": "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass ; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1'))" }, "type": "enable" }, @@ -316,13 +316,13 @@ "type": "enable" }, "gcc-arm-none-eabi": { - "description": "ARM 編譯器 (推薦使用 Docker 以避免環境問題)", + "description": "ARM 編譯器", "install": { - "linux": "sudo apt install gcc-arm-none-eabi -y", - "mac": "brew install --cask gcc-arm-embedded", + "linux": "asdf plugin add gcc-arm-none-eabi && asdf install gcc-arm-none-eabi latest && asdf global gcc-arm-none-eabi latest", + "mac": "asdf plugin add gcc-arm-none-eabi && asdf install gcc-arm-none-eabi latest && asdf global gcc-arm-none-eabi latest", "windows": "choco install gcc-arm-embedded -y" }, - "type": "disable" + "type": "enable" }, "ilspy": { "description": "C# 反編譯工具", @@ -333,11 +333,29 @@ }, "type": "enable" }, + "lazydocker": { + "description": "一個簡單的終端機使用者介面,適用於 docker 與 docker-compose", + "install": { + "linux": "asdf install lazydocker latest && asdf global lazydocker latest", + "mac": "asdf install lazydocker latest && asdf global lazydocker latest", + "windows": "choco install lazydocker -y" + }, + "type": "enable" + }, + "lazygit": { + "description": "一個簡單的終端機使用者介面,適用於 git", + "install": { + "linux": "asdf plugin add lazygit && asdf install lazygit latest && asdf global lazygit latest", + "mac": "asdf plugin add lazygit && asdf install lazygit latest && asdf global lazygit latest", + "windows": "" + }, + "type": "enable" + }, "make": { "description": "", "install": { - "linux": "sudo apt install make -y", - "mac": "brew install make", + "linux": "asdf plugin add make && asdf install make latest && asdf global make latest", + "mac": "asdf plugin add make && asdf install make latest && asdf global make latest", "windows": "choco install make -y" }, "type": "enable" @@ -358,7 +376,7 @@ "mac": "pip install --upgrade pyocd --user", "windows": "pip install --upgrade pyocd --user" }, - "type": "disable" + "type": "enable" }, "usbipd-win": { "description": "USB over IP 的 Windows 版本", @@ -367,7 +385,7 @@ "mac": "", "windows": "winget install --interactive --exact dorssel.usbipd-win" }, - "type": "disable" + "type": "enable" } }, "MISC": { @@ -482,12 +500,21 @@ "Hugo": { "description": "靜態網站產生器", "install": { - "linux": "sudo apt install hugo -y", - "mac": "brew install hugo", + "linux": "asdf plugin add hugo && HUGO_LATEST_VERSION=$(asdf list-all hugo | tail -1) && asdf install hugo extended_$HUGO_LATEST_VERSION && asdf global hugo extended_$HUGO_LATEST_VERSION", + "mac": "asdf plugin add hugo && HUGO_LATEST_VERSION=$(asdf list-all hugo | tail -1) && asdf install hugo extended_$HUGO_LATEST_VERSION && asdf global hugo extended_$HUGO_LATEST_VERSION", "windows": "choco install hugo-extended -y" }, "type": "enable" }, + "ImageMagick": { + "description": "圖像處理工具", + "install": { + "linux": "asdf plugin add imagemagick && asdf install imagemagick latest && asdf global imagemagick latest", + "mac": "asdf plugin add imagemagick && asdf install imagemagick latest && asdf global imagemagick latest", + "windows": "choco install imagemagick -y" + }, + "type": "enable" + }, "Inkscape": { "description": "免費向量繪圖軟體,類似 Adobe Illustrator", "install": { @@ -591,7 +618,7 @@ "description": "", "install": { "linux": "", - "mac": "brew install --cask vlc", + "mac": "", "windows": "choco install potplayer -y" }, "type": "enable" @@ -662,8 +689,8 @@ "ffmepg": { "description": "影片處理 CLI 工具", "install": { - "linux": "sudo apt install ffmpeg -y", - "mac": "brew install ffmpeg", + "linux": "asdf plugin add ffmpeg && asdf install ffmpeg latest && asdf global ffmpeg latest", + "mac": "asdf plugin add ffmpeg && asdf install ffmpeg latest && asdf global ffmpeg latest", "windows": "choco install ffmpeg -y" }, "type": "enable" @@ -680,8 +707,8 @@ "yt-dlp": { "description": "YouTube 影片下載 CLI 工具", "install": { - "linux": "sudo apt install yt-dlp -y", - "mac": "brew install yt-dlp", + "linux": "asdf plugin add yt-dlp && asdf install yt-dlp latest && asdf global yt-dlp latest", + "mac": "asdf plugin add yt-dlp && asdf install yt-dlp latest && asdf global yt-dlp latest", "windows": "choco install yt-dlp -y" }, "type": "enable" diff --git a/src/index.mjs b/src/index.mjs index 090350f..ea3762c 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -44,9 +44,7 @@ class SetupManager { selectedPackages.forEach((p) => p && this.shell.addCommand(p.installCommand)); - if (os.platform() === 'win32') { - this.shell.addCommand('refreshenv\n'); - } + refreshEnvironment(); if (selectedPackages.some((p) => p && p.packageName.startsWith('Python'))) { if (os.platform() === 'win32') { @@ -54,10 +52,12 @@ class SetupManager { } else { this.shell.addEnvironment('\'export PATH="$HOME/.local/bin:$PATH"\''); } - const poetryInstallCommand = os.platform() === 'win32' ? '(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -' : 'curl -sSL https://install.python-poetry.org | python3'; - this.shell.addCommand(poetryInstallCommand); this.shell.addCommand('python --version'); this.shell.addCommand('pip --version'); + /* Install Poetry */ + const poetryInstallCommand = os.platform() === 'win32' ? '(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -' : 'asdf plugin add poetry && asdf install poetry latest && asdf global poetry latest'; + this.shell.addCommand(poetryInstallCommand); + refreshEnvironment(); this.shell.addCommand('poetry --version'); this.shell.addCommand('poetry config virtualenvs.in-project true'); this.shell.addCommand(fs.readFileSync(path.join(__dirname, 'scripts/pip.setup'), 'utf8').trim()); @@ -80,12 +80,11 @@ class SetupManager { console.log('Ubuntu 20.04 not detected'); } } + refreshEnvironment(); this.shell.addCommand('node --version'); this.shell.addCommand('npm --version'); this.shell.addCommand(fs.readFileSync(path.join(__dirname, 'scripts/npm.setup'), 'utf8').trim()); - if (os.platform() === 'win32') { - this.shell.addCommand('refreshenv\n'); - } + refreshEnvironment(); } if (os.platform() === 'win32' && selectedPackages.some((p) => p && p.packageName.startsWith('Sublime Text'))) { @@ -98,7 +97,7 @@ class SetupManager { this.shell.addCommand(fs.readFileSync(path.join(__dirname, 'scripts/macos/macsetup.sh'), 'utf8').trim()); } - this.shell.addCommand('npx @leoli0605/git-setup'); + if (!isLinuxRunAsRoot()) this.shell.addCommand('npx @leoli0605/git-setup'); } setupNonWindowsEnvironment() { @@ -116,6 +115,21 @@ class SetupManager { } } + refreshEnvironment() { + if (os.platform() === 'win32') { + this.shell.addCommand('refreshenv\n'); + } else { + this.shell.addCommand('source ~/.bashrc\n'); + if (fs.existsSync(path.join(os.homedir(), '.zshrc'))) { + this.shell.addCommand('source ~/.zshrc\n'); + } + } + } + + isLinuxRunAsRoot() { + return os.platform() === 'linux' && process.getuid() === 0; + } + finalizeScript() { const script = this.shell.script(); this.args = os.platform() === 'win32' ? ['-NoProfile', '-EncodedCommand', Buffer.from(script, 'utf16le').toString('base64')] : ['-c', script];