Adjust rnpm link to colorize skipped linking steps
Summary: Sometimes when working with a team of developers, someone adds a library but does not link it. To identify if this required linking, you have to type react-native link and then read a wall of text to see if rnpm handled the issue. This can be sped up with a friendly logging level for previously linked messages. Continuation of #9507 ![image](https://cloud.githubusercontent.com/assets/997157/17908676/119884a2-6947-11e6-8297-818fefed26a0.png) ![image](https://cloud.githubusercontent.com/assets/997157/17908687/1bad1b56-6947-11e6-9cf5-b8eec1f2d6ef.png) Closes https://github.com/facebook/react-native/pull/9551 Differential Revision: D3821468 Pulled By: bestander fbshipit-source-id: 3e83bf46454519debdd95cf3d5e8561e3c77364a
This commit is contained in:
parent
406a1b3ca2
commit
db870f8729
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* 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 mockColor = () => {
|
||||
return {
|
||||
bold: () => { return { }; },
|
||||
};
|
||||
};
|
||||
|
||||
mockColor.bold = function() {
|
||||
return {};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
dim: s => s,
|
||||
magenta: mockColor,
|
||||
white: mockColor,
|
||||
blue: mockColor,
|
||||
yellow: mockColor,
|
||||
green: mockColor,
|
||||
bold: mockColor,
|
||||
red: mockColor,
|
||||
cyan: mockColor,
|
||||
gray: mockColor,
|
||||
black: mockColor,
|
||||
};
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) 2013-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();
|
||||
|
@ -5,6 +14,10 @@ jest.autoMockOff();
|
|||
const sinon = require('sinon');
|
||||
const log = require('npmlog');
|
||||
const path = require('path');
|
||||
jest.setMock(
|
||||
'chalk',
|
||||
{ grey: (str) => str, }
|
||||
);
|
||||
|
||||
describe('link', () => {
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
/**
|
||||
* Copyright (c) 2013-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.
|
||||
*/
|
||||
|
||||
const log = require('npmlog');
|
||||
const path = require('path');
|
||||
const uniq = require('lodash').uniq;
|
||||
const flatten = require('lodash').flatten;
|
||||
const chalk = require('chalk');
|
||||
|
||||
const isEmpty = require('lodash').isEmpty;
|
||||
const promiseWaterfall = require('./promiseWaterfall');
|
||||
|
@ -30,7 +40,7 @@ const linkDependencyAndroid = (androidProject, dependency) => {
|
|||
const isInstalled = isInstalledAndroid(androidProject, dependency.name);
|
||||
|
||||
if (isInstalled) {
|
||||
log.info(`Android module ${dependency.name} is already linked`);
|
||||
log.info(chalk.grey(`Android module ${dependency.name} is already linked`));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -56,7 +66,7 @@ const linkDependencyIOS = (iOSProject, dependency) => {
|
|||
const isInstalled = isInstalledIOS(iOSProject, dependency.config.ios);
|
||||
|
||||
if (isInstalled) {
|
||||
log.info(`iOS module ${dependency.name} is already linked`);
|
||||
log.info(chalk.grey(`iOS module ${dependency.name} is already linked`));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,7 +92,7 @@ const linkAssets = (project, assets) => {
|
|||
copyAssetsAndroid(assets, project.android.assetsPath);
|
||||
}
|
||||
|
||||
log.info(`Assets have been successfully linked to your project`);
|
||||
log.info('Assets have been successfully linked to your project');
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -126,11 +136,11 @@ function link(args, config) {
|
|||
return promiseWaterfall(tasks).catch(err => {
|
||||
log.error(
|
||||
`It seems something went wrong while linking. Error: ${err.message} \n`
|
||||
+ `Please file an issue here: https://github.com/facebook/react-native/issues`
|
||||
+ 'Please file an issue here: https://github.com/facebook/react-native/issues'
|
||||
);
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
func: link,
|
||||
|
|
Loading…
Reference in New Issue