first commit
This commit is contained in:
22
node_modules/@inquirer/editor/LICENSE
generated
vendored
Normal file
22
node_modules/@inquirer/editor/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2025 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.
|
||||
111
node_modules/@inquirer/editor/README.md
generated
vendored
Normal file
111
node_modules/@inquirer/editor/README.md
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
# `@inquirer/editor`
|
||||
|
||||
Prompt that'll open the user preferred editor with default content and allow for a convenient multi-line input controlled through the command line.
|
||||
|
||||
The editor launched is the one [defined by the user's `EDITOR` environment variable](https://dev.to/jonasbn/til-integrate-visual-studio-code-with-shell--cli-2l1l).
|
||||
|
||||
# Special Thanks
|
||||
|
||||
<div align="center" markdown="1">
|
||||
|
||||
[](https://graphite.dev/?utm_source=npmjs&utm_medium=repo&utm_campaign=inquirerjs)<br>
|
||||
|
||||
### [Graphite is the AI developer productivity platform helping teams on GitHub ship higher quality software, faster](https://graphite.dev/?utm_source=npmjs&utm_medium=repo&utm_campaign=inquirerjs)
|
||||
|
||||
</div>
|
||||
|
||||
# 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 colSpan="2" align="center">Or</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
npm install @inquirer/editor
|
||||
```
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
yarn add @inquirer/editor
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
# Usage
|
||||
|
||||
```js
|
||||
import { editor } from '@inquirer/prompts';
|
||||
// Or
|
||||
// import editor from '@inquirer/editor';
|
||||
|
||||
const answer = await editor({
|
||||
message: 'Enter a description',
|
||||
});
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
| Property | Type | Required | Description |
|
||||
| --------------- | ------------------------------------------------------------------------------ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| message | `string` | yes | The question to ask |
|
||||
| default | `string` | no | Default value which will automatically be present in the editor |
|
||||
| validate | `string => boolean \| string \| Promise<boolean \| string>` | no | On submit, validate the content. 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. |
|
||||
| postfix | `string` | no (default to `.txt`) | The postfix of the file being edited. Adding this will add color highlighting to the file content in most editors. |
|
||||
| file | [`IFileOptions`](https://github.com/mrkmg/node-external-editor#config-options) | no | Exposes the [`external-editor` package options](https://github.com/mrkmg/node-external-editor#config-options) to configure the temporary file. |
|
||||
| waitForUseInput | `boolean` | no (default to `true`) | Open the editor automatically without waiting for the user to press enter. Note that this mean the user will not see the question! So make sure you have a default value that provide guidance if it's unclear what input is expected. |
|
||||
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
|
||||
|
||||
## 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 | { idle: string; done: string };
|
||||
spinner: {
|
||||
interval: number;
|
||||
frames: string[];
|
||||
};
|
||||
style: {
|
||||
message: (text: string, status: 'idle' | 'done' | 'loading') => string;
|
||||
error: (text: string) => string;
|
||||
help: (text: string) => string;
|
||||
key: (text: string) => string;
|
||||
};
|
||||
validationFailureMode: 'keep' | 'clear';
|
||||
};
|
||||
```
|
||||
|
||||
`validationFailureMode` defines the behavior of the prompt when the value submitted is invalid. By default, we'll keep the value allowing the user to edit it. When the theme option is set to `clear`, we'll remove and reset to the default value or empty string.
|
||||
|
||||
# License
|
||||
|
||||
Copyright (c) 2023 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
|
||||
Licensed under the MIT license.
|
||||
17
node_modules/@inquirer/editor/dist/commonjs/index.d.ts
generated
vendored
Normal file
17
node_modules/@inquirer/editor/dist/commonjs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { IFileOptions } from '@inquirer/external-editor';
|
||||
import { type Theme } from '@inquirer/core';
|
||||
import type { PartialDeep } from '@inquirer/type';
|
||||
type EditorTheme = {
|
||||
validationFailureMode: 'keep' | 'clear';
|
||||
};
|
||||
type EditorConfig = {
|
||||
message: string;
|
||||
default?: string;
|
||||
postfix?: string;
|
||||
waitForUseInput?: boolean;
|
||||
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
||||
file?: IFileOptions;
|
||||
theme?: PartialDeep<Theme<EditorTheme>>;
|
||||
};
|
||||
declare const _default: import("@inquirer/type").Prompt<string, EditorConfig>;
|
||||
export default _default;
|
||||
76
node_modules/@inquirer/editor/dist/commonjs/index.js
generated
vendored
Normal file
76
node_modules/@inquirer/editor/dist/commonjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const external_editor_1 = require("@inquirer/external-editor");
|
||||
const core_1 = require("@inquirer/core");
|
||||
const editorTheme = {
|
||||
validationFailureMode: 'keep',
|
||||
};
|
||||
exports.default = (0, core_1.createPrompt)((config, done) => {
|
||||
const { waitForUseInput = true, file: { postfix = config.postfix ?? '.txt', ...fileProps } = {}, validate = () => true, } = config;
|
||||
const theme = (0, core_1.makeTheme)(editorTheme, config.theme);
|
||||
const [status, setStatus] = (0, core_1.useState)('idle');
|
||||
const [value = '', setValue] = (0, core_1.useState)(config.default);
|
||||
const [errorMsg, setError] = (0, core_1.useState)();
|
||||
const prefix = (0, core_1.usePrefix)({ status, theme });
|
||||
function startEditor(rl) {
|
||||
rl.pause();
|
||||
const editCallback = async (error, answer) => {
|
||||
rl.resume();
|
||||
if (error) {
|
||||
setError(error.toString());
|
||||
}
|
||||
else {
|
||||
setStatus('loading');
|
||||
const finalAnswer = answer ?? '';
|
||||
const isValid = await validate(finalAnswer);
|
||||
if (isValid === true) {
|
||||
setError(undefined);
|
||||
setStatus('done');
|
||||
done(finalAnswer);
|
||||
}
|
||||
else {
|
||||
if (theme.validationFailureMode === 'clear') {
|
||||
setValue(config.default);
|
||||
}
|
||||
else {
|
||||
setValue(finalAnswer);
|
||||
}
|
||||
setError(isValid || 'You must provide a valid value');
|
||||
setStatus('idle');
|
||||
}
|
||||
}
|
||||
};
|
||||
(0, external_editor_1.editAsync)(value, (error, answer) => void editCallback(error, answer), {
|
||||
postfix,
|
||||
...fileProps,
|
||||
});
|
||||
}
|
||||
(0, core_1.useEffect)((rl) => {
|
||||
if (!waitForUseInput) {
|
||||
startEditor(rl);
|
||||
}
|
||||
}, []);
|
||||
(0, core_1.useKeypress)((key, rl) => {
|
||||
// Ignore keypress while our prompt is doing other processing.
|
||||
if (status !== 'idle') {
|
||||
return;
|
||||
}
|
||||
if ((0, core_1.isEnterKey)(key)) {
|
||||
startEditor(rl);
|
||||
}
|
||||
});
|
||||
const message = theme.style.message(config.message, status);
|
||||
let helpTip = '';
|
||||
if (status === 'loading') {
|
||||
helpTip = theme.style.help('Received');
|
||||
}
|
||||
else if (status === 'idle') {
|
||||
const enterKey = theme.style.key('enter');
|
||||
helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`);
|
||||
}
|
||||
let error = '';
|
||||
if (errorMsg) {
|
||||
error = theme.style.error(errorMsg);
|
||||
}
|
||||
return [[prefix, message, helpTip].filter(Boolean).join(' '), error];
|
||||
});
|
||||
3
node_modules/@inquirer/editor/dist/commonjs/package.json
generated
vendored
Normal file
3
node_modules/@inquirer/editor/dist/commonjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
17
node_modules/@inquirer/editor/dist/esm/index.d.ts
generated
vendored
Normal file
17
node_modules/@inquirer/editor/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { IFileOptions } from '@inquirer/external-editor';
|
||||
import { type Theme } from '@inquirer/core';
|
||||
import type { PartialDeep } from '@inquirer/type';
|
||||
type EditorTheme = {
|
||||
validationFailureMode: 'keep' | 'clear';
|
||||
};
|
||||
type EditorConfig = {
|
||||
message: string;
|
||||
default?: string;
|
||||
postfix?: string;
|
||||
waitForUseInput?: boolean;
|
||||
validate?: (value: string) => boolean | string | Promise<string | boolean>;
|
||||
file?: IFileOptions;
|
||||
theme?: PartialDeep<Theme<EditorTheme>>;
|
||||
};
|
||||
declare const _default: import("@inquirer/type").Prompt<string, EditorConfig>;
|
||||
export default _default;
|
||||
74
node_modules/@inquirer/editor/dist/esm/index.js
generated
vendored
Normal file
74
node_modules/@inquirer/editor/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
import { editAsync } from '@inquirer/external-editor';
|
||||
import { createPrompt, useEffect, useState, useKeypress, usePrefix, isEnterKey, makeTheme, } from '@inquirer/core';
|
||||
const editorTheme = {
|
||||
validationFailureMode: 'keep',
|
||||
};
|
||||
export default createPrompt((config, done) => {
|
||||
const { waitForUseInput = true, file: { postfix = config.postfix ?? '.txt', ...fileProps } = {}, validate = () => true, } = config;
|
||||
const theme = makeTheme(editorTheme, config.theme);
|
||||
const [status, setStatus] = useState('idle');
|
||||
const [value = '', setValue] = useState(config.default);
|
||||
const [errorMsg, setError] = useState();
|
||||
const prefix = usePrefix({ status, theme });
|
||||
function startEditor(rl) {
|
||||
rl.pause();
|
||||
const editCallback = async (error, answer) => {
|
||||
rl.resume();
|
||||
if (error) {
|
||||
setError(error.toString());
|
||||
}
|
||||
else {
|
||||
setStatus('loading');
|
||||
const finalAnswer = answer ?? '';
|
||||
const isValid = await validate(finalAnswer);
|
||||
if (isValid === true) {
|
||||
setError(undefined);
|
||||
setStatus('done');
|
||||
done(finalAnswer);
|
||||
}
|
||||
else {
|
||||
if (theme.validationFailureMode === 'clear') {
|
||||
setValue(config.default);
|
||||
}
|
||||
else {
|
||||
setValue(finalAnswer);
|
||||
}
|
||||
setError(isValid || 'You must provide a valid value');
|
||||
setStatus('idle');
|
||||
}
|
||||
}
|
||||
};
|
||||
editAsync(value, (error, answer) => void editCallback(error, answer), {
|
||||
postfix,
|
||||
...fileProps,
|
||||
});
|
||||
}
|
||||
useEffect((rl) => {
|
||||
if (!waitForUseInput) {
|
||||
startEditor(rl);
|
||||
}
|
||||
}, []);
|
||||
useKeypress((key, rl) => {
|
||||
// Ignore keypress while our prompt is doing other processing.
|
||||
if (status !== 'idle') {
|
||||
return;
|
||||
}
|
||||
if (isEnterKey(key)) {
|
||||
startEditor(rl);
|
||||
}
|
||||
});
|
||||
const message = theme.style.message(config.message, status);
|
||||
let helpTip = '';
|
||||
if (status === 'loading') {
|
||||
helpTip = theme.style.help('Received');
|
||||
}
|
||||
else if (status === 'idle') {
|
||||
const enterKey = theme.style.key('enter');
|
||||
helpTip = theme.style.help(`Press ${enterKey} to launch your preferred editor.`);
|
||||
}
|
||||
let error = '';
|
||||
if (errorMsg) {
|
||||
error = theme.style.error(errorMsg);
|
||||
}
|
||||
return [[prefix, message, helpTip].filter(Boolean).join(' '), error];
|
||||
});
|
||||
3
node_modules/@inquirer/editor/dist/esm/package.json
generated
vendored
Normal file
3
node_modules/@inquirer/editor/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
110
node_modules/@inquirer/editor/package.json
generated
vendored
Normal file
110
node_modules/@inquirer/editor/package.json
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"name": "@inquirer/editor",
|
||||
"version": "4.2.21",
|
||||
"description": "Inquirer multiline editor prompt",
|
||||
"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"
|
||||
],
|
||||
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/editor/README.md",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"attw": "attw --pack",
|
||||
"tsc": "tshy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@inquirer/core": "^10.3.0",
|
||||
"@inquirer/external-editor": "^1.0.2",
|
||||
"@inquirer/type": "^3.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.18.2",
|
||||
"@inquirer/testing": "^2.1.51",
|
||||
"tshy": "^3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"tshy": {
|
||||
"exclude": [
|
||||
"src/**/*.test.ts"
|
||||
],
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": ">=18"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"gitHead": "87cb01e67a25983bdaf0d74a7685915c0afb5f23"
|
||||
}
|
||||
Reference in New Issue
Block a user