Skip to content

Commit

Permalink
do not repeat --resource values on pipeline stub and configure stages…
Browse files Browse the repository at this point in the history
… (use meta-data file contents instead)
  • Loading branch information
llaville committed Aug 27, 2024
1 parent 988f46c commit c22e99d
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
name: Build Release Artifact
run: |
bin/box-manifest make -r console-table.txt -r plain.txt -r sbom.json build
bin/box-manifest make -r console-table.txt -r plain.txt -r sbom.json --output-stub stub.php stub
bin/box-manifest make --output-stub stub.php stub
bin/box-manifest make compile -c box.json.dist -vvv --ansi
- # https://github.com/softprops/action-gh-release
Expand Down
17 changes: 11 additions & 6 deletions docs/Tutorial/generate-box-json-dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ you need to have a BOX configuration file that :
>
> Don't forget to specify option `--config /path/to/any-box.json` on following command invocations.
## :material-numeric-1-box: Identify all manifest files

To do so, you have to specify `--resource` (`-r` shortcut) option with filename that should be previously built (or not).
## :material-numeric-1-box: Store manifests in default directory

=== "Command"

```shell
box-manifest make -r console-table.txt -r manifest.txt configure
box-manifest make configure
```

=== "Output"

Here, we supposed to have previously generated `console-table.txt` and `manifest.txt` resources.

```json
{
"files-bin": [
Expand All @@ -49,11 +49,13 @@ To do so, you have to specify `--resource` (`-r` shortcut) option with filename
=== "Command"

```shell
box-manifest make -r console-table.txt -r manifest.txt --resource-dir '.my_manifests/' configure
box-manifest make --resource-dir '.my_manifests/' configure
```

=== "Output"

Here, we supposed to have previously generated `console-table.txt` and `manifest.txt` resources.

```json
{
"files-bin": [
Expand Down Expand Up @@ -84,16 +86,19 @@ To do so, you have to specify `--output-stub` option with filename that should b
=== "Command"

```shell
box-manifest make -r console-table.txt -r manifest.txt --resource-dir '.my_manifests/' --output-stub app-fixtures-stub.php configure
box-manifest make --resource-dir '.my_manifests/' --output-stub app-fixtures-stub.php configure
```

=== "Output"

Here, we supposed to have previously generated `console-table.txt` and `manifest.txt` resources.

```json
{
"files-bin": [
"console-table.txt",
"manifest.txt",
".box.manifests.bin",
],
"map": [
{
Expand Down
6 changes: 4 additions & 2 deletions docs/Tutorial/generate-custom-stub.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ Make for example this stub (see **Output** tab), either manually or with the fol
=== "Command"

```shell
box-manifest make -r console-table.txt -r manifest.txt stub
box-manifest make stub
```

=== "Output"

Here, we supposed to have previously generated `console-table.txt` and `manifest.txt` resources.

```php
<?php

Expand Down Expand Up @@ -71,7 +73,7 @@ Make for example this stub (see **Output** tab), either manually or with the fol
> === "Command"
>
> ```shell
> box-manifest make -r console-table.txt -r manifest.txt --template resources/empty_stub.template --output-stub my-stub.php stub
> box-manifest make --template resources/empty_stub.template --output-stub my-stub.php stub
> ```
>
> === "Output"
Expand Down
2 changes: 1 addition & 1 deletion docs/UseCases/ConsoleTextFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

![console format](../assets/images/app-fixtures-console.png)

## :material-numeric-2-box: With new pipeline command
## :material-numeric-2-box: With pipeline command

=== "Command"

Expand Down
2 changes: 1 addition & 1 deletion docs/UseCases/CustomFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ either by your autoloader or with bootstrap helper feature (see `--bootstrap|-b`
)
```

## :material-numeric-2-box: With new pipeline command
## :material-numeric-2-box: With pipeline command

=== "Command"

Expand Down
2 changes: 1 addition & 1 deletion docs/UseCases/DecoratedTextFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

![ansi format](../assets/images/app-fixtures-ansi.png)

## :material-numeric-2-box: With new pipeline command
## :material-numeric-2-box: With pipeline command

=== "Command"

Expand Down
2 changes: 1 addition & 1 deletion docs/UseCases/PlainTextFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
psr/log: 3.0.0
```

## :material-numeric-2-box: With new pipeline command
## :material-numeric-2-box: With pipeline command

=== "Command"

Expand Down
2 changes: 1 addition & 1 deletion docs/UseCases/SBomJsonFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}
```

## :material-numeric-2-box: With new pipeline command
## :material-numeric-2-box: With pipeline command

=== "Command"

Expand Down
2 changes: 1 addition & 1 deletion docs/UseCases/SBomXmlFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</bom>
```

## :material-numeric-2-box: With new pipeline command
## :material-numeric-2-box: With pipeline command

=== "Command"

Expand Down
13 changes: 12 additions & 1 deletion docs/build-your-stub.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
=== "Pipeline Command"

```shell
box-manifest make -r console-table.txt -r manifest.txt -r sbom.json --output-stub stub.php stub
box-manifest make --output-stub stub.php stub
```

> [!CAUTION]
>
> When none resources are provided (`--resource|-r`) recommended way,
> we used list defined into `.box.manifests.bin` meta-data file.
>
> === "Meta-data file"
>
> ```
> a:3:{s:17:"console-table.txt";s:24:"application/octet-stream";s:12:"manifest.txt";s:10:"text/plain";s:9:"sbom.json";s:38:"application/vnd.sbom+json; version=1.6";}
> ```

=== "Legacy Command"

```shell
Expand Down
10 changes: 6 additions & 4 deletions src/Pipeline/ConfigureStage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Bartlett\BoxManifest\Pipeline;

use Throwable;
use function array_keys;
use function array_push;
use function file_exists;
use function file_get_contents;
Expand Down Expand Up @@ -44,12 +45,13 @@ public function __invoke(array $payload): array
$configs['files-bin'] = [];
}

array_push($configs['files-bin'], ...$payload['resources']);
$configs['files-bin'][] = '.box.manifests.bin';
$resources = empty($payload['resources']) ? array_keys($this->getMetaData()) : $payload['resources'];
$resourceDir = $payload['resourceDir'];

$mapFiles = $payload['map'];
array_push($configs['files-bin'], ...$resources);
$configs['files-bin'][] = $resourceDir;

$resourceDir = $payload['resourceDir'];
$mapFiles = $payload['map'];

if (!empty($resourceDir) && '/' !== $resourceDir) {
foreach ($payload['resources'] as $resource) {
Expand Down

0 comments on commit c22e99d

Please sign in to comment.