-
Notifications
You must be signed in to change notification settings - Fork 913
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 foundry #867
Migrate to foundry #867
Conversation
#812 maybe something we could handle in different PR nicely? |
This is great stuff @technophile-04 tysm!! I'll start testing and report back! |
README.md
Outdated
2. Create `packages/foundry/.env` file based of on `packages/foundry/.env.example` | ||
|
||
``` | ||
cp packages/foundry/.env.example packages/foundry/.env | ||
``` | ||
|
||
> NOTE: If you are using windows and not using git bash or wsl, use `copy packages\foundry\.env.example packages\foundry\.env` | ||
|
||
3. Run a local network in the first terminal: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that you already commented about this in the PR comment. Having to do this is a PITA (the 3 magic commands don't work out of the box), so I've been trying some options (postinstall as you mentioned)
branch: https://github.com/scaffold-eth/scaffold-eth-2/commits/foundry-main--cp-env/
commit: 951f733
Using the smallest copy
lib that I could find (even tho it installs a few other deps, maybe we can explore other options), which should work on any OS.
I remember that we had some issues with the postinstall script (not running at all in some OS? Or running after every time you run yarn install
? Added the --no-overwrite
in case it's the latter).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we take this path, this can help to decide about the lib to use. https://pkg-size.dev/
eg. https://pkg-size.dev/cpy-cli => 1.3MB vs the 5 KB advertised (which doesn't count the deps)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After researching for a while I think postinstall seems a safe option.
Some notes on `postinstall` script:
-
Postinstall in yarn will run only when something in root
node_modules
changes(which means some package is added in dependency or devDependency of rootpackage.json
) ornode_moduels
is initialized -
Postinstall in yarn does not log output to stdout, which means If you do
postinstall: echo 'hello world'
it won't log hello world. It will only show output on error (example this image ) -
Running
yarn install
multiple times won't runpostinstall
multiple times until you add any package to rootpacakage.json
. If you add npm package innextjs
it won't run.
So considering all the above points, I think postinstall
seems a fine options for us
not running at all in some OS?
Even I had the same feeling, but went through SE-2 issues throughly and could only found this : #275
The above issue was not related too much related to postinstall
(since postinstall ran) but it was related to node js script not resolving proper path on windows.
So yeah 951f733 seems good if it works nicely on windows (hopefully it resolves path correctly internally)
Another options we could also put our own node script at root of monorepo and call it in postinstall: node startUp.js
but we need to make sure it works properly on windows the path resolution thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just trying https://github.com/scaffold-eth/scaffold-eth-2/tree/foundry-main--cp-env and found a minor disadvantage that:
- First you clone above repo and
yarn install
this creates.env.example
nicely inpacakge/foundry
- If you try to install node dependency in
foundry
packagecd packages/foundry
andyarn add viem
it will fail :
basically you won't be able to install any node / js dependency in foundry
package because it will fail since we are using ---no-overwrite
it throwing error
An alternatie solution will be finding a library which doesn't throw error or writting our own node script which doesn't throw error if .env
is already present. The only reason I am afraid of writing our own script is because of #275 where isn't properly able to get the path but maybe we should give it another shot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what we need: https://www.npmjs.com/package/shx (we can use commands from linux, and we could copy... or even test if the file exist before copying)
And it takes less space https://pkg-size.dev/shx
I'll give it a shot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this (using shx): 46443fb
I pushed it to https://github.com/scaffold-eth/scaffold-eth-2/commits/foundry-main--cp-env/
If we like it, we can have Pablo to test on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noiicee, just tried it out and works great!! Tysm!!, I think this works great!! Will merge in this changes!
Reset account fixed this |
ba1f869
to
5e43708
Compare
Was talking with Carlos and just switched the base branch from So for this PR we get this #867 (comment) solved merge it to |
Just merged the To test first run: git clone https://github.com/scaffold-eth/scaffold-eth-2.git -b foundry-main scaffold-eth-foundry
cd scaffold-eth-foundry
yarn install && forge install --root packages/foundry And then the three command |
for me it also works! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just merged the postinstallchanges mentioned in #867 (comment) works nicely for me!. cc @Pabl0cks could you test it on windows once w/ without wsl and gitbash also if others could give another try too would be great 🙌
Awesome job @technophile-04 for tackling this and @carletex @rin-st for the great reviews! ❤
It's working great on Windows with Git Bash, also installed and configured WSL with Ubuntu 20.04 and is working great too 🙌
Everything working great on Ubuntu 20.04!! @technophile-04 Great job!!! |
Tried it on a win11 + git bash machine |
Thanks all merging this in |
TODOs:
packages/foundry/.env
cp packages/foundry/.env.example packages/foundry/.env
in READMEscripts-js
so that people who are familiar with foundry don't feel weird by seeing js files inscript
dir.foundry fmt && prettier
as pre-commit step in packages/foundryTesting steps:
Follow this branch README: https://github.com/scaffold-eth/scaffold-eth-2/tree/foundry-main?tab=readme-ov-file#-scaffold-eth-2
Next todos: