2017 © Pedro Pelรกez
 

library lean-package-validator

Library and CLI for validating if a project or package has and will have lean releases.

image

stolt/lean-package-validator

Library and CLI for validating if a project or package has and will have lean releases.

  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 4 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

Lean package validator

Test Status Version PHP Version composer.lock available PDS Skeleton, (*1)

Lean package validator logo , (*2)

The lean package validator or its abbreviation lpv is a utility tool that validates a project/micro-package for its leanness. A project/micro-package is considered lean when its common repository artifacts won't be included in release assets., (*3)

Installation

The lean package validator CLI can be installed globally through Composer., (*4)

``` bash composer global require stolt/lean-package-validator, (*5)


Make sure that the path to your global vendor binaries directory is in your `$PATH`. You can determine the location of your global vendor binaries directory via `composer global config bin-dir --absolute`. This way the `lean-package-validator` executable can be located. Since the default name of the CLI is quite a mouthful, an alias which can be placed in `~/.aliases`, `~/.zshrc` or the like might come in handy. The alias shown next assumes that `$COMPOSER_HOME` is `~/.config/composer` and not `~/.composer`. ``` bash alias lpv='~/.config/composer/vendor/bin/lean-package-validator $@'

The lean package validator also can be installed locally to a project which allows further utilisation via Composer scripts., (*6)

``` bash composer require --dev stolt/lean-package-validator, (*7)


> [!TIP] > As of release `v1.9.0` it's also possible to install and use the lean package validator > via a PHAR [file](https://github.com/raphaelstolt/lean-package-validator/releases/tag/v1.9.0). Therefor download a released version e.g. v3.3.1 and move it to `/usr/local/bin` as shown next. ``` bash wget --quiet https://github.com/raphaelstolt/lean-package-validator/releases/download/v3.3.1/lean-package-validator.phar mv lean-package-validator.phar /usr/local/bin/lean-package-validator

Usage

Run the lean package validator CLI within or against a project/micro-package directory, and it will validate the export-ignore entries present in a .gitattributes file against a set of common repository artifacts. If no .gitattributes file is present it will suggest to create one., (*8)

``` bash lean-package-validator validate [], (*9)


### Available options The `--enforce-strict-order` option will enforce a strict order comparison of export-ignores in the `.gitattributes` file and fail validation if the order differs. Per __default__ the order comparison is done in a non-strict fashion. ``` bash lean-package-validator validate --enforce-strict-order [<directory>]

The --create|-c option creates an .gitattributes file if nonexistent., (*10)

``` bash lean-package-validator validate --create [], (*11)


The `--overwrite|-o` option overwrites an existing `.gitattributes` file when there are any `export-ignore` entries missing. Using this option on a directory with a nonexistent `.gitattributes` file implicates the `--create` option. ``` bash lean-package-validator validate --overwrite [<directory>]

The --glob-pattern option allows you to overwrite the default pattern used to match common repository artifacts. The amount of pattern in the grouping braces is expected to be >1. As shown next this utility could thereby also be used for projects (i.e. Python) outside the PHP ecosystem., (*12)

``` bash lean-package-validator validate --glob-pattern '{.,.rst,*.py[cod],dist/}' [], (*13)


The default pattern is defined in the PHP preset [file](./src/Presets/PhpPreset.php). The `--glob-pattern-file` option allows you to load patterns, which should be used to match the common repository artifacts, from a given file. You can put a `.lpv` file in the repository which will be used per default and overwrite the default pattern. The structure of such a glob pattern file can be taken from the [example](example/.lpv) directory or be created via `lean-package-validator init`. ``` bash lean-package-validator validate --glob-pattern-file /path/to/glob-pattern-file [<directory>]

The --keep-license option will allow a license file in the release/dist archive file which is per default ommitted., (*14)

``` bash lean-package-validator validate --keep-license [], (*15)


The `--keep-readme` option will allow a README file in the release/dist archive file which is per default ommitted. ``` bash lean-package-validator validate --keep-readme [<directory>]

The --keep-glob-pattern option allows to keep matching files in the release/dist archive file which are per default ommitted., (*16)

``` bash lean-package-validator validate --keep-glob-pattern '{LICENSE.,README.,docs*}' [], (*17)


The `--align-export-ignores|-a` option will align the created or overwritten export-ignores for a better readability. ``` bash lean-package-validator validate --align-export-ignores --create [<directory>]

The --sort-from-directories-to-files|-s option will order the export-ignores from directories to files for a better readability., (*18)

``` bash lean-package-validator validate --sort-from-directories-to-files --create [], (*19)


The `--enforce-alignment` option will enforce a strict alignment of export-ignores in the `.gitattributes` file and fail validation if they aren't aligned. Per __default__ no alignment is enforced. The `--validate-git-archive` option will validate that no common repository artifacts slip into the release/dist archive file. It will do so by creating a `temporary archive` from the current Git `HEAD` and inspecting its content. With a set `--keep-license` option a license file becomes mandatory and will fail the archive validation if not present. ``` bash lean-package-validator validate --validate-git-archive [<directory>]

The --diff option will show a visual diff between the actual and expected .gitattributes content., (*20)

``` bash lean-package-validator validate --diff [], (*21)

The present .gitattributes file is considered invalid., (*22)

Would expect the following .gitattributes file content: --- Original +++ Expected @@ -7,9 +7,8 @@ .github/ export-ignore .gitignore export-ignore .gitmessage export-ignore .php-cs-fixer.php export-ignore -.phpunit.result.cache export-ignore +.idea/ export-ignore bin/application-version export-ignore bin/lean-package-validator.phar export-ignore bin/release-version export-ignore, (*23)


The `--report-stale-export-ignores` option extends the validation to look for export-ignore statements referencing non-existent repository artifacts. In combination with the `--diff` option these will be shown in the output. The `--stdin-input` option allows the validate command to read from `STDIN`, so that the following piped output can be used for validation. It currently only does a strict comparison. ```bash cat .gitattributes | lean-package-validator validate --stdin-input

Additional commands

Init command

The init command will create an initial .lpv file with the default patterns used to match common repository artifacts., (*24)

``` bash lean-package-validator init [], (*25)


The `--overwrite|-o` option overwrites an existing `.lpv` file. The `--preset` option allows to choose from a predefined set of glob pattern. Available presets are `PHP`, `Python`, and `Go`. With `PHP` being the default. #### Tree command The `tree` command of the lean package validator allows you to inspect the __flat__ `source` and `dist package` structure of the given project/micro-package. It is __not__ intended for validation use. ``` bash lean-package-validator tree --src [<directory>] Package: stolt/lean-package-validator . โ”œโ”€โ”€ bin โ”œโ”€โ”€ example โ”œโ”€โ”€ .github โ”œโ”€โ”€ src โ”œโ”€โ”€ tests โ”œโ”€โ”€ box.json.dist โ”œโ”€โ”€ CHANGELOG.md โ”œโ”€โ”€ composer.json โ”œโ”€โ”€ composer.lock โ”œโ”€โ”€ .editorconfig โ”œโ”€โ”€ .gitattributes โ”œโ”€โ”€ .gitignore โ”œโ”€โ”€ .gitmessage โ”œโ”€โ”€ LICENSE.md โ”œโ”€โ”€ lpv-logo.png โ”œโ”€โ”€ peck.json โ”œโ”€โ”€ .php-cs-fixer.php โ”œโ”€โ”€ phpstan.neon.dist โ”œโ”€โ”€ phpunit.xml.dist โ””โ”€โ”€ README.md 5 directories, 15 files

``` bash lean-package-validator tree --dist-package [], (*26)

Package: stolt/lean-package-validator . โ”œโ”€โ”€ bin โ”œโ”€โ”€ composer.json โ””โ”€โ”€ src, (*27)

2 directories, 1 file, (*28)


## Utilisation via Composer scripts, cpx, or it's dedicated GitHub Action To avoid that changes coming from contributions or own modifications slip into release/dist archives it might be helpful to use a guarding [Composer script](https://getcomposer.org/doc/articles/scripts.md), which will be available at everyone's fingertips. By adding the following to the project/micro-package its `composer.json` the `.gitattributes` file can now be easily validated via `composer validate-gitattributes`. ``` json { "scripts": { "validate-gitattributes": "lean-package-validator validate" }, }

Another option to utilise the lean package validator is via cpx., (*29)

``` bash cpx stolt/lean-package-validator validate, (*30)


For utilising a dedicated GitHub Action have a look at the documentation over [here](https://github.com/raphaelstolt/lean-package-validator-action). ### Running tests ``` bash composer lpv:test

License

This library and its CLI are licensed under the MIT license. Please see LICENSE.md for more details., (*31)

Changelog

Please see CHANGELOG.md for more details., (*32)

Contributing

Please see CONTRIBUTING.md for more details., (*33)

The Versions

15/06 2018

dev-master

9999999-dev

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

18/10 2017

v1.8.1

1.8.1.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

13/10 2017

v1.8.0

1.8.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

02/10 2017

v1.7.3

1.7.3.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

08/05 2017

v1.7.2

1.7.2.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

06/05 2017

v1.7.1

1.7.1.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

31/03 2017

v1.7.0

1.7.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

08/10 2016

v1.6.0

1.6.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

08/10 2016

v1.5.2

1.5.2.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

05/10 2016

v1.5.1

1.5.1.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

05/10 2016

v1.5.0

1.5.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

04/10 2016

v1.4.0

1.4.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

04/10 2016

v1.3.1

1.3.1.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

30/09 2016

v1.3.0

1.3.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

22/09 2016

v1.2.0

1.2.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

18/09 2016

v1.1.0

1.1.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

11/09 2016

v1.0.6

1.0.6.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

09/09 2016

v1.0.5

1.0.5.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

09/09 2016

v1.0.4

1.0.4.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

05/09 2016

v1.0.3

1.0.3.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

05/09 2016

v1.0.2

1.0.2.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

04/09 2016

v1.0.1

1.0.1.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes

04/09 2016

v1.0.0

1.0.0.0

Library and CLI for validating if a project or package has and will have lean releases.

  Sources   Download

MIT

The Requires

 

The Development Requires

validation cli package project release lean dist gitattributes