How to use ern-cauldron-api - 10 common examples

To help you get started, we’ve selected a few ern-cauldron-api 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 / syncCauldronContainer.ts View on Github external
}: {
    containerVersion?: string
    sourceMapOutput?: string
  } = {}
) {
  if (!descriptor.platform) {
    throw new Error(`${descriptor} does not specify a platform`)
  }

  const platform = descriptor.platform
  const outDir = Platform.getContainerGenOutDirectory(platform)
  let cauldronContainerNewVersion
  let cauldron

  try {
    cauldron = await getActiveCauldron()

    // ================================================================
    // Set new Container version
    // ================================================================
    if (containerVersion) {
      cauldronContainerNewVersion = containerVersion
    } else {
      const detachContainerVersionFromRoot = await cauldron.getConfigForKey(
        'detachContainerVersionFromRoot',
        descriptor
      )
      cauldronContainerNewVersion = detachContainerVersionFromRoot
        ? await cauldron.getContainerVersion(descriptor)
        : await cauldron.getTopLevelContainerVersion(descriptor)
      if (cauldronContainerNewVersion) {
        cauldronContainerNewVersion = semver.inc(
github electrode-io / electrode-native / ern-orchestrator / src / gitHub.ts View on Github external
export async function getGitHubApi({
  owner,
  repo,
}: {
  owner: string
  repo: string
}) {
  if (!process.env.ERN_GITHUB_TOKEN) {
    throw new Error('ERN_GITHUB_TOKEN environment variable must be set')
  }
  const cauldron = await getActiveCauldron()
  const gitHubConfig = await cauldron.getGitHubConfig()
  const opts: any = {
    auth: `token ${process.env.ERN_GITHUB_TOKEN}`,
  }
  if (gitHubConfig && gitHubConfig.baseUrl) {
    opts.baseUrl = gitHubConfig.baseUrl
  }
  return new GitHubApi({
    opts,
    owner,
    repo,
  })
}
github electrode-io / electrode-native / ern-orchestrator / src / performContainerStateUpdateInCauldron.ts View on Github external
containerVersion?: string
    forceFullGeneration?: boolean
    publishUnmodifiedContainer?: boolean
  } = {}
) {
  if (!napDescriptor.platform) {
    throw new Error(`${napDescriptor} does not specify a platform`)
  }

  const platform = napDescriptor.platform
  let outDir = Platform.getContainerGenOutDirectory(platform)
  let cauldronContainerNewVersion
  let cauldron

  try {
    cauldron = await getActiveCauldron()

    const currentContainerVersion = await cauldron.getContainerVersion(
      napDescriptor
    )

    if (containerVersion) {
      cauldronContainerNewVersion = containerVersion
    } else {
      const napVersion: CauldronNativeAppVersion = await cauldron.getDescriptor(
        napDescriptor
      )
      cauldronContainerNewVersion = napVersion.detachContainerVersionFromRoot
        ? await cauldron.getContainerVersion(napDescriptor)
        : await cauldron.getTopLevelContainerVersion(napDescriptor)
      if (cauldronContainerNewVersion) {
        cauldronContainerNewVersion = semver.inc(
github electrode-io / electrode-native / ern-local-cli / src / lib / Ensure.js View on Github external
static async napDescritorDoesNotExistsInCauldron (
    napDescriptor: string,
    extraErrorMessage: string = '') {
    const cauldron = await getActiveCauldron()
    const descriptor = NativeApplicationDescriptor.fromString(napDescriptor)
    if (await cauldron.isDescriptorInCauldron(descriptor)) {
      throw new Error(`${descriptor.toString()} descriptor exist in Cauldron.\n${extraErrorMessage}`)
    }
  }
github electrode-io / electrode-native / ern-local-cli / src / lib / Ensure.js View on Github external
static async dependencyIsInNativeApplicationVersionContainerWithDifferentVersion (
    obj: string | Array | void,
    napDescriptor: NativeApplicationDescriptor,
    extraErrorMessage: string = '') {
    if (!obj) return
    const cauldron = await getActiveCauldron()
    await this.dependencyIsInNativeApplicationVersionContainer(obj, napDescriptor)
    const dependenciesStrings = obj instanceof Array ? obj : [ obj ]
    for (const dependencyString of dependenciesStrings) {
      const dependencyFromCauldron = await cauldron.getContainerNativeDependency(napDescriptor,
        PackagePath.fromString(dependencyString).basePath)
      if (dependencyFromCauldron && dependencyFromCauldron.version === PackagePath.fromString(dependencyString).version) {
        throw new Error(`${PackagePath.fromString(dependencyString).basePath} is already at version ${dependencyFromCauldron.version || 'undefined'} in ${napDescriptor.toString()}.\n${extraErrorMessage}`)
      }
    }
  }
github electrode-io / electrode-native / ern-orchestrator / src / Ensure.ts View on Github external
public static async dependencyNotInNativeApplicationVersionContainer(
    obj: string | PackagePath | Array | void,
    napDescriptor: AppVersionDescriptor,
    extraErrorMessage: string = ''
  ) {
    if (!obj) {
      return
    }
    const cauldron = await getActiveCauldron()
    const dependencies = coreUtils.coerceToPackagePathArray(obj)
    for (const dependency of dependencies) {
      if (
        await cauldron.isNativeDependencyInContainer(
          napDescriptor,
          dependency.basePath
        )
      ) {
        throw new Error(
          `${
            dependency.basePath
          } dependency exists in ${napDescriptor.toString()}.\n${extraErrorMessage}`
        )
      }
    }
  }
github electrode-io / electrode-native / ern-orchestrator / src / codepush.ts View on Github external
}: {
    baseComposite?: PackagePath
    codePushIsMandatoryRelease?: boolean
    codePushRolloutPercentage?: number
    description?: string
    disableDuplicateReleaseError?: boolean
    force?: boolean
    pathToYarnLock?: string
    sourceMapOutput?: string
    targetBinaryVersion?: string
  } = {}
) {
  let cauldron
  try {
    const codePushSdk = getCodePushSdk()
    cauldron = await getActiveCauldron()
    const plugins = await cauldron.getNativeDependencies(napDescriptor)
    const compositeGenConfig = await cauldron.getCompositeGeneratorConfig(
      napDescriptor
    )
    baseComposite = baseComposite ?? compositeGenConfig?.baseComposite
    await cauldron.beginTransaction()
    const codePushPlugin = _.find(
      plugins,
      p => p.basePath === 'react-native-code-push'
    )
    if (!codePushPlugin) {
      throw new Error('react-native-code-push plugin is not in native app !')
    }

    const tmpWorkingDir = createTmpDir()
github electrode-io / electrode-native / ern-local-cli / src / lib / Ensure.js View on Github external
static async miniAppNotInNativeApplicationVersionContainer (
    obj: string | Array | void,
    napDescriptor: NativeApplicationDescriptor,
    extraErrorMessage: string = '') {
    if (!obj) return
    const cauldron = await getActiveCauldron()
    const miniAppsStrings = obj instanceof Array ? obj : [ obj ]
    for (const miniAppString of miniAppsStrings) {
      const basePathMiniAppString = PackagePath.fromString(miniAppString).basePath
      if (await cauldron.isMiniAppInContainer(napDescriptor, basePathMiniAppString)) {
        throw new Error(`${basePathMiniAppString} MiniApp exists in ${napDescriptor.toString()}.\n${extraErrorMessage}`)
      }
    }
  }
github electrode-io / electrode-native / ern-orchestrator / src / container.ts View on Github external
export async function runCaudronBundleGen(
  napDescriptor: AppVersionDescriptor,
  {
    baseComposite,
    compositeDir,
    outDir,
    resolutions,
  }: {
    baseComposite?: PackagePath
    compositeDir?: string
    outDir: string
    resolutions?: { [pkg: string]: string }
  }
): Promise {
  try {
    const cauldron = await getActiveCauldron()
    const compositeGenConfig = await cauldron.getCompositeGeneratorConfig(
      napDescriptor
    )
    baseComposite =
      baseComposite || (compositeGenConfig && compositeGenConfig.baseComposite)
    const miniapps = await cauldron.getContainerMiniApps(napDescriptor)
    const jsApiImpls = await cauldron.getContainerJsApiImpls(napDescriptor)
    const containerGenConfig = await cauldron.getContainerGeneratorConfig(
      napDescriptor
    )
    let pathToYarnLock
    if (!containerGenConfig || !containerGenConfig.bypassYarnLock) {
      pathToYarnLock = await cauldron.getPathToYarnLock(
        napDescriptor,
        constants.CONTAINER_YARN_KEY
      )
github electrode-io / electrode-native / ern-local-cli / src / commands / cauldron / repo / use.ts View on Github external
export const commandHandler = async ({ alias }: { alias: string }) => {
  cauldronRepositories.activate({ alias })
  log.info(`${alias} Cauldron is now activated`)
}