Skip to content

Commit

Permalink
Quality assurance
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ committed Sep 10, 2024
1 parent 0f25061 commit 5d3241b
Show file tree
Hide file tree
Showing 13 changed files with 554 additions and 448 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-phar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build PHAR
on:
release:
types: [ created ]

jobs:
build-phar:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer:v2

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Composer install
run: composer install --prefer-dist --no-progress --optimize-autoloader

- name: Generate PHAR file
run: composer build

- name: Upload phar to release
uses: softprops/action-gh-release@v2
with:
files: build/bin/unolia.phar
36 changes: 36 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Linting
on:
workflow_dispatch:
pull_request: ~
push:
branches-ignore:
- 'dependabot/npm_and_yarn/*'
jobs:
pint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer:v2

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Composer install
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Launch Pint inspection
run: composer pint
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on:
pull_request: ~
push:
branches:
- main

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
php: [8.2, 8.3]

name: Test with php ${{ matrix.php }} on ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Run tests
run: ./vendor/bin/pest
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Eser DENIZ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 49 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,75 @@
![Packagist PHP Version](https://img.shields.io/packagist/dependency-v/unolia/unolia-cli/php)
![Packagist License (custom server)](https://img.shields.io/packagist/l/unolia/unolia-cli)

Unolia CLI is a command line interface for Unolia API.
Unolia CLI is a command line interface for managing your DNS records across different providers. It uses [Unolia API](https://app.unolia.com/docs/#/) to unify your provider under the same API. Check out [unolia.com](https://unolia.com) for more information.

Check out [unolia.com](https://unolia.com) for more information.
Currently supported providers:
- [Amazon Route 53](https://aws.amazon.com/route53/)
- [Bunnynet](https://bunny.net/)
- [Cloudflare](https://www.cloudflare.com/)
- [Digitalocean](https://www.digitalocean.com/)
- [Gandi](https://www.gandi.net/)
- [Ionos](https://www.ionos.fr/)
- [OVH](https://www.ovh.com/)
- Namecheap (soon)
- Porkbun (soon)
- Godaddy

## Installation
Current installation requires you to have PHP and Composer installed on your computer. After that, it's as simple as that:
```bash
composer global require unolia/unolia-cli
```

## Configuration
## Connect your accounts
If it's the first time you are using Unolia, [add your first providers](https://app.unolia.com/providers).

Then you can log in for a 30-day period with this command:
```bash
unolia login
```
or

If you prefer a longer lifetime, [create a token](https://unolia.test/user/api-tokens) for your user account or one dedicated to your team and use the token as follows:
```bash
unolia login --token={TOKEN}
```

## Basic usage
## Usage
List information about the current user
```bash
# List information about the current user
unolia me
unolia teams

# List all domains
```
List all domains
```bash
unolia domain:list

# List all records for a domain
unolia domain:records unolia.com

# Add, update and remove records
unolia domain:add unolia.com mx mg.unolia.com "10 mxa.eu.mailgun.org"
unolia domain:add unolia.com mx mg.unolia.com "10 mxb.eu.mailgun.org"
```
List all records for a domain
```bash
unolia domain:records example.com
```
Add, update and remove records
```bash
unolia domain:add example.com MX mg.example.com "10 mxa.eu.mailgun.org"
unolia domain:add example.com MX mg.example.com "10 mxb.eu.mailgun.org"
unolia domain:update {ID}
unolia domain:remove {ID}

# Check DNS records
```
Check DNS records
```bash
unolia dig unolia.com TXT
unolia dig unolia.com A
```


## Upgrade
Installed with composer:
```bash
composer global update unolia/unolia-cli
```

## Credits
**unolia-cli** was created by Eser DENIZ.

## License
**unolia-cli** PHP is licensed under the MIT License. See LICENSE for more information.
2 changes: 1 addition & 1 deletion app/Commands/DomainListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle()
{
$connector = Helpers::getApiConnector();

$response = $connector->paginate(new Domains());
$response = $connector->paginate(new Domains);

$table = $response->collect()->map(fn ($domain) => [
'Domain' => $domain['domain'],
Expand Down
6 changes: 3 additions & 3 deletions app/Commands/LoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function handle()

if (! empty($token)) {
try {
$verify = $connector->send(new CurrentToken());
$verify = $connector->send(new CurrentToken);
$verify->throw();

$this->line('You are already logged in.');
Expand Down Expand Up @@ -98,7 +98,7 @@ public function handle()

$connector = Helpers::getApiConnector($token);
try {
$response = $connector->send(new CurrentToken());
$response = $connector->send(new CurrentToken);
$response->throw();
} catch (\Exception $e) {
$this->error('Failed to authenticate with the API: '.$e->getMessage());
Expand All @@ -108,7 +108,7 @@ public function handle()

$current_token = $response->json('data');

$response = $connector->send(new CurrentAuthenticated());
$response = $connector->send(new CurrentAuthenticated);

if ($response->failed()) {
$this->error('Failed to fetch user details: '.($response->json('message') ?: 'Unknown error'));
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/LogoutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function handle()
}

$connector = Helpers::getAuthConnector();
$logout = $connector->send(new Logout());
$logout = $connector->send(new Logout);

if ($logout->failed() && ! $this->option('force')) {
$this->error('Logout failed: '.$logout->json('message'));
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/MeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function handle()
{
$connector = Helpers::getApiConnector();

$response = $connector->send(new CurrentToken());
$response = $connector->send(new CurrentToken);

if ($response->failed()) {
$this->error('Failed to fetch token info: '.($response->json('message') ?: 'Unknown error'));
Expand All @@ -27,7 +27,7 @@ public function handle()

$token = $response->json('data');

$response = $connector->send(new CurrentAuthenticated());
$response = $connector->send(new CurrentAuthenticated);

if ($response->failed()) {
$this->error('Failed to fetch user details: '.($response->json('message') ?: 'Unknown error'));
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/TeamsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function handle()
{
$connector = Helpers::getApiConnector();

$response = $connector->send(new Teams());
$response = $connector->send(new Teams);

$table = $response->collect('data')->map(fn ($team) => [
'ID' => $team['id'],
Expand Down
Binary file modified builds/unolia
Binary file not shown.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": "^8.2|^8.3",
"php": "^8.2",
"laravel-zero/phar-updater": "^1.3",
"laravel/prompts": "^0.1.20",
"react/dns": "^1.12",
Expand Down Expand Up @@ -45,6 +45,7 @@
"test": "./vendor/bin/pest -p",
"pint": "./vendor/bin/pint",
"phpstan": "./vendor/bin/phpstan",
"build": "@php unolia app:build",
"qa": [
"@composer pint",
"@composer phpstan",
Expand Down
Loading

0 comments on commit 5d3241b

Please sign in to comment.