How to use the ern-core.mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile function in ern-core

To help you get started, we’ve selected a few ern-core 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-container-gen / src / generators / android / AndroidGenerator.ts View on Github external
)
      for (const file of files) {
        if (
          (file.startsWith(pathLibSrcMainJavaCom) &&
            !file.startsWith(pathLibSrcMainJavaComWalmartlabsErnContainer)) ||
          file.startsWith(pathLibSrcMainAssets)
        ) {
          // We don't want to Mustache process library files. It can lead to bad things
          // We also don't want to process assets files ...
          // We just want to process container specific code (which contains mustache templates)
          log.debug(`Skipping mustaching of ${file}`)
          continue
        }
        log.debug(`Mustaching ${file}`)
        const pathToFile = path.join(config.outDir, file)
        await mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
          pathToFile,
          mustacheView,
          pathToFile
        )
      }

      log.debug('Creating miniapp activities')
      for (const miniApp of config.miniApps) {
        const activityFileName = `${miniApp.pascalCaseName}Activity.java`

        log.debug(`Creating ${activityFileName}`)
        const pathToMiniAppActivityMustacheTemplate = path.join(
          PATH_TO_TEMPLATES_DIR,
          'MiniAppActivity.mustache'
        )
        const pathToOutputActivityFile = path.join(
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / ios / ApiImplIosGenerator.ts View on Github external
if (file === 'requestHandlerProvider.mustache') {
          const reqHandlerProviderClassFile = path.join(
            outputDir,
            classNames[file]
          )
          editableFiles.push(reqHandlerProviderClassFile)
          if (
            this.regenerateApiImpl &&
            shell.test('-e', reqHandlerProviderClassFile)
          ) {
            log.debug(`Skipping regeneration of ${classNames[file]}`)
            continue
          }
        }

        await mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
          path.join(resourceDir, file),
          api,
          path.join(outputDir, classNames[file])
        )
        iosProject.addSourceFile(
          path.join(API_IMPL_GROUP_NAME, classNames[file]),
          null,
          iosProject.findPBXGroupKey({ name: API_IMPL_GROUP_NAME })
        )
      }

      log.debug(
        `Api implementation files successfully generated for ${api.apiName}Api`
      )
    }
  }
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.ts View on Github external
paths: any,
    reactNativeVersion: string,
    outputDirectory: string
  ): Promise {
    let mustacheView: any = {}
    const versions = android.resolveAndroidVersions({
      androidGradlePlugin: '3.2.1',
    })
    mustacheView.reactNativeVersion = reactNativeVersion
    mustacheView = Object.assign(mustacheView, versions)
    mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(paths.apiImplHull, 'android/build.gradle'),
      mustacheView,
      path.join(outputDirectory, 'build.gradle')
    )
    return mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(paths.apiImplHull, 'android/lib/build.gradle'),
      mustacheView,
      path.join(outputDirectory, 'lib/build.gradle')
    )
  }
github electrode-io / electrode-native / ern-runner-gen-android / src / AndroidRunnerGenerator.ts View on Github external
const subPathToRunnerConfig =
      'app/src/main/java/com/walmartlabs/ern/miniapp/RunnerConfig.java'

    const pathToRunnerConfigHull = path.join(
      runnerHullPath,
      subPathToRunnerConfig
    )
    const pathToRunnerConfig = path.join(
      config.outDir,
      'app/src/main/java',
      getPackageFilePath(config),
      'RunnerConfig.java'
    )
    shell.cp(pathToRunnerConfigHull, pathToRunnerConfig)
    await mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      pathToRunnerConfig,
      mustacheView,
      pathToRunnerConfig
    )
  }
}
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.ts View on Github external
public updateBuildGradle(
    paths: any,
    reactNativeVersion: string,
    outputDirectory: string
  ): Promise {
    let mustacheView: any = {}
    const versions = android.resolveAndroidVersions({
      androidGradlePlugin: '3.2.1',
    })
    mustacheView.reactNativeVersion = reactNativeVersion
    mustacheView = Object.assign(mustacheView, versions)
    mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(paths.apiImplHull, 'android/build.gradle'),
      mustacheView,
      path.join(outputDirectory, 'build.gradle')
    )
    return mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(paths.apiImplHull, 'android/lib/build.gradle'),
      mustacheView,
      path.join(outputDirectory, 'lib/build.gradle')
    )
  }
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.ts View on Github external
log.warn(
              `Skipping mustaching of ${file}. No resulting file mapping found, consider adding one. \nThis might cause issues in generated implementation project.`
            )
            throw new Error(
              `Class name mapping is missing for ${file}, unable to generate implementation class file.`
            )
          }

          if (file === 'requestHandlerProvider.mustache') {
            editableFiles.push(path.join(outputDir, classNames[file]))
            if (this.regenerateApiImpl) {
              log.debug(`Skipping regeneration of ${classNames[file]}`)
              continue
            }
          }
          await mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
            path.join(resourceDir, file),
            api,
            path.join(outputDir, classNames[file])
          )
        }
        log.debug(
          `Api implementation files successfully generated for ${
            api.apiName
          }Api`
        )
      }
      return editableFiles
    } catch (e) {
      throw new Error(`Failed to update RequestHandlerClass: ${e}`)
    }
  }
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.ts View on Github external
public updateGradleProperties(
    paths: any,
    outputDirectory: string
  ): Promise {
    let mustacheView: any = {}
    const versions = android.resolveAndroidVersions()
    mustacheView = Object.assign(mustacheView, versions)
    return mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(
        paths.apiImplHull,
        'android/gradle/wrapper/gradle-wrapper.properties'
      ),
      mustacheView,
      path.join(outputDirectory, 'gradle/wrapper/gradle-wrapper.properties')
    )
  }
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.js View on Github external
updateBuildGradle (paths: Object, reactNativeVersion: string, outputDirectory: string): Promise<*> {
    let mustacheView = {}
    mustacheView.reactNativeVersion = reactNativeVersion
    return mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(paths.apiImplHull, 'android', 'lib', 'build.gradle'),
      mustacheView,
      path.join(outputDirectory, 'lib', 'build.gradle'))
  }
github electrode-io / electrode-native / ern-container-gen / src / publishers / JcenterPublisher.ts View on Github external
)

    fs.appendFileSync(
      path.join(config.containerPath, 'build.gradle'),
      `buildscript {
      dependencies {
          classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
      }
    }`
    )

    shell.cp(
      path.join(__dirname, 'supplements', 'jcenter-publish.gradle'),
      path.join(config.containerPath, 'lib')
    )
    mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
      path.join(config.containerPath, 'lib', 'jcenter-publish.gradle'),
      mustacheConfig,
      path.join(config.containerPath, 'lib', 'jcenter-publish.gradle')
    )

    try {
      log.info('[=== Starting build and jcenter publication ===]')
      shell.pushd(config.containerPath)
      await this.buildAndUploadArchive()
      log.info('[=== Completed build and publication of the Container ===]')
      log.info(
        `[Artifact: ${config.extra.groupId}:${config.extra.artifactId}:${
          config.containerVersion
        } ]`
      )
    } finally {