Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Run lint
run: npm run lint

deno:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.2.6

- name: Cache dependencies
run: deno cache source/cli.tsx

- name: Run tests
run: deno test --allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys

- name: Run lint
run: deno lint

- name: Run format check
run: deno fmt --check
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.2.6

- name: Build for macOS (arm64)
run: |
deno compile --target aarch64-apple-darwin \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output permit-cli-macos-arm64 source/cli.tsx

- name: Build for macOS (x64)
run: |
deno compile --target x86_64-apple-darwin \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output permit-cli-macos-x64 source/cli.tsx

- name: Build for Linux (x64)
run: |
deno compile --target x86_64-unknown-linux-gnu \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output permit-cli-linux-x64 source/cli.tsx

- name: Build for Windows (x64)
run: |
deno compile --target x86_64-pc-windows-msvc \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output permit-cli-windows-x64.exe source/cli.tsx

- name: Install create-dmg
run: |
brew install create-dmg

- name: Create DMG for macOS (arm64)
run: |
mkdir -p dmg/arm64
cp permit-cli-macos-arm64 dmg/arm64/permit
create-dmg \
--volname "Permit CLI" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "permit" 200 190 \
--hide-extension "permit" \
--app-drop-link 600 185 \
"permit-cli-macos-arm64.dmg" \
"dmg/arm64/"

- name: Create DMG for macOS (x64)
run: |
mkdir -p dmg/x64
cp permit-cli-macos-x64 dmg/x64/permit
create-dmg \
--volname "Permit CLI" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "permit" 200 190 \
--hide-extension "permit" \
--app-drop-link 600 185 \
"permit-cli-macos-x64.dmg" \
"dmg/x64/"

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
permit-cli-macos-arm64
permit-cli-macos-x64
permit-cli-linux-x64
permit-cli-windows-x64.exe
permit-cli-macos-arm64.dmg
permit-cli-macos-x64.dmg
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,9 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*

# Deno build artifacts
permit-cli
permit-cli.exe
dist/
66 changes: 44 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Permit CLI [![test](https://github.com/permitio/permit-cli/actions/workflows/node.js.yml/badge.svg)](https://github.com/vadimdemedes/pastel/actions/workflows/node.js.yml) [![Join our Slack!](https://img.shields.io/badge/Slack%20Community-4A154B?logo=slack&logoColor=white)](https://io.permit.io/cli-slack) ![Early Stage Development](https://img.shields.io/badge/⚠️_Early_Stage_Development-2B1400) ![Follow us on LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)
# Permit CLI [![test](https://github.com/permitio/permit-cli/actions/workflows/node.js.yml/badge.svg)](https://github.com/permitio/permit-cli/actions/workflows/node.js.yml) [![Join our Slack!](https://img.shields.io/badge/Slack%20Community-4A154B?logo=slack&logoColor=white)](https://io.permit.io/cli-slack) ![Early Stage Development](https://img.shields.io/badge/⚠️_Early_Stage_Development-2B1400) ![Follow us on LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)

<p align="center">
<a href="https://www.permit.io/?utm_source=github&utm_medium=referral&utm_campaign=cli" align="center">
Expand All @@ -15,12 +15,35 @@ The **Permit CLI** is an open-source command-line utility that empowers develope

## Installation

Permit CLI is now available only via the `npm` and requires a [Node.js installation](https://nodejs.org/en/download) to run
### Quick Install (All Platforms)

```console
npm install -g @permitio/cli
```bash
# Using curl
curl -fsSL https://raw.githubusercontent.com/permitio/permit-cli/main/install.sh | sh
```

### Windows

```powershell
# Using PowerShell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/permitio/permit-cli/main/install.ps1'))
```

### macOS

```bash
# Using Homebrew
brew tap permitio/permit
brew install permit
```

### Manual Installation

1. Download the binary for your platform from our [releases page](https://github.com/permitio/permit-cli/releases)
2. Rename it to `permit` (or `permit.exe` on Windows)
3. Move it to a directory in your PATH
4. Make it executable (Unix-like systems only): `chmod +x permit`

## Usage

All the commands in the CLI are available via the `permit` command in the following convention:
Expand Down Expand Up @@ -92,7 +115,7 @@ This command will log you out from your Permit account and remove the stored key
#### Example

```bash
permit logout
$ permit logout
```

---
Expand Down Expand Up @@ -144,7 +167,7 @@ Use this command to perform an authorization check against the PDP. The command
#### Example

```bash
$ permit pdp check --user eventHandler --action update --resource Widget:dashboard-1-widget
permit pdp check --user eventHandler --action update --resource Widget:dashboard-1-widget
```

### `pdp stats`
Expand All @@ -162,7 +185,7 @@ Use this command to view statistics about your PDP's performance and usage. This
#### Example

```bash
$ permit pdp stats
permit pdp stats
```

---
Expand All @@ -187,7 +210,7 @@ Developers and CI pipelines can use this command to enable secure blue-green dep
#### Example

```bash
$ permit env copy --key permit_key_.......... --from staging --to production --conflict-strategy overwrite
permit env copy --key permit_key_.......... --from staging --to production --conflict-strategy overwrite
```

### `env create`
Expand All @@ -206,13 +229,13 @@ This command creates a new environment in a specified project. This is useful fo
#### Example

```bash
$ permit env create --key permit_key_.......... --name "Staging" --description "Staging environment for testing"
permit env create --key permit_key_.......... --name "Staging" --description "Staging environment for testing"
```

**You can also create a complex environment with all options:**

```bash
$ permit env create --apiKey permit_key_.......... --name "Development" --envKey "dev" --description "Dev environment" --customBranchName "dev-branch" --jwks '{"ttl": 3600}' --settings '{"debug": true}'
permit env create --api-key permit_key_.......... --name "Development" --env-key "dev" --description "Dev environment" --custom-branch-name "dev-branch" --jwks '{"ttl": 3600}' --settings '{"debug": true}'
```

### `env delete`
Expand All @@ -228,13 +251,13 @@ This command deletes an existing environment. Use with caution as this operation
#### Example

```bash
$ permit env delete --key permit_key_.......... --environmentId env_456
permit env delete --key permit_key_.......... --environment-id env_456
```

**Or to force deletion without confirmation:**

```bash
$ permit env delete --key permit_key_.......... --environmentId env_456 --force
permit env delete --key permit_key_.......... --environment-id env_456 --force
```

> **Note:** If you've authenticated via `permit login`, the commands will use your current project context automatically.
Expand All @@ -256,7 +279,7 @@ This command can run in the CI after creating a new environment for development
#### Example

```bash
$ permit env member --key permit_key_.......... --environment staging --project my-project --email gabriel@permit.io --role Owner
permit env member --key permit_key_.......... --environment staging --project my-project --email gabriel@permit.io --role Owner
```

### `env select`
Expand All @@ -270,31 +293,30 @@ This command will let you select a different active Permit.io environment. This
#### Example

```bash
$ permit env select --key permit_key_.........
permit env select --key permit_key_.........
```

### `env export terraform`

This command exports your Permit environment configuration as a Terraform HCL file. This is useful for users who want to start working with Terraform after configuring their Permit settings through the UI or API. The command export all environment content (resources, roles, user sets, resource sets, condition sets) in the Permit Terraform provider format.

Options
#### Options

- `--key <string>` (Optional) - a Permit API key to authenticate the operation. If not provided, the command will use the AuthProvider to get the API key you logged in with.

- `--file <string>` (Optional) - a file path where the exported HCL should be saved. If not provided, the output will be printed to the console.
- `--file <string>` (Optional) - the file to export the configuration to (will prompt if not provided)

### Example

### Using the permit key

```bash
$ permit env export terraform --key permit_key_.......... --file permit-config.tf
permit env export terraform --key permit_key_.......... --file permit-config.tf
```

### With login session

```bash
$ permit env export terraform --file permit-config.tf
permit env export terraform --file permit-config.tf
```

### output configuration to console
Expand All @@ -318,7 +340,7 @@ Use this command to list all the available policy templates to apply to your env
#### Example

```bash
$ permit env template list
permit env template list
```

### `env template apply`
Expand All @@ -335,7 +357,7 @@ The command is using the Terraform provider to apply the template, but it's not
#### Example

```bash
$ permit env template apply --template my-template
permit env template apply --template my-template
```

---
Expand All @@ -356,7 +378,7 @@ This command will print the available policies of an active OPA instance. This i
#### Example

```bash
$ permit opa policy --server-url http://localhost:8181 --api-key permit_key_..........
permit opa policy --server-url http://localhost:8181 --api-key permit_key_..........
```

---
Expand Down
47 changes: 47 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Create build directory
mkdir -p dist

# Build for macOS (arm64)
echo "Building for macOS (arm64)..."
deno compile \
--target aarch64-apple-darwin \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output dist/permit-cli-macos-arm64 source/cli.tsx

# Build for macOS (x64)
echo "Building for macOS (x64)..."
deno compile \
--target x86_64-apple-darwin \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output dist/permit-cli-macos-x64 source/cli.tsx

# Build for Linux (x64)
echo "Building for Linux (x64)..."
deno compile \
--target x86_64-unknown-linux-gnu \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output dist/permit-cli-linux-x64 source/cli.tsx

# Build for Windows (x64)
echo "Building for Windows (x64)..."
deno compile \
--target x86_64-pc-windows-msvc \
--allow-read --allow-write --allow-net --allow-env --allow-run --allow-sys \
--output dist/permit-cli-windows-x64.exe source/cli.tsx

# Create zip archives
echo "Creating zip archives..."
cd dist
zip permit-cli-macos-arm64.zip permit-cli-macos-arm64
zip permit-cli-macos-x64.zip permit-cli-macos-x64
zip permit-cli-linux-x64.zip permit-cli-linux-x64
zip permit-cli-windows-x64.zip permit-cli-windows-x64.exe
cd ..

# Build npm package
echo "Building npm package..."
npm run build

echo "Build complete! Check the dist directory for the compiled binaries and zip files."
Loading
Loading