mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
remove rnc/cli-tools version & errors deps (#45380)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45380 Removed the use of version checking and error code that is in react-native-community/cli-tools. Changelog: [Internal] [Changed] - Removed community-cli-plugin version & error dependencies Reviewed By: robhogan Differential Revision: D59378012 fbshipit-source-id: b009edc615b873ff2bff31296ac5d87a4482944f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6547b157b5
commit
9aaadd9b2e
@@ -17,12 +17,12 @@ import typeof TerminalReporter from 'metro/src/lib/TerminalReporter';
|
||||
import isDevServerRunning from '../../utils/isDevServerRunning';
|
||||
import loadMetroConfig from '../../utils/loadMetroConfig';
|
||||
import {logger} from '../../utils/logger';
|
||||
import * as version from '../../utils/version';
|
||||
import attachKeyHandlers from './attachKeyHandlers';
|
||||
import {
|
||||
createDevServerMiddleware,
|
||||
indexPageMiddleware,
|
||||
} from '@react-native-community/cli-server-api';
|
||||
import {version} from '@react-native-community/cli-tools';
|
||||
import {createDevMiddleware} from '@react-native/dev-middleware';
|
||||
import chalk from 'chalk';
|
||||
import Metro from 'metro';
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
import {CLIError} from './errors';
|
||||
import {logger} from './logger';
|
||||
import {CLIError} from '@react-native-community/cli-tools';
|
||||
|
||||
const CTRL_C = '\u0003';
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
/**
|
||||
* A custom Error that creates a single-lined message to match current styling inside CLI.
|
||||
* Uses original stack trace when `originalError` is passed or erase the stack if it's not defined.
|
||||
*/
|
||||
export class CLIError extends Error {
|
||||
constructor(msg: string, originalError?: Error | string) {
|
||||
super(inlineString(msg));
|
||||
if (originalError != null) {
|
||||
this.stack =
|
||||
typeof originalError === 'string'
|
||||
? originalError
|
||||
: originalError.stack || ''.split('\n').slice(0, 2).join('\n');
|
||||
} else {
|
||||
// When the "originalError" is not passed, it means that we know exactly
|
||||
// what went wrong and provide means to fix it. In such cases showing the
|
||||
// stack is an unnecessary clutter to the CLI output, hence removing it.
|
||||
this.stack = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raised when we're unable to find a package.json
|
||||
*/
|
||||
export class UnknownProjectError extends Error {}
|
||||
|
||||
export const inlineString = (str: string = ''): string =>
|
||||
str.replace(/(\s{2,})/gm, ' ').trim();
|
||||
@@ -12,9 +12,9 @@
|
||||
import type {Config} from '@react-native-community/cli-types';
|
||||
import type {ConfigT, InputConfigT, YargArguments} from 'metro-config';
|
||||
|
||||
import {CLIError} from './errors';
|
||||
import {logger} from './logger';
|
||||
import {reactNativePlatformResolver} from './metroPlatformResolver';
|
||||
import {CLIError} from '@react-native-community/cli-tools';
|
||||
import {loadConfig, mergeConfig, resolveConfig} from 'metro-config';
|
||||
import path from 'path';
|
||||
|
||||
|
||||
@@ -74,7 +74,26 @@ const enable = () => {
|
||||
|
||||
const hasDebugMessages = (): boolean => hidden;
|
||||
|
||||
export const logger = {
|
||||
let communityLogger;
|
||||
try {
|
||||
const {logger} = require('@react-native-community/cli-tools');
|
||||
logger.debug("Using @react-naive-community/cli-tools' logger");
|
||||
communityLogger = logger;
|
||||
} catch {
|
||||
// This is no longer a required dependency in react-native projects, but use it instead of
|
||||
// our forked version if it's available. Fail silently otherwise.
|
||||
}
|
||||
|
||||
type Logger = $ReadOnly<{
|
||||
debug: (...message: Array<string>) => void,
|
||||
error: (...message: Array<string>) => void,
|
||||
log: (...message: Array<string>) => void,
|
||||
info: (...message: Array<string>) => void,
|
||||
warn: (...message: Array<string>) => void,
|
||||
...
|
||||
}>;
|
||||
|
||||
export const logger: Logger = communityLogger ?? {
|
||||
success,
|
||||
info,
|
||||
warn,
|
||||
@@ -87,3 +106,7 @@ export const logger = {
|
||||
disable,
|
||||
enable,
|
||||
};
|
||||
|
||||
if (communityLogger == null) {
|
||||
logger.debug("Using @react-native/communityu-cli-plugin's logger");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user