@shopify/cli-kit 3.6.2 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +61 -0
- package/dist/analytics.d.ts +11 -1
- package/dist/analytics.js +33 -23
- package/dist/analytics.js.map +1 -1
- package/dist/api/admin.js.map +1 -1
- package/dist/api/common.d.ts +1 -1
- package/dist/api/common.js +1 -1
- package/dist/api/common.js.map +1 -1
- package/dist/api/graphql/extension_specifications.js.map +1 -1
- package/dist/api/graphql/functions/app_function_set.d.ts +9 -23
- package/dist/api/graphql/functions/app_function_set.js +18 -27
- package/dist/api/graphql/functions/app_function_set.js.map +1 -1
- package/dist/api/graphql/functions/upload_url_generate.d.ts +12 -0
- package/dist/api/graphql/functions/upload_url_generate.js +11 -0
- package/dist/api/graphql/functions/upload_url_generate.js.map +1 -0
- package/dist/api/graphql/get_urls.d.ts +10 -0
- package/dist/api/graphql/get_urls.js +10 -0
- package/dist/api/graphql/get_urls.js.map +1 -0
- package/dist/api/graphql/index.d.ts +19 -14
- package/dist/api/graphql/index.js +19 -14
- package/dist/api/graphql/index.js.map +1 -1
- package/dist/api/graphql/update_draft.js.map +1 -1
- package/dist/api/graphql/update_urls.d.ts +2 -2
- package/dist/api/graphql/update_urls.js +2 -2
- package/dist/api/graphql/update_urls.js.map +1 -1
- package/dist/array.d.ts +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/content-tokens.d.ts +44 -0
- package/dist/content-tokens.js +103 -0
- package/dist/content-tokens.js.map +1 -0
- package/dist/environment/local.d.ts +19 -2
- package/dist/environment/local.js +45 -5
- package/dist/environment/local.js.map +1 -1
- package/dist/environment/utilities.d.ts +4 -0
- package/dist/environment/utilities.js +9 -0
- package/dist/environment/utilities.js.map +1 -1
- package/dist/error.d.ts +4 -4
- package/dist/error.js +16 -4
- package/dist/error.js.map +1 -1
- package/dist/file.d.ts +9 -1
- package/dist/file.js +15 -2
- package/dist/file.js.map +1 -1
- package/dist/git.js.map +1 -1
- package/dist/github.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +180 -12
- package/dist/metadata.js +39 -6
- package/dist/metadata.js.map +1 -1
- package/dist/monorail.d.ts +48 -1
- package/dist/monorail.js +2 -1
- package/dist/monorail.js.map +1 -1
- package/dist/node/archiver.js +1 -0
- package/dist/node/archiver.js.map +1 -1
- package/dist/node/base-command.d.ts +11 -1
- package/dist/node/base-command.js +19 -4
- package/dist/node/base-command.js.map +1 -1
- package/dist/node/checksum.js.map +1 -1
- package/dist/node/cli.js +2 -2
- package/dist/node/cli.js.map +1 -1
- package/dist/node/dot-env.d.ts +9 -0
- package/dist/node/dot-env.js +31 -0
- package/dist/node/dot-env.js.map +1 -1
- package/dist/node/error-handler.d.ts +14 -2
- package/dist/node/error-handler.js +58 -13
- package/dist/node/error-handler.js.map +1 -1
- package/dist/node/hooks/prerun.js +1 -1
- package/dist/node/hooks/prerun.js.map +1 -1
- package/dist/node/node-package-manager.d.ts +12 -18
- package/dist/node/node-package-manager.js +23 -14
- package/dist/node/node-package-manager.js.map +1 -1
- package/dist/node/ruby.js +2 -1
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +22 -43
- package/dist/output.js +31 -91
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +1 -0
- package/dist/plugins/tunnel.d.ts +40 -0
- package/dist/plugins/tunnel.js +11 -0
- package/dist/plugins/tunnel.js.map +1 -0
- package/dist/plugins.d.ts +11 -13
- package/dist/plugins.js +0 -1
- package/dist/plugins.js.map +1 -1
- package/dist/session/authorize.js +1 -1
- package/dist/session/authorize.js.map +1 -1
- package/dist/session/exchange.js +1 -2
- package/dist/session/exchange.js.map +1 -1
- package/dist/session/post-auth.js +7 -1
- package/dist/session/post-auth.js.map +1 -1
- package/dist/session/redirect-listener.js +6 -5
- package/dist/session/redirect-listener.js.map +1 -1
- package/dist/session/validate.js.map +1 -1
- package/dist/session.js +1 -1
- package/dist/session.js.map +1 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.js +3 -4
- package/dist/store.js.map +1 -1
- package/dist/string.d.ts +1 -0
- package/dist/string.js +3 -0
- package/dist/string.js.map +1 -1
- package/dist/system.d.ts +2 -2
- package/dist/testing/output.js +6 -6
- package/dist/testing/output.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing/deep-required.d.ts +12 -0
- package/dist/typing/deep-required.js +2 -0
- package/dist/typing/deep-required.js.map +1 -0
- package/dist/typing/pick-by-prefix.d.ts +12 -0
- package/dist/typing/pick-by-prefix.js +2 -0
- package/dist/typing/pick-by-prefix.js.map +1 -0
- package/dist/ui/executor.d.ts +14 -0
- package/dist/ui/executor.js +88 -0
- package/dist/ui/executor.js.map +1 -0
- package/dist/ui/inquirer/autocomplete.d.ts +11 -0
- package/dist/ui/inquirer/autocomplete.js +105 -0
- package/dist/ui/inquirer/autocomplete.js.map +1 -0
- package/dist/ui/inquirer/input.d.ts +16 -0
- package/dist/ui/inquirer/input.js +46 -0
- package/dist/ui/inquirer/input.js.map +1 -0
- package/dist/ui/inquirer/password.d.ts +7 -0
- package/dist/ui/inquirer/password.js +8 -0
- package/dist/ui/inquirer/password.js.map +1 -0
- package/dist/ui/inquirer/select.d.ts +14 -0
- package/dist/ui/inquirer/select.js +27 -0
- package/dist/ui/inquirer/select.js.map +1 -0
- package/dist/ui.d.ts +12 -23
- package/dist/ui.js +14 -61
- package/dist/ui.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/package.json +23 -13
- package/dist/api/graphql/functions/module_upload_url_generate.d.ts +0 -18
- package/dist/api/graphql/functions/module_upload_url_generate.js +0 -17
- package/dist/api/graphql/functions/module_upload_url_generate.js.map +0 -1
- package/dist/ui/autocomplete.d.ts +0 -7
- package/dist/ui/autocomplete.js +0 -43
- package/dist/ui/autocomplete.js.map +0 -1
- package/dist/ui/input.d.ts +0 -7
- package/dist/ui/input.js +0 -48
- package/dist/ui/input.js.map +0 -1
- package/dist/ui/select.d.ts +0 -6
- package/dist/ui/select.js +0 -30
- package/dist/ui/select.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a mapping type to be non-optional
|
|
3
|
+
*
|
|
4
|
+
* ```
|
|
5
|
+
* type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>
|
|
6
|
+
* T = {optionalKey: string, nullableValue: string, undefinableValue: string}
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare type DeepRequired<T> = {
|
|
11
|
+
[TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-required.js","sourceRoot":"","sources":["../../src/typing/deep-required.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Converts a mapping type to be non-optional\n *\n * ```\n * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>\n * T = {optionalKey: string, nullableValue: string, undefinableValue: string}\n * ```\n *\n */\nexport type DeepRequired<T> = {\n [TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches
|
|
3
|
+
*
|
|
4
|
+
* ```
|
|
5
|
+
* type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>
|
|
6
|
+
*
|
|
7
|
+
* T = {foo_1: number, foo_2: number, included: string, also: number}
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {
|
|
11
|
+
[TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey];
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick-by-prefix.js","sourceRoot":"","sources":["../../src/typing/pick-by-prefix.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches\n *\n * ```\n * type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>\n *\n * T = {foo_1: number, foo_2: number, included: string, also: number}\n * ```\n */\nexport type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {\n [TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey]\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Question, QuestionChoiceType } from '../ui.js';
|
|
2
|
+
export declare function run<TName extends string & keyof TAnswers, TAnswers extends {
|
|
3
|
+
[key in TName]: string;
|
|
4
|
+
} = {
|
|
5
|
+
[key in TName]: string;
|
|
6
|
+
}>(question: unknown): Promise<TAnswers>;
|
|
7
|
+
export declare function mapper(question: Question): unknown;
|
|
8
|
+
export declare function groupAndMapChoices(choices: QuestionChoiceType[]): ({
|
|
9
|
+
type: string;
|
|
10
|
+
line: string;
|
|
11
|
+
} | {
|
|
12
|
+
name: string;
|
|
13
|
+
value: string;
|
|
14
|
+
})[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CustomInput } from './inquirer/input.js';
|
|
2
|
+
import { CustomAutocomplete } from './inquirer/autocomplete.js';
|
|
3
|
+
import { CustomSelect } from './inquirer/select.js';
|
|
4
|
+
import { CustomPassword } from './inquirer/password.js';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import fuzzy from 'fuzzy';
|
|
7
|
+
export async function run(question) {
|
|
8
|
+
const questionName = question.name;
|
|
9
|
+
return (await inquirer.prompt(question, { ...question.choices }))[questionName];
|
|
10
|
+
}
|
|
11
|
+
export function mapper(question) {
|
|
12
|
+
switch (question.type) {
|
|
13
|
+
case 'input':
|
|
14
|
+
inquirer.registerPrompt('custom-input', CustomInput);
|
|
15
|
+
return {
|
|
16
|
+
...question,
|
|
17
|
+
type: 'custom-input',
|
|
18
|
+
};
|
|
19
|
+
case 'password':
|
|
20
|
+
inquirer.registerPrompt('custom-password', CustomPassword);
|
|
21
|
+
return {
|
|
22
|
+
...question,
|
|
23
|
+
type: 'custom-password',
|
|
24
|
+
};
|
|
25
|
+
case 'select':
|
|
26
|
+
inquirer.registerPrompt('custom-select', CustomSelect);
|
|
27
|
+
return {
|
|
28
|
+
...question,
|
|
29
|
+
type: 'custom-select',
|
|
30
|
+
source: getAutompleteFilterType(),
|
|
31
|
+
choices: question.choices ? groupAndMapChoices(question.choices) : undefined,
|
|
32
|
+
};
|
|
33
|
+
case 'autocomplete':
|
|
34
|
+
inquirer.registerPrompt('autocomplete', CustomAutocomplete);
|
|
35
|
+
return {
|
|
36
|
+
...question,
|
|
37
|
+
type: 'autocomplete',
|
|
38
|
+
source: getAutompleteFilterType(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function fuzzyFilter(answers, input = '') {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
resolve(fuzzy
|
|
45
|
+
.filter(input, Object.values(answers), {
|
|
46
|
+
extract(el) {
|
|
47
|
+
return el.name;
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
.map((el) => el.original));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function containsFilter(answers, input = '') {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
resolve(Object.values(answers).filter((answer) => !answer.name || answer.name.includes(input)));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function getAutompleteFilterType() {
|
|
59
|
+
return process.env.SHOPIFY_USE_AUTOCOMPLETE_FILTER === 'fuzzy' ? fuzzyFilter : containsFilter;
|
|
60
|
+
}
|
|
61
|
+
export function groupAndMapChoices(choices) {
|
|
62
|
+
const initialGroups = [];
|
|
63
|
+
// Switched from choices with group information to groups with a list of choices
|
|
64
|
+
const groups = choices.reduce((finalChoices, choice) => {
|
|
65
|
+
const currentGroup = choice.group ?? { name: 'Other', order: Number.MAX_SAFE_INTEGER };
|
|
66
|
+
const existingGroup = finalChoices.find((group) => group.name === currentGroup.name);
|
|
67
|
+
if (existingGroup) {
|
|
68
|
+
existingGroup.choices.push(choice);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
finalChoices.push({ ...currentGroup, choices: [choice] });
|
|
72
|
+
}
|
|
73
|
+
return finalChoices;
|
|
74
|
+
}, initialGroups);
|
|
75
|
+
const sortedGroups = groups.sort((g1, g2) => g1.order - g2.order);
|
|
76
|
+
const grouped = sortedGroups.length > 1 || sortedGroups[0].order !== Number.MAX_SAFE_INTEGER;
|
|
77
|
+
// Mapped the group with a list of extensions to a list of inquirer choices including group separators
|
|
78
|
+
return sortedGroups.flatMap((group) => {
|
|
79
|
+
const finalChoices = [];
|
|
80
|
+
if (grouped && group.name) {
|
|
81
|
+
finalChoices.push({ type: 'separator', line: '' });
|
|
82
|
+
finalChoices.push({ type: 'separator', line: group.name });
|
|
83
|
+
}
|
|
84
|
+
finalChoices.push(...group.choices);
|
|
85
|
+
return finalChoices;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/ui/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAC,cAAc,E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C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC,CAAA;QACpF,IAAI,aAAa,EAAE;YACjB,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SACnC;aAAM;YACL,YAAY,CAAC,IAAI,CAAC,EAAC,GAAG,YAAY,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAC,CAAC,CAAA;SACxD;QACD,OAAO,YAAY,CAAA;IACrB,CAAC,EAAE,aAAa,CAAC,CAAA;IAEjB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IACjE,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,CAAC,CAAE,CAAC,KAAK,KAAK,MAAM,CAAC,gBAAgB,CAAA;IAE7F,sGAAsG;IACtG,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACpC,MAAM,YAAY,GAAqE,EAAE,CAAA;QACzF,IAAI,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;YACzB,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC,CAAA;YAChD,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC,CAAC,CAAA;SACzD;QACD,YAAY,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;QACnC,OAAO,YAAY,CAAA;IACrB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CustomInput} from './inquirer/input.js'\nimport {CustomAutocomplete} from './inquirer/autocomplete.js'\nimport {CustomSelect} from './inquirer/select.js'\nimport {CustomPassword} from './inquirer/password.js'\nimport {Question, QuestionChoiceType} from '../ui.js'\nimport inquirer, {Answers, QuestionCollection} from 'inquirer'\nimport fuzzy from 'fuzzy'\n\nexport async function run<\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(question: unknown): Promise<TAnswers> {\n const questionName = (question as Question).name\n return (await inquirer.prompt(question as QuestionCollection<Answers>, {...(question as Question).choices}))[\n questionName\n ]\n}\n\nexport function mapper(question: Question): unknown {\n switch (question.type) {\n case 'input':\n inquirer.registerPrompt('custom-input', CustomInput)\n return {\n ...question,\n type: 'custom-input',\n }\n case 'password':\n inquirer.registerPrompt('custom-password', CustomPassword)\n return {\n ...question,\n type: 'custom-password',\n }\n case 'select':\n inquirer.registerPrompt('custom-select', CustomSelect)\n return {\n ...question,\n type: 'custom-select',\n source: getAutompleteFilterType(),\n choices: question.choices ? groupAndMapChoices(question.choices) : undefined,\n }\n case 'autocomplete':\n inquirer.registerPrompt('autocomplete', CustomAutocomplete)\n return {\n ...question,\n type: 'autocomplete',\n source: getAutompleteFilterType(),\n }\n }\n}\n\nfunction fuzzyFilter(answers: {name: string; value: string}[], input = '') {\n return new Promise((resolve) => {\n resolve(\n fuzzy\n .filter(input, Object.values(answers), {\n extract(el: {name: string; value: string}) {\n return el.name\n },\n })\n .map((el) => el.original),\n )\n })\n}\n\nfunction containsFilter(answers: {name: string; value: string}[], input = '') {\n return new Promise((resolve) => {\n resolve(Object.values(answers).filter((answer) => !answer.name || answer.name.includes(input)))\n })\n}\n\nfunction getAutompleteFilterType() {\n return process.env.SHOPIFY_USE_AUTOCOMPLETE_FILTER === 'fuzzy' ? fuzzyFilter : containsFilter\n}\n\nexport function groupAndMapChoices(choices: QuestionChoiceType[]) {\n const initialGroups: {name?: string; order: number; choices: {name: string; value: string; order?: number}[]}[] = []\n\n // Switched from choices with group information to groups with a list of choices\n const groups = choices.reduce((finalChoices, choice) => {\n const currentGroup = choice.group ?? {name: 'Other', order: Number.MAX_SAFE_INTEGER}\n const existingGroup = finalChoices.find((group) => group.name === currentGroup.name)\n if (existingGroup) {\n existingGroup.choices.push(choice)\n } else {\n finalChoices.push({...currentGroup, choices: [choice]})\n }\n return finalChoices\n }, initialGroups)\n\n const sortedGroups = groups.sort((g1, g2) => g1.order - g2.order)\n const grouped = sortedGroups.length > 1 || sortedGroups[0]!.order !== Number.MAX_SAFE_INTEGER\n\n // Mapped the group with a list of extensions to a list of inquirer choices including group separators\n return sortedGroups.flatMap((group) => {\n const finalChoices: ({type: string; line: string} | {name: string; value: string})[] = []\n if (grouped && group.name) {\n finalChoices.push({type: 'separator', line: ''})\n finalChoices.push({type: 'separator', line: group.name})\n }\n finalChoices.push(...group.choices)\n return finalChoices\n })\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import AutocompletePrompt from 'inquirer-autocomplete-prompt';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { Interface } from 'readline';
|
|
5
|
+
export declare class CustomAutocomplete extends AutocompletePrompt {
|
|
6
|
+
protected isAutocomplete: boolean;
|
|
7
|
+
constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers);
|
|
8
|
+
protected render(error?: string): void;
|
|
9
|
+
protected getQuestion(): string;
|
|
10
|
+
protected prefix(): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { colors } from '../../node/colors.js';
|
|
2
|
+
import AutocompletePrompt from 'inquirer-autocomplete-prompt';
|
|
3
|
+
// eslint-disable-next-line import/extensions
|
|
4
|
+
import Paginator from 'inquirer/lib/utils/paginator.js';
|
|
5
|
+
export class CustomAutocomplete extends AutocompletePrompt {
|
|
6
|
+
constructor(questions, rl, answers) {
|
|
7
|
+
super(questions, rl, answers);
|
|
8
|
+
this.isAutocomplete = true;
|
|
9
|
+
this.paginator = new Paginator(this.screen, {
|
|
10
|
+
isInfinite: false,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
render(error) {
|
|
14
|
+
let content = this.getQuestion();
|
|
15
|
+
let bottomContent = '';
|
|
16
|
+
if (this.status !== 'answered') {
|
|
17
|
+
content += colors.gray('… ');
|
|
18
|
+
if (!this.isAutocomplete) {
|
|
19
|
+
process.stdout.write('\u001b[?25l');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (this.status === 'answered') {
|
|
23
|
+
content += `${colors.dim('·')} ${colors.magenta(this.shortAnswer || this.answerName || this.answer)}`;
|
|
24
|
+
process.stdout.write('\u001b[?25h');
|
|
25
|
+
}
|
|
26
|
+
else if (this.searching) {
|
|
27
|
+
content += this.rl.line;
|
|
28
|
+
bottomContent += ` ${colors.magenta.dim('Searching...')}`;
|
|
29
|
+
}
|
|
30
|
+
else if (this.nbChoices) {
|
|
31
|
+
const choicesStr = listRender(this.currentChoices, this.selected, this.isAutocomplete ? this.rl.line : undefined);
|
|
32
|
+
content += this.isAutocomplete ? this.rl.line : '';
|
|
33
|
+
const indexPosition = this.selected;
|
|
34
|
+
let realIndexPosition = 0;
|
|
35
|
+
this.currentChoices.choices.every((choice, index) => {
|
|
36
|
+
if (index > indexPosition) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (choice.type === 'separator') {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const name = choice.name;
|
|
43
|
+
realIndexPosition += name ? name.split('\n').length : 0;
|
|
44
|
+
return true;
|
|
45
|
+
});
|
|
46
|
+
bottomContent += this.paginator.paginate(choicesStr, realIndexPosition, this.isAutocomplete ? 10 : 500);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
content += this.rl.line;
|
|
50
|
+
bottomContent += ` ${colors.magenta('No matching choices')}`;
|
|
51
|
+
}
|
|
52
|
+
if (error) {
|
|
53
|
+
bottomContent += `\n${colors.magenta('>> ')}${error}`;
|
|
54
|
+
}
|
|
55
|
+
this.firstRender = false;
|
|
56
|
+
this.screen.render(content, bottomContent);
|
|
57
|
+
}
|
|
58
|
+
getQuestion() {
|
|
59
|
+
return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`;
|
|
60
|
+
}
|
|
61
|
+
prefix() {
|
|
62
|
+
const color = colors.magenta.bold;
|
|
63
|
+
return this.status === 'answered' ? color('✔') : color('?');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function listRender(choices, pointer, searchToken) {
|
|
67
|
+
let output = '';
|
|
68
|
+
let separatorOffset = 0;
|
|
69
|
+
choices.forEach((choice, i) => {
|
|
70
|
+
if (choice.type === 'separator') {
|
|
71
|
+
separatorOffset++;
|
|
72
|
+
if (choice.line.includes('──────────────')) {
|
|
73
|
+
output += `\n`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
output += ` ${colors.dim.underline(choice)}\n`;
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (choice.disabled) {
|
|
81
|
+
separatorOffset++;
|
|
82
|
+
output += ` - ${choice.name}`;
|
|
83
|
+
output += ` (${typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'})`;
|
|
84
|
+
output += '\n';
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const isSelected = i - separatorOffset === pointer;
|
|
88
|
+
let line = (isSelected ? '> ' : ' ') + choice.name;
|
|
89
|
+
if (isSelected) {
|
|
90
|
+
line = colors.magenta(line);
|
|
91
|
+
}
|
|
92
|
+
if (searchToken) {
|
|
93
|
+
line = line
|
|
94
|
+
.split(searchToken)
|
|
95
|
+
.map((token) => (isSelected ? colors.magenta(token) : token))
|
|
96
|
+
.join(colors.magenta.dim(searchToken));
|
|
97
|
+
}
|
|
98
|
+
else if (isSelected) {
|
|
99
|
+
line = colors.magenta(line);
|
|
100
|
+
}
|
|
101
|
+
output += `${line} \n`;
|
|
102
|
+
});
|
|
103
|
+
return output.replace(/\n$/, '');
|
|
104
|
+
}
|
|
105
|
+
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import AutocompletePrompt from 'inquirer-autocomplete-prompt'\nimport DistinctChoice from 'inquirer/lib/objects/choices'\nimport inquirer from 'inquirer'\n// eslint-disable-next-line import/extensions\nimport Paginator from 'inquirer/lib/utils/paginator.js'\nimport {Interface} from 'readline'\n\nexport class CustomAutocomplete extends AutocompletePrompt {\n protected isAutocomplete: boolean\n\n constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers) {\n super(questions, rl, answers)\n this.isAutocomplete = true\n this.paginator = new Paginator(this.screen, {\n isInfinite: false,\n })\n }\n\n protected render(error?: string) {\n let content = this.getQuestion()\n let bottomContent = ''\n\n if (this.status !== 'answered') {\n content += colors.gray('… ')\n if (!this.isAutocomplete) {\n process.stdout.write('\\u001b[?25l')\n }\n }\n\n if (this.status === 'answered') {\n content += `${colors.dim('·')} ${colors.magenta(this.shortAnswer || this.answerName || this.answer)}`\n process.stdout.write('\\u001b[?25h')\n } else if (this.searching) {\n content += this.rl.line\n bottomContent += ` ${colors.magenta.dim('Searching...')}`\n } else if (this.nbChoices) {\n const choicesStr = listRender(this.currentChoices, this.selected, this.isAutocomplete ? this.rl.line : undefined)\n content += this.isAutocomplete ? this.rl.line : ''\n const indexPosition = this.selected\n let realIndexPosition = 0\n this.currentChoices.choices.every((choice, index: number) => {\n if (index > indexPosition) {\n return false\n }\n if (choice.type === 'separator') {\n return true\n }\n const name = choice.name\n realIndexPosition += name ? name.split('\\n').length : 0\n return true\n })\n bottomContent += this.paginator.paginate(choicesStr, realIndexPosition, this.isAutocomplete ? 10 : 500)\n } else {\n content += this.rl.line\n bottomContent += ` ${colors.magenta('No matching choices')}`\n }\n\n if (error) {\n bottomContent += `\\n${colors.magenta('>> ')}${error}`\n }\n\n this.firstRender = false\n\n this.screen.render(content, bottomContent)\n }\n\n protected getQuestion(): string {\n return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`\n }\n\n protected prefix(): string {\n const color = colors.magenta.bold\n return this.status === 'answered' ? color('✔') : color('?')\n }\n}\n\nfunction listRender(choices: DistinctChoice, pointer: number, searchToken?: string): string {\n let output = ''\n let separatorOffset = 0\n\n choices.forEach((choice, i: number) => {\n if (choice.type === 'separator') {\n separatorOffset++\n if (choice.line.includes('──────────────')) {\n output += `\\n`\n } else {\n output += ` ${colors.dim.underline(choice)}\\n`\n }\n return\n }\n\n if (choice.disabled) {\n separatorOffset++\n output += ` - ${choice.name}`\n output += ` (${typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'})`\n output += '\\n'\n return\n }\n\n const isSelected = i - separatorOffset === pointer\n let line = (isSelected ? '> ' : ' ') + choice.name\n\n if (isSelected) {\n line = colors.magenta(line)\n }\n\n if (searchToken) {\n line = line\n .split(searchToken)\n .map((token) => (isSelected ? colors.magenta(token) : token))\n .join(colors.magenta.dim(searchToken))\n } else if (isSelected) {\n line = colors.magenta(line)\n }\n\n output += `${line} \\n`\n })\n\n return output.replace(/\\n$/, '')\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Input from 'inquirer/lib/prompts/input.js';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { Interface } from 'readline';
|
|
5
|
+
export declare class CustomInput extends Input {
|
|
6
|
+
protected isPassword: boolean;
|
|
7
|
+
constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers);
|
|
8
|
+
protected render(error?: string): void;
|
|
9
|
+
protected getQuestion(): string;
|
|
10
|
+
protected prefix(): any;
|
|
11
|
+
protected onError(data: {
|
|
12
|
+
isValid: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}): void;
|
|
15
|
+
private formatContent;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { colors } from '../../node/colors.js';
|
|
2
|
+
// eslint-disable-next-line import/extensions
|
|
3
|
+
import Input from 'inquirer/lib/prompts/input.js';
|
|
4
|
+
import readline from 'readline';
|
|
5
|
+
export class CustomInput extends Input {
|
|
6
|
+
constructor(questions, rl, answers) {
|
|
7
|
+
super(questions, rl, answers);
|
|
8
|
+
this.isPassword = false;
|
|
9
|
+
}
|
|
10
|
+
render(error) {
|
|
11
|
+
const color = colors.magenta;
|
|
12
|
+
const isFinal = this.status === 'answered';
|
|
13
|
+
let prompt = this.getQuestion();
|
|
14
|
+
let bottomContent = '';
|
|
15
|
+
if (isFinal) {
|
|
16
|
+
prompt += `${colors.dim('·')} ${color(this.formatContent(this.answer))}`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
prompt += `\n${color('>')} ${this.rl.line ? this.formatContent(this.rl.line) : color.dim(this.opt.default)}`;
|
|
20
|
+
bottomContent = '─'.repeat(Math.max(this.rl.line.length, 30));
|
|
21
|
+
bottomContent = ` ${color(bottomContent)}`;
|
|
22
|
+
if (error) {
|
|
23
|
+
bottomContent += `\n\n ${colors.red(`! ${error}`)}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
this.screen.render(prompt, bottomContent);
|
|
27
|
+
if (!isFinal && !this.rl.line) {
|
|
28
|
+
readline.cursorTo(process.stdout, 2);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getQuestion() {
|
|
32
|
+
return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`;
|
|
33
|
+
}
|
|
34
|
+
prefix() {
|
|
35
|
+
const color = colors.magenta.bold;
|
|
36
|
+
return this.status === 'answered' ? color('✔') : color('?');
|
|
37
|
+
}
|
|
38
|
+
onError(data) {
|
|
39
|
+
this.rl.write(data.value === this.opt.default ? '' : data.value);
|
|
40
|
+
this.render(data.isValid);
|
|
41
|
+
}
|
|
42
|
+
formatContent(content) {
|
|
43
|
+
return this.isPassword ? colors.gray('*'.repeat(content.length)) : content;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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M,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IAC5E,CAAC;CACF","sourcesContent":["import {colors} from '../../node/colors.js'\n// eslint-disable-next-line import/extensions\nimport Input from 'inquirer/lib/prompts/input.js'\nimport inquirer from 'inquirer'\nimport readline, {Interface} from 'readline'\n\nexport class CustomInput extends Input {\n protected isPassword: boolean\n\n constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers) {\n super(questions, rl, answers)\n this.isPassword = false\n }\n\n protected render(error?: string): void {\n const color = colors.magenta\n const isFinal = this.status === 'answered'\n\n let prompt = this.getQuestion()\n\n let bottomContent = ''\n if (isFinal) {\n prompt += `${colors.dim('·')} ${color(this.formatContent(this.answer))}`\n } else {\n prompt += `\\n${color('>')} ${this.rl.line ? this.formatContent(this.rl.line) : color.dim(this.opt.default)}`\n bottomContent = '─'.repeat(Math.max(this.rl.line.length, 30))\n bottomContent = ` ${color(bottomContent)}`\n if (error) {\n bottomContent += `\\n\\n ${colors.red(`! ${error}`)}`\n }\n }\n this.screen.render(prompt, bottomContent)\n if (!isFinal && !this.rl.line) {\n readline.cursorTo(process.stdout, 2)\n }\n }\n\n protected getQuestion() {\n return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`\n }\n\n protected prefix() {\n const color = colors.magenta.bold\n return this.status === 'answered' ? color('✔') : color('?')\n }\n\n protected onError(data: {isValid: string; value: string}) {\n this.rl.write(data.value === this.opt.default ? '' : data.value)\n this.render(data.isValid)\n }\n\n private formatContent(content: string): string {\n return this.isPassword ? colors.gray('*'.repeat(content.length)) : content\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CustomInput } from './input.js';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { Interface } from 'readline';
|
|
5
|
+
export declare class CustomPassword extends CustomInput {
|
|
6
|
+
constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers);
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../../src/ui/inquirer/password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAItC,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,SAA8C,EAAE,EAAa,EAAE,OAAyB;QAClG,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;IACxB,CAAC;CACF","sourcesContent":["import {CustomInput} from './input.js'\nimport inquirer from 'inquirer'\nimport {Interface} from 'readline'\n\nexport class CustomPassword extends CustomInput {\n constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers) {\n super(questions, rl, answers)\n this.isPassword = true\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CustomAutocomplete } from './autocomplete.js';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { Interface } from 'readline';
|
|
5
|
+
export declare class CustomSelect extends CustomAutocomplete {
|
|
6
|
+
constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers);
|
|
7
|
+
onKeypress(event: {
|
|
8
|
+
key: {
|
|
9
|
+
name: string;
|
|
10
|
+
ctrl: boolean;
|
|
11
|
+
};
|
|
12
|
+
value: string;
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CustomAutocomplete } from './autocomplete.js';
|
|
2
|
+
// eslint-disable-next-line import/extensions
|
|
3
|
+
import utils from 'inquirer/lib/utils/readline.js';
|
|
4
|
+
export class CustomSelect extends CustomAutocomplete {
|
|
5
|
+
constructor(questions, rl, answers) {
|
|
6
|
+
super(questions, rl, answers);
|
|
7
|
+
this.isAutocomplete = false;
|
|
8
|
+
}
|
|
9
|
+
onKeypress(event) {
|
|
10
|
+
let len;
|
|
11
|
+
const keyName = (event.key && event.key.name) || undefined;
|
|
12
|
+
if (keyName === 'down' || (keyName === 'n' && event.key.ctrl)) {
|
|
13
|
+
len = this.nbChoices;
|
|
14
|
+
this.selected = this.selected < len - 1 ? this.selected + 1 : 0;
|
|
15
|
+
this.ensureSelectedInRange();
|
|
16
|
+
super.render();
|
|
17
|
+
utils.up(this.rl, 2);
|
|
18
|
+
}
|
|
19
|
+
else if (keyName === 'up' || (keyName === 'p' && event.key.ctrl)) {
|
|
20
|
+
len = this.nbChoices;
|
|
21
|
+
this.selected = this.selected > 0 ? this.selected - 1 : len - 1;
|
|
22
|
+
this.ensureSelectedInRange();
|
|
23
|
+
this.render();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/ui/inquirer/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AACpD,6CAA6C;AAC7C,OAAO,KAAK,MAAM,gCAAgC,CAAA;AAIlD,MAAM,OAAO,YAAa,SAAQ,kBAAkB;IAClD,YAAY,SAA8C,EAAE,EAAa,EAAE,OAAyB;QAClG,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAA;IAC7B,CAAC;IAED,UAAU,CAAC,KAA0D;QACnE,IAAI,GAAG,CAAA;QACP,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,SAAS,CAAA;QAE1D,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC7D,GAAG,GAAG,IAAI,CAAC,SAAS,CAAA;YACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/D,IAAI,CAAC,qBAAqB,EAAE,CAAA;YAC5B,KAAK,CAAC,MAAM,EAAE,CAAA;YACd,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;SACrB;aAAM,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAClE,GAAG,GAAG,IAAI,CAAC,SAAS,CAAA;YACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;YAC/D,IAAI,CAAC,qBAAqB,EAAE,CAAA;YAC5B,IAAI,CAAC,MAAM,EAAE,CAAA;SACd;IACH,CAAC;CACF","sourcesContent":["import {CustomAutocomplete} from './autocomplete.js'\n// eslint-disable-next-line import/extensions\nimport utils from 'inquirer/lib/utils/readline.js'\nimport inquirer from 'inquirer'\nimport {Interface} from 'readline'\n\nexport class CustomSelect extends CustomAutocomplete {\n constructor(questions: inquirer.Question<inquirer.Answers>, rl: Interface, answers: inquirer.Answers) {\n super(questions, rl, answers)\n this.isAutocomplete = false\n }\n\n onKeypress(event: {key: {name: string; ctrl: boolean}; value: string}) {\n let len\n const keyName = (event.key && event.key.name) || undefined\n\n if (keyName === 'down' || (keyName === 'n' && event.key.ctrl)) {\n len = this.nbChoices\n this.selected = this.selected < len - 1 ? this.selected + 1 : 0\n this.ensureSelectedInRange()\n super.render()\n utils.up(this.rl, 2)\n } else if (keyName === 'up' || (keyName === 'p' && event.key.ctrl)) {\n len = this.nbChoices\n this.selected = this.selected > 0 ? this.selected - 1 : len - 1\n this.ensureSelectedInRange()\n this.render()\n }\n }\n}\n"]}
|
package/dist/ui.d.ts
CHANGED
|
@@ -2,13 +2,23 @@ import { Listr as OriginalListr, ListrTask } from 'listr2';
|
|
|
2
2
|
export declare function newListr(tasks: ListrTask[], options?: object): OriginalListr<any, any, "verbose">;
|
|
3
3
|
export declare type ListrTasks = ConstructorParameters<typeof OriginalListr>[0];
|
|
4
4
|
export type { ListrTaskWrapper, ListrDefaultRenderer, ListrTask } from 'listr2';
|
|
5
|
-
interface
|
|
5
|
+
export interface Question<TName extends string = string> {
|
|
6
6
|
name: TName;
|
|
7
7
|
message: string;
|
|
8
8
|
preface?: string;
|
|
9
9
|
validate?: (value: string) => string | true;
|
|
10
10
|
default?: string;
|
|
11
11
|
result?: (value: string) => string | boolean;
|
|
12
|
+
type: 'input' | 'select' | 'autocomplete' | 'password';
|
|
13
|
+
choices?: QuestionChoiceType[];
|
|
14
|
+
}
|
|
15
|
+
export interface QuestionChoiceType {
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
group?: {
|
|
19
|
+
name: string;
|
|
20
|
+
order: number;
|
|
21
|
+
};
|
|
12
22
|
}
|
|
13
23
|
/**
|
|
14
24
|
* Performs a task with the title kept up to date and stdout available to the
|
|
@@ -21,28 +31,7 @@ export interface TaskOptions {
|
|
|
21
31
|
}>;
|
|
22
32
|
}
|
|
23
33
|
export declare const task: ({ title, task }: TaskOptions) => Promise<void>;
|
|
24
|
-
export declare
|
|
25
|
-
type: 'input';
|
|
26
|
-
};
|
|
27
|
-
export declare type SelectQuestion<TName extends string> = BaseQuestion<TName> & {
|
|
28
|
-
type: 'select';
|
|
29
|
-
choices: string[] | {
|
|
30
|
-
name: string;
|
|
31
|
-
value: string;
|
|
32
|
-
}[];
|
|
33
|
-
};
|
|
34
|
-
export declare type AutocompleteQuestion<TName extends string> = BaseQuestion<TName> & {
|
|
35
|
-
type: 'autocomplete';
|
|
36
|
-
choices: string[] | {
|
|
37
|
-
name: string;
|
|
38
|
-
value: string;
|
|
39
|
-
}[];
|
|
40
|
-
};
|
|
41
|
-
export declare type PasswordQuestion<TName extends string> = BaseQuestion<TName> & {
|
|
42
|
-
type: 'password';
|
|
43
|
-
};
|
|
44
|
-
export declare type Question<TName extends string = string> = InputQuestion<TName> | SelectQuestion<TName> | AutocompleteQuestion<TName> | PasswordQuestion<TName>;
|
|
45
|
-
export declare const prompt: <TName extends string & keyof TAnswers, TAnswers extends { [key in TName]: string; } = { [key_1 in TName]: string; }>(questions: readonly Question<TName>[], debugForceInquirer?: boolean) => Promise<TAnswers>;
|
|
34
|
+
export declare const prompt: <TName extends string & keyof TAnswers, TAnswers extends { [key in TName]: string; } = { [key_1 in TName]: string; }>(questions: readonly Question<TName>[]) => Promise<TAnswers>;
|
|
46
35
|
export declare function nonEmptyDirectoryPrompt(directory: string): Promise<void>;
|
|
47
36
|
export declare function terminateBlockingPortProcessPrompt(port: number, stepDescription?: string): Promise<boolean>;
|
|
48
37
|
export declare const keypress: () => Promise<void>;
|
package/dist/ui.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { AutoComplete } from './ui/autocomplete.js';
|
|
2
|
-
import { Input } from './ui/input.js';
|
|
3
|
-
import { Select } from './ui/select.js';
|
|
4
1
|
import { CancelExecution, Abort } from './error.js';
|
|
5
2
|
import { remove, exists } from './file.js';
|
|
6
3
|
import { info, completed, content, token, logUpdate, logToFile, stringifyMessage } from './output.js';
|
|
7
4
|
import { colors } from './node/colors.js';
|
|
8
5
|
import { relative } from './path.js';
|
|
9
6
|
import { isTerminalInteractive } from './environment/local.js';
|
|
10
|
-
import {
|
|
11
|
-
import inquirer from 'inquirer';
|
|
7
|
+
import { mapper as mapperUI, run as executorUI } from './ui/executor.js';
|
|
12
8
|
import { Listr as OriginalListr, ListrTaskState } from 'listr2';
|
|
13
9
|
import findProcess from 'find-process';
|
|
14
10
|
export function newListr(tasks, options) {
|
|
@@ -59,42 +55,25 @@ export const task = async ({ title, task }) => {
|
|
|
59
55
|
completed(success, logUpdate);
|
|
60
56
|
logUpdate.done();
|
|
61
57
|
};
|
|
62
|
-
export const prompt = async (questions
|
|
58
|
+
export const prompt = async (questions) => {
|
|
63
59
|
if (!isTerminalInteractive() && questions.length !== 0) {
|
|
64
60
|
throw new Abort(content `
|
|
65
61
|
The CLI prompted in a non-interactive terminal with the following questions:
|
|
66
62
|
${token.json(questions)}
|
|
67
63
|
`);
|
|
68
64
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const questionName = question.name;
|
|
76
|
-
// eslint-disable-next-line no-await-in-loop
|
|
77
|
-
const answer = (await inquirer.prompt([convertQuestionForInquirer(question)]))[questionName];
|
|
78
|
-
logPromptResults(question.message, answer);
|
|
79
|
-
results.push([questionName, answer]);
|
|
80
|
-
}
|
|
81
|
-
return Object.fromEntries(results);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
const value = {};
|
|
85
|
-
for (const question of questions) {
|
|
86
|
-
if (question.preface) {
|
|
87
|
-
info(question.preface);
|
|
88
|
-
}
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
const mappedQuestion = mapper(question);
|
|
91
|
-
// eslint-disable-next-line no-await-in-loop
|
|
92
|
-
const answer = await mappedQuestion.run();
|
|
93
|
-
value[question.name] = answer;
|
|
94
|
-
logPromptResults(question.message, answer);
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
const mappedQuestions = questions.map(mapperUI);
|
|
67
|
+
const value = {};
|
|
68
|
+
for (const question of mappedQuestions) {
|
|
69
|
+
if (question.preface) {
|
|
70
|
+
info(question.preface);
|
|
95
71
|
}
|
|
96
|
-
|
|
72
|
+
// eslint-disable-next-line no-await-in-loop
|
|
73
|
+
value[question.name] = await executorUI(question);
|
|
74
|
+
logPromptResults(question.message, value[question.name]);
|
|
97
75
|
}
|
|
76
|
+
return value;
|
|
98
77
|
};
|
|
99
78
|
function logPromptResults(questionName, answer) {
|
|
100
79
|
logToFile([questionName, answer].join(' '), 'INFO');
|
|
@@ -116,13 +95,13 @@ export async function nonEmptyDirectoryPrompt(directory) {
|
|
|
116
95
|
if (choice.value === 'abort') {
|
|
117
96
|
throw new CancelExecution();
|
|
118
97
|
}
|
|
119
|
-
remove(directory);
|
|
98
|
+
await remove(directory);
|
|
120
99
|
}
|
|
121
100
|
}
|
|
122
101
|
export async function terminateBlockingPortProcessPrompt(port, stepDescription) {
|
|
123
102
|
const stepDescriptionContent = stepDescription ?? 'current step';
|
|
124
103
|
const processInfo = await findProcess('port', port);
|
|
125
|
-
const formattedProcessName = processInfo && processInfo.length > 0 && processInfo[0]
|
|
104
|
+
const formattedProcessName = processInfo && processInfo.length > 0 && processInfo[0]?.name
|
|
126
105
|
? ` ${content `${token.italic(`(${processInfo[0].name})`)}`.value}`
|
|
127
106
|
: '';
|
|
128
107
|
const options = [
|
|
@@ -147,30 +126,4 @@ export const keypress = async () => {
|
|
|
147
126
|
resolve();
|
|
148
127
|
}));
|
|
149
128
|
};
|
|
150
|
-
function convertQuestionForInquirer(question) {
|
|
151
|
-
switch (question.type) {
|
|
152
|
-
case 'input':
|
|
153
|
-
case 'password':
|
|
154
|
-
return question;
|
|
155
|
-
case 'select':
|
|
156
|
-
case 'autocomplete':
|
|
157
|
-
return {
|
|
158
|
-
...question,
|
|
159
|
-
type: 'list',
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function mapper(question) {
|
|
164
|
-
switch (question.type) {
|
|
165
|
-
case 'input':
|
|
166
|
-
case 'password':
|
|
167
|
-
return new Input(question);
|
|
168
|
-
case 'select':
|
|
169
|
-
return new Select(question);
|
|
170
|
-
case 'autocomplete':
|
|
171
|
-
return new AutoComplete(question);
|
|
172
|
-
default:
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
129
|
//# sourceMappingURL=ui.js.map
|