Skip to content

Commit

Permalink
Update Alexandria references to refer to new package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaput committed Aug 10, 2023
1 parent 9f5c5f2 commit c6883b3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions scarb/src/bin/scarb/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ pub struct AddArgs {
/// Reference to a package to add as a dependency
///
/// You can reference a package by:
/// - `<name>`, like `scarb add alexandria` (the latest version will be used)
/// - `<name>@<version-req>`, like `scarb add alexandria@1` or `scarb add alexandria@=0.1.0`
/// - `<name>`, like `scarb add alexandria_math` (the latest version will be used)
/// - `<name>@<version-req>`, like `scarb add alexandria_math@1` or `scarb add alexandria_math@=0.1.0`
#[arg(value_name = "DEP_ID", verbatim_doc_comment)]
pub packages: Vec<DepId>,

Expand Down
2 changes: 1 addition & 1 deletion website/.vitepress/components/home/Terminal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<p>scarb init --name hello_world</p>
<p>
scarb add alexandria --git
scarb add alexandria_math --git
<span class="br">
\<br />
&nbsp;&nbsp;&nbsp;&nbsp;
Expand Down
10 changes: 5 additions & 5 deletions website/docs/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ Add dependency hosted on a Git repository:

```toml
[dependencies]
alexandria = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
```

Add dependency located in local path:

```toml
[dependencies]
alexandria = { path = "../path-to-alexandria-checkout/alexandria" }
alexandria_math = { path = "../path-to-alexandria-checkout/alexandria" }
```

::: info
Expand All @@ -89,17 +89,17 @@ You can use `ssh://` URLs, Scarb uses local `git` installation for all network o
Add dependency hosted on a Git repository:

```shell
scarb add alexandria --git https://github.com/keep-starknet-strange/alexandria.git
scarb add alexandria_math --git https://github.com/keep-starknet-strange/alexandria.git
```

Add dependency located in local path:

```shell
scarb add alexandria --path ../path-to-alexandria-checkout/alexandria
scarb add alexandria_math --path ../path-to-alexandria-checkout/alexandria
```

::: info
You can specify package version like this: `alexandria@0.1.0`, but see remarks in previous section.
You can specify package version like this: `alexandria_math@0.1.0`, but see remarks in previous section.
:::

::: info
Expand Down
16 changes: 8 additions & 8 deletions website/docs/guides/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ approach. Therefore, we plan to create a proper package registry in long term.
If your `Scarb.toml` doesn't already have a `[dependencies]` section, add it, then list the package name and the URL to
its Git repository.
This example adds a dependency on the [`alexandria`](https://github.com/keep-starknet-strange/alexandria) package (note
that Alexandria is a collection of multiple packages, and we will use math as an example in this guide):
that Alexandria is a collection of multiple packages, and we will use `alexandria_math` as an example in this guide):

```toml
[dependencies]
alexandria = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
```

In fact, it is always good to pin Git dependencies to concrete commits, otherwise Scarb would try to update this
Expand All @@ -27,7 +27,7 @@ For example, in this guide we will pin to a concrete commit hash:

```toml
[dependencies]
alexandria = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "4a0afdc" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "27fbf5b" }
```

::: info
Expand All @@ -47,10 +47,10 @@ $ scarb build
Finished release target(s) in 4 seconds
```

You can now use the `alexandria` library in `src/lib.cairo`:
You can now use the `alexandria_math` package in `src/lib.cairo`:

```cairo
use alexandria::math::fibonacci;
use alexandria_math::fibonacci;
fn main() -> felt252 {
fibonacci::fib(0, 1, 10)
}
Expand All @@ -61,10 +61,10 @@ fn main() -> felt252 {
If you prefer, you can also ask Scarb to edit `Scarb.toml` to add a dependency automagically for you.
The `scarb add` command accepts many parameters, matching all possibilities of expressing dependencies.
It can also automatically keep the list sorted, if it already is.
For example, the above example of dependency on `alexandria`, can be also added like this:
For example, the above example of dependency on `alexandria_math`, can be also added like this:

```shell
scarb add alexandria --git https://github.com/keep-starknet-strange/alexandria.git --rev 4a0afdc
scarb add alexandria_math --git https://github.com/keep-starknet-strange/alexandria.git --rev 27fbf5b
```

## Removing a dependency
Expand All @@ -74,5 +74,5 @@ To remove a dependency, simply remove related lines from your `Scarb.toml`.
As a quick shortcut, the `scarb remove` (also available in short `scarb rm`) can clean the manifest automatically:

```shell
scarb rm alexandria
scarb rm alexandria_math
```
15 changes: 12 additions & 3 deletions website/docs/guides/working-on-an-existing-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ If you download an existing package that uses Scarb, it's really easy to get goi
First, get the package from somewhere.
For example, the [`alexandria`](https://github.com/keep-starknet-strange/alexandria) package is hosted on GitHub, and
we 'll clone its repository using Git.
Note that Alexandria is a collection of multiple packages, and we will use math as an example in this guide.
Note that Alexandria is a collection of multiple packages, and we will use `alexandria_math` as an example in this
guide.

```shell
git clone https://github.com/keep-starknet-strange/alexandria
Expand All @@ -17,8 +18,16 @@ Then to build it, use `scarb build`:

```shell
$ scarb build
Compiling alexandria v0.1.0 (/path/to/package/alexandria/math/Scarb.toml)
Finished release target(s) in 4 seconds
Compiling alexandria_ascii v0.1.0 (/path/to/package/alexandria/src/ascii/Scarb.toml)
Compiling alexandria_data_structures v0.1.0 (/path/to/package/alexandria/src/data_structures/Scarb.toml)
Compiling alexandria_encoding v0.1.0 (/path/to/package/alexandria/src/encoding/Scarb.toml)
Compiling alexandria_linalg v0.1.0 (/path/to/package/alexandria/src/linalg/Scarb.toml)
Compiling alexandria_math v0.2.0 (/path/to/package/alexandria/src/math/Scarb.toml)
Compiling alexandria_numeric v0.1.0 (/path/to/package/alexandria/src/numeric/Scarb.toml)
Compiling alexandria_searching v0.1.0 (/path/to/package/alexandria/src/searching/Scarb.toml)
Compiling alexandria_sorting v0.1.0 (/path/to/package/alexandria/src/sorting/Scarb.toml)
Compiling alexandria_storage v0.2.0 (/path/to/package/alexandria/src/storage/Scarb.toml)
Finished release target(s) in 5 seconds
```

This will fetch all the dependencies and then build them, along with the package.
4 changes: 2 additions & 2 deletions website/docs/reference/specifying-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository with the `git` key:

```toml
[dependencies]
alexandria = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
```

Scarb will fetch the `git` repository at this location and then look for a `Scarb.toml` for the requested package
Expand All @@ -23,7 +23,7 @@ Here is an example of specifying that you want to use the latest commit on a bra

```toml
[dependencies]
alexandria = { git = "https://github.com/keep-starknet-strange/alexandria.git", branch = "next" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", branch = "next" }
```

Anything that is not a branch or tag falls under `rev`.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/reference/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Example:
members = ["foo", "bar"]

[workspace.dependencies]
alexandria = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", branch = "cairo-2" }
```

Expand All @@ -155,7 +155,7 @@ name = "foo"
version = "0.2.0"

[dependencies]
alexandria.workspace = true
alexandria_math.workspace = true
```

```toml [bar/Scarb.toml]
Expand Down

0 comments on commit c6883b3

Please sign in to comment.