Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/android/__tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { ExpoConfig } from "expo/config";

import { withAndroidStringsDependency } from "../strings-dependency";

const config = { name: "test", slug: "test" } as ExpoConfig;

describe("Android config", () => {
it.each([undefined, ""])(
"rejects a missing CodePush server URL",
(CodePushServerURL) => {
expect(() =>
withAndroidStringsDependency(config, {
android: {
CodePushDeploymentKey: "android-key",
CodePushServerURL: CodePushServerURL as string,
},
ios: {
CodePushDeploymentKey: "ios-key",
CodePushServerURL: "https://updates.example.com",
},
}),
).toThrow(/App Center is retired/);
},
);

it("rejects a missing deployment key", () => {
expect(() =>
withAndroidStringsDependency(config, {
android: {
CodePushDeploymentKey: "",
CodePushServerURL: "https://updates.example.com",
},
ios: {
CodePushDeploymentKey: "ios-key",
CodePushServerURL: "https://updates.example.com",
},
}),
).toThrow(/CodePushDeploymentKey/);
});
});
24 changes: 11 additions & 13 deletions src/android/strings-dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,24 @@ export const withAndroidStringsDependency: ConfigPlugin<PluginConfigType> = (
config,
props,
) => {
// if (!props?.android?.CodePushServerURL) {
// throw new Error(
// "You need to provide the `CodePushServerURL` Android property for the @config-plugins/react-native-code-push plugin to work."
// );
// }
if (!props?.android?.CodePushServerURL) {
throw new Error(
"You need to provide the `CodePushServerURL` Android property for react-native-code-push-plugin to work. App Center is retired, so the default server no longer works.",
);
}

if (!props?.android?.CodePushDeploymentKey) {
throw new Error(
"You need to provide the `CodePushDeploymentKey` Android property for the @config-plugins/react-native-code-push plugin to work.",
"You need to provide the `CodePushDeploymentKey` Android property for react-native-code-push-plugin to work.",
);
}

return withStringsXml(config, (xmlProps) => {
if (props?.android?.CodePushServerURL) {
xmlProps.modResults = setStrings(
xmlProps.modResults,
"CodePushServerURL",
props?.android?.CodePushServerURL,
);
}
xmlProps.modResults = setStrings(
xmlProps.modResults,
"CodePushServerURL",
props.android.CodePushServerURL,
);

xmlProps.modResults = setStrings(
xmlProps.modResults,
Expand Down
40 changes: 40 additions & 0 deletions src/ios/__tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { ExpoConfig } from "expo/config";

import { withIosInfoPlistDependency } from "../info-plist-dependency";

const config = { name: "test", slug: "test" } as ExpoConfig;

describe("iOS config", () => {
it.each([undefined, ""])(
"rejects a missing CodePush server URL",
(CodePushServerURL) => {
expect(() =>
withIosInfoPlistDependency(config, {
android: {
CodePushDeploymentKey: "android-key",
CodePushServerURL: "https://updates.example.com",
},
ios: {
CodePushDeploymentKey: "ios-key",
CodePushServerURL: CodePushServerURL as string,
},
}),
).toThrow(/App Center is retired/);
},
);

it("rejects a missing deployment key", () => {
expect(() =>
withIosInfoPlistDependency(config, {
android: {
CodePushDeploymentKey: "android-key",
CodePushServerURL: "https://updates.example.com",
},
ios: {
CodePushDeploymentKey: "",
CodePushServerURL: "https://updates.example.com",
},
}),
).toThrow(/CodePushDeploymentKey/);
});
});
17 changes: 7 additions & 10 deletions src/ios/info-plist-dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ export const withIosInfoPlistDependency: ConfigPlugin<PluginConfigType> = (
config,
props,
) => {
// if (!props?.ios?.CodePushServerURL) {
// throw new Error(
// "You need to provide the `CodePushServerURL` IOS property for the @config-plugins/react-native-code-push plugin to work."
// );
// }
if (!props?.ios?.CodePushServerURL) {
throw new Error(
"You need to provide the `CodePushServerURL` iOS property for react-native-code-push-plugin to work. App Center is retired, so the default server no longer works.",
);
}

if (!props?.ios?.CodePushDeploymentKey) {
throw new Error(
"You need to provide the `CodePushDeploymentKey` IOS property for the @config-plugins/react-native-code-push plugin to work.",
"You need to provide the `CodePushDeploymentKey` iOS property for react-native-code-push-plugin to work.",
);
}

return withInfoPlist(config, (infoPlistProps) => {
if (props?.ios?.CodePushServerURL) {
infoPlistProps.modResults.CodePushServerURL =
props?.ios?.CodePushServerURL;
}
infoPlistProps.modResults.CodePushServerURL = props.ios.CodePushServerURL;

infoPlistProps.modResults.CodePushDeploymentKey =
props.ios.CodePushDeploymentKey;
Expand Down
4 changes: 2 additions & 2 deletions src/plugin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*/
export type PluginConfigType = {
ios: {
CodePushServerURL?: string;
CodePushServerURL: string;
CodePushDeploymentKey: string;
};
android: {
CodePushServerURL?: string;
CodePushServerURL: string;
CodePushDeploymentKey: string;
CodePushPublicKey?: string;
};
Expand Down
Loading