UNPKG

@appshuttle.io/turing

Version:
82 lines (69 loc) 3.14 kB
const fs = require('fs') var shell = require('shelljs') var nodePath = process.execPath ? process.execPath : (which('node') || which('nodejs')) shell.config.execPath = nodePath.stdout const ncp = require('ncp').ncp const AndroidMainProjectGenerator = require('./AndroidGenerators/AndroidMainProjectGenerator') class AndroidBuilder { constructor(exportPath, project, screenPointers, screens) { if (!exportPath) throw new Error('No shuttle project 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 = exportPath + '/Android' this.project = project this.screenPointers = screenPointers this.screens = screens this.AndroidSDKLocation = '/AppData/Local/Android/sdk/tools' this.ANDROID_BUILD_COMMAND = './gradlew build'; this.AndroidMainProjectGenerator = new AndroidMainProjectGenerator(this.path + '/' + this.project.name, this.project, this.screenPointers, this.screens) this.generateAndroidProject = function (success, error) { try { if (!fs.existsSync(this.path)) { fs.mkdirSync(this.path); } var context = this; ncp('C:/Users/danie/Dropbox/Trabajo/AppShuttle/Shuttle-Turing/Android/Template', this.path + '/' + this.project.name, function (err) { if (err) { return console.error(err); } console.log('done!'); var generationPromises = [] generationPromises.push(context.AndroidMainProjectGenerator.generateMainProject()) Promise.all(generationPromises).then(function (values) { success() }).catch(function (err) { error(err) }) }); } catch (err) { console.log(err) return } } this.buildAndroidEnv = function (success, error) { this.checkAndroidBuildEnvironment(function () { console.log('Environment OK') success() }, function (err) { console.log(err) error(err) }) } this.checkAndroidBuildEnvironment = function (success, error) { // if (!shell.which('./gradlew')) { // shell.echo('Sorry, this script requires gradlew for building') // shell.exit(1) // error('Sorry, this script requires gradlew for building') // retur // } return true; } this.getAndroidSdkPath = function () { //TODO get user folder with code return 'C:/Users/danie' + this.AndroidSDKLocation } } } module.exports = AndroidBuilder