Package | Status | Description |
---|---|---|
@synthetixio/contracts-interface |
Synthetix contracts interface | |
@synthetixio/queries |
React library for querying data | |
@synthetixio/providers |
Synthetix providers for layer 1 and 2 | |
@synthetixio/optimism-networks |
Network utility for layer 2 | |
@synthetixio/codegen-graph-ts |
Query generator | |
@synthetixio/safe-import |
Async imports with retry |
This repo uses Yarn workspaces to manage multiple packages in the same repo. To prepare the repository for use, run:
yarn install
This will install all dependencies, wire dependencies between packages in this repo, and allow for you to build projects.
If you make a change and want to generate the library JS code, run:
yarn build
This will ensure all projects are fully built in topological order. You are also free to run script commands from individual repositories if necessary or desired.
Monorepo is now switched to independent versioning so each package inside monorepo can have its own version independently of all others
We have a GitHub workflow for publishing releases.
To publish:
- Go here https://github.com/Synthetixio/js-monorepo/actions/workflows/updateDependency.yml
- Click Run Workflow
- Fill
synthetix_version
in a format of1.2.3
for the version - Run the workflow
This will upgrade synthetix
in the monorepo and all affected packages will be published with new patch
release
For example now only the @synthetixio/contracts-interface
package depends on synthetix
, so it will get new patch
version. But then all the packages that depend on it will get new patch
version in a cascade (check full list of cascade updates with yarn deps:version
). So overall these packages will be published:
@synthetixio/contracts-interface
@synthetixio/providers
@synthetixio/queries
We have a GitHub workflow for publishing package releases.
To publish:
- Go here https://github.com/Synthetixio/js-monorepo/actions/workflows/publishSinglePackage.yml
- Click Run Workflow
- Fill
package
in a format of@synthetixio/wei
for the package name - Fill
version
in a format of1.2.3
(orpatch
,minor
,major
) for the package version (optional, default value ispatch
) - Run the workflow
NOTE: All the packages that depend on package
will be published with patch
version automatically.
For example when publishing @synthetixio/wei
these packages will get updates (check with yarn deps:version
):
@synthetixio/wei
@synthetixio/codegen-graph-ts
@synthetixio/queries
When you open a PR a dev package will be published automatically when CI passes. The version will be 0.0.0-<git short sha>
Yarn workspaces are specially designed to handle package updates. If you want to push a new release for one or more packages in this repo, run:
- Firstly set desired versions to updated packages:
yarn version check --interactive
- Then apply new versions
yarn apply --all
- Commit changes
- And now we can publish all the updated packages
yarn workspaces foreach --no-private npm publish --tolerate-republish
- Yarn will automatically replace all the
workspace:*
versions with appropriate semver on publish.
This is 3-step process:
- Prepare original repo
- Add remote to monorepo
- Merge original repo branch and update build to match monorepo processes
Using codegen-graph-ts
as an example
-
Create a separate branch
move-to-monorepo
-
Create the intended destination folder inside monorepo
mkdir -p tools/codegen-graph-ts
-
Move all the package files into
tools/codegen-graph-ts
-
Remove all the files that won't be used (CI config, lockfile, etc)
-
Commit looks like this:
cd ~/synthetix/js-monorepo
git remote add codegen-graph-ts ~/synthetix/codegen-graph-ts
git fetch --all
#
git merge codegen-graph-ts/move-to-monorepo --allow-unrelated-histories
Using --allow-unrelated-histories
allows merging independent git history
git merge codegen-graph-ts/move-to-monorepo --allow-unrelated-histories
Because we moved all the files into the separate folder we have no merge conflicts and at the same time we have full history added to the git tree
Now we can remove remote as it is no longer necessary and cleanup all the added tags too
git remote remove codegen-graph-ts
# Cleanup all local tags and re-fetch existing tags without just removed `codegen-graph-ts` remote
git tag -l | xargs git tag -d
git fetch --tags
To preserve all the merge commits when rebasing on top of updated master use --rebase-merges
git rebase master --rebase-merge
Interactive rebase works too
git rebase master --rebase-merge --interactive