How to use the ern-api-gen.ApiGenUtils.extractApiEventsAndRequests function in ern-api-gen

To help you get started, we’ve selected a few ern-api-gen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electrode-io / electrode-native / ern-api-impl-gen / src / generators / ApiImplGen.js View on Github external
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}`))
  }
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / ApiImplGen.ts View on Github external
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) {

ern-api-gen

Electrode Native API Generator

Apache-2.0
Latest version published 4 months ago

Package Health Score

66 / 100
Full package analysis