New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for `scripts-descriptions` #88

Closed
aeimer opened this Issue Oct 10, 2018 · 5 comments

Comments

2 participants
@aeimer
Copy link

aeimer commented Oct 10, 2018

Steps required to reproduce the problem

  1. If you have a package.json with the scripts-descriptions object, the values in there are not getting sorted

Expected Result

"scripts": {
        "post-install-cmd": [
            "@auto-scripts",
            "@composer normalize"
        ],
        "post-update-cmd": [
            "@auto-scripts",
            "@composer normalize"
        ],
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "check-code-quality": "@phpqa",
        "php-cs-fixer": "vendor/bin/php-cs-fixer fix src --format txt --config .php_cs.dist",
        "phpcbf": "vendor/bin/phpcbf  --ignore=*/Migrations/* --extensions=php --standard=psr2 src tests",
        "phpdoc": "bash ./bin/phpdoc.sh run -p -d src/ -t docu/ --ignore \"src/Migrations/*,src/Kernel.php\" --encoding \"utf-8\" --cache-folder \"var/cache/dev/phpdoc\" --sourcecode",
        "phpqa": "ant -Dframework.php-qa-mode=cli package.check-code-quality"
    },
    "scripts-descriptions": {
        "check-code-quality": "Alias for phpqa",
        "php-cs-fixer": "Run PHP-CS-FIXER to actually fix",
        "phpcbf": "Run PHP-CBF",
        "phpdoc": "Generates the PHP-Docs",
        "phpqa": "Run all PHP QA stuff"
    }

Actual Result

"scripts": {
        "post-install-cmd": [
            "@auto-scripts",
            "@composer normalize"
        ],
        "post-update-cmd": [
            "@auto-scripts",
            "@composer normalize"
        ],
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "check-code-quality": "@phpqa",
        "php-cs-fixer": "vendor/bin/php-cs-fixer fix src --format txt --config .php_cs.dist",
        "phpcbf": "vendor/bin/phpcbf  --ignore=*/Migrations/* --extensions=php --standard=psr2 src tests",
        "phpdoc": "bash ./bin/phpdoc.sh run -p -d src/ -t docu/ --ignore \"src/Migrations/*,src/Kernel.php\" --encoding \"utf-8\" --cache-folder \"var/cache/dev/phpdoc\" --sourcecode",
        "phpqa": "ant -Dframework.php-qa-mode=cli package.check-code-quality"
    },
    "scripts-descriptions": {
        "phpqa": "Run all PHP QA stuff",
        "check-code-quality": "Alias for phpqa",
        "phpcbf": "Run PHP-CBF",
        "phpdoc": "Generates the PHP-Docs",
        "php-cs-fixer": "Run PHP-CS-FIXER to actually fix"
    }

@localheinz localheinz self-assigned this Oct 10, 2018

@localheinz localheinz referenced this issue Oct 10, 2018

Merged

Enhancement: Sort scripts-descriptions #89

1 of 1 task complete
@localheinz

This comment has been minimized.

Copy link
Owner

localheinz commented Oct 10, 2018

Thank you for your report, @aeimer!

Do you want to take a look at #89?

@localheinz

This comment has been minimized.

Copy link
Owner

localheinz commented Oct 10, 2018

@aeimer

Tagged a new release, hope you like it!

See 0.8.0...0.9.0.

@aeimer

This comment has been minimized.

Copy link

aeimer commented Oct 10, 2018

Yes it's great. But have i seen in right that you don't sort the scripts section?

Thanks for the super fast reply ;)

@localheinz

This comment has been minimized.

Copy link
Owner

localheinz commented Oct 10, 2018

@aeimer

The scripts section is sorted by Localheinz\Json\Normalizer\SchemaNormalizer::normalize(), see https://github.com/localheinz/json-normalizer/blob/0.9.0/src/SchemaNormalizer.php#L205-L211.

In a nutshell, what happens there is the following:

  • pick all properties from the underlying schema in the order in which they are present in the schema, in this case, properties defined in the scripts section (see https://getcomposer.org/schema.json)
  • sort all remaining properties by key

Glad you like it!

I'm aware this tool doesn't save the world, but I'm happy to have contributed something that makes at least a small part of the work of a developer a bit easier.

@aeimer

This comment has been minimized.

Copy link

aeimer commented Oct 10, 2018

Ah alright 👍

BTW, you could mention in the README that running this after install/update makes a lot of sense ;)

This is from a symfony 4 project:

"scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts",
            "@composer normalize"
        ],
        "post-update-cmd": [
            "@auto-scripts",
            "@composer normalize"
        ]
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment