Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error('react-native-electrode-bridge version needs to be defined')
}
const reactNative = await manifest.getNativeDependency(
PackagePath.fromString('react-native'),
{ manifestId }
)
if (!reactNative) {
throw new Error(
'react-native-electrode-bridge not found in manifest. cannot infer version to use'
)
}
log.info(`Generating ${apiName} API`)
await ApiGen.generateApi({
apiAuthor,
apiSchemaPath: schemaPath,
apiVersion,
bridgeVersion: `${bridgeDep.version || ''}`,
name: apiName,
npmScope: scope,
packageName,
reactNativeVersion: reactNative.version,
})
log.info('Success')
}
const bridgeDep = await manifest.getNativeDependency(PackagePath.fromString('react-native-electrode-bridge'))
if (!bridgeDep) {
throw new Error('react-native-electrode-bridge not found in manifest. cannot infer version to use')
}
if (!bridgeDep.version) {
throw new Error('react-native-electrode-bridge version needs to be defined')
}
const reactNative = await manifest.getNativeDependency(PackagePath.fromString('react-native'))
if (!reactNative) {
throw new Error('react-native-electrode-bridge not found in manifest. cannot infer version to use')
}
log.info(`Generating ${apiName} API`)
await ApiGen.generateApi({
bridgeVersion: `${bridgeDep.version || ''}`,
reactNativeVersion: reactNative.version,
name: apiName,
npmScope: scope,
apiSchemaPath: schemaPath,
apiVersion: apiVersion,
apiAuthor: apiAuthor,
packageName: packageName
})
log.info('Success!')
} catch (e) {
coreUtils.logErrorAndExitProcess(e)
}
}
skipVersion: boolean,
bridgeVersion: string
} = {}) {
try {
if (!bridgeVersion) {
const bridgeDep = await manifest.getNativeDependency(PackagePath.fromString('react-native-electrode-bridge'))
if (!bridgeDep) {
throw new Error('react-native-electrode-bridge not found in manifest. please provide explicit version')
}
if (!bridgeDep.version) {
throw new Error('react-native-electrode-bridge version not defined. This should not happen')
}
bridgeVersion = bridgeDep.version
}
await ApiGen.regenerateCode({bridgeVersion, skipVersion})
} catch (e) {
coreUtils.logErrorAndExitProcess(e)
}
}
const bridgeDep = await manifest.getNativeDependency(electrodeBridgePkg, {
manifestId,
})
if (!bridgeDep) {
throw new Error(
`react-native-electrode-bridge is not found in manifest. Specify explicit --bridgeVersion in the command.\n ${errorMessage}`
)
}
if (!bridgeDep.version) {
throw new Error(
`react-native-electrode-bridge version not defined. Specify explicit --bridgeVersion in the command. \n ${errorMessage}`
)
}
bridgeVersion = bridgeDep.version
}
await ApiGen.regenerateCode({ bridgeVersion, skipVersion })
}
apiPackagePath: PackagePath,
paths: {
workingDirectory: string,
pluginsDownloadDirectory: string,
apiImplHull: string,
outDirectory: string
},
reactNativeVersion: string,
platforms: Array,
regen: boolean = false) {
log.debug(`Inside generateApiImplementation for api:${apiPackagePath.toString()}, platforms:${platforms.toString()}`)
await this.downloadApiAndDependencies(apiPackagePath, paths.pluginsDownloadDirectory, reactNativeVersion)
const schemaJson = path.join(paths.pluginsDownloadDirectory, 'node_modules', apiPackagePath.basePath, 'schema.json')
const apis:Array = await ApiGenUtils.extractApiEventsAndRequests(schemaJson)
this.updatePackageJsonWithApiNames(paths.outDirectory, apis)
const generators: Array = this.getGenerators(platforms)
for (let generator of generators) {
try {
if (generator) {
await generator.generate(apiPackagePath, paths, reactNativeVersion, plugins, apis, regen)
}
} catch (e) {
throw new Error(`API implementation project generation failed: ${e}`)
}
}
log.info(chalk.green(`API implementation project was successfully generated in ${paths.outDirectory}`))
}
reactNativeVersion: string,
platforms: string[],
regen: boolean = false
) {
log.debug(
`Inside generateApiImplementation for api:${apiPackagePath.toString()}, platforms:${platforms.toString()}`
)
const schemaJson = path.join(
paths.outDirectory,
'node_modules',
apiPackagePath.basePath,
'schema.json'
)
const apis: any[] = await ApiGenUtils.extractApiEventsAndRequests(
schemaJson
)
this.updatePackageJsonWithApiNames(paths.outDirectory, apis)
const reactNativeElectrodeBridge: any = await readPackageJson(
path.join(
paths.outDirectory,
'node_modules/react-native-electrode-bridge'
)
)
const generators: ApiImplGeneratable[] = this.getGenerators(platforms)
for (const generator of generators) {
try {
if (generator) {