Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
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(
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`
)
}
}
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')
)
}
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
)
}
}
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')
)
}
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}`)
}
}
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')
)
}
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'))
}
)
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 {