-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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(mix): Support private hex repos/registries #29775
base: main
Are you sure you want to change the base?
feat(mix): Support private hex repos/registries #29775
Conversation
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
36e3f93
to
6c293a1
Compare
Feedback should be addressed 👍🏻 |
file: { type: 'addition', path: 'mix.lock', contents: 'New mix.lock' }, | ||
}, | ||
]); | ||
expect(execSnapshots).toMatchObject([ |
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 don't see a test for the mix repo.add ...
command
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.
The test is to check that we don't do that in this case. does not add registries configured in registryAliases but no token in hostRules
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.
then add a test for it
@@ -75,26 +78,50 @@ export async function updateArtifacts({ | |||
|
|||
for (const { packageName } of updatedDeps) { | |||
if (packageName) { | |||
const [, organization] = packageName.split(':'); | |||
const [, organization, ,] = packageName.split(':'); |
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.
const [, organization, ,] = packageName.split(':'); | |
const [, organization] = packageName.split(':'); |
not needed
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 don't understand the suggestion. This wants to extract the second value in whatever is returned. The packageName when split can be 2 or 3 elements in length. The suggestion only works when array of length 2 is returned.
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.
no, the split returns all elements, but the array destruction will only return the first two and ignore the rest.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
|
||
return acc; | ||
}, [] as string[]); | ||
// istanbul ignore if: no good way to test |
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.
no, why? you can mock hostrule find properly
return packageName; | ||
} | ||
|
||
const [, repoName, ,] = packageName.split(':'); |
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.
const [, repoName, ,] = packageName.split(':'); | |
const [, repoName] = packageName.split(':'); |
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 don't understand the suggestion. This wants to extract the second value in whatever is returned.
registryAliases: { | ||
oban: 'https://getoban.pro/repo', | ||
}, |
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.
this should be scoped to mix
manager, otherwise it will interferre with other managers using registry aliases
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.
So there needs to be a further nesting of the object? I didn't see any examples of that in other managers
registryAliases: { | ||
hexpm: 'https://hex.pm', | ||
}, |
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 is this needed
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.
We need the URL for the hexpm registry, which is the default, so we put it into the default config. This is merged with anything the user has supplied, giving us a complete lookup of the URLs. This has an added benefit that if a company wished to host an internal proxy registry, no updates are needed to their mix files; they have a way to point someplace else.
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.
you should not add a default url, the datasource has it already, so only set registry url if it's not the default
if (requirement?.startsWith('==')) { | ||
dep.currentVersion = requirement.replace(regEx(/^==\s*/), ''); | ||
} | ||
|
||
if (organization) { | ||
dep.packageName = `org:${organization}:${app}`; |
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.
this is used by the hex datasource, so needs changes there too
const [hexPackageName, organizationName] = packageName.split(':'); |
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.
That is in the other PR. You requested to split them so neither PR will work on its own
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.
then don't change package name in this PR, do the package name change in a separate refactor PR
Changes
This adds support to the mix manager to add private hex repos/registries via
registryAliases
for mapping andhostRules
for authentication.Context
This is the companion to #29756 and dependent on that change. Splitting the manager and datasource work per request in #29756. When combined, this will enable support for private repos/registries such as oban pro.
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via:
Tested in combination with #29756. This will not fully work without that code.