diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c6e50e4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,16 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - run: bun install + - run: bun run check diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..939cd89 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,22 @@ +name: Publish + +on: + push: + tags: + - "v*" + +jobs: + publish: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - uses: actions/setup-node@v4 + with: + node-version: "20" + registry-url: "https://registry.npmjs.org" + - run: bun install + - run: bun run build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 65e7a57..f7899d7 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,15 @@ { "name": "macctl", + "version": "0.1.0", + "description": "macOS CLI for controlling system settings (volume, screen, etc.) via AppleScript", "module": "src/index.ts", "type": "module", "bin": { - "macctl": "./src/index.ts" + "macctl": "./dist/index.js" }, + "files": [ + "dist" + ], "scripts": { "dev": "bun run src/index.ts", "build": "bun build ./src/index.ts --target bun --outdir ./dist", @@ -12,9 +17,10 @@ "lint": "biome lint src package.json tsconfig.json", "format": "biome format --write src package.json tsconfig.json", "check": "biome check src package.json tsconfig.json", - "check:fix": "biome check --write src package.json tsconfig.json" + "check:fix": "biome check --write src package.json tsconfig.json", + "prepublishOnly": "bun run build" }, - "private": true, + "license": "MIT", "devDependencies": { "@biomejs/biome": "^2.4.8", "@types/bun": "latest" diff --git a/src/commands/volume.ts b/src/commands/volume.ts index 10b57f7..6af3e71 100644 --- a/src/commands/volume.ts +++ b/src/commands/volume.ts @@ -7,6 +7,7 @@ import { setMute, setVolume, toggleMute, + type VolumeState, } from "../lib/volume"; function ensurePercent(value: number, field = "value"): number { @@ -93,7 +94,7 @@ export function createVolumeCommand() { .description("Mute controls") .argument("", "on | off | toggle") .action((state: string) => { - let result; + let result: VolumeState; if (state === "on") { result = setMute(true); diff --git a/src/index.ts b/src/index.ts index 4bcfcaf..168c724 100755 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ #!/usr/bin/env bun import { Command } from "commander"; -import { createVolumeCommand } from "./commands/volume"; import { createScreenCommand } from "./commands/screen"; +import { createVolumeCommand } from "./commands/volume"; const program = new Command();