Skip to content
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

Add support for global activating package from a custom pub URL #2041

Merged

Conversation

evanweible-wf
Copy link
Contributor

Proposed solution for #2039, looking for feedback on whether or not this would be an acceptable addition.

The solution ended up being very straightforward since pub already knows how to handle dependencies from custom hosted pub servers and activating a package globally is essentially just performing a pub get in a dummy package with a single dependency. All that was needed was a command-line flag to specify the custom pub URL that is then passed through to the .refFor() call used to build the dependency ref.

I went with --source-url for the CLI option mainly in an attempt to note its relation to --source while keeping it brief, but there may be a better name.

Additionally, since this flag is only applicable when activating from a hosted source, it might be worth failing if it is used with a non-hosted source.

Copy link
Member

@jonasfj jonasfj left a comment

Choose a reason for hiding this comment

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

Looks good if you ask me :)

I haven't tried to run the tests though.

@@ -38,6 +38,11 @@ class GlobalActivateCommand extends PubCommand {
argParser.addFlag("overwrite",
negatable: false,
help: "Overwrite executables from other packages with the same name.");

argParser.addOption("source-url",
Copy link
Member

Choose a reason for hiding this comment

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

--server-url or --hosted-url might be better, the key for this in the pubspec is dependencies.<packageName>.hosted.url

Or maybe --hosted-source-url

Copy link
Member

Choose a reason for hiding this comment

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

+1 on --hosted-url

test/global/activate/custom_source_url_test.dart Outdated Show resolved Hide resolved
@@ -38,6 +38,11 @@ class GlobalActivateCommand extends PubCommand {
argParser.addFlag("overwrite",
negatable: false,
help: "Overwrite executables from other packages with the same name.");

argParser.addOption("source-url",
Copy link
Member

Choose a reason for hiding this comment

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

+1 on --hosted-url

@natebosch natebosch removed the request for review from jakemac53 February 6, 2019 16:44
@evanweible-wf
Copy link
Contributor Author

@natebosch @jonasfj Updated the command line option to --hosted-url, let me know if there's any other changes you'd like to see.

@jonasfj jonasfj merged commit 980fc94 into dart-lang:master Feb 11, 2019
@evanweible-wf evanweible-wf deleted the support_custom_hosted_source_url branch February 11, 2019 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants