Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial documentation for dart pub unpack #5775

Merged
merged 8 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/_includes/pub-subcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
* [`publish`](/tools/pub/cmd/pub-lish)
* [`remove`](/tools/pub/cmd/pub-remove)
* [`token`](/tools/pub/cmd/pub-token)
* [`upgrade`](/tools/pub/cmd/pub-upgrade)
* [`unpack`](/tools/pub/cmd/pub-unpack)
* [`upgrade`](/tools/pub/cmd/pub-upgrade)
2 changes: 1 addition & 1 deletion src/content/tools/pub/cmd/pub-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `dart pub token` subcommand has three subcommands:
[`add`][], [`list`][] and [`remove`][].

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

[`add`]: #add-a-new-credential
[`list`]: #return-a-list-of-credentials
Expand Down
80 changes: 80 additions & 0 deletions src/content/tools/pub/cmd/pub-unpack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: dart pub unpack
description: Downloads a package and unpacks its contents in place.
---

:::version-note
The `unpack` subcommand was introduced in Dart 3.4.
To download the archive of a package with an earlier SDK,
visit the **Versions** tab of a package on the [pub.dev site]({{site.pub}}).
:::

_Unpack_ is one of the commands of the [pub tool](/tools/pub/cmd).

```plaintext
$ dart pub unpack <package>[:descriptor] [--[no-]resolve] [--output=<output directory>] [--[no-]force] [other options]
```

This command downloads the specified `<package>` and
extracts its contents to a `<package>-<version>` directory.

For example, the following command downloads and extracts the
latest stable version of `package:http` from the [pub.dev site]({{site.pub}}),
to the current directory:

```console
$ dart pub unpack http
```

To change the source or version of the downloaded package,
add a source descriptor after the package name and a colon.
For example, the following command downloads the `1.2.0` release
of `package:http` from the pub.dev site:

```console
$ dart pub unpack http:1.2.0
```

The source descriptor supports more configuration
with the same syntax as `dart pub add`.
To learn more about source descriptors and their syntax, check out
the [source descriptor][] documentation for `dart pub add`.

[source descriptor]: /tools/pub/cmd/pub-add#source-descriptor

## Options

For options that apply to all pub commands, check out
[Global options](/tools/pub/cmd#global-options).

### `--force` or `-f` {:#force-option}

Overwrite existing folders that conflict
with the package folder or its contents during extraction.

### `--[no-]resolve` {:#resolve-option}

By default, `dart pub get` runs automatically to complete
package resolution after downloading and unpacking a package.
To disable automatic resolution,
specify the `--no-resolve` flag:

```console
$ dart pub unpack http --no-resolve
```

### `--output=<dir>` or `-o <dir>` {:#output-option}

By default, extract the package to the current directory (`.`).
To change the directory the package is extracted to,
specify the desired output directory with the `--output` option.

For example, the following commands unpacks the
`1.2.0` release of `package:http` to the `local_http_copies` directory.

```console
$ dart pub unpack http:1.2.0 -o local_http_copies
```


{% render 'pub-problems.md' %}