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

request: support authentication with private pub repositories #498

Closed
1 task done
adamzhu-xs opened this issue Apr 11, 2023 · 6 comments · Fixed by #627
Closed
1 task done

request: support authentication with private pub repositories #498

adamzhu-xs opened this issue Apr 11, 2023 · 6 comments · Fixed by #627

Comments

@adamzhu-xs
Copy link

adamzhu-xs commented Apr 11, 2023

Is there an existing issue for this?

  • I have searched the existing issues.

Version

3.0.1

Description

Below is correct url to get package versions.

https://artifactory.abc.com/artifactory/api/pub/pub-all/api/packages/my_package

Melos is using wrong url after below line of code:

final url = pubHosted.replace(path: '/api/packages/$name');

https://artifactory.abc.com/api/packages/my_package -> this will give 404

Steps to reproduce

You have to setup a private pub host

Expected behavior

Melos should works with different pub host (different urls)

Screenshots

No response

Additional context and comments

No response

@adamzhu-xs adamzhu-xs added bug Something isn't working Needs: Triage The issue needs triaging labels Apr 11, 2023
@adamzhu-xs
Copy link
Author

Need add auth header also.

final pubToken = currentPlatform.environment['PUB_TOKEN'] ?? '';
final response = await http.get(url, headers: {'Authorization': 'Bearer $pubToken'});

@blaugold
Copy link
Collaborator

blaugold commented May 2, 2023

In your case, the full URL for the private pub repository is https://artifactory.abc.com/artifactory/api/pub/pub-all. For example:

name: myapp
dependencies:
  mypkg:
    version: ^1.0.0
    hosted:
      url: https://artifactory.abc.com/artifactory/api/pub/pub-all
      name: mypkg

See also the pub repository spec.

Melos does not currently support pub repositories that require authorization, but we might be able to use the tokens managed by the dart pub token commands.

@blaugold blaugold added feature request and removed bug Something isn't working Needs: Triage The issue needs triaging labels May 2, 2023
@blaugold blaugold changed the title fix: Melos getPublishedVersions not working for packages hosted on private artifactory request: support authentication with private pub repositories May 2, 2023
@adamzhu-xs
Copy link
Author

Thx for checking. However i am trying to publish private package into private repository. The spec change is for include dep package which is different thing.

Also pub token is working for me with private repository. However during publishing Melos is using http.get directly which didn't include default pub token.

@ncuillery
Copy link

Exactly, publishing to private repo works, but I'm not able to run melos publish to publish only the packages that needs to be published.

Melos sees all the packages as unpublished. If I confirme the publish operation with "yes", it fails with "This version already exists".

@ncuillery
Copy link

For my privately-hosted packages on Jetbrains Space, it now breaks with a 503 before the "yes" step:

$ melos publish
melos publish
  └> /Users/ncuillery/Dev/my/path

Reading pub registry for package information... SUCCESS
Unhandled exception:
Exception: Error reading pub.dev registry for package "my_package" (HTTP Status 503), response: 
#0      Package.getPublishedVersions (package:melos/src/package.dart:908:7)
<asynchronous suspension>
#1      _PublishMixin._getLatestPublishedVersionForPackages.<anonymous closure> (package:melos/src/commands/publish.dart:110:24)
<asynchronous suspension>
#2      Pool.forEach.run (package:pool/pool.dart:183:19)
<asynchronous suspension>
#3      Pool.withResource (package:pool/pool.dart:127:14)
<asynchronous suspension>
#4      Future.wait.<anonymous closure> (dart:async/future.dart:525:21)
<asynchronous suspension>

melos version 3.1.1 (it works fine with 3.0.0)

@VictorOhashi
Copy link
Contributor

Probably a good solution would be to implement something like pub does:

https://github.com/dart-lang/pub/blob/master/lib/src/source/hosted.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants