Rewrite 'react-native init' and 'react-native upgrade' without using Yeoman in preparation for templates support

Summary:
This is the manually imported version of https://github.com/facebook/react-native/pull/10786

This was mostly straigthforward by replacing the local-cli folder with the version I had in my local git checkout,
plus a few other files I listed with git diff --name-only.

Reviewed By: hramos

Differential Revision: D4201118

fbshipit-source-id: 4d0fb54b0edda9de1abba427958e420fd2ac105c
This commit is contained in:
Martin Konicek 2016-11-18 18:25:02 -08:00 committed by Facebook Github Bot
parent eddc2c90f6
commit a477aec10d
69 changed files with 723 additions and 1889 deletions

View File

@ -2,8 +2,8 @@
; We fork some components by platform
.*/*[.]android.js
; Ignore generators because they are not real JS files
.*/local-cli/generator/templates/.*
; Ignore templates for 'react-native init'
.*/local-cli/templates/.*
; Ignore the website subdir
<PROJECT_ROOT>/website/.*

View File

@ -1,268 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
jest.autoMockOff();
var path = require('path');
var fs = require('fs');
// eslint-disable-next-line improperly-disabled-jasmine-tests
xdescribe('React Yeoman Generators', function() {
describe('react:react', function() {
var assert;
beforeEach(function() {
// A deep dependency of yeoman spams console.log with giant json objects.
// yeoman-generator/node_modules/
// download/node_modules/
// caw/node_modules/
// get-proxy/node_modules/
// rc/index.js
var log = console.log;
console.log = function() {};
assert = require('yeoman-generator').assert;
var helpers = require('yeoman-generator').test;
console.log = log;
var generated = false;
runs(function() {
helpers.run(path.resolve(__dirname, '../generator'))
.withArguments(['TestApp'])
.on('end', function() {
generated = true;
});
});
waitsFor(function() {
jest.runAllTicks();
jest.runOnlyPendingTimers();
return generated;
}, 'generation', 750);
});
it('creates files', function() {
assert.file([
'.flowconfig',
'.gitignore',
'.watchmanconfig',
'index.ios.js',
'index.android.js'
]);
});
it('replaces vars in index.ios.js', function() {
assert.fileContent('index.ios.js', 'var TestApp = React.createClass({');
assert.fileContent(
'index.ios.js',
'AppRegistry.registerComponent(\'TestApp\', () => TestApp);'
);
assert.noFileContent('index.ios.js', '<%= name %>');
});
it('replaces vars in index.android.js', function() {
assert.fileContent('index.android.js', 'var TestApp = React.createClass({');
assert.fileContent(
'index.android.js',
'AppRegistry.registerComponent(\'TestApp\', () => TestApp);'
);
assert.noFileContent('index.ios.js', '<%= name %>');
});
it('composes with ios generator', function() {
var stat = fs.statSync('ios');
expect(stat.isDirectory()).toBe(true);
});
it('composes with android generator', function() {
var stat = fs.statSync('android');
expect(stat.isDirectory()).toBe(true);
});
});
describe('react:android', function () {
var assert;
beforeEach(function (done) {
// A deep dependency of yeoman spams console.log with giant json objects.
// yeoman-generator/node_modules/
// download/node_modules/
// caw/node_modules/
// get-proxy/node_modules/
// rc/index.js
var log = console.log;
console.log = function() {};
assert = require('yeoman-generator').assert;
var helpers = require('yeoman-generator').test;
console.log = log;
var generated = false;
runs(function() {
helpers.run(path.resolve(__dirname, '..', 'generator-android'))
.withArguments(['TestAppAndroid'])
.withOptions({
'package': 'com.reactnative.test',
})
.on('end', function() {
generated = true;
});
});
waitsFor(function() {
jest.runAllTicks();
jest.runOnlyPendingTimers();
return generated;
}, 'generation', 750);
});
it('creates files', function () {
assert.file([
path.join('android', 'build.gradle'),
path.join('android', 'gradle.properties'),
path.join('android', 'gradlew.bat'),
path.join('android', 'gradlew'),
path.join('android', 'settings.gradle'),
path.join('android', 'app', 'build.gradle'),
path.join('android', 'app', 'proguard-rules.pro'),
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-hdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-mdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-xhdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'mipmap-xxhdpi', 'ic_launcher.png'),
path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
path.join('android', 'app', 'src', 'main', 'res', 'values', 'styles.xml'),
path.join('android', 'gradle', 'wrapper', 'gradle-wrapper.jar'),
path.join('android', 'gradle', 'wrapper', 'gradle-wrapper.properties')
]);
});
it('replaces variables', function() {
assert.fileContent(path.join('android', 'app', 'build.gradle'), 'applicationId "com.reactnative.test"');
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
'package="com.reactnative.test"'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'AndroidManifest.xml'),
'name=".MainActivity"'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
'package com.reactnative.test;'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'java', 'com', 'reactnative', 'test', 'MainActivity.java'),
'mReactRootView.startReactApplication(mReactInstanceManager, "TestAppAndroid", null);'
);
assert.fileContent(
path.join('android', 'app', 'src', 'main', 'res', 'values', 'strings.xml'),
'<string name="app_name">TestAppAndroid</string>'
);
});
});
describe('react:ios', function() {
var assert;
beforeEach(function() {
// A deep dependency of yeoman spams console.log with giant json objects.
// yeoman-generator/node_modules/
// download/node_modules/
// caw/node_modules/
// get-proxy/node_modules/
// rc/index.js
var log = console.log;
console.log = function() {};
assert = require('yeoman-generator').assert;
var helpers = require('yeoman-generator').test;
console.log = log;
var generated = false;
runs(function() {
helpers.run(path.resolve(__dirname, '../generator-ios'))
.withArguments(['TestAppIOS'])
.on('end', function() {
generated = true;
});
});
waitsFor(function() {
jest.runAllTicks();
jest.runOnlyPendingTimers();
return generated;
}, 'generation', 750);
});
it('creates files', function() {
assert.file([
'ios/TestAppIOS/AppDelegate.h',
'ios/TestAppIOS/AppDelegate.m',
'ios/TestAppIOS/Base.lproj/LaunchScreen.xib',
'ios/TestAppIOS/Images.xcassets/AppIcon.appiconset/Contents.json',
'ios/TestAppIOS/Info.plist',
'ios/TestAppIOS/main.m',
'ios/TestAppIOS.xcodeproj/project.pbxproj',
'ios/TestAppIOS.xcodeproj/xcshareddata/xcschemes/TestAppIOS.xcscheme',
'ios/TestAppIOSTests/TestAppIOSTests.m',
'ios/TestAppIOSTests/Info.plist'
]);
});
it('replaces vars in AppDelegate.m', function() {
var appDelegate = 'ios/TestAppIOS/AppDelegate.m';
assert.fileContent(appDelegate, 'moduleName:@"TestAppIOS"');
assert.noFileContent(appDelegate, '<%= name %>');
});
it('replaces vars in LaunchScreen.xib', function() {
var launchScreen = 'ios/TestAppIOS/Base.lproj/LaunchScreen.xib';
assert.fileContent(launchScreen, 'text="TestAppIOS"');
assert.noFileContent(launchScreen, '<%= name %>');
});
it('replaces vars in TestAppIOSTests.m', function() {
var tests = 'ios/TestAppIOSTests/TestAppIOSTests.m';
assert.fileContent(tests, '@interface TestAppIOSTests : XCTestCase');
assert.fileContent(tests, '@implementation TestAppIOSTests');
assert.noFileContent(tests, '<%= name %>');
});
it('replaces vars in project.pbxproj', function() {
var pbxproj = 'ios/TestAppIOS.xcodeproj/project.pbxproj';
assert.fileContent(pbxproj, '"TestAppIOS"');
assert.fileContent(pbxproj, '"TestAppIOSTests"');
assert.fileContent(pbxproj, 'TestAppIOS.app');
assert.fileContent(pbxproj, 'TestAppIOSTests.xctest');
assert.noFileContent(pbxproj, '<%= name %>');
});
it('replaces vars in xcscheme', function() {
var xcscheme = 'ios/TestAppIOS.xcodeproj/xcshareddata/xcschemes/TestAppIOS.xcscheme';
assert.fileContent(xcscheme, '"TestAppIOS"');
assert.fileContent(xcscheme, '"TestAppIOS.app"');
assert.fileContent(xcscheme, 'TestAppIOS.xcodeproj');
assert.fileContent(xcscheme, '"TestAppIOSTests.xctest"');
assert.fileContent(xcscheme, '"TestAppIOSTests"');
assert.noFileContent(xcscheme, '<%= name %>');
});
});
});

View File

@ -1,38 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var fs = require('fs');
var generate = require('../generate/generate');
function android(argv, config, args) {
return generate([
'--platform', 'android',
'--project-path', process.cwd(),
'--project-name', args.projectName,
], config);
}
module.exports = {
name: 'android',
description: 'creates an empty android project',
func: android,
options: [{
command: '--project-name [name]',
default: () => {
try {
return JSON.parse(
fs.readFileSync('package.json', 'utf8')
).name;
} catch (e) {
return 'unknown-app-name';
}
},
}],
};

View File

@ -36,7 +36,6 @@ export type Command = {
};
const documentedCommands = [
require('./android/android'),
require('./server/server'),
require('./runIOS/runIOS'),
require('./runAndroid/runAndroid'),

View File

@ -1,31 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var path = require('path');
var yeoman = require('yeoman-environment');
/**
* Simple utility for running the android yeoman generator.
*
* @param {String} projectDir root project directory (i.e. contains index.js)
* @param {String} name name of the root JS module for this app
*/
module.exports = function(projectDir, name) {
var oldCwd = process.cwd();
process.chdir(projectDir);
var env = yeoman.createEnv();
var generatorPath = path.join(__dirname, 'generator');
env.register(generatorPath, 'react:app');
var args = ['react:app', name].concat(process.argv.slice(4));
env.run(args, {'skip-ios': true}, function() {
process.chdir(oldCwd);
});
};

View File

@ -1,63 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const yeoman = require('yeoman-environment');
/**
* Generates the template for the given platform.
*/
function generate(argv, config) {
return new Promise((resolve, reject) => {
_generate(argv, config, resolve, reject);
});
}
function _generate(argv, config, resolve, reject) {
const args = parseCommandLine([{
command: 'platform',
description: 'Platform (ios|android)',
type: 'string',
required: true,
},
{
command: 'project-path',
description: 'Path to the project directory',
type: 'string',
required: true,
},
{
command: 'project-name',
description: 'Name of the project',
type: 'string',
required: true,
}], argv);
const oldCwd = process.cwd();
process.chdir(args['project-path']);
const env = yeoman.createEnv();
env.register(path.join(__dirname, '../generator'), 'react:app');
env.run(
['react:app', args['project-name']],
{
'skip-ios': args.platform !== 'ios',
'skip-android': args.platform !== 'android'
},
() => {
process.chdir(oldCwd);
resolve();
}
);
}
module.exports = generate;

View File

@ -1,91 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var chalk = require('chalk');
var fs = require('fs');
var path = require('path');
var yeoman = require('yeoman-generator');
function validatePackageName(name) {
if (!name.match(/^([a-zA-Z][a-zA-Z\d_]*\.)+([a-zA-Z_][a-zA-Z\d_]*)$/)) {
return false;
}
return true;
}
module.exports = yeoman.generators.NamedBase.extend({
constructor: function() {
yeoman.generators.NamedBase.apply(this, arguments);
this.option('package', {
desc: 'Package name for the application (com.example.app)',
type: String,
defaults: 'com.' + this.name.toLowerCase()
});
this.option('upgrade', {
desc: 'Specify an upgrade',
type: Boolean,
defaults: false
});
},
initializing: function() {
if (!validatePackageName(this.options.package)) {
throw new Error('Package name ' + this.options.package + ' is invalid');
}
},
writing: function() {
var templateParams = {
package: this.options.package,
name: this.name
};
if (!this.options.upgrade) {
this.fs.copyTpl(
this.templatePath(path.join('src', '**')),
this.destinationPath('android'),
templateParams
);
this.fs.copy(
this.templatePath(path.join('bin', '**')),
this.destinationPath('android')
);
} else {
this.fs.copyTpl(
this.templatePath(path.join('src', '*')),
this.destinationPath('android'),
templateParams
);
this.fs.copyTpl(
this.templatePath(path.join('src', 'app', '*')),
this.destinationPath(path.join('android', 'app')),
templateParams
);
}
var javaPath = path.join.apply(
null,
['android', 'app', 'src', 'main', 'java'].concat(this.options.package.split('.'))
);
this.fs.copyTpl(
this.templatePath(path.join('package', '**')),
this.destinationPath(javaPath),
templateParams
);
},
end: function() {
var projectPath = this.destinationRoot();
this.log(chalk.white.bold('To run your app on Android:'));
this.log(chalk.white(' Have an Android emulator running (quickest way to get started), or a device connected'));
this.log(chalk.white(' cd ' + projectPath));
this.log(chalk.white(' react-native run-android'));
}
});

View File

@ -1,3 +0,0 @@
<resources>
<string name="app_name"><%= name %></string>
</resources>

View File

@ -1,3 +0,0 @@
rootProject.name = '<%= name %>'
include ':app'

View File

@ -1,58 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var chalk = require('chalk');
var path = require('path');
var yeoman = require('yeoman-generator');
module.exports = yeoman.generators.NamedBase.extend({
writing: function() {
var templateVars = {name: this.name};
// SomeApp/ios/SomeApp
this.fs.copyTpl(
this.templatePath(path.join('app', '**')),
this.destinationPath(path.join('ios', this.name)),
templateVars
);
// SomeApp/ios/SomeAppTests
this.fs.copyTpl(
this.templatePath(path.join('tests', 'Tests.m')),
this.destinationPath(path.join('ios', this.name + 'Tests', this.name + 'Tests.m')),
templateVars
);
this.fs.copy(
this.templatePath(path.join('tests', 'Info.plist')),
this.destinationPath(path.join('ios', this.name + 'Tests', 'Info.plist'))
);
// SomeApp/ios/SomeApp.xcodeproj
this.fs.copyTpl(
this.templatePath(path.join('xcodeproj', 'project.pbxproj')),
this.destinationPath(path.join('ios', this.name + '.xcodeproj', 'project.pbxproj')),
templateVars
);
this.fs.copyTpl(
this.templatePath(path.join('xcodeproj', 'xcshareddata', 'xcschemes', '_xcscheme')),
this.destinationPath(path.join('ios', this.name + '.xcodeproj', 'xcshareddata', 'xcschemes', this.name + '.xcscheme')),
templateVars
);
},
end: function() {
var projectPath = path.resolve(this.destinationRoot(), 'ios', this.name);
this.log(chalk.white.bold('To run your app on iOS:'));
this.log(chalk.white(' cd ' + this.destinationRoot()));
this.log(chalk.white(' react-native run-ios'));
this.log(chalk.white(' - or -'));
this.log(chalk.white(' Open ' + projectPath + '.xcodeproj in Xcode'));
this.log(chalk.white(' Hit the Run button'));
}
});

View File

@ -1,814 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
00E356F31AD99517003FC87E /* <%= name %>Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* <%= name %>Tests.m */; };
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTActionSheet;
};
00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTGeolocation;
};
00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
remoteInfo = RCTImage;
};
00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511DB1A9E6C8500147676;
remoteInfo = RCTNetwork;
};
00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
remoteInfo = RCTVibration;
};
00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
remoteInfo = <%= name %>;
};
139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTSettings;
};
139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3C86DF461ADF2C930047B81A;
remoteInfo = RCTWebSocket;
};
146834031AC3E56700842450 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
remoteInfo = React;
};
5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTAnimation;
};
5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 2D2A28201D9B03D100D4039D;
remoteInfo = "RCTAnimation-tvOS";
};
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTLinking;
};
832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = main.jsbundle; sourceTree = "<group>"; };
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = "<group>"; };
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj; sourceTree = "<group>"; };
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
00E356EE1AD99517003FC87E /* <%= name %>Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = <%= name %>Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
00E356F21AD99517003FC87E /* <%= name %>Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = <%= name %>Tests.m; sourceTree = "<group>"; };
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj; sourceTree = "<group>"; };
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* <%= name %>.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = <%= name %>.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = <%= name %>/AppDelegate.h; sourceTree = "<group>"; };
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = <%= name %>/AppDelegate.m; sourceTree = "<group>"; };
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = <%= name %>/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = <%= name %>/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = <%= name %>/main.m; sourceTree = "<group>"; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../node_modules/react-native/React/React.xcodeproj; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = ../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = ../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../node_modules/react-native/Libraries/Text/RCTText.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
00E356EB1AD99517003FC87E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */,
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
00C302A81ABCB8CE00DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302B61ABCB90400DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302BC1ABCB91800DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302C01ABCB91800DB3ED1 /* libRCTImage.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302D41ABCB9D200DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302E01ABCB9EE00DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */,
);
name = Products;
sourceTree = "<group>";
};
00E356EF1AD99517003FC87E /* <%= name %>Tests */ = {
isa = PBXGroup;
children = (
00E356F21AD99517003FC87E /* <%= name %>Tests.m */,
00E356F01AD99517003FC87E /* Supporting Files */,
);
path = <%= name %>Tests;
sourceTree = "<group>";
};
00E356F01AD99517003FC87E /* Supporting Files */ = {
isa = PBXGroup;
children = (
00E356F11AD99517003FC87E /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
139105B71AF99BAD00B5F7CC /* Products */ = {
isa = PBXGroup;
children = (
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */,
);
name = Products;
sourceTree = "<group>";
};
139FDEE71B06529A00C62182 /* Products */ = {
isa = PBXGroup;
children = (
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */,
);
name = Products;
sourceTree = "<group>";
};
13B07FAE1A68108700A75B9A /* <%= name %> */ = {
isa = PBXGroup;
children = (
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.m */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
13B07FB71A68108700A75B9A /* main.m */,
);
name = <%= name %>;
sourceTree = "<group>";
};
146834001AC3E56700842450 /* Products */ = {
isa = PBXGroup;
children = (
146834041AC3E56700842450 /* libReact.a */,
);
name = Products;
sourceTree = "<group>";
};
5E91572E1DD0AC6500FF2AA8 /* Products */ = {
isa = PBXGroup;
children = (
5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */,
5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
};
78C398B11ACF4ADC00677621 /* Products */ = {
isa = PBXGroup;
children = (
78C398B91ACF4ADC00677621 /* libRCTLinking.a */,
);
name = Products;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */,
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */,
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */,
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */,
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
};
832341B11AAA6A8300B99B32 /* Products */ = {
isa = PBXGroup;
children = (
832341B51AAA6A8300B99B32 /* libRCTText.a */,
);
name = Products;
sourceTree = "<group>";
};
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
13B07FAE1A68108700A75B9A /* <%= name %> */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* <%= name %>Tests */,
83CBBA001A601CBA00E9B192 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
83CBBA001A601CBA00E9B192 /* Products */ = {
isa = PBXGroup;
children = (
13B07F961A680F5B00A75B9A /* <%= name %>.app */,
00E356EE1AD99517003FC87E /* <%= name %>Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
00E356ED1AD99517003FC87E /* <%= name %>Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "<%= name %>Tests" */;
buildPhases = (
00E356EA1AD99517003FC87E /* Sources */,
00E356EB1AD99517003FC87E /* Frameworks */,
00E356EC1AD99517003FC87E /* Resources */,
);
buildRules = (
);
dependencies = (
00E356F51AD99517003FC87E /* PBXTargetDependency */,
);
name = <%= name %>Tests;
productName = <%= name %>Tests;
productReference = 00E356EE1AD99517003FC87E /* <%= name %>Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
13B07F861A680F5B00A75B9A /* <%= name %> */ = {
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "<%= name %>" */;
buildPhases = (
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
);
buildRules = (
);
dependencies = (
);
name = <%= name %>;
productName = "Hello World";
productReference = 13B07F961A680F5B00A75B9A /* <%= name %>.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "<%= name %>" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 83CBB9F61A601CBA00E9B192;
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
},
{
ProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */;
ProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;
},
{
ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */;
ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
},
{
ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */;
ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
},
{
ProductGroup = 78C398B11ACF4ADC00677621 /* Products */;
ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
},
{
ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */;
ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
},
{
ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
},
{
ProductGroup = 832341B11AAA6A8300B99B32 /* Products */;
ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
},
{
ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */;
ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
},
{
ProductGroup = 139FDEE71B06529A00C62182 /* Products */;
ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
},
{
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
);
projectRoot = "";
targets = (
13B07F861A680F5B00A75B9A /* <%= name %> */,
00E356ED1AD99517003FC87E /* <%= name %>Tests */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTActionSheet.a;
remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTGeolocation.a;
remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTImage.a;
remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTNetwork.a;
remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTVibration.a;
remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTSettings.a;
remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTWebSocket.a;
remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
146834041AC3E56700842450 /* libReact.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libReact.a;
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTAnimation.a;
remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libRCTAnimation-tvOS.a";
remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTLinking.a;
remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
832341B51AAA6A8300B99B32 /* libRCTText.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTText.a;
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
00E356EC1AD99517003FC87E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F8E1A680F5B00A75B9A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
showEnvVarsInLog = 1;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
00E356EA1AD99517003FC87E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
00E356F31AD99517003FC87E /* <%= name %>Tests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F871A680F5B00A75B9A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
00E356F51AD99517003FC87E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 13B07F861A680F5B00A75B9A /* <%= name %> */;
targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
13B07FB21A68108700A75B9A /* Base */,
);
name = LaunchScreen.xib;
path = <%= name %>;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
00E356F61AD99517003FC87E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = <%= name %>Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/<%= name %>.app/<%= name %>";
};
name = Debug;
};
00E356F71AD99517003FC87E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = <%= name %>Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/<%= name %>.app/<%= name %>";
};
name = Release;
};
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
);
INFOPLIST_FILE = "<%= name %>/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-lc++",
);
PRODUCT_NAME = <%= name %>;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
);
INFOPLIST_FILE = "<%= name %>/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-lc++",
);
PRODUCT_NAME = <%= name %>;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
};
83CBBA201A601CBA00E9B192 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
83CBBA211A601CBA00E9B192 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "<%= name %>Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
00E356F61AD99517003FC87E /* Debug */,
00E356F71AD99517003FC87E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "<%= name %>" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13B07F941A680F5B00A75B9A /* Debug */,
13B07F951A680F5B00A75B9A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "<%= name %>" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83CBBA201A601CBA00E9B192 /* Debug */,
83CBBA211A601CBA00E9B192 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
}

View File

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "<%= name %>.app"
BlueprintName = "<%= name %>"
ReferencedContainer = "container:<%= name %>.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "<%= name %>Tests.xctest"
BlueprintName = "<%= name %>Tests"
ReferencedContainer = "container:<%= name %>.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "<%= name %>Tests.xctest"
BlueprintName = "<%= name %>Tests"
ReferencedContainer = "container:<%= name %>.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "<%= name %>.app"
BlueprintName = "<%= name %>"
ReferencedContainer = "container:<%= name %>.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "<%= name %>.app"
BlueprintName = "<%= name %>"
ReferencedContainer = "container:<%= name %>.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "<%= name %>.app"
BlueprintName = "<%= name %>"
ReferencedContainer = "container:<%= name %>.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,43 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var fs = require('fs');
var path = require('path');
function copyAndReplace(src, dest, replacements) {
if (fs.lstatSync(src).isDirectory()) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
} else {
var content = fs.readFileSync(src, 'utf8');
Object.keys(replacements).forEach(function(regex) {
content = content.replace(new RegExp(regex, 'gm'), replacements[regex]);
});
fs.writeFileSync(dest, content);
}
}
function walk(current) {
if (!fs.lstatSync(current).isDirectory()) {
return [current];
}
var files = fs.readdirSync(current).map(function(child) {
child = path.join(current, child);
return walk(child);
});
return [].concat.apply([current], files);
}
module.exports = {
copyAndReplace: copyAndReplace,
walk: walk
};

View File

@ -0,0 +1,101 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const chalk = require('chalk');
const copyAndReplace = require('../util/copyAndReplace');
const path = require('path');
const prompt = require('./promptSync')();
const walk = require('../util/walk');
/**
* Util for creating a new React Native project.
* Copy the project from a template and use the correct project name in
* all files.
* @param srcPath e.g. '/Users/martin/AwesomeApp/node_modules/react-native/local-cli/templates/HelloWorld'
* @param destPath e.g. '/Users/martin/AwesomeApp'
* @param newProjectName e.g. 'AwesomeApp'
*/
function copyProjectTemplateAndReplace(srcPath, destPath, newProjectName, options) {
if (!srcPath) { throw new Error('Need a path to copy from'); }
if (!destPath) { throw new Error('Need a path to copy to'); }
if (!newProjectName) { throw new Error('Need a project name'); }
walk(srcPath).forEach(absoluteSrcFilePath => {
// 'react-native upgrade'
if (options && options.upgrade) {
// Don't upgrade these files
const fileName = path.basename(absoluteSrcFilePath);
// This also includes __tests__/index.*.js
if (fileName === 'index.ios.js') { return; }
if (fileName === 'index.android.js') { return; }
}
const relativeFilePath = path.relative(srcPath, absoluteSrcFilePath);
const relativeRenamedPath = relativeFilePath
.replace(/HelloWorld/g, newProjectName)
.replace(/helloworld/g, newProjectName.toLowerCase());
let contentChangedCallback = null;
if (options && options.upgrade && (!options.force)) {
contentChangedCallback = (_, contentChanged) => {
return upgradeFileContentChangedCallback(
absoluteSrcFilePath,
relativeRenamedPath,
contentChanged,
);
};
}
copyAndReplace(
absoluteSrcFilePath,
path.resolve(destPath, relativeRenamedPath),
{
'HelloWorld': newProjectName,
'helloworld': newProjectName.toLowerCase(),
},
contentChangedCallback,
);
});
}
function upgradeFileContentChangedCallback(
absoluteSrcFilePath,
relativeDestPath,
contentChanged
) {
if (contentChanged === 'new') {
console.log(chalk.bold('new') + ' ' + relativeDestPath);
return 'overwrite';
} else if (contentChanged === 'changed') {
console.log(chalk.bold(relativeDestPath) + ' ' +
'has changed in the new version.\nDo you want to keep your ' +
relativeDestPath + ' or replace it with the ' +
'latest version?\nIf you ever made any changes ' +
'to this file, you\'ll probably want to keep it.\n' +
'You can see the new version here: ' + absoluteSrcFilePath + '\n' +
'Do you want to replace ' + relativeDestPath + '? ' +
'Answer y to replace, n to keep your version: ');
const answer = prompt();
if (answer === 'y') {
console.log('Replacing ' + relativeDestPath);
return 'overwrite';
} else {
console.log('Keeping your ' + relativeDestPath);
return 'keep';
}
} else if (contentChanged === 'identical') {
return 'keep';
} else {
throw new Error(`Unkown file changed state: ${relativeDestPath}, ${contentChanged}`);
}
}
module.exports = copyProjectTemplateAndReplace;

View File

@ -1,213 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var execSync = require('child_process').execSync;
var fs = require('fs');
var path = require('path');
var semver = require('semver')
var utils = require('../generator-utils');
var yeoman = require('yeoman-generator');
// Use Yarn if available, it's much faster than the npm client.
// Return the version of yarn installed on the system, null if yarn is not available.
function getYarnVersionIfAvailable() {
let yarnVersion;
try {
// execSync returns a Buffer -> convert to string
if (process.platform.startsWith('win')) {
yarnVersion = (execSync('yarn --version').toString() || '').trim();
} else {
yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '').trim();
}
} catch (error) {
return null;
}
// yarn < 0.16 has a 'missing manifest' bug
try {
if (semver.gte(yarnVersion, '0.16.0')) {
return yarnVersion;
} else {
return null;
}
} catch (error) {
console.error('Cannot parse yarn version: ' + yarnVersion);
return null;
}
}
/**
* Check that 'react-native init' itself used yarn to install React Native.
* When using an old global react-native-cli@1.0.0 (or older), we don't want
* to install React Native with npm, and React + Jest with yarn.
* Let's be safe and not mix yarn and npm in a single project.
* @param projectDir e.g. /Users/martin/AwesomeApp
*/
function isGlobalCliUsingYarn(projectDir) {
return fs.existsSync(path.join(projectDir, 'yarn.lock'));
}
module.exports = yeoman.generators.NamedBase.extend({
constructor: function() {
yeoman.generators.NamedBase.apply(this, arguments);
this.option('skip-ios', {
desc: 'Skip generating iOS files',
type: Boolean,
defaults: false
});
this.option('skip-android', {
desc: 'Skip generating Android files',
type: Boolean,
defaults: false
});
this.option('skip-jest', {
desc: 'Skip installing Jest',
type: Boolean,
defaults: false
});
this.option('upgrade', {
desc: 'Specify an upgrade',
type: Boolean,
defaults: false
});
// Temporary option until yarn becomes stable.
this.option('npm', {
desc: 'Use the npm client, even if yarn is available.',
type: Boolean,
defaults: false
});
// this passes command line arguments down to the composed generators
var args = {args: arguments[0], options: this.options};
if (!this.options['skip-ios']) {
this.composeWith('react:ios', args, {
local: require.resolve(path.resolve(__dirname, '..', 'generator-ios'))
});
}
if (!this.options['skip-android']) {
this.composeWith('react:android', args, {
local: require.resolve(path.resolve(__dirname, '..', 'generator-android'))
});
}
},
configuring: function() {
utils.copyAndReplace(
this.templatePath('../../../.flowconfig'),
this.destinationPath('.flowconfig'),
{
'Libraries\/react-native\/react-native-interface.js' : 'node_modules/react-native/Libraries/react-native/react-native-interface.js',
'^flow/$' : 'node_modules/react-native/flow\nflow/'
}
);
this.fs.copy(
this.templatePath('_gitignore'),
this.destinationPath('.gitignore')
);
this.fs.copy(
this.templatePath('_gitattributes'),
this.destinationPath('.gitattributes')
);
this.fs.copy(
this.templatePath('_watchmanconfig'),
this.destinationPath('.watchmanconfig')
);
this.fs.copy(
this.templatePath('_buckconfig'),
this.destinationPath('.buckconfig')
);
},
writing: function() {
if (this.options.upgrade) {
// never upgrade index.*.js files
return;
}
if (!this.options['skip-ios']) {
this.fs.copyTpl(
this.templatePath('index.ios.js'),
this.destinationPath('index.ios.js'),
{name: this.name}
);
}
if (!this.options['skip-android']) {
this.fs.copyTpl(
this.templatePath('index.android.js'),
this.destinationPath('index.android.js'),
{name: this.name}
);
}
},
install: function() {
if (this.options.upgrade) {
return;
}
var reactNativePackageJson = require('../../package.json');
var { peerDependencies } = reactNativePackageJson;
if (!peerDependencies) {
return;
}
var reactVersion = peerDependencies.react;
if (!reactVersion) {
return;
}
const yarnVersion = (!this.options['npm']) && getYarnVersionIfAvailable() && isGlobalCliUsingYarn(this.destinationRoot());
console.log('Installing React...');
if (yarnVersion) {
execSync(`yarn add react@${reactVersion}`);
} else {
this.npmInstall(`react@${reactVersion}`, { '--save': true, '--save-exact': true });
}
if (!this.options['skip-jest']) {
console.log('Installing Jest...');
if (yarnVersion) {
execSync(`yarn add jest babel-jest jest-react-native babel-preset-react-native react-test-renderer@${reactVersion} --dev --exact`);
} else {
this.npmInstall(`jest babel-jest babel-preset-react-native react-test-renderer@${reactVersion}`.split(' '), {
saveDev: true,
'--save-exact': true
});
}
fs.writeFileSync(
path.join(
this.destinationRoot(),
'.babelrc'
),
'{\n"presets": ["react-native"]\n}'
);
this.fs.copy(
this.templatePath('__tests__'),
this.destinationPath('__tests__'),
{
nodir: false
}
);
var packageJSONPath = path.join(
this.destinationRoot(),
'package.json'
);
var packageJSON = JSON.parse(
fs.readFileSync(
packageJSONPath
)
);
packageJSON.scripts.test = 'jest';
packageJSON.jest = {
preset: 'react-native'
};
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, '\t'));
}
}
});

View File

@ -0,0 +1,35 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var chalk = require('chalk');
var path = require('path');
function printRunInstructions(projectDir, projectName) {
const absoluteProjectDir = path.resolve(projectDir);
const relativeProjectDir = path.relative(process.cwd(), absoluteProjectDir);
// If we're in the project directory already, no need to 'cd' into it
const needToCd = !!relativeProjectDir;
// iOS
const xcodeProjectPath = path.resolve(projectDir, 'ios', projectName) + '.xcodeproj';
const relativeXcodeProjectPath = path.relative(process.cwd(), xcodeProjectPath);
console.log(chalk.white.bold('To run your app on iOS:'));
if (needToCd) { console.log(' cd ' + relativeProjectDir); }
console.log(' react-native run-ios');
console.log(' - or -');
console.log(' Open ' + relativeXcodeProjectPath + ' in Xcode');
console.log(' Hit the Run button');
// Android
console.log(chalk.white.bold('To run your app on Android:'));
console.log(' Have an Android emulator running (quickest way to get started), or a device connected');
if (needToCd) { console.log(' cd ' + relativeProjectDir); }
console.log(' react-native run-android');
}
module.exports = printRunInstructions;

View File

@ -0,0 +1,118 @@
// Simplified version of:
// https://github.com/0x00A/prompt-sync/blob/master/index.js
'use strict';
var fs = require('fs');
var term = 13; // carriage return
function create() {
return prompt;
function prompt(ask, value, opts) {
var insert = 0, savedinsert = 0, res, i, savedstr;
opts = opts || {};
if (Object(ask) === ask) {
opts = ask;
ask = opts.ask;
} else if (Object(value) === value) {
opts = value;
value = opts.value;
}
ask = ask || '';
var echo = opts.echo;
var masked = 'echo' in opts;
var fd = (process.platform === 'win32') ?
process.stdin.fd :
fs.openSync('/dev/tty', 'rs');
var wasRaw = process.stdin.isRaw;
if (!wasRaw) { process.stdin.setRawMode(true); }
var buf = new Buffer(3);
var str = '', character, read;
savedstr = '';
if (ask) {
process.stdout.write(ask);
}
var cycle = 0;
var prevComplete;
while (true) {
read = fs.readSync(fd, buf, 0, 3);
if (read > 1) { // received a control sequence
if (buf.toString()) {
str = str + buf.toString();
str = str.replace(/\0/g, '');
insert = str.length;
process.stdout.write('\u001b[2K\u001b[0G'+ ask + str);
process.stdout.write('\u001b[' + (insert+ask.length+1) + 'G');
buf = new Buffer(3);
}
continue; // any other 3 character sequence is ignored
}
// if it is not a control character seq, assume only one character is read
character = buf[read-1];
// catch a ^C and return null
if (character == 3){
process.stdout.write('^C\n');
fs.closeSync(fd);
process.exit(130);
process.stdin.setRawMode(wasRaw);
return null;
}
// catch the terminating character
if (character == term) {
fs.closeSync(fd);
break;
}
if (character == 127 || (process.platform == 'win32' && character == 8)) { //backspace
if (!insert) continue;
str = str.slice(0, insert-1) + str.slice(insert);
insert--;
process.stdout.write('\u001b[2D');
} else {
if ((character < 32 ) || (character > 126))
continue;
str = str.slice(0, insert) + String.fromCharCode(character) + str.slice(insert);
insert++;
};
if (masked) {
process.stdout.write('\u001b[2K\u001b[0G' + ask + Array(str.length+1).join(echo));
} else {
process.stdout.write('\u001b[s');
if (insert == str.length) {
process.stdout.write('\u001b[2K\u001b[0G'+ ask + str);
} else {
if (ask) {
process.stdout.write('\u001b[2K\u001b[0G'+ ask + str);
} else {
process.stdout.write('\u001b[2K\u001b[0G'+ str + '\u001b[' + (str.length - insert) + 'D');
}
}
process.stdout.write('\u001b[u');
process.stdout.write('\u001b[1C');
}
}
process.stdout.write('\n')
process.stdin.setRawMode(wasRaw);
return str || value || '';
};
};
module.exports = create;

6
local-cli/init/gen.js Normal file
View File

@ -0,0 +1,6 @@
const init = require('./init');
init(
'/Users/mkonicek/code/testapps/ignite',
['AwesomeApp', '--verbose']
);

View File

@ -8,48 +8,104 @@
*/
'use strict';
const copyProjectTemplateAndReplace = require('../generator/copyProjectTemplateAndReplace');
const execSync = require('child_process').execSync;
const fs = require('fs');
const minimist = require('minimist');
const path = require('path');
const TerminalAdapter = require('yeoman-environment/lib/adapter.js');
const yeoman = require('yeoman-environment');
class CreateSuppressingTerminalAdapter extends TerminalAdapter {
constructor() {
super();
// suppress 'create' output generated by yeoman
this.log.create = function() {};
}
}
const printRunInstructions = require('../generator/printRunInstructions');
const process = require('process');
const yarn = require('../util/yarn');
/**
* Creates the template for a React Native project given the provided
* parameters:
* - projectDir: templates will be copied here.
* - argsOrName: project name or full list of custom arguments to pass to the
* generator.
* @param projectDir Templates will be copied here.
* @param argsOrName Project name or full list of custom arguments
* for the generator.
*/
function init(projectDir, argsOrName) {
console.log('Setting up new React Native app in ' + projectDir);
const env = yeoman.createEnv(
undefined,
undefined,
new CreateSuppressingTerminalAdapter()
);
env.register(
require.resolve(path.join(__dirname, '../generator')),
'react:app'
);
// argv is for instance
// ['node', 'react-native', 'init', 'AwesomeApp', '--verbose']
// args should be ['AwesomeApp', '--verbose']
const args = Array.isArray(argsOrName)
? argsOrName
: [argsOrName].concat(process.argv.slice(4));
? argsOrName // argsOrName was e.g. ['AwesomeApp', '--verbose']
: [argsOrName].concat(process.argv.slice(4)); // argsOrName was e.g. 'AwesomeApp'
const generator = env.create('react:app', {args: args});
generator.destinationRoot(projectDir);
generator.run();
// args array is e.g. ['AwesomeApp', '--verbose']
if (!args || args.lentgh == 0) {
console.error('react-native init requires a project name.');
return;
}
const newProjectName = args[0];
const options = minimist(args);
generateProject(projectDir, newProjectName, options);
}
/**
* Generates a new React Native project based on the template.
* @param Absolute path at which the project folder should be created.
* @param options Command line arguments parsed by minimist.
*/
function generateProject(destinationRoot, newProjectName, options) {
var reactNativePackageJson = require('../../package.json');
var { peerDependencies } = reactNativePackageJson;
if (!peerDependencies) {
console.error('Missing React peer dependency in React Native\'s package.json. Aborting.');
return;
}
var reactVersion = peerDependencies.react;
if (!reactVersion) {
console.error('Missing React peer dependency in React Native\'s package.json. Aborting.');
return;
}
const yarnVersion =
(!options['npm']) &&
yarn.getYarnVersionIfAvailable() &&
yarn.isGlobalCliUsingYarn(destinationRoot);
copyProjectTemplateAndReplace(
path.resolve('node_modules', 'react-native', 'local-cli', 'templates', 'HelloWorld'),
destinationRoot,
newProjectName
);
if (yarnVersion) {
console.log('Adding React...');
execSync(`yarn add react@${reactVersion}`);
} else {
console.log('Installing React...');
execSync(`npm install react@${reactVersion} --save --save-exact`);
}
if (!options['skip-jest']) {
const jestDeps = `jest babel-jest jest-react-native babel-preset-react-native react-test-renderer@${reactVersion}`;
if (yarnVersion) {
console.log('Adding Jest...');
execSync(`yarn add ${jestDeps} --dev --exact`);
} else {
console.log('Installing Jest...');
execSync(`npm install ${jestDeps} --save-dev --save-exact`);
}
addJestToPackageJson(destinationRoot);
}
printRunInstructions(destinationRoot, newProjectName);
}
/**
* Add Jest-related stuff to package.json, which was created by the react-native-cli.
*/
function addJestToPackageJson(destinationRoot) {
var packageJSONPath = path.join(destinationRoot, 'package.json');
var packageJSON = JSON.parse(fs.readFileSync(packageJSONPath));
packageJSON.scripts.test = 'jest';
packageJSON.jest = {
preset: 'react-native'
};
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, '\t'));
}
module.exports = init;

View File

@ -8,13 +8,14 @@
*/
'use strict';
const Promise = require('promise');
const adb = require('./adb');
const chalk = require('chalk');
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const isPackagerRunning = require('../util/isPackagerRunning');
const Promise = require('promise');
const adb = require('./adb');
const path = require('path');
// Verifies this is an Android project
function checkAndroid(root) {
@ -104,7 +105,7 @@ function buildAndRun(args) {
if (args.configuration.toUpperCase() === 'RELEASE') {
console.log(chalk.bold(
`Generating the bundle for the release build...`
'Generating the bundle for the release build...'
));
child_process.execSync(`react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output ${androidProjectDir}/app/src/main/assets/index.android.bundle --assets-dest ${androidProjectDir}/app/src/main/res/`, {
@ -121,7 +122,7 @@ function buildAndRun(args) {
: './gradlew';
console.log(chalk.bold(
`Building and installing the app on the device (cd android && ${cmd} ${gradleArgs.join(' ')}...`
`Building and installing the app on the device (cd android && ${cmd} ${gradleArgs.join(' ')})...`
));
child_process.execFileSync(cmd, gradleArgs, {

View File

@ -1,2 +0,0 @@
/captures/*
preLoadedCapture.js

View File

@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}

View File

@ -0,0 +1 @@
a528552661748a6cc72c37824ade3722d94eeb48

View File

@ -0,0 +1,45 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
[include]
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/
[options]
module.system=haste
experimental.strict_type_args=true
munge_underscores=true
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-5]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-5]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
unsafe.enable_getters_and_setters=true
[version]
^0.35.0

View File

@ -22,12 +22,13 @@ DerivedData
*.xcuserstate
project.xcworkspace
# Android/IJ
# Android/IntelliJ
#
*.iml
build/
.idea
.gradle
local.properties
*.iml
# node.js
#

View File

@ -46,13 +46,13 @@ android_library(
android_build_config(
name = 'build_config',
package = '<%= package %>',
package = 'com.helloworld',
)
android_resource(
name = 'res',
res = 'src/main/res',
package = '<%= package %>',
package = 'com.helloworld',
)
android_binary(

View File

@ -87,7 +87,7 @@ android {
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "<%= package %>"
applicationId "com.helloworld"
minSdkVersion 16
targetSdkVersion 22
versionCode 1

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<%= package %>"
package="com.helloworld"
android:versionCode="1"
android:versionName="1.0">

View File

@ -1,4 +1,4 @@
package <%= package %>;
package com.helloworld;
import com.facebook.react.ReactActivity;
@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity {
*/
@Override
protected String getMainComponentName() {
return "<%= name %>";
return "HelloWorld";
}
}

View File

@ -1,4 +1,4 @@
package <%= package %>;
package com.helloworld;
import android.app.Application;
import android.util.Log;

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">HelloWorld</string>
</resources>

View File

@ -0,0 +1,3 @@
rootProject.name = 'HelloWorld'
include ':app'

View File

@ -12,7 +12,7 @@ import {
View
} from 'react-native';
export default class <%= name %> extends Component {
export default class HelloWorld extends Component {
render() {
return (
<View style={styles.container}>
@ -50,4 +50,4 @@ const styles = StyleSheet.create({
},
});
AppRegistry.registerComponent('<%= name %>', () => <%= name %>);
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);

View File

@ -12,7 +12,7 @@ import {
View
} from 'react-native';
export default class <%= name %> extends Component {
export default class HelloWorld extends Component {
render() {
return (
<View style={styles.container}>
@ -50,4 +50,4 @@ const styles = StyleSheet.create({
},
});
AppRegistry.registerComponent('<%= name %>', () => <%= name %>);
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);

View File

@ -21,7 +21,7 @@
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"<%= name %>"
moduleName:@"HelloWorld"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

View File

@ -18,7 +18,7 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<%= name %>" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="HelloWorld" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>

View File

@ -16,11 +16,11 @@
#define TIMEOUT_SECONDS 600
#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
@interface <%= name %>Tests : XCTestCase
@interface HelloWorldTests : XCTestCase
@end
@implementation <%= name %>Tests
@implementation HelloWorldTests
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
{

View File

@ -0,0 +1,3 @@
const upgradeCommand = require('./upgrade');
upgradeCommand.func();

View File

@ -8,99 +8,141 @@
*/
'use strict';
const fs = require('fs');
const chalk = require('chalk');
const path = require('path');
const Promise = require('promise');
const yeoman = require('yeoman-environment');
const chalk = require('chalk');
const copyProjectTemplateAndReplace = require('../generator/copyProjectTemplateAndReplace');
const fs = require('fs');
const path = require('path');
const printRunInstructions = require('../generator/printRunInstructions');
const semver = require('semver');
const yarn = require('../util/yarn');
function upgrade(args, config) {
args = args || process.argv;
const env = yeoman.createEnv();
const pak = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const version = pak.dependencies['react-native'];
/**
* Migrate application to a new version of React Native.
* See http://facebook.github.io/react-native/docs/upgrading.html
*
* IMPORTANT: Assumes the cwd() is the project directory.
* The code here must only be invoked via the CLI:
* $ cd MyAwesomeApp
* $ react-native upgrade
*/
function validateAndUpgrade() {
const projectDir = process.cwd();
if (version) {
if (version === 'latest' || version === '*') {
console.warn(
chalk.yellow(
'Major releases are most likely to introduce breaking changes.\n' +
'Use a proper version number in your \'package.json\' file to avoid breakage.\n' +
'e.g. - ^0.18.0'
)
);
} else {
const installed = JSON.parse(fs.readFileSync('node_modules/react-native/package.json', 'utf8'));
const packageJSON = JSON.parse(
fs.readFileSync(path.resolve(projectDir, 'package.json'), 'utf8')
);
if (semver.satisfies(installed.version, version)) {
const v = version.replace(/^(~|\^|=)/, '').replace(/x/i, '0');
const projectName = packageJSON.name;
if (!projectName) {
warn(
"Your project needs to have a name, declared in package.json, " +
"such as \"name\": \"AwesomeApp\". Please add a project name. Aborting."
);
return;
}
if (semver.valid(v)) {
console.log(
'Upgrading project to react-native v' + installed.version + '\n' +
'Be sure to read the release notes and breaking changes:\n' +
chalk.blue(
'https://github.com/facebook/react-native/releases/tag/v' + semver.major(v) + '.' + semver.minor(v) + '.0'
)
);
const version = packageJSON.dependencies['react-native'];
if (!version) {
warn(
"Your 'package.json' file doesn't seem to declare 'react-native' as " +
"a dependency. Nothing to upgrade. Aborting."
);
return;
}
// >= v0.21.0, we require react to be a peer dependency
if (semver.gte(v, '0.21.0') && !pak.dependencies.react) {
console.log(
chalk.yellow(
'\nYour \'package.json\' file doesn\'t seem to have \'react\' as a dependency.\n' +
'\'react\' was changed from a dependency to a peer dependency in react-native v0.21.0.\n' +
'Therefore, it\'s necessary to include \'react\' in your project\'s dependencies.\n' +
'Just run \'npm install --save react\', then re-run \'react-native upgrade\'.\n'
)
);
return;
}
if (version === 'latest' || version === '*') {
warn(
"Some major releases introduce breaking changes.\n" +
"Please use a caret version number in your 'package.json' file \n" +
"to avoid breakage. Use e.g. react-native: ^0.38.0. Aborting."
);
return;
}
if (semver.satisfies(v, '~0.26.0')) {
console.log(
chalk.yellow(
'React Native 0.26 introduced some breaking changes to the native files on iOS. You can\n' +
'perform them manually by checking the release notes or use \'rnpm\' to do it automatically.\n' +
'Just run:\n' +
'\'npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev\', then run \'rnpm upgrade\''
)
);
}
} else {
console.log(
chalk.yellow(
'A valid version number for \'react-native\' is not specified in your \'package.json\' file.'
)
);
}
} else {
console.warn(
chalk.yellow(
'react-native version in \'package.json\' doesn\'t match the installed version in \'node_modules\'.\n' +
'Try running \'npm install\' to fix the issue.'
)
);
}
}
} else {
console.warn(
chalk.yellow(
'Your \'package.json\' file doesn\'t seem to have \'react-native\' as a dependency.'
)
const installed = JSON.parse(
fs.readFileSync(
path.resolve(projectDir, 'node_modules/react-native/package.json'),
'utf8'
)
);
if (!semver.satisfies(installed.version, version)) {
warn(
"react-native version in 'package.json' doesn't match the installed version in 'node_modules'.\n" +
"Try running 'npm install' to fix this. Aborting."
);
return;
}
const v = version.replace(/^(~|\^|=)/, '').replace(/x/i, '0');
if (!semver.valid(v)) {
warn(
"A valid version number for 'react-native' is not specified in your " +
"'package.json' file. Aborting."
);
return;
}
console.log(
'Upgrading project to react-native v' + installed.version + '\n' +
'Check out the release notes and breaking changes: ' +
'https://github.com/facebook/react-native/releases/tag/v' + semver.major(v) + '.' + semver.minor(v) + '.0'
);
// >= v0.21.0, we require react to be a peer dependency
if (semver.gte(v, '0.21.0') && !packageJSON.dependencies.react) {
warn(
"Your 'package.json' file doesn't seem to have 'react' as a dependency.\n" +
"'react' was changed from a dependency to a peer dependency in react-native v0.21.0.\n" +
"Therefore, it's necessary to include 'react' in your project's dependencies.\n" +
"Please run 'npm install --save react', then re-run 'react-native upgrade'.\n"
);
return;
}
if (semver.satisfies(v, '~0.26.0')) {
warn(
"React Native 0.26 introduced some breaking changes to the native files on iOS. You can\n" +
"perform them manually by checking the release notes or use \'rnpm\' to do it automatically.\n" +
"Just run:\n" +
"\'npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev\', then run \'rnpm upgrade\'"
);
}
const generatorPath = path.join(__dirname, '..', 'generator');
env.register(generatorPath, 'react:app');
const generatorArgs = ['react:app', pak.name].concat(args);
return new Promise((resolve) => env.run(generatorArgs, {upgrade: true}, resolve));
return new Promise((resolve) => {
upgradeProjectFiles(projectDir, projectName);
console.log(
'Successfully upgraded this project to react-native v' + installed.version
);
resolve();
});
}
module.exports = {
/**
* Once all checks passed, upgrade the project files.
*/
function upgradeProjectFiles(projectDir, projectName) {
// Just owerwrite
copyProjectTemplateAndReplace(
path.resolve('node_modules', 'react-native', 'local-cli', 'templates', 'HelloWorld'),
projectDir,
projectName,
{upgrade: true}
);
}
function warn(message) {
console.warn(chalk.yellow(message));
}
const upgradeCommand = {
name: 'upgrade',
description: 'upgrade your app\'s template files to the latest version; run this after ' +
'updating the react-native version in your package.json and running npm install',
func: upgrade,
func: validateAndUpgrade,
};
module.exports = upgradeCommand;

View File

@ -9,22 +9,120 @@
'use strict';
const fs = require('fs');
const path = require('path');
function copyAndReplace(src, dest, replacements) {
console.log('src', src);
console.log('dest', dest);
if (fs.lstatSync(src).isDirectory()) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
// Binary files, don't process these (avoid decoding as utf8)
const binaryExtensions = ['.png', '.jar'];
/**
* Copy a file to given destination, replacing parts of its contents.
* @param srcPath Path to a file to be copied.
* @param destPath Destination path.
* @param replacements: e.g. {'TextToBeReplaced': 'Replacement'}
* @param contentChangedCallback
* Used when upgrading projects. Based on if file contents would change
* when being replaced, allows the caller to specify whether the file
* should be replaced or not.
* If null, files will be overwritten.
* Function(path, 'identical' | 'changed' | 'new') => 'keep' | 'overwrite'
*/
function copyAndReplace(srcPath, destPath, replacements, contentChangedCallback) {
if (fs.lstatSync(srcPath).isDirectory()) {
if (!fs.existsSync(destPath)) {
fs.mkdirSync(destPath);
}
// Not recursive
return;
}
const extension = path.extname(srcPath);
if (binaryExtensions.indexOf(extension) !== -1) {
// Binary file
let shouldOverwrite = 'overwrite';
if (contentChangedCallback) {
const newContentBuffer = fs.readFileSync(srcPath);
let contentChanged = 'identical';
try {
const origContentBuffer = fs.readFileSync(destPath);
if (Buffer.compare(origContentBuffer, newContentBuffer) !== 0) {
contentChanged = 'changed';
}
} catch (err) {
if (err.code === 'ENOENT') {
contentChanged = 'new';
} else {
throw err;
}
}
shouldOverwrite = contentChangedCallback(destPath, contentChanged);
}
if (shouldOverwrite === 'overwrite') {
copyBinaryFile(srcPath, destPath, (err) => {
if (err) { throw err; }
});
}
} else {
let content = fs.readFileSync(src, 'utf8');
// Text file
const srcPermissions = fs.statSync(srcPath).mode;
let content = fs.readFileSync(srcPath, 'utf8');
Object.keys(replacements).forEach(regex =>
content = content.replace(new RegExp(regex, 'g'), replacements[regex])
);
fs.writeFileSync(dest, content);
let shouldOverwrite = 'overwrite';
if (contentChangedCallback) {
// Check if contents changed and ask to overwrite
let contentChanged = 'identical';
try {
const origContent = fs.readFileSync(destPath, 'utf8');
if (content !== origContent) {
//console.log('Content changed: ' + destPath);
contentChanged = 'changed';
}
} catch (err) {
if (err.code === 'ENOENT') {
contentChanged = 'new';
} else {
throw err;
}
}
shouldOverwrite = contentChangedCallback(destPath, contentChanged);
}
if (shouldOverwrite === 'overwrite') {
fs.writeFileSync(destPath, content, {
encoding: 'utf8',
mode: srcPermissions,
});
}
}
}
/**
* Same as 'cp' on Unix. Don't do any replacements.
*/
function copyBinaryFile(srcPath, destPath, cb) {
let cbCalled = false;
const srcPermissions = fs.statSync(srcPath).mode;
const readStream = fs.createReadStream(srcPath);
readStream.on('error', function(err) {
done(err);
});
const writeStream = fs.createWriteStream(destPath, {
mode: srcPermissions
});
writeStream.on('error', function(err) {
done(err);
});
writeStream.on('close', function(ex) {
done();
});
readStream.pipe(writeStream);
function done(err) {
if (!cbCalled) {
cb(err);
cbCalled = true;
}
}
}
module.exports = copyAndReplace;

58
local-cli/util/yarn.js Normal file
View File

@ -0,0 +1,58 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
const fs = require('fs');
const path = require('path');
const semver = require('semver');
/**
* Use Yarn if available, it's much faster than the npm client.
* Return the version of yarn installed on the system, null if yarn is not available.
*/
function getYarnVersionIfAvailable() {
let yarnVersion;
try {
// execSync returns a Buffer -> convert to string
if (process.platform.startsWith('win')) {
yarnVersion = (execSync('yarn --version').toString() || '').trim();
} else {
yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '').trim();
}
} catch (error) {
return null;
}
// yarn < 0.16 has a 'missing manifest' bug
try {
if (semver.gte(yarnVersion, '0.16.0')) {
return yarnVersion;
} else {
return null;
}
} catch (error) {
console.error('Cannot parse yarn version: ' + yarnVersion);
return null;
}
}
/**
* Check that 'react-native init' itself used yarn to install React Native.
* When using an old global react-native-cli@1.0.0 (or older), we don't want
* to install React Native with npm, and React + Jest with yarn.
* Let's be safe and not mix yarn and npm in a single project.
* @param projectDir e.g. /Users/martin/AwesomeApp
*/
function isGlobalCliUsingYarn(projectDir) {
return fs.existsSync(path.join(projectDir, 'yarn.lock'));
}
module.exports = {
getYarnVersionIfAvailable: getYarnVersionIfAvailable,
isGlobalCliUsingYarn: isGlobalCliUsingYarn,
};

View File

@ -27,7 +27,7 @@
"testPathIgnorePatterns": [
"/node_modules/",
"/website/",
"local-cli/generator/templates/"
"local-cli/templates/"
],
"haste": {
"defaultPlatform": "ios",

View File

@ -273,7 +273,7 @@ function run(root, projectName, rnPackage, forceNpmClient) {
console.log('Installing ' + getInstallPackage(rnPackage) + '...');
installCommand = 'yarn add ' + getInstallPackage(rnPackage) + ' --exact';
} else {
console.log('Installing ' + getInstallPackage(rnPackage) + ' from npm...');
console.log('Installing ' + getInstallPackage(rnPackage) + '...');
if (!forceNpmClient) {
console.log('Consider installing yarn to make this faster: https://yarnpkg.com');
}

View File

@ -33,8 +33,8 @@ const TEMP = exec('mktemp -d /tmp/react-native-XXXXXXXX').stdout.trim();
// To make sure we actually installed the local version
// of react-native, we will create a temp file inside the template
// and check that it exists after `react-native init
const MARKER_IOS = exec(`mktemp ${ROOT}/local-cli/generator-ios/templates/app/XXXXXXXX`).stdout.trim();
const MARKER_ANDROID = exec(`mktemp ${ROOT}/local-cli/generator-android/templates/src/XXXXXXXX`).stdout.trim();
const MARKER_IOS = exec(`mktemp ${ROOT}/local-cli/templates/HelloWorld/ios/HelloWorld/XXXXXXXX`).stdout.trim();
const MARKER_ANDROID = exec(`mktemp ${ROOT}/local-cli/templates/HelloWorld/android/XXXXXXXX`).stdout.trim();
const numberOfRetries = argv.retries || 1;
let SERVER_PID;
let APPIUM_PID;
@ -186,12 +186,12 @@ try {
if (argv.js) {
// Check the packager produces a bundle (doesn't throw an error)
if (exec('REACT_NATIVE_MAX_WORKERS=1 react-native bundle --platform android --dev true --entry-file index.android.js --bundle-output android-bundle.js').code) {
echo('Could not build android package');
echo('Could not build Android bundle');
exitCode = 1;
throw Error(exitCode);
}
if (exec('REACT_NATIVE_MAX_WORKERS=1 react-native bundle --platform ios --dev true --entry-file index.ios.js --bundle-output ios-bundle.js').code) {
echo('Could not build ios package');
echo('Could not build iOS bundle');
exitCode = 1;
throw Error(exitCode);
}