Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async getInjectableNativeDependencies(
platform: NativePlatform
): Promise {
const dependencies = await this.getResolvedNativeDependencies()
const result: PackagePath[] = []
for (const dependency of dependencies.resolved) {
// Always include react-native
if (dependency.basePath === 'react-native') {
result.push(dependency)
continue
}
const pluginConfig = await manifest.getPluginConfig(dependency)
if (platform === 'android' && pluginConfig?.android) {
result.push(dependency)
} else if (platform === 'ios' && pluginConfig?.ios) {
result.push(dependency)
}
}
return result
}
public async addiOSPluginHookClasses(
containerIosProject: any,
plugins: PackagePath[],
outDir: string
): Promise {
try {
log.debug('[=== iOS: Adding plugin hook classes ===]')
for (const plugin of plugins) {
if (plugin.basePath === 'react-native') {
continue
}
const pluginConfig = await manifest.getPluginConfig(plugin)
if (!pluginConfig.ios) {
log.warn(
`${
plugin.basePath
} does not have any injection configuration for iOS`
)
continue
}
const iOSPluginHook = pluginConfig.ios.pluginHook
if (iOSPluginHook && iOSPluginHook.name) {
if (!pluginConfig.path) {
throw new Error('No plugin config path was set. Cannot proceed.')
}
const pluginConfigPath = pluginConfig.path
const pathToCopyPluginHooksTo = path.join(
async buildApiImplPluginViews (plugins: Array,
mustacheView: Object,
pathSpec: Object,
projectSpec: Object) {
for (const plugin of plugins) {
const pluginConfig = await manifest.getPluginConfig(plugin, projectSpec.projectName)
shell.cd(pathSpec.pluginsDownloadDirectory)
if (await utils.isDependencyApiImpl(plugin.basePath)) {
const pluginSourcePath = await utils.downloadPluginSource(pluginConfig.origin)
populateApiImplMustacheView(pluginSourcePath, mustacheView, true)
}
}
if (mustacheView.apiImplementations) {
mustacheView.hasApiImpl = true
for (const api of mustacheView.apiImplementations) {
if (api.hasConfig) {
mustacheView.hasAtleastOneApiImplConfig = true
break
}
}
}
public async addiOSPluginHookClasses(
containerIosProject: any,
plugins: PackagePath[],
outDir: string
): Promise {
for (const plugin of plugins) {
if (plugin.basePath === 'react-native') {
continue
}
const pluginConfig = await manifest.getPluginConfig(plugin)
if (!pluginConfig) {
continue
}
if (!pluginConfig.ios) {
log.warn(
`${plugin.basePath} does not have any injection configuration for ios platform`
)
continue
}
const iOSPluginHook = pluginConfig.ios.pluginHook
if (iOSPluginHook?.name) {
if (!pluginConfig.path) {
throw new Error('No plugin config path was set. Cannot proceed.')
}
const pluginConfigPath = pluginConfig.path
injectReactNativeVersionKeysInObject(
mustacheView,
reactNativePlugin.version
)
mustacheView.miniApps = config.miniApps
await this.buildAndroidPluginsViews(config.plugins, mustacheView)
await this.addAndroidPluginHookClasses(config.plugins, config.outDir)
for (const plugin of config.plugins) {
if (await coreUtils.isDependencyJsApiImpl(plugin.basePath)) {
log.debug('JS api implementation identified, skipping fill hull.')
continue
}
const pluginConfig = await manifest.getPluginConfig(plugin)
let pluginSourcePath
if (plugin.basePath === 'react-native') {
continue
}
if (!pluginConfig.android) {
log.warn(
`Skipping ${
plugin.basePath
} as it does not have an Android configuration`
)
continue
}
shell.cd(config.pluginsDownloadDir)
pluginSourcePath = await coreUtils.downloadPluginSource(
pluginConfig.origin
export async function generatePluginsMustacheViews(
plugins: PackagePath[],
platform: string
) {
const pluginsViews: any[] = []
log.debug('Generating plugins mustache views')
for (const plugin of plugins) {
if (plugin.basePath === 'react-native') {
continue
}
const pluginConfig = await manifest.getPluginConfig(plugin)
if (!pluginConfig) {
continue
}
if (!pluginConfig[platform]) {
log.warn(
`${
plugin.basePath
} does not have any injection configuration for ${platform} platform`
)
continue
}
const pluginHook = pluginConfig[platform].pluginHook
const containerHeader = pluginConfig[platform].containerPublicHeader
if (!pluginHook && !containerHeader) {
continue
export async function generatePluginsMustacheViews (
plugins: Array,
platform: string) {
let pluginsViews = []
log.debug('Generating plugins mustache views')
for (const plugin of plugins) {
if (plugin.name === 'react-native') {
continue
}
let pluginConfig = await manifest.getPluginConfig(plugin)
if (!pluginConfig[platform]) {
log.warn(`${plugin.basePath} does not have any injection configuration for ${platform} platform`)
continue
}
const pluginHook = pluginConfig[platform].pluginHook
const containerHeader = pluginConfig[platform].containerPublicHeader
if (!pluginHook && !containerHeader) {
continue
}
let pluginView = {}
if (pluginHook) {
pluginView.name = pluginHook.name
pluginView.lcname = pluginHook.name && pluginHook.name.charAt(0).toLowerCase() + pluginHook.name.slice(1)
pluginView.configurable = pluginHook.configurable
shell.cd(ROOT_DIR)
const outputDirectory = path.join(paths.outDirectory, 'android')
log.debug(`Creating out directory(${outputDirectory}) for android and copying container hull to it.`)
if (!fs.existsSync(outputDirectory)) {
shell.mkdir(outputDirectory)
}
fileUtils.chmodr(READ_WRITE_EXECUTE, outputDirectory)
shell.cp('-Rf', path.join(paths.apiImplHull, 'android', '{.*,*}'), outputDirectory)
const srcOutputDirectory = path.join(outputDirectory, 'lib', SRC_MAIN_JAVA_DIR)
for (let pluginPath: PackagePath of pluginsPaths) {
log.debug(`Copying ${pluginPath.basePath} to ${outputDirectory}`)
await manifest.getPluginConfig(pluginPath).then((pluginConfig) => {
this.copyPluginToOutput(paths, srcOutputDirectory, pluginPath, pluginConfig)
})
}
const editableFiles = await this.generateRequestHandlerClasses(apiDependency, paths, apis)
await this.updateFilePermissions(srcOutputDirectory, editableFiles)
await this.updateBuildGradle(paths, reactNativeVersion, outputDirectory)
} catch (e) {
throw new Error(`Error during apiimpl hull: ${e}`)
}
}