UNPKG

@appshuttle.io/turing

Version:
61 lines (43 loc) 1.7 kB
const fs = require('fs') const crypto = require('crypto') const LocalPropertiesTemplates = require('../TemplateContent/LocalProperties-Template') class LocalPropertiesMotor { 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.localPropsContent = '' this.templates = new LocalPropertiesTemplates() this.generateLocalProperties = function () { this.generateLocalPropsStructure() const context = this return new Promise((resolve, reject) => { try { fs.writeFileSync(context.path, context.localPropsContent) resolve() } catch (error) { reject(error) } }) } /* GENERATION METHODS */ this.generateLocalPropsStructure = function () { this.localPropsContent = this.templates.getLocalPropertiesStructure() this.localPropsContent = this.localPropsContent.replace(this.templates.SDK_DIR_HOLDER, this.getSdkUrl()) } /* CONTENT PRODUCERS */ this.getSdkUrl = function () { return this.templates.SDK_DIR_DEFAULT } } } module.exports = LocalPropertiesMotor