@shopify/cli-kit 3.34.0 → 3.36.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.
Files changed (241) hide show
  1. package/dist/content-tokens.js +1 -1
  2. package/dist/content-tokens.js.map +1 -1
  3. package/dist/error.js +2 -2
  4. package/dist/error.js.map +1 -1
  5. package/dist/git.js +2 -2
  6. package/dist/git.js.map +1 -1
  7. package/dist/index.d.ts +0 -6
  8. package/dist/index.js +0 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/metadata.d.ts +1 -1
  11. package/dist/metadata.js.map +1 -1
  12. package/dist/monorail.d.ts +1 -1
  13. package/dist/monorail.js +1 -1
  14. package/dist/monorail.js.map +1 -1
  15. package/dist/output.js +3 -7
  16. package/dist/output.js.map +1 -1
  17. package/dist/plugins.d.ts +1 -1
  18. package/dist/plugins.js.map +1 -1
  19. package/dist/{typing → private/common/ts}/deep-required.d.ts +3 -3
  20. package/dist/{typing → private/common/ts}/deep-required.js +0 -0
  21. package/dist/private/common/ts/deep-required.js.map +1 -0
  22. package/dist/{typing → private/common/ts}/overloaded-parameters.d.ts +0 -0
  23. package/dist/{typing → private/common/ts}/overloaded-parameters.js +0 -0
  24. package/dist/private/common/ts/overloaded-parameters.js.map +1 -0
  25. package/dist/private/node/api/graphql.js +2 -3
  26. package/dist/private/node/api/graphql.js.map +1 -1
  27. package/dist/private/node/api/headers.d.ts +11 -2
  28. package/dist/private/node/api/headers.js +29 -3
  29. package/dist/private/node/api/headers.js.map +1 -1
  30. package/dist/private/node/api/rest.d.ts +5 -3
  31. package/dist/private/node/api/rest.js +8 -7
  32. package/dist/private/node/api/rest.js.map +1 -1
  33. package/dist/private/node/constants.d.ts +42 -0
  34. package/dist/private/node/constants.js +58 -0
  35. package/dist/private/node/constants.js.map +1 -0
  36. package/dist/private/node/environment/service.js +2 -2
  37. package/dist/private/node/environment/service.js.map +1 -1
  38. package/dist/private/node/session/device-authorization.js +1 -1
  39. package/dist/private/node/session/device-authorization.js.map +1 -1
  40. package/dist/private/node/session/exchange.js +1 -1
  41. package/dist/private/node/session/exchange.js.map +1 -1
  42. package/dist/private/node/session/identity-token-validation.js +1 -1
  43. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  44. package/dist/private/node/session/post-auth.js +10 -10
  45. package/dist/private/node/session/post-auth.js.map +1 -1
  46. package/dist/private/node/session/store.js +6 -6
  47. package/dist/private/node/session/store.js.map +1 -1
  48. package/dist/private/node/session/validate.js +2 -2
  49. package/dist/private/node/session/validate.js.map +1 -1
  50. package/dist/private/node/session.js +2 -2
  51. package/dist/private/node/session.js.map +1 -1
  52. package/dist/{typing → private/node}/simple-definitions.d.ts +0 -0
  53. package/dist/{typing → private/node}/simple-definitions.js +0 -0
  54. package/dist/private/node/simple-definitions.js.map +1 -0
  55. package/dist/private/node/ui/alert.d.ts +1 -1
  56. package/dist/private/node/ui/alert.js +2 -2
  57. package/dist/private/node/ui/alert.js.map +1 -1
  58. package/dist/private/node/ui/components/Alert.d.ts +5 -0
  59. package/dist/private/node/ui/components/Alert.js +9 -6
  60. package/dist/private/node/ui/components/Alert.js.map +1 -1
  61. package/dist/private/node/ui/components/Alert.test.js +30 -4
  62. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  63. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +12 -0
  64. package/dist/private/node/ui/components/AutocompletePrompt.js +111 -0
  65. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -0
  66. package/dist/private/node/ui/components/AutocompletePrompt.test.d.ts +1 -0
  67. package/dist/private/node/ui/components/AutocompletePrompt.test.js +473 -0
  68. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -0
  69. package/dist/private/node/ui/components/Banner.d.ts +0 -1
  70. package/dist/private/node/ui/components/Banner.js +4 -4
  71. package/dist/private/node/ui/components/Banner.js.map +1 -1
  72. package/dist/private/node/ui/components/Banner.test.js +10 -5
  73. package/dist/private/node/ui/components/Banner.test.js.map +1 -1
  74. package/dist/private/node/ui/components/FatalError.js +1 -1
  75. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  76. package/dist/private/node/ui/components/FatalError.test.js +4 -8
  77. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  78. package/dist/private/node/ui/components/{Table.d.ts → Prompts/InfoTable.d.ts} +2 -2
  79. package/dist/private/node/ui/components/{Table.js → Prompts/InfoTable.js} +6 -6
  80. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -0
  81. package/dist/private/node/ui/components/SelectInput.d.ts +9 -2
  82. package/dist/private/node/ui/components/SelectInput.js +96 -52
  83. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  84. package/dist/private/node/ui/components/SelectInput.test.js +140 -54
  85. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  86. package/dist/private/node/ui/components/SelectPrompt.d.ts +6 -4
  87. package/dist/private/node/ui/components/SelectPrompt.js +18 -11
  88. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  89. package/dist/private/node/ui/components/SelectPrompt.test.js +113 -23
  90. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  91. package/dist/private/node/ui/components/Table/Column.d.ts +5 -0
  92. package/dist/private/node/ui/components/Table/Column.js +2 -0
  93. package/dist/private/node/ui/components/Table/Column.js.map +1 -0
  94. package/dist/private/node/ui/components/Table/Row.d.ts +12 -0
  95. package/dist/private/node/ui/components/Table/Row.js +24 -0
  96. package/dist/private/node/ui/components/Table/Row.js.map +1 -0
  97. package/dist/private/node/ui/components/Table/ScalarDict.d.ts +5 -0
  98. package/dist/private/node/ui/components/Table/ScalarDict.js +2 -0
  99. package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -0
  100. package/dist/private/node/ui/components/Table/Table.d.ts +12 -0
  101. package/dist/private/node/ui/components/Table/Table.js +30 -0
  102. package/dist/private/node/ui/components/Table/Table.js.map +1 -0
  103. package/dist/private/node/ui/components/Table/Table.test.d.ts +1 -0
  104. package/dist/private/node/ui/components/Table/Table.test.js +41 -0
  105. package/dist/private/node/ui/components/Table/Table.test.js.map +1 -0
  106. package/dist/private/node/ui/components/Tasks.d.ts +6 -5
  107. package/dist/private/node/ui/components/Tasks.js +32 -11
  108. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  109. package/dist/private/node/ui/components/Tasks.test.js +55 -9
  110. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  111. package/dist/private/node/ui/components/TextInput.d.ts +4 -1
  112. package/dist/private/node/ui/components/TextInput.js +22 -13
  113. package/dist/private/node/ui/components/TextInput.js.map +1 -1
  114. package/dist/private/node/ui/components/TextInput.test.js +47 -40
  115. package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
  116. package/dist/private/node/ui/components/TextPrompt.d.ts +3 -1
  117. package/dist/private/node/ui/components/TextPrompt.js +28 -15
  118. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  119. package/dist/private/node/ui/components/TextPrompt.test.js +71 -15
  120. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  121. package/dist/private/node/ui/components/TokenizedText.d.ts +3 -0
  122. package/dist/private/node/ui/components/TokenizedText.js +33 -1
  123. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  124. package/dist/private/node/ui/utilities.d.ts +2 -0
  125. package/dist/private/node/ui/utilities.js +6 -0
  126. package/dist/private/node/ui/utilities.js.map +1 -0
  127. package/dist/public/common/string.d.ts +11 -0
  128. package/dist/public/common/string.js +21 -0
  129. package/dist/public/common/string.js.map +1 -1
  130. package/dist/{typing → public/common/ts}/pick-by-prefix.d.ts +4 -3
  131. package/dist/{typing → public/common/ts}/pick-by-prefix.js +0 -0
  132. package/dist/public/common/ts/pick-by-prefix.js.map +1 -0
  133. package/dist/public/common/version.d.ts +1 -0
  134. package/dist/public/common/version.js +2 -0
  135. package/dist/public/common/version.js.map +1 -0
  136. package/dist/public/node/analytics.js +2 -2
  137. package/dist/public/node/analytics.js.map +1 -1
  138. package/dist/public/node/api/admin.d.ts +4 -1
  139. package/dist/public/node/api/admin.js +5 -4
  140. package/dist/public/node/api/admin.js.map +1 -1
  141. package/dist/public/node/api/http.d.ts +0 -0
  142. package/dist/public/node/api/http.js +2 -0
  143. package/dist/public/node/api/http.js.map +1 -0
  144. package/dist/public/node/api/oxygen.js +1 -1
  145. package/dist/public/node/api/oxygen.js.map +1 -1
  146. package/dist/public/node/archiver.js +2 -1
  147. package/dist/public/node/archiver.js.map +1 -1
  148. package/dist/public/node/cli.js +6 -6
  149. package/dist/public/node/cli.js.map +1 -1
  150. package/dist/public/node/dot-env.js +2 -2
  151. package/dist/public/node/dot-env.js.map +1 -1
  152. package/dist/public/node/environment/local.js +17 -17
  153. package/dist/public/node/environment/local.js.map +1 -1
  154. package/dist/public/node/environment/spin.js +6 -6
  155. package/dist/public/node/environment/spin.js.map +1 -1
  156. package/dist/public/node/error-handler.js +13 -10
  157. package/dist/public/node/error-handler.js.map +1 -1
  158. package/dist/public/node/framework.js +2 -2
  159. package/dist/public/node/framework.js.map +1 -1
  160. package/dist/public/node/fs.d.ts +241 -4
  161. package/dist/public/node/fs.js +366 -2
  162. package/dist/public/node/fs.js.map +1 -1
  163. package/dist/public/node/git.d.ts +90 -0
  164. package/dist/public/node/git.js +174 -0
  165. package/dist/public/node/git.js.map +1 -0
  166. package/dist/public/node/github.js +1 -1
  167. package/dist/public/node/github.js.map +1 -1
  168. package/dist/{http/fetch.d.ts → public/node/http.d.ts} +18 -7
  169. package/dist/{http/fetch.js → public/node/http.js} +21 -8
  170. package/dist/public/node/http.js.map +1 -0
  171. package/dist/public/node/liquid.js +9 -9
  172. package/dist/public/node/liquid.js.map +1 -1
  173. package/dist/public/node/node-package-manager.d.ts +20 -9
  174. package/dist/public/node/node-package-manager.js +19 -25
  175. package/dist/public/node/node-package-manager.js.map +1 -1
  176. package/dist/public/node/path.d.ts +22 -0
  177. package/dist/{path.js → public/node/path.js} +8 -20
  178. package/dist/public/node/path.js.map +1 -0
  179. package/dist/public/node/presets.js +5 -5
  180. package/dist/public/node/presets.js.map +1 -1
  181. package/dist/public/node/ruby.js +29 -33
  182. package/dist/public/node/ruby.js.map +1 -1
  183. package/dist/public/node/session.js +2 -2
  184. package/dist/public/node/session.js.map +1 -1
  185. package/dist/public/node/ui.d.ts +63 -9
  186. package/dist/public/node/ui.js +83 -8
  187. package/dist/public/node/ui.js.map +1 -1
  188. package/dist/public/node/vscode.js +8 -8
  189. package/dist/public/node/vscode.js.map +1 -1
  190. package/dist/secure-store.js +4 -4
  191. package/dist/secure-store.js.map +1 -1
  192. package/dist/store.d.ts +10 -10
  193. package/dist/store.js +21 -22
  194. package/dist/store.js.map +1 -1
  195. package/dist/testing/store.js +3 -3
  196. package/dist/testing/store.js.map +1 -1
  197. package/dist/testing/ui.d.ts +4 -1
  198. package/dist/testing/ui.js +24 -1
  199. package/dist/testing/ui.js.map +1 -1
  200. package/dist/tsconfig.tsbuildinfo +1 -1
  201. package/dist/ui/executor.d.ts +2 -14
  202. package/dist/ui/executor.js +38 -72
  203. package/dist/ui/executor.js.map +1 -1
  204. package/dist/ui.js +9 -26
  205. package/dist/ui.js.map +1 -1
  206. package/package.json +4 -6
  207. package/dist/constants.d.ts +0 -48
  208. package/dist/constants.js +0 -67
  209. package/dist/constants.js.map +0 -1
  210. package/dist/file.d.ts +0 -98
  211. package/dist/file.js +0 -216
  212. package/dist/file.js.map +0 -1
  213. package/dist/http/fetch.js.map +0 -1
  214. package/dist/http/formdata.d.ts +0 -3
  215. package/dist/http/formdata.js +0 -6
  216. package/dist/http/formdata.js.map +0 -1
  217. package/dist/http.d.ts +0 -26
  218. package/dist/http.js +0 -31
  219. package/dist/http.js.map +0 -1
  220. package/dist/npm.d.ts +0 -27
  221. package/dist/npm.js +0 -20
  222. package/dist/npm.js.map +0 -1
  223. package/dist/path.d.ts +0 -25
  224. package/dist/path.js.map +0 -1
  225. package/dist/private/node/ui/components/Table.js.map +0 -1
  226. package/dist/typing/deep-required.js.map +0 -1
  227. package/dist/typing/overloaded-parameters.js.map +0 -1
  228. package/dist/typing/pick-by-prefix.js.map +0 -1
  229. package/dist/typing/simple-definitions.js.map +0 -1
  230. package/dist/ui/inquirer/autocomplete.d.ts +0 -11
  231. package/dist/ui/inquirer/autocomplete.js +0 -110
  232. package/dist/ui/inquirer/autocomplete.js.map +0 -1
  233. package/dist/ui/inquirer/input.d.ts +0 -16
  234. package/dist/ui/inquirer/input.js +0 -45
  235. package/dist/ui/inquirer/input.js.map +0 -1
  236. package/dist/ui/inquirer/password.d.ts +0 -7
  237. package/dist/ui/inquirer/password.js +0 -8
  238. package/dist/ui/inquirer/password.js.map +0 -1
  239. package/dist/ui/inquirer/select.d.ts +0 -14
  240. package/dist/ui/inquirer/select.js +0 -26
  241. package/dist/ui/inquirer/select.js.map +0 -1
@@ -1,14 +1,2 @@
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
- })[];
1
+ import { Question } from '../ui.js';
2
+ export declare function run(question: Question): Promise<string>;
@@ -1,90 +1,56 @@
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';
1
+ import { renderAutocompletePrompt, renderSelectPrompt, renderTextPrompt } from '@shopify/cli-kit/node/ui';
7
2
  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) {
3
+ let mappedQuestion;
12
4
  switch (question.type) {
13
5
  case 'input':
14
- inquirer.registerPrompt('custom-input', CustomInput);
15
- return {
6
+ mappedQuestion = {
16
7
  ...question,
17
- type: 'custom-input',
8
+ defaultValue: question.default,
9
+ validate: question.validate
10
+ ? (value) => {
11
+ const error = question.validate(value);
12
+ return typeof error === 'string' ? error : undefined;
13
+ }
14
+ : undefined,
18
15
  };
16
+ return renderTextPrompt(mappedQuestion);
19
17
  case 'password':
20
- inquirer.registerPrompt('custom-password', CustomPassword);
21
- return {
18
+ mappedQuestion = {
22
19
  ...question,
23
- type: 'custom-password',
20
+ password: true,
21
+ validate: question.validate
22
+ ? (value) => {
23
+ const error = question.validate(value);
24
+ return typeof error === 'string' ? error : undefined;
25
+ }
26
+ : undefined,
24
27
  };
28
+ return renderTextPrompt(mappedQuestion);
25
29
  case 'select':
26
- inquirer.registerPrompt('custom-select', CustomSelect);
27
- return {
30
+ mappedQuestion = {
28
31
  ...question,
29
- type: 'custom-select',
30
- source: getAutocompleteFilterType(),
31
- choices: question.choices ? groupAndMapChoices(question.choices) : undefined,
32
+ defaultValue: question.default,
33
+ choices: question.choices.map((choice) => {
34
+ return {
35
+ label: choice.name,
36
+ value: choice.value,
37
+ group: choice.group?.name,
38
+ };
39
+ }),
32
40
  };
41
+ return renderSelectPrompt(mappedQuestion);
33
42
  case 'autocomplete': {
34
- inquirer.registerPrompt('autocomplete', CustomAutocomplete);
35
- const filterType = getAutocompleteFilterType();
36
- return {
43
+ mappedQuestion = {
37
44
  ...question,
38
- type: 'autocomplete',
39
- source: question.source ? question.source(filterType) : filterType,
45
+ choices: question.choices.map((choice) => {
46
+ return {
47
+ label: choice.name,
48
+ value: choice.value,
49
+ };
50
+ }),
40
51
  };
52
+ return renderAutocompletePrompt(mappedQuestion);
41
53
  }
42
54
  }
43
55
  }
44
- function fuzzyFilter(answers, input = '') {
45
- return new Promise((resolve) => {
46
- resolve(fuzzy
47
- .filter(input, Object.values(answers), {
48
- extract(el) {
49
- return el.name;
50
- },
51
- })
52
- .map((el) => el.original));
53
- });
54
- }
55
- function containsFilter(answers, input = '') {
56
- return new Promise((resolve) => {
57
- resolve(Object.values(answers).filter((answer) => !answer.name || answer.name.toLowerCase().includes(input.toLowerCase())));
58
- });
59
- }
60
- function getAutocompleteFilterType() {
61
- return process.env.SHOPIFY_USE_AUTOCOMPLETE_FILTER === 'fuzzy' ? fuzzyFilter : containsFilter;
62
- }
63
- export function groupAndMapChoices(choices) {
64
- const initialGroups = [];
65
- // Switched from choices with group information to groups with a list of choices
66
- const groups = choices.reduce((finalChoices, choice) => {
67
- const currentGroup = choice.group ?? { name: 'Other', order: Number.MAX_SAFE_INTEGER };
68
- const existingGroup = finalChoices.find((group) => group.name === currentGroup.name);
69
- if (existingGroup) {
70
- existingGroup.choices.push(choice);
71
- }
72
- else {
73
- finalChoices.push({ ...currentGroup, choices: [choice] });
74
- }
75
- return finalChoices;
76
- }, initialGroups);
77
- const sortedGroups = groups.sort((g1, g2) => g1.order - g2.order);
78
- const grouped = sortedGroups.length > 1 || sortedGroups[0].order !== Number.MAX_SAFE_INTEGER;
79
- // Mapped the group with a list of extensions to a list of inquirer choices including group separators
80
- return sortedGroups.flatMap((group) => {
81
- const finalChoices = [];
82
- if (grouped && group.name) {
83
- finalChoices.push({ type: 'separator', line: '' });
84
- finalChoices.push({ type: 'separator', line: group.name });
85
- }
86
- finalChoices.push(...group.choices);
87
- return finalChoices;
88
- });
89
- }
90
56
  //# sourceMappingURL=executor.js.map
@@ -1 +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,EAAC,MAAM,wBAAwB,CAAA;AAErD,OAAO,QAAuC,MAAM,UAAU,CAAA;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEz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CustomAutocomplete} from './inquirer/autocomplete.js'\nimport {CustomSelect} from './inquirer/select.js'\nimport {CustomPassword} from './inquirer/password.js'\nimport {PromptAnswer, 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: getAutocompleteFilterType(),\n choices: question.choices ? groupAndMapChoices(question.choices) : undefined,\n }\n case 'autocomplete': {\n inquirer.registerPrompt('autocomplete', CustomAutocomplete)\n const filterType = getAutocompleteFilterType()\n return {\n ...question,\n type: 'autocomplete',\n source: question.source ? question.source(filterType) : filterType,\n }\n }\n }\n}\n\nfunction fuzzyFilter(answers: {name: string; value: string}[], input = ''): Promise<PromptAnswer[]> {\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 = ''): Promise<PromptAnswer[]> {\n return new Promise((resolve) => {\n resolve(\n Object.values(answers).filter(\n (answer) => !answer.name || answer.name.toLowerCase().includes(input.toLowerCase()),\n ),\n )\n })\n}\n\nfunction getAutocompleteFilterType() {\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"]}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/ui/executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAA;AAEvG,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,QAAkB;IAC1C,IAAI,cAAc,CAAA;IAElB,QAAQ,QAAQ,CAAC,IAAI,EAAE;QACrB,KAAK,OAAO;YACV,cAAc,GAAG;gBACf,GAAG,QAAQ;gBACX,YAAY,EAAE,QAAQ,CAAC,OAAO;gBAC9B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;oBACzB,CAAC,CAAC,CAAC,KAAa,EAAE,EAAE;wBAChB,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAS,CAAC,KAAK,CAAC,CAAA;wBACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CA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,CAAC,CAAA;SAChD;KACF;AACH,CAAC","sourcesContent":["import {Question} from '../ui.js'\nimport {renderAutocompletePrompt, renderSelectPrompt, renderTextPrompt} from '@shopify/cli-kit/node/ui'\n\nexport async function run(question: Question): Promise<string> {\n let mappedQuestion\n\n switch (question.type) {\n case 'input':\n mappedQuestion = {\n ...question,\n defaultValue: question.default,\n validate: question.validate\n ? (value: string) => {\n const error = question.validate!(value)\n return typeof error === 'string' ? error : undefined\n }\n : undefined,\n }\n\n return renderTextPrompt(mappedQuestion)\n case 'password':\n mappedQuestion = {\n ...question,\n password: true,\n validate: question.validate\n ? (value: string) => {\n const error = question.validate!(value)\n return typeof error === 'string' ? error : undefined\n }\n : undefined,\n }\n\n return renderTextPrompt(mappedQuestion)\n case 'select':\n mappedQuestion = {\n ...question,\n defaultValue: question.default,\n choices: question.choices.map((choice) => {\n return {\n label: choice.name,\n value: choice.value,\n group: choice.group?.name,\n }\n }),\n }\n\n return renderSelectPrompt(mappedQuestion)\n case 'autocomplete': {\n mappedQuestion = {\n ...question,\n choices: question.choices.map((choice) => {\n return {\n label: choice.name,\n value: choice.value,\n }\n }),\n }\n\n return renderAutocompletePrompt(mappedQuestion)\n }\n }\n}\n"]}
package/dist/ui.js CHANGED
@@ -1,29 +1,14 @@
1
1
  import { CancelExecution, Abort, AbortSilent } from './error.js';
2
- import { remove, exists } from './file.js';
2
+ import { removeFile, fileExists } from './public/node/fs.js';
3
3
  import { info, completed, content, token, logUpdate, stringifyMessage, debug } from './output.js';
4
4
  import colors from './public/node/colors.js';
5
- import { relative } from './path.js';
5
+ import { relativePath } from './public/node/path.js';
6
6
  import { isTerminalInteractive } from './public/node/environment/local.js';
7
- import { mapper as mapperUI, run as executorUI } from './ui/executor.js';
8
- import { Listr as OriginalListr, ListrTaskState } from 'listr2';
7
+ import { run as executorUI } from './ui/executor.js';
8
+ import { Listr as OriginalListr } from 'listr2';
9
9
  import findProcess from 'find-process';
10
10
  export function newListr(tasks, options) {
11
11
  const listr = new OriginalListr(tasks, options);
12
- listr.tasks.forEach((task) => {
13
- const loggedSubtaskTitles = [];
14
- task.renderHook$.subscribe(() => {
15
- if (task.hasSubtasks()) {
16
- const activeSubtasks = task.subtasks.filter((subtask) => {
17
- return [ListrTaskState.PENDING, ListrTaskState.COMPLETED].includes(subtask.state);
18
- });
19
- activeSubtasks.forEach((subtask) => {
20
- if (subtask.title && !loggedSubtaskTitles.includes(subtask.title)) {
21
- loggedSubtaskTitles.push(subtask.title);
22
- }
23
- });
24
- }
25
- });
26
- });
27
12
  return listr;
28
13
  }
29
14
  const started = (content, logger) => {
@@ -56,25 +41,23 @@ The CLI prompted in a non-interactive terminal with the following questions:
56
41
  ${token.json(questions)}
57
42
  `);
58
43
  }
59
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
- const mappedQuestions = questions.map(mapperUI);
61
44
  const value = {};
62
- for (const question of mappedQuestions) {
45
+ for (const question of questions) {
63
46
  if (question.preface) {
64
47
  info(question.preface);
65
48
  }
66
49
  // eslint-disable-next-line no-await-in-loop
67
- value[question.name] = await executorUI(question);
50
+ value[question.name] = (await executorUI(question));
68
51
  }
69
52
  return value;
70
53
  };
71
54
  export async function nonEmptyDirectoryPrompt(directory) {
72
- if (await exists(directory)) {
55
+ if (await fileExists(directory)) {
73
56
  const options = [
74
57
  { name: 'No, don’t delete the files', value: 'abort' },
75
58
  { name: 'Yes, delete the files', value: 'overwrite' },
76
59
  ];
77
- const relativeDirectory = relative(process.cwd(), directory);
60
+ const relativeDirectory = relativePath(process.cwd(), directory);
78
61
  const questions = {
79
62
  type: 'select',
80
63
  name: 'value',
@@ -85,7 +68,7 @@ export async function nonEmptyDirectoryPrompt(directory) {
85
68
  if (choice.value === 'abort') {
86
69
  throw new CancelExecution();
87
70
  }
88
- await remove(directory);
71
+ await removeFile(directory);
89
72
  }
90
73
  }
91
74
  export async function terminateBlockingPortProcessPrompt(port, stepDescription) {
package/dist/ui.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file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MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YAErB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;gBAClC,KAAK,CAAC,wCAAwC,CAAC,CAAA;gBAC/C,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;aAC1B;YACD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;QACtB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {CancelExecution, Abort, AbortSilent} from './error.js'\nimport {remove, exists} from './file.js'\nimport {info, completed, content, token, logUpdate, Message, Logger, stringifyMessage, debug} from './output.js'\nimport colors from './public/node/colors.js'\nimport {relative} from './path.js'\nimport {isTerminalInteractive} from './public/node/environment/local.js'\nimport {mapper as mapperUI, run as executorUI} from './ui/executor.js'\nimport {Listr as OriginalListr, ListrTask, ListrTaskState, ListrBaseClassOptions} from 'listr2'\nimport findProcess from 'find-process'\n\nexport function newListr(tasks: ListrTask[], options?: object | ListrBaseClassOptions) {\n const listr = new OriginalListr(tasks, options)\n listr.tasks.forEach((task) => {\n const loggedSubtaskTitles: string[] = []\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 }\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 PromptAnswer {\n name: string\n value: string\n}\nexport type FilterFunction = (answers: PromptAnswer[], input: string) => Promise<PromptAnswer[]>\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 choices?: QuestionChoiceType[]\n source?: (filter: FilterFunction) => FilterFunction\n}\n\ntype TextQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'input'\n // a default is required, otherwise we'd show a prompt like 'undefined'\n default: string\n}\n\ntype PasswordQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'password'\n}\n\ntype SelectableQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'select' | 'autocomplete'\n choices: QuestionChoiceType[]\n}\n\nexport type Question<TName extends string = string> =\n | TextQuestion<TName>\n | SelectableQuestion<TName>\n | PasswordQuestion<TName>\n\nexport interface QuestionChoiceType {\n name: string\n value: string\n group?: {name: string; order: number}\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 return value\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 return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n debug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilent())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,KAAK,EAAE,WAAW,EAAC,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAmB,gBAAgB,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAChH,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAC,GAAG,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,KAAK,IAAI,aAAa,EAAmC,MAAM,QAAQ,CAAA;AAC/E,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,MAAM,UAAU,QAAQ,CAAC,KAAkB,EAAE,OAAwC;IACnF,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,KAAK,CAAA;AACd,CAAC;AAgDD,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAE,MAAc,EAAE,EAAE;IACnD,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAA;IACpE,I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UAAU,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {CancelExecution, Abort, AbortSilent} from './error.js'\nimport {removeFile, fileExists} from './public/node/fs.js'\nimport {info, completed, content, token, logUpdate, Message, Logger, stringifyMessage, debug} from './output.js'\nimport colors from './public/node/colors.js'\nimport {relativePath} from './public/node/path.js'\nimport {isTerminalInteractive} from './public/node/environment/local.js'\nimport {run as executorUI} from './ui/executor.js'\nimport {Listr as OriginalListr, ListrTask, ListrBaseClassOptions} from 'listr2'\nimport findProcess from 'find-process'\n\nexport function newListr(tasks: ListrTask[], options?: object | ListrBaseClassOptions) {\n const listr = new OriginalListr(tasks, options)\n return listr\n}\n\nexport type ListrTasks = ConstructorParameters<typeof OriginalListr>[0]\nexport type {ListrTaskWrapper, ListrDefaultRenderer, ListrTask} from 'listr2'\n\nexport interface PromptAnswer {\n name: string\n value: string\n}\nexport type FilterFunction = (answers: PromptAnswer[], input: string) => Promise<PromptAnswer[]>\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 choices?: QuestionChoiceType[]\n source?: (filter: FilterFunction) => FilterFunction\n}\n\ntype TextQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'input'\n // a default is required, otherwise we'd show a prompt like 'undefined'\n default: string\n}\n\ntype PasswordQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'password'\n}\n\ntype SelectableQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'select' | 'autocomplete'\n choices: QuestionChoiceType[]\n}\n\nexport type Question<TName extends string = string> =\n | TextQuestion<TName>\n | SelectableQuestion<TName>\n | PasswordQuestion<TName>\n\nexport interface QuestionChoiceType {\n name: string\n value: string\n group?: {name: string; order: number}\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 const value = {} as TAnswers\n for (const question of questions) {\n if (question.preface) {\n info(question.preface)\n }\n\n // eslint-disable-next-line no-await-in-loop\n value[question.name] = (await executorUI(question)) as TAnswers[TName]\n }\n return value\n}\n\nexport async function nonEmptyDirectoryPrompt(directory: string) {\n if (await fileExists(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 = relativePath(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 removeFile(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 return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n debug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilent())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/cli-kit",
3
- "version": "3.34.0",
3
+ "version": "3.36.0",
4
4
  "private": false,
5
5
  "description": "A set of utilities, interfaces, and models that are common across all the platform features",
6
6
  "keywords": [
@@ -61,8 +61,8 @@
61
61
  "./environment/local.js",
62
62
  "@oclif/core",
63
63
  "../../private/node/environment/utilities.js",
64
- "../../constants.js",
65
- "../../path.js",
64
+ "../../private/node/constants.js",
65
+ "./path.js",
66
66
  "./system.js"
67
67
  ],
68
68
  "static": [
@@ -94,6 +94,7 @@
94
94
  "envfile": "6.18.0",
95
95
  "execa": "6.0.0",
96
96
  "fast-glob": "3.2.11",
97
+ "figures": "5.0.0",
97
98
  "find-process": "1.4.7",
98
99
  "find-up": "6.2.0",
99
100
  "find-versions": "5.0.0",
@@ -106,8 +107,6 @@
106
107
  "graphql-request": "4.3.0",
107
108
  "h3": "0.7.21",
108
109
  "ink": "3.2.0",
109
- "inquirer": "9.1.4",
110
- "inquirer-autocomplete-prompt": "3.0.0",
111
110
  "is-interactive": "2.0.0",
112
111
  "js-yaml": "4.1.0",
113
112
  "keytar": "7.9.0",
@@ -143,7 +142,6 @@
143
142
  "@types/diff": "^5.0.2",
144
143
  "@types/fs-extra": "9.0.13",
145
144
  "@types/gradient-string": "^1.1.2",
146
- "@types/inquirer": "^9.0.3",
147
145
  "@types/lodash": "4.14.191",
148
146
  "@types/node": "14.17.0",
149
147
  "@types/react": "17.0.2",
@@ -1,48 +0,0 @@
1
- declare const constants: {
2
- environmentVariables: {
3
- alwaysLogAnalytics: string;
4
- deviceAuth: string;
5
- enableCliRedirect: string;
6
- env: string;
7
- firstPartyDev: string;
8
- noAnalytics: string;
9
- partnersToken: string;
10
- runAsUser: string;
11
- serviceEnv: string;
12
- skipCliRedirect: string;
13
- spinInstance: string;
14
- themeToken: string;
15
- unitTest: string;
16
- verbose: string;
17
- themeBundling: string;
18
- codespaceName: string;
19
- codespaces: string;
20
- gitpod: string;
21
- spin: string;
22
- };
23
- paths: {
24
- executables: {
25
- dev: string;
26
- };
27
- directories: {
28
- cache: {
29
- path: () => string;
30
- vendor: {
31
- path: () => any;
32
- binaries: () => any;
33
- };
34
- };
35
- };
36
- };
37
- versions: {
38
- cliKit: () => Promise<string>;
39
- };
40
- keychain: {
41
- service: string;
42
- };
43
- session: {
44
- expirationTimeMarginInMinutes: number;
45
- };
46
- };
47
- export declare const bugsnagApiKey = "9e1e6889176fd0c795d5c659225e0fae";
48
- export default constants;
package/dist/constants.js DELETED
@@ -1,67 +0,0 @@
1
- import { join as pathJoin } from './path.js';
2
- import { findPackageVersionUp } from './public/node/node-package-manager.js';
3
- import envPaths from 'env-paths';
4
- const identifier = 'shopify-cli';
5
- const cacheFolder = () => {
6
- if (process.env.XDG_CACHE_HOME)
7
- return process.env.XDG_CACHE_HOME;
8
- return envPaths(identifier).cache;
9
- };
10
- const constants = {
11
- environmentVariables: {
12
- alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',
13
- deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',
14
- enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',
15
- env: 'SHOPIFY_CLI_ENV',
16
- firstPartyDev: 'SHOPIFY_CLI_1P_DEV',
17
- noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',
18
- partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',
19
- runAsUser: 'SHOPIFY_RUN_AS_USER',
20
- serviceEnv: 'SHOPIFY_SERVICE_ENV',
21
- skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',
22
- spinInstance: 'SPIN_INSTANCE',
23
- themeToken: 'SHOPIFY_CLI_THEME_TOKEN',
24
- unitTest: 'SHOPIFY_UNIT_TEST',
25
- verbose: 'SHOPIFY_FLAG_VERBOSE',
26
- themeBundling: 'SHOPIFY_THEME_BUNDLING',
27
- // Variables to detect if the CLI is running in a cloud environment
28
- codespaceName: 'CODESPACE_NAME',
29
- codespaces: 'CODESPACES',
30
- gitpod: 'GITPOD_WORKSPACE_URL',
31
- spin: 'SPIN',
32
- },
33
- paths: {
34
- executables: {
35
- dev: '/opt/dev/bin/dev',
36
- },
37
- directories: {
38
- cache: {
39
- path: () => {
40
- return cacheFolder();
41
- },
42
- vendor: {
43
- path: () => {
44
- return pathJoin(cacheFolder(), 'vendor');
45
- },
46
- binaries: () => {
47
- return pathJoin(cacheFolder(), 'vendor', 'binaries');
48
- },
49
- },
50
- },
51
- },
52
- },
53
- versions: {
54
- cliKit: async () => {
55
- return findPackageVersionUp({ fromModuleURL: import.meta.url });
56
- },
57
- },
58
- keychain: {
59
- service: 'shopify-cli',
60
- },
61
- session: {
62
- expirationTimeMarginInMinutes: 4,
63
- },
64
- };
65
- export const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae';
66
- export default constants;
67
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[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AE,QAAQ,CAAC,CAAA;oBAC1C,CAAC;oBACD,QAAQ,EAAE,GAAG,EAAE;wBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;oBACtD,CAAC;iBACF;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,oBAAoB,CAAC,EAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './public/node/node-package-manager.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinInstance: 'SPIN_INSTANCE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n themeBundling: 'SHOPIFY_THEME_BUNDLING',\n // Variables to detect if the CLI is running in a cloud environment\n codespaceName: 'CODESPACE_NAME',\n codespaces: 'CODESPACES',\n gitpod: 'GITPOD_WORKSPACE_URL',\n spin: 'SPIN',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
package/dist/file.d.ts DELETED
@@ -1,98 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- export declare function stripUp(path: string, strip: number): any;
4
- /**
5
- * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.
6
- * @param callback - The callback that receives the temporary directory.
7
- */
8
- export declare function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T>;
9
- /**
10
- * It reads a file and returns its content as a string using the
11
- * utf-8 encoding
12
- * @param path - Path to the file to read.
13
- * @returns A promise that resolves with the content of the file.
14
- */
15
- export declare type ReadOptions = undefined | {
16
- flag?: string | undefined;
17
- } | {
18
- encoding: BufferEncoding | string;
19
- flag?: string | undefined;
20
- };
21
- export declare function read(path: string, options?: ReadOptions): Promise<string>;
22
- export declare function read(path: string, options?: ReadOptions): Promise<Buffer>;
23
- /**
24
- * Given a path, it determines the actual path. This is useful when working
25
- * with paths that represent symlinks.
26
- * @param path - Path whose real path will be returned.
27
- */
28
- export declare function realpath(path: string): Promise<string>;
29
- export declare function readSync(path: string, options?: object): string;
30
- /**
31
- * Copies a file
32
- * @param from - Path to the directory or file to be copied.
33
- * @param to - Destination path.
34
- */
35
- export declare function copy(from: string, to: string): Promise<void>;
36
- export declare function touch(path: string): Promise<void>;
37
- export declare function appendFile(path: string, content: string): Promise<void>;
38
- export declare function touchSync(path: string): void;
39
- export declare function write(path: string, data: string): Promise<void>;
40
- export declare function writeSync(path: string, data: string): void;
41
- export declare function append(path: string, data: string): Promise<void>;
42
- export declare function appendSync(path: string, data: string): void;
43
- export declare function mkdir(path: string): Promise<void>;
44
- export declare function mkdirSync(path: string): void;
45
- export declare function remove(path: string): Promise<void>;
46
- export declare function removeSync(path: string): void;
47
- export declare function rmdir(path: string, { force }?: {
48
- force?: boolean;
49
- }): Promise<void>;
50
- export declare function mkTmpDir(): Promise<string>;
51
- export declare function isDirectory(path: string): Promise<boolean>;
52
- export declare function size(path: string): Promise<number>;
53
- export declare function sizeSync(path: string): number;
54
- export declare function createReadStream(path: string): import("fs").ReadStream;
55
- /**
56
- * Returns the Date object for the last modification of a file.
57
- * @param path - Path to the directory or file.
58
- * @returns A unix timestamp.
59
- */
60
- export declare function lastUpdated(path: string): Promise<Date>;
61
- /**
62
- * Returns the unix timestamp of the last modification of a file.
63
- * @param path - Path to the directory or file.
64
- * @returns A unix timestamp.
65
- */
66
- export declare function lastUpdatedTimestamp(path: string): Promise<number | undefined>;
67
- /**
68
- * Moves a file.
69
- * @param src - File to be moved.
70
- * @param dest - Path to be moved to.
71
- * @param options - Moving options.
72
- */
73
- export declare function move(src: string, dest: string, options?: {
74
- overwrite?: boolean;
75
- }): Promise<void>;
76
- /**
77
- * Changes the permissions of a directory or file.
78
- * @param path - Path to the file or directory whose permissions will be modified.
79
- * @param mode - Permissions to set to the file or directory.
80
- */
81
- export declare function chmod(path: string, mode: number | string): Promise<void>;
82
- /**
83
- * Checks if a file has executable permissions.
84
- * @param path - Path to the file whose permissions will be checked.
85
- */
86
- export declare function hasExecutablePermissions(path: string): Promise<boolean>;
87
- /**
88
- * Returns true if a file or directory exists
89
- * @param path - Path to the directory or file.
90
- * @returns True if it exists.
91
- */
92
- export declare function exists(path: string): Promise<boolean>;
93
- /**
94
- * Format a string using prettier. Return the formatted content.
95
- */
96
- export declare function format(content: string, options: {
97
- path: string;
98
- }): Promise<string>;