UNPKG

@appshuttle.io/turing

Version:
66 lines (47 loc) 1.93 kB
const fs = require('fs') const crypto = require('crypto') const BuildGradleTemplates = require('../TemplateContent/BuildGradle-Template') class BuildGradleMotor { constructor(path, project, screenPointers, screens) { if (!path) throw new Error('No pbxproj path is specified') if (!project) throw new Error('No project is specified') if (!screenPointers) throw new Error('No screen pointers were specified') if (!screens) throw new Error('No screens were specified') this.path = path this.project = project this.screenPointers = screenPointers this.screens = screens this.gradleContent = '' this.templates = new BuildGradleTemplates() this.generateBuildGradle = function () { this.generateGradleStructure() const context = this return new Promise((resolve, reject) => { try { fs.writeFileSync(context.path, context.gradleContent) resolve() } catch (error) { reject(error) } }) } /* GENERATION METHODS */ this.generateGradleStructure = function () { this.gradleContent = this.templates.getBuildGradleStructure() this.gradleContent = this.gradleContent.replace(new RegExp(this.templates.REPOSITORIES_HOLDER, 'g'), this.getGradleRepositories()) this.gradleContent = this.gradleContent.replace(this.templates.GRADLE_VERSION_HOLDER, this.getGradleVersion()) } /* CONTENT PRODUCERS */ this.getGradleRepositories = function () { return this.templates.REPOSITORIES_DEFAULT } this.getGradleVersion = function () { return this.templates.GRADLE_VERSION_DEFAULT } } } module.exports = BuildGradleMotor