A docker container and management tools for running a local dart package respository.
Unpubd is essentially an installer for the unpub package.
The install creates two docker containers mongo, and unpubd.
Mongo provides the database for the packages and unpubd the web interface and api for the dart pub command.
Once installed and configured you can publish packages to a local repository.
Unpubd also acts as local proxy for pub.dev.
To use unpubd you can either use the unpub command in place of 'dart pub' or set up an environment variable PUB_HOSTED_URL which will cause dart pub to use your local repository.
Unpubd was created by the OnePub team.
If you don't want to roll your own private repository then OnePub provides a SAAS solution with a generous free tier.
OnePub allows you to privately share dart packages between your own projects or with colleagues. Try it for free and publish your first private package in seconds.
Note: If you try the beta and send me a note with your thoughts, via the 'Contact OnePub' link on the home page and mention unpubd, I will organise you a free upgrade to 5 pro seats, which might fix your unpubd problem ;)
FYI: we still plan on supporting unpubd.
dart pub global activate onepub
onepub login
dart create mytool
cd mytool
onepub pub private
dart pub publish
See the OnePub blog on publishing your first package.
- Docker
- docker-compose
Start by installing the prequesites note above.
Then run.
dart pub global activate unpubd
unpubd install
When you install unpubd it will ask you for a port no. (defaults to 4000) to expose unpubd on. You can changes this to any port between 1025 and 65000). Just make sure the port isn't already in use.
To start unpubd in the foreground
unpubd up
To start unpubd in the background
unpub up --detach
If you are using unpubd in the foreground then just hit ctrl-c to terminate the app.
If th unpubd is running in the background run:
unpubd stop
The pub get/outdated/upgrade/publish commands all interact with pub.dev
See the OnePub blog on publishing your first package. Whilst it is written for OnePub it also covers of the basics of publishing a package.
Note: both flutter pub
and dart pub
work the with the same changes desribed below.
Two methods are available to redirect the pub command to use your local package repository.
If you set the PUB_HOSTED_URL environment variable to point to your local repository then both dart pub and flutter pub will use your local repo.
You need to configure the environment variable so it is avialable in your shell.
Once PUB_HOSTED_URL is created you can run any pub command and your local repository will be used.
export PUB_HOSTED_URL=http://localhost:4000
Add the same URL to your PATH via the registry.
Drop me a line if you know the details :)
The unpub command (as opposed to unpubd which we used during the install) is simply a pass through mechanism to dart pub. The unpub command dynamically sets the PUB_HOSTED_URL and then calls dart pub with the same arguments.
- unpub - for user of the Dart SDK use:
- funpub - For users of the Flutter SDK use:
This approach has the advantage in that if you need to revert to using pub.dev you can just revert to using dart pub/flutter pub and you don't have to create any environment variables.
To publish your packages to unpubd (rather than pub.dev) you need to add a 'publish_to' key to your packages pubspec.yaml.
name: dcli
description: Dart console SDK
version: 1.0.0
repository: https://github.com/noojee/dcli
homepage: dcli.noojee.dev
publish_to: http://your-unpubd-server.com
Now when you run pub publish
for your package it will be published to your unpubd server.
If you run dart pub with the PUB_HOSTED_URL or unpub then pub will automatically try to pull dependencies from unpubd.
However you can also ensure that your package dependencies are always pulled from unpubd by altering the dependency in pubspec.yaml to a 'hosted' dependency.
dependencies:
dcli:
hosted:
url: http://your-unpubd-server.com
version: ˆ1.0.0
This technique is also useful if you are preparing a PR for a public package. You can first publish it to your unpubd server and test it internally before pushing the PR.
I find this particularly useful while you are waiting for a public package to accept and publish your PR.
unpubd suports a number of commands
Installs unpubd and the docker containser
Deletes the docker containers and volumes.
WARNING: all of you local packages will be deleted.
Starts the unpubd and mongo docker containsers.
Shuts down the unpubd and mongo containers.
This section is for developers of unpubd.
- Docker
- docker-compose
- dcli (pub global activate dcli)
- pub_release (pub global activate pub_release)
- critical_test (pub global activate critical_test)
To create a release of unpubd
dcli pack
tool/build.dart
pub_release
The release process builds and publishes docker images to the Noojee repository (you need to be an admin on the docker hub noojee repo) and publishes the package to pub.dev.
When making source code changes that need require a rebuild of you docker images you can use the --clone switch.
tool\build.dart --clone
This command will only re-clone the source from git hub and only rebuild the docker steps required.
If you need to force a full rebuild of the docker container use:
tool\build.dart --clean
If you are having problems accessing your unpubd server here are a few things you can try.
-
To see the status of your unpubd service.
Run:
unpubd doctor
-
Check the logs
docker logs unpubd docker logs mongo