Skip to content
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

fix expo config plugin #161

Merged
merged 2 commits into from
Mar 5, 2024
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
17 changes: 16 additions & 1 deletion app.plugin.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
module.exports = require('./lib/commonjs/expo-plugins');
const packageJson = require('./package.json');

const pkg = {
// Prevent this plugin from being run more than once.
// This pattern enables users to safely migrate off of this
// out-of-tree `@config-plugins/intercom-react-native` to a future
// upstream plugin in `intercom-react-native`
name: packageJson.name,
// Indicates that this plugin is dangerously linked to a module,
// and might not work with the latest version of that module.
version: packageJson.version,
};

const plugin = require('./lib/commonjs/expo-plugins');

module.exports = plugin.default(pkg);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"android",
"ios",
"cpp",
"app.plugin.js",
"intercom-react-native.podspec",
"!lib/typescript/example",
"!android/build",
Expand Down
19 changes: 3 additions & 16 deletions src/expo-plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
insertContentsInsideObjcFunctionBlock,
} from '@expo/config-plugins/build/ios/codeMod';
import type { IntercomPluginProps, IntercomRegion } from './@types';
import packageJson from '../../package.json';

const mainApplication: ConfigPlugin<IntercomPluginProps> = (_config, props) =>
withMainApplication(_config, (config) => {
Expand Down Expand Up @@ -122,19 +121,7 @@ const withIntercomReactNative: ConfigPlugin<IntercomPluginProps> = (
return newConfig;
};

const pkg = {
// Prevent this plugin from being run more than once.
// This pattern enables users to safely migrate off of this
// out-of-tree `@config-plugins/intercom-react-native` to a future
// upstream plugin in `intercom-react-native`
name: packageJson.name,
// Indicates that this plugin is dangerously linked to a module,
// and might not work with the latest version of that module.
version: packageJson.version,
};
const configPlugin = (pkg: { name: string; version: string }) =>
createRunOncePlugin(withIntercomReactNative, pkg.name, pkg.version);

export default createRunOncePlugin(
withIntercomReactNative,
pkg.name,
pkg.version
);
export default configPlugin;