diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3c17b5..bb4d263 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,25 @@ jobs: run: bun install - name: Type check - run: bun run tsc --noEmit + run: bun run typecheck - - name: Test build + - name: Build for npm + run: npm run build:js + + - name: Test npm CLI + run: node dist/cli.js --help + + - name: Test npm pack and install + run: | + npm pack + npm install -g factory-nanobanana-*.tgz + nanobanana --help + nanobanana tips generate + + - name: Build standalone binary run: bun build cli.ts --compile --outfile nanobanana - - name: Test CLI + - name: Test standalone CLI run: ./nanobanana --help unit-tests: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2be1bc9..5628e04 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: permissions: contents: write + id-token: write jobs: build: @@ -109,3 +110,30 @@ jobs: ``` Get an API key at https://aistudio.google.com/apikey + + publish-npm: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '24' + registry-url: 'https://registry.npmjs.org' + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Build for npm + run: npm run build:js + + - name: Publish to npm + run: npm publish --access public diff --git a/.gitignore b/.gitignore index 1fc5709..55e5835 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +dist/ nanobanana-output/ nanobanana nanobanana-linux diff --git a/README.md b/README.md index 1e044fe..d70f704 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,19 @@

nanobanana

- Gemini image generation from the command line. Single binary, no dependencies. + Gemini image generation from the command line.

## Installation +### npm (recommended) + +```bash +npm install -g @factory/nanobanana +``` + +### Standalone binary + ```bash # macOS (Apple Silicon) curl -L https://github.com/Factory-AI/nanobanana-cli/releases/latest/download/nanobanana-darwin-arm64 -o nanobanana @@ -29,7 +37,9 @@ chmod +x nanobanana Invoke-WebRequest -Uri "https://github.com/Factory-AI/nanobanana-cli/releases/latest/download/nanobanana-windows-x64.exe" -OutFile "nanobanana.exe" ``` -Then set your API key: +## Setup + +Set your API key: ```bash # macOS/Linux diff --git a/bun.lock b/bun.lock index ee772c4..8a3abaa 100644 --- a/bun.lock +++ b/bun.lock @@ -6,11 +6,20 @@ "dependencies": { "@google/genai": "^0.7.0", }, + "devDependencies": { + "@types/bun": "^1.3.6", + "@types/node": "^25.0.9", + "typescript": "^5.9.3", + }, }, }, "packages": { "@google/genai": ["@google/genai@0.7.0", "", { "dependencies": { "google-auth-library": "^9.14.2", "ws": "^8.18.0" } }, "sha512-r+Fwj/emnXZN5R+4JCxDXboY4AGTmTn7+Wnori5dgyJiStP0P82f9YYL0CVsCnDIumNY2i0UIcZ1zGZdtHJ34w=="], + "@types/bun": ["@types/bun@1.3.6", "", { "dependencies": { "bun-types": "1.3.6" } }, "sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA=="], + + "@types/node": ["@types/node@25.0.9", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw=="], + "agent-base": ["agent-base@7.1.4", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="], "base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="], @@ -19,6 +28,8 @@ "buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="], + "bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="], + "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], "ecdsa-sig-formatter": ["ecdsa-sig-formatter@1.0.11", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ=="], @@ -53,6 +64,10 @@ "tr46": ["tr46@0.0.3", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="], + "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=="], + "uuid": ["uuid@9.0.1", "", { "bin": { "uuid": "dist/bin/uuid" } }, "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA=="], "webidl-conversions": ["webidl-conversions@3.0.1", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="], diff --git a/cli.ts b/cli.ts index 6d20d07..0890ee5 100644 --- a/cli.ts +++ b/cli.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env bun +#!/usr/bin/env node import { parseArgs, @@ -7,7 +7,7 @@ import { story, showTips, showHelp, -} from "./lib"; +} from "./lib.js"; async function main() { const args = process.argv.slice(2); diff --git a/package.json b/package.json index 9551b55..70883e7 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,50 @@ { - "name": "nanobanana-cli", - "version": "1.0.0", + "name": "@factory/nanobanana", + "publishConfig": { + "access": "public" + }, + "version": "1.0.1", "description": "CLI for Gemini image generation (Nano Banana Pro)", "type": "module", + "main": "dist/lib.js", + "types": "dist/lib.d.ts", "bin": { - "nanobanana": "./cli.ts" + "nanobanana": "dist/cli.js" }, + "files": [ + "dist" + ], "scripts": { "start": "bun run cli.ts", "test": "bun test", "test:unit": "bun test tests/unit.test.ts", "test:e2e": "bun test tests/e2e.test.ts", "test:integration": "bun test tests/integration.test.ts --timeout 180000", + "typecheck": "tsc -p tsconfig.test.json --noEmit", + "build:js": "tsc", "build": "bun build cli.ts --compile --outfile nanobanana", "build:linux": "bun build cli.ts --compile --target=bun-linux-x64 --outfile nanobanana-linux", "build:mac": "bun build cli.ts --compile --target=bun-darwin-arm64 --outfile nanobanana-mac", - "build:windows": "bun build cli.ts --compile --target=bun-windows-x64 --outfile nanobanana.exe" + "build:windows": "bun build cli.ts --compile --target=bun-windows-x64 --outfile nanobanana.exe", + "prepublishOnly": "npm run build:js" }, - "keywords": ["gemini", "image-generation", "ai", "cli"], + "keywords": ["gemini", "image-generation", "ai", "cli", "generative-ai"], "author": "Eno Reyes", "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/Factory-AI/nanobanana-cli.git" + }, + "homepage": "https://github.com/Factory-AI/nanobanana-cli#readme", + "engines": { + "node": ">=18" + }, "dependencies": { "@google/genai": "^0.7.0" + }, + "devDependencies": { + "@types/bun": "^1.3.6", + "@types/node": "^25.0.9", + "typescript": "^5.9.3" } } diff --git a/tsconfig.json b/tsconfig.json index 6282e8a..f73081c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,15 @@ { "compilerOptions": { "target": "ES2022", - "module": "ESNext", - "moduleResolution": "bundler", + "module": "NodeNext", + "moduleResolution": "NodeNext", "esModuleInterop": true, "strict": true, + "skipLibCheck": true, "outDir": "dist", - "rootDir": "src", "declaration": true, - "skipLibCheck": true + "types": ["node"] }, - "include": ["src/**/*"] + "include": ["lib.ts", "cli.ts"], + "exclude": ["dist", "node_modules", "tests"] } diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000..f5be13a --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "noEmit": true, + "types": ["bun-types"] + }, + "include": ["*.ts", "tests/**/*"], + "exclude": ["dist", "node_modules"] +}