From 874c15d6f63977c5b10d5d574ec88cea6609c7e1 Mon Sep 17 00:00:00 2001 From: Pranav Chauhan Date: Sat, 24 Nov 2018 17:01:17 +0530 Subject: [PATCH] - bumping version - ios: migrating to auto pod-installer --- package.json | 10 +++-- scripts/installer.js | 100 ------------------------------------------- 2 files changed, 6 insertions(+), 104 deletions(-) delete mode 100644 scripts/installer.js diff --git a/package.json b/package.json index 9160e43..1208f91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-app-tour", - "version": "0.0.17", + "version": "0.0.18", "description": "React Native: Native App Tour Library", "repository": { "type": "git", @@ -9,15 +9,17 @@ "main": "RNAppTour.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "postinstall": "node scripts/installer.js" + "postinstall": "node ../pod-installer/index.js" }, "keywords": [ "react-native" ], "author": "Pranav Raj Singh Chauhan", "license": "Apache License", - "dependencies": {}, + "dependencies": { + "pod-installer": "0.0.0" + }, "devDependencies": { - "prettier-pack": "0.0.7" + "prettier-pack": "0.0.8" } } diff --git a/scripts/installer.js b/scripts/installer.js deleted file mode 100644 index cb246cd..0000000 --- a/scripts/installer.js +++ /dev/null @@ -1,100 +0,0 @@ -const exec = require('child_process').exec - -var osvar = process.platform - -if (osvar !== 'darwin') return - -exists('pod') - .then(function(command) { - installPods() - }) - .catch(function() { - installCocoaPods().then(() => { - installPods() - }) - }) - -function installPods() { - console.log('executing pod install command') - - exec('cd ./ios && pod install', (err, stdout, stderr) => { - console.log(stderr) - - if (err === undefined || err === null) { - console.log('pod install command successfull') - return - } - - if (stdout !== undefined && stdout !== null) { - if (stdout.includes('could not find compatible versions for pod')) { - console.log('executing pod repo update command.') - - exec('pod repo update', (err, stdout, stderr) => { - if (err === undefined || err === null) { - console.log('pod repo update successfull') - - exec('cd ./ios && pod install', (err, stdout, stderr) => {}) - - return - } - - console.log(stdout) - }) - } - } else { - console.log('pod install sucessfull') - } - }) -} - -function installCocoaPods() { - console.log('installing socoapods.') - - return new Promise((resolve, reject) => { - run('sudo gem install cocoapods') - .then(() => { - console.log('sudo gem install cocoapods sucessfull') - resolve() - }) - .catch(e => { - console.log(e) - }) - }) -} - -// returns Promise which fulfills with true if command exists -function exists(cmd) { - return run(`which ${cmd}`).then(stdout => { - if (stdout.trim().length === 0) { - // maybe an empty command was supplied? - // are we running on Windows?? - return Promise.reject(new Error('No output')) - } - - const rNotFound = /^[\w\-]+ not found/g - - if (rNotFound.test(cmd)) { - return Promise.resolve(false) - } - - return Promise.resolve(true) - }) -} - -function run(command) { - return new Promise((fulfill, reject) => { - exec(command, (err, stdout, stderr) => { - if (err) { - reject(err) - return - } - - if (stderr) { - reject(new Error(stderr)) - return - } - - fulfill(stdout) - }) - }) -}