How to use the ern-core.kax.task 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-orchestrator / src / start.ts View on Github external
descriptor
    )
    baseComposite = baseComposite || compositeGenConfig?.baseComposite
    resolutions = compositeGenConfig?.resolutions
  }

  // Because this command can only be stoped through `CTRL+C` (or killing the process)
  // we listen for the SIGINT signal and then just exit the process
  // This is needed for tmp module to do its cleanup, otherwise the temporary directory
  // is not removed after `CTRL+C` is done
  process.on('SIGINT', () => process.exit())

  compositeDir = compositeDir || createTmpDir()
  log.trace(`Temporary composite directory is ${compositeDir}`)

  const composite = await kax
    .task(`Generating composite in ${compositeDir}`)
    .run(
      Composite.generate({
        baseComposite,
        extraJsDependencies: extraJsDependencies || undefined,
        jsApiImplDependencies: jsApiImpls,
        miniApps: miniapps!,
        outDir: compositeDir,
        resolutions,
      })
    )

  // Third party native modules
  const nativeDependencies = await composite.getNativeDependencies()
  const nativeModules: PackagePath[] = [
    ...nativeDependencies.thirdPartyInManifest,
github electrode-io / electrode-native / ern-container-gen-android / src / AndroidGenerator.ts View on Github external
public async postBundle(
    config: ContainerGeneratorConfig,
    bundle: BundlingResult
  ) {
    if (this.getJavaScriptEngine(config) === JavaScriptEngine.HERMES) {
      const hermesVersion =
        config.androidConfig.hermesVersion || android.DEFAULT_HERMES_VERSION
      const hermesCli = await kax
        .task(`Installing hermes-engine@${hermesVersion}`)
        .run(HermesCli.fromVersion(hermesVersion))
      const hermesBundle = await kax
        .task('Compiling JS bundle to Hermes bytecode')
        .run(
          hermesCli.compileReleaseBundle({ jsBundlePath: bundle.bundlePath })
        )

      if (bundle.sourceMapPath) {
        // Unfortunately Hermes binary does not give control over the
        // location of generated source map. It just generates it in
        // the same directory as the hermes bundle, with the same name
        // as the bundle, with a new .map extension.
        // We don't want to keep the generated source map in the container,
        // So if the JS bundle had an associated source map generated,
        // just overwrite it with the Hermes one ...
        shell.mv(hermesBundle.hermesSourceMapPath, bundle.sourceMapPath)
      } else {
        // ... otherwise just remove it from the container
github electrode-io / electrode-native / ern-orchestrator / src / runContainerPublishers.ts View on Github external
extra = parseJsonFromStringOrFile(extraFile.toString())
      }

      // ==================================================================
      // Legacy code. To be deprecated
      let publisherName = publisherFromCauldron.name
      if (publisherName === 'github') {
        log.warn(
          `Your Cauldron is using the 'github' publisher which has been deprecated.
Please rename 'github' publisher name to 'git' in your Cauldron to get rid of this warning.`
        )
        publisherName = 'git'
      }
      // ==================================================================

      await kax.task(`Running Container Publisher ${publisherName}`).run(
        publishContainer({
          containerPath,
          containerVersion,
          extra,
          platform: napDescriptor.platform,
          publisher: publisherName,
          url: publisherFromCauldron.url,
        })
      )
    }
    log.info(
      `Published new Container version ${containerVersion} for ${napDescriptor.toString()}`
    )
  }
}
github electrode-io / electrode-native / ern-container-gen / src / generateContainer.ts View on Github external
// Otherwise any module dependent on r-n won't be able to use it
  config.plugins = [
    ...(reactNativePlugin ? [reactNativePlugin] : []),
    ...config.plugins.filter(plugin => plugin !== reactNativePlugin),
  ]

  shell.pushd(config.outDir)
  try {
    if (fillContainerHull) {
      await fillContainerHull(config)
    }
  } finally {
    shell.popd()
  }

  const bundlingResult: BundlingResult = await kax
    .task('Bundling MiniApps')
    .run(
      bundleMiniAppsFromComposite({
        compositeDir: config.composite.path,
        outDir: config.outDir,
        platform: config.targetPlatform,
        sourceMapOutput: config.sourceMapOutput,
      })
    )

  if (postBundle) {
    await postBundle(config, bundlingResult)
  }

  if (!config.ignoreRnpmAssets) {
    copyRnpmAssets(
github electrode-io / electrode-native / ern-local-cli / src / lib / logErrorAndExitIfNotSatisfied.ts View on Github external
napDescritorDoesNotExistsInCauldron.extraErrorMessage
      )
      kaxTask.succeed()
    }
    if (publishedToNpm) {
      kaxTask = kax.task(
        'Ensuring that package(s) version(s) have been published to NPM'
      )
      await Ensure.publishedToNpm(
        publishedToNpm.obj,
        publishedToNpm.extraErrorMessage
      )
      kaxTask.succeed()
    }
    if (miniAppNotInNativeApplicationVersionContainer) {
      kaxTask = kax.task(
        'Ensuring that MiniApp(s) is/are not present in native application version container'
      )
      await Ensure.miniAppNotInNativeApplicationVersionContainer(
        miniAppNotInNativeApplicationVersionContainer.miniApp,
        miniAppNotInNativeApplicationVersionContainer.descriptor,
        miniAppNotInNativeApplicationVersionContainer.extraErrorMessage
      )
      kaxTask.succeed()
    }
    if (miniAppIsInNativeApplicationVersionContainer) {
      kaxTask = kax.task(
        'Ensuring that MiniApp(s) is/are present in native application version container'
      )
      await Ensure.miniAppIsInNativeApplicationVersionContainer(
        miniAppIsInNativeApplicationVersionContainer.miniApp,
        miniAppIsInNativeApplicationVersionContainer.descriptor,
github electrode-io / electrode-native / ern-orchestrator / src / container.ts View on Github external
sourceMapOutput,
  }: {
    outDir?: string
    ignoreRnpmAssets?: boolean
    jsMainModuleName?: string
    extra?: any
    sourceMapOutput?: string
  }
): Promise {
  try {
    const generator = getGeneratorForPlatform(platform)
    const nativeDependencies = await composite.getInjectableNativeDependencies(
      platform
    )

    return kax.task('Generating Container').run(
      generator.generate({
        androidConfig: (extra && extra.androidConfig) || {},
        composite,
        ignoreRnpmAssets,
        jsMainModuleName,
        outDir,
        plugins: nativeDependencies,
        sourceMapOutput,
        targetPlatform: platform,
      })
    )
  } catch (e) {
    log.error(`runLocalContainerGen failed: ${e}`)
    throw e
  }
}
github electrode-io / electrode-native / ern-local-cli / src / commands / create-container.ts View on Github external
baseComposite || (compositeGenConfig && compositeGenConfig.baseComposite)
  }

  if (!descriptor && miniapps) {
    platform = platform || (await askUserToSelectAPlatform())

    const composite = await kax.task('Generating Composite locally').run(
      runLocalCompositeGen(miniapps, {
        baseComposite,
        jsApiImpls,
        outDir: compositeDir,
      })
    )

    outDir = outDir || Platform.getContainerGenOutDirectory(platform)
    await kax.task('Generating Container locally').run(
      runLocalContainerGen(platform, composite, {
        extra: extraObj,
        ignoreRnpmAssets,
        outDir,
        sourceMapOutput,
      })
    )
  } else if (descriptor) {
    const composite = await kax.task('Generating Composite from Cauldron').run(
      runCauldronCompositeGen(descriptor, {
        baseComposite,
        favorGitBranches: !!fromGitBranches,
        outDir: compositeDir,
      })
    )
github electrode-io / electrode-native / ern-local-cli / src / lib / logErrorAndExitIfNotSatisfied.ts View on Github external
isNewerContainerVersion.extraErrorMessage
      )
      kaxTask.succeed()
    }
    if (noGitOrFilesystemPath) {
      kaxTask = kax.task(
        'Ensuring that not git or file system path(s) is/are used'
      )
      Ensure.noGitOrFilesystemPath(
        noGitOrFilesystemPath.obj,
        noGitOrFilesystemPath.extraErrorMessage
      )
      kaxTask.succeed()
    }
    if (noFileSystemPath) {
      kaxTask = kax.task('Ensuring that no file system path(s) is/are used')
      Ensure.noFileSystemPath(
        noFileSystemPath.obj,
        noFileSystemPath.extraErrorMessage
      )
      kaxTask.succeed()
    }
    if (napDescriptorExistInCauldron) {
      kaxTask = kax.task(
        'Ensuring that native application descriptor exists in Cauldron'
      )
      await Ensure.napDescritorExistsInCauldron(
        napDescriptorExistInCauldron.descriptor,
        napDescriptorExistInCauldron.extraErrorMessage
      )
      kaxTask.succeed()
    }
github electrode-io / electrode-native / ern-orchestrator / src / container.ts View on Github external
let pathToYarnLock
    if (!containerGenConfig || !containerGenConfig.bypassYarnLock) {
      pathToYarnLock = await cauldron.getPathToYarnLock(
        napDescriptor,
        constants.CONTAINER_YARN_KEY
      )
    } else {
      log.debug(
        'Bypassing yarn.lock usage as bypassYarnLock flag is set in Cauldron config'
      )
    }
    if (!napDescriptor.platform) {
      throw new Error(`${napDescriptor} does not specify a platform`)
    }

    return kax.task('Bundling MiniApps').run(
      bundleMiniApps(
        miniapps,
        compositeDir || createTmpDir(),
        outDir,
        napDescriptor.platform,
        {
          baseComposite,
          jsApiImplDependencies: jsApiImpls,
          pathToYarnLock: pathToYarnLock || undefined,
          resolutions,
        }
      )
    )
  } catch (e) {
    log.error(`runCauldronBundleGen failed: ${e}`)
    throw e
github electrode-io / electrode-native / ern-local-cli / src / commands / bundlestore / upload.ts View on Github external
} else {
        log.debug(
          'Bypassing yarn.lock usage as bypassYarnLock flag is set in config'
        )
      }
      const compositeGenConfig = await cauldron.getCompositeGeneratorConfig(
        descriptor
      )
      baseComposite =
        baseComposite ||
        (compositeGenConfig && compositeGenConfig.baseComposite)
      resolutions = compositeGenConfig && compositeGenConfig.resolutions
    }

    const compositeDir = createTmpDir()
    await kax.task('Generating Composite').run(
      generateComposite({
        baseComposite,
        extraJsDependencies,
        jsApiImplDependencies: jsApiImpls,
        miniApps: miniapps!,
        outDir: compositeDir,
        pathToYarnLock,
        resolutions,
      })
    )

    for (const curPlatform of platforms) {
      const outDir = createTmpDir()
      const bundlePath = path.join(outDir, 'index.bundle')
      const sourceMapPath = path.join(outDir, 'index.map')
      await kax.task(`Bundling MiniApps for ${curPlatform}`).run(