How to use the ern-core.shell.cd 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-api-impl-gen / src / generators / ApiImplGen.js View on Github external
async downloadApiAndDependencies (apiPackagePath: PackagePath, path: string, reactNativeVersion: string) {
    try {
      shell.cd(path)

      await this.spinAndDownload(apiPackagePath)
      plugins = await this.getDependencies(apiPackagePath)
      plugins.push(apiPackagePath)// Also add the api as a plugin so it's src files will get copied.
      if (plugins) {
        log.info('Downloading dependencies')
        for (let dependency of plugins) {
          await this.spinAndDownload(dependency)
        }
      }
      log.debug('Downloading react-native dependency')
      await this.spinAndDownload(new PackagePath(`react-native@${reactNativeVersion}`))
    } catch (e) {
      throw new Error(`Api dependency download failed: ${e}`)
    }
  }
github electrode-io / electrode-native / ern-container-gen / src / generators / android / AndroidGenerator.ts View on Github external
public async fillContainerHull(
    config: ContainerGeneratorConfig
  ): Promise {
    try {
      log.debug('[=== Starting container hull filling ===]')

      shell.cd(ROOT_DIR)

      const copyFromPath = path.join(PATH_TO_HULL_DIR, '{.*,*}')

      shell.cp('-R', copyFromPath, config.outDir)

      // https://github.com/npm/npm/issues/1862 : Npm renames .gitigonre to .npmignore causing the generated contaier to emit the .gitnore file. This solution below helps to bypass it.
      shell.mv(`${config.outDir}/gitignore`, `${config.outDir}/.gitignore`)

      const reactNativePlugin = _.find(
        config.plugins,
        p => p.basePath === 'react-native'
      )
      if (!reactNativePlugin) {
        throw new Error('react-native was not found in plugins list !')
      }
      if (!reactNativePlugin.version) {
github electrode-io / electrode-native / ern-api-impl-gen / src / ApiImpl.js View on Github external
async function createNodePackage (
  outputDirectoryPath: string,
  apiDependency: PackagePath,
  apiImplName: string,
  packageName: string,
  scope? : string,
  nativeOnly: boolean,
  hasConfig: boolean) {
  let currentDirectory = process.cwd()
  shell.cd(outputDirectoryPath)
  await yarn.init()
  await yarn.add(apiDependency)
  shell.cp(path.join(Platform.currentPlatformVersionPath, 'ern-api-impl-gen', 'resources', 'gitignore'), path.join(outputDirectoryPath, '.gitignore'))
  ernifyPackageJson(outputDirectoryPath, apiImplName, packageName, scope, nativeOnly, hasConfig)
  shell.cd(currentDirectory)
}
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.js View on Github external
async fillHull (apiDependency: PackagePath,
                  paths: Object,
                  reactNativeVersion: string,
                  pluginsPaths: Array,
                  apis: Array) {
    try {
      log.debug(`[=== Starting hull filling for api impl gen for ${this.platform} ===]`)

      shell.cd(ROOT_DIR)

      const outputDirectory = path.join(paths.outDirectory, 'android')
      log.debug(`Creating out directory(${outputDirectory}) for android and copying container hull to it.`)
      if (!fs.existsSync(outputDirectory)) {
        shell.mkdir(outputDirectory)
      }

      fileUtils.chmodr(READ_WRITE_EXECUTE, outputDirectory)
      shell.cp('-Rf', path.join(paths.apiImplHull, 'android', '{.*,*}'), outputDirectory)

      const srcOutputDirectory = path.join(outputDirectory, 'lib', SRC_MAIN_JAVA_DIR)
      for (let pluginPath: PackagePath of pluginsPaths) {
        log.debug(`Copying ${pluginPath.basePath} to ${outputDirectory}`)
        await manifest.getPluginConfig(pluginPath).then((pluginConfig) => {
          this.copyPluginToOutput(paths, srcOutputDirectory, pluginPath, pluginConfig)
        })
github electrode-io / electrode-native / ern-container-gen / src / generators / ios / IosGenerator.js View on Github external
async buildApiImplPluginViews (plugins: Array,
                                 mustacheView: Object,
                                 pathSpec: Object,
                                 projectSpec: Object) {
    for (const plugin of plugins) {
      const pluginConfig = await manifest.getPluginConfig(plugin, projectSpec.projectName)
      shell.cd(pathSpec.pluginsDownloadDirectory)
      if (await utils.isDependencyApiImpl(plugin.basePath)) {
        const pluginSourcePath = await utils.downloadPluginSource(pluginConfig.origin)
        populateApiImplMustacheView(pluginSourcePath, mustacheView, true)
      }
    }

    if (mustacheView.apiImplementations) {
      mustacheView.hasApiImpl = true
      for (const api of mustacheView.apiImplementations) {
        if (api.hasConfig) {
          mustacheView.hasAtleastOneApiImplConfig = true
          break
        }
      }
    }
  }
github electrode-io / electrode-native / ern-container-gen / src / generators / ios / IosGenerator.ts View on Github external
public async buildApiImplPluginViews(
    plugins: PackagePath[],
    mustacheView: any,
    pathSpec: any,
    projectSpec: any
  ) {
    for (const plugin of plugins) {
      const pluginConfig = await manifest.getPluginConfig(
        plugin,
        projectSpec.projectName
      )
      shell.cd(pathSpec.pluginsDownloadDirectory)
      if (await utils.isDependencyApiImpl(plugin.basePath)) {
        const pluginSourcePath = await utils.downloadPluginSource(
          pluginConfig.origin
        )
        populateApiImplMustacheView(pluginSourcePath, mustacheView, true)
      }
    }

    if (mustacheView.apiImplementations) {
      mustacheView.hasApiImpl = true
      for (const api of mustacheView.apiImplementations) {
        if (api.hasConfig) {
          mustacheView.hasAtleastOneApiImplConfig = true
          break
        }
      }
github electrode-io / electrode-native / ern-container-gen / src / generators / android / AndroidGenerator.ts View on Github external
pluginSourcePath = await coreUtils.downloadPluginSource(
          pluginConfig.origin
        )
        if (!pluginSourcePath) {
          throw new Error(`Was not able to download ${plugin.basePath}`)
        }

        if (await coreUtils.isDependencyNativeApiImpl(plugin.basePath)) {
          populateApiImplMustacheView(pluginSourcePath, mustacheView, true)
        }

        const pathToPluginProject = path.join(
          pluginSourcePath,
          pluginConfig.android.root
        )
        shell.cd(pathToPluginProject)

        const relPathToPluginSource = pluginConfig.android.moduleName
          ? path.join(pluginConfig.android.moduleName, 'src', 'main', 'java')
          : path.join('src', 'main', 'java')
        const absPathToCopyPluginSourceTo = path.join(
          config.outDir,
          'lib',
          'src',
          'main'
        )
        shell.cp('-R', relPathToPluginSource, absPathToCopyPluginSourceTo)

        if (pluginConfig.android) {
          if (pluginConfig.android.copy) {
            handleCopyDirective(
              pluginSourcePath,