-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make packages usable locally (#984)
- Loading branch information
Showing
70 changed files
with
778 additions
and
890 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
"@fuel-ts/abi-coder": minor | ||
"@fuel-ts/abi-typegen": minor | ||
"@fuel-ts/address": minor | ||
"@fuel-ts/contract": minor | ||
"forc-bin": minor | ||
"fuels": minor | ||
"@fuel-ts/hasher": minor | ||
"@fuel-ts/hdwallet": minor | ||
"@fuel-ts/interfaces": minor | ||
"@fuel-ts/keystore": minor | ||
"@fuel-ts/math": minor | ||
"@fuel-ts/merkle": minor | ||
"@fuel-ts/merkle-shared": minor | ||
"@fuel-ts/merklesum": minor | ||
"@fuel-ts/mnemonic": minor | ||
"@fuel-ts/predicate": minor | ||
"@fuel-ts/program": minor | ||
"@fuel-ts/providers": minor | ||
"@fuel-ts/script": minor | ||
"@fuel-ts/signer": minor | ||
"@fuel-ts/sparsemerkle": minor | ||
"@fuel-ts/transactions": minor | ||
"@fuel-ts/versions": minor | ||
"@fuel-ts/wallet": minor | ||
"@fuel-ts/wallet-manager": minor | ||
"@fuel-ts/wordlists": minor | ||
--- | ||
|
||
Revamping all packages configs, enabling local installation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
## π Contributing To Fuel TypeScript SDK | ||
# Contributing To Fuel TypeScript SDK | ||
|
||
Thanks for your interest in contributing to the Fuel TypeScript SDK! This document outlines the process for installing dependencies, setting up for development, and conventions for contributing. | ||
Thanks for your interest in contributing to the Fuel TypeScript SDK! | ||
|
||
## Finding Something to Work On | ||
This document outlines the process for installing dependencies, setting up for development and conventions for contributing. | ||
|
||
# Finding Something to Work On | ||
|
||
There are many ways in which you may contribute to the project, some of which involve coding knowledge and some which do not. A few examples include: | ||
|
||
|
@@ -14,7 +16,7 @@ Check out our [Help Wanted](https://github.com/FuelLabs/fuels-ts/issues?q=is%3Ao | |
|
||
If you are planning something big, for example, changes related to multiple components or changes to current behaviors, make sure to [open an issue](https://github.com/FuelLabs/fuels-ts/issues/new) to discuss with us before starting on the implementation. | ||
|
||
### Setup | ||
# Setting up | ||
|
||
```sh | ||
git clone [email protected]:FuelLabs/fuels-ts.git | ||
|
@@ -23,9 +25,76 @@ pnpm install | |
pnpm build | ||
``` | ||
|
||
## Testing | ||
# Developing | ||
|
||
For building everything in watch-mode, run: | ||
|
||
```sh | ||
# build all projects in watch-mode | ||
pnpm dev | ||
``` | ||
|
||
File watching is done by `nodemon` for increased performance. | ||
|
||
Check `nodemon.config.json` for all settings. | ||
|
||
> **Note**: You can `pnpm dev` a single package: | ||
> | ||
> ```sh | ||
> cd packages/abi-coder | ||
> pnpm dev | ||
> ``` | ||
# Using local sym-linked packages | ||
First, we need to link our `fuels` package globally in our local `global pnpm store`: | ||
```sh | ||
cd fuels-ts/packages/fuels | ||
pnpm link --global | ||
``` | ||
Let's check it out: | ||
|
||
```sh | ||
pnpm list --global | ||
``` | ||
|
||
Cool, now on the root directory of `my-local-project`: | ||
|
||
```sh | ||
cd my-local-project | ||
pnpm link --global fuels | ||
``` | ||
|
||
That's it β `my-local-project` is now using our local version of `fuels`. | ||
|
||
The same can be done with all other packages: | ||
|
||
```sh | ||
cd fuels-ts/packages/wallet | ||
pnpm link --global | ||
|
||
# ... | ||
|
||
pnpm list --global # validating | ||
|
||
# ... | ||
|
||
cd my-local-project | ||
pnpm link --global @fuel-ts/wallet | ||
``` | ||
|
||
> **Warning** When using local symlinked `fuels-ts` in `your-local-project`, remember to `pnpm build` the SDK whenever you change a source file to reflect the changes on `your-local-project`. To automate this, you can use `pnpm dev`, which will keep watching and compiling everything automatically while developing. | ||
See also: | ||
|
||
- [Developing](#Developing) | ||
|
||
# Testing | ||
|
||
In order to run tests locally, you need `fuel-core` running as a docker container. | ||
|
||
To do that run this command in your terminal: | ||
|
||
```sh | ||
|
@@ -37,10 +106,15 @@ And then run the tests in another terminal tab: | |
```sh | ||
# run all tests | ||
pnpm test | ||
# run tests and get coverage | ||
pnpm test -- --coverage | ||
|
||
# run tests while passing other flags to sub-program | ||
pnpm test -- --coverage --my-other-flag | ||
|
||
# run tests for a specific package | ||
pnpm --filter @fuel-ts/contract run test | ||
pnpm test packages/my-desired-package | ||
|
||
# run tests for a specific file | ||
pnpm test packages/my-desired-package/src/my.test.ts | ||
``` | ||
|
||
Or if you want to run docker and all tests serially you can do: | ||
|
@@ -51,10 +125,10 @@ pnpm ci:test | |
|
||
This will run `services:run`, `test` and then `services:clean` | ||
|
||
> The tests may break if you are running your tests locally using`services:run` in a separate terminal. | ||
> The tests may break if you are running your tests locally using `services:run` in a separate terminal. | ||
> To fix this run `services:clean` to clean docker containers and volumes. | ||
## Commit Convention | ||
# Commit Convention | ||
|
||
Before you create a Pull Request, please check whether your commits comply with | ||
the commit conventions used in this repository. | ||
|
@@ -79,7 +153,7 @@ the following categories: | |
- `chore`: all changes to the repository that do not fit into any of the above | ||
categories | ||
|
||
## Steps to PR | ||
# Steps to PR | ||
|
||
1. Fork the fuels-ts repository and clone your fork | ||
|
||
|
@@ -100,74 +174,39 @@ the following categories: | |
> `pnpm changeset add --empty` to generate an empty changeset file to document | ||
> your changes. | ||
## Git Hooks | ||
# Git Hooks | ||
|
||
The SDK utilizes a pre-push git hook to validate your contribution before review. This is a script that will run automatically before changes are pushed to the remote repository. Within the SDK, the pre-push script will run code linting. | ||
|
||
> This can be overridden using the `--no-verify` flag when pushing. | ||
## Build and watch all packages | ||
|
||
If you want to work locally using realtime builds, open in one terminal tab build in watch mode | ||
on all packages from the root directory: | ||
|
||
```sh | ||
pnpm build:watch | ||
``` | ||
|
||
This command will run `tsup --watch` on all packages using Turborepo | ||
|
||
## Using linked packages | ||
|
||
This will link all packages inside our monorepo in your `global pnpm store`, enabling you to use `fuels-ts` packages via links in | ||
your local projects. | ||
|
||
### On `fuels-ts` root directory | ||
|
||
```sh | ||
pnpm -r exec pnpm link --global --dir ./ | ||
``` | ||
|
||
You can use [build watch](#build-and-watch-all-packages). | ||
|
||
### On `your project` root directory | ||
|
||
```sh | ||
pnpm link --global fuels | ||
``` | ||
# Updating Forc version | ||
|
||
Or for specfic packages just use `pnpm link @fuel-ts/<pkg-name>`, ex; | ||
The following script will upgrade Forc to the latest version on GitHub, remove all lockfiles so the latest stdlib can be used, and rebuild all projects: | ||
|
||
```sh | ||
pnpm link --global @fuel-ts/wallet | ||
pnpm forc:update | ||
``` | ||
|
||
### Troubleshooting | ||
|
||
If you're linking for the first time, you might need: | ||
After this you should run tests and fix any incompatibilities. | ||
|
||
```sh | ||
pnpm setup | ||
``` | ||
# Updating Fuel Core version | ||
|
||
If it still have problems, you might need to setup again (As `pnpm` releases new version, the global folder structure may change) | ||
Manually edit the `.docker/fuel-core/Dockerfile` file, add the right version, and then: | ||
|
||
```sh | ||
pnpm setup | ||
pnpm services:clean # causes rebuilding of the Docker image | ||
pnpm test:ci | ||
``` | ||
|
||
## Updating Forc version | ||
If all tests pass, that's it. | ||
|
||
The following script will upgrade Forc to the latest version on GitHub, remove all lockfiles so the latest stdlib can be used, and rebuild all projects: | ||
Otherwise, you have work to do. | ||
|
||
```sh | ||
pnpm forc:update | ||
``` | ||
|
||
After this you should run tests and fix any incompatibilities. | ||
|
||
## FAQ | ||
# FAQ | ||
|
||
### Why is the prefix `fuels` and not `fuel`? | ||
|
||
In order to make the SDK for Fuel feel familiar with those coming from the [ethers.js](https://github.com/ethers-io/ethers.js) ecosystem, this project opted for an `s` at the end. The `fuels-*` family of SDKs is inspired by The Ethers Project. | ||
In order to make the SDK for Fuel feel familiar with those coming from the [ethers.js](https://github.com/ethers-io/ethers.js) ecosystem, this project opted for an `s` at the end. | ||
|
||
The `fuels-*` family of SDKs is inspired by The Ethers Project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.