@shopify/cli-kit 3.6.2 → 3.7.1

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.
Files changed (114) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/analytics.d.ts +2 -1
  3. package/dist/analytics.js +32 -16
  4. package/dist/analytics.js.map +1 -1
  5. package/dist/api/common.d.ts +1 -1
  6. package/dist/api/common.js +1 -1
  7. package/dist/api/common.js.map +1 -1
  8. package/dist/api/graphql/extension_specifications.js.map +1 -1
  9. package/dist/api/graphql/functions/app_function_set.d.ts +9 -23
  10. package/dist/api/graphql/functions/app_function_set.js +18 -27
  11. package/dist/api/graphql/functions/app_function_set.js.map +1 -1
  12. package/dist/api/graphql/functions/upload_url_generate.d.ts +12 -0
  13. package/dist/api/graphql/functions/upload_url_generate.js +11 -0
  14. package/dist/api/graphql/functions/upload_url_generate.js.map +1 -0
  15. package/dist/api/graphql/index.d.ts +1 -1
  16. package/dist/api/graphql/index.js +1 -1
  17. package/dist/api/graphql/index.js.map +1 -1
  18. package/dist/constants.d.ts +3 -1
  19. package/dist/constants.js +3 -1
  20. package/dist/constants.js.map +1 -1
  21. package/dist/environment/local.d.ts +19 -2
  22. package/dist/environment/local.js +45 -5
  23. package/dist/environment/local.js.map +1 -1
  24. package/dist/environment/utilities.d.ts +4 -0
  25. package/dist/environment/utilities.js +9 -0
  26. package/dist/environment/utilities.js.map +1 -1
  27. package/dist/error.d.ts +2 -2
  28. package/dist/error.js +7 -1
  29. package/dist/error.js.map +1 -1
  30. package/dist/file.d.ts +2 -1
  31. package/dist/file.js +6 -2
  32. package/dist/file.js.map +1 -1
  33. package/dist/github.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/metadata.d.ts +180 -12
  38. package/dist/metadata.js +39 -6
  39. package/dist/metadata.js.map +1 -1
  40. package/dist/monorail.d.ts +48 -1
  41. package/dist/monorail.js +2 -1
  42. package/dist/monorail.js.map +1 -1
  43. package/dist/node/archiver.js +1 -0
  44. package/dist/node/archiver.js.map +1 -1
  45. package/dist/node/base-command.d.ts +11 -1
  46. package/dist/node/base-command.js +19 -4
  47. package/dist/node/base-command.js.map +1 -1
  48. package/dist/node/cli.js +2 -2
  49. package/dist/node/cli.js.map +1 -1
  50. package/dist/node/error-handler.d.ts +9 -0
  51. package/dist/node/error-handler.js +13 -3
  52. package/dist/node/error-handler.js.map +1 -1
  53. package/dist/node/hooks/prerun.js +1 -1
  54. package/dist/node/hooks/prerun.js.map +1 -1
  55. package/dist/node/node-package-manager.d.ts +3 -7
  56. package/dist/node/node-package-manager.js +2 -1
  57. package/dist/node/node-package-manager.js.map +1 -1
  58. package/dist/path.d.ts +1 -0
  59. package/dist/plugins/tunnel.d.ts +40 -0
  60. package/dist/plugins/tunnel.js +11 -0
  61. package/dist/plugins/tunnel.js.map +1 -0
  62. package/dist/plugins.d.ts +11 -13
  63. package/dist/plugins.js +0 -1
  64. package/dist/plugins.js.map +1 -1
  65. package/dist/session/authorize.js +1 -1
  66. package/dist/session/authorize.js.map +1 -1
  67. package/dist/session/exchange.js +1 -2
  68. package/dist/session/exchange.js.map +1 -1
  69. package/dist/session/redirect-listener.js +6 -5
  70. package/dist/session/redirect-listener.js.map +1 -1
  71. package/dist/session.js +1 -1
  72. package/dist/session.js.map +1 -1
  73. package/dist/string.d.ts +1 -0
  74. package/dist/string.js +3 -0
  75. package/dist/string.js.map +1 -1
  76. package/dist/tsconfig.tsbuildinfo +1 -1
  77. package/dist/typing/deep-required.d.ts +12 -0
  78. package/dist/typing/deep-required.js +2 -0
  79. package/dist/typing/deep-required.js.map +1 -0
  80. package/dist/typing/pick-by-prefix.d.ts +12 -0
  81. package/dist/typing/pick-by-prefix.js +2 -0
  82. package/dist/typing/pick-by-prefix.js.map +1 -0
  83. package/dist/ui/executor.d.ts +7 -0
  84. package/dist/ui/executor.js +60 -0
  85. package/dist/ui/executor.js.map +1 -0
  86. package/dist/ui/inquirer/autocomplete.d.ts +11 -0
  87. package/dist/ui/inquirer/autocomplete.js +95 -0
  88. package/dist/ui/inquirer/autocomplete.js.map +1 -0
  89. package/dist/ui/inquirer/input.d.ts +16 -0
  90. package/dist/ui/inquirer/input.js +46 -0
  91. package/dist/ui/inquirer/input.js.map +1 -0
  92. package/dist/ui/inquirer/password.d.ts +7 -0
  93. package/dist/ui/inquirer/password.js +8 -0
  94. package/dist/ui/inquirer/password.js.map +1 -0
  95. package/dist/ui/inquirer/select.d.ts +14 -0
  96. package/dist/ui/inquirer/select.js +27 -0
  97. package/dist/ui/inquirer/select.js.map +1 -0
  98. package/dist/ui.d.ts +7 -23
  99. package/dist/ui.js +13 -60
  100. package/dist/ui.js.map +1 -1
  101. package/dist/version.d.ts +1 -0
  102. package/package.json +14 -5
  103. package/dist/api/graphql/functions/module_upload_url_generate.d.ts +0 -18
  104. package/dist/api/graphql/functions/module_upload_url_generate.js +0 -17
  105. package/dist/api/graphql/functions/module_upload_url_generate.js.map +0 -1
  106. package/dist/ui/autocomplete.d.ts +0 -7
  107. package/dist/ui/autocomplete.js +0 -43
  108. package/dist/ui/autocomplete.js.map +0 -1
  109. package/dist/ui/input.d.ts +0 -7
  110. package/dist/ui/input.js +0 -48
  111. package/dist/ui/input.js.map +0 -1
  112. package/dist/ui/select.d.ts +0 -6
  113. package/dist/ui/select.js +0 -30
  114. 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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=deep-required.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pick-by-prefix.js.map
@@ -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,7 @@
1
+ import { Question } 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;
@@ -0,0 +1,60 @@
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
+ };
32
+ case 'autocomplete':
33
+ inquirer.registerPrompt('autocomplete', CustomAutocomplete);
34
+ return {
35
+ ...question,
36
+ type: 'autocomplete',
37
+ source: getAutompleteFilterType(),
38
+ };
39
+ }
40
+ }
41
+ function fuzzyFilter(answers, input = '') {
42
+ return new Promise((resolve) => {
43
+ resolve(fuzzy
44
+ .filter(input, Object.values(answers), {
45
+ extract(el) {
46
+ return el.name;
47
+ },
48
+ })
49
+ .map((el) => el.original));
50
+ });
51
+ }
52
+ function containsFilter(answers, input = '') {
53
+ return new Promise((resolve) => {
54
+ resolve(Object.values(answers).filter((answer) => answer.name.includes(input)));
55
+ });
56
+ }
57
+ function getAutompleteFilterType() {
58
+ return process.env.SHOPIFY_USE_AUTOCOMPLETE_FILTER === 'fuzzy' ? fuzzyFilter : containsFilter;
59
+ }
60
+ //# sourceMapp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EAAE,kBAAkB,CAAC,CAAA;YAC3D,OAAO;gBACL,GAAG,QAAQ;gBACX,IAAI,EAAE,cAAc;gBACpB,MAAM,EAAE,uBAAuB,EAAE;aAClC,CAAA;KACJ;AACH,CAAC;AAED,SAAS,WAAW,CAAC,OAAwC,EAAE,KAAK,GAAG,EAAE;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,OAAO,CACL,KAAK;aACF,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACrC,OAAO,CAAC,EAAiC;gBACvC,OAAO,EAAE,CAAC,IAAI,CAAA;YAChB,CAAC;SACF,CAAC;aACD,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAC5B,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAwC,EAAE,KAAK,GAAG,EAAE;IAC1E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACjF,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,uBAAuB;IAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAA;AAC/F,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} 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 }\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.includes(input)))\n })\n}\n\nfunction getAutompleteFilterType() {\n return process.env.SHOPIFY_USE_AUTOCOMPLETE_FILTER === 'fuzzy' ? fuzzyFilter : containsFilter\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,95 @@
1
+ import { colors } from '../../node/colors.js';
2
+ import AutocompletePrompt from 'inquirer-autocomplete-prompt';
3
+ export class CustomAutocomplete extends AutocompletePrompt {
4
+ constructor(questions, rl, answers) {
5
+ super(questions, rl, answers);
6
+ this.isAutocomplete = true;
7
+ }
8
+ render(error) {
9
+ let content = this.getQuestion();
10
+ let bottomContent = '';
11
+ if (this.status !== 'answered') {
12
+ content += colors.gray('… ');
13
+ if (!this.isAutocomplete) {
14
+ process.stdout.write('\u001b[?25l');
15
+ }
16
+ }
17
+ if (this.status === 'answered') {
18
+ content += `${colors.dim('·')} ${colors.magenta(this.shortAnswer || this.answerName || this.answer)}`;
19
+ process.stdout.write('\u001b[?25h');
20
+ }
21
+ else if (this.searching) {
22
+ content += this.rl.line;
23
+ bottomContent += ` ${colors.magenta.dim('Searching...')}`;
24
+ }
25
+ else if (this.nbChoices) {
26
+ const choicesStr = listRender(this.currentChoices, this.selected, this.isAutocomplete ? this.rl.line : undefined);
27
+ content += this.isAutocomplete ? this.rl.line : '';
28
+ const indexPosition = this.selected;
29
+ let realIndexPosition = 0;
30
+ this.currentChoices.choices.every((choice, index) => {
31
+ if (index > indexPosition) {
32
+ return false;
33
+ }
34
+ if (choice.type === 'separator') {
35
+ return true;
36
+ }
37
+ const name = choice.name;
38
+ realIndexPosition += name ? name.split('\n').length : 0;
39
+ return true;
40
+ });
41
+ bottomContent += this.paginator.paginate(choicesStr, realIndexPosition, 10);
42
+ }
43
+ else {
44
+ content += this.rl.line;
45
+ bottomContent += ` ${colors.magenta('No matching choices')}`;
46
+ }
47
+ if (error) {
48
+ bottomContent += `\n${colors.magenta('>> ')}${error}`;
49
+ }
50
+ this.firstRender = false;
51
+ this.screen.render(content, bottomContent);
52
+ }
53
+ getQuestion() {
54
+ return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`;
55
+ }
56
+ prefix() {
57
+ const color = colors.magenta.bold;
58
+ return this.status === 'answered' ? color('✔') : color('?');
59
+ }
60
+ }
61
+ function listRender(choices, pointer, searchToken) {
62
+ let output = '';
63
+ let separatorOffset = 0;
64
+ choices.forEach((choice, i) => {
65
+ if (choice.type === 'separator') {
66
+ separatorOffset++;
67
+ output += ` ${choice}\n`;
68
+ return;
69
+ }
70
+ if (choice.disabled) {
71
+ separatorOffset++;
72
+ output += ` - ${choice.name}`;
73
+ output += ` (${typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'})`;
74
+ output += '\n';
75
+ return;
76
+ }
77
+ const isSelected = i - separatorOffset === pointer;
78
+ let line = (isSelected ? '> ' : ' ') + choice.name;
79
+ if (isSelected) {
80
+ line = colors.magenta(line);
81
+ }
82
+ if (searchToken) {
83
+ line = line
84
+ .split(searchToken)
85
+ .map((token) => (isSelected ? colors.magenta(token) : token))
86
+ .join(colors.magenta.dim(searchToken));
87
+ }
88
+ else if (isSelected) {
89
+ line = colors.magenta(line);
90
+ }
91
+ output += `${line} \n`;
92
+ });
93
+ return output.replace(/\n$/, '');
94
+ }
95
+ //# sourceMappingURL=autocomplete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../../src/ui/inquirer/autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAA;AAC3C,OAAO,kBAAkB,MAAM,8BAA8B,CAAA;AAK7D,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IAGxD,YAAY,SAA8C,EAAE,EAAa,EAAE,OAAyB;QAClG,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;IAC5B,CAAC;IAES,MAAM,CAAC,KAAc;QAC7B,IAAI,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;QAChC,IAAI,aAAa,GAAG,EAAE,CAAA;QAEtB,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE;YAC9B,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAA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AAC,CAAA;SAC5B;QAED,MAAM,IAAI,GAAG,IAAI,KAAK,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAClC,CAAC","sourcesContent":["import {colors} from '../../node/colors.js'\nimport AutocompletePrompt from 'inquirer-autocomplete-prompt'\nimport DistinctChoice from 'inquirer/lib/objects/choices'\nimport inquirer from 'inquirer'\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 }\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, 10)\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 output += ` ${choice}\\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
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/ui/inquirer/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAA;AAC3C,6CAA6C;AAC7C,OAAO,KAAK,MAAM,+BAA+B,CAAA;AAEjD,OAAO,QAAqB,MAAM,UAAU,CAAA;AAE5C,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGpC,YAAY,SAA8C,EAAE,EAAa,EAAE,OAAyB;QAClG,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;IACzB,CAAC;IAES,MAAM,CAAC,KAAc;QAC7B,MAAM,KAAK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MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAA;IAClG,CAAC;IAES,MAAM;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAA;QACjC,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7D,CAAC;IAES,OAAO,CAAC,IAAsC;QACtD,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAChE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3B,CAAC;IAEO,aAAa,CAAC,OAAe;QACnC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,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,8 @@
1
+ import { CustomInput } from './input.js';
2
+ export class CustomPassword extends CustomInput {
3
+ constructor(questions, rl, answers) {
4
+ super(questions, rl, answers);
5
+ this.isPassword = true;
6
+ }
7
+ }
8
+ //# sourceMappingURL=password.js.map
@@ -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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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,18 @@ 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 BaseQuestion<TName extends string> {
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?: {
14
+ name: string;
15
+ value: string;
16
+ }[];
12
17
  }
13
18
  /**
14
19
  * Performs a task with the title kept up to date and stdout available to the
@@ -21,28 +26,7 @@ export interface TaskOptions {
21
26
  }>;
22
27
  }
23
28
  export declare const task: ({ title, task }: TaskOptions) => Promise<void>;
24
- export declare type InputQuestion<TName extends string> = BaseQuestion<TName> & {
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>;
29
+ 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
30
  export declare function nonEmptyDirectoryPrompt(directory: string): Promise<void>;
47
31
  export declare function terminateBlockingPortProcessPrompt(port: number, stepDescription?: string): Promise<boolean>;
48
32
  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 { isTruthy } from './environment/utilities.js';
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, debugForceInquirer = false) => {
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
- if (debugForceInquirer || isTruthy(process.env.SHOPIFY_USE_INQUIRER)) {
70
- const results = [];
71
- for (const question of questions) {
72
- if (question.preface) {
73
- info(question.preface);
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
- return value;
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,7 +95,7 @@ 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) {
@@ -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
package/dist/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AACrC,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,YAAY,CAAA;AACjD,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,WAAW,CAAA;AACxC,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAmB,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACpH,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AACnD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B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,IAAI,EAAE,MAAM;aACb,CAAA;KACJ;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAkB;IAChC,QAAQ,QAAQ,CAAC,IAAI,EAAE;QACrB,KAAK,OAAO,CAAC;QACb,KAAK,UAAU;YACb,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC5B,KAAK,QAAQ;YACX,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC7B,KAAK,cAAc;YACjB,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAA;QACnC;YACE,OAAO,SAAS,CAAA;KACnB;AACH,CAAC","sourcesContent":["import {AutoComplete} from './ui/autocomplete.js'\nimport {Input} from './ui/input.js'\nimport {Select} from './ui/select.js'\nimport {CancelExecution, Abort} from './error.js'\nimport {remove, exists} from './file.js'\nimport {info, completed, content, token, logUpdate, logToFile, Message, Logger, stringifyMessage} from './output.js'\nimport {colors} from './node/colors.js'\nimport {relative} from './path.js'\nimport {isTerminalInteractive} from './environment/local.js'\nimport {isTruthy} from './environment/utilities.js'\nimport inquirer from 'inquirer'\nimport {Listr as OriginalListr, ListrTask, ListrEvent, ListrTaskState} from 'listr2'\nimport findProcess from 'find-process'\n\nexport function newListr(tasks: ListrTask[], options?: object) {\n const listr = new OriginalListr(tasks, options)\n listr.tasks.forEach((task) => {\n const loggedSubtaskTitles: string[] = []\n task.subscribe((event: ListrEvent) => {\n if (event.type === 'TITLE' && typeof event.data === 'string') {\n logToFile(event.data, 'INFO')\n }\n })\n task.renderHook$.subscribe(() => {\n if (task.hasSubtasks()) {\n const activeSubtasks = task.subtasks.filter((subtask) => {\n return [ListrTaskState.PENDING, ListrTaskState.COMPLETED].includes(subtask.state as ListrTaskState)\n })\n activeSubtasks.forEach((subtask) => {\n if (subtask.title && !loggedSubtaskTitles.includes(subtask.title)) {\n loggedSubtaskTitles.push(subtask.title)\n logToFile(subtask.title, 'INFO')\n }\n })\n }\n })\n })\n return listr\n}\n\nexport type ListrTasks = ConstructorParameters<typeof OriginalListr>[0]\nexport type {ListrTaskWrapper, ListrDefaultRenderer, ListrTask} from 'listr2'\n\ninterface BaseQuestion<TName extends string> {\n name: TName\n message: string\n preface?: string\n validate?: (value: string) => string | true\n default?: string\n result?: (value: string) => string | boolean\n}\n\nconst started = (content: Message, logger: Logger) => {\n const message = `${colors.yellow('❯')} ${stringifyMessage(content)}`\n info(message, logger)\n}\n\nconst failed = (content: Message, logger: Logger) => {\n const message = `${colors.red('✖')} ${stringifyMessage(content)}`\n info(message, logger)\n}\n\n/**\n * Performs a task with the title kept up to date and stdout available to the\n * task while it runs (there is no re-writing stdout while the task runs).\n */\nexport interface TaskOptions {\n title: string\n task: () => Promise<void | {successMessage: string}>\n}\nexport const task = async ({title, task}: TaskOptions) => {\n let success\n started(title, logUpdate)\n try {\n const result = await task()\n success = result?.successMessage || title\n } catch (err) {\n failed(title, logUpdate)\n logUpdate.done()\n throw err\n }\n completed(success, logUpdate)\n logUpdate.done()\n}\n\nexport type InputQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'input'\n}\n\nexport type SelectQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'select'\n choices: string[] | {name: string; value: string}[]\n}\n\nexport type AutocompleteQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'autocomplete'\n choices: string[] | {name: string; value: string}[]\n}\n\nexport type PasswordQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'password'\n}\n\nexport type Question<TName extends string = string> =\n | InputQuestion<TName>\n | SelectQuestion<TName>\n | AutocompleteQuestion<TName>\n | PasswordQuestion<TName>\n\nexport const prompt = async <\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(\n questions: ReadonlyArray<Question<TName>>,\n debugForceInquirer = false,\n): Promise<TAnswers> => {\n if (!isTerminalInteractive() && questions.length !== 0) {\n throw new Abort(content`\nThe CLI prompted in a non-interactive terminal with the following questions:\n${token.json(questions)}\n `)\n }\n\n if (debugForceInquirer || isTruthy(process.env.SHOPIFY_USE_INQUIRER)) {\n const results = []\n for (const question of questions) {\n if (question.preface) {\n info(question.preface)\n }\n\n const questionName = question.name\n // eslint-disable-next-line no-await-in-loop\n const answer = (await inquirer.prompt([convertQuestionForInquirer(question)]))[questionName]\n logPromptResults(question.message, answer)\n results.push([questionName, answer])\n }\n\n return Object.fromEntries(results) as TAnswers\n } else {\n const value = {} as TAnswers\n for (const question of questions) {\n if (question.preface) {\n info(question.preface)\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const mappedQuestion: any = mapper(question)\n // eslint-disable-next-line no-await-in-loop\n const answer = await mappedQuestion.run()\n value[question.name as keyof TAnswers] = answer\n logPromptResults(question.message, answer)\n }\n return value\n }\n}\n\nfunction logPromptResults(questionName: string, answer: string) {\n logToFile([questionName, answer].join(' '), 'INFO')\n}\n\nexport async function nonEmptyDirectoryPrompt(directory: string) {\n if (await exists(directory)) {\n const options = [\n {name: 'No, don’t delete the files', value: 'abort'},\n {name: 'Yes, delete the files', value: 'overwrite'},\n ]\n\n const relativeDirectory = relative(process.cwd(), directory)\n\n const questions: Question<'value'> = {\n type: 'select',\n name: 'value',\n message: `${relativeDirectory} is not an empty directory. Do you want to delete the existing files and continue?`,\n choices: options,\n }\n\n const choice = await prompt([questions])\n\n if (choice.value === 'abort') {\n throw new CancelExecution()\n }\n\n remove(directory)\n }\n}\n\nexport async function terminateBlockingPortProcessPrompt(port: number, stepDescription?: string): Promise<boolean> {\n const stepDescriptionContent = stepDescription ?? 'current step'\n\n const processInfo = await findProcess('port', port)\n const formattedProcessName =\n processInfo && processInfo.length > 0 && processInfo[0].name\n ? ` ${content`${token.italic(`(${processInfo[0].name})`)}`.value}`\n : ''\n\n const options = [\n {name: 'Yes, terminate process in order to log in now', value: 'finish'},\n {name: `No, cancel command and try later`, value: 'cancel'},\n ]\n\n const choice = await prompt([\n {\n type: 'select',\n name: 'value',\n message: `${stepDescriptionContent} requires a port ${port} that's unavailable because it's running another process${formattedProcessName}. Terminate that process? `,\n choices: options,\n },\n ])\n return choice.value === 'finish'\n}\n\nexport const keypress = async () => {\n process.stdin.setRawMode(true)\n process.stdin.resume()\n return new Promise<void>((resolve) =>\n process.stdin.once('data', () => {\n process.stdin.setRawMode(false)\n resolve()\n }),\n )\n}\n\nfunction convertQuestionForInquirer<\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(question: Question<TName>): inquirer.DistinctQuestion<TAnswers> {\n switch (question.type) {\n case 'input':\n case 'password':\n return question\n case 'select':\n case 'autocomplete':\n return {\n ...question,\n type: 'list',\n }\n }\n}\n\nfunction mapper(question: Question): unknown {\n switch (question.type) {\n case 'input':\n case 'password':\n return new Input(question)\n case 'select':\n return new Select(question)\n case 'autocomplete':\n return new AutoComplete(question)\n default:\n return undefined\n }\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,YAAY,CAAA;AACjD,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,WAAW,CAAA;AACxC,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAmB,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACpH,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAC,MAAM,IAAI,QAAQ,EAAE,GAAG,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAC,KAAK,IAAI,aAAa,EAAyB,cAAc,EAAC,MAAM,QAAQ,CAAA;AACpF,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,MAAM,UAAU,QAAQ,CAAC,KAAkB,EAAE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K,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QAC9B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAC/B,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {CancelExecution, Abort} from './error.js'\nimport {remove, exists} from './file.js'\nimport {info, completed, content, token, logUpdate, logToFile, Message, Logger, stringifyMessage} from './output.js'\nimport {colors} from './node/colors.js'\nimport {relative} from './path.js'\nimport {isTerminalInteractive} from './environment/local.js'\nimport {mapper as mapperUI, run as executorUI} from './ui/executor.js'\nimport {Listr as OriginalListr, ListrTask, ListrEvent, ListrTaskState} from 'listr2'\nimport findProcess from 'find-process'\n\nexport function newListr(tasks: ListrTask[], options?: object) {\n const listr = new OriginalListr(tasks, options)\n listr.tasks.forEach((task) => {\n const loggedSubtaskTitles: string[] = []\n task.subscribe((event: ListrEvent) => {\n if (event.type === 'TITLE' && typeof event.data === 'string') {\n logToFile(event.data, 'INFO')\n }\n })\n task.renderHook$.subscribe(() => {\n if (task.hasSubtasks()) {\n const activeSubtasks = task.subtasks.filter((subtask) => {\n return [ListrTaskState.PENDING, ListrTaskState.COMPLETED].includes(subtask.state as ListrTaskState)\n })\n activeSubtasks.forEach((subtask) => {\n if (subtask.title && !loggedSubtaskTitles.includes(subtask.title)) {\n loggedSubtaskTitles.push(subtask.title)\n logToFile(subtask.title, 'INFO')\n }\n })\n }\n })\n })\n return listr\n}\n\nexport type ListrTasks = ConstructorParameters<typeof OriginalListr>[0]\nexport type {ListrTaskWrapper, ListrDefaultRenderer, ListrTask} from 'listr2'\n\nexport interface Question<TName extends string = string> {\n name: TName\n message: string\n preface?: string\n validate?: (value: string) => string | true\n default?: string\n result?: (value: string) => string | boolean\n type: 'input' | 'select' | 'autocomplete' | 'password'\n choices?: {name: string; value: string}[]\n}\n\nconst started = (content: Message, logger: Logger) => {\n const message = `${colors.yellow('❯')} ${stringifyMessage(content)}`\n info(message, logger)\n}\n\nconst failed = (content: Message, logger: Logger) => {\n const message = `${colors.red('✖')} ${stringifyMessage(content)}`\n info(message, logger)\n}\n\n/**\n * Performs a task with the title kept up to date and stdout available to the\n * task while it runs (there is no re-writing stdout while the task runs).\n */\nexport interface TaskOptions {\n title: string\n task: () => Promise<void | {successMessage: string}>\n}\nexport const task = async ({title, task}: TaskOptions) => {\n let success\n started(title, logUpdate)\n try {\n const result = await task()\n success = result?.successMessage || title\n } catch (err) {\n failed(title, logUpdate)\n logUpdate.done()\n throw err\n }\n completed(success, logUpdate)\n logUpdate.done()\n}\nexport const prompt = async <\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(\n questions: ReadonlyArray<Question<TName>>,\n): Promise<TAnswers> => {\n if (!isTerminalInteractive() && questions.length !== 0) {\n throw new Abort(content`\nThe CLI prompted in a non-interactive terminal with the following questions:\n${token.json(questions)}\n `)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const mappedQuestions: any[] = questions.map(mapperUI)\n const value = {} as TAnswers\n for (const question of mappedQuestions) {\n if (question.preface) {\n info(question.preface)\n }\n\n // eslint-disable-next-line no-await-in-loop\n value[question.name as TName] = await executorUI(question)\n\n logPromptResults(question.message, value[question.name as TName])\n }\n return value\n}\n\nfunction logPromptResults(questionName: string, answer: string) {\n logToFile([questionName, answer].join(' '), 'INFO')\n}\n\nexport async function nonEmptyDirectoryPrompt(directory: string) {\n if (await exists(directory)) {\n const options = [\n {name: 'No, don’t delete the files', value: 'abort'},\n {name: 'Yes, delete the files', value: 'overwrite'},\n ]\n\n const relativeDirectory = relative(process.cwd(), directory)\n\n const questions: Question<'value'> = {\n type: 'select',\n name: 'value',\n message: `${relativeDirectory} is not an empty directory. Do you want to delete the existing files and continue?`,\n choices: options,\n }\n\n const choice = await prompt([questions])\n\n if (choice.value === 'abort') {\n throw new CancelExecution()\n }\n\n await remove(directory)\n }\n}\n\nexport async function terminateBlockingPortProcessPrompt(port: number, stepDescription?: string): Promise<boolean> {\n const stepDescriptionContent = stepDescription ?? 'current step'\n\n const processInfo = await findProcess('port', port)\n const formattedProcessName =\n processInfo && processInfo.length > 0 && processInfo[0].name\n ? ` ${content`${token.italic(`(${processInfo[0].name})`)}`.value}`\n : ''\n\n const options = [\n {name: 'Yes, terminate process in order to log in now', value: 'finish'},\n {name: `No, cancel command and try later`, value: 'cancel'},\n ]\n\n const choice = await prompt([\n {\n type: 'select',\n name: 'value',\n message: `${stepDescriptionContent} requires a port ${port} that's unavailable because it's running another process${formattedProcessName}. Terminate that process? `,\n choices: options,\n },\n ])\n return choice.value === 'finish'\n}\n\nexport const keypress = async () => {\n process.stdin.setRawMode(true)\n process.stdin.resume()\n return new Promise<void>((resolve) =>\n process.stdin.once('data', () => {\n process.stdin.setRawMode(false)\n resolve()\n }),\n )\n}\n"]}
package/dist/version.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { Bug } from './error.js';
2
3
  export declare const PackageJsonVersionNotFoundError: (packageJsonPath: string) => Bug;
3
4
  /**