-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Is your feature request related to a problem?
The current cli.schema.json does not include a version property for CLI definitions, nor does it enforce a standard versioning format. To ensure consistency and enable automated tooling to correctly parse and interpret CLI versions, we need to introduce a version property and validate it against the Semantic Versioning (Semver) specification, specifically excluding the 'v' prefix.
Problem:
Without a defined version field and corresponding validation, CLI definitions might use inconsistent version strings (e.g., "v1.0.0", "1.0", "release-1.0.0"), making it difficult to programmatically determine and compare versions.
Describe the solution you'd like
Proposed Solution:
-
Add
versionproperty tocli.schema.json:
Introduce a new top-level property namedversionto thecli.schema.json. -
Enforce Semver format:
Utilize a regular expression to validate theversionproperty, ensuring it adheres to the Semver 2.0. specification (e.g.,MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]) but without an optional leading 'v'
A suitable regex for this might be:
`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\
[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`
Benefits:
*Consistency: All CLI definitions will use a standardized version format.
- Interoperability: Easier for external tools and scripts to parse and utilize version information.
- Clarity: Clearer communication of breaking changes and new features through standardized versioning
Example of desired schema addition (conceptual):
{
"$id": "https://example.com/cli.schema.json",
"$schema": "<http://json-schema.org/draft-07/schema#>",
"title": "CLI Schema",
"description": "Canonical schema for declarative CLI definitions",
"version": {
"type": "string",
"description": "The semantic version of the CLI definition (e.g., '1.0.0'). Must follow semver without a
'v' prefix.",
"pattern":
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\
\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]))))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
},
"type": "object",
"properties": {
"cli": {
// ... existing cli properties
}
},
// ... existing definitions
}
Describe alternatives you've considered
No response
Additional Context
No response