From a21e226b68b1a7224cf6f8925dac6ac2bee80e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Bigio?= Date: Tue, 13 Oct 2015 12:06:20 -0700 Subject: [PATCH] Remove `install` command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public The implementation wasn't working. Lets remove this for now and revisit if we trully want to support this. Reviewed By: @frantic Differential Revision: D2536442 fb-gh-sync-id: 4aca2d1d2584cd15ac855d69e6e9a5a08abf778e --- local-cli/__tests__/install-test.js | 47 ---------- local-cli/cli.js | 5 -- local-cli/install.js | 133 ---------------------------- 3 files changed, 185 deletions(-) delete mode 100644 local-cli/__tests__/install-test.js delete mode 100644 local-cli/install.js diff --git a/local-cli/__tests__/install-test.js b/local-cli/__tests__/install-test.js deleted file mode 100644 index bfecc2e25..000000000 --- a/local-cli/__tests__/install-test.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -jest.dontMock('../install'); -jest.dontMock('fs'); -jest.dontMock('path'); - -var install = require('../install.js'); - -var openingReactTag = '#'; -var closingReactTag = '#'; - -var fs = require.requireActual('fs'); -var path = require.requireActual('path'); - -process.chdir(__dirname); - -describe('setup Podfile', function() { - - it('creates a Podfile if none exists', function() { - try { - fs.unlinkSync(path.resolve(__dirname, '../Podfile')); - } catch(e) {} - - var setupPodfile = install.setupPodfile(); - - expect(setupPodfile.created).toBe(true); - }); - - it('does not create Podfile if one exists', function() { - var setupPodfile = install.setupPodfile(); - expect(setupPodfile.created).toBe(false); - }); - - it('includes React Native Tags', function() { - var setupPodfile = install.setupPodfile(); - - expect(setupPodfile.podfileText).toContain(openingReactTag); - expect(setupPodfile.podfileText).toContain(closingReactTag); - - // cleanup - try { - fs.unlinkSync(path.resolve(__dirname, '../Podfile')); - } catch(e) { - throw new Error('failed to cleanup Podfile', e); - } - }); -}); diff --git a/local-cli/cli.js b/local-cli/cli.js index 7258be6ed..35106f6e5 100644 --- a/local-cli/cli.js +++ b/local-cli/cli.js @@ -10,7 +10,6 @@ var Config = require('../private-cli/src/util/Config'); var fs = require('fs'); var generateAndroid = require('./generate-android.js'); var init = require('./init.js'); -var install = require('./install.js'); var newLibrary = require('./new-library.js'); var runAndroid = require('./run-android.js'); var runPackager = require('./run-packager.js'); @@ -21,7 +20,6 @@ function printUsage() { '', 'Commands:', ' start: starts the webserver', - ' install: installs npm react components', ' bundle: builds the javascript bundle for offline use', ' new-library: generates a native library bridge', ' android: generates an Android project for your app' @@ -47,9 +45,6 @@ function run() { case 'start': runPackager(); break; - case 'install': - install.init(); - break; case 'bundle': bundle(args, Config.get(__dirname)).done(); // bundle_DEPRECATED.init(args); diff --git a/local-cli/install.js b/local-cli/install.js deleted file mode 100644 index 63e763667..000000000 --- a/local-cli/install.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - */ - - 'use strict'; - -var fs = require('fs'); -var path = require('path'); -var exec = require('child_process').exec; - -var NODE_MODULE_PATH = path.resolve(__dirname, 'node_modules'); - -var PODFILE_PATH = path.resolve(__dirname, 'Podfile'); - -function addDependency(name, path) { - console.log('Found dependency: ' + name); - - var podfileText; - try { - podfileText = fs.readFileSync(PODFILE_PATH, 'utf8'); - } catch(e) {} - - if (podfileText.indexOf('pod \'' + name + '\'') === -1) { - var indexOfReactComponents = podfileText.indexOf('#') - 1; - - var insertedDependency = '\npod \'' + name + '\', :path => \'' + path + '\'\n'; - var newPodfileText = [podfileText.slice(0, indexOfReactComponents), - insertedDependency, - podfileText.slice(indexOfReactComponents)].join(''); - - fs.writeFileSync(PODFILE_PATH, newPodfileText); - console.log('Added ' + name + ' to Podfile.'); - } else { - console.log(name + ' already in Podfile'); - } -} - -function installDependecies() { - console.log('Installing dependencies...'); - exec('pod install', function(error, stdout, stderr) { - if (!stderr) { - console.log('Installed Pod dependencies.'); - } else { - console.error('Error installing Pod dependencies.', stderr); - } - process.exit(1); - }); -} - -module.exports = { - setupPodfile: function() { - var returnArgs = { - created: false - }; - - var podfileText; - try { - podfileText = fs.readFileSync(PODFILE_PATH, 'utf8'); - } catch(e) {} - - var openingReactTag = '#'; - var closingReactTag = '\n#'; - var reactPodfileBoilerplate = openingReactTag + closingReactTag; - - if (!podfileText) { - returnArgs.created = true; - fs.appendFileSync(PODFILE_PATH, reactPodfileBoilerplate); - } else { - if (podfileText.indexOf(openingReactTag) === -1 || podfileText.indexOf(closingReactTag) === -1) { - fs.appendFileSync(PODFILE_PATH, reactPodfileBoilerplate); - } - } - - try { - podfileText = fs.readFileSync(PODFILE_PATH, 'utf8'); - returnArgs.podfileText = podfileText; - } catch(e) {} - - if (podfileText.indexOf('pod \'React\'') === -1) { - var indexOfReactComponents = podfileText.indexOf(openingReactTag) + openingReactTag.length; - - var insertedReactDependency = '\npod \'React\', :path => \'node_modules/react-native\'\n'; - try { - var newPodfileText = [podfileText.slice(0, indexOfReactComponents), - insertedReactDependency, - podfileText.slice(indexOfReactComponents)].join(''); - - fs.writeFileSync(PODFILE_PATH, newPodfileText); - returnArgs.podfileText = newPodfileText; - } catch(e) { - throw e; - } - } - - return returnArgs; - }, - init: function(arguement) { - // arguement is available for future arguement commands - console.log('Searching for installable React Native components...'); - this.setupPodfile(); - - var nodeModuleList = fs.readdirSync(NODE_MODULE_PATH); - - if (nodeModuleList.length > 0) { - nodeModuleList.forEach(function(nodeModule) { - // Module would not start with '.' hidden file identifier - if (nodeModule.charAt(0) !== '.') { - var modulePath = './node_modules/' + nodeModule; - - var nodeModulePackage; - try { - nodeModulePackage = fs.readFileSync(modulePath + '/package.json', 'utf8'); - } catch(error) { - console.error('Error reading Node Module: `%s` package.json', nodeModule); - throw error; - } - - var packageJSON = JSON.parse(nodeModulePackage); - console.log(packageJSON.hasOwnProperty('react-native-component')); - if (packageJSON.hasOwnProperty('react-native-component')) { - addDependency(nodeModule, modulePath); - } - } - }); - - installDependecies(); - } else { - console.error('./node_modules directory contains 0 modules'); - console.log('No React Native components found.'); - process.exit(1); - } - } -};