Skip to content

Commit

Permalink
Merge branch 'release/v0.1.5' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Sep 26, 2023
2 parents cdac2f1 + ce6e0fb commit 2c0aef7
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.1.5 (2023-09-26)
* Converted phpstan doc comments to generic

## v0.1.4 (2022-11-30)
* Switched to Systemic v0.11

Expand Down
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/integra?style=flat)](https://packagist.org/packages/decodelabs/integra)
[![Latest Version](https://img.shields.io/packagist/v/decodelabs/integra.svg?style=flat)](https://packagist.org/packages/decodelabs/integra)
[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/integra.svg?style=flat)](https://packagist.org/packages/decodelabs/integra)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/decodelabs/integra/Integrate)](https://github.com/string|int|floatdecodelabs/integra/actions/workflows/integrate.yml)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/integra/integrate.yml?branch=develop)](https://github.com/string|int|floatdecodelabs/integra/actions/workflows/integrate.yml)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat)](https://github.com/phpstan/phpstan)
[![License](https://img.shields.io/packagist/l/decodelabs/integra?style=flat)](https://packagist.org/packages/decodelabs/integra)

Expand All @@ -25,7 +25,53 @@ composer require decodelabs/integra

## Usage

Coming soon...
Load a context to work from:

```php
use DecodeLabs\Integra\Context;

$context = new Context('path/to/project/');
```

Or use the `Integra` Veneer frontage to work from `cwd()`.
Integra will search back up the file tree for the nearest composer.json.


```php
echo Integra::$runDir; // Working directory
echo Integra::$rootDir; // Parent or current dir containing composer.json
echo Integra::$binDir; // Bin dir relative to composer
echo Integra::$composerFile; // Location of composer.json

Integra::run('update'); // composer update
Integra::runGlobal('update'); // composer global update
Integra::runScript('my-script'); // composer run-script my-script
Integra::runBin('phpstan', '--debug'); // composer exec phpstan -- --debug
Integra::runGlobalBin('phpstan', '--debug'); // composer global exec phpstan -- --debug

if(!Integra::hasPackage('package1')) {
Integra::install('package1', 'package2'); // composer require package1 package2
}

Integra::installDev('package1', 'package2'); // composer require package1 package2 --dev
Integra::installGlobal('package1', 'package2'); // composer global require package1 package2
Integra::installDevGlobal('package1', 'package2'); // composer global require package1 package2 --dev
```

### Manifest

Access the composer.json manifest:

```php
$manifest = Integra::getLocalManifest();
echo $manifest->getDescription();

foreach($manifest->getRequiredPackages() as $package) {
echo $package->name;
}
```

See the Manifest.php class for full data access interface - it maps to the majority of the documented composer config options.

## Licensing

Expand Down
2 changes: 1 addition & 1 deletion src/Integra/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public function hasPackage(string $package): bool
/**
* Get extra config
*
* @phpstan-return Tree<string|int|float|null>
* @return Tree<string|int|float|null>
*/
public function getExtra(): Tree
{
Expand Down
19 changes: 8 additions & 11 deletions src/Integra/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@
use DecodeLabs\Integra\Structure\Funding;
use DecodeLabs\Integra\Structure\Package;

/**
* @phpstan-type TTree Tree<string|int|float|null>
*/
class Manifest
{
protected File $file;

/**
* @phpstan-var TTree
* @var Tree<string|int|float|null>
*/
protected Tree $data;

Expand All @@ -51,7 +48,7 @@ public function reload(): void

/** @var array<string, mixed> */
$json = json_decode($this->file->getContents(), true);
/** @phpstan-var TTree $tree */
/** @var Tree<string|int|float|null> $tree */
$tree = new NativeTree($json);
$this->data = $tree;
}
Expand All @@ -60,7 +57,7 @@ public function reload(): void
/**
* Get node from tree
*
* @phpstan-return TTree
* @return Tree<string|int|float|null>
*/
public function __get(string $name): Tree
{
Expand Down Expand Up @@ -339,7 +336,7 @@ public function getSuggestedPackages(): array
/**
* Get autoload config
*
* @phpstan-return TTree
* @return Tree<string|int|float|null>
*/
public function getAutoloadConfig(): Tree
{
Expand Down Expand Up @@ -370,7 +367,7 @@ public function shouldPreferStable(): bool
/**
* Get repository config
*
* @phpstan-return TTree
* @return Tree<string|int|float|null>
*/
public function getRepositoryConfig(): Tree
{
Expand All @@ -380,7 +377,7 @@ public function getRepositoryConfig(): Tree
/**
* Get config
*
* @phpstan-return TTree
* @return Tree<string|int|float|null>
*/
public function getConfig(): Tree
{
Expand All @@ -390,7 +387,7 @@ public function getConfig(): Tree
/**
* Get extra
*
* @phpstan-return TTree
* @return Tree<string|int|float|null>
*/
public function getExtra(): Tree
{
Expand Down Expand Up @@ -435,7 +432,7 @@ public function hasScript(string $name): bool
/**
* Get archive config
*
* @phpstan-return TTree
* @return Tree<string|int|float|null>
*/
public function getArchiveConfig(): Tree
{
Expand Down
2 changes: 1 addition & 1 deletion stubs/DecodeLabs/Integra.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Integra implements Proxy
{
use ProxyTrait;

const VENEER = 'DecodeLabs\Integra';
const VENEER = 'DecodeLabs\\Integra';
const VENEER_TARGET = Inst::class;

public static Inst $instance;
Expand Down

0 comments on commit 2c0aef7

Please sign in to comment.