UNPKG

@appshuttle.io/turing

Version:
65 lines (46 loc) 1.78 kB
const fs = require('fs') const crypto = require('crypto') const AppManifestTemplates = require('../TemplateContent/AppManifest-Template') class AppManifestMotor { 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.mainActViewContent = '' this.templates = new AppManifestTemplates() this.generateAppManifest = function () { this.generateStructure() const context = this return new Promise((resolve, reject) => { try { fs.writeFileSync(context.path, context.mainActViewContent) resolve() } catch (error) { reject(error) } }) } /* GENERATION METHODS */ this.generateStructure = function () { this.mainActViewContent = this.templates.getAppManifestStructure() this.mainActViewContent = this.mainActViewContent.replace(this.templates.PACKAGE_HOLDER, this.getPackage()) } /* CONTENT PRODUCERS */ this.getPackage = function () { return 'com.appshuttle.' + this.getProjectName() } this.getProjectName = function () { return this.project.name.trim().toLowerCase() } } } module.exports = AppManifestMotor