-
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
Working module/package system #673
base: master
Are you sure you want to change the base?
Conversation
-f
filter
In this POC I haven't fixed importing relative modules |
12862d7
to
20f065b
Compare
If this idea is to be implemented upstream one day, please consider choosing another name for the I would suggest
|
@zopieux: No worries -- it's not an env var, even though it looks like one. It is used internally when resolving context-dependent paths; as is That said, these strings could also be prefixed internally -- although I'm not sure it's necessary. |
My bad, thought that was part of the finding-lib-directories stuff. |
@zopieux: it is part of finding lib dirs for the package system in this pull request -- unless we're accidentally talking about different things -- but |
fb64e35
to
3e4dc88
Compare
Code comments by @nicowilliams were lost during rebase; here are the direct commit links:
|
41138d4
to
d74351a
Compare
@nicowilliams: pushed updated code, hopefully addressing your comments. Further things to work on:
|
The default file path |
You can see my fixes in the |
@nicowilliams: great! I'll look at nicowilliams@3cd687c and nicowilliams@2afc83a. |
@nicowilliams: regarding comment in joelpurra@784fbc3 for "Use P/jq/main.jq if no -f and no direct filter"; this is the old packages/projects difference confusion. Packages (only functions, only imported as modules) and projects (non-functions are allowed, can't be imported, are used directly) are very similar and they're treated the same by jqnpm in terms of installation/management. Guess projects can be seen as "entry-points" -- this is where you'd write code, while depending on (other people's) packages. You won't execute "Use P/jq/main.jq if no -f and no direct filter" is not a critical feature and I'm open to comments. It's partially connected to the (current lack of) This may be superseded by #!/usr/bin/env jq --SOMEFLAG /path/to/P |
58e17a2
to
57f2ec2
Compare
@joelpurra But deciding on such things based on (The default program, when we have a tty, is now |
@nicowilliams: doesn't mean just about every other interpreter is right. I'll drop the commit though. It was meant to come later anyways, but it was easier to implement than reading Edit: done. |
And BTW, the tests pass for me on Linux. There was an infinite loop in the package dir search code. You saw I removed all the logic for detecting that we've reached the root directory and replaced it with checking when |
@nicowilliams: checking the length is much smarter than my solution, thanks! All that should be merged (already). |
Thanks. I'll do a final review the next couple of days. |
@nicowilliams: the tests in jqnpm are more evolved (emulating remote git server and the local cache, etcetera), so please check them out. I'll keep the I'll look at |
@joelpurra Import relative to module doing the import is already supported. As to the |
@dtolnay: haven't rebased my jq fork since May, so it looks like this pull-request is a bit outdated. The last thing I did was incorporate @nicowilliams' suggested changes (#673 (comment)). Feature-wise this is a good start for a module system; I've also implemented From the first comment (#673 (comment)):
@nicowilliams says (in the previous comment #673 (comment)) relative paths are supported, but I haven't confirmed in jqnpm myself. Barring any conflicts since I last ran the test suite in @dtolnay: you seem to be on a roll -- care to look at the merge conflicts in this pull request? C isn't my forte, but you seem fluent =) By the way: gave core jq developers/contributors collaborator access to joelpurra/jqnpm, so as to not hold up v1.5 more than necessary -- go ahead and implement minor fixes. |
@nicowilliams, @dtolnay: rebased and pushed. Please test, lint etcetera to make sure the C code is alright. @pkoppstein, @slapresta, @wtlangford, @agordon, others interested: please test this pull request against joelpurra/jqnpm@jq-package-root. Testing |
Any news on this? |
Re-reviewing this and my fixups, I think the only part we should take is the I don't really like having to hard-code things like |
Haven't updated my forked brew tap joelpurra/joelpurra
brew unlink jqnpm
brew unlink jq
brew install jqnpm --devel jq -f file/with/deep/imports.jq |
The current package system is not a mess - this should prove things work. I'll read #672 soon.
See also #659 (comment). If you haven't tried
jqnpm
yet, please clone it right away. There is no need for me to try to convince you if you won't even try the POC of a working system.