-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Semantic version utility #566
Comments
I've C code that does this sort of matching using the jv interfaces, but perhaps we should always use a jq program to do this (it'd be less code!). |
If we'd need this utility to be available for use in jq programs (rather than buried in the internals), then coding it once in jq seems best. OTOH, evaluating jq code in the process of loading libraries seems likely to slow things down unnecessarily. |
I've got a better version in C. |
@nicowilliams: great! Quick comment.
Yes, please. I'd like to be able to parse (for example) the suggested |
On Tue, Sep 02, 2014 at 02:55:35AM -0700, Joel Purra wrote:
I've re-written it rather differently, and in C. When it's closer I'll Responding out of order.
I agree that putting version information in a .jq file is a bit awkward! I'll definitely do this. Though I like having the option to put some I also have been meaning to allow for large constant data to be stored
Well, at Sun Microsystems we called it "micro" (Solaris marketing called
That seems much, much too complex for jq's needs.
Clearly 1.2.4 satisfies a requirement for 1.2.3. It's just not equal. There's not much point to having any semantics attached to major, minor, Though I agree that a way to express a strict equality requirement with I won't implement all of the syntax for node-semver#ranges unless (Wildcards are easy, so that will be supported, and in my new code
Semantic versioning is nothing new. Sun practiced it for decades, for Perhaps we could even have an option to use alternative versioning forms |
Also, regarding the version string BNF, I'd much rather use a JSON If these are absent in the importer's requirements, then they are An array representation is also ok ( The importer could have an I'm not really keen on parsing version strings no matter what the BTW, the BNF seems underdeveloped. Identifiers can start with '-'?! |
My new code does the following:
I should re-cast the code to be a cmp function, returning -1, 0, or 1, |
That would be great!
I'm of course referring to the http://semver.org/ standard.
Well, no. You're already about to implement all of it, just not standardized. Yes, I know the semver standard is working on strings, but they're not impossible to parse. Also, in this case it would be a good thing to indicate (throw an error?) a malformed semver string so there won't "ever" be any in the wild. (Comparing this to recently writing a URL library that had to swallow a lot of things, where "the wild" is really wild because malformed URLs are silently ignored.)
Having a default (for non-existent) operator that expands to
That'd be
Whatever subset you implement, I'd still say that it's best to follow an established standard. Again, node-semver#ranges are used in tens of thousands of published NPM packages.
You're making my point: "Details have generally varied." - and that's why there's now a semver standard that already has lots of momentum after only a few years. From semver.org:
If you decide to deviate from the semver standard and node-semver#ranges defacto standard, then yes please. But bear in mind that I still don't want to see any Note that it'd be easy for you to use the |
Please see the semver standard before implementing this.
Then you'd end up with a property per node-semver#ranges logic. I'd rather see
That's a good idea! Internally converting semver strings to "proper" objects, which can be used for comparisons. (Again, I'd love to see strict parsing without any margin for inconsistencies/errors.)
You might be right about these; I don't use semver outside of Guess some of it is related to how git can be used to generate version numbers. |
Sure. But for now I'm working with objects -- parsed versions. Parsing
Oh I know :(
Using equality as the default makes me wonder why bother with semantic Seriously, why shouldn't we do that? Why wouldn't that be good enough? Besides, to me semantic versioning is all about determining
Version metadata on I'll need a schema for the metadata JSON text, something like:
I know, it's "a" standard. I'm asking if that really is "the" standard :)
That does add appeal to Node semver, but I'm still not loving all of it. |
The problem I have is that if we're going to use equality by default we Wildcarding is -I agree- not a terribly good idea for major.minor.micro, So I'm definitely adding something (exact matching of commit IDs and
Is there a forum for discussing that standard?
It's traditional, really, not git-specific. People tend to do |
In a first iteration, I'd say stick to the very basics, and make sure to no deviate from the semver standard and the node-semver#ranges style of strings (albeit parsed to objects before used internally). Sticking with the basics means that a lookup for (Stuff like avoiding a known bad version
Yes! That is what package managers do, and that is what fuels a healthy language/system/code ecosystem where people can create and then share lego blocks.
In the first iteration, yes. (Further iterations could rely more on user-global/symlinked packages - but the Please read the smarts summed up here: This would be the
Great! If you ask me, you could make
Great! Note that the node module lookup algorithm doesn't mention versions - the package manager part does.
Yes, following the semver.org standard is great for determining compatibility, "Only ever" isn't what I said though - but equality is a sane default. (Do I need to remind you that people who release packages might not be sane enough for kosher semver?) Either way, a package manager will take care of the details for you.
I suggest looking at
{
"name": "shazam",
"version": "1.0.2",
"main": "./lib/i-call-this-what-i-want.jq",
"dependencies": {
"url-utils": "^1.6.1",
"advanced-statistics": "^7.1.0"
}
} Other metadata such as author, license, webpage can be added later - and it's of no interest to the
Yes, I consider it the standard. It has spread to several languages and systems I use, and people understand it well enough for it to work on a larger scale. Tried and true, well defined enough. |
No, not the same thing. Semver equality as the sane semver default is not the same as hash/string equality. Commit hashes are random, unsortable as strings without (complete) history.
I agree on a package manager utilizing a D/CVS that uses hashes as a backend for loading code/versions from. But it's not an accident that these hash based D/CVS's use tags as a human-parseable named pointer. If you really want to build a Merkle tree (cool!) then you can read the underlying D/CVS hash separately. It doesn't sound like something the
Not semver, no thanks.
Sure, put it in your package name - but keep it in your semver version string as well. You wouldn't release the package
I think the package manager should take care of it. If you want commit Again, see https://www.npmjs.org/doc/files/package.json.html
Yes, it's on github.
True. Since semver formalizes how prerelease versions etcetera are compared to other semvers, that adds to the appeal. Sorry for making this thread about package mangers by the way =) |
I'll be pushing the latest module system soon. There will be no versioning, but modules will be searched first locally to the modules importing them, thus allowing an external component to do all versioning. |
@joelpurra @pkoppstein @wtlangford @stedolan I've pushed a revamp of @wtlangford doesn't like the idea that |
So is the proposal to support:
? Would "import MODULE as null" not be simpler? It wouldn't preclude subsequent developments along the Python path. |
@pkoppstein I have no specific proposals. I'm open to them. I could live with I can also live with |
@nicowilliams -- In the previous posting in this thread, you confirmed what you had said elsewhere, e.g. on Aug 12, 2014 you wrote:
At present, however, it does not seem to be possible to import into the importer's namespace.
but
At present, therefore, there does not seem to be a way to "include" multiple libraries. This had been supported before, and I believe that as things stand, ensuring that the "import" command can be used to do so would be an appropriate path forward. Thanks! |
I've asked at Stack Overflow how to manage module dependencies in jq and user peak came up with a useful workaround. This can be extended for full semantic versioning (the official standard) and recursive dependencies, so we'll have a solution that works with jq >= 1.5.:
Sure build in support in jq would be better to simplify usage to
|
I was searching for a BNF specification of the JQ language as well. For the same reasons as mentioned here: https://softwarerecs.stackexchange.com/questions/91500/does-any-jmespath-jq-query-linter-validator-tool-exist-at-all. A clear syntax specification in whatever format would allow for JQ query syntax validation and for linting/feedback in IDE's such as VSCode. jmespath for example wrote their grammar using ABNF, as described in RFC4234, which can be found here: https://jmespath.org/specification.html. An alternative to BNF or ABNF to my understanding is Parsing Expression Grammars (PEG) which could be tested for example with https://peggyjs.org/online.html. |
There's a TextMate grammar at https://github.com/wooorm/starry-night/blob/main/lang/source.jq.js The paper at https://arxiv.org/pdf/2403.20132 has a formal grammar for the syntax of a large subset of jq. |
There is also https://github.com/wader/vscode-jq/tree/master/syntaxes which seems to be what the above TextMate grammar is based on, which itself was partially based on https://github.com/fadado/JBOL/blob/master/doc/JQ-language-grammar.md There is also at least two tree-sitter grammars for jq https://github.com/flurie/tree-sitter-jq and https://github.com/nverno/tree-sitter-jq but i'm not sure how complete they are. There is also https://github.com/wader/jq-lsp which i my LSP for jq which uses a modified version of gojq's parser which is yacc-based. |
@JaneX8 please let us know how it goes! could maybe ends up being something to add to https://github.com/fiatjaf/awesome-jq |
I will once I get to this but right now I'm breaking my head over it. Here are some thoughts, any suggestions are welcome. I have a very custom situation where I dynamically read a bunch of files that I gave the I basically enclosed the jq-queries inside a static JSON structure that is passed and successfully used by I considered writing at least some specific DevSkim (JSON) rules for this, and I still might for my use-case but those regular expressions are going to be insanely complicated, and I can't use JSON path inside those DevSkim rules too because well, it isn't valid JSON yet. So, I'm not looking forward to that without some kind of language implementation first. I'm not even sure the JQ language definition describes this behaviour, as in having a JQ enclosed in a JSON structure. I thought of using comments as placeholders to make it slightly easier, but I still need preprocessing then. An example: {
"name": "Example",
"data": [
# __JQ_START__
.input | map({ key: .key, value: .value })
# __JQ_END__
]
} If this is getting slightly off-topic, I'm fine to open a new issue. Any (alternative) thoughts anyone because I'm kind of stuck here now? Moved into a discussion here: #3218 |
Ok i see. The closest thing that can think of that can do that is https://github.com/wader/vscode-jq (or some other LSP-capable editor) combined with https://github.com/wader/jq-lsp. With that you can have jq expressions inside JSON and it will do syntax checking, scope checking, highlighting and completion to some extent. With "validate one step earlier" do you mean using some CLI tool to validate/lint? i've thought making jq-lsp capable of this. Yeap maybe at bit off-topic for this issue :) maybe continue in discussions? |
👍 I think anyone should be able to create a new discussion at https://github.com/jqlang/jq/discussions Yeap give them a try, i'm happy to help or improve them |
Consider this jq module:
Which means roughly:
$req
when the two are numeric or can be represented as numericVersion numbers of type "number" are compared numerically. Version numbers with major version number components can be given as objects and even as arrays.
It allows all of these as version specifications:
and even:
and so on.
One could then write
and so on and on.
The text was updated successfully, but these errors were encountered: