Prettier files with shebang
Reviewed By: yungsters Differential Revision: D7974564 fbshipit-source-id: 00db563ce24868c0fde117e981936b83cec30e48
This commit is contained in:
parent
36fcbaa56d
commit
0e5c2633ee
|
@ -7,6 +7,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
@ -26,8 +27,8 @@ An incoming message of 'exit' will shut down the server.
|
|||
`);
|
||||
|
||||
const server = new WebSocket.Server({port: 5555});
|
||||
server.on('connection', (ws) => {
|
||||
ws.on('message', (message) => {
|
||||
server.on('connection', ws => {
|
||||
ws.on('message', message => {
|
||||
console.log('Received message:', message);
|
||||
if (message === 'exit') {
|
||||
console.log('WebSocket integration test server exit');
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
@ -29,8 +30,8 @@ ArrayBuffer instead of a string.
|
|||
|
||||
const respondWithBinary = process.argv.indexOf('--binary') !== -1;
|
||||
const server = new WebSocket.Server({port: 5555});
|
||||
server.on('connection', (ws) => {
|
||||
ws.on('message', (message) => {
|
||||
server.on('connection', ws => {
|
||||
ws.on('message', message => {
|
||||
console.log('Received message:', message);
|
||||
console.log('Cookie:', ws.upgradeReq.headers.cookie);
|
||||
if (respondWithBinary) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
|
@ -14,23 +16,28 @@ if (isWindows) {
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
// On Windows, assume we are installed globally if we can't find a package.json above node_modules.
|
||||
installedGlobally = !(fs.existsSync(path.join(__dirname, '../../../package.json')));
|
||||
installedGlobally = !fs.existsSync(
|
||||
path.join(__dirname, '../../../package.json'),
|
||||
);
|
||||
} else {
|
||||
// On non-windows, assume we are installed globally if we are called from outside of the node_mobules/.bin/react-native executable.
|
||||
var script = process.argv[1];
|
||||
installedGlobally = script.indexOf('node_modules/.bin/react-native') === -1;
|
||||
}
|
||||
|
||||
|
||||
if (installedGlobally) {
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.error([
|
||||
chalk.red('Looks like you installed react-native globally, maybe you meant react-native-cli?'),
|
||||
chalk.red('To fix the issue, run:'),
|
||||
'npm uninstall -g react-native',
|
||||
'npm install -g react-native-cli'
|
||||
].join('\n'));
|
||||
console.error(
|
||||
[
|
||||
chalk.red(
|
||||
'Looks like you installed react-native globally, maybe you meant react-native-cli?',
|
||||
),
|
||||
chalk.red('To fix the issue, run:'),
|
||||
'npm uninstall -g react-native',
|
||||
'npm install -g react-native-cli',
|
||||
].join('\n'),
|
||||
);
|
||||
process.exit(1);
|
||||
} else {
|
||||
require('./cli').run();
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -60,12 +62,7 @@ var semver = require('semver');
|
|||
var options = require('minimist')(process.argv.slice(2));
|
||||
|
||||
var CLI_MODULE_PATH = function() {
|
||||
return path.resolve(
|
||||
process.cwd(),
|
||||
'node_modules',
|
||||
'react-native',
|
||||
'cli.js'
|
||||
);
|
||||
return path.resolve(process.cwd(), 'node_modules', 'react-native', 'cli.js');
|
||||
};
|
||||
|
||||
var REACT_NATIVE_PACKAGE_JSON_PATH = function() {
|
||||
|
@ -73,7 +70,7 @@ var REACT_NATIVE_PACKAGE_JSON_PATH = function() {
|
|||
process.cwd(),
|
||||
'node_modules',
|
||||
'react-native',
|
||||
'package.json'
|
||||
'package.json',
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -90,7 +87,9 @@ function getYarnVersionIfAvailable() {
|
|||
if (process.platform.startsWith('win')) {
|
||||
yarnVersion = (execSync('yarn --version 2> NUL').toString() || '').trim();
|
||||
} else {
|
||||
yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '').trim();
|
||||
yarnVersion = (
|
||||
execSync('yarn --version 2>/dev/null').toString() || ''
|
||||
).trim();
|
||||
}
|
||||
} catch (error) {
|
||||
return null;
|
||||
|
@ -119,51 +118,51 @@ if (cli) {
|
|||
cli.run();
|
||||
} else {
|
||||
if (options._.length === 0 && (options.h || options.help)) {
|
||||
console.log([
|
||||
'',
|
||||
' Usage: react-native [command] [options]',
|
||||
'',
|
||||
'',
|
||||
' Commands:',
|
||||
'',
|
||||
' init <ProjectName> [options] generates a new project and installs its dependencies',
|
||||
'',
|
||||
' Options:',
|
||||
'',
|
||||
' -h, --help output usage information',
|
||||
' -v, --version use a specific version of React Native',
|
||||
' --template use an app template. Use --template to see available templates.',
|
||||
'',
|
||||
].join('\n'));
|
||||
console.log(
|
||||
[
|
||||
'',
|
||||
' Usage: react-native [command] [options]',
|
||||
'',
|
||||
'',
|
||||
' Commands:',
|
||||
'',
|
||||
' init <ProjectName> [options] generates a new project and installs its dependencies',
|
||||
'',
|
||||
' Options:',
|
||||
'',
|
||||
' -h, --help output usage information',
|
||||
' -v, --version use a specific version of React Native',
|
||||
' --template use an app template. Use --template to see available templates.',
|
||||
'',
|
||||
].join('\n'),
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (commands.length === 0) {
|
||||
console.error(
|
||||
'You did not pass any commands, run `react-native --help` to see a list of all available commands.'
|
||||
'You did not pass any commands, run `react-native --help` to see a list of all available commands.',
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
switch (commands[0]) {
|
||||
case 'init':
|
||||
if (!commands[1]) {
|
||||
case 'init':
|
||||
if (!commands[1]) {
|
||||
console.error('Usage: react-native init <ProjectName> [--verbose]');
|
||||
process.exit(1);
|
||||
} else {
|
||||
init(commands[1], options);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.error(
|
||||
'Usage: react-native init <ProjectName> [--verbose]'
|
||||
'Command `%s` unrecognized. ' +
|
||||
'Make sure that you have run `npm install` and that you are inside a react-native project.',
|
||||
commands[0],
|
||||
);
|
||||
process.exit(1);
|
||||
} else {
|
||||
init(commands[1], options);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.error(
|
||||
'Command `%s` unrecognized. ' +
|
||||
'Make sure that you have run `npm install` and that you are inside a react-native project.',
|
||||
commands[0]
|
||||
);
|
||||
process.exit(1);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +171,7 @@ function validateProjectName(name) {
|
|||
console.error(
|
||||
'"%s" is not a valid name for a project. Please use a valid identifier ' +
|
||||
'name (alphanumeric).',
|
||||
name
|
||||
name,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -181,7 +180,7 @@ function validateProjectName(name) {
|
|||
console.error(
|
||||
'"%s" is not a valid name for a project. Please do not use the ' +
|
||||
'reserved word "React".',
|
||||
name
|
||||
name,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -212,10 +211,10 @@ function createAfterConfirmation(name, options) {
|
|||
message: 'Directory ' + name + ' already exists. Continue?',
|
||||
validator: /y[es]*|n[o]?/,
|
||||
warning: 'Must respond yes or no',
|
||||
default: 'no'
|
||||
default: 'no',
|
||||
};
|
||||
|
||||
prompt.get(property, function (err, result) {
|
||||
prompt.get(property, function(err, result) {
|
||||
if (result.yesno[0] === 'y') {
|
||||
createProject(name, options);
|
||||
} else {
|
||||
|
@ -231,7 +230,7 @@ function createProject(name, options) {
|
|||
|
||||
console.log(
|
||||
'This will walk you through creating a new React Native project in',
|
||||
root
|
||||
root,
|
||||
);
|
||||
|
||||
if (!fs.existsSync(root)) {
|
||||
|
@ -246,9 +245,12 @@ function createProject(name, options) {
|
|||
start: 'node node_modules/react-native/local-cli/cli.js start',
|
||||
ios: 'react-native run-ios',
|
||||
android: 'react-native run-android',
|
||||
}
|
||||
},
|
||||
};
|
||||
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson));
|
||||
fs.writeFileSync(
|
||||
path.join(root, 'package.json'),
|
||||
JSON.stringify(packageJson),
|
||||
);
|
||||
process.chdir(root);
|
||||
|
||||
run(root, projectName, options);
|
||||
|
@ -269,7 +271,7 @@ function getInstallPackage(rnPackage) {
|
|||
function run(root, projectName, options) {
|
||||
var rnPackage = options.version; // e.g. '0.38' or '/path/to/archive.tgz'
|
||||
var forceNpmClient = options.npm;
|
||||
var yarnVersion = (!forceNpmClient) && getYarnVersionIfAvailable();
|
||||
var yarnVersion = !forceNpmClient && getYarnVersionIfAvailable();
|
||||
var installCommand;
|
||||
if (options.installCommand) {
|
||||
// In CI environments it can be useful to provide a custom command,
|
||||
|
@ -286,9 +288,12 @@ function run(root, projectName, options) {
|
|||
} else {
|
||||
console.log('Installing ' + getInstallPackage(rnPackage) + '...');
|
||||
if (!forceNpmClient) {
|
||||
console.log('Consider installing yarn to make this faster: https://yarnpkg.com');
|
||||
console.log(
|
||||
'Consider installing yarn to make this faster: https://yarnpkg.com',
|
||||
);
|
||||
}
|
||||
installCommand = 'npm install --save --save-exact ' + getInstallPackage(rnPackage);
|
||||
installCommand =
|
||||
'npm install --save --save-exact ' + getInstallPackage(rnPackage);
|
||||
if (options.verbose) {
|
||||
installCommand += ' --verbose';
|
||||
}
|
||||
|
@ -312,13 +317,15 @@ function checkNodeVersion() {
|
|||
return;
|
||||
}
|
||||
if (!semver.satisfies(process.version, packageJson.engines.node)) {
|
||||
console.error(chalk.red(
|
||||
console.error(
|
||||
chalk.red(
|
||||
'You are currently running Node %s but React Native requires %s. ' +
|
||||
'Please use a supported version of Node.\n' +
|
||||
'See https://facebook.github.io/react-native/docs/getting-started.html'
|
||||
'Please use a supported version of Node.\n' +
|
||||
'See https://facebook.github.io/react-native/docs/getting-started.html',
|
||||
),
|
||||
process.version,
|
||||
packageJson.engines.node);
|
||||
packageJson.engines.node,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,7 +334,9 @@ function printVersionsAndExit(reactNativePackageJsonPath) {
|
|||
try {
|
||||
console.log('react-native: ' + require(reactNativePackageJsonPath).version);
|
||||
} catch (e) {
|
||||
console.log('react-native: n/a - not inside a React Native project directory');
|
||||
console.log(
|
||||
'react-native: n/a - not inside a React Native project directory',
|
||||
);
|
||||
}
|
||||
process.exit();
|
||||
}
|
||||
|
|
|
@ -5,30 +5,34 @@
|
|||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
var cli = require('./cli');
|
||||
|
||||
if (argv._.length === 0 && (argv.h || argv.help)) {
|
||||
console.log([
|
||||
'',
|
||||
' Usage: react-native-git-upgrade [version] [options]',
|
||||
'',
|
||||
'',
|
||||
' Commands:',
|
||||
'',
|
||||
' [Version] upgrades React Native and app templates to the desired version',
|
||||
' (latest, if not specified)',
|
||||
'',
|
||||
' Options:',
|
||||
'',
|
||||
' -h, --help output usage information',
|
||||
' -v, --version output the version number',
|
||||
' --verbose output debugging info',
|
||||
' --npm force using the npm client even if your project uses yarn',
|
||||
'',
|
||||
].join('\n'));
|
||||
console.log(
|
||||
[
|
||||
'',
|
||||
' Usage: react-native-git-upgrade [version] [options]',
|
||||
'',
|
||||
'',
|
||||
' Commands:',
|
||||
'',
|
||||
' [Version] upgrades React Native and app templates to the desired version',
|
||||
' (latest, if not specified)',
|
||||
'',
|
||||
' Options:',
|
||||
'',
|
||||
' -h, --help output usage information',
|
||||
' -v, --version output the version number',
|
||||
' --verbose output debugging info',
|
||||
' --npm force using the npm client even if your project uses yarn',
|
||||
'',
|
||||
].join('\n'),
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
@ -37,5 +41,4 @@ if (argv._.length === 0 && (argv.v || argv.version)) {
|
|||
process.exit(0);
|
||||
}
|
||||
|
||||
cli.run(argv._[0], argv)
|
||||
.catch(console.error);
|
||||
cli.run(argv._[0], argv).catch(console.error);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
@ -14,13 +16,7 @@
|
|||
* All you have to do is push changes to remote and CI will make a new build.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const {
|
||||
cat,
|
||||
echo,
|
||||
exec,
|
||||
exit,
|
||||
sed,
|
||||
} = require('shelljs');
|
||||
const {cat, echo, exec, exit, sed} = require('shelljs');
|
||||
|
||||
const minimist = require('minimist');
|
||||
|
||||
|
@ -30,7 +26,9 @@ let argv = minimist(process.argv.slice(2), {
|
|||
});
|
||||
|
||||
// - check we are in release branch, e.g. 0.33-stable
|
||||
let branch = exec('git symbolic-ref --short HEAD', {silent: true}).stdout.trim();
|
||||
let branch = exec('git symbolic-ref --short HEAD', {
|
||||
silent: true,
|
||||
}).stdout.trim();
|
||||
|
||||
if (branch.indexOf('-stable') === -1) {
|
||||
echo('You must be in 0.XX-stable branch to bump a version');
|
||||
|
@ -44,14 +42,18 @@ let versionMajor = branch.slice(0, branch.indexOf('-stable'));
|
|||
// e.g. 0.33.1 or 0.33.0-rc4
|
||||
let version = argv._[0];
|
||||
if (!version || version.indexOf(versionMajor) !== 0) {
|
||||
echo(`You must pass a tag like 0.${versionMajor}.[X]-rc[Y] to bump a version`);
|
||||
echo(
|
||||
`You must pass a tag like 0.${versionMajor}.[X]-rc[Y] to bump a version`,
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Generate version files to detect mismatches between JS and native.
|
||||
let match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
|
||||
if (!match) {
|
||||
echo(`You must pass a correctly formatted version; couldn't parse ${version}`);
|
||||
echo(
|
||||
`You must pass a correctly formatted version; couldn't parse ${version}`,
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
let [, major, minor, patch, prerelease] = match;
|
||||
|
@ -62,8 +64,11 @@ fs.writeFileSync(
|
|||
.replace('${major}', major)
|
||||
.replace('${minor}', minor)
|
||||
.replace('${patch}', patch)
|
||||
.replace('${prerelease}', prerelease !== undefined ? `"${prerelease}"` : 'null'),
|
||||
'utf-8'
|
||||
.replace(
|
||||
'${prerelease}',
|
||||
prerelease !== undefined ? `"${prerelease}"` : 'null',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
|
@ -72,8 +77,11 @@ fs.writeFileSync(
|
|||
.replace('${major}', `@(${major})`)
|
||||
.replace('${minor}', `@(${minor})`)
|
||||
.replace('${patch}', `@(${patch})`)
|
||||
.replace('${prerelease}', prerelease !== undefined ? `@"${prerelease}"` : '[NSNull null]'),
|
||||
'utf-8'
|
||||
.replace(
|
||||
'${prerelease}',
|
||||
prerelease !== undefined ? `@"${prerelease}"` : '[NSNull null]',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
|
@ -82,8 +90,11 @@ fs.writeFileSync(
|
|||
.replace('${major}', major)
|
||||
.replace('${minor}', minor)
|
||||
.replace('${patch}', patch)
|
||||
.replace('${prerelease}', prerelease !== undefined ? `'${prerelease}'` : 'null'),
|
||||
'utf-8'
|
||||
.replace(
|
||||
'${prerelease}',
|
||||
prerelease !== undefined ? `'${prerelease}'` : 'null',
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
let packageJson = JSON.parse(cat('package.json'));
|
||||
|
@ -91,16 +102,27 @@ packageJson.version = version;
|
|||
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');
|
||||
|
||||
// - change ReactAndroid/gradle.properties
|
||||
if (sed('-i', /^VERSION_NAME=.*/, `VERSION_NAME=${version}`, 'ReactAndroid/gradle.properties').code) {
|
||||
echo('Couldn\'t update version for Gradle');
|
||||
if (
|
||||
sed(
|
||||
'-i',
|
||||
/^VERSION_NAME=.*/,
|
||||
`VERSION_NAME=${version}`,
|
||||
'ReactAndroid/gradle.properties',
|
||||
).code
|
||||
) {
|
||||
echo("Couldn't update version for Gradle");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// verify that files changed, we just do a git diff and check how many times version is added across files
|
||||
let numberOfChangedLinesWithNewVersion = exec(`git diff -U0 | grep '^[+]' | grep -c ${version} `, {silent: true})
|
||||
.stdout.trim();
|
||||
let numberOfChangedLinesWithNewVersion = exec(
|
||||
`git diff -U0 | grep '^[+]' | grep -c ${version} `,
|
||||
{silent: true},
|
||||
).stdout.trim();
|
||||
if (+numberOfChangedLinesWithNewVersion !== 2) {
|
||||
echo('Failed to update all the files. package.json and gradle.properties must have versions in them');
|
||||
echo(
|
||||
'Failed to update all the files. package.json and gradle.properties must have versions in them',
|
||||
);
|
||||
echo('Fix the issue, revert and try again');
|
||||
exec('git diff');
|
||||
exit(1);
|
||||
|
@ -114,7 +136,9 @@ if (exec(`git commit -a -m "[${version}] Bump version numbers"`).code) {
|
|||
|
||||
// - add tag v0.21.0-rc
|
||||
if (exec(`git tag v${version}`).code) {
|
||||
echo(`failed to tag the commit with v${version}, are you sure this release wasn't made earlier?`);
|
||||
echo(
|
||||
`failed to tag the commit with v${version}, are you sure this release wasn't made earlier?`,
|
||||
);
|
||||
echo('You may want to rollback the last commit');
|
||||
echo('git reset --hard HEAD~1');
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue