Skip to content

Commit

Permalink
fix disabled plugins, fix getSkipLinkingDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
pavjacko committed Jan 26, 2024
1 parent c3ab334 commit 5319030
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
7 changes: 5 additions & 2 deletions packages/app-harness/renative.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
},
"podName": "react-native-splash-screen"
},
"tvos": {
"disabled": true
},
"version": "3.3.0"
},
"react-native-carplay": {
Expand Down Expand Up @@ -58,8 +61,8 @@
"version": "2.3.0"
},
"react-native-permissions": {
"ios": {
"podName": "RNPermissions"
"tvos": {
"disabled": true
},
"version": "3.10.1"
},
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ export const parsePlugins = (
c: RnvContext,
platform: RnvPlatform,
pluginCallback: PluginCallback,
ignorePlatformObjectCheck?: boolean
ignorePlatformObjectCheck?: boolean,
includeDisabledPlugins?: boolean
) => {
logTask('parsePlugins');
if (c.buildConfig && platform) {
Expand Down Expand Up @@ -407,12 +408,12 @@ export const parsePlugins = (
// skipLinking: true,
// disabled: true,
// };
//TODO: consider supportedPlatforms for plugins
if (ignorePlatformObjectCheck) {
// totalIncludedPlugins++;
handleActivePlugin();
} else if (pluginPlat) {
const isPluginDisabled = plugin.disabled === true;
//DEPreCATED
const isPluginPlatDisabled = pluginPlat.disabled === true;
if (!isPluginDisabled && !isPluginPlatDisabled) {
if (plugin.deprecated) {
Expand All @@ -425,6 +426,9 @@ export const parsePlugins = (
} else if (isPluginPlatDisabled) {
logInfo(`Plugin ${key} is marked disabled for platform ${platform} skipping.`);
}
if (includeDisabledPlugins) {
handleActivePlugin();
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/sdk-react-native/src/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const getApplicationId = () => {

const getSkipLinkingDeps = () => {
const skipLinkingEnv = process.env.RNV_SKIP_LINKING;

if (skipLinkingEnv) {
const plugins = skipLinkingEnv.split(',').map((item) => item.trim());

return {
const result = {
dependencies: plugins.reduce((acc, plugin) => {
acc[plugin] = {
platforms: {
Expand All @@ -23,6 +24,8 @@ const getSkipLinkingDeps = () => {
return acc;
}, {} as { [plugin: string]: { platforms: { ios: null } } }),
};

return result;
}

return {};
Expand Down
38 changes: 16 additions & 22 deletions packages/sdk-react-native/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { doResolve, getAppId, getConfigProp, getContext, getRelativePath } from '@rnv/core';
import { doResolve, getAppId, getConfigProp, getContext, getRelativePath, parsePlugins } from '@rnv/core';
import RNPermissionsMap from './rnPermissionsMap';

export const EnvVars = {
Expand Down Expand Up @@ -54,30 +54,24 @@ export const EnvVars = {
},
RNV_SKIP_LINKING: () => {
const ctx = getContext();
const {
platform,
buildConfig: { plugins },
} = ctx;
const platformsToCheck = ['ios', 'tvos'];

if (platform && plugins) {
const filteredPlugins = Object.entries(plugins)
.filter(([_, pluginConfig]) => {
const pluginConfigKeys = Object.keys(pluginConfig);
return (
typeof pluginConfig !== 'string' &&
pluginConfigKeys.some((key) => platformsToCheck.includes(key)) &&
!pluginConfigKeys.includes(platform)
);
})
.reduce((acc: any, [pluginName]) => {
acc.push(pluginName);
return acc;
}, []);
const skipPlugins: string[] = [];
parsePlugins(
ctx,
ctx.platform,
(plugin, pluginPlat, key) => {
if (pluginPlat.disabled || plugin.disabled) {
skipPlugins.push(key);
}
},
false,
true
);

const resultString = `${filteredPlugins.join(', ')}`;
return { RNV_SKIP_LINKING: resultString };
if (skipPlugins.length > 0) {
return { RNV_SKIP_LINKING: skipPlugins.join(', ') };
}

return {};
},
};

0 comments on commit 5319030

Please sign in to comment.