dub run <package> should search the registry on failure#1082
dub run <package> should search the registry on failure#1082wilzbach wants to merge 1 commit intodlang:masterfrom
Conversation
|
What about making this slightly interactive and requiring the user to confirm the download. This would also be a chance to print the package description and maybe the github address, to make it less likely to make this en entry point for malicious code. There is http://code.dlang.org/packages/gitcompatibledubpackage which is used in some of the tests already. We'd just have to add an executable configuration (in this case just a |
Good idea - I gave it a shot. It's not perfect because without more refactoring the
https://github.com/MartinNowak/gitcompatibledubpackage/pull/1/files I also added a test for this -> Travis will fail for a bit. |
Merged |
|
Appears that |
| set -e -o pipefail | ||
|
|
||
| $DUB remove --version='*' cpuid > /dev/null 2>&1 || true | ||
| $DUB run dfmt |
There was a problem hiding this comment.
How is that different from the test below?
source/dub/commandline.d
Outdated
| if (json == Json.emptyObject) | ||
| return 2; | ||
|
|
||
| writefln("%s wasn't found online, but there's version available online:", package_name); |
There was a problem hiding this comment.
dfmt wasn't found online, but there's version available online???
source/dub/commandline.d
Outdated
| writefln("%s wasn't found online, but there's version available online:", package_name); | ||
| if ("authors" in json) | ||
| writefln("Authors: %-(%s, %)", json["authors"][].map!(v => v.get!string)); | ||
| if ("license" in json) |
There was a problem hiding this comment.
How about
if (auto p = "license" in json)
writefln("Description: %s", p.get!string);
source/dub/commandline.d
Outdated
| if ("version" in json) | ||
| writefln("Version: %s", json["version"].get!string); | ||
| if ("description" in json) | ||
| writefln("License: %s", json["license"].get!string); |
There was a problem hiding this comment.
Description and License are mixed up.
source/dub/commandline.d
Outdated
| default: | ||
| } | ||
| } else { | ||
| nb = true; |
There was a problem hiding this comment.
Should be the default value, no?
source/dub/commandline.d
Outdated
| nb = true; | ||
| case "no", "n": | ||
| nb = false; | ||
| default: |
There was a problem hiding this comment.
I'd rather loop in here, than on the outside. Also allows you to drop Nullable.
source/dub/commandline.d
Outdated
| logInfo("Retry with ~master..."); | ||
| dep = Dependency("~master"); | ||
| json = dub.info(package_name, dep, fetchOpts, supplier); | ||
| } |
There was a problem hiding this comment.
Could this maybe reuse dub.searchPackages?
source/dub/commandline.d
Outdated
| auto package_name = free_args[0]; | ||
| auto pack = dub.packageManager.getFirstPackage(package_name); | ||
|
|
||
| if (!pack) |
There was a problem hiding this comment.
Please check some --non-interactive argument as well to prevent hanging scripts.
Dub packages must first be fetched before you can run them, at least until dlang/dub#1082 is accepted.
Dub packages must first be fetched before you can run them, at least until dlang/dub#1082 is accepted.
|
Thanks for your pull request, @wilzbach! |
473f67a to
f6cf601
Compare
|
Okay I finally found time to rebase and rework this. Thanks to @MartinNowak's feedback and the time passed since I submitted this, I managed to cut the size of this PR in half :) This only needs a new release of |
source/dub/commandline.d
Outdated
|
|
||
| bool answer = input("Do you want to fetch %s?".format(package_name)); | ||
| auto dep = Dependency(p.version_); | ||
| dub.fetch(package_name, dep, dub.defaultPlacementLocation, fetchOpts); |
There was a problem hiding this comment.
Nitpick: since the package doesn't exist locally, FetchOptions.forceBranchUpgrade shouldn't have an effect and FetchOptions.none would be sufficient here.
|
I accidentally closed this PR because I wanted to trigger a notification to Semaphore while I pushed and GitHub doesn't seem to like this (even restoring the old commit sha still doesn't allow me to reopen). Anyway, I opened a new PR -> #1428 |
Adds a simple fallback to
dub run, s.t. the following pattern simply works:I am not sure how we can best test this without querying the registry. Also I don't know any package that is compatible with all the compilers that DUB supports.
What would be the best strategy here?