Skip to content
Merged
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
43 changes: 4 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: CI

on: [push]
on: [push, pull_request]

jobs:
phpunit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2', '8.3']
php-version: ['8.4', '8.5']
dependencies: ['lowest', 'highest']
name: 'PHPUnit'
steps:
Expand All @@ -31,41 +31,6 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Psalm'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Composer
uses: "ramsey/composer-install@v3"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: Psalm
run: vendor/bin/psalm --shepherd
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']
name: 'CS'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Composer
uses: "ramsey/composer-install@v3"
- name: CS
run: vendor/bin/php-cs-fixer fix --diff --dry-run
uses: innmind/github-workflows/.github/workflows/cs.yml@main
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [Unreleased]

### Changed

- Requires PHP `8.4`
- Requires `innmind/foundation:~2.1`
- Requires `innmind/framework:~4.0`

## 3.8.0 - 2024-11-11

### Changed
Expand Down
18 changes: 7 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
"issues": "http://github.com/Innmind/DependencyGraph/issues"
},
"require": {
"php": "~8.2",
"innmind/immutable": "~5.10",
"innmind/url": "~4.1",
"innmind/operating-system": "~4.1|~5.0",
"innmind/json": "^1.1",
"innmind/graphviz": "~3.1",
"php": "~8.4",
"innmind/foundation": "~2.1",
"innmind/graphviz": "~5.0",
"composer/semver": "^3.4.4",
"innmind/framework": "~2.0",
"innmind/validation": "~1.7"
"innmind/framework": "~4.0"
},
"autoload": {
"psr-4": {
Expand All @@ -36,9 +32,9 @@
}
},
"require-dev": {
"phpunit/phpunit": "~10.2",
"vimeo/psalm": "~5.15",
"innmind/black-box": "~5.5",
"phpunit/phpunit": "~12.0",
"innmind/static-analysis": "~1.3",
"innmind/black-box": "~6.5",
"innmind/coding-standard": "~2.0"
},
"bin": ["dependency-graph"]
Expand Down
22 changes: 16 additions & 6 deletions src/Command/CheckDotInstalled.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
use Innmind\CLI\{
Console,
Command,
Command\Usage,
};
use Innmind\Server\Control\Server\{
Processes,
Command as Process
};
use Innmind\Immutable\Str;
use Innmind\Immutable\{
Str,
Attempt,
};

final class CheckDotInstalled implements Command
{
Expand All @@ -24,7 +28,8 @@ public function __construct(Command $command, Processes $processes)
$this->processes = $processes;
}

public function __invoke(Console $console): Console
#[\Override]
public function __invoke(Console $console): Attempt
{
/** @psalm-suppress ArgumentTypeCoercion Due to the environment variables */
return $this
Expand All @@ -36,19 +41,24 @@ public function __invoke(Console $console): Console
static fn($name) => $name === 'PATH',
)),
)
->wait()
->flatMap(
static fn($process) => $process
->wait()
->attempt(static fn() => new \Exception),
)
->match(
fn() => ($this->command)($console),
static fn() => $console
->output(Str::of("Graphviz needs to be installed first\n"))
->exit(1),
->exit(1)
->output(Str::of("Graphviz needs to be installed first\n")),
);
}

/**
* @psalm-mutation-free
*/
public function usage(): string
#[\Override]
public function usage(): Usage
{
return $this->command->usage();
}
Expand Down
28 changes: 17 additions & 11 deletions src/Command/DependsOn.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
};
use Innmind\CLI\{
Command,
Command\Usage,
Console,
};
use Innmind\Immutable\{
Set,
Str,
Attempt,
};

final class DependsOn implements Command
Expand All @@ -32,7 +34,8 @@ public function __construct(Dependents $load, Save $save, Display $display)
$this->display = $display;
}

public function __invoke(Console $console): Console
#[\Override]
public function __invoke(Console $console): Attempt
{
/** @psalm-suppress MixedArgumentTypeCoercion Due to the reduce */
$vendors = $console
Expand Down Expand Up @@ -63,28 +66,31 @@ public function __invoke(Console $console): Console
$fileName = $fileName->prepend('direct_');
}

return $console
->options()
->maybe('output')
->match(
fn() => ($this->display)($console, $packages),
fn() => ($this->save)($console, $fileName, $packages),
);
return Attempt::result(
$console
->options()
->maybe('output')
->match(
fn() => ($this->display)($console, $packages),
fn() => ($this->save)($console, $fileName, $packages),
),
);
}

/**
* @psalm-pure
*/
public function usage(): string
#[\Override]
public function usage(): Usage
{
return <<<USAGE
return Usage::parse(<<<USAGE
depends-on package vendor ...vendors --direct --output

Generate a graph of all packages depending on a given package

The packages are searched in a given set of vendors. This restriction
is due to the fact that packagist.org doesn't expose via an api the
packages that depends on an other.
USAGE;
USAGE);
}
}
36 changes: 22 additions & 14 deletions src/Command/FromLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
};
use Innmind\CLI\{
Command,
Command\Usage,
Console,
};
use Innmind\Immutable\Str;
use Innmind\Immutable\{
Str,
Attempt,
};

final class FromLock implements Command
{
Expand All @@ -27,38 +31,42 @@ public function __construct(ComposerLock $load, Save $save, Display $display)
$this->display = $display;
}

public function __invoke(Console $console): Console
#[\Override]
public function __invoke(Console $console): Attempt
{
$packages = ($this->load)($console->workingDirectory());

if ($packages->empty()) {
return $console
->error(Str::of("No packages found\n"))
->exit(1);
->exit(1)
->error(Str::of("No packages found\n"));
}

$fileName = Str::of('dependencies.svg');

return $console
->options()
->maybe('output')
->match(
fn() => ($this->display)($console, $packages),
fn() => ($this->save)($console, $fileName, $packages),
);
return Attempt::result(
$console
->options()
->maybe('output')
->match(
fn() => ($this->display)($console, $packages),
fn() => ($this->save)($console, $fileName, $packages),
),
);
}

/**
* @psalm-pure
*/
public function usage(): string
#[\Override]
public function usage(): Usage
{
return <<<USAGE
return Usage::parse(<<<USAGE
from-lock --output

Generate the dependency graph out of a composer.lock

It will look for a composer.lock in the working directory
USAGE;
USAGE);
}
}
32 changes: 20 additions & 12 deletions src/Command/Of.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
};
use Innmind\CLI\{
Command,
Command\Usage,
Console,
};
use Innmind\Immutable\Str;
use Innmind\Immutable\{
Str,
Attempt,
};

final class Of implements Command
{
Expand All @@ -28,31 +32,35 @@ public function __construct(Dependencies $load, Save $save, Display $display)
$this->display = $display;
}

public function __invoke(Console $console): Console
#[\Override]
public function __invoke(Console $console): Attempt
{
$packages = ($this->load)(Name::of($console->arguments()->get('package')));
$fileName = Str::of($console->arguments()->get('package'))
->replace('/', '_')
->append('_dependencies.svg');

return $console
->options()
->maybe('output')
->match(
fn() => ($this->display)($console, $packages),
fn() => ($this->save)($console, $fileName, $packages),
);
return Attempt::result(
$console
->options()
->maybe('output')
->match(
fn() => ($this->display)($console, $packages),
fn() => ($this->save)($console, $fileName, $packages),
),
);
}

/**
* @psalm-pure
*/
public function usage(): string
#[\Override]
public function usage(): Usage
{
return <<<USAGE
return Usage::parse(<<<USAGE
of package --output

Generate the dependency graph of the given package
USAGE;
USAGE);
}
}
Loading
Loading