{"size": 2018, "ext": "js", "max_stars_repo_path": "src/core/fileWriter.js", "max_stars_repo_name": "sntsabode/expo-ts-init", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/core/fileWriter.js", "max_issues_repo_name": "sntsabode/expo-ts-init", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/core/fileWriter.js", "max_forks_repo_name": "sntsabode/expo-ts-init", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.6764705882, "max_line_length": 89, "alphanum_fraction": 0.6823587711}
const { writeFileSync, mkdirSync } = require('fs')
const { join } = require('path')
const commonStyles = require('../files/commonStyles')
const components = require('../files/components')
const reactnavigation = require('../files/reactnavigation')
const redux = require('../files/redux')

class FileWriter {
  cwd

  /**
   * @param {String} cwd
   */
  constructor(cwd) {
    this.cwd = cwd
  }

  writeApp() {
    writeFileSync(join(this.cwd, 'App.tsx'), components.app)
  }

  writeReduxFiles() {
    const hooksDir = join(this.cwd, 'src', 'app', 'hooks', 'redux')
    mkdirSync(hooksDir, { recursive: true })

    const storeDir = join(this.cwd, 'src', 'app', 'store')
    mkdirSync(storeDir, { recursive: true })

    const dummyReducerDir = join(this.cwd, 'src', 'app', 'reducers', 'dummy')
    mkdirSync(dummyReducerDir, { recursive: true })

    writeFileSync(join(hooksDir, 'index.ts'), redux.hooks)
    writeFileSync(join(storeDir, 'index.ts'), redux.store)
    writeFileSync(join(dummyReducerDir, 'index.ts'), redux.dummyReducer)
  }

  writeReactNavigation() {
    const navigationStackDir = join(this.cwd, 'src', 'navigationStack')
    mkdirSync(navigationStackDir, { recursive: true })

    const screensDir = join(this.cwd, 'src', 'screens')

    const homeDir = join(screensDir, 'Home')
    mkdirSync(homeDir, { recursive: true })

    writeFileSync(join(navigationStackDir, 'index.tsx'), reactnavigation.navigationStack)
    writeFileSync(join(homeDir, 'index.tsx'), reactnavigation.homeScreen)
  }

  writeComponents() {
    const componentsDir = join(this.cwd, 'src', 'components')

    const goodluckDir = join(componentsDir, 'Goodluck')
    mkdirSync(goodluckDir, { recursive: true })

    writeFileSync(join(goodluckDir, 'index.tsx'), components.goodluck)
  }

  writeCommonStyles() {
    const stylesDir = join(this.cwd, 'src', 'styles')
    mkdirSync(stylesDir, { recursive: true })

    writeFileSync(join(stylesDir, 'index.ts'), commonStyles.commonStyles)
  }
}

exports.default = FileWriter
