Skip to content

Commit eafd99e

Browse files
sdankelesdrubalJoshuaBattykayagokalp
authored
feat: Add forc-publish plugin (#6890)
## Description Closes #6889 Currently it only works when running locally, as the forc.pub server is not yet live. Allows users to publish a package by running `forc publish` in the root of the package directory. Workspaces not yet supported. It's intentionally not yet added to the release process (will be done in #6891) To test it locally, run the [forc.pub](https://github.com/FuelLabs/forc.pub/) server and web app locally (see that repo's README for more details). 1. Start DB ./scripts/start_local_db.sh 2. Start server cargo run 3. Start frontend cd app && npm start - opens localhost:3000 4. Get API token from local webapp -> Login with Github -> API Tokens -> Generate new token 5. Edit `std-lib-core/Forc.toml` and add a version key, i.e. `version = 0.1.0` 6. Run `forc publish` from this branch: FuelLabs/forc.pub#29 and you'll be prompted to enter the token. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Marcos Henrich <marcoshenrich@gmail.com> Co-authored-by: Joshua Batty <joshpbatty@gmail.com> Co-authored-by: Kaya Gökalp <kaya.gokalp@fuel.sh>
1 parent 0640dbe commit eafd99e

File tree

10 files changed

+908
-15
lines changed

10 files changed

+908
-15
lines changed

Cargo.lock

+115-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"forc-plugins/forc-fmt",
1111
"forc-plugins/forc-lsp",
1212
"forc-plugins/forc-migrate",
13+
"forc-plugins/forc-publish",
1314
"forc-plugins/forc-tx",
1415
"forc-test",
1516
"forc-tracing",
@@ -57,8 +58,9 @@ forc-debug = { path = "forc-plugins/forc-debug/", version = "0.66.7" }
5758
forc-doc = { path = "forc-plugins/forc-doc/", version = "0.66.7" }
5859
forc-fmt = { path = "forc-plugins/forc-fmt/", version = "0.66.7" }
5960
forc-lsp = { path = "forc-plugins/forc-lsp/", version = "0.66.7" }
60-
forc-tx = { path = "forc-plugins/forc-tx/", version = "0.66.7" }
6161
forc-migrate = { path = "forc-plugins/forc-migrate/", version = "0.66.7" }
62+
forc-publish = { path = "forc-plugins/forc-publish/", version = "0.66.7" }
63+
forc-tx = { path = "forc-plugins/forc-tx/", version = "0.66.7" }
6264

6365
sway-ast = { path = "sway-ast/", version = "0.66.7" }
6466
sway-core = { path = "sway-core/", version = "0.66.7" }
@@ -230,6 +232,7 @@ unicode-bidi = "0.3"
230232
unicode-xid = "0.2"
231233
url = "2.2"
232234
urlencoding = "2.1"
235+
uuid = "1.13"
233236
vec1 = "1.8"
234237
vte = "0.13"
235238
walkdir = "2.3"

forc-plugins/forc-publish/Cargo.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "forc-publish"
3+
version.workspace = true
4+
description = "Forc subcommand for uploading a package to the registry."
5+
authors.workspace = true
6+
edition.workspace = true
7+
homepage.workspace = true
8+
license.workspace = true
9+
repository.workspace = true
10+
11+
[dependencies]
12+
clap = { workspace = true, features = ["derive", "env"] }
13+
flate2.workspace = true
14+
forc-tracing.workspace = true
15+
forc-util.workspace = true
16+
reqwest = { workspace = true, features = ["json"] }
17+
semver = { workspace = true, features = ["serde"] }
18+
serde = { workspace = true, features = ["derive"] }
19+
serde_json.workspace = true
20+
tar.workspace = true
21+
tempfile.workspace = true
22+
thiserror.workspace = true
23+
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
24+
toml = { workspace = true, features = ["parse"] }
25+
tracing.workspace = true
26+
url.workspace = true
27+
uuid = { workspace = true, features = ["v4", "serde"] }
28+
walkdir.workspace = true
29+
30+
[dev-dependencies]
31+
wiremock = "0.6.2"

forc-plugins/forc-publish/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# forc-publish
2+
3+
Forc subcommand for uploading a package to the registry.
4+
5+
## Authentication
6+
7+
Requires either the `--token` argument to be passed, or a `~/.forc/credentials.toml` file like this:
8+
9+
```toml
10+
[registry]
11+
token = "YOUR_TOKEN"
12+
```
13+
14+
This credential file can be created automatically by running the CLI without the `--token` argument.
15+
16+
## Local development
17+
18+
For local development, run [forc.pub](https://github.com/FuelLabs/forc.pub), create an API token and then `forc publish --registry-url http://localhost:8080`

0 commit comments

Comments
 (0)