Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cxj/laravel-looking-glass-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.0
Choose a base ref
...
head repository: cxj/laravel-looking-glass-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Mar 5, 2023

  1. Update CHANGELOG

    cxj authored and github-actions[bot] committed Mar 5, 2023
    Copy the full SHA
    b678c5b View commit details
  2. Extran "About" information.

    cxj committed Mar 5, 2023
    Copy the full SHA
    d442dd9 View commit details

Commits on Mar 6, 2023

  1. Copy the full SHA
    5314715 View commit details
  2. Copy the full SHA
    6099b55 View commit details
  3. Remove debugging.

    cxj committed Mar 6, 2023
    Copy the full SHA
    c2c6ef2 View commit details
  4. Update

    cxj authored Mar 6, 2023
    Copy the full SHA
    ca40a62 View commit details
  5. Create SECURITY.md

    cxj authored Mar 6, 2023
    Copy the full SHA
    2b43c06 View commit details
  6. Update CHANGELOG

    cxj authored and github-actions[bot] committed Mar 6, 2023
    Copy the full SHA
    fe6f4ad View commit details
  7. A couple simple tests.

    cxj committed Mar 6, 2023
    Copy the full SHA
    0a385b8 View commit details
  8. Copy the full SHA
    356fa8f View commit details
  9. Copy the full SHA
    f2c0220 View commit details

Commits on Mar 7, 2023

  1. Update CHANGELOG

    cxj authored and github-actions[bot] committed Mar 7, 2023
    Copy the full SHA
    ac68253 View commit details

Commits on Mar 21, 2023

  1. Update README.md

    cxj authored Mar 21, 2023
    Copy the full SHA
    e3a2510 View commit details

Commits on Mar 25, 2023

  1. Apply fixes from StyleCI

    StyleCIBot committed Mar 25, 2023
    Copy the full SHA
    003f8e9 View commit details
  2. Merge pull request #1 from cxj/analysis-7WQRZj

    Apply fixes from StyleCI
    cxj authored Mar 25, 2023
    Copy the full SHA
    5f1c8b4 View commit details
  3. Update README.md

    cxj authored Mar 25, 2023
    Copy the full SHA
    33623e4 View commit details

Commits on Apr 24, 2023

  1. Bump dependabot/fetch-metadata from 1.3.6 to 1.4.0

    Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.3.6 to 1.4.0.
    - [Release notes](https://github.com/dependabot/fetch-metadata/releases)
    - [Commits](dependabot/fetch-metadata@v1.3.6...v1.4.0)
    
    ---
    updated-dependencies:
    - dependency-name: dependabot/fetch-metadata
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 24, 2023
    Copy the full SHA
    9612ffe View commit details
  2. Merge pull request #2 from cxj/dependabot/github_actions/dependabot/f…

    …etch-metadata-1.4.0
    
    Bump dependabot/fetch-metadata from 1.3.6 to 1.4.0
    github-actions[bot] authored Apr 24, 2023
    Copy the full SHA
    dc7102e View commit details

Commits on May 29, 2023

  1. Bump dependabot/fetch-metadata from 1.4.0 to 1.5.1

    Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.4.0 to 1.5.1.
    - [Release notes](https://github.com/dependabot/fetch-metadata/releases)
    - [Commits](dependabot/fetch-metadata@v1.4.0...v1.5.1)
    
    ---
    updated-dependencies:
    - dependency-name: dependabot/fetch-metadata
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored May 29, 2023
    Copy the full SHA
    ba71586 View commit details
  2. Merge pull request #3 from cxj/dependabot/github_actions/dependabot/f…

    …etch-metadata-1.5.1
    
    Bump dependabot/fetch-metadata from 1.4.0 to 1.5.1
    github-actions[bot] authored May 29, 2023
    Copy the full SHA
    cd157f3 View commit details

Commits on Jul 3, 2023

  1. Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0

    Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.5.1 to 1.6.0.
    - [Release notes](https://github.com/dependabot/fetch-metadata/releases)
    - [Commits](dependabot/fetch-metadata@v1.5.1...v1.6.0)
    
    ---
    updated-dependencies:
    - dependency-name: dependabot/fetch-metadata
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jul 3, 2023
    Copy the full SHA
    839354f View commit details
  2. Merge pull request #4 from cxj/dependabot/github_actions/dependabot/f…

    …etch-metadata-1.6.0
    
    Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0
    github-actions[bot] authored Jul 3, 2023
    Copy the full SHA
    915a58c View commit details
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.6
uses: dependabot/fetch-metadata@v1.6.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Changelog

All notable changes to `laravel-looking-glass-client` will be documented in this file.

## Adds a pair of simple tests, cleans up some rough edges - 2023-03-07

**Full Changelog**: https://github.com/cxj/laravel-looking-glass-client/compare/0.1.0...0.3.0

## Minor bug fixes and improvements - 2023-03-06

**Full Changelog**: https://github.com/cxj/laravel-looking-glass-client/compare/0.1.0...0.2.0

## Initial public release - 2023-03-05

- This is the initial release to Packagist so that this library is directly usable by any Composer-based Laravel project.
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,13 +2,12 @@

[![Latest Version on Packagist](https://img.shields.io/packagist/v/cxj/laravel-looking-glass-client.svg?style=flat-square)](https://packagist.org/packages/cxj/laravel-looking-glass-client)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/cxj/laravel-looking-glass-client/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/cxj/laravel-looking-glass-client/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/cxj/laravel-looking-glass-client/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/cxj/laravel-looking-glass-client/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![StyleCI](https://github.styleci.io/repos/609676447/shield?branch=main)](https://github.styleci.io/repos/609676447?branch=main)
[![Total Downloads](https://img.shields.io/packagist/dt/cxj/laravel-looking-glass-client.svg?style=flat-square)](https://packagist.org/packages/cxj/laravel-looking-glass-client)

This is an easy to use Laravel client for the Looking Glass application
status and health monitoring web application. This package makes it easy
for any Laravel application to report any status or health data to Looking
Glass.
This is an easy to use Laravel client for the [Looking Glass](https://github.com/cxj/looking-glass)
application status and health monitoring web application. This package makes it easy
for any Laravel application to report any status or health data to Looking Glass.

## Installation

@@ -18,13 +17,6 @@ You can install the package via composer:
composer require cxj/laravel-looking-glass-client
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="laravel-looking-glass-client-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
@@ -35,20 +27,18 @@ This is the contents of the published config file:

```php
return [
'url' => env('LOOKING_GLASS_URL', 'localhost:8000/api/webhook'),
'secret' => env('LOOKING_GLASS_SECRET', 'shared-secret'),
];
```

Optionally, you can publish the views using

```bash
php artisan vendor:publish --tag="laravel-looking-glass-client-views"
```

## Usage

```php
$laravelLookingGlassClient = new Cxj\LookingGlass();
echo $laravelLookingGlassClient->echoPhrase('Hello, Cxj!'); // Todo: TBD
$result = Cxj\Result::make('Test message from your application');

$glass = new Cxj\LookingGlass();
$glass->transmit('Name of Test or Status', $result);
```

## Testing
12 changes: 12 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Security Policy

## Supported Versions

| Version | Supported |
| ------- | ------------------ |
| 1.0.x | :white_check_mark: |
| < 0.0.2 | :x: |

## Reporting a Vulnerability

Please send email to the project owner to report security problems discovered.
4 changes: 1 addition & 3 deletions config/looking-glass.php
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@

// config for Cxj/LookingGlass
return [
'url' => env('LOOKING_GLASS_URL', 'localhost:8000/webhook'),
'name' => env('LOOKING_GLASS_NAME', 'Test App'),
'label' => env('LOOKING_GLASS_LABEL', 'Test Label'),
'url' => env('LOOKING_GLASS_URL', 'localhost:8000/api/webhook'),
'secret' => env('LOOKING_GLASS_SECRET', 'shared-secret'),
];
2 changes: 1 addition & 1 deletion src/Commands/LookingGlassCommand.php
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ public function handle(): int

// todo Until we can quiet PHPStan about Facade static call.
$glass = new LookingGlass();
$glass->transmit($result);
$glass->transmit('CLI Test', $result, null);

$this->comment('Message queued for webhook job');

3 changes: 2 additions & 1 deletion src/Facades/LookingGlass.php
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@

/**
* @see \Cxj\LookingGlass\LookingGlass
* @method static transmit(Result $result)
*
* @method static transmit(string $label, Result $result, string $appName))
*/
class LookingGlass extends Facade
{
35 changes: 12 additions & 23 deletions src/LookingGlass.php
Original file line number Diff line number Diff line change
@@ -17,32 +17,21 @@ public function getDispatch(): PendingDispatch
return $this->dispatch;
}

public function transmit(Result $result): self
{
public function transmit(
string $testName,
Result $result,
string $appName = null
): self {
$name = $appName ?? config('app.name');

// Send this status to Looking Glass.
$this->dispatch = WebhookCall
::create()
$this->dispatch = WebhookCall::create()
->throwExceptionOnFailure()
->url(config('looking-glass.url'))
->withHeaders(['App-Name' => $name])
->useSecret(config('looking-glass.secret'))
->payload(
[
'name' => config(
'looking-glass.name'
),
'result' => $result,
'label' => config(
'looking-glass.label'
),
]
)
->withHeaders(
[
'App-Name' => config(
'looking-glass.name'
)
]
)
->useSecret(
config('looking-glass.secret')
['name' => $name, 'result' => $result, 'label' => $testName]
)
->dispatch();

8 changes: 5 additions & 3 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@

namespace Cxj\LookingGlass;

use Cxj\LookingGlass\Commands\LookingGlassCommand;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Foundation\Console\AboutCommand;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Exceptions\InvalidPackage;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Cxj\LookingGlass\Commands\LookingGlassCommand;
use Spatie\WebhookServer\WebhookCall;
use Spatie\WebhookServer\WebhookServerServiceProvider;

@@ -44,13 +44,15 @@ public function register()
parent::register(); // 🙄
}


public function boot(): void
{
// Register commands.
AboutCommand::add(
'Looking Glass Client',
fn() => ['Version' => self::VERSION, 'foo' => 'bar']
fn () => [
'Version' => self::VERSION,
'Repo' => 'https://github.com/cxj/laravel-looking-glass-client',
]
);

// Make dependency package(s) available.
27 changes: 27 additions & 0 deletions tests/LookingGlassTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Cxj\LookingGlass\LookingGlass;
use Cxj\LookingGlass\Result;
use Illuminate\Support\Facades\Queue;

it('can be instantiated', function () {
// arrange
$glass = new LookingGlass();
// act
// nothing to do here.
// assert
$this->assertInstanceOf(LookingGlass::class, $glass);
});

it('sends a success message', function () {
// arrange
Queue::fake();
$result = Result::make('success message');
$glass = new LookingGlass();

// act
$glass->transmit('Pest test label', $result, 'Pest');

// assert
$this->assertInstanceOf(LookingGlass::class, $glass);
});
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@

namespace Cxj\LookingGlass\Tests;

use Cxj\LookingGlass\ServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Cxj\LookingGlass\ServiceProvider;

class TestCase extends Orchestra
{