From 45a0bf78f82824d25f1b0373b21b509d147ffe83 Mon Sep 17 00:00:00 2001 From: leoli Date: Tue, 26 Dec 2023 18:12:42 +0800 Subject: [PATCH] feat: add packages file and related functions --- .gitignore | 180 ++++++++++++++ cspell.json | 51 ++++ package.json | 33 +++ packageData.json | 537 +++++++++++++++++++++++++++++++++++++++++ pnpm-lock.yaml | 451 ++++++++++++++++++++++++++++++++++ src/index.js | 12 + src/packageSelector.js | 76 ++++++ 7 files changed, 1340 insertions(+) create mode 100644 .gitignore create mode 100644 cspell.json create mode 100644 package.json create mode 100644 packageData.json create mode 100644 pnpm-lock.yaml create mode 100644 src/index.js create mode 100644 src/packageSelector.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf3018e --- /dev/null +++ b/.gitignore @@ -0,0 +1,180 @@ +# Created by https://www.toptal.com/developers/gitignore/api/macos +# Edit at https://www.toptal.com/developers/gitignore?templates=macos + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +# End of https://www.toptal.com/developers/gitignore/api/macos +# Created by https://www.toptal.com/developers/gitignore/api/node +# Edit at https://www.toptal.com/developers/gitignore?templates=node + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +# End of https://www.toptal.com/developers/gitignore/api/node diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..79d8c36 --- /dev/null +++ b/cspell.json @@ -0,0 +1,51 @@ +{ + "version": "0.2", + "ignorePaths": [], + "dictionaryDefinitions": [], + "dictionaries": [], + "words": [ + "adobereader", + "androidstudio", + "anydesk", + "bandizip", + "beyondcompare", + "choco", + "codemaid", + "coreutils", + "crystaldiskmark", + "cuda", + "eabi", + "ffmepg", + "filezilla", + "fira", + "firacode", + "googledrive", + "ilspy", + "imagej", + "inkscape", + "Keyviz", + "kicad", + "krita", + "leoli", + "linqpad", + "logi", + "logioptionsplus", + "megadownloader", + "miniconda", + "mulaRahul", + "obsproject", + "pdftk", + "Photoshop", + "potplayer", + "powertoys", + "quicklook", + "revo", + "sublimetext", + "Tera", + "teraterm", + "Unarchiver", + "winget" + ], + "ignoreWords": [], + "import": [] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f02ae9d --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "@leoli0605/env-setup", + "version": "0.1.0", + "description": "\"\"", + "main": "./src/index.js", + "type": "module", + "repository": { + "type": "git", + "url": "https://github.com/leoli0605/npm-env-setup" + }, + "bugs": { + "url": "https://github.com/leoli0605/npm-env-setup/issues" + }, + "engines": { + "node": ">= 10.13.0" + }, + "keywords": [ + "env", + "setup", + "config" + ], + "homepage": "https://github.com/leoli0605/npm-env-setup", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Leo Li", + "license": "MIT", + "dependencies": { + "@types/inquirer": "^9.0.7", + "chalk": "^5.3.0", + "inquirer": "^9.2.12" + } +} diff --git a/packageData.json b/packageData.json new file mode 100644 index 0000000..03ede88 --- /dev/null +++ b/packageData.json @@ -0,0 +1,537 @@ +{ + "Development": { + "Android Studio": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask android-studio", + "windows": "choco install androidstudio -y" + }, + "type": "enable" + }, + "Beyond Compare": { + "description": "用來做檔案差異比較的 GUI 軟體", + "install": { + "linux": "", + "mac": "brew install --cask beyond-compare", + "windows": "choco install beyondcompare -y" + }, + "type": "enable" + }, + "Cuda": { + "description": "控制 NVIDIA GPU 的 CLI 工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install cuda -y" + }, + "type": "disable" + }, + "Docker": { + "description": "虛擬化容器工具,會同時安裝 docker & docker-compose", + "install": { + "linux": "sudo apt install docker.io -y && sudo apt install docker-compose -y", + "mac": "brew install --cask docker && brew install docker-compose", + "windows": "choco install docker-desktop -y && choco install docker-compose -y" + }, + "type": "enable" + }, + "dotnet-sdk": { + "description": "", + "install": { + "linux": "sudo apt install dotnet-sdk -y", + "mac": "brew install --cask dotnet-sdk", + "windows": "choco install dotnet-sdk -y" + }, + "type": "enable" + }, + "FileZilla": { + "description": "免費的 FTP 用戶端軟體", + "install": { + "linux": "", + "mac": "", + "windows": "choco install filezilla -y" + }, + "type": "disable" + }, + "gcc": { + "description": "C / C++ 編譯器", + "install": { + "linux": "", + "mac": "", + "windows": "choco install mingw -y" + }, + "type": "enable" + }, + "gcc-arm-none-eabi": { + "description": "ARM 編譯器", + "install": { + "linux": "sudo apt install gcc-arm-none-eabi -y", + "mac": "brew install --cask gcc-arm-embedded", + "windows": "choco install gcc-arm-embedded -y" + }, + "type": "enable" + }, + "Git": { + "description": "", + "install": { + "linux": "sudo apt install git -y", + "mac": "brew install git", + "windows": "choco install git -y" + }, + "type": "force" + }, + "ilspy": { + "description": "C# 反編譯工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install ilspy -y" + }, + "type": "enable" + }, + "ImageJ": { + "description": "基於 Java 的圖像處理軟體", + "install": { + "linux": "", + "mac": "", + "windows": "choco install imagej -y" + }, + "type": "enable" + }, + "KiCad": { + "description": "繪製電路原理圖和印刷電路板設計的自由軟體", + "install": { + "linux": "sudo add-apt-repository ppa:kicad/kicad-7.0-releases -y && sudo apt update && sudo apt install kicad -y", + "mac": "brew install --cask kicad", + "windows": "choco install kicad -y" + }, + "type": "enable" + }, + "LINQPad 7": { + "description": "一款強大的 .NET 程式碼編輯器", + "install": { + "linux": "", + "mac": "", + "windows": "choco install linqpad7 -y --ignore-checksums" + }, + "type": "enable" + }, + "make": { + "description": "", + "install": { + "linux": "sudo apt install make -y", + "mac": "brew install make", + "windows": "choco install make -y" + }, + "type": "enable" + }, + "Miniconda 3": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install miniconda3 -y --params=\"'/AddToPath:1 /RegisterPython:0 /InstallationType:JustMe'\"" + }, + "type": "disable" + }, + "Node.js": { + "description": "", + "install": { + "linux": "asdf plugin add nodejs && asdf install nodejs 16.20.2 && asdf global nodejs 16.20.2", + "mac": "asdf plugin add nodejs && asdf install nodejs 18.18.0 && asdf global nodejs 18.18.0", + "windows": "choco install nodejs-lts -y" + }, + "type": "force" + }, + "OpenSSH": { + "description": "", + "install": { + "linux": "sudo apt install openssh-server -y", + "mac": "", + "windows": "" + }, + "type": "enable" + }, + "PuTTY": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install putty -y" + }, + "type": "enable" + }, + "Python": { + "description": "", + "install": { + "linux": "asdf plugin add python && asdf install python 3.10.0 && asdf global python 3.10.0", + "mac": "asdf plugin add python && asdf install python 3.10.0 && asdf global python 3.10.0", + "windows": "choco install python310 -y" + }, + "type": "force" + }, + "Sublime Text 4": { + "description": "高效、多功能的文本編輯器", + "install": { + "linux": "", + "mac": "", + "windows": "choco install sublimetext4 -y" + }, + "type": "enable" + }, + "Tera Term": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install teraterm -y" + }, + "type": "enable" + }, + "Virtual Box": { + "description": "自由及開放原始碼的虛擬機器軟體", + "install": { + "linux": "", + "mac": "", + "windows": "choco install virtualbox -y" + }, + "type": "enable" + }, + "Visual Studio 2022 Community": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install visualstudio2022community -y" + }, + "type": "enable" + }, + "Visual Studio Code": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask visual-studio-code", + "windows": "choco install vscode -y" + }, + "type": "enable" + } + }, + "MISC": { + "7-Zip": { + "description": "壓縮程式", + "install": { + "linux": "", + "mac": "brew install p7zip", + "windows": "choco install 7zip -y" + }, + "type": "enable" + }, + "Adobe Creative Cloud": { + "description": "Adobe 軟體管理工具", + "install": { + "linux": "", + "mac": "brew install --cask adobe-creative-cloud", + "windows": "" + }, + "type": "enable" + }, + "Adobe Reader": { + "description": "PDF 閱讀器", + "install": { + "linux": "", + "mac": "brew install --cask adobe-acrobat-reader", + "windows": "choco install adobereader -y" + }, + "type": "enable" + }, + "Anydesk": { + "description": "遠端桌面軟體", + "install": { + "linux": "", + "mac": "brew install --cask anydesk", + "windows": "choco install anydesk -y" + }, + "type": "enable" + }, + "Bandizip": { + "description": "好看的壓縮程式", + "install": { + "linux": "", + "mac": "", + "windows": "choco install bandizip -y" + }, + "type": "enable" + }, + "CPU-Z": { + "description": "CPU 資訊檢視工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install cpu-z -y" + }, + "type": "disable" + }, + "CrystalDiskMark": { + "description": "硬碟效能檢測工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install crystaldiskmark -y" + }, + "type": "disable" + }, + "Discord": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask discord", + "windows": "choco install discord -y" + }, + "type": "enable" + }, + "Everything": { + "description": "免費 Windows 搜尋引擎,搜尋速度快", + "install": { + "linux": "", + "mac": "", + "windows": "choco install everything -y" + }, + "type": "enable" + }, + "ffmepg": { + "description": "影片處理 CLI 工具", + "install": { + "linux": "sudo apt install ffmpeg -y", + "mac": "brew install ffmpeg", + "windows": "choco install ffmpeg -y" + }, + "type": "enable" + }, + "Fira Code": { + "description": "好看的程式碼字型", + "install": { + "linux": "", + "mac": "brew tap homebrew/cask-fonts && brew install --cask font-fira-code", + "windows": "choco install firacode -y" + }, + "type": "force" + }, + "Folder Size": { + "description": "資料夾大小檢視工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install folder_size -y" + }, + "type": "disable" + }, + "Google Drive": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask google-drive", + "windows": "choco install googledrive -y" + }, + "type": "enable" + }, + "Hugo": { + "description": "靜態網站產生器", + "install": { + "linux": "sudo apt install hugo -y", + "mac": "brew install hugo", + "windows": "choco install hugo-extended -y" + }, + "type": "enable" + }, + "Inkscape": { + "description": "免費向量繪圖軟體,類似 Adobe Illustrator", + "install": { + "linux": "sudo apt install inkscape -y", + "mac": "brew install --cask inkscape", + "windows": "choco install inkscape -y" + }, + "type": "enable" + }, + "Keyviz": { + "description": "按鍵可視化工具,它可以實時顯示用戶當前按下的按鍵。", + "install": { + "linux": "", + "mac": "", + "windows": "winget install mulaRahul.Keyviz" + }, + "type": "enable" + }, + "Krita": { + "description": "免費的數位繪圖軟體,類似 Adobe Photoshop", + "install": { + "linux": "", + "mac": "brew install --cask krita", + "windows": "choco install krita -y" + }, + "type": "enable" + }, + "Logi Options+": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask logi-options-plus", + "windows": "choco install logioptionsplus -y" + }, + "type": "enable" + }, + "Logitech G HUB": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask logitech-g-hub", + "windows": "" + }, + "type": "enable" + }, + "Mega Downloader": { + "description": "Mega.nz 下載器", + "install": { + "linux": "", + "mac": "", + "windows": "choco install megadownloader -y" + }, + "type": "disable" + }, + "Microsoft Edge": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask microsoft-edge", + "windows": "" + }, + "type": "enable" + }, + "Notion": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask notion", + "windows": "choco install notion -y" + }, + "type": "disable" + }, + "OBS Studio": { + "description": "開源的串流軟體", + "install": { + "linux": "sudo add-apt-repository ppa:obsproject/obs-studio -y && sudo apt update && sudo apt install obs-studio -y", + "mac": "brew install --cask obs", + "windows": "choco install obs-studio -y" + }, + "type": "enable" + }, + "pdf2svg": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install pdf2svg -y --ignore-checksums" + }, + "type": "disable" + }, + "PDF24": { + "description": "PDF 處理軟體", + "install": { + "linux": "", + "mac": "", + "windows": "choco install pdf24 -y" + }, + "type": "enable" + }, + "PDFtk": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install pdftk -y" + }, + "type": "disable" + }, + "PowerToys": { + "description": "Windows 10 / 11 的實用小工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install powertoys -y" + }, + "type": "enable" + }, + "Prince": { + "description": "", + "install": { + "linux": "", + "mac": "", + "windows": "choco install prince -y" + }, + "type": "disable" + }, + "QuickLook": { + "description": "類似於 macOS 的快速預覽工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install quicklook -y" + }, + "type": "enable" + }, + "Revo Uninstaller": { + "description": "Windows 的軟體卸載工具", + "install": { + "linux": "", + "mac": "", + "windows": "choco install revo-uninstaller -y" + }, + "type": "enable" + }, + "Spotify": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask spotify", + "windows": "choco install spotify -y" + }, + "type": "enable" + }, + "Telegram": { + "description": "", + "install": { + "linux": "", + "mac": "brew install --cask telegram-desktop", + "windows": "choco install telegram -y" + }, + "type": "enable" + }, + "The Unarchiver": { + "description": "macOS 的解壓縮軟體", + "install": { + "linux": "", + "mac": "brew install --cask the-unarchiver", + "windows": "" + }, + "type": "enable" + }, + "Video Player": { + "description": "macOS 安裝 VLC ; Windows 安裝 PotPlayer", + "install": { + "linux": "", + "mac": "brew install --cask vlc", + "windows": "choco install potplayer -y" + }, + "type": "enable" + }, + "yt-dlp": { + "description": "YouTube 影片下載 CLI 工具", + "install": { + "linux": "sudo apt install yt-dlp -y", + "mac": "brew install yt-dlp", + "windows": "choco install yt-dlp -y" + }, + "type": "enable" + } + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..f9d8ed1 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,451 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +dependencies: + '@types/inquirer': + specifier: ^9.0.7 + version: 9.0.7 + chalk: + specifier: ^5.3.0 + version: 5.3.0 + inquirer: + specifier: ^9.2.12 + version: 9.2.12 + +packages: + + /@ljharb/through@2.3.11: + resolution: {integrity: sha512-ccfcIDlogiXNq5KcbAwbaO7lMh3Tm1i3khMPYpxlK8hH/W53zN81KM9coerRLOnTGu3nfXIniAmQbRI9OxbC0w==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.5 + dev: false + + /@types/inquirer@9.0.7: + resolution: {integrity: sha512-Q0zyBupO6NxGRZut/JdmqYKOnN95Eg5V8Csg3PGKkP+FnvsUZx1jAyK7fztIszxxMuoBA6E3KXWvdZVXIpx60g==} + dependencies: + '@types/through': 0.0.33 + rxjs: 7.8.1 + dev: false + + /@types/node@20.10.5: + resolution: {integrity: sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==} + dependencies: + undici-types: 5.26.5 + dev: false + + /@types/through@0.0.33: + resolution: {integrity: sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==} + dependencies: + '@types/node': 20.10.5 + dev: false + + /ansi-escapes@4.3.2: + resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} + engines: {node: '>=8'} + dependencies: + type-fest: 0.21.3 + dev: false + + /ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + dev: false + + /ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + dependencies: + color-convert: 2.0.1 + dev: false + + /base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + dev: false + + /bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + dev: false + + /buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + dev: false + + /call-bind@1.0.5: + resolution: {integrity: sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==} + dependencies: + function-bind: 1.1.2 + get-intrinsic: 1.2.2 + set-function-length: 1.1.1 + dev: false + + /chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + dev: false + + /chalk@5.3.0: + resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: false + + /chardet@0.7.0: + resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + dev: false + + /cli-cursor@3.1.0: + resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} + engines: {node: '>=8'} + dependencies: + restore-cursor: 3.1.0 + dev: false + + /cli-spinners@2.9.2: + resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==} + engines: {node: '>=6'} + dev: false + + /cli-width@4.1.0: + resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==} + engines: {node: '>= 12'} + dev: false + + /clone@1.0.4: + resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} + engines: {node: '>=0.8'} + dev: false + + /color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + dependencies: + color-name: 1.1.4 + dev: false + + /color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + dev: false + + /defaults@1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} + dependencies: + clone: 1.0.4 + dev: false + + /define-data-property@1.1.1: + resolution: {integrity: sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.2.2 + gopd: 1.0.1 + has-property-descriptors: 1.0.1 + dev: false + + /emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + dev: false + + /escape-string-regexp@5.0.0: + resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} + engines: {node: '>=12'} + dev: false + + /external-editor@3.1.0: + resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} + engines: {node: '>=4'} + dependencies: + chardet: 0.7.0 + iconv-lite: 0.4.24 + tmp: 0.0.33 + dev: false + + /figures@5.0.0: + resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==} + engines: {node: '>=14'} + dependencies: + escape-string-regexp: 5.0.0 + is-unicode-supported: 1.3.0 + dev: false + + /function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + dev: false + + /get-intrinsic@1.2.2: + resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==} + dependencies: + function-bind: 1.1.2 + has-proto: 1.0.1 + has-symbols: 1.0.3 + hasown: 2.0.0 + dev: false + + /gopd@1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + dependencies: + get-intrinsic: 1.2.2 + dev: false + + /has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + dev: false + + /has-property-descriptors@1.0.1: + resolution: {integrity: sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==} + dependencies: + get-intrinsic: 1.2.2 + dev: false + + /has-proto@1.0.1: + resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} + engines: {node: '>= 0.4'} + dev: false + + /has-symbols@1.0.3: + resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} + engines: {node: '>= 0.4'} + dev: false + + /hasown@2.0.0: + resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} + engines: {node: '>= 0.4'} + dependencies: + function-bind: 1.1.2 + dev: false + + /iconv-lite@0.4.24: + resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} + engines: {node: '>=0.10.0'} + dependencies: + safer-buffer: 2.1.2 + dev: false + + /ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + dev: false + + /inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + dev: false + + /inquirer@9.2.12: + resolution: {integrity: sha512-mg3Fh9g2zfuVWJn6lhST0O7x4n03k7G8Tx5nvikJkbq8/CK47WDVm+UznF0G6s5Zi0KcyUisr6DU8T67N5U+1Q==} + engines: {node: '>=14.18.0'} + dependencies: + '@ljharb/through': 2.3.11 + ansi-escapes: 4.3.2 + chalk: 5.3.0 + cli-cursor: 3.1.0 + cli-width: 4.1.0 + external-editor: 3.1.0 + figures: 5.0.0 + lodash: 4.17.21 + mute-stream: 1.0.0 + ora: 5.4.1 + run-async: 3.0.0 + rxjs: 7.8.1 + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 6.2.0 + dev: false + + /is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + dev: false + + /is-interactive@1.0.0: + resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} + engines: {node: '>=8'} + dev: false + + /is-unicode-supported@0.1.0: + resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} + engines: {node: '>=10'} + dev: false + + /is-unicode-supported@1.3.0: + resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==} + engines: {node: '>=12'} + dev: false + + /lodash@4.17.21: + resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + dev: false + + /log-symbols@4.1.0: + resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} + engines: {node: '>=10'} + dependencies: + chalk: 4.1.2 + is-unicode-supported: 0.1.0 + dev: false + + /mimic-fn@2.1.0: + resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} + engines: {node: '>=6'} + dev: false + + /mute-stream@1.0.0: + resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: false + + /onetime@5.1.2: + resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} + engines: {node: '>=6'} + dependencies: + mimic-fn: 2.1.0 + dev: false + + /ora@5.4.1: + resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} + engines: {node: '>=10'} + dependencies: + bl: 4.1.0 + chalk: 4.1.2 + cli-cursor: 3.1.0 + cli-spinners: 2.9.2 + is-interactive: 1.0.0 + is-unicode-supported: 0.1.0 + log-symbols: 4.1.0 + strip-ansi: 6.0.1 + wcwidth: 1.0.1 + dev: false + + /os-tmpdir@1.0.2: + resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} + engines: {node: '>=0.10.0'} + dev: false + + /readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + dependencies: + inherits: 2.0.4 + string_decoder: 1.3.0 + util-deprecate: 1.0.2 + dev: false + + /restore-cursor@3.1.0: + resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} + engines: {node: '>=8'} + dependencies: + onetime: 5.1.2 + signal-exit: 3.0.7 + dev: false + + /run-async@3.0.0: + resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==} + engines: {node: '>=0.12.0'} + dev: false + + /rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + dependencies: + tslib: 2.6.2 + dev: false + + /safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + dev: false + + /safer-buffer@2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + dev: false + + /set-function-length@1.1.1: + resolution: {integrity: sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.1 + get-intrinsic: 1.2.2 + gopd: 1.0.1 + has-property-descriptors: 1.0.1 + dev: false + + /signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + dev: false + + /string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + dependencies: + emoji-regex: 8.0.0 + is-fullwidth-code-point: 3.0.0 + strip-ansi: 6.0.1 + dev: false + + /string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + dependencies: + safe-buffer: 5.2.1 + dev: false + + /strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + dependencies: + ansi-regex: 5.0.1 + dev: false + + /supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + dependencies: + has-flag: 4.0.0 + dev: false + + /tmp@0.0.33: + resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} + engines: {node: '>=0.6.0'} + dependencies: + os-tmpdir: 1.0.2 + dev: false + + /tslib@2.6.2: + resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + dev: false + + /type-fest@0.21.3: + resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} + engines: {node: '>=10'} + dev: false + + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + dev: false + + /util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + dev: false + + /wcwidth@1.0.1: + resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + dependencies: + defaults: 1.0.4 + dev: false + + /wrap-ansi@6.2.0: + resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} + engines: {node: '>=8'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + dev: false diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..77c586b --- /dev/null +++ b/src/index.js @@ -0,0 +1,12 @@ +// main.js + +import { selectPackages } from "./packageSelector.js"; + +selectPackages() + .then((selectedPackages) => { + console.log("Selected packages:", selectedPackages); + // Further processing with the selected packages and their commands + }) + .catch((error) => { + console.error("Error selecting packages:", error); + }); diff --git a/src/packageSelector.js b/src/packageSelector.js new file mode 100644 index 0000000..b471810 --- /dev/null +++ b/src/packageSelector.js @@ -0,0 +1,76 @@ +// packageSelector.js + +import chalk from "chalk"; +import fs from "fs"; +import inquirer from "inquirer"; +import os from "os"; + +export async function selectPackages() { + const packagesJson = fs.readFileSync("packageData.json", "utf8"); + const packagesData = JSON.parse(packagesJson); + + const currentOS = os.platform() === "win32" ? "windows" : os.platform() === "darwin" ? "mac" : "linux"; + + const choices = Object.entries(packagesData).flatMap(([category, packages]) => [ + new inquirer.Separator(chalk.red(`-- ${category} --`)), + ...Object.entries(packages) + .filter(([_, packageDetails]) => packageDetails.install[currentOS] !== "") + .map(([packageName, packageDetails]) => { + let choiceName = packageName; + if (packageDetails.description) { + choiceName += ` - ${packageDetails.description}`; + } + + if (packageDetails.type === "force") { + return { + name: choiceName, + checked: true, + disabled: chalk.yellow("Forced installation"), // This will disable the option to deselect + }; + } + + return { + name: choiceName, + checked: packageDetails.type === "enable", + }; + }), + ]); + + try { + const answers = await inquirer.prompt([ + { + type: "checkbox", + message: "Select packages to install", + name: "selectedPackages", + choices: choices, + pageSize: 15, + }, + ]); + + const forcedPackages = Object.entries(packagesData).flatMap(([category, packages]) => + Object.entries(packages) + .filter(([_, packageDetails]) => packageDetails.type === "force" && packageDetails.install[currentOS] !== "") + .map(([packageName, _]) => packageName) + ); + + const selectedPackages = [...new Set([...forcedPackages, ...answers.selectedPackages])]; + + return selectedPackages + .map((packageName) => { + for (const category in packagesData) { + if (packagesData[category][packageName]) { + const packageDetails = packagesData[category][packageName]; + return { + packageName, + installCommand: packageDetails.install[currentOS], + }; + } + } + return null; + }) + .filter((pkg) => pkg !== null); + } catch (error) { + console.error("An error occurred:", error); + throw error; + } +}