Skip to content

Commit

Permalink
feat: monorepo conversion (#42)
Browse files Browse the repository at this point in the history
Description
---

In order to support both browser and nodejs environments we need to
allow users to choose which packages to import.
The first step along that road is to structure the project as a monorepo
of multiple packages.
At this time all the packages are required for tarijs, however in the
future these requirements will be eliminated and instead passed as
parameters based on which provider package is installed.

How Has This Been Tested?
---
Building the project


What process can a PR reviewer use to test or verify this change?
---
after installing proto run 
`moon tarijs:build` then navigate to packages/tarijs directory. you
should have the build output in dist subdirectory. You should also run
the integration tests


<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->

---------

Co-authored-by: Martins Erts <[email protected]>
  • Loading branch information
a-h-i and martinserts authored Feb 11, 2025
1 parent 41464bd commit 4bf9cba
Show file tree
Hide file tree
Showing 104 changed files with 5,045 additions and 4,868 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: 'moonrepo/setup-toolchain@v0'
with:
node-version: "20"
- run: npm ci
- run: npm run build
auto-install: true
- run: pnpm install
- run: moon :build
15 changes: 7 additions & 8 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: 'moonrepo/setup-toolchain@v0'
with:
node-version: "20"
- run: npm ci
- run: npm run build
- uses: JS-DevTools/npm-publish@v3
auto-install: true
- run: pnpm install
- run: moon :build
- uses: simenandre/publish-with-pnpm@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: 'public'

npm-auth-token: ${{ secrets.NPM_TOKEN }}

16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
node_modules
.pnp
.pnp.js

# testing
/coverage
coverage

# production
/build
/dist
build
dist

# misc
.DS_Store
Expand All @@ -25,4 +25,8 @@ yarn-error.log*

# Editor directories and files
.idea/
.vscode
.vscode
# moon
.moon/cache
.moon/docker
*.tsbuildinfo
6 changes: 6 additions & 0 deletions .moon/toolchain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Enable Node.js and override default settings
language: 'typescript'
node:
packageManager: 'pnpm'
typescript:
syncProjectReferences: true
32 changes: 32 additions & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://moonrepo.dev/docs/config/workspace
$schema: 'https://moonrepo.dev/schemas/workspace.json'

# Require a specific version of moon while running commands, otherwise fail.
# versionConstraint: '>=1.0.0'

# Extend and inherit an external configuration file. Must be a valid HTTPS URL or file system path.
# extends: './shared/workspace.yml'

# REQUIRED: A map of all projects found within the workspace, or a list or file system globs.
# When using a map, each entry requires a unique project ID as the map key, and a file system
# path to the project folder as the map value. File paths are relative from the workspace root,
# and cannot reference projects located outside the workspace boundary.
projects:
- 'apps/*'
- 'packages/*'



# Configures the version control system to utilize within the workspace. A VCS
# is required for determining touched (added, modified, etc) files, calculating file hashes,
# computing affected files, and much more.
vcs:
# The client to use when managing the repository.
# Accepts "git". Defaults to "git".
manager: 'git'

# The default branch (master/main/trunk) in the repository for comparing the
# local branch against. For git, this is is typically "master" or "main",
# and must include the remote prefix (before /).
defaultBranch: 'main'

9 changes: 9 additions & 0 deletions .prototools
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
moon = "1.31.0"
node = "22.13.1"
pnpm = "9.15.3"

[plugins]
moon = "https://raw.githubusercontent.com/moonrepo/moon/master/proto-plugin.toml"

[settings]
auto-install = true
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Please read the [TODO](TODO.md) file for upcoming features.
You must have the [tari-dan](https://github.com/tari-project/tari-dan) repo cloned at the same folder level as this repo.

To build the library:
First you must install [proto](https://moonrepo.dev/proto) to manage node and pnpm versions
```shell
npm install
npm run build
proto use
pnpm install
moon tarijs:build
```

The bundled files for deployment or publication will be located under the `dist` folder.
Expand All @@ -29,18 +31,17 @@ To run the example site you will need to:
* Have access to a Tari Wallet Daemon and to the Tari MetaMask Snap.
* Copy the `example/.env.example` file to `example/.env` and edit the correct environment variable values.

To run in development mode:
To run in development mode, in the packages/tarijs folder:
```shell
cd example
npm install
npm run dev
moon tarijs:build
pnpm run dev
```

For building and distribution
For building and distribution, in the packages/tarijs folder
```shell
cd example
npm install
npm run build
moon tarijs:build
```
The distribution files will be under the `example/dist` folder.

Loading

0 comments on commit 4bf9cba

Please sign in to comment.