Skip to content

Commit da4f0e9

Browse files
Initial documentation for dart pub unpack (#5775)
Resolves #5695 --------- Co-authored-by: Marya <111139605+MaryaBelanger@users.noreply.github.com>
1 parent 50c7e76 commit da4f0e9

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

src/_includes/pub-subcommands.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
* [`publish`](/tools/pub/cmd/pub-lish)
99
* [`remove`](/tools/pub/cmd/pub-remove)
1010
* [`token`](/tools/pub/cmd/pub-token)
11-
* [`upgrade`](/tools/pub/cmd/pub-upgrade)
11+
* [`unpack`](/tools/pub/cmd/pub-unpack)
12+
* [`upgrade`](/tools/pub/cmd/pub-upgrade)

src/content/tools/pub/cmd/pub-token.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `dart pub token` subcommand has three subcommands:
1212
[`add`][], [`list`][] and [`remove`][].
1313

1414
The `dart pub` command considers the terms _credential_, _token_, _secret_,
15-
and _secret token_ to be interchangable.
15+
and _secret token_ to be interchangeable.
1616

1717
[`add`]: #add-a-new-credential
1818
[`list`]: #return-a-list-of-credentials
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: dart pub unpack
3+
description: Downloads a package and unpacks its contents in place.
4+
---
5+
6+
:::version-note
7+
The `unpack` subcommand was introduced in Dart 3.4.
8+
To download the archive of a package with an earlier SDK,
9+
visit the **Versions** tab of a package on the [pub.dev site]({{site.pub}}).
10+
:::
11+
12+
_Unpack_ is one of the commands of the [pub tool](/tools/pub/cmd).
13+
14+
```plaintext
15+
$ dart pub unpack <package>[:descriptor] [--[no-]resolve] [--output=<output directory>] [--[no-]force] [other options]
16+
```
17+
18+
This command downloads the specified `<package>` and
19+
extracts its contents to a `<package>-<version>` directory.
20+
21+
For example, the following command downloads and extracts the
22+
latest stable version of `package:http` from the [pub.dev site]({{site.pub}}),
23+
to the current directory:
24+
25+
```console
26+
$ dart pub unpack http
27+
```
28+
29+
To change the source or version of the downloaded package,
30+
add a source descriptor after the package name and a colon.
31+
For example, the following command downloads the `1.2.0` release
32+
of `package:http` from the pub.dev site:
33+
34+
```console
35+
$ dart pub unpack http:1.2.0
36+
```
37+
38+
The source descriptor supports more configuration
39+
with the same syntax as `dart pub add`.
40+
To learn more about source descriptors and their syntax, check out
41+
the [source descriptor][] documentation for `dart pub add`.
42+
43+
[source descriptor]: /tools/pub/cmd/pub-add#source-descriptor
44+
45+
## Options
46+
47+
For options that apply to all pub commands, check out
48+
[Global options](/tools/pub/cmd#global-options).
49+
50+
### `--force` or `-f` {:#force-option}
51+
52+
Overwrite existing folders that conflict
53+
with the package folder or its contents during extraction.
54+
55+
### `--[no-]resolve` {:#resolve-option}
56+
57+
By default, `dart pub get` runs automatically to complete
58+
package resolution after downloading and unpacking a package.
59+
To disable automatic resolution,
60+
specify the `--no-resolve` flag:
61+
62+
```console
63+
$ dart pub unpack http --no-resolve
64+
```
65+
66+
### `--output=<dir>` or `-o <dir>` {:#output-option}
67+
68+
By default, extract the package to the current directory (`.`).
69+
To change the directory the package is extracted to,
70+
specify the desired output directory with the `--output` option.
71+
72+
For example, the following commands unpacks the
73+
`1.2.0` release of `package:http` to the `local_http_copies` directory.
74+
75+
```console
76+
$ dart pub unpack http:1.2.0 -o local_http_copies
77+
```
78+
79+
80+
{% render 'pub-problems.md' %}

0 commit comments

Comments
 (0)