Cloudsmith Launches World’s First Private Dart Repository Service
The promise of Cloudsmith is simple. We ensure development teams have access to the software packages they need, when they need them.
And we do that through a private, cloud-based repository that can help shield the business from malware, security and licensing concerns related to the use of third party software packages, whilst giving you total control over access to your own packages.
A key aspect of our approach is universality. We understand that individual developers and teams work in multiple languages and with multiple package formats. We allow them to continue to do just that, but handle package management in a consistent, reliable and performant way through Cloudsmith.
Dart is an open-source, object-oriented, general-purpose programming language developed by Google. It is a client-optimized language for building fast apps on any platform, focused on providing a productive environment for developers new to the web, especially developers comfortable with structured languages and tools.
Since 2013, Google has implemented websites such as AdWords and Google Fiber using Dart, and in 2017, we saw the release of Flutter; Google’s UI framework for building native interfaces in iOS and Android, which is built on top of Dart.
The popularity of Flutter has spurred a revival of Dart's usage for mobile development, a process accelerated by the roll-out of Dart 2.0, which featured improvements to client-side development, including strong typing and “UI as code”. Dart also appears to be popular with those who use it. In 2019 the Stack Overflow developer survey found that 66.3% of those using Dart would continue to use it in future - putting it firmly in the ‘loved’ category.
Dart comes bundled with Pub, a package manager for the Dart programming language, containing reusable libraries & packages for Flutter and general Dart programs.
As most readers will know, packages allow code-sharing and reusability across Flutter/Dart apps. Pub is responsible for downloading and installing these packages, mostly from pub.dev, the official Dart package repository.
But you don’t have to use pub.dev. Pub provides all the necessary tooling and configuration flags to point at another repository if needed.
And there are several great reasons you may wish to do exactly that - and run your own private repository on Cloudsmith. Taking this approach allows development teams to:
Develop Dart packages internally and share them privately to other teams.
Distribute and deploy your own Dart packages in a pipeline at your org.
If you take a look inside the new directory where you created these files you'll see the following:
│ ├── output.dart
At present, the native tooling does not support generating a package but it can be used to validate the pubspec.yaml using the lish command via pub:
$ pub lish
To create the package, we will use tar to copy all files into a .tar.gz. In this example, the only files that exist are our pubspec and dart file however it's important to exclude any unnecessary files.
$ tar --exclude='.dart_tool' -czf my-package-0.1.0.tar.gz ./*
Once built you can push the package to Cloudsmith using the Cloudsmith CLI. We don't yet support pushing packages with pub publish, but we'll be adding support in a future release (if you want it, please let us know). For now, use the CLI.
Publishing your Dart packages to Cloudsmith
First, ensure you've installed the Cloudsmith CLI and configured authentication:
Then, use the CLI to push the package, which operates like pub publish but is specific to Cloudsmith:
$ cloudsmith push dart my-org/my-repo my-package-0.1.0.tar.gz
Checking dart package upload parameters ... OK
Checking my-package-0.1.0.tar.gz file upload parameters ... OK
Requesting file upload for my-package-0.1.0.tar.gz ... OK
Creating a new dart package ... OK
Created: my-org/my-repo/my-package-010targz (eeb4n20QxSYM)
Synchronising my-package-010targz: [####################################] 100% Sync Completed / Fully Synchronised
Package synchronised successfully!
Your repository should now contain the uploaded package. An example of which is our official Cloudsmith examples repository (this is where we upload our examples from), as shown below:
Installing your Dart packages from Cloudsmith
First, we need to tell Pub how to access the repository. To do so you need to add the following entry in your pubspec.yaml (replace TOKEN with an entitlement token, which is a type of read-only authentication token that we support)
It really is that simple, and now you've sourced a Dart package privately from your very own private Dart repository on Cloudsmith. Well done!
Cloudsmith provides fully featured Dart repositories on all plans, flexible enough for use whether you’re hosting public packages for a public or open-source project, or private packages for your company’s internal needs. We're extremely proud to be able to support the Dart ecosystem with this first (non-official) implementation of public and private Dart packages.
You can find further, context-specific information, including detailed setup and integration instructions inside each Cloudsmith repository. You can see an example of this documentation in our public examples repository.