Transferring a dart library to another owner in pub.dartlang.org - dart

Since pub uses my identity for the publish, how would I go about transferring control to someone else, yet still allow them to publish releases to the same project? Maybe this is trivial; I've never tried it.

You can use pub uploader [options] {add/remove} <email>.
Once the new uploader added, you can remove yourself.
pub uploader add <new-owner-email>
pub uploader remove <old-owner-email>
$ pub uploader -h
Manage uploaders for a package on pub.dartlang.org.
Usage: pub uploader [options] {add/remove} <email>
-h, --help Print usage information for this command.
--server The package server on which the package is hosted.
(defaults to "https://pub.dartlang.org")
--package The package whose uploaders will be modified.
(defaults to the current package)

Update: It is now possible to invite new uploaders using the admin tab on the package page on pub.dev website.

Related

How do I log out from Dart's pub package manager?

I have uploaded packages to pub.dartlang.org under two different accounts (one of them work-related, the other personal).
The pub command line tool doesn't have any option to select with which account to publish, so once I log on with the tool, and try to upload a package that belongs to the other account, I see:
$ pub publish
UnauthorizedAccess: Unauthorized user: ___#example.com is not allowed to upload versions to package xyz..
How do I publish with a specific account? Failing that, how do I log out the pub tool in order to log on again under a different account?
There is currently no way in the command line pub tool to upload under different credentials (although there is a proposal).
If you have a fairly recent version of pub, you can log out with:
$ pub logout
Then try pub publish again. The tool will ask you for new credentials.
Could not find a command named "logout".
The pub logout command is an addition from January 2019. If pub tells you this command doesn't exist, you'll have to manually remove the credentials file.
$ rm ~/.pub-cache/credentials.json
If you want to temporarily publish with different credentials you can use a command like:
PUB_CACHE=~/.other_credentials_cache pub publish
This will create a entirely separate "profile" which is used whenever running any pub command with the PUB_CACHE environment variable pointing to a directory other than ~/.pub_cache. If you were to pub get with this cache you'd get entirely separate package downloaded.
With this approach you can toggle between credentials by specifying or not specifying the different cache directory. You'll need to authenticate the first time you use the new directory.

Mimicking build_runner serve on a nodeJs server

With the expiration of Dartium that happened just a few days ago, I felt compelled to migrate from dart 1.24.3 to Dart2, even though it is still in dev.
I have although hit a few walls doing so, one of them being related to the architecture of my apps.
I run a nodeJs server, which also acts as a webserver with client side dart.
The problem that I experience with the new dart SDK is that in order for the .dart files to be read in Chrome, they must be served using webdev serve or build_runner serve.
Obviously, these 2 commands act as the file server, which is not what I want since I'm using a nodeJS server.
By using build_runner watch I think I am enabling the build and watch of the .dart files into .dart.js inside of the following directory :
.dart_tool/build/generated//lib
I am also able to serve them from my nodeJS server. What remains is the package directory, I can't seem to find where pub serves gets the following package files:
/packages/$sdk/dev_compiler/amd/require.js
/packages/$sdk/dev_compiler/amd/dart_sdk.js
Does anyone know what build_runner serve does to include them?
Thank you,
There are 2 options for using a different server during development.
Run build_runner serve on a different port and proxy the requests to it from your other server. This has the benefit of delaying requests while a build is ongoing so you don't get an inconsistent set of assets.
Run build_runner watch --output web:build and use the created build/ directory to serve files from. This will include a build/packages directory that has these files in it.
These files are served from the lib directory of the dart sdk itself.
Note that there is another option, which is to use the -o option from build_runner. This will create a merged directory with source and generated files, which you can serve directly without relying on any internal file layout.

How to use dartdoc to generate the documentation for flutter like docs.flutter.io?

I found the command of dartdoc, when I run it, I get the api documantation for Dart. How can I generate the documantation for flutter just like docs.flutter.io?
Run from the project root directory the command line command
new
dart doc
old
pub global activate dartdoc
dartdoc
See also https://pub.dartlang.org/packages/dartdoc
By default docs are only generate for the public API in lib/.
Code in lib/src/ is considered private if not exported from files in lib/

How to install waf?

I have cloned and built the waf script using:
./waf-light configure
Then to build my project (provided by Gomspace) I need to add waf and the eclipse.py to my path. So far I haven't found better than this setenv script:
WAFROOT=~/git/waf/
export PYTHONPATH=$WAFROOT/waflib/extras/:$PYTHONPATH
export PATH=~/git/waf/:$PATH
Called with:
source setenv
This is somehow a pretty ugly solution. Is there a more elegant way to install waf?
You don't install waf. The command you found correctly builds waf: /waf-light configure build Then for each project you create, you put the built waf script into that projects root directory. I can't find a reference, but this is the way in which waf:s primary author Thomas Nagy wants the tool to be used. Projects that repackage waf to make the tool installable aren't "officially sanctioned."
There are advantages and disadvantages with non-installation:
Disadvantages:
You have to add the semi-binary 100kb large waf file to your repository.
Because the file contains binary code, people can have legal objections to distributing it.
Advantages:
It doesn't matter if new versions of waf break the old API.
Users don't need to install waf before compiling the project -- having Python on the system is enough.
Fedora (at least Fedora 22) has a yum package for waf, so you could see that it's possible to do a system install of waf, albeit with a hack.
After you run something like python3 ./waf-light configure build, you'll get a file called waf that's actually a Python script with some binary data at the end. If you put it into /usr/bin and run it as non-root, you'll get an error because it fails to create a directory in /usr/bin. If you run it as root, you'll get the new directory and /usr/bin/waf runs normally.
Here's the trick that I learned from examining the find_lib() function in the waf Python script.
Copy the waf to /usr/bin/waf
As root, run /usr/bin/waf. Notice that it creates a directory. You'll see something like /usr/bin/.waf-2.0.19-b2f63c807a4215294bf6005410c74c18
mv that directory to /usr/lib, dropping the . in the directory name, e.g. mv /usr/bin/.waf-2.0.19-b2f63c807a4215294bf6005410c74c18 /usr/lib/waf-2.0.19-b2f63c807a4215294bf6005410c74c18
If you want to use waf with Python3, repeat Steps 2-3 running the Python script /usr/bin/waf under Python3. Under Python3, the directory names will start with .waf3-/waf3- instead instead of .waf-/waf-.
(Optional) Remove the binary data at the end of /usr/bin/waf.
Now, non-root should be able to just use /usr/bin/waf.
That said, here's something to consider, like what another answer said: I believe waf's author intended waf to be embedded in projects so that each project can use its own version of waf without fear that a project will fail to build when there are newer versions of waf. Thus, the one-global-version use case seems to be not officially supported.

dart pub package upload user?

I've recently started using a new development machine and when I try to upload my pub package it fails saying "You aren't an uploader for package '\name\'." I've had a look on the pub site but haven't found away for me to find out A) who it thinks I am and B) how to give my current user access.
What is the package name?
You can take a look at the command pub uploader to modify your local uploader settings.

Resources