Change endpoint from persons to people

This commit is contained in:
xfarrow
2025-03-23 21:00:08 +01:00
parent 4ae263662c
commit d005193f63
7158 changed files with 700476 additions and 735 deletions

View File

@ -0,0 +1,35 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
/**
* 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.
*/
class BaseWatchPlugin {
_stdin;
_stdout;
constructor({stdin, stdout}) {
this._stdin = stdin;
this._stdout = stdout;
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
apply(_hooks) {}
getUsageInfo(_globalConfig) {
return null;
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
onKey(_key) {}
run(_globalConfig, _updateConfigAndRun) {
return Promise.resolve();
}
}
var _default = BaseWatchPlugin;
exports.default = _default;

View File

@ -0,0 +1,63 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
/**
* 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.
*/
class JestHooks {
_listeners;
_subscriber;
_emitter;
constructor() {
this._listeners = {
onFileChange: [],
onTestRunComplete: [],
shouldRunTestSuite: []
};
this._subscriber = {
onFileChange: fn => {
this._listeners.onFileChange.push(fn);
},
onTestRunComplete: fn => {
this._listeners.onTestRunComplete.push(fn);
},
shouldRunTestSuite: fn => {
this._listeners.shouldRunTestSuite.push(fn);
}
};
this._emitter = {
onFileChange: fs =>
this._listeners.onFileChange.forEach(listener => listener(fs)),
onTestRunComplete: results =>
this._listeners.onTestRunComplete.forEach(listener =>
listener(results)
),
shouldRunTestSuite: async testSuiteInfo => {
const result = await Promise.all(
this._listeners.shouldRunTestSuite.map(listener =>
listener(testSuiteInfo)
)
);
return result.every(Boolean);
}
};
}
isUsed(hook) {
return this._listeners[hook]?.length > 0;
}
getSubscriber() {
return this._subscriber;
}
getEmitter() {
return this._emitter;
}
}
var _default = JestHooks;
exports.default = _default;

View File

@ -0,0 +1,74 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _ansiEscapes() {
const data = _interopRequireDefault(require('ansi-escapes'));
_ansiEscapes = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* 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.
*/
const {CLEAR} = _jestUtil().specialChars;
const usage = entity =>
`\n${_chalk().default.bold('Pattern Mode Usage')}\n` +
` ${_chalk().default.dim('\u203A Press')} Esc ${_chalk().default.dim(
'to exit pattern mode.'
)}\n` +
` ${_chalk().default.dim('\u203A Press')} Enter ` +
`${_chalk().default.dim(`to filter by a ${entity} regex pattern.`)}\n` +
'\n';
const usageRows = usage('').split('\n').length;
class PatternPrompt {
_currentUsageRows;
constructor(_pipe, _prompt, _entityName = '') {
this._pipe = _pipe;
this._prompt = _prompt;
this._entityName = _entityName;
this._currentUsageRows = usageRows;
}
run(onSuccess, onCancel, options) {
this._pipe.write(_ansiEscapes().default.cursorHide);
this._pipe.write(CLEAR);
if (options && options.header) {
this._pipe.write(`${options.header}\n`);
this._currentUsageRows = usageRows + options.header.split('\n').length;
} else {
this._currentUsageRows = usageRows;
}
this._pipe.write(usage(this._entityName));
this._pipe.write(_ansiEscapes().default.cursorShow);
this._prompt.enter(this._onChange.bind(this), onSuccess, onCancel);
}
_onChange(_pattern, _options) {
this._pipe.write(_ansiEscapes().default.eraseLine);
this._pipe.write(_ansiEscapes().default.cursorLeft);
}
}
exports.default = PatternPrompt;

View File

@ -0,0 +1,45 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _emittery() {
const data = _interopRequireDefault(require('emittery'));
_emittery = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* 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.
*/
class TestWatcher extends _emittery().default {
state;
_isWatchMode;
constructor({isWatchMode}) {
super();
this.state = {
interrupted: false
};
this._isWatchMode = isWatchMode;
}
async setState(state) {
Object.assign(this.state, state);
await this.emit('change', this.state);
}
isInterrupted() {
return this.state.interrupted;
}
isWatchMode() {
return this._isWatchMode;
}
}
exports.default = TestWatcher;

View File

@ -0,0 +1,27 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.KEYS = void 0;
/**
* 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.
*/
const isWindows = process.platform === 'win32';
const KEYS = {
ARROW_DOWN: '\u001b[B',
ARROW_LEFT: '\u001b[D',
ARROW_RIGHT: '\u001b[C',
ARROW_UP: '\u001b[A',
BACKSPACE: Buffer.from(isWindows ? '08' : '7f', 'hex').toString(),
CONTROL_C: '\u0003',
CONTROL_D: '\u0004',
CONTROL_U: '\u0015',
ENTER: '\r',
ESCAPE: '\u001b'
};
exports.KEYS = KEYS;

View File

@ -0,0 +1,222 @@
/**
* 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.
*/
/// <reference types="node" />
import type {AggregatedResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import Emittery = require('emittery');
export declare type AllowedConfigOptions = Partial<
Pick<
Config.GlobalConfig,
| 'bail'
| 'changedSince'
| 'collectCoverage'
| 'collectCoverageFrom'
| 'coverageDirectory'
| 'coverageReporters'
| 'findRelatedTests'
| 'nonFlagArgs'
| 'notify'
| 'notifyMode'
| 'onlyFailures'
| 'reporters'
| 'testNamePattern'
| 'testPathPattern'
| 'updateSnapshot'
| 'verbose'
> & {
mode: 'watch' | 'watchAll';
}
>;
declare type AvailableHooks =
| 'onFileChange'
| 'onTestRunComplete'
| 'shouldRunTestSuite';
export declare abstract class BaseWatchPlugin implements WatchPlugin {
protected _stdin: NodeJS.ReadStream;
protected _stdout: NodeJS.WriteStream;
constructor({
stdin,
stdout,
}: {
stdin: NodeJS.ReadStream;
stdout: NodeJS.WriteStream;
});
apply(_hooks: JestHookSubscriber): void;
getUsageInfo(_globalConfig: Config.GlobalConfig): UsageData | null;
onKey(_key: string): void;
run(
_globalConfig: Config.GlobalConfig,
_updateConfigAndRun: UpdateConfigCallback,
): Promise<void | boolean>;
}
declare type FileChange = (fs: JestHookExposedFS) => void;
export declare class JestHook {
private readonly _listeners;
private readonly _subscriber;
private readonly _emitter;
constructor();
isUsed(hook: AvailableHooks): boolean;
getSubscriber(): Readonly<JestHookSubscriber>;
getEmitter(): Readonly<JestHookEmitter>;
}
export declare type JestHookEmitter = {
onFileChange: (fs: JestHookExposedFS) => void;
onTestRunComplete: (results: AggregatedResult) => void;
shouldRunTestSuite: (
testSuiteInfo: TestSuiteInfo,
) => Promise<boolean> | boolean;
};
declare type JestHookExposedFS = {
projects: Array<{
config: Config.ProjectConfig;
testPaths: Array<string>;
}>;
};
export declare type JestHookSubscriber = {
onFileChange: (fn: FileChange) => void;
onTestRunComplete: (fn: TestRunComplete) => void;
shouldRunTestSuite: (fn: ShouldRunTestSuite) => void;
};
export declare const KEYS: {
ARROW_DOWN: string;
ARROW_LEFT: string;
ARROW_RIGHT: string;
ARROW_UP: string;
BACKSPACE: string;
CONTROL_C: string;
CONTROL_D: string;
CONTROL_U: string;
ENTER: string;
ESCAPE: string;
};
export declare abstract class PatternPrompt {
protected _pipe: NodeJS.WritableStream;
protected _prompt: Prompt;
protected _entityName: string;
protected _currentUsageRows: number;
constructor(
_pipe: NodeJS.WritableStream,
_prompt: Prompt,
_entityName?: string,
);
run(
onSuccess: (value: string) => void,
onCancel: () => void,
options?: {
header: string;
},
): void;
protected _onChange(_pattern: string, _options: ScrollOptions_2): void;
}
export declare function printPatternCaret(
pattern: string,
pipe: NodeJS.WritableStream,
): void;
export declare function printRestoredPatternCaret(
pattern: string,
currentUsageRows: number,
pipe: NodeJS.WritableStream,
): void;
export declare class Prompt {
private _entering;
private _value;
private _onChange;
private _onSuccess;
private _onCancel;
private _offset;
private _promptLength;
private _selection;
constructor();
private readonly _onResize;
enter(
onChange: (pattern: string, options: ScrollOptions_2) => void,
onSuccess: (pattern: string) => void,
onCancel: () => void,
): void;
setPromptLength(length: number): void;
setPromptSelection(selected: string): void;
put(key: string): void;
abort(): void;
isEntering(): boolean;
}
declare type ScrollOptions_2 = {
offset: number;
max: number;
};
export {ScrollOptions_2 as ScrollOptions};
declare type ShouldRunTestSuite = (
testSuiteInfo: TestSuiteInfo,
) => Promise<boolean>;
declare type State = {
interrupted: boolean;
};
declare type TestRunComplete = (results: AggregatedResult) => void;
declare type TestSuiteInfo = {
config: Config.ProjectConfig;
duration?: number;
testPath: string;
};
export declare class TestWatcher extends Emittery<{
change: State;
}> {
state: State;
private readonly _isWatchMode;
constructor({isWatchMode}: {isWatchMode: boolean});
setState(state: State): Promise<void>;
isInterrupted(): boolean;
isWatchMode(): boolean;
}
export declare type UpdateConfigCallback = (
config?: AllowedConfigOptions,
) => void;
export declare type UsageData = {
key: string;
prompt: string;
};
export declare interface WatchPlugin {
isInternal?: boolean;
apply?: (hooks: JestHookSubscriber) => void;
getUsageInfo?: (globalConfig: Config.GlobalConfig) => UsageData | null;
onKey?: (value: string) => void;
run?: (
globalConfig: Config.GlobalConfig,
updateConfigAndRun: UpdateConfigCallback,
) => Promise<void | boolean>;
}
export declare interface WatchPluginClass {
new (options: {
config: Record<string, unknown>;
stdin: NodeJS.ReadStream;
stdout: NodeJS.WriteStream;
}): WatchPlugin;
}
export {};

View File

@ -0,0 +1,74 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _exportNames = {
BaseWatchPlugin: true,
JestHook: true,
PatternPrompt: true,
TestWatcher: true,
Prompt: true
};
Object.defineProperty(exports, 'BaseWatchPlugin', {
enumerable: true,
get: function () {
return _BaseWatchPlugin.default;
}
});
Object.defineProperty(exports, 'JestHook', {
enumerable: true,
get: function () {
return _JestHooks.default;
}
});
Object.defineProperty(exports, 'PatternPrompt', {
enumerable: true,
get: function () {
return _PatternPrompt.default;
}
});
Object.defineProperty(exports, 'Prompt', {
enumerable: true,
get: function () {
return _Prompt.default;
}
});
Object.defineProperty(exports, 'TestWatcher', {
enumerable: true,
get: function () {
return _TestWatcher.default;
}
});
var _BaseWatchPlugin = _interopRequireDefault(require('./BaseWatchPlugin'));
var _JestHooks = _interopRequireDefault(require('./JestHooks'));
var _PatternPrompt = _interopRequireDefault(require('./PatternPrompt'));
var _TestWatcher = _interopRequireDefault(require('./TestWatcher'));
var _constants = require('./constants');
Object.keys(_constants).forEach(function (key) {
if (key === 'default' || key === '__esModule') return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _constants[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _constants[key];
}
});
});
var _Prompt = _interopRequireDefault(require('./lib/Prompt'));
var _patternModeHelpers = require('./lib/patternModeHelpers');
Object.keys(_patternModeHelpers).forEach(function (key) {
if (key === 'default' || key === '__esModule') return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _patternModeHelpers[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _patternModeHelpers[key];
}
});
});
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}

View File

@ -0,0 +1,113 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
var _constants = require('../constants');
/**
* 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.
*/
class Prompt {
_entering;
_value;
_onChange;
_onSuccess;
_onCancel;
_offset;
_promptLength;
_selection;
constructor() {
// Copied from `enter` to satisfy TS
this._entering = true;
this._value = '';
this._selection = null;
this._offset = -1;
this._promptLength = 0;
/* eslint-disable @typescript-eslint/no-empty-function */
this._onChange = () => {};
this._onSuccess = () => {};
this._onCancel = () => {};
/* eslint-enable */
}
_onResize = () => {
this._onChange();
};
enter(onChange, onSuccess, onCancel) {
this._entering = true;
this._value = '';
this._onSuccess = onSuccess;
this._onCancel = onCancel;
this._selection = null;
this._offset = -1;
this._promptLength = 0;
this._onChange = () =>
onChange(this._value, {
max: 10,
offset: this._offset
});
this._onChange();
process.stdout.on('resize', this._onResize);
}
setPromptLength(length) {
this._promptLength = length;
}
setPromptSelection(selected) {
this._selection = selected;
}
put(key) {
switch (key) {
case _constants.KEYS.ENTER:
this._entering = false;
this._onSuccess(this._selection ?? this._value);
this.abort();
break;
case _constants.KEYS.ESCAPE:
this._entering = false;
this._onCancel(this._value);
this.abort();
break;
case _constants.KEYS.ARROW_DOWN:
this._offset = Math.min(this._offset + 1, this._promptLength - 1);
this._onChange();
break;
case _constants.KEYS.ARROW_UP:
this._offset = Math.max(this._offset - 1, -1);
this._onChange();
break;
case _constants.KEYS.ARROW_LEFT:
case _constants.KEYS.ARROW_RIGHT:
break;
case _constants.KEYS.CONTROL_U:
this._value = '';
this._offset = -1;
this._selection = null;
this._onChange();
break;
default:
this._value =
key === _constants.KEYS.BACKSPACE
? this._value.slice(0, -1)
: this._value + key;
this._offset = -1;
this._selection = null;
this._onChange();
break;
}
}
abort() {
this._entering = false;
this._value = '';
process.stdout.removeListener('resize', this._onResize);
}
isEntering() {
return this._entering;
}
}
exports.default = Prompt;

View File

@ -0,0 +1,30 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = colorize;
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* 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.
*/
function colorize(str, start, end) {
return (
_chalk().default.dim(str.slice(0, start)) +
_chalk().default.reset(str.slice(start, end)) +
_chalk().default.dim(str.slice(end))
);
}

View File

@ -0,0 +1,67 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = formatTestNameByPattern;
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
var _colorize = _interopRequireDefault(require('./colorize'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* 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.
*/
const DOTS = '...';
const ENTER = '⏎';
function formatTestNameByPattern(testName, pattern, width) {
const inlineTestName = testName.replace(/(\r\n|\n|\r)/gm, ENTER);
let regexp;
try {
regexp = new RegExp(pattern, 'i');
} catch {
return _chalk().default.dim(inlineTestName);
}
const match = inlineTestName.match(regexp);
if (!match) {
return _chalk().default.dim(inlineTestName);
}
const startPatternIndex = Math.max(match.index ?? 0, 0);
const endPatternIndex = startPatternIndex + match[0].length;
if (inlineTestName.length <= width) {
return (0, _colorize.default)(
inlineTestName,
startPatternIndex,
endPatternIndex
);
}
const slicedTestName = inlineTestName.slice(0, width - DOTS.length);
if (startPatternIndex < slicedTestName.length) {
if (endPatternIndex > slicedTestName.length) {
return (0, _colorize.default)(
slicedTestName + DOTS,
startPatternIndex,
slicedTestName.length + DOTS.length
);
} else {
return (0, _colorize.default)(
slicedTestName + DOTS,
Math.min(startPatternIndex, slicedTestName.length),
endPatternIndex
);
}
}
return `${_chalk().default.dim(slicedTestName)}${_chalk().default.reset(
DOTS
)}`;
}

View File

@ -0,0 +1,54 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.printPatternCaret = printPatternCaret;
exports.printRestoredPatternCaret = printRestoredPatternCaret;
function _ansiEscapes() {
const data = _interopRequireDefault(require('ansi-escapes'));
_ansiEscapes = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
function _stringLength() {
const data = _interopRequireDefault(require('string-length'));
_stringLength = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* 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.
*/
function printPatternCaret(pattern, pipe) {
const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
pipe.write(_ansiEscapes().default.eraseDown);
pipe.write(inputText);
pipe.write(_ansiEscapes().default.cursorSavePosition);
}
function printRestoredPatternCaret(pattern, currentUsageRows, pipe) {
const inputText = `${_chalk().default.dim(' pattern \u203A')} ${pattern}`;
pipe.write(
_ansiEscapes().default.cursorTo(
(0, _stringLength().default)(inputText),
currentUsageRows - 1
)
);
pipe.write(_ansiEscapes().default.cursorRestorePosition);
}

View File

@ -0,0 +1,31 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = scroll;
/**
* 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.
*/
function scroll(size, {offset, max}) {
let start = 0;
let index = Math.min(offset, size);
const halfScreen = max / 2;
if (index <= halfScreen) {
start = 0;
} else {
if (size >= max) {
start = Math.min(index - halfScreen - 1, size - max);
}
index = Math.min(index - start, size);
}
return {
end: Math.min(size, start + max),
index,
start
};
}

View File

@ -0,0 +1 @@
'use strict';