Giter VIP home page Giter VIP logo

pub_server's Introduction

ARCHIVED

This repo has been archived, and is no longer maintained.

Issues and PRs will not be responded to.

Should there be community interest in alternate package servers for Dart, we recommend these are handled as community projects.

NOTE: This is package is an alpha version and is not recommended for production use.

Provides re-usable code for making a Dart package repository server. The package:pub_server/shelf_pubserver.dart library provides a shelf HTTP handler which provides the HTTP API used by the pub client. One can use different backend implementations by implementing the PackageRepository interface of the package:pub_server/repository.dart library.

Example pub repository server

An experimental pub server based on a file system can be found in example/example.dart. It uses a filesystem-based PackageRepository for storing packages and has a read-only fallback to the real pub.dartlang.org site, if a package is not available locally. This allows one to use all pub.dartlang.org packages and have additional ones, on top of the publicly available packages, available only locally.

It can be run as follows

~ $ git clone https://github.com/dart-lang/pub_server.git
~ $ cd pub_server
~/pub_server $ pub get
...
~/pub_server $ dart example/example.dart -d /tmp/package-db
Listening on http://localhost:8080

To make the pub client use this repository configure your shell via:

    $ export PUB_HOSTED_URL=http://localhost:8080

Using it for uploading new packages to the locally running server or downloading packages locally available or via a fallback to pub.dartlang.org is as easy as:

~/foobar $ export PUB_HOSTED_URL=http://localhost:8080
~/foobar $ pub get
...
~/foobar $ pub publish
Publishing x 0.1.0 to http://localhost:8080:
|-- ...
'-- pubspec.yaml

Looks great! Are you ready to upload your package (y/n)? y
Uploading...
Successfully uploaded package.

The fact that the pub publish command requires you to grant it oauth2 access - which requires a Google account - is due to the fact that the pub publish cannot work without authentication or with another authentication scheme. But the information sent by the pub client is not used for this local server at the moment.

pub_server's People

Contributors

anands avatar isoos avatar jakobr-google avatar jonasfj avatar kevmoo avatar koudle avatar mit-mit avatar mkustermann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pub_server's Issues

After I executed "pub publish", the authorization was successful, but I always waited for timeout. May I ask why?

D:\pub_server\pub_server>pub publish
Publishing pub_server 0.1.6-dev to https://pub.flutter-io.cn:
|-- .gitignore
|-- .idea
| |-- codeStyles
| | '-- Project.xml
| |-- libraries
| | |-- Dart_Packages.xml
| | '-- Dart_SDK.xml
| |-- misc.xml
| |-- modules.xml
| |-- pub_server.iml
| |-- vcs.xml
| '-- workspace.xml
|-- .travis.yml
|-- AUTHORS
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- analysis_options.yaml
|-- codereview.settings
|-- example
| |-- example.dart
| '-- src
| '-- examples
| |-- cow_repository.dart
| |-- file_repository.dart
| '-- http_proxy_repository.dart
|-- lib
| |-- repository.dart
| '-- shelf_pubserver.dart
|-- pubspec.yaml
'-- test
'-- shelf_pubserver_test.dart
Suggestions:

  • .\CHANGELOG.md doesn't mention current version (0.1.6-dev).
    Consider updating it with notes on this version prior to publication.

Package has 1 warning. Upload anyway (y/n)? y
Pub needs your authorization to upload packages on your behalf.
In a web browser, go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A61995&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
Then click "Allow access".

Waiting for your authorization...
Authorization received, processing...
It looks like accounts.google.com is having some trouble.
Pub will wait for a while before trying to connect again.
OS Error: 信号灯超时时间已到
, errno = 121, address = accounts.google.com, port = 62508

D:\pub_server\pub_server>pub publish
Publishing pub_server 0.1.6-dev to https://pub.flutter-io.cn:
|-- .gitignore
|-- .idea
| |-- codeStyles
| | '-- Project.xml
| |-- libraries
| | |-- Dart_Packages.xml
| | '-- Dart_SDK.xml
| |-- misc.xml
| |-- modules.xml
| |-- pub_server.iml
| |-- vcs.xml
| '-- workspace.xml
|-- .travis.yml
|-- AUTHORS
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- analysis_options.yaml
|-- codereview.settings
|-- example
| |-- example.dart
| '-- src
| '-- examples
| |-- cow_repository.dart
| |-- file_repository.dart
| '-- http_proxy_repository.dart
|-- lib
| |-- repository.dart
| '-- shelf_pubserver.dart
|-- pubspec.yaml
'-- test
'-- shelf_pubserver_test.dart
Suggestions:

  • .\CHANGELOG.md doesn't mention current version (0.1.6-dev).
    Consider updating it with notes on this version prior to publication.

Package has 1 warning. Upload anyway (y/n)? y
Pub needs your authorization to upload packages on your behalf.
In a web browser, go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A63172&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
Then click "Allow access".

Waiting for your authorization...
Authorization received, processing...
It looks like accounts.google.com is having some trouble.
Pub will wait for a while before trying to connect again.
OS Error: 信号灯超时时间已到
, errno = 121, address = accounts.google.com, port = 63891

multiple source about pub

I need to publish libs to my personal pub, and I need "flutter packages get" by multiple source. Thanks

pub get not finishing

Great job on this one! I'm trying out this server using the original example. I was able to push a library A without a problem but when calling pub get from library B which depends on A it simply never finishes the resolving packages stage. This is due to the following exception:

ERROR - 2018-08-09 23:53:30.287675
Asynchronous error
type 'List<dynamic>' is not a subtype of type 'List<Map<dynamic, dynamic>>' in type cast
dart:core                                              Object._as
example/src/examples/http_proxy_repository.dart 33:37  HttpProxyRepository.versions
===== asynchronous gap ===========================
example/src/examples/cow_repository.dart 135:18        _RemoteMetadataCache.fetchVersionlist.<fn>
dart:collection                                        __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent
example/src/examples/cow_repository.dart 131:10        _RemoteMetadataCache.fetchVersionlist
example/src/examples/cow_repository.dart 47:35         CopyAndWriteRepository.versions.onListen
dart:async                                             Stream.toList
package:pub_server/shelf_pubserver.dart 244:62         ShelfPubServer._listVersions

PS: Is there any plan to replicate all pub.dartlang.org functionality eventually? Including serving a website to browse packages, version, and documentation.

Set Content-Type application/vnd.pub.v2+json

The client was originally designed to send Accept: application/vnd.pub.v2+json, to support multiple versions of the API.

I've recently documented this in:
https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md

We should probably start responding Content-Type: application/vnd.pub.v2+json to requests which carry Accept: application/vnd.pub.v2+json.

We might have to interpret no accept header or application/json accept header as to mean return Content-Type: application/json with the version 2 format. We could likely do some logging and figure out of this is necessary and then document it in the API docs.

But just returning Content-Type: application/vnd.pub.v2+json to requests with Accept: application/vnd.pub.v2+json is a good start. It means clients can start to check the Content-Type.

Pub Server Authentication For Private Pub Packages

Currently in order to host proprietary pub packages on a private pub server, the server must be behind a VPN. There is no way to require authentication for package downloads. Maven, npm, and Go all have ways of putting packages behind authentication barriers.

I saw no existing issue discussing this, so I figured I'd make one to get it on the Dart team's radar.

Local private pub-server usage problem

I built the pub-server successfully on this machine, and then uploaded the private package successfully, but I am relying on this package in the project when the error is as follows:
image
Dependency settings are as follows:
image
Please help me to see what the problem is, thank you!

pub get hanging on typing issue

When the server tries to find a package on the remote, it throws a typing error.

//type 'List' is not a subtype of type 'List<Map<dynamic, dynamic>>' in type cast example\src\examples\cow_repository.dart 135:18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.