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