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

Setup NPM workspaces #199

Merged
merged 33 commits into from
Jan 12, 2024
Merged

Setup NPM workspaces #199

merged 33 commits into from
Jan 12, 2024

Conversation

akshay-ap
Copy link
Member

@akshay-ap akshay-ap commented Jan 8, 2024

Fixes #146

Summary: This PR proposes use of NPM workspaces which will work as a monorepo where the packages (Safe modules)
would be stored in modules directory. The root package.json of the project should store all the shared dependencies (code formatting, linting, and possibly typescript version as well).

Changes in PR:

  • Remove modules:

    • dutchx_seller
    • recurring_transfers
  • Move below modules to modules/ directory which is marked as a workspaces directory in root package.json

    • allowances
    • 4337
    • 4337-gas-metering (though this is not another module). Perhaps this directory should be in packages/ directory?
  • The root package.json contains dependencies related to code formatting and linting (eslint and prettier) instead of each of the package having individual configurations and dependency versions

  • Changes in allowances modules:

    • Uses Safe contracts 1.4.1 version
  • Changes in github workflow files:

    • Update working directory
    • Update paths wherever required for the workflow to pass
    • Update npm commands in each workflow file to consider appropriate workspace
  • Update README.md:

    • Remove references to dutchx_seller module
    • Update paths of existing modules

@akshay-ap akshay-ap self-assigned this Jan 8, 2024
@akshay-ap akshay-ap requested a review from a team as a code owner January 8, 2024 10:46
@akshay-ap akshay-ap requested review from rmeissner, nlordell, mmv08 and remedcu and removed request for a team January 8, 2024 10:46
@akshay-ap akshay-ap marked this pull request as draft January 8, 2024 10:46
@akshay-ap akshay-ap added the enhancement New feature or request label Jan 8, 2024
@coveralls
Copy link

coveralls commented Jan 10, 2024

Pull Request Test Coverage Report for Build 7503993801

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 85.093%

Totals Coverage Status
Change from base Build 7503869444: 0.0%
Covered Lines: 100
Relevant Lines: 107

💛 - Coveralls

@akshay-ap akshay-ap marked this pull request as ready for review January 11, 2024 16:39
@mmv08
Copy link
Member

mmv08 commented Jan 11, 2024

It looks like prettier-plugin-solidity isn't included in the root dependency list and is nested in one of the package's dependencies. Other than that, it looks good so far.

Copy link
Member

@mmv08 mmv08 left a comment

Choose a reason for hiding this comment

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

One bug I found: the fmt command defined globally doesn't respect the .prettierignore file of individual packages. I ran it, and it formatted the FCL files despite being explicitly ignored in the package.

It seems like it's a long-awaited feature: prettier/prettier#4081

For now, I'd suggest:

  1. Define the fmt command in each package that will take into account all the package-specific configuration
  2. Keep the global command for formatting everything but packages (markdown, GitHub actions, package.json, etc.)

@mmv08 mmv08 force-pushed the refactor-146-npm-workspaces branch from ca87668 to 7e477dc Compare January 11, 2024 17:37
@akshay-ap
Copy link
Member Author

One bug I found: the fmt command defined globally doesn't respect the .prettierignore file of individual packages. I ran it, and it formatted the FCL files despite being explicitly ignored in the package.

It seems like it's a long-awaited feature: prettier/prettier#4081

For now, I'd suggest:

  1. Define the fmt command in each package that will take into account all the package-specific configuration
  2. Keep the global command for formatting everything but packages (markdown, GitHub actions, package.json, etc.)

Here 1d03625.
Should we also setup a github workflow that verifies files in root directory other than packages/?

@akshay-ap akshay-ap requested a review from mmv08 January 12, 2024 09:54
@mmv08
Copy link
Member

mmv08 commented Jan 12, 2024

One bug I found: the fmt command defined globally doesn't respect the .prettierignore file of individual packages. I ran it, and it formatted the FCL files despite being explicitly ignored in the package.
It seems like it's a long-awaited feature: prettier/prettier#4081
For now, I'd suggest:

  1. Define the fmt command in each package that will take into account all the package-specific configuration
  2. Keep the global command for formatting everything but packages (markdown, GitHub actions, package.json, etc.)

Here 1d03625. Should we also setup a github workflow that verifies files in root directory other than packages/?

This doesn't check the formatting in packages (point 1 from my comment), does it?

@akshay-ap
Copy link
Member Author

akshay-ap commented Jan 12, 2024

One bug I found: the fmt command defined globally doesn't respect the .prettierignore file of individual packages. I ran it, and it formatted the FCL files despite being explicitly ignored in the package.
It seems like it's a long-awaited feature: prettier/prettier#4081
For now, I'd suggest:

  1. Define the fmt command in each package that will take into account all the package-specific configuration
  2. Keep the global command for formatting everything but packages (markdown, GitHub actions, package.json, etc.)

Here 1d03625. Should we also setup a github workflow that verifies files in root directory other than packages/?

This doesn't check the formatting in packages (point 1 from my comment), does it?

When npm ci is executed from root of the project, packages directory will be ignored in this commit.

Screenshot 2024-01-12 at 13 53 46

Each of the package already has its own fmt command so, package specific formatting can be done by specifying workspace name parameter e.g. npm run fmt -w modules/4337.

@mmv08
Copy link
Member

mmv08 commented Jan 12, 2024

One bug I found: the fmt command defined globally doesn't respect the .prettierignore file of individual packages. I ran it, and it formatted the FCL files despite being explicitly ignored in the package.
It seems like it's a long-awaited feature: prettier/prettier#4081
For now, I'd suggest:

  1. Define the fmt command in each package that will take into account all the package-specific configuration
  2. Keep the global command for formatting everything but packages (markdown, GitHub actions, package.json, etc.)

Here 1d03625. Should we also setup a github workflow that verifies files in root directory other than packages/?

This doesn't check the formatting in packages (point 1 from my comment), does it?

When npm ci is executed from root of the project, packages directory will be ignored in this commit.

Screenshot 2024-01-12 at 13 53 46 Each of the package already has its own `fmt` command so, package specific formatting can be done by specifying workspace name parameter e.g. `npm run fmt -w modules/4337`.

Yes, but how would it be used? I'd expect the ci to check package specific + global formatting, so npm run fmt:global and npm run fmt for packages

Also I accidentally edited your message instead of replying, sorry 🤦

@akshay-ap akshay-ap force-pushed the refactor-146-npm-workspaces branch 2 times, most recently from 57fb232 to a84bb58 Compare January 12, 2024 13:54
@akshay-ap
Copy link
Member Author

Yes, but how would it be used?

I suggested to have a github action for global checking here. What you suggested is even better. Added in this commit

@mmv08
Copy link
Member

mmv08 commented Jan 12, 2024

Yes, but how would it be used?

I suggested to have a github action for global checking here. What you suggested is even better. Added in this commit

But this executes a check only on the global level without a check on the package level, or am I missing anything? Should it be npm run fmt:global-check && npm run fmt:check ?

@akshay-ap
Copy link
Member Author

akshay-ap commented Jan 12, 2024

But this executes a check only on the global level without a check on the package level, or am I missing anything? Should it be npm run fmt:global-check && npm run fmt:check ?

I added ci.yml to contain only global checks and not package specific checks because they are already setup in each package (module) specific github workflow

@mmv08
Copy link
Member

mmv08 commented Jan 12, 2024

But this executes a check only on the global level without a check on the package level, or am I missing anything? Should it be npm run fmt:global-check && npm run fmt:check ?

I added ci.yml to contain only global checks and not package specific checks because they are already setup in each package (module) specific github workflow

Ahh, makes sense, my bad. All good then

@mmv08
Copy link
Member

mmv08 commented Jan 12, 2024

My bad, I created a bunch of conflicts here. Will resolve them

@akshay-ap akshay-ap merged commit dfdfced into master Jan 12, 2024
11 checks passed
@akshay-ap akshay-ap deleted the refactor-146-npm-workspaces branch January 12, 2024 15:18
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up NPM Workspace for Safe Modules
3 participants