[build-properties] Expand extraMavenRepos support#26895
Conversation
- Allow users to specify authentication scheme and credentials for
repositories added to the project via `android.extraMavenRepos`
|
thank you for the PR! @Kudo is OOO at the moment and is the best person to review, he'll back late next week |
|
@Kudo Would you mind reviewing/merging this when you have the chance? |
Kudo
left a comment
There was a problem hiding this comment.
sorry i missed this and thanks for your reminder as well as the great pr! i like the pr much for having great test coverage / comment / and nice code. i'm just leave a comment for not using typescript enum. let me know how do you feel for that.
- Change the `authentication` property to use a string union instead
of a TS enum
…peltonc/expo into extraMavenRepos-expanded-functionality
- Convert `AndroidMavenRepositoryAuthenticationScheme` to string union
|
sorry there're more 🤦♂️ i still dunno how to push directly to a pr where authors allowing maintainer to edit. please help me to edit the change again. commit b119bc25b01cbde4cd459d248b9f91f1700f2c1e
diff --git a/packages/expo-modules-autolinking/build/types.d.ts b/packages/expo-modules-autolinking/build/types.d.ts
index 9146e0306c..587d9149c8 100644
Binary files a/packages/expo-modules-autolinking/build/types.d.ts and b/packages/expo-modules-autolinking/build/types.d.ts differ
diff --git a/packages/expo-modules-autolinking/build/types.js b/packages/expo-modules-autolinking/build/types.js
index 7e60b199d7..11e638d1ee 100644
Binary files a/packages/expo-modules-autolinking/build/types.js and b/packages/expo-modules-autolinking/build/types.js differ
diff --git a/packages/expo-modules-autolinking/build/types.js.map b/packages/expo-modules-autolinking/build/types.js.map
index 066206f0cc..9c759e3f5a 100644
Binary files a/packages/expo-modules-autolinking/build/types.js.map and b/packages/expo-modules-autolinking/build/types.js.map differ
diff --git a/packages/expo-modules-autolinking/src/autolinking/__tests__/extraDependencies-test.ts b/packages/expo-modules-autolinking/src/autolinking/__tests__/extraDependencies-test.ts
index 9473adbf54..7317bce7ba 100644
--- a/packages/expo-modules-autolinking/src/autolinking/__tests__/extraDependencies-test.ts
+++ b/packages/expo-modules-autolinking/src/autolinking/__tests__/extraDependencies-test.ts
@@ -1,6 +1,5 @@
import { getConfig } from '@expo/config';
-import { AndroidMavenRepositoryAuthenticationScheme } from '../../types';
import { getBuildPropertiesAsync, resolveExtraDependenciesAsync } from '../extraDependencies';
jest.mock('@expo/config', () => ({
@@ -105,7 +104,7 @@ describe(resolveExtraDependenciesAsync, () => {
username: 'user',
password: 'password',
},
- authentication: AndroidMavenRepositoryAuthenticationScheme.BasicAuthentication,
+ authentication: 'basic',
},
],
},
@@ -148,8 +147,7 @@ describe(resolveExtraDependenciesAsync, () => {
name: 'token',
value: 'some_token',
},
- authentication:
- AndroidMavenRepositoryAuthenticationScheme.HttpHeaderAuthentication,
+ authentication: 'header',
},
],
},
@@ -192,7 +190,7 @@ describe(resolveExtraDependenciesAsync, () => {
username: 'user',
password: 'password',
},
- authentication: AndroidMavenRepositoryAuthenticationScheme.DigestAuthentication,
+ authentication: 'digest',
},
],
},
diff --git a/packages/expo-modules-autolinking/src/types.ts b/packages/expo-modules-autolinking/src/types.ts
index fbee9d9816..44569036ec 100644
--- a/packages/expo-modules-autolinking/src/types.ts
+++ b/packages/expo-modules-autolinking/src/types.ts
@@ -228,12 +228,6 @@ export interface RawExpoModuleConfig {
};
}
-export enum AndroidMavenRepositoryAuthenticationScheme {
- BasicAuthentication = 'basic',
- DigestAuthentication = 'digest',
- HttpHeaderAuthentication = 'header',
-}
-
interface AndroidMavenRepositoryPasswordCredentials {
username: string;
password: string;
|
|
Thanks for being thorough and catching all this. I'll get all this fixed and do a full sweep and test of my original PR before I push another hasty commit. I should have caught this. |
|
Removed all references to that enum and replaced them all with string unions, ran all the tests and build packagers again for both packages, and (after fixing a bug!) tested it again successfully linking a maven repo that requires basic authentication. I'm confident this is ready to go and addresses all your comments, @Kudo |
Kudo
left a comment
There was a problem hiding this comment.
everything looks good and i'm going to merge this pr. thanks again for the fantastic contribution 👏
android.extraMavenReposper Gradle/Maven documentation.Why
Support was added in Expo Build Properties 0.8.0 to allow users to specify additional Maven repositories to be included with an Android build, but this initial implementation is somewhat naive and only offers the user a small portion of the functionality Gradle and Maven offers, namely only allowing users to add repositories that don't require credentials. Users who would like to include Maven repositories that do require credentials are precluded from using Expo Build Properties to add them and would appreciate the ability to use the
extraMavenRepossupport to include these repos in their builds as well.How
extraMavenReposdefinition to accept an array of either these objects or strings, providing backwards-compatibility to consumers of this library who upgrade to this version and averting introducing breaking changes.expo-modules-autolinkingto accept the new properties and include them in the autolinking script.expo-modules-autolinkingpackage.Test Plan
One of the projects I work on specifies an extra Maven repository that requires a credentialed login. I specified a object in the
android.extraMavenRepossection of myapp.config.tsfile that included a url, credentials object, and authentication scheme. Then I rannpx expo prebuild --cleanandnpx expo android:run. With correct credentials, the app builds and runs successfully, and the feature provided by the repo is usable from within the Expo application.For reviewers of this PR, the main obstacle in testing will likely be finding a Maven repository that needs credentials for access, and obtaining valid credentials. I wish I could provide the credentials I used to test, but they are, of course, sensitive. Hopefully, we can collaborate on devising an easier way to test this PR.
Checklist
npx expo prebuild& EAS Build (eg: updated a module plugin).