-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: barebones dependency conversion #61
Conversation
c2d625a
to
7c818ed
Compare
5f90b8c
to
6993ff6
Compare
cd631e6
to
c4b2b29
Compare
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.
LGTM!
expect(parsedDependencies).to.deep.eq({}); | ||
}); | ||
}); | ||
describe('with a file with several dependencies', function () { |
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.
Maybe worth also having a case where the gitmodules exist but is not in the format we expect it
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.
added them in 52b257b
const matches = [...iniAsStr.matchAll(/(?:path|url) = (.*)/g)].map(regexMatch => regexMatch[1]); | ||
if (matches.length == 0) return {}; | ||
|
||
// this assumes .gitmodules to be well formed, same amount of paths and urls |
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 is not, shouldn't it throw an error describing the issue?
I see this as a NTH tho
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.
52b257b
added a test for a valid .gitmodules that breaks it, but am not explicitly throwing an error in that case, as figuring out if the precondition is met or not would involve extra logic
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.
Approved with a comment, agreed with Tony that would be nice to cover the case where the submodules file contains a different format than what we are expecting.
Nice one!
52b257b
I've tried running the tests locally and got the following output. Looks like the file mock doesn't work, because creating the
|
`, | ||
}); | ||
}); | ||
it.skip('should be able to parse them', function () { |
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.
Why are some tests being skipped?
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.
to acknowledge, yet thoroughly document the limitations of the current implementation. Example of a previous discussion: #58 (comment)
This test in particular was added to document the consequences of not doing proper git-config
format parsing (I couldn't find an existing implementation, and the generic .ini parser in npm was not enough either)
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.
Tests passed using 18
as node version. Nicely done ser!
merge after #58
closes #60
adding support for git dependencies means we'll probably also support projects where the dependencies are not explicitly stated in
remappings.txt
, the build instead relying on foundry's implicit remappings. To fully handle those cases, this project should invokeforge remappings
instead of readingremappings.txt
TODO
transformRemappings
.gitmodules
parsingI tried to use the ini npm package since
.gitmodules
seem to be .ini files, but didn't behave as expected.It didn't recognize the various
path
andurl
fields as part of the relevantsubmodule
subsections, instead assignig them as items ofsubmodule
, so after parsing an entire file only the last two remained:would yield
The current implementation works for machine-generated
.gitmodules
, but will break if a subseciton is populated in two passes like so:or if path and url are out of order (which is perfectly valid for git)
and probably other cases that are syntactically valid ini, and sematically valid submodule definitions, but that dont match my arbitrary regex
I deem this good enough for now, specially considering we are doing the same problematic regex-parsing for solidity files