chrome: restore colors enabled/levels logic (#34767)
This commit is contained in:
parent
3d760b657b
commit
ded909c13f
|
@ -11,6 +11,7 @@ This project incorporates components from the projects listed below. The origina
|
|||
- brace-expansion@1.1.11 (https://github.com/juliangruber/brace-expansion)
|
||||
- buffer-crc32@0.2.13 (https://github.com/brianloveswords/buffer-crc32)
|
||||
- codemirror@5.65.18 (https://github.com/codemirror/CodeMirror)
|
||||
- colors@1.4.0 (https://github.com/Marak/colors.js)
|
||||
- commander@8.3.0 (https://github.com/tj/commander.js)
|
||||
- concat-map@0.0.1 (https://github.com/substack/node-concat-map)
|
||||
- debug@4.3.4 (https://github.com/debug-js/debug)
|
||||
|
@ -354,6 +355,36 @@ THE SOFTWARE.
|
|||
=========================================
|
||||
END OF codemirror@5.65.18 AND INFORMATION
|
||||
|
||||
%% colors@1.4.0 NOTICES AND INFORMATION BEGIN HERE
|
||||
=========================================
|
||||
MIT License
|
||||
|
||||
Original Library
|
||||
- Copyright (c) Marak Squires
|
||||
|
||||
Additional Functionality
|
||||
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
=========================================
|
||||
END OF colors@1.4.0 AND INFORMATION
|
||||
|
||||
%% commander@8.3.0 NOTICES AND INFORMATION BEGIN HERE
|
||||
=========================================
|
||||
(The MIT License)
|
||||
|
@ -1524,6 +1555,6 @@ END OF yazl@2.5.1 AND INFORMATION
|
|||
|
||||
SUMMARY BEGIN HERE
|
||||
=========================================
|
||||
Total Packages: 45
|
||||
Total Packages: 46
|
||||
=========================================
|
||||
END OF SUMMARY
|
|
@ -8,6 +8,7 @@
|
|||
"name": "utils-bundle",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"colors": "1.4.0",
|
||||
"commander": "8.3.0",
|
||||
"debug": "^4.3.4",
|
||||
"diff": "^7.0.0",
|
||||
|
@ -162,6 +163,15 @@
|
|||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/colors": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
|
||||
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"colors": "1.4.0",
|
||||
"commander": "8.3.0",
|
||||
"debug": "^4.3.4",
|
||||
"diff": "^7.0.0",
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
/* eslint-disable import/order */
|
||||
|
||||
import colorsLibrary from 'colors/safe';
|
||||
export const colors = colorsLibrary;
|
||||
|
||||
import debugLibrary from 'debug';
|
||||
export const debug = debugLibrary;
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ export class Connection extends EventEmitter {
|
|||
this._callbacks.delete(id);
|
||||
if (error && !result) {
|
||||
const parsedError = parseError(error);
|
||||
rewriteErrorMessage(parsedError, parsedError.message + formatCallLog(log));
|
||||
rewriteErrorMessage(parsedError, parsedError.message + formatCallLog(this.platform, log));
|
||||
callback.reject(parsedError);
|
||||
} else {
|
||||
const validator = findValidator(callback.type, callback.method, 'Result');
|
||||
|
|
|
@ -18,8 +18,14 @@ import * as crypto from 'crypto';
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import { webColors, noColors } from '../utils/isomorphic/colors';
|
||||
|
||||
import type { Colors } from '../utils/isomorphic/colors';
|
||||
|
||||
|
||||
export type Platform = {
|
||||
calculateSha1(text: string): Promise<string>;
|
||||
colors: Colors;
|
||||
createGuid: () => string;
|
||||
fs: () => typeof fs;
|
||||
inspectCustom: symbol | undefined;
|
||||
|
@ -37,6 +43,8 @@ export const webPlatform: Platform = {
|
|||
return Array.from(new Uint8Array(hashBuffer), b => b.toString(16).padStart(2, '0')).join('');
|
||||
},
|
||||
|
||||
colors: webColors,
|
||||
|
||||
createGuid: () => {
|
||||
return Array.from(crypto.getRandomValues(new Uint8Array(16)), b => b.toString(16).padStart(2, '0')).join('');
|
||||
},
|
||||
|
@ -68,6 +76,8 @@ export const emptyPlatform: Platform = {
|
|||
throw new Error('Not implemented');
|
||||
},
|
||||
|
||||
colors: noColors,
|
||||
|
||||
createGuid: () => {
|
||||
throw new Error('Not implemented');
|
||||
},
|
||||
|
|
|
@ -23,8 +23,7 @@ import * as path from 'path';
|
|||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
|
||||
import { getUserAgent } from '../utils/userAgent';
|
||||
import { progress as ProgressBar } from '../../utilsBundle';
|
||||
import { colors } from '../../utils/isomorphic/colors';
|
||||
import { progress as ProgressBar, colors } from '../../utilsBundle';
|
||||
import { existsAsync } from '../utils/fileUtils';
|
||||
|
||||
import { browserDirectoryToMarkerFilePath } from '.';
|
||||
|
|
|
@ -19,8 +19,7 @@ import { compare } from './image_tools/compare';
|
|||
// @ts-ignore
|
||||
import pixelmatch from '../../third_party/pixelmatch';
|
||||
import { jpegjs } from '../../utilsBundle';
|
||||
import { colors } from '../../utils/isomorphic/colors';
|
||||
import { diff } from '../../utilsBundle';
|
||||
import { colors, diff } from '../../utilsBundle';
|
||||
import { PNG } from '../../utilsBundle';
|
||||
|
||||
export type ImageComparatorOptions = { threshold?: number, maxDiffPixels?: number, maxDiffPixelRatio?: number, comparator?: string };
|
||||
|
|
|
@ -19,6 +19,7 @@ import * as fs from 'fs';
|
|||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
|
||||
import { colors } from '../../utilsBundle';
|
||||
import { Platform } from '../../common/platform';
|
||||
import { debugLogger } from './debugLogger';
|
||||
|
||||
|
@ -29,6 +30,8 @@ export const nodePlatform: Platform = {
|
|||
return Promise.resolve(sha1.digest('hex'));
|
||||
},
|
||||
|
||||
colors,
|
||||
|
||||
createGuid: () => crypto.randomBytes(16).toString('hex'),
|
||||
|
||||
fs: () => fs,
|
||||
|
|
|
@ -44,9 +44,12 @@ export * from './server/utils/fileUtils';
|
|||
export * from './server/utils/hostPlatform';
|
||||
export * from './server/utils/httpServer';
|
||||
export * from './server/utils/network';
|
||||
export * from './server/utils/nodePlatform';
|
||||
export * from './server/utils/processLauncher';
|
||||
export * from './server/utils/profiler';
|
||||
export * from './server/utils/socksProxy';
|
||||
export * from './server/utils/spawnAsync';
|
||||
export * from './server/utils/userAgent';
|
||||
export * from './server/utils/wsServer';
|
||||
|
||||
export { colors } from './utilsBundle';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const colors = {
|
||||
export const webColors = {
|
||||
enabled: true,
|
||||
reset: (text: string) => applyStyle(0, 0, text),
|
||||
|
||||
|
@ -36,36 +36,9 @@ export const colors = {
|
|||
white: (text: string) => applyStyle(37, 39, text),
|
||||
gray: (text: string) => applyStyle(90, 39, text),
|
||||
grey: (text: string) => applyStyle(90, 39, text),
|
||||
|
||||
brightRed: (text: string) => applyStyle(91, 39, text),
|
||||
brightGreen: (text: string) => applyStyle(92, 39, text),
|
||||
brightYellow: (text: string) => applyStyle(93, 39, text),
|
||||
brightBlue: (text: string) => applyStyle(94, 39, text),
|
||||
brightMagenta: (text: string) => applyStyle(95, 39, text),
|
||||
brightCyan: (text: string) => applyStyle(96, 39, text),
|
||||
brightWhite: (text: string) => applyStyle(97, 39, text),
|
||||
|
||||
bgBlack: (text: string) => applyStyle(40, 49, text),
|
||||
bgRed: (text: string) => applyStyle(41, 49, text),
|
||||
bgGreen: (text: string) => applyStyle(42, 49, text),
|
||||
bgYellow: (text: string) => applyStyle(43, 49, text),
|
||||
bgBlue: (text: string) => applyStyle(44, 49, text),
|
||||
bgMagenta: (text: string) => applyStyle(45, 49, text),
|
||||
bgCyan: (text: string) => applyStyle(46, 49, text),
|
||||
bgWhite: (text: string) => applyStyle(47, 49, text),
|
||||
bgGray: (text: string) => applyStyle(100, 49, text),
|
||||
bgGrey: (text: string) => applyStyle(100, 49, text),
|
||||
|
||||
bgBrightRed: (text: string) => applyStyle(101, 49, text),
|
||||
bgBrightGreen: (text: string) => applyStyle(102, 49, text),
|
||||
bgBrightYellow: (text: string) => applyStyle(103, 49, text),
|
||||
bgBrightBlue: (text: string) => applyStyle(104, 49, text),
|
||||
bgBrightMagenta: (text: string) => applyStyle(105, 49, text),
|
||||
bgBrightCyan: (text: string) => applyStyle(106, 49, text),
|
||||
bgBrightWhite: (text: string) => applyStyle(107, 49, text),
|
||||
};
|
||||
|
||||
type Colors = typeof colors;
|
||||
export type Colors = typeof webColors;
|
||||
|
||||
export const noColors: Colors = {
|
||||
enabled: false,
|
||||
|
@ -87,30 +60,6 @@ export const noColors: Colors = {
|
|||
white: t => t,
|
||||
gray: t => t,
|
||||
grey: t => t,
|
||||
brightRed: t => t,
|
||||
brightGreen: t => t,
|
||||
brightYellow: t => t,
|
||||
brightBlue: t => t,
|
||||
brightMagenta: t => t,
|
||||
brightCyan: t => t,
|
||||
brightWhite: t => t,
|
||||
bgBlack: t => t,
|
||||
bgRed: t => t,
|
||||
bgGreen: t => t,
|
||||
bgYellow: t => t,
|
||||
bgBlue: t => t,
|
||||
bgMagenta: t => t,
|
||||
bgCyan: t => t,
|
||||
bgWhite: t => t,
|
||||
bgGray: t => t,
|
||||
bgGrey: t => t,
|
||||
bgBrightRed: t => t,
|
||||
bgBrightGreen: t => t,
|
||||
bgBrightYellow: t => t,
|
||||
bgBrightBlue: t => t,
|
||||
bgBrightMagenta: t => t,
|
||||
bgBrightCyan: t => t,
|
||||
bgBrightWhite: t => t
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { colors } from './colors';
|
||||
import { findRepeatedSubsequences } from './sequence';
|
||||
import { parseStackFrame } from './stackUtils';
|
||||
|
||||
import type { StackFrame } from '@protocol/channels';
|
||||
import type { Platform } from '../../common/platform';
|
||||
|
||||
export function parseStackTraceLine(line: string, pathSeparator: string): StackFrame | null {
|
||||
const frame = parseStackFrame(line, pathSeparator);
|
||||
|
@ -142,12 +142,12 @@ export function splitErrorMessage(message: string): { name: string, message: str
|
|||
};
|
||||
}
|
||||
|
||||
export function formatCallLog(log: string[] | undefined): string {
|
||||
export function formatCallLog(platform: Platform, log: string[] | undefined): string {
|
||||
if (!log || !log.some(l => !!l))
|
||||
return '';
|
||||
return `
|
||||
Call log:
|
||||
${colors.dim(log.join('\n'))}
|
||||
${platform.colors.dim(log.join('\n'))}
|
||||
`;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const colors: typeof import('../bundles/utils/node_modules/colors/safe') = require('./utilsBundleImpl').colors;
|
||||
export const debug: typeof import('../bundles/utils/node_modules/@types/debug') = require('./utilsBundleImpl').debug;
|
||||
export const diff: typeof import('../bundles/utils/node_modules/@types/diff') = require('./utilsBundleImpl').diff;
|
||||
export const dotenv: typeof import('../bundles/utils/node_modules/dotenv') = require('./utilsBundleImpl').dotenv;
|
||||
|
|
|
@ -26,11 +26,11 @@ import { getEastAsianWidth } from '../utilsBundle';
|
|||
|
||||
import type { ReporterV2 } from './reporterV2';
|
||||
import type { FullConfig, FullResult, Location, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter';
|
||||
import type { Colors } from '@isomorphic/colors';
|
||||
|
||||
export type TestResultOutput = { chunk: string | Buffer, type: 'stdout' | 'stderr' };
|
||||
export const kOutputSymbol = Symbol('output');
|
||||
|
||||
type Colors = typeof realColors;
|
||||
|
||||
type ErrorDetails = {
|
||||
message: string;
|
||||
location?: Location;
|
||||
|
|
|
@ -21,6 +21,7 @@ import util from 'util';
|
|||
|
||||
import { parseStackTraceLine, sanitizeForFilePath, calculateSha1, formatCallLog, isRegExp, isString, stringifyStackFrames } from 'playwright-core/lib/utils';
|
||||
import { debug, mime, minimatch } from 'playwright-core/lib/utilsBundle';
|
||||
import { nodePlatform } from 'playwright-core/lib/utils';
|
||||
|
||||
import type { Location } from './../types/testReporter';
|
||||
import type { TestInfoErrorImpl } from './common/ipc';
|
||||
|
@ -224,7 +225,7 @@ export function getContainedPath(parentPath: string, subPath: string = ''): stri
|
|||
|
||||
export const debugTest = debug('pw:test');
|
||||
|
||||
export const callLogText = formatCallLog;
|
||||
export const callLogText = (log: string[] | undefined) => formatCallLog(nodePlatform, log);
|
||||
|
||||
const folderToPackageJsonPath = new Map<string, string>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue