| OLD | NEW |
| (Empty) |
| 1 --- | |
| 2 title: "Command: Publish" | |
| 3 --- | |
| 4 | |
| 5 $ pub publish [--dry-run] [--force] [--server <url>] | |
| 6 | |
| 7 This command publishes your package on | |
| 8 [pub.dartlang.org](http://pub.dartlang.org) for anyone to download and depend | |
| 9 on. For example, if your package is named transmogrify, it will be listed on | |
| 10 `http://pub.dartlang.org/packages/transmogify`, and users can depend on it in | |
| 11 their pubspecs and get it via [pub get](pub-get.html) using something | |
| 12 like: | |
| 13 | |
| 14 {% highlight dart %} | |
| 15 dependencies: | |
| 16 transmogrify: ">= 1.0.0 < 2.0.0" | |
| 17 {% endhighlight %} | |
| 18 | |
| 19 When publishing a package, it's important to follow the [pubspec | |
| 20 format](pubspec.html) and [package layout conventions](package-layout.html). | |
| 21 Some of these are required in order for others to be able to use your package. | |
| 22 Others are suggestions to help make it easier for users to understand and work | |
| 23 with your package. In both cases, pub will try to help you by pointing out what | |
| 24 changes will help make your package play nicer with the Dart ecosystem. There | |
| 25 are a few additional requirements for uploading a package: | |
| 26 | |
| 27 * You must include a license file (named `LICENSE`, `COPYING`, or some | |
| 28 variation) that contains an [open-source license](http://opensource.org/). We | |
| 29 recommend the [BSD license](http://opensource.org/licenses/BSD-2-Clause), | |
| 30 which is used by Dart itself. You must also have the legal right to | |
| 31 redistribute anything that you upload as part of your package. | |
| 32 | |
| 33 * Your package must be less than ten megabytes large after gzip compression. If | |
| 34 it's too large, consider splitting it into multiple packages, or cutting down | |
| 35 on the number of included resources or examples. | |
| 36 | |
| 37 * Your package should only have hosted dependencies. Git dependencies are | |
| 38 allowed but strongly discouraged; not everyone using Dart has Git installed, | |
| 39 and Git dependencies don't support version resolution as well as hosted | |
| 40 dependencies do. | |
| 41 | |
| 42 Be aware that the email address associated with your Google account will be | |
| 43 displayed on [pub.dartlang.org](http://pub.dartlang.org) along with any packages | |
| 44 you upload. | |
| 45 | |
| 46 ## What files are published? | |
| 47 | |
| 48 **All files** in your package will be included in the published package, with | |
| 49 the following exceptions: | |
| 50 | |
| 51 * Any `packages` directories. | |
| 52 * Your package's [lockfile](glossary.html#lockfile). | |
| 53 * If you're using Git, any files ignored by your `.gitignore` file. | |
| 54 * If you aren't using Git, all "hidden" files (that is, files whose names begin | |
| 55 with `.`). | |
| 56 | |
| 57 If there are other files you don't want to include, be sure to delete them (or | |
| 58 add them to `.gitignore`) before running `pub publish`. | |
| 59 | |
| 60 To be on the safe side, `pub publish` will list all files it's going to publish | |
| 61 for you to look over before it actually uploads your package. | |
| 62 | |
| 63 ## Options | |
| 64 | |
| 65 ### `--dry-run` or `-n` | |
| 66 | |
| 67 With this, pub goes through the validation process but does not actually upload | |
| 68 the package. This is useful if you want to see if your package meets all of the | |
| 69 publishing requirements before you're ready to actually go public. | |
| 70 | |
| 71 ### `--force` or `-f` | |
| 72 | |
| 73 With this, pub does not ask for confirmation before publishing. Normally, it | |
| 74 shows you the package contents and asks for you to confirm the upload. | |
| 75 | |
| 76 If there are any errors in your package, it is not uploaded and this exits with | |
| 77 an error. If there are warnings, it *will* be uploaded. If you want to ensure | |
| 78 your package has no warnings before uploading, either don't use `--force`, or | |
| 79 use `--dry-run` first. | |
| 80 | |
| 81 ### `--server` | |
| 82 | |
| 83 If you pass `--server` followed by a URL, it will attempt to publish the | |
| 84 package to that server. It assumes the server supports the same HTTP API that | |
| 85 [pub.dartlang.org][pubsite] uses. | |
| 86 | |
| 87 This can be useful if you're running your own local package server for testing. | |
| 88 The main pub server is itself open source and available [here][pub repo]. | |
| 89 | |
| 90 [pubsite]: http://pub.dartlang.org | |
| 91 [pub repo]: https://github.com/dart-lang/pub-dartlang | |
| OLD | NEW |