diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 5c2e204a..99138151 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -66,3 +66,25 @@ jobs: - name: Validate CSV (junit) run: OUTPUT=junit make demo-github continue-on-error: true + + phar: + name: Phar + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + tools: composer + + - name: Build the project + run: make build --no-print-directory + + - name: Trying to use the phar file + run: ./build/csv-blueprint.phar validate:csv --csv=./tests/fixtures/demo.csv --schema=./tests/schemas/demo_invalid.yml + continue-on-error: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5cf213ea..bc869c47 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -138,3 +138,39 @@ jobs: with: name: Reports - ${{ matrix.php-version }} path: build/ + + phar: + name: Phar + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [ 8.1, 8.2, 8.3 ] + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: xdebug + tools: composer + extensions: ast + + - name: Build the project + run: make build --no-print-directory + + - name: Building Phar binary file + run: make build-phar --no-print-directory + + - name: Trying to use the phar file + run: ./build/csv-blueprint.phar + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + continue-on-error: true + with: + name: Reports - ${{ matrix.php-version }} + path: build/ diff --git a/Makefile b/Makefile index 6629f209..2f8cfa4d 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ # @see https://github.com/JBZoo/Csv-Blueprint # +.PHONY: build ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile)) include ./vendor/jbzoo/codestyle/src/init.Makefile @@ -17,10 +18,21 @@ endif OUTPUT ?= table -update: ##@Project Install/Update all 3rd party dependencies +build: ##@Project Install all 3rd party dependencies $(call title,"Install/Update all 3rd party dependencies") + @composer install + @make build-phar + @make create-symlink + + +update: ##@Project Install/Update all 3rd party dependencies @echo "Composer flags: $(JBZOO_COMPOSER_UPDATE_FLAGS)" @composer update $(JBZOO_COMPOSER_UPDATE_FLAGS) + @make build-phar + + +create-symlink: ##@Project Create Symlink (alias for testing) + @ln -sfv `pwd`/csv-blueprint `pwd`/vendor/bin/csv-blueprint test-all: ##@Project Run all project tests at once diff --git a/box.json.dist b/box.json.dist new file mode 100644 index 00000000..b7336f27 --- /dev/null +++ b/box.json.dist @@ -0,0 +1,22 @@ +{ + "banner" : [ + "JBZoo Toolbox - Csv-Blueprint", + "", + "This file is part of the JBZoo Toolbox project.", + "For the full copyright and license information, please view the LICENSE", + "file that was distributed with this source code.", + "", + "@package Csv-Blueprint", + "@license MIT", + "@copyright Copyright (C) JBZoo.com, All rights reserved.", + "@link https://github.com/JBZoo/Csv-Blueprint" + ], + + "output" : "build/csv-blueprint.phar", + + "directories" : ["src"], + "files" : ["csv-blueprint.php"], + "git-version" : "git-version", + + "finder" : [{"in" : "vendor"}] +} diff --git a/composer.json b/composer.json index ef26dcbe..f1085b3d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,8 @@ "jbzoo/utils" : "^7.1", "jbzoo/ci-report-converter" : "^7.2", "league/csv" : "^9.15", - "fakerphp/faker" : "^1.23" + "fakerphp/faker" : "^1.23", + "symfony/yaml" : "^6.4" }, "require-dev" : { @@ -42,6 +43,8 @@ "jbzoo/toolbox-dev" : "^7.1" }, + "bin" : ["csv-blueprint"], + "autoload" : { "psr-4" : {"JBZoo\\CsvBlueprint\\" : "src"} }, diff --git a/composer.lock b/composer.lock index b3c61e26..9ff9a5bd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aa2d64e2d78d191e4bc83a4ad90051b6", + "content-hash": "b20133b2673ce83b855f63c4993bcf8d", "packages": [ { "name": "bluepsyduck/symfony-process-manager", @@ -1665,6 +1665,78 @@ } ], "time": "2024-02-01T13:16:41+00:00" + }, + { + "name": "symfony/yaml", + "version": "v6.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d75715985f0f94f978e3a8fa42533e10db921b90", + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0|^7.0" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v6.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T14:51:35+00:00" } ], "packages-dev": [ @@ -7790,78 +7862,6 @@ ], "time": "2024-02-26T08:37:45+00:00" }, - { - "name": "symfony/yaml", - "version": "v6.4.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "d75715985f0f94f978e3a8fa42533e10db921b90" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/d75715985f0f94f978e3a8fa42533e10db921b90", - "reference": "d75715985f0f94f978e3a8fa42533e10db921b90", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "symfony/console": "<5.4" - }, - "require-dev": { - "symfony/console": "^5.4|^6.0|^7.0" - }, - "bin": [ - "Resources/bin/yaml-lint" - ], - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Loads and dumps YAML files", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v6.4.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-23T14:51:35+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.3", diff --git a/csv-blueprint b/csv-blueprint index c98a086a..30f40786 100644 --- a/csv-blueprint +++ b/csv-blueprint @@ -1,43 +1,18 @@ #!/usr/bin/env php registerCommandsByPath(PATH_ROOT . '/src/Commands', __NAMESPACE__) - ->setLogo( - <<<'EOF' - _____ ______ _ _ _ - / __ \ | ___ \ | (_) | | - | / \/_____ __ | |_/ / |_ _ ___ _ __ _ __ _ _ __ | |_ - | | / __\ \ / / | ___ \ | | | |/ _ \ '_ \| '__| | '_ \| __| - | \__/\__ \\ V / | |_/ / | |_| | __/ |_) | | | | | | | |_ - \____/___/ \_/ \____/|_|\__,_|\___| .__/|_| |_|_| |_|\__| - | | - |_| - EOF, - ) - ->run(); +require_once __DIR__ . '/csv-blueprint.php'; diff --git a/csv-blueprint.php b/csv-blueprint.php new file mode 100644 index 00000000..330bce06 --- /dev/null +++ b/csv-blueprint.php @@ -0,0 +1,54 @@ +registerCommandsByPath(PATH_ROOT . '/src/Commands', __NAMESPACE__) + ->setLogo( + <<<'EOF' + _____ ______ _ _ _ + / __ \ | ___ \ | (_) | | + | / \/_____ __ | |_/ / |_ _ ___ _ __ _ __ _ _ __ | |_ + | | / __\ \ / / | ___ \ | | | |/ _ \ '_ \| '__| | '_ \| __| + | \__/\__ \\ V / | |_/ / | |_| | __/ |_) | | | | | | | |_ + \____/___/ \_/ \____/|_|\__,_|\___| .__/|_| |_|_| |_|\__| + | | + |_| + EOF, + ) + ->run();