Skip to content

satis.json schema #271

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

Merged
merged 8 commits into from
Dec 15, 2015
Merged

satis.json schema #271

merged 8 commits into from
Dec 15, 2015

Conversation

JamesRezo
Copy link
Contributor

This is a proposal for a satis file validation schema.
It can be tested with https://github.com/justinrainbow/json-schema :

validate-json /path/to/satis.json res/satis-schema.json

"minimum-stability": {
"type": ["string"],
"description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
"pattern": "^dev|alpha|beta|rc|RC|stable$"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using enum would be simpler

@alcohol
Copy link
Member

alcohol commented Nov 25, 2015

It would probably be a good idea to validate the schema on every run. Not necessarily fail the run, but at least print out errors/warnings to notify the user.

"require": {
"type": "object",
"description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
"additionalProperties": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than true, this should use a schema object here, to force all additional properties to contain strings

@stof
Copy link
Contributor

stof commented Nov 25, 2015

You are missing the config property (which is the same than the property of the composer package schema)

@JamesRezo
Copy link
Contributor Author

@stof, i completely agree about require, that could be the same for repositories. But it's to Composer to support sub-schema I guess. Is it possible to have more than one validation file in Composer ?
I can of course add a config property and maybe something about authentication... but again, it's about to Composer to support such sub-schemas.
Also, minimum-stability is a copy of the Composer property.

What I mean is that it would be preferable Composer manages its definitions and then Satis could use it. How do you feel about this ?

I have no idea how to set abandoned specification here. It has to match

"abandoned" : {
    "vendor/name": true,
    "vendor/othername": "othervendor/othername",
   ...
}

It's clearly an object, but how to specify its properties ?

@alcohol. Yep, it's the idea I have in mind. But for now, il would be a lot a duplicate code between Composer and Satis.

@stof
Copy link
Contributor

stof commented Nov 25, 2015

@JamesRezo require values are just strings, same for abandonned (well, string or boolean in this case).

@stof
Copy link
Contributor

stof commented Nov 25, 2015

I can of course add a config property

if you don't add it at all, you forbid defining it in the satis config, which is wrong.

@JamesRezo
Copy link
Contributor Author

Sorry for the name mismatch :-)

}
}
},
"extra": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra does not make sense in the Satis config

@alcohol
Copy link
Member

alcohol commented Nov 27, 2015

/cc @Seldaek got any feedback regarding this schema?

if (!$skipErrors) {
throw $e;
}
$output->writeln(sprintf("<error>Skipping Exception '%s'.</error>", $e->getMessage()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use warning instead of error I think, since $skipErrors basically downgrades them. Don't need the pre-text either then, just the exception. E.g. sprintf('<warning>%s: %s</warning>', get_class($e), $e->getMessage()).

@JamesRezo
Copy link
Contributor Author

Is there something blocking yet ?

alcohol added a commit that referenced this pull request Dec 15, 2015
@alcohol alcohol merged commit c568983 into composer:master Dec 15, 2015
@alcohol
Copy link
Member

alcohol commented Dec 15, 2015

No, I'll merge it, and if anything pops up I expect a new PR :-)

@JamesRezo JamesRezo deleted the feature/schema branch December 15, 2015 09:04
@glensc
Copy link
Contributor

glensc commented Jan 7, 2016

looks like this change made "homepage" key required, and it was not easy to figure out WHY the validation failed (the error is not self-explanatory). i had pretty much test each option to figure out what made validation to fail...

$ satis build libs.json  -vvv

  [Composer\Json\JsonValidationException]                       
  The json config file does not match the expected JSON schema  

Exception trace:
 () at /usr/share/php/Composer/Satis/Command/BuildCommand.php:269
 Composer\Satis\Command\BuildCommand->check() at /usr/share/php/Composer/Satis/Command/BuildCommand.php:128
 Composer\Satis\Command\BuildCommand->execute() at /usr/share/php/Symfony/Component/Console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /usr/share/php/Symfony/Component/Console/Application.php:838
 Symfony\Component\Console\Application->doRunCommand() at /usr/share/php/Symfony/Component/Console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /usr/share/php/Composer/Satis/Console/Application.php:52
 Composer\Satis\Console\Application->doRun() at /usr/share/php/Symfony/Component/Console/Application.php:120
 Symfony\Component\Console\Application->run() at /usr/bin/satis:13


build [--repository-url [REPOSITORY-URL]] [--no-html-output] [--skip-errors] [--] [<file>] [<output-dir>] [<packages>]...
$ cat libs.json
{
        "name": "libs",
        "description": "Composer Libraries Repository",
        "require-all": true,
        "repositories": [
        ]
}

@glensc
Copy link
Contributor

glensc commented Jan 7, 2016

also, "name" seems to be required now, i had repo without name working fine before (generated without html output), and even now the name seems to be optional

so i'd send PR to make "name" and "homepage" optional again, ok?

@stof
Copy link
Contributor

stof commented Jan 7, 2016

Well, the BuildCommand should display validation errors properly (the JsonValidationException contains some details)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants