diff --git a/.github/workflows/npm-publish-cli.yml b/.github/workflows/npm-publish-cli.yml new file mode 100644 index 00000000..4a1e6dd3 --- /dev/null +++ b/.github/workflows/npm-publish-cli.yml @@ -0,0 +1,43 @@ +name: Publish @trycua/cli to npm + +on: + push: + branches: main + +jobs: + publish: + permissions: + id-token: write + contents: read + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Check if version changed + id: check-version + uses: EndBug/version-check@v2 + with: + file-name: libs/typescript/cua-cli/package.json + diff-search: true + + - name: Install dependencies + if: steps.check-version.outputs.changed == 'true' + working-directory: ./libs/typescript/cua-cli + run: bun install --frozen-lockfile + + - name: Build package + if: steps.check-version.outputs.changed == 'true' + working-directory: ./libs/typescript/cua-cli + run: bun run build --if-present + + - name: Publish to npm + if: steps.check-version.outputs.changed == 'true' + working-directory: ./libs/typescript/cua-cli + run: bun publish --access public + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/libs/typescript/cua-cli/.prettierrc b/libs/typescript/cua-cli/.prettierrc new file mode 100644 index 00000000..123d3e80 --- /dev/null +++ b/libs/typescript/cua-cli/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": true, + "tabWidth": 2, + "useTabs": false +} diff --git a/libs/typescript/cua-cli/bun.lock b/libs/typescript/cua-cli/bun.lock index 50bf2d87..b91c382e 100644 --- a/libs/typescript/cua-cli/bun.lock +++ b/libs/typescript/cua-cli/bun.lock @@ -10,8 +10,8 @@ "devDependencies": { "@types/bun": "latest", "@types/yargs": "^17.0.33", - }, - "peerDependencies": { + "bumpp": "^10.1.0", + "prettier": "^3.0.0", "typescript": "^5", }, }, @@ -31,24 +31,86 @@ "ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="], + "ansis": ["ansis@4.2.0", "", {}, "sha512-HqZ5rWlFjGiV0tDm3UxxgNRqsOTniqoKZu0pIAfh7TZQMGuZK+hH0drySty0si0QXj1ieop4+SkSfPZBPPkHig=="], + + "args-tokenizer": ["args-tokenizer@0.3.0", "", {}, "sha512-xXAd7G2Mll5W8uo37GETpQ2VrE84M181Z7ugHFGQnJZ50M2mbOv0osSZ9VsSgPfJQ+LVG0prSi0th+ELMsno7Q=="], + + "bumpp": ["bumpp@10.3.1", "", { "dependencies": { "ansis": "^4.2.0", "args-tokenizer": "^0.3.0", "c12": "^3.3.0", "cac": "^6.7.14", "escalade": "^3.2.0", "jsonc-parser": "^3.3.1", "package-manager-detector": "^1.3.0", "semver": "^7.7.2", "tinyexec": "^1.0.1", "tinyglobby": "^0.2.15", "yaml": "^2.8.1" }, "bin": { "bumpp": "bin/bumpp.mjs" } }, "sha512-cOKPRFCWvHcYPJQAHN6V7Jp/wAfnyqQRXQ+2fgWIL6Gao20rpu7xQ1cGGo1APOfmbQmmHngEPg9Fy7nJ3giRkQ=="], + "bun-types": ["bun-types@1.3.0", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-u8X0thhx+yJ0KmkxuEo9HAtdfgCBaM/aI9K90VQcQioAmkVp3SG3FkwWGibUFz3WdXAdcsqOcbU40lK7tbHdkQ=="], + "c12": ["c12@3.3.2", "", { "dependencies": { "chokidar": "^4.0.3", "confbox": "^0.2.2", "defu": "^6.1.4", "dotenv": "^17.2.3", "exsolve": "^1.0.8", "giget": "^2.0.0", "jiti": "^2.6.1", "ohash": "^2.0.11", "pathe": "^2.0.3", "perfect-debounce": "^2.0.0", "pkg-types": "^2.3.0", "rc9": "^2.1.2" }, "peerDependencies": { "magicast": "*" }, "optionalPeers": ["magicast"] }, "sha512-QkikB2X5voO1okL3QsES0N690Sn/K9WokXqUsDQsWy5SnYb+psYQFGA10iy1bZHj3fjISKsI67Q90gruvWWM3A=="], + + "cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="], + + "chokidar": ["chokidar@4.0.3", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="], + + "citty": ["citty@0.1.6", "", { "dependencies": { "consola": "^3.2.3" } }, "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ=="], + "cliui": ["cliui@9.0.1", "", { "dependencies": { "string-width": "^7.2.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w=="], + "confbox": ["confbox@0.2.2", "", {}, "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ=="], + + "consola": ["consola@3.4.2", "", {}, "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA=="], + "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], + "defu": ["defu@6.1.4", "", {}, "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg=="], + + "destr": ["destr@2.0.5", "", {}, "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA=="], + + "dotenv": ["dotenv@17.2.3", "", {}, "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w=="], + "emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="], "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], + "exsolve": ["exsolve@1.0.8", "", {}, "sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA=="], + + "fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="], + "get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="], "get-east-asian-width": ["get-east-asian-width@1.4.0", "", {}, "sha512-QZjmEOC+IT1uk6Rx0sX22V6uHWVwbdbxf1faPqJ1QhLdGgsRGCZoyaQBm/piRdJy/D2um6hM1UP7ZEeQ4EkP+Q=="], + "giget": ["giget@2.0.0", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.0", "defu": "^6.1.4", "node-fetch-native": "^1.6.6", "nypm": "^0.6.0", "pathe": "^2.0.3" }, "bin": { "giget": "dist/cli.mjs" } }, "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA=="], + + "jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="], + + "jsonc-parser": ["jsonc-parser@3.3.1", "", {}, "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ=="], + + "node-fetch-native": ["node-fetch-native@1.6.7", "", {}, "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q=="], + + "nypm": ["nypm@0.6.2", "", { "dependencies": { "citty": "^0.1.6", "consola": "^3.4.2", "pathe": "^2.0.3", "pkg-types": "^2.3.0", "tinyexec": "^1.0.1" }, "bin": { "nypm": "dist/cli.mjs" } }, "sha512-7eM+hpOtrKrBDCh7Ypu2lJ9Z7PNZBdi/8AT3AX8xoCj43BBVHD0hPSTEvMtkMpfs8FCqBGhxB+uToIQimA111g=="], + + "ohash": ["ohash@2.0.11", "", {}, "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ=="], + + "package-manager-detector": ["package-manager-detector@1.5.0", "", {}, "sha512-uBj69dVlYe/+wxj8JOpr97XfsxH/eumMt6HqjNTmJDf/6NO9s+0uxeOneIz3AsPt2m6y9PqzDzd3ATcU17MNfw=="], + + "pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="], + + "perfect-debounce": ["perfect-debounce@2.0.0", "", {}, "sha512-fkEH/OBiKrqqI/yIgjR92lMfs2K8105zt/VT6+7eTjNwisrsh47CeIED9z58zI7DfKdH3uHAn25ziRZn3kgAow=="], + + "picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="], + + "pkg-types": ["pkg-types@2.3.0", "", { "dependencies": { "confbox": "^0.2.2", "exsolve": "^1.0.7", "pathe": "^2.0.3" } }, "sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig=="], + + "prettier": ["prettier@3.6.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="], + + "rc9": ["rc9@2.1.2", "", { "dependencies": { "defu": "^6.1.4", "destr": "^2.0.3" } }, "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg=="], + + "readdirp": ["readdirp@4.1.2", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="], + + "semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="], + "string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="], "strip-ansi": ["strip-ansi@7.1.2", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA=="], + "tinyexec": ["tinyexec@1.0.2", "", {}, "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg=="], + + "tinyglobby": ["tinyglobby@0.2.15", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="], + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], @@ -57,6 +119,8 @@ "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="], + "yaml": ["yaml@2.8.1", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw=="], + "yargs": ["yargs@18.0.0", "", { "dependencies": { "cliui": "^9.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "string-width": "^7.2.0", "y18n": "^5.0.5", "yargs-parser": "^22.0.0" } }, "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg=="], "yargs-parser": ["yargs-parser@22.0.0", "", {}, "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="], diff --git a/libs/typescript/cua-cli/package.json b/libs/typescript/cua-cli/package.json index 0651e521..b9469d71 100644 --- a/libs/typescript/cua-cli/package.json +++ b/libs/typescript/cua-cli/package.json @@ -1,19 +1,45 @@ { - "name": "cua-cli", - "module": "index.ts", + "name": "@trycua/cli", + "version": "0.1.0", + "packageManager": "bun@1.1.38", + "description": "Command-line interface for CUA cloud VMs and authentication", "type": "module", - "private": true, - "devDependencies": { - "@types/bun": "latest", - "@types/yargs": "^17.0.33" + "license": "MIT", + "homepage": "https://github.com/trycua/cua/tree/main/libs/typescript/cua-cli", + "bugs": { + "url": "https://github.com/trycua/cua/issues" }, - "peerDependencies": { - "typescript": "^5" + "repository": { + "type": "git", + "url": "git+https://github.com/trycua/cua.git" }, + "author": "cua", + "files": [ + "index.ts", + "src", + "README.md" + ], "bin": { "cua": "./index.ts" }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "lint": "prettier --check .", + "lint:fix": "prettier --write .", + "typecheck": "tsc --noEmit", + "release": "bumpp && bun publish", + "prepublishOnly": "bun run typecheck" + }, "dependencies": { "yargs": "^18.0.0" + }, + "devDependencies": { + "@types/bun": "latest", + "@types/yargs": "^17.0.33", + "bumpp": "^10.1.0", + "prettier": "^3.0.0", + "typescript": "^5" } } diff --git a/scripts/install-cli.ps1 b/scripts/install-cli.ps1 new file mode 100644 index 00000000..a3036a08 --- /dev/null +++ b/scripts/install-cli.ps1 @@ -0,0 +1,65 @@ +# CUA CLI Installation Script for Windows +$ErrorActionPreference = "Stop" + +Write-Host "🚀 Installing CUA CLI..." -ForegroundColor Green + +# Check if bun is already installed +try { + $bunVersion = bun --version 2>$null + Write-Host "✅ Bun is already installed (version $bunVersion)" -ForegroundColor Green +} catch { + Write-Host "📦 Installing Bun..." -ForegroundColor Yellow + try { + powershell -c "irm bun.sh/install.ps1|iex" + + # Refresh environment variables + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + + # Add bun to PATH for this session if not already there + $bunPath = "$env:USERPROFILE\.bun\bin" + if ($env:Path -notlike "*$bunPath*") { + $env:Path = "$bunPath;$env:Path" + } + } catch { + Write-Host "❌ Failed to install Bun. Please install manually from https://bun.sh" -ForegroundColor Red + exit 1 + } +} + +# Verify bun installation +try { + $bunVersion = bun --version 2>$null + Write-Host "✅ Bun verified (version $bunVersion)" -ForegroundColor Green +} catch { + Write-Host "❌ Bun installation failed. Please install manually from https://bun.sh" -ForegroundColor Red + exit 1 +} + +Write-Host "📦 Installing CUA CLI..." -ForegroundColor Yellow +try { + bun add -g @trycua/cli +} catch { + Write-Host "❌ Failed to install CUA CLI with Bun. Trying with npm..." -ForegroundColor Yellow + try { + npm install -g @trycua/cli + } catch { + Write-Host "❌ Installation failed. Please ensure you have Node.js or Bun installed." -ForegroundColor Red + exit 1 + } +} + +# Verify installation +try { + $cuaVersion = cua --version 2>$null + Write-Host "✅ CUA CLI installed successfully!" -ForegroundColor Green + Write-Host "" + Write-Host "🎉 Get started with:" -ForegroundColor Cyan + Write-Host " cua auth login" -ForegroundColor White + Write-Host " cua vm create --os linux --configuration small --region north-america" -ForegroundColor White + Write-Host "" + Write-Host "📚 For more help, visit: https://docs.cua.ai/libraries/cua-cli" -ForegroundColor Cyan +} catch { + Write-Host "❌ Installation verification failed. Please try installing manually:" -ForegroundColor Red + Write-Host " npm install -g @trycua/cli" -ForegroundColor White + exit 1 +} diff --git a/scripts/install-cli.sh b/scripts/install-cli.sh new file mode 100644 index 00000000..e30b0ba8 --- /dev/null +++ b/scripts/install-cli.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# CUA CLI Installation Script for macOS/Linux +echo "🚀 Installing CUA CLI..." + +# Check if bun is already installed +if command -v bun &> /dev/null; then + echo "✅ Bun is already installed" +else + echo "📦 Installing Bun..." + curl -fsSL https://bun.sh/install | bash + + # Source the shell profile to make bun available + if [ -f "$HOME/.bashrc" ]; then + source "$HOME/.bashrc" + elif [ -f "$HOME/.zshrc" ]; then + source "$HOME/.zshrc" + fi + + # Add bun to PATH for this session + export PATH="$HOME/.bun/bin:$PATH" +fi + +# Verify bun installation +if ! command -v bun &> /dev/null; then + echo "❌ Failed to install Bun. Please install manually from https://bun.sh" + exit 1 +fi + +echo "📦 Installing CUA CLI..." +bun add -g @trycua/cli + +# Verify installation +if command -v cua &> /dev/null; then + echo "✅ CUA CLI installed successfully!" + echo "" + echo "🎉 Get started with:" + echo " cua auth login" + echo " cua vm create --os linux --configuration small --region north-america" + echo "" + echo "📚 For more help, visit: https://docs.cua.ai/libraries/cua-cli" +else + echo "❌ Installation failed. Please try installing manually:" + echo " npm install -g @trycua/cli" + exit 1 +fi