Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

22
node_modules/@inquirer/search/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
Copyright (c) 2023 Simon Boudrias
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.

198
node_modules/@inquirer/search/README.md generated vendored Normal file
View file

@ -0,0 +1,198 @@
# `@inquirer/search`
Interactive search prompt component for command line interfaces.
![search prompt](https://raw.githubusercontent.com/SBoudrias/Inquirer.js/f459199e679aec7676cecc0fc12ef8a4cd3dda0b/assets/screenshots/search.png)
# Installation
<table>
<tr>
<th>npm</th>
<th>yarn</th>
</tr>
<tr>
<td>
```sh
npm install @inquirer/prompts
```
</td>
<td>
```sh
yarn add @inquirer/prompts
```
</td>
</tr>
<tr>
<td>
```sh
npm install @inquirer/search
```
</td>
<td>
```sh
yarn add @inquirer/search
```
</td>
</tr>
</table>
# Usage
```js
import { search, Separator } from '@inquirer/prompts';
// Or
// import search, { Separator } from '@inquirer/search';
const answer = await search({
message: 'Select an npm package',
source: async (input, { signal }) => {
if (!input) {
return [];
}
const response = await fetch(
`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(input)}&size=20`,
{ signal },
);
const data = await response.json();
return data.objects.map((pkg) => ({
name: pkg.package.name,
value: pkg.package.name,
description: pkg.package.description,
}));
},
});
```
## Options
| Property | Type | Required | Description |
| -------- | ---------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| message | `string` | yes | The question to ask |
| source | `(term: string \| void) => Promise<Choice[]>` | yes | This function returns the choices relevant to the search term. |
| pageSize | `number` | no | By default, lists of choice longer than 7 will be paginated. Use this option to control how many choices will appear on the screen at once. |
| validate | `Value => boolean \| string \| Promise<boolean \| string>` | no | On submit, validate the answer. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
### `source` function
The full signature type of `source` is as follow:
```ts
function(
term: string | void,
opt: { signal: AbortSignal },
): Promise<ReadonlyArray<Choice<Value> | Separator>>;
```
When `term` is `undefined`, it means the search term input is empty. You can use this to return default choices, or return an empty array.
Aside from returning the choices:
1. An `AbortSignal` is passed in to cancel ongoing network calls when the search term change.
2. `Separator`s can be used to organize the list.
### `Choice` object
The `Choice` object is typed as
```ts
type Choice<Value> = {
value: Value;
name?: string;
description?: string;
short?: string;
disabled?: boolean | string;
};
```
Here's each property:
- `value`: The value is what will be returned by `await search()`.
- `name`: This is the string displayed in the choice list.
- `description`: Option for a longer description string that'll appear under the list when the cursor highlight a given choice.
- `short`: Once the prompt is done (press enter), we'll use `short` if defined to render next to the question. By default we'll use `name`.
- `disabled`: Disallow the option from being selected. If `disabled` is a string, it'll be used as a help tip explaining why the choice isn't available.
Choices can also be an array of string, in which case the string will be used both as the `value` and the `name`.
### Validation & autocomplete interaction
The validation within the search prompt acts as a signal for the autocomplete feature.
When a list value is submitted and fail validation, the prompt will compare it to the search term. If they're the same, the prompt display the error. If they're not the same, we'll autocomplete the search term to match the value. Doing this will trigger a new search.
You can rely on this behavior to implement progressive autocomplete searches. Where you want the user to narrow the search in a progressive manner.
Pressing `tab` also triggers the term autocomplete.
You can see this behavior in action in [our search demo](https://github.com/SBoudrias/Inquirer.js/blob/main/packages/demo/demos/search.mjs).
## Theming
You can theme a prompt by passing a `theme` object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
```ts
type Theme = {
prefix: string;
spinner: {
interval: number;
frames: string[];
};
style: {
answer: (text: string) => string;
message: (text: string) => string;
error: (text: string) => string;
help: (text: string) => string;
highlight: (text: string) => string;
description: (text: string) => string;
disabled: (text: string) => string;
searchTerm: (text: string) => string;
};
icon: {
cursor: string;
};
helpMode: 'always' | 'never' | 'auto';
};
```
### `theme.helpMode`
- `auto` (default): Hide the help tips after an interaction occurs.
- `always`: The help tips will always show and never hide.
- `never`: The help tips will never show.
## Recipes
### Debounce search
```js
import { setTimeout } from 'node:timers/promises';
import { search } from '@inquirer/prompts';
const answer = await search({
message: 'Select an npm package',
source: async (input, { signal }) => {
await setTimeout(300);
if (signal.aborted) return [];
// Do the search
fetch(...)
},
});
```
# License
Copyright (c) 2024 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
Licensed under the MIT license.

202
node_modules/@inquirer/search/dist/cjs/index.js generated vendored Normal file
View file

@ -0,0 +1,202 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Separator = void 0;
const core_1 = require("@inquirer/core");
const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs"));
const figures_1 = __importDefault(require("@inquirer/figures"));
const searchTheme = {
icon: { cursor: figures_1.default.pointer },
style: {
disabled: (text) => yoctocolors_cjs_1.default.dim(`- ${text}`),
searchTerm: (text) => yoctocolors_cjs_1.default.cyan(text),
description: (text) => yoctocolors_cjs_1.default.cyan(text),
},
helpMode: 'auto',
};
function isSelectable(item) {
return !core_1.Separator.isSeparator(item) && !item.disabled;
}
function normalizeChoices(choices) {
return choices.map((choice) => {
var _a, _b, _c;
if (core_1.Separator.isSeparator(choice))
return choice;
if (typeof choice === 'string') {
return {
value: choice,
name: choice,
short: choice,
disabled: false,
};
}
const name = (_a = choice.name) !== null && _a !== void 0 ? _a : String(choice.value);
return {
value: choice.value,
name,
description: choice.description,
short: (_b = choice.short) !== null && _b !== void 0 ? _b : name,
disabled: (_c = choice.disabled) !== null && _c !== void 0 ? _c : false,
};
});
}
exports.default = (0, core_1.createPrompt)((config, done) => {
var _a;
const { pageSize = 7, validate = () => true } = config;
const theme = (0, core_1.makeTheme)(searchTheme, config.theme);
const firstRender = (0, core_1.useRef)(true);
const [status, setStatus] = (0, core_1.useState)('searching');
const [searchTerm, setSearchTerm] = (0, core_1.useState)('');
const [searchResults, setSearchResults] = (0, core_1.useState)([]);
const [searchError, setSearchError] = (0, core_1.useState)();
const isLoading = status === 'loading' || status === 'searching';
const prefix = (0, core_1.usePrefix)({ isLoading, theme });
const bounds = (0, core_1.useMemo)(() => {
const first = searchResults.findIndex(isSelectable);
const last = searchResults.findLastIndex(isSelectable);
return { first, last };
}, [searchResults]);
const [active = bounds.first, setActive] = (0, core_1.useState)();
(0, core_1.useEffect)(() => {
const controller = new AbortController();
setStatus('searching');
setSearchError(undefined);
const fetchResults = () => __awaiter(void 0, void 0, void 0, function* () {
try {
const results = yield config.source(searchTerm || undefined, {
signal: controller.signal,
});
if (!controller.signal.aborted) {
// Reset the pointer
setActive(undefined);
setSearchError(undefined);
setSearchResults(normalizeChoices(results));
setStatus('pending');
}
}
catch (error) {
if (!controller.signal.aborted && error instanceof Error) {
setSearchError(error.message);
}
}
});
void fetchResults();
return () => {
controller.abort();
};
}, [searchTerm]);
// Safe to assume the cursor position never points to a Separator.
const selectedChoice = searchResults[active];
(0, core_1.useKeypress)((key, rl) => __awaiter(void 0, void 0, void 0, function* () {
if ((0, core_1.isEnterKey)(key)) {
if (selectedChoice) {
setStatus('loading');
const isValid = yield validate(selectedChoice.value);
setStatus('pending');
if (isValid === true) {
setStatus('done');
done(selectedChoice.value);
}
else if (selectedChoice.name === searchTerm) {
setSearchError(isValid || 'You must provide a valid value');
}
else {
// Reset line with new search term
rl.write(selectedChoice.name);
setSearchTerm(selectedChoice.name);
}
}
else {
// Reset the readline line value to the previous value. On line event, the value
// get cleared, forcing the user to re-enter the value instead of fixing it.
rl.write(searchTerm);
}
}
else if (key.name === 'tab' && selectedChoice) {
rl.clearLine(0); // Remove the tab character.
rl.write(selectedChoice.name);
setSearchTerm(selectedChoice.name);
}
else if (status !== 'searching' && (key.name === 'up' || key.name === 'down')) {
rl.clearLine(0);
if ((key.name === 'up' && active !== bounds.first) ||
(key.name === 'down' && active !== bounds.last)) {
const offset = key.name === 'up' ? -1 : 1;
let next = active;
do {
next = (next + offset + searchResults.length) % searchResults.length;
} while (!isSelectable(searchResults[next]));
setActive(next);
}
}
else {
setSearchTerm(rl.line);
}
}));
const message = theme.style.message(config.message);
if (active > 0) {
firstRender.current = false;
}
let helpTip = '';
if (searchResults.length > 1 &&
(theme.helpMode === 'always' || (theme.helpMode === 'auto' && firstRender.current))) {
helpTip =
searchResults.length > pageSize
? `\n${theme.style.help('(Use arrow keys to reveal more choices)')}`
: `\n${theme.style.help('(Use arrow keys)')}`;
}
// TODO: What to do if no results are found? Should we display a message?
const page = (0, core_1.usePagination)({
items: searchResults,
active,
renderItem({ item, isActive }) {
if (core_1.Separator.isSeparator(item)) {
return ` ${item.separator}`;
}
if (item.disabled) {
const disabledLabel = typeof item.disabled === 'string' ? item.disabled : '(disabled)';
return theme.style.disabled(`${item.name} ${disabledLabel}`);
}
const color = isActive ? theme.style.highlight : (x) => x;
const cursor = isActive ? theme.icon.cursor : ` `;
return color(`${cursor} ${item.name}`);
},
pageSize,
loop: false,
});
let error;
if (searchError) {
error = theme.style.error(searchError);
}
else if (searchResults.length === 0 && searchTerm !== '' && status === 'pending') {
error = theme.style.error('No results found');
}
let searchStr;
if (status === 'done' && selectedChoice) {
const answer = (_a = selectedChoice.short) !== null && _a !== void 0 ? _a : selectedChoice.name;
return `${prefix} ${message} ${theme.style.answer(answer)}`;
}
else {
searchStr = theme.style.searchTerm(searchTerm);
}
const choiceDescription = (selectedChoice === null || selectedChoice === void 0 ? void 0 : selectedChoice.description)
? `\n${theme.style.description(selectedChoice.description)}`
: ``;
return [
[prefix, message, searchStr].filter(Boolean).join(' '),
`${error !== null && error !== void 0 ? error : page}${helpTip}${choiceDescription}`,
];
});
var core_2 = require("@inquirer/core");
Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return core_2.Separator; } });

View file

@ -0,0 +1,32 @@
import { Separator, type Theme } from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
type SearchTheme = {
icon: {
cursor: string;
};
style: {
disabled: (text: string) => string;
searchTerm: (text: string) => string;
description: (text: string) => string;
};
helpMode: 'always' | 'never' | 'auto';
};
type Choice<Value> = {
value: Value;
name?: string;
description?: string;
short?: string;
disabled?: boolean | string;
type?: never;
};
declare const _default: <Value>(config: {
message: string;
source: (term: string | undefined, opt: {
signal: AbortSignal;
}) => readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[] | Promise<readonly (string | Separator)[]> | Promise<readonly (Separator | Choice<Value>)[]>;
validate?: ((value: Value) => boolean | string | Promise<string | boolean>) | undefined;
pageSize?: number | undefined;
theme?: PartialDeep<Theme<SearchTheme>> | undefined;
}, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
export default _default;
export { Separator } from '@inquirer/core';

184
node_modules/@inquirer/search/dist/esm/index.mjs generated vendored Normal file
View file

@ -0,0 +1,184 @@
import { createPrompt, useState, useKeypress, usePrefix, usePagination, useRef, useEffect, useMemo, isEnterKey, Separator, makeTheme, } from '@inquirer/core';
import colors from 'yoctocolors-cjs';
import figures from '@inquirer/figures';
const searchTheme = {
icon: { cursor: figures.pointer },
style: {
disabled: (text) => colors.dim(`- ${text}`),
searchTerm: (text) => colors.cyan(text),
description: (text) => colors.cyan(text),
},
helpMode: 'auto',
};
function isSelectable(item) {
return !Separator.isSeparator(item) && !item.disabled;
}
function normalizeChoices(choices) {
return choices.map((choice) => {
if (Separator.isSeparator(choice))
return choice;
if (typeof choice === 'string') {
return {
value: choice,
name: choice,
short: choice,
disabled: false,
};
}
const name = choice.name ?? String(choice.value);
return {
value: choice.value,
name,
description: choice.description,
short: choice.short ?? name,
disabled: choice.disabled ?? false,
};
});
}
export default createPrompt((config, done) => {
const { pageSize = 7, validate = () => true } = config;
const theme = makeTheme(searchTheme, config.theme);
const firstRender = useRef(true);
const [status, setStatus] = useState('searching');
const [searchTerm, setSearchTerm] = useState('');
const [searchResults, setSearchResults] = useState([]);
const [searchError, setSearchError] = useState();
const isLoading = status === 'loading' || status === 'searching';
const prefix = usePrefix({ isLoading, theme });
const bounds = useMemo(() => {
const first = searchResults.findIndex(isSelectable);
const last = searchResults.findLastIndex(isSelectable);
return { first, last };
}, [searchResults]);
const [active = bounds.first, setActive] = useState();
useEffect(() => {
const controller = new AbortController();
setStatus('searching');
setSearchError(undefined);
const fetchResults = async () => {
try {
const results = await config.source(searchTerm || undefined, {
signal: controller.signal,
});
if (!controller.signal.aborted) {
// Reset the pointer
setActive(undefined);
setSearchError(undefined);
setSearchResults(normalizeChoices(results));
setStatus('pending');
}
}
catch (error) {
if (!controller.signal.aborted && error instanceof Error) {
setSearchError(error.message);
}
}
};
void fetchResults();
return () => {
controller.abort();
};
}, [searchTerm]);
// Safe to assume the cursor position never points to a Separator.
const selectedChoice = searchResults[active];
useKeypress(async (key, rl) => {
if (isEnterKey(key)) {
if (selectedChoice) {
setStatus('loading');
const isValid = await validate(selectedChoice.value);
setStatus('pending');
if (isValid === true) {
setStatus('done');
done(selectedChoice.value);
}
else if (selectedChoice.name === searchTerm) {
setSearchError(isValid || 'You must provide a valid value');
}
else {
// Reset line with new search term
rl.write(selectedChoice.name);
setSearchTerm(selectedChoice.name);
}
}
else {
// Reset the readline line value to the previous value. On line event, the value
// get cleared, forcing the user to re-enter the value instead of fixing it.
rl.write(searchTerm);
}
}
else if (key.name === 'tab' && selectedChoice) {
rl.clearLine(0); // Remove the tab character.
rl.write(selectedChoice.name);
setSearchTerm(selectedChoice.name);
}
else if (status !== 'searching' && (key.name === 'up' || key.name === 'down')) {
rl.clearLine(0);
if ((key.name === 'up' && active !== bounds.first) ||
(key.name === 'down' && active !== bounds.last)) {
const offset = key.name === 'up' ? -1 : 1;
let next = active;
do {
next = (next + offset + searchResults.length) % searchResults.length;
} while (!isSelectable(searchResults[next]));
setActive(next);
}
}
else {
setSearchTerm(rl.line);
}
});
const message = theme.style.message(config.message);
if (active > 0) {
firstRender.current = false;
}
let helpTip = '';
if (searchResults.length > 1 &&
(theme.helpMode === 'always' || (theme.helpMode === 'auto' && firstRender.current))) {
helpTip =
searchResults.length > pageSize
? `\n${theme.style.help('(Use arrow keys to reveal more choices)')}`
: `\n${theme.style.help('(Use arrow keys)')}`;
}
// TODO: What to do if no results are found? Should we display a message?
const page = usePagination({
items: searchResults,
active,
renderItem({ item, isActive }) {
if (Separator.isSeparator(item)) {
return ` ${item.separator}`;
}
if (item.disabled) {
const disabledLabel = typeof item.disabled === 'string' ? item.disabled : '(disabled)';
return theme.style.disabled(`${item.name} ${disabledLabel}`);
}
const color = isActive ? theme.style.highlight : (x) => x;
const cursor = isActive ? theme.icon.cursor : ` `;
return color(`${cursor} ${item.name}`);
},
pageSize,
loop: false,
});
let error;
if (searchError) {
error = theme.style.error(searchError);
}
else if (searchResults.length === 0 && searchTerm !== '' && status === 'pending') {
error = theme.style.error('No results found');
}
let searchStr;
if (status === 'done' && selectedChoice) {
const answer = selectedChoice.short ?? selectedChoice.name;
return `${prefix} ${message} ${theme.style.answer(answer)}`;
}
else {
searchStr = theme.style.searchTerm(searchTerm);
}
const choiceDescription = selectedChoice?.description
? `\n${theme.style.description(selectedChoice.description)}`
: ``;
return [
[prefix, message, searchStr].filter(Boolean).join(' '),
`${error ?? page}${helpTip}${choiceDescription}`,
];
});
export { Separator } from '@inquirer/core';

View file

@ -0,0 +1,32 @@
import { Separator, type Theme } from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
type SearchTheme = {
icon: {
cursor: string;
};
style: {
disabled: (text: string) => string;
searchTerm: (text: string) => string;
description: (text: string) => string;
};
helpMode: 'always' | 'never' | 'auto';
};
type Choice<Value> = {
value: Value;
name?: string;
description?: string;
short?: string;
disabled?: boolean | string;
type?: never;
};
declare const _default: <Value>(config: {
message: string;
source: (term: string | undefined, opt: {
signal: AbortSignal;
}) => readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[] | Promise<readonly (string | Separator)[]> | Promise<readonly (Separator | Choice<Value>)[]>;
validate?: ((value: Value) => boolean | string | Promise<string | boolean>) | undefined;
pageSize?: number | undefined;
theme?: PartialDeep<Theme<SearchTheme>> | undefined;
}, context?: import("@inquirer/type").Context) => import("@inquirer/type").CancelablePromise<Value>;
export default _default;
export { Separator } from '@inquirer/core';

91
node_modules/@inquirer/search/package.json generated vendored Normal file
View file

@ -0,0 +1,91 @@
{
"name": "@inquirer/search",
"version": "1.1.0",
"description": "Inquirer search prompt",
"main": "./dist/cjs/index.js",
"typings": "./dist/cjs/types/index.d.ts",
"files": [
"dist/**/*"
],
"repository": {
"type": "git",
"url": "https://github.com/SBoudrias/Inquirer.js.git"
},
"keywords": [
"answer",
"answers",
"ask",
"base",
"cli",
"command",
"command-line",
"confirm",
"enquirer",
"generate",
"generator",
"hyper",
"input",
"inquire",
"inquirer",
"interface",
"iterm",
"javascript",
"menu",
"node",
"nodejs",
"prompt",
"promptly",
"prompts",
"question",
"readline",
"scaffold",
"scaffolder",
"scaffolding",
"stdin",
"stdout",
"terminal",
"tty",
"ui",
"yeoman",
"yo",
"zsh"
],
"author": "Simon Boudrias <admin@simonboudrias.com>",
"license": "MIT",
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/search/README.md",
"dependencies": {
"@inquirer/core": "^9.1.0",
"@inquirer/figures": "^1.0.5",
"@inquirer/type": "^1.5.3",
"yoctocolors-cjs": "^2.1.2"
},
"devDependencies": {
"@inquirer/testing": "^2.1.32"
},
"scripts": {
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
"tsc:esm": "rm -rf dist/esm && tsc -p ./tsconfig.json",
"tsc:cjs": "rm -rf dist/cjs && tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs",
"attw": "attw --pack"
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=18"
},
"exports": {
".": {
"import": {
"types": "./dist/esm/types/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/types/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"sideEffects": false,
"gitHead": "0c039599ef88fe9eb804fe083ee386ec906a856f"
}