Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-30 13:56:09 +01:00
forgejo/docs/content/usage/packages/pub.zh-cn.md
John Olheiser bd4c7ce578
Docusaurus-ify (#26051)
This PR cleans up the docs in a way to make them simpler to ingest by
our [docs repo](https://gitea.com/gitea/gitea-docusaurus).

1. It includes all of the sed invocations our ingestion did, removing
the need to do it at build time.
2. It replaces the shortcode variable replacement method with
`@variable@` style, simply for easier sed invocations when required.
3. It removes unused files and moves the docs up a level as cleanup.

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-07-26 04:53:13 +00:00

81 lines
2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
date: "2022-07-31T00:00:00+00:00"
title: "Pub 软件包注册表"
slug: "pub"
sidebar_position: 90
draft: false
toc: false
menu:
sidebar:
parent: "packages"
name: "Pub"
sidebar_position: 90
identifier: "pub"
---
# Pub 软件包注册表
为您的用户或组织发布 [Pub](https://dart.dev/guides/packages) 软件包。
## 要求
要使用Pub软件包注册表您需要使用 [dart](https://dart.dev/tools/dart-tool) 和/或 [flutter](https://docs.flutter.dev/reference/flutter-cli). 工具。
以下示例使用 `dart`
## 配置软件包注册表
要注册软件包注册表并提供凭据,请执行以下操作:
```shell
dart pub token add https://gitea.example.com/api/packages/{owner}/pub
```
| 占位符 | 描述 |
| ------- | -------------- |
| `owner` | 软件包的所有者 |
您需要提供您的[个人访问令牌](development/api-usage.md#通过-api-认证)。
## 发布软件包
要发布软件包,请编辑 `pubspec.yaml` 文件,并添加以下行:
```yaml
publish_to: https://gitea.example.com/api/packages/{owner}/pub
```
| 占位符 | 描述 |
| ------- | -------------- |
| `owner` | 软件包的所有者 |
现在,您可以通过运行以下命令来发布软件包:
```shell
dart pub publish
```
如果已存在具有相同名称和版本的软件包,则无法发布软件包。您必须先删除现有的软件包。
## 安装软件包
要从软件包注册表安装Pub软件包请执行以下命令
```shell
dart pub add {package_name} --hosted-url=https://gitea.example.com/api/packages/{owner}/pub/
```
| 参数 | 描述 |
| -------------- | -------------- |
| `owner` | 软件包的所有者 |
| `package_name` | 软件包名称 |
例如:
```shell
# use latest version
dart pub add mypackage --hosted-url=https://gitea.example.com/api/packages/testuser/pub/
# specify version
dart pub add mypackage:1.0.8 --hosted-url=https://gitea.example.com/api/packages/testuser/pub/
```