@shopify/cli-kit 3.31.1 → 3.32.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 (252) hide show
  1. package/README.md +1 -1
  2. package/dist/api.d.ts +2 -5
  3. package/dist/api.js +2 -5
  4. package/dist/api.js.map +1 -1
  5. package/dist/constants.d.ts +1 -0
  6. package/dist/constants.js +1 -0
  7. package/dist/constants.js.map +1 -1
  8. package/dist/environment/local.d.ts +1 -0
  9. package/dist/environment/local.js +4 -1
  10. package/dist/environment/local.js.map +1 -1
  11. package/dist/file.d.ts +10 -3
  12. package/dist/file.js +34 -34
  13. package/dist/file.js.map +1 -1
  14. package/dist/http/fetch.js +1 -1
  15. package/dist/http/fetch.js.map +1 -1
  16. package/dist/http.d.ts +0 -1
  17. package/dist/http.js +0 -1
  18. package/dist/http.js.map +1 -1
  19. package/dist/index.d.ts +0 -8
  20. package/dist/index.js +0 -8
  21. package/dist/index.js.map +1 -1
  22. package/dist/metadata.d.ts +1 -1
  23. package/dist/metadata.js.map +1 -1
  24. package/dist/monorail.d.ts +1 -1
  25. package/dist/monorail.js.map +1 -1
  26. package/dist/npm.js +1 -1
  27. package/dist/npm.js.map +1 -1
  28. package/dist/output.d.ts +2 -2
  29. package/dist/output.js +1 -1
  30. package/dist/output.js.map +1 -1
  31. package/dist/path.d.ts +3 -1
  32. package/dist/path.js +2 -2
  33. package/dist/path.js.map +1 -1
  34. package/dist/plugins.d.ts +1 -1
  35. package/dist/plugins.js.map +1 -1
  36. package/dist/{json.d.ts → private/common/json.d.ts} +0 -0
  37. package/dist/{json.js → private/common/json.js} +0 -0
  38. package/dist/private/common/json.js.map +1 -0
  39. package/dist/private/node/analytics.d.ts +27 -0
  40. package/dist/private/node/analytics.js +57 -0
  41. package/dist/private/node/analytics.js.map +1 -0
  42. package/dist/private/node/api/graphql.d.ts +5 -0
  43. package/dist/private/node/api/graphql.js +63 -0
  44. package/dist/private/node/api/graphql.js.map +1 -0
  45. package/dist/{api/common.d.ts → private/node/api/headers.d.ts} +3 -8
  46. package/dist/{api/common.js → private/node/api/headers.js} +20 -60
  47. package/dist/private/node/api/headers.js.map +1 -0
  48. package/dist/private/node/ui/components/Alert.test.js +5 -5
  49. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  50. package/dist/private/node/ui/components/Banner.js +5 -5
  51. package/dist/private/node/ui/components/Banner.js.map +1 -1
  52. package/dist/private/node/ui/components/Banner.test.js +11 -11
  53. package/dist/private/node/ui/components/Banner.test.js.map +1 -1
  54. package/dist/private/node/ui/components/Command.test.js +3 -3
  55. package/dist/private/node/ui/components/Command.test.js.map +1 -1
  56. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
  57. package/dist/private/node/ui/components/ConcurrentOutput.js +1 -1
  58. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  59. package/dist/private/node/ui/components/ConcurrentOutput.test.js +3 -3
  60. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  61. package/dist/private/node/ui/components/FatalError.test.js +9 -9
  62. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  63. package/dist/private/node/ui/components/FilePath.test.js +3 -3
  64. package/dist/private/node/ui/components/FilePath.test.js.map +1 -1
  65. package/dist/private/node/ui/components/FullScreen.js +11 -9
  66. package/dist/private/node/ui/components/FullScreen.js.map +1 -1
  67. package/dist/private/node/ui/components/Link.test.js +5 -5
  68. package/dist/private/node/ui/components/Link.test.js.map +1 -1
  69. package/dist/private/node/ui/components/List.test.js +5 -5
  70. package/dist/private/node/ui/components/List.test.js.map +1 -1
  71. package/dist/private/node/ui/components/SelectInput.d.ts +2 -2
  72. package/dist/private/node/ui/components/SelectInput.js +16 -24
  73. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  74. package/dist/private/node/ui/components/SelectInput.test.js +62 -32
  75. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  76. package/dist/private/node/ui/components/{Prompt.d.ts → SelectPrompt.d.ts} +4 -3
  77. package/dist/private/node/ui/components/SelectPrompt.js +46 -0
  78. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -0
  79. package/dist/private/node/ui/components/{Prompt.test.d.ts → SelectPrompt.test.d.ts} +0 -0
  80. package/dist/private/node/ui/components/{Prompt.test.js → SelectPrompt.test.js} +7 -6
  81. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -0
  82. package/dist/private/node/ui/components/Table.js +2 -2
  83. package/dist/private/node/ui/components/Table.js.map +1 -1
  84. package/dist/private/node/ui/components/Tasks.d.ts +1 -1
  85. package/dist/private/node/ui/components/Tasks.js +3 -3
  86. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  87. package/dist/private/node/ui/components/Tasks.test.js +4 -4
  88. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  89. package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
  90. package/dist/private/node/ui/components/TextInput.d.ts +9 -0
  91. package/dist/private/node/ui/components/TextInput.js +74 -0
  92. package/dist/private/node/ui/components/TextInput.js.map +1 -0
  93. package/dist/private/node/ui/components/TextInput.test.d.ts +1 -0
  94. package/dist/private/node/ui/components/TextInput.test.js +139 -0
  95. package/dist/private/node/ui/components/TextInput.test.js.map +1 -0
  96. package/dist/private/node/ui/components/TextPrompt.d.ts +8 -0
  97. package/dist/private/node/ui/components/TextPrompt.js +52 -0
  98. package/dist/private/node/ui/components/TextPrompt.js.map +1 -0
  99. package/dist/private/node/ui/components/TextPrompt.test.d.ts +1 -0
  100. package/dist/private/node/ui/components/TextPrompt.test.js +68 -0
  101. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -0
  102. package/dist/private/node/ui/components/TokenizedText.test.js +3 -3
  103. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  104. package/dist/private/node/ui/components/UserInput.test.js +3 -3
  105. package/dist/private/node/ui/components/UserInput.test.js.map +1 -1
  106. package/dist/private/node/ui/hooks/use-layout.d.ts +6 -3
  107. package/dist/private/node/ui/hooks/use-layout.js +17 -8
  108. package/dist/private/node/ui/hooks/use-layout.js.map +1 -1
  109. package/dist/private/node/ui.d.ts +2 -3
  110. package/dist/private/node/ui.js +7 -16
  111. package/dist/private/node/ui.js.map +1 -1
  112. package/dist/public/common/array.js +1 -1
  113. package/dist/public/common/array.js.map +1 -1
  114. package/dist/public/common/collection.js +1 -1
  115. package/dist/public/common/collection.js.map +1 -1
  116. package/dist/public/common/function.js +1 -1
  117. package/dist/public/common/function.js.map +1 -1
  118. package/dist/public/common/lang.js +1 -1
  119. package/dist/public/common/lang.js.map +1 -1
  120. package/dist/public/common/object.js +4 -4
  121. package/dist/public/common/object.js.map +1 -1
  122. package/dist/public/common/string.d.ts +55 -1
  123. package/dist/public/common/string.js +93 -1
  124. package/dist/public/common/string.js.map +1 -1
  125. package/dist/public/common/url.d.ts +7 -0
  126. package/dist/public/common/url.js +17 -0
  127. package/dist/public/common/url.js.map +1 -0
  128. package/dist/public/node/abort.d.ts +16 -0
  129. package/dist/public/node/abort.js +17 -0
  130. package/dist/public/node/abort.js.map +1 -0
  131. package/dist/public/node/analytics.d.ts +13 -0
  132. package/dist/public/node/analytics.js +82 -0
  133. package/dist/public/node/analytics.js.map +1 -0
  134. package/dist/public/node/api/admin.d.ts +11 -0
  135. package/dist/public/node/api/admin.js +70 -0
  136. package/dist/public/node/api/admin.js.map +1 -0
  137. package/dist/public/node/api/oxygen.d.ts +22 -0
  138. package/dist/public/node/api/oxygen.js +40 -0
  139. package/dist/public/node/api/oxygen.js.map +1 -0
  140. package/dist/{api → public/node/api}/partners.d.ts +11 -3
  141. package/dist/public/node/api/partners.js +40 -0
  142. package/dist/public/node/api/partners.js.map +1 -0
  143. package/dist/public/node/archiver.js +1 -1
  144. package/dist/public/node/archiver.js.map +1 -1
  145. package/dist/public/node/base-command.js +1 -1
  146. package/dist/public/node/base-command.js.map +1 -1
  147. package/dist/public/node/crypto.d.ts +42 -0
  148. package/dist/public/node/crypto.js +55 -0
  149. package/dist/public/node/crypto.js.map +1 -0
  150. package/dist/public/node/error-handler.js +3 -2
  151. package/dist/public/node/error-handler.js.map +1 -1
  152. package/dist/public/node/framework.js +1 -1
  153. package/dist/public/node/framework.js.map +1 -1
  154. package/dist/public/node/hooks/postrun.js +2 -2
  155. package/dist/public/node/hooks/postrun.js.map +1 -1
  156. package/dist/public/node/hooks/prerun.js +2 -2
  157. package/dist/public/node/hooks/prerun.js.map +1 -1
  158. package/dist/{template.d.ts → public/node/liquid.d.ts} +10 -2
  159. package/dist/{template.js → public/node/liquid.js} +18 -13
  160. package/dist/public/node/liquid.js.map +1 -0
  161. package/dist/public/node/node-package-manager.d.ts +3 -3
  162. package/dist/public/node/node-package-manager.js +1 -1
  163. package/dist/public/node/node-package-manager.js.map +1 -1
  164. package/dist/public/node/os.d.ts +16 -0
  165. package/dist/{os.js → public/node/os.js} +33 -29
  166. package/dist/public/node/os.js.map +1 -0
  167. package/dist/public/node/presets.d.ts +1 -1
  168. package/dist/public/node/presets.js +2 -2
  169. package/dist/public/node/presets.js.map +1 -1
  170. package/dist/public/node/ruby.d.ts +13 -9
  171. package/dist/public/node/ruby.js +91 -23
  172. package/dist/public/node/ruby.js.map +1 -1
  173. package/dist/public/node/tcp.d.ts +2 -0
  174. package/dist/public/node/tcp.js +9 -0
  175. package/dist/public/node/tcp.js.map +1 -1
  176. package/dist/public/node/toml.d.ts +15 -0
  177. package/dist/public/node/toml.js +20 -0
  178. package/dist/public/node/toml.js.map +1 -0
  179. package/dist/public/node/ui.d.ts +12 -17
  180. package/dist/public/node/ui.js +25 -29
  181. package/dist/public/node/ui.js.map +1 -1
  182. package/dist/public/node/vscode.d.ts +14 -0
  183. package/dist/{vscode.js → public/node/vscode.js} +13 -7
  184. package/dist/public/node/vscode.js.map +1 -0
  185. package/dist/session/authorize.d.ts +4 -0
  186. package/dist/session/authorize.js +8 -3
  187. package/dist/session/authorize.js.map +1 -1
  188. package/dist/{api/identity.d.ts → session/identity-token-validation.d.ts} +0 -0
  189. package/dist/{api/identity.js → session/identity-token-validation.js} +1 -1
  190. package/dist/session/identity-token-validation.js.map +1 -0
  191. package/dist/session/redirect-listener.js +6 -3
  192. package/dist/session/redirect-listener.js.map +1 -1
  193. package/dist/session/schema.d.ts +18 -18
  194. package/dist/session/store.js +1 -1
  195. package/dist/session/store.js.map +1 -1
  196. package/dist/session.js +3 -3
  197. package/dist/session.js.map +1 -1
  198. package/dist/system.d.ts +2 -2
  199. package/dist/system.js +1 -1
  200. package/dist/system.js.map +1 -1
  201. package/dist/testing/ui.d.ts +1 -1
  202. package/dist/testing/ui.js +1 -1
  203. package/dist/testing/ui.js.map +1 -1
  204. package/dist/tsconfig.tsbuildinfo +1 -1
  205. package/dist/ui/inquirer/autocomplete.d.ts +2 -2
  206. package/dist/ui/inquirer/autocomplete.js +1 -1
  207. package/dist/ui/inquirer/autocomplete.js.map +1 -1
  208. package/dist/ui/inquirer/input.d.ts +2 -2
  209. package/dist/ui/inquirer/input.js.map +1 -1
  210. package/dist/ui/inquirer/password.d.ts +2 -2
  211. package/dist/ui/inquirer/password.js.map +1 -1
  212. package/dist/ui/inquirer/select.d.ts +2 -2
  213. package/dist/ui/inquirer/select.js +2 -2
  214. package/dist/ui/inquirer/select.js.map +1 -1
  215. package/package.json +30 -27
  216. package/dist/abort.d.ts +0 -1
  217. package/dist/abort.js +0 -2
  218. package/dist/abort.js.map +0 -1
  219. package/dist/analytics.d.ts +0 -44
  220. package/dist/analytics.js +0 -154
  221. package/dist/analytics.js.map +0 -1
  222. package/dist/api/admin.d.ts +0 -3
  223. package/dist/api/admin.js +0 -56
  224. package/dist/api/admin.js.map +0 -1
  225. package/dist/api/common.js.map +0 -1
  226. package/dist/api/identity.js.map +0 -1
  227. package/dist/api/oxygen.d.ts +0 -5
  228. package/dist/api/oxygen.js +0 -30
  229. package/dist/api/oxygen.js.map +0 -1
  230. package/dist/api/partners.js +0 -44
  231. package/dist/api/partners.js.map +0 -1
  232. package/dist/http/graphql.d.ts +0 -13
  233. package/dist/http/graphql.js +0 -12
  234. package/dist/http/graphql.js.map +0 -1
  235. package/dist/id.d.ts +0 -6
  236. package/dist/id.js +0 -18
  237. package/dist/id.js.map +0 -1
  238. package/dist/json.js.map +0 -1
  239. package/dist/os.d.ts +0 -10
  240. package/dist/os.js.map +0 -1
  241. package/dist/private/node/ui/components/Prompt.js +0 -23
  242. package/dist/private/node/ui/components/Prompt.js.map +0 -1
  243. package/dist/private/node/ui/components/Prompt.test.js.map +0 -1
  244. package/dist/string.d.ts +0 -28
  245. package/dist/string.js +0 -77
  246. package/dist/string.js.map +0 -1
  247. package/dist/template.js.map +0 -1
  248. package/dist/toml.d.ts +0 -3
  249. package/dist/toml.js +0 -8
  250. package/dist/toml.js.map +0 -1
  251. package/dist/vscode.d.ts +0 -8
  252. package/dist/vscode.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACvD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,yBAAyB,EAAE,CAAA;QAC3D,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAC,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAC;YAC/E,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC;SAC9B,CAAA;QACD,KAAK,CAAC,kDAAkD,iBAAiB,EAAE,CAAC,CAAA;QAE5E,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAE/D,IAAI,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE;YACzE,8DAA8D;YAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YACvC,KAAK,CAAC,gCAAgC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;YACnD,OAAO,IAAI,CAAC,KAAK,CAAA;SAClB;aAAM;YACL,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAClC,KAAK,CAAC;aACC,QAAQ,CAAC,MAAM;8BACE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;WAC3E,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAC5B,OAAO,KAAK,CAAA;SACb;QACD,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACxG,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch(instrospectionURL, options)\n\n if (response.ok && response.headers.get('content-type')?.includes('json')) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n } else {\n const text = await response.text()\n debug(`The Introspection request failed with:\n - status: ${response.status}\n - www-authenticate header: ${JSON.stringify(response.headers.get('www-authenticate'))}\n - body: ${JSON.stringify(text)}`)\n return false\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
@@ -1,5 +0,0 @@
1
- import { Variables, RequestDocument } from 'graphql-request';
2
- import FormData from 'form-data';
3
- import { Response } from 'node-fetch';
4
- export declare function request<T>(oxygenAddress: string, query: RequestDocument, token: string, variables?: Variables): Promise<T>;
5
- export declare function uploadDeploymentFile(oxygenAddress: string, token: string, data: FormData): Promise<Response>;
@@ -1,30 +0,0 @@
1
- import { buildHeaders, debugLogRequest } from './common.js';
2
- import { graphqlClient } from '../http/graphql.js';
3
- import { shopifyFetch } from '../http.js';
4
- export async function request(oxygenAddress, query, token, variables) {
5
- const headers = await buildHeaders(token);
6
- debugLogRequest('Oxygen', query, variables, headers);
7
- const client = await graphqlClient({
8
- headers,
9
- url: getOxygenAddress(oxygenAddress),
10
- });
11
- const response = await client.request(query, variables);
12
- return response;
13
- }
14
- export async function uploadDeploymentFile(oxygenAddress, token, data) {
15
- const headers = await buildHeaders(token);
16
- delete headers['Content-Type'];
17
- const response = await shopifyFetch(getOxygenAddress(oxygenAddress), {
18
- method: 'POST',
19
- body: data,
20
- headers: {
21
- ...headers,
22
- ...data.getHeaders(),
23
- },
24
- });
25
- return response;
26
- }
27
- const getOxygenAddress = (oxygenHost) => {
28
- return `https://${oxygenHost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EAAU,EAAE;IACtD,OAAO,WAAW,UAAU,wBAAwB,CAAA;AACtD,CAAC,CAAA","sourcesContent":["import {buildHeaders, debugLogRequest} from './common.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {shopifyFetch} from '../http.js'\nimport {Variables, RequestDocument} from 'graphql-request'\nimport FormData from 'form-data'\nimport {Response} from 'node-fetch'\n\nexport async function request<T>(\n oxygenAddress: string,\n query: RequestDocument,\n token: string,\n variables?: Variables,\n): Promise<T> {\n const headers = await buildHeaders(token)\n debugLogRequest('Oxygen', query, variables, headers)\n const client = await graphqlClient({\n headers,\n url: getOxygenAddress(oxygenAddress),\n })\n\n const response = await client.request<T>(query, variables)\n return response\n}\n\nexport async function uploadDeploymentFile(oxygenAddress: string, token: string, data: FormData): Promise<Response> {\n const headers = await buildHeaders(token)\n delete headers['Content-Type']\n\n const response = await shopifyFetch(getOxygenAddress(oxygenAddress), {\n method: 'POST',\n body: data,\n headers: {\n ...headers,\n ...data.getHeaders(),\n },\n })\n\n return response\n}\n\nconst getOxygenAddress = (oxygenHost: string): string => {\n return `https://${oxygenHost}/api/graphql/deploy/v1`\n}\n"]}
@@ -1,44 +0,0 @@
1
- import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
2
- import { ScriptServiceProxyQuery } from './graphql/index.js';
3
- import { partners as partnersFqdn } from '../environment/fqdn.js';
4
- import { graphqlClient } from '../http/graphql.js';
5
- import { debug } from '../output.js';
6
- import { performance } from 'perf_hooks';
7
- export async function request(query, token, variables) {
8
- const api = 'Partners';
9
- return handlingErrors(api, async () => {
10
- const fqdn = await partnersFqdn();
11
- const url = `https://${fqdn}/api/cli/graphql`;
12
- const headers = await buildHeaders(token);
13
- debugLogRequest(api, query, variables, headers);
14
- const client = await graphqlClient({ headers, url });
15
- const t0 = performance.now();
16
- const response = await client.request(query, variables);
17
- const t1 = performance.now();
18
- debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`);
19
- return response;
20
- });
21
- }
22
- /**
23
- * Function queries are proxied through the script service proxy.
24
- * To execute a query, we encapsulate it inside another query (including the variables)
25
- * This is done automatically, you just need to provide the query and the variables.
26
- *
27
- * @param apiKey - APIKey of the app where the query will be executed.
28
- * @param query - GraphQL query to execute.
29
- * @param token - Partners token
30
- * @param variables - GraphQL variables to pass to the query.
31
- * @returns The response of the query.
32
- */
33
- export async function functionProxyRequest(apiKey, query, token, variables) {
34
- const proxyVariables = {
35
- api_key: apiKey,
36
- query,
37
- variables: JSON.stringify(variables) || '{}',
38
- };
39
- const proxyQuery = ScriptServiceProxyQuery;
40
- const res = await request(proxyQuery, token, proxyVariables);
41
- const json = JSON.parse(res.scriptServiceProxy);
42
- return json;
43
- }
44
- //# sourceMappingURL=partners.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAElC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAEtC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAE,SAAqB;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;QACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kBAAkB,CAAA;QAC7C,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;QACzC,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC,CAAA;QAClD,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAA;QAC1D,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,KAAK,CAAC,cAAc,GAAG,CAAC,QAAQ,EAAE,iBAAiB,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;QAC5E,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC;AAMD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,KAAc,EACd,KAAa,EACb,SAAmB;IAEnB,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,MAAM;QACf,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {debug} from '../output.js'\nimport {Variables, RequestDocument} from 'graphql-request'\nimport {performance} from 'perf_hooks'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({headers, url})\n const t0 = performance.now()\n const response = await client.request<T>(query, variables)\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`)\n return response\n })\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey - APIKey of the app where the query will be executed.\n * @param query - GraphQL query to execute.\n * @param token - Partners token\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
@@ -1,13 +0,0 @@
1
- import { GraphQLClient } from 'graphql-request';
2
- interface GraphqlClientOptions {
3
- url: string;
4
- headers: {
5
- [key: string]: string;
6
- };
7
- }
8
- /**
9
- * Creates a GraphQLClient instance with the right HTTPs agent baed on the service
10
- * the client will interact with.
11
- */
12
- export declare function graphqlClient(options: GraphqlClientOptions): Promise<GraphQLClient>;
13
- export {};
@@ -1,12 +0,0 @@
1
- import { httpsAgent } from '../http.js';
2
- import { GraphQLClient } from 'graphql-request';
3
- /**
4
- * Creates a GraphQLClient instance with the right HTTPs agent baed on the service
5
- * the client will interact with.
6
- */
7
- export async function graphqlClient(options) {
8
- const clientOptions = { agent: await httpsAgent(), headers: options.headers };
9
- const client = new GraphQLClient(options.url, clientOptions);
10
- return client;
11
- }
12
- //# sourceMappingURL=graphql.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/http/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAO7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,MAAM,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAA;IAC3E,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {httpsAgent} from '../http.js'\nimport {GraphQLClient} from 'graphql-request'\n\ninterface GraphqlClientOptions {\n url: string\n headers: {[key: string]: string}\n}\n\n/**\n * Creates a GraphQLClient instance with the right HTTPs agent baed on the service\n * the client will interact with.\n */\nexport async function graphqlClient(options: GraphqlClientOptions) {\n const clientOptions = {agent: await httpsAgent(), headers: options.headers}\n const client = new GraphQLClient(options.url, clientOptions)\n return client\n}\n"]}
package/dist/id.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Generates and returns a random UUID.
3
- * @returns The random UUID generated.
4
- */
5
- export declare const generateRandomUUID: () => string;
6
- export declare const generateShortId: () => string;
package/dist/id.js DELETED
@@ -1,18 +0,0 @@
1
- import { randomUUID } from 'crypto';
2
- /**
3
- * Generates and returns a random UUID.
4
- * @returns The random UUID generated.
5
- */
6
- export const generateRandomUUID = () => {
7
- return randomUUID();
8
- };
9
- export const generateShortId = () => {
10
- let result = '';
11
- const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
12
- const charactersLength = characters.length;
13
- for (let i = 0; i < 7; i++) {
14
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
15
- }
16
- return result;
17
- };
18
- //# sourceMappingURL=id.js.map
package/dist/id.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"id.js","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAW,EAAE;IAC7C,OAAO,UAAU,EAAE,CAAA;AACrB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,GAAW,EAAE;IAC1C,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,MAAM,UAAU,GAAG,sCAAsC,CAAA;IACzD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAA;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAA;KAC1E;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import {randomUUID} from 'crypto'\n\n/**\n * Generates and returns a random UUID.\n * @returns The random UUID generated.\n */\nexport const generateRandomUUID = (): string => {\n return randomUUID()\n}\n\nexport const generateShortId = (): string => {\n let result = ''\n const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'\n const charactersLength = characters.length\n for (let i = 0; i < 7; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength))\n }\n return result\n}\n"]}
package/dist/json.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"","sourcesContent":["export interface JsonMap {\n [key: string]: AnyJson\n}\ntype JsonArray = undefined[] | null[] | boolean[] | number[] | string[] | JsonMap[] | Date[]\nexport type AnyJson = undefined | null | boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]\n"]}
package/dist/os.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { platform as processPlatform } from 'node:process';
2
- export declare const username: (platform?: typeof processPlatform) => Promise<string | null>;
3
- /**
4
- * Returns the platform and architecture.
5
- * @returns Returns the current platform and architecture.
6
- */
7
- export declare const platformAndArch: (platform?: typeof processPlatform) => {
8
- platform: string;
9
- arch: string;
10
- };
package/dist/os.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"os.js","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAC,QAAQ,IAAI,eAAe,EAAC,MAAM,cAAc,CAAA;AACxD,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAC,MAAM,SAAS,CAAA;AAE9D,MAAM,sBAAsB,GAAG,GAAG,EAAE;IAClC,MAAM,EAAC,GAAG,EAAC,GAAG,OAAO,CAAA;IAErB,OAAO,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAA;AAC7F,CAAC,CAAA;AAED,MAAM,yBAAyB,GAAG,GAAkB,EAAE;IACpD,IAAI;QACF,OAAO,UAAU,EAAE,CAAC,QAAQ,CAAA;QAC5B,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AAEzE,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,eAAe,MA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AAI,GAAG,KAAK,CAAA;KACb;IACD,IAAI,cAAc,GAAG,QAAkB,CAAA;IACvC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC5B,cAAc,GAAG,SAAS,CAAA;KAC3B;IACD,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAC,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import {debug, content} from './output.js'\nimport {execa} from 'execa'\nimport {platform as processPlatform} from 'node:process'\nimport {userInfo as osUserInfo, arch as osArch} from 'node:os'\n\nconst getEnvironmentVariable = () => {\n const {env} = process\n\n return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME\n}\n\nconst getUsernameFromOsUserInfo = (): string | null => {\n try {\n return osUserInfo().username\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\nconst cleanWindowsCommand = (value: string) => value.replace(/^.*\\\\/, '')\n\nconst makeUsernameFromId = (userId: string) => `no-username-${userId}`\n\n// This code has been vendored from https://github.com/sindresorhus/username\n// because adding it as a transtive dependency causes conflicts with other\n// packages that haven't been yet migrated to the latest version.\nexport const username = async (platform: typeof processPlatform = processPlatform): Promise<string | null> => {\n debug(content`Obtaining user name...`)\n const environmentVariable = getEnvironmentVariable()\n if (environmentVariable) {\n return environmentVariable\n }\n\n const userInfoUsername = getUsernameFromOsUserInfo()\n if (userInfoUsername) {\n return userInfoUsername\n }\n\n /**\n\tFirst we try to get the ID of the user and then the actual username. We do this because in `docker run --user <uid>:<gid>` context, we don't have \"username\" available. Therefore, we have a fallback to `makeUsernameFromId` for such scenario. Applies also to the `sync()` method below.\n\t*/\n try {\n if (platform === 'win32') {\n const {stdout} = await execa('whoami')\n return cleanWindowsCommand(stdout)\n }\n\n const {stdout: userId} = await execa('id', ['-u'])\n try {\n const {stdout} = await execa('id', ['-un', userId])\n return stdout\n\n // eslint-disable-next-line no-catch-all/no-catch-all,no-empty\n } catch {}\n return makeUsernameFromId(userId)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\n/**\n * Returns the platform and architecture.\n * @returns Returns the current platform and architecture.\n */\nexport const platformAndArch = (\n platform: typeof processPlatform = processPlatform,\n): {platform: string; arch: string} => {\n let arch = osArch()\n if (arch === 'x64') {\n arch = 'amd64'\n }\n if (arch === 'ia32') {\n arch = '386'\n }\n let platformString = platform as string\n if (platform.match(/^win.+/)) {\n platformString = 'windows'\n }\n return {platform: platformString, arch}\n}\n"]}
@@ -1,23 +0,0 @@
1
- import SelectInput from './SelectInput.js';
2
- import Table from './Table.js';
3
- import React, { useState } from 'react';
4
- import { Box, Text } from 'ink';
5
- import { figures } from 'listr2';
6
- export default function Prompt({ message, choices, infoTable, onChoose, }) {
7
- const [answer, setAnswer] = useState(null);
8
- return (React.createElement(Box, { flexDirection: "column", marginBottom: 1 },
9
- React.createElement(Box, null,
10
- React.createElement(Box, { marginRight: 2 },
11
- React.createElement(Text, null, "?")),
12
- React.createElement(Text, null, message)),
13
- infoTable && !answer && (React.createElement(Box, { marginLeft: 7 },
14
- React.createElement(Table, { table: infoTable }))),
15
- answer ? (React.createElement(Box, null,
16
- React.createElement(Box, { marginRight: 2 },
17
- React.createElement(Text, { color: "cyan" }, figures.tick)),
18
- React.createElement(Text, { color: "cyan" }, answer.label))) : (React.createElement(SelectInput, { items: choices, onSelect: (value) => {
19
- setAnswer(choices.find((choice) => choice.value === value) ?? null);
20
- onChoose(value);
21
- } }))));
22
- }
23
- //# sourceMappingURL=Prompt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Prompt.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAuD,MAAM,kBAAkB,CAAA;AACtF,OAAO,KAA4B,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAA;AACrC,OAAO,EAAC,GAAG,EAAE,IAAI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ectInput.js'\nimport Table, {Props as TableProps} from './Table.js'\nimport React, {useState} from 'react'\nimport {Box, Text} from 'ink'\nimport {figures} from 'listr2'\n\nexport interface Props<T> {\n message: string\n choices: SelectProps<T>['items']\n onChoose: SelectProps<T>['onSelect']\n infoTable?: TableProps['table']\n}\n\nexport default function Prompt<T>({\n message,\n choices,\n infoTable,\n onChoose,\n}: React.PropsWithChildren<Props<T>>): JSX.Element | null {\n const [answer, setAnswer] = useState<SelectItem<T> | null>(null)\n\n return (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Box marginRight={2}>\n <Text>?</Text>\n </Box>\n <Text>{message}</Text>\n </Box>\n {infoTable && !answer && (\n <Box marginLeft={7}>\n <Table table={infoTable} />\n </Box>\n )}\n {answer ? (\n <Box>\n <Box marginRight={2}>\n <Text color=\"cyan\">{figures.tick}</Text>\n </Box>\n\n <Text color=\"cyan\">{answer.label}</Text>\n </Box>\n ) : (\n <SelectInput\n items={choices}\n onSelect={(value: T) => {\n setAnswer(choices.find((choice) => choice.value === value) ?? null)\n onChoose(value)\n }}\n />\n )}\n </Box>\n )\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Prompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Prompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,SAAS,EAAE,sBAAsB,EAAC,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AACjD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAE1C,MAAM,UAAU,GAAG,UAAU,CAAA;AAC7B,MAAM,KAAK,GAAG,IAAI,CAAA;AAElB,QAAQ,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;IAC5B,IAAI,CAAC,kBAAkB,E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K,EAAE,OAAO,EAAC;YAChC,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAC;YAClC,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAC;YACtD,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAC;YACtD,EAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAC;YACpC,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAC;YAC3D,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAC;YACzD,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAC;SACjC,CAAA;QAED,MAAM,SAAS,GAAG;YAChB,GAAG,EAAE,CAAC,SAAS,CAAC;YAChB,MAAM,EAAE,CAAC,uBAAuB,EAAE,gBAAgB,CAAC;SACpD,CAAA;QAED,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,MAAM,IACL,OAAO,EAAC,uDAAuD,EAC/D,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,GAClB,CACH,CAAA;QAED,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;KAwBxD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import Prompt from './Prompt.js'\nimport {sendInput, waitForInputsToBeReady} from '../../../../testing/ui.js'\nimport {describe, expect, test, vi} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\nconst ARROW_DOWN = '\\u001B[B'\nconst ENTER = '\\r'\n\ndescribe('Prompt', async () => {\n test('choose an answer', async () => {\n const onEnter = vi.fn()\n\n const items = [\n {label: 'first', value: 'first'},\n {label: 'second', value: 'second'},\n {label: 'third', value: 'third'},\n ]\n\n const infoTable = {Add: ['new-ext'], Remove: ['integrated-demand-ext', 'order-discount']}\n\n const renderInstance = render(\n <Prompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n infoTable={infoTable}\n onChoose={onEnter}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInput(renderInstance, ARROW_DOWN)\n await sendInput(renderInstance, ENTER)\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n \u001b[36m✔\u001b[39m \u001b[36msecond\u001b[39m\n \"\n `)\n expect(onEnter).toHaveBeenCalledWith(items[1]!.value)\n })\n\n test('supports an info table', async () => {\n const items = [\n {label: 'first', value: 'first', key: 'f'},\n {label: 'second', value: 'second', key: 's'},\n {label: 'third', value: 'third'},\n {label: 'fourth', value: 'fourth'},\n {label: 'fifth', value: 'fifth', group: 'Automations'},\n {label: 'sixth', value: 'sixth', group: 'Automations'},\n {label: 'seventh', value: 'seventh'},\n {label: 'eighth', value: 'eighth', group: 'Merchant Admin'},\n {label: 'ninth', value: 'ninth', group: 'Merchant Admin'},\n {label: 'tenth', value: 'tenth'},\n ]\n\n const infoTable = {\n Add: ['new-ext'],\n Remove: ['integrated-demand-ext', 'order-discount'],\n }\n\n const renderInstance = render(\n <Prompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n infoTable={infoTable}\n onChoose={() => {}}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n Add: • new-ext\n Remove: • integrated-demand-ext\n • order-discount\n\n \u001b[36m>\u001b[39m \u001b[36m(f) first\u001b[39m\n (s) second\n (3) third\n (4) fourth\n (5) seventh\n (6) tenth\n\n \u001b[1mAutomations\u001b[22m\n (7) fifth\n (8) sixth\n\n \u001b[1mMerchant Admin\u001b[22m\n (9) eighth\n (10) ninth\n\n \u001b[2mnavigate with arrows, enter to select\u001b[22m\n \"\n `)\n })\n})\n"]}
package/dist/string.d.ts DELETED
@@ -1,28 +0,0 @@
1
- export { camelCase as camelize } from 'change-case';
2
- export { paramCase as hyphenize } from 'change-case';
3
- export { snakeCase as underscore } from 'change-case';
4
- export { constantCase as constantize } from 'change-case';
5
- /** Returns a random string */
6
- export declare function randomHex(size: number): string;
7
- export declare function generateRandomChallengePair(): {
8
- codeVerifier: string;
9
- codeChallenge: string;
10
- };
11
- export declare function hashString(str: string): string;
12
- /**
13
- * Given a string, it returns it with the first letter capitalized.
14
- * @param string - String whose first letter will be caplitalized.
15
- * @returns The given string with its first letter capitalized.
16
- */
17
- export declare function capitalize(string: string): string;
18
- /**
19
- * Try to convert a string to an int, falling back to undefined if unable to
20
- */
21
- export declare function tryParseInt(maybeInt: string | undefined): number | undefined;
22
- /**
23
- * Given a series of rows inside an array, where each row is an array of strings (representing columns)
24
- * Parse it into a single string with the columns aligned
25
- */
26
- export declare function linesToColumns(lines: string[][]): string;
27
- export declare const slugify: (str: string) => string;
28
- export declare const escapeRegExp: (str: string) => string;
package/dist/string.js DELETED
@@ -1,77 +0,0 @@
1
- import { unstyled } from './output.js';
2
- import crypto from 'crypto';
3
- export { camelCase as camelize } from 'change-case';
4
- export { paramCase as hyphenize } from 'change-case';
5
- export { snakeCase as underscore } from 'change-case';
6
- export { constantCase as constantize } from 'change-case';
7
- /** Returns a random string */
8
- export function randomHex(size) {
9
- return crypto.randomBytes(size).toString('hex');
10
- }
11
- export function generateRandomChallengePair() {
12
- const codeVerifier = base64URLEncode(crypto.randomBytes(32));
13
- const codeChallenge = base64URLEncode(sha256(codeVerifier));
14
- return { codeVerifier, codeChallenge };
15
- }
16
- function base64URLEncode(str) {
17
- return str.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/[=]/g, '');
18
- }
19
- function sha256(str) {
20
- return crypto.createHash('sha256').update(str).digest();
21
- }
22
- export function hashString(str) {
23
- return crypto.createHash('sha1').update(str).digest('hex');
24
- }
25
- /**
26
- * Given a string, it returns it with the first letter capitalized.
27
- * @param string - String whose first letter will be caplitalized.
28
- * @returns The given string with its first letter capitalized.
29
- */
30
- export function capitalize(string) {
31
- return string.substring(0, 1).toUpperCase() + string.substring(1);
32
- }
33
- /**
34
- * Try to convert a string to an int, falling back to undefined if unable to
35
- */
36
- export function tryParseInt(maybeInt) {
37
- let asInt;
38
- if (maybeInt !== undefined) {
39
- asInt = parseInt(maybeInt, 10);
40
- if (isNaN(asInt)) {
41
- asInt = undefined;
42
- }
43
- }
44
- return asInt;
45
- }
46
- /**
47
- * Given a series of rows inside an array, where each row is an array of strings (representing columns)
48
- * Parse it into a single string with the columns aligned
49
- */
50
- export function linesToColumns(lines) {
51
- const widths = [];
52
- for (let i = 0; lines[0] && i < lines[0].length; i++) {
53
- const columnRows = lines.map((line) => line[i]);
54
- widths.push(Math.max(...columnRows.map((row) => unstyled(row).length)));
55
- }
56
- const paddedLines = lines
57
- .map((line) => {
58
- return line
59
- .map((col, index) => {
60
- return `${col}${' '.repeat(widths[index] - unstyled(col).length)}`;
61
- })
62
- .join(' ')
63
- .trimEnd();
64
- })
65
- .join('\n');
66
- return paddedLines;
67
- }
68
- export const slugify = (str) => str
69
- .toLowerCase()
70
- .trim()
71
- .replace(/[^\w\s-]/g, '')
72
- .replace(/[\s_-]+/g, '-')
73
- .replace(/^-+|-+$/g, '');
74
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
75
- // $& means the whole matched string
76
- export const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
77
- //# sourceMappingURL=string.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AACpC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3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AC,CAAC;aACD,IAAI,CAAC,KAAK,CAAC;aACX,OAAO,EAAE,CAAA;IACd,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CACrC,GAAG;KACA,WAAW,EAAE;KACb,IAAI,EAAE;KACN,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;KACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;KACxB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;AAE5B,6FAA6F;AAC7F,oCAAoC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA","sourcesContent":["import {unstyled} from './output.js'\nimport crypto from 'crypto'\n\nexport {camelCase as camelize} from 'change-case'\nexport {paramCase as hyphenize} from 'change-case'\nexport {snakeCase as underscore} from 'change-case'\nexport {constantCase as constantize} from 'change-case'\n\n/** Returns a random string */\nexport function randomHex(size: number): string {\n return crypto.randomBytes(size).toString('hex')\n}\n\nexport function generateRandomChallengePair() {\n const codeVerifier = base64URLEncode(crypto.randomBytes(32))\n const codeChallenge = base64URLEncode(sha256(codeVerifier))\n return {codeVerifier, codeChallenge}\n}\n\nfunction base64URLEncode(str: Buffer) {\n return str.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/[=]/g, '')\n}\n\nfunction sha256(str: string) {\n return crypto.createHash('sha256').update(str).digest()\n}\n\nexport function hashString(str: string): string {\n return crypto.createHash('sha1').update(str).digest('hex')\n}\n\n/**\n * Given a string, it returns it with the first letter capitalized.\n * @param string - String whose first letter will be caplitalized.\n * @returns The given string with its first letter capitalized.\n */\nexport function capitalize(string: string) {\n return string.substring(0, 1).toUpperCase() + string.substring(1)\n}\n\n/**\n * Try to convert a string to an int, falling back to undefined if unable to\n */\nexport function tryParseInt(maybeInt: string | undefined) {\n let asInt: number | undefined\n if (maybeInt !== undefined) {\n asInt = parseInt(maybeInt, 10)\n if (isNaN(asInt)) {\n asInt = undefined\n }\n }\n return asInt\n}\n\n/**\n * Given a series of rows inside an array, where each row is an array of strings (representing columns)\n * Parse it into a single string with the columns aligned\n */\nexport function linesToColumns(lines: string[][]): string {\n const widths: number[] = []\n for (let i = 0; lines[0] && i < lines[0].length; i++) {\n const columnRows = lines.map((line) => line[i]!)\n widths.push(Math.max(...columnRows.map((row) => unstyled(row).length)))\n }\n const paddedLines = lines\n .map((line) => {\n return line\n .map((col, index) => {\n return `${col}${' '.repeat(widths[index]! - unstyled(col).length)}`\n })\n .join(' ')\n .trimEnd()\n })\n .join('\\n')\n return paddedLines\n}\n\nexport const slugify = (str: string) =>\n str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\n// $& means the whole matched string\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACvD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,wBAAwB,EAAC,MAAM,WAAW,CAAA;AAChG,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAE/B,yDAAyD;AACzD,MAAM,UAAU,MAAM,CAAC,eAAuB;IAC5C,OAAO,C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AAE;YACvC,MAAM,KAAK,CAAC,UAAU,CAAC,CAAA;SACxB;aAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAC/C,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;YAChC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,CAAA;YAC5C,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAA;YACjD,MAAM,YAAY,GAAG,MAAM,wBAAwB,CAAC,gBAAgB,CAAC,CAAA;YACrE,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACjE,MAAM,IAAI,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;YACrD,MAAM,KAAK,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAA;YACnD,IAAI,YAAY,EAAE;gBAChB,MAAM,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;aAC5C;SACF;aAAM;YACL,MAAM,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;SACzC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC","sourcesContent":["import {glob, join, dirname, relative} from './path.js'\nimport {mkdir, read, copy, chmod, isDirectory, write, hasExecutablePermissions} from './file.js'\nimport {content, token, debug} from './output.js'\nimport {Liquid} from 'liquidjs'\n\n// This line is necessary to register additional helpers.\nexport function create(templateContent: string) {\n return (data: object): Promise<string> => {\n const engine = new Liquid()\n return engine.render(engine.parse(templateContent), data)\n }\n}\n\n/**\n * Given a directory, it traverses the files and directories recursively\n * and replaces variables in directory and file names, and files' content\n * using the Liquid template engine.\n * Files indicate that they are liquid template by using the .liquid extension.\n * @param from - Directory that contains the template.\n * @param to - Output directory.\n * @param data - Data to feed the template engine.\n */\nexport async function recursiveDirectoryCopy(from: string, to: string, data: object) {\n debug(content`Copying template from directory ${token.path(from)} to ${token.path(to)}`)\n const templateFiles: string[] = await glob(join(from, '**/*'), {dot: true})\n\n const sortedTemplateFiles = templateFiles\n .map((path) => path.split('/'))\n .sort((lhs, rhs) => (lhs.length < rhs.length ? 1 : -1))\n .map((components) => components.join('/'))\n await Promise.all(\n sortedTemplateFiles.map(async (templateItemPath) => {\n const outputPath = await create(join(to, relative(from, templateItemPath)))(data)\n if (await isDirectory(templateItemPath)) {\n await mkdir(outputPath)\n } else if (templateItemPath.endsWith('.liquid')) {\n await mkdir(dirname(outputPath))\n const content = await read(templateItemPath)\n const contentOutput = await create(content)(data)\n const isExecutable = await hasExecutablePermissions(templateItemPath)\n const outputPathWithoutLiquid = outputPath.replace('.liquid', '')\n await copy(templateItemPath, outputPathWithoutLiquid)\n await write(outputPathWithoutLiquid, contentOutput)\n if (isExecutable) {\n await chmod(outputPathWithoutLiquid, 0o755)\n }\n } else {\n await copy(templateItemPath, outputPath)\n }\n }),\n )\n}\n"]}
package/dist/toml.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import * as toml from '@iarna/toml';
2
- export declare function decode(input: string): object;
3
- export declare function encode(content: toml.JsonMap): string;
package/dist/toml.js DELETED
@@ -1,8 +0,0 @@
1
- import * as toml from '@iarna/toml';
2
- export function decode(input) {
3
- return toml.parse(input);
4
- }
5
- export function encode(content) {
6
- return toml.stringify(content);
7
- }
8
- //# sourceMappingURL=toml.js.map
package/dist/toml.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"toml.js","sourceRoot":"","sources":["../src/toml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAqB;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import * as toml from '@iarna/toml'\n\nexport function decode(input: string): object {\n return toml.parse(input)\n}\n\nexport function encode(content: toml.JsonMap): string {\n return toml.stringify(content)\n}\n"]}
package/dist/vscode.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if user editor is VS Code
3
- */
4
- export declare const isVSCode: (root?: string) => Promise<boolean>;
5
- /**
6
- * Add VSCode extension recommendations
7
- */
8
- export declare function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../src/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;IACrD,KAAK,CAAC,OAAO,CAAA,6BAA6B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IAC/G,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,CAAA;IAEvE,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAA;KACb;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAiB,EAAE,eAAyB;IACzF,KAAK,CAAC,OAAO,CAAA,2CAA2C,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;EAC7E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;GAC1B,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;IAEjE,IAAI,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,sBAAsB,GAAG,EAAC,eAAe,EAAE,EAAE,EAAC,CAAA;QAClD,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,EAAE;YAChC,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,CAAA;YACzD,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;SAC5D;QACD,MAAM,iBAAiB,GAAG;YACxB,GAAG,sBAAsB;YACzB,eAAe,EAAE,CAAC,GAAG,sBAAsB,CAAC,eAAe,EAAE,GAAG,eAAe,CAAC;SACjF,CAAA;QACD,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;KACxE;AACH,CAAC","sourcesContent":["import {exists, write, read} from './file.js'\nimport {findUp, join} from './path.js'\nimport {content, token, debug} from './output.js'\n\n/**\n * Check if user editor is VS Code\n */\nexport const isVSCode = async (root = process.cwd()) => {\n debug(content`Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `)\n const config = await findUp(join(root, '.vscode'), {type: 'directory'})\n\n if (!config) {\n return false\n }\n\n return exists(config)\n}\n\n/**\n * Add VSCode extension recommendations\n */\nexport async function addRecommendedExtensions(directory: string, recommendations: string[]) {\n debug(content`Adding VSCode recommended extensions at ${token.path(directory)}:\n${token.json(recommendations)}\n `)\n const extensionsPath = join(directory, '.vscode/extensions.json')\n\n if (await isVSCode(directory)) {\n let originalExtensionsJson = {recommendations: []}\n if (await exists(extensionsPath)) {\n const originalExtensionsFile = await read(extensionsPath)\n originalExtensionsJson = JSON.parse(originalExtensionsFile)\n }\n const newExtensionsJson = {\n ...originalExtensionsJson,\n recommendations: [...originalExtensionsJson.recommendations, ...recommendations],\n }\n await write(extensionsPath, JSON.stringify(newExtensionsJson, null, 2))\n }\n}\n"]}