Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to a monorepo #297

Merged
merged 22 commits into from
Oct 5, 2023
Merged

Conversation

piotr-roslaniec
Copy link
Contributor

@piotr-roslaniec piotr-roslaniec commented Sep 13, 2023

To Do
Consider moving to separate issues/PRs

Type of PR:

  • Refactor

Required reviews:

  • 3

What this does:

  • Creates a workspace for the monorepo structure with shared, pre, and taco packages
  • Configures pnpm as a package manager
  • Reworks linting, docs generating, and other utilities
  • Replaces jest with vitest
  • Deduplicates config files across the repo
  • Creates a ./packages/test-utils package to deduplicate tests across packages
  • Updates examples
  • Updated dependencies

Notes for reviewers:

  • How to review this PR
    • It's easier to view large line changes locally. GH is not going to handle rendering ~60k changes well.
    • The second commit 06f95ad is the largest because it moves a lot of code. You may want to view it separately. Other commits are more self-contained.
    • This PR fixed some issues and documented a lot of other issues. See the To Do section above and consider our priorities. Which of these items should we solve before releasing the monorepo packages? Are there any other issues not covered there?
    • Consider developer experience when working with monorepo. Would you be able to contribute to this repository on the first go? If not, why? Is there anything we could do to lower the barrier to entry?
    • Consider the structure of packages, taco, pre, and shared
  • The test-utils package is not meant to be published. pre and taco will be published. Consider publishing a shared package. Package naming TBD.
  • Previous monorepo PR Migrate to a monorepo #294 was closed due to a rebase
  • Currently, ./examples are using @nucypher/shared. Ideally, they would be using pre and taco where appropriate. We need to figure out the structure of pre package before migrating them, and we need to add taco usage examples.

packages/taco/LICENSE Show resolved Hide resolved
packages/taco/package.json Outdated Show resolved Hide resolved
packages/shared/package.json Outdated Show resolved Hide resolved
import * as base from './base';
import * as predefined from './predefined';

export { predefined, base };
// TODO: Or do we want to export everything from the base and predefined modules?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate a bit on this? WDYM with structured exports vs export everything from the base?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we're exporting everything in a shared namespace:

import * as base from './base';
import * as predefined from './predefined';

So everything ends up being available in the project root module:

import {Condition, ERC721Ownership} from "@nucypher/shared";

Previously, we used named module exports:

export { predefined, base };

And used them like so:

import {based, predefined} from "@nucypher/shared";
// use base.Condition, predefined.ERC721Ownership

We could use both. Not sure yet - I need to sort out contents of pre first.

examples/nodejs/src/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. I've left some minor suggestions

@codecov-commenter
Copy link

codecov-commenter commented Sep 15, 2023

Codecov Report

Merging #297 (142eb98) into monorepo (ca9e163) will decrease coverage by 16.15%.
The diff coverage is 90.63%.

@@              Coverage Diff              @@
##           monorepo     #297       +/-   ##
=============================================
- Coverage     81.38%   65.23%   -16.15%     
=============================================
  Files            37       48       +11     
  Lines          1069     5218     +4149     
  Branches        112       35       -77     
=============================================
+ Hits            870     3404     +2534     
- Misses          191     1808     +1617     
+ Partials          8        6        -2     
Files Coverage Δ
packages/shared/src/characters/index.ts 100.00% <100.00%> (ø)
packages/shared/src/conditions/base/contract.ts 95.74% <100.00%> (ø)
packages/shared/src/conditions/base/index.ts 100.00% <100.00%> (ø)
packages/shared/src/conditions/base/rpc.ts 100.00% <ø> (ø)
packages/shared/src/conditions/base/shared.ts 100.00% <ø> (ø)
packages/shared/src/conditions/base/time.ts 100.00% <ø> (ø)
...ckages/shared/src/conditions/compound-condition.ts 100.00% <100.00%> (ø)
packages/shared/src/conditions/condition.ts 68.18% <100.00%> (ø)
packages/shared/src/conditions/const.ts 100.00% <ø> (ø)
packages/shared/src/conditions/context/index.ts 100.00% <ø> (ø)
... and 38 more

Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✌️

@@ -0,0 +1,9 @@
root = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file supposed to be in the repo or maybe should it be ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to be in repo: https://editorconfig.org/

@@ -1,365 +0,0 @@
# Changelog
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with this changelog?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure how to transition from the old changelog to the new one. So far I figured that:

  • nucypher-ts package will be discontinued and superseded by taco, pre, etc. packages
  • We can make appropriate changes to changelog upon new package release
  • We could put the old changelog at the bottom of the old changelog
  • Or we could put it into CHANGELOG.old.md
  • Irregardless of the two above, we could explain this transition in the README.md

examples/README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,64 @@
import {Alice, Bob, getPorterUri, SecretKey, toBytes} from '@nucypher/shared';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a PRE example...I found confusing to find this here. It should be moved somewhere else and/or clearly marked in the filename/path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed these changes in another PR, #301

return <div>Loading...</div>;
}

const { Alice, Bob, EnactedPolicy, getPorterUri, SecretKey, toHexString } = nucypher;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

export * from './bob';
export * from './cbd-recipient';
export * from './enrico';
export * from './pre-recipient';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between bob and pre-recipient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bob is a vanilla PRE character, PreDecrypter from ./pre-recipient is a tdec-adapted Bob.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, well, we should deprecate PreDecryper as soon as possible, but I guess that's something that can wait after this PR.

Copy link
Contributor Author

@piotr-roslaniec piotr-roslaniec Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will deprecate the reminder of PRE-tDec - #303

@@ -0,0 +1,2145 @@
/* Autogenerated file. Do not edit manually. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When and how is this file autogenerated?

Copy link
Contributor Author

@piotr-roslaniec piotr-roslaniec Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated by typechain by postinstall and build npm scripts.

Copy link
Member

@KPrasch KPrasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a huge organizational effort!

While I cannot say that this is the final form of the repository and packaging manifests, as a whole you present a massively improved DX for both contributors and implementers and a division of logic that resolves technical debt. I need more experience using the demos and building TACo dapps before I can make any further API suggestions but I broadly agree with the internal tool choices you made here. To unblock further efforts this PR must be merged along with the follow-ups.

Your meticulous effort and focus on maintainability haven’t gone unnoticed. It’s a solid step forward in both code quality and efficiency. On this note, I’m greenlighting the merge. Thanks @piotr-roslaniec 👏🏻

@piotr-roslaniec piotr-roslaniec merged commit 9bcadf5 into nucypher:monorepo Oct 5, 2023
1 check passed
@piotr-roslaniec piotr-roslaniec deleted the monorepo branch October 5, 2023 08:07
@derekpierre derekpierre mentioned this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

5 participants