@shopify/cli-kit 3.33.0 → 3.35.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 (212) hide show
  1. package/dist/git.js +3 -3
  2. package/dist/git.js.map +1 -1
  3. package/dist/http/fetch.js +1 -1
  4. package/dist/http/fetch.js.map +1 -1
  5. package/dist/http.js +2 -2
  6. package/dist/http.js.map +1 -1
  7. package/dist/index.d.ts +0 -7
  8. package/dist/index.js +0 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/metadata.js +1 -1
  11. package/dist/metadata.js.map +1 -1
  12. package/dist/npm.js +3 -3
  13. package/dist/npm.js.map +1 -1
  14. package/dist/output.js +4 -4
  15. package/dist/output.js.map +1 -1
  16. package/dist/path.d.ts +1 -1
  17. package/dist/path.js +5 -3
  18. package/dist/path.js.map +1 -1
  19. package/dist/private/node/analytics.js +6 -9
  20. package/dist/private/node/analytics.js.map +1 -1
  21. package/dist/private/node/api/graphql.js +2 -1
  22. package/dist/private/node/api/graphql.js.map +1 -1
  23. package/dist/private/node/api/headers.d.ts +2 -2
  24. package/dist/private/node/api/headers.js +4 -4
  25. package/dist/private/node/api/headers.js.map +1 -1
  26. package/dist/private/node/api/rest.d.ts +6 -4
  27. package/dist/private/node/api/rest.js +8 -7
  28. package/dist/private/node/api/rest.js.map +1 -1
  29. package/dist/private/node/constants.d.ts +42 -0
  30. package/dist/private/node/constants.js +58 -0
  31. package/dist/private/node/constants.js.map +1 -0
  32. package/dist/private/node/environment/service.d.ts +18 -0
  33. package/dist/private/node/environment/service.js +32 -0
  34. package/dist/private/node/environment/service.js.map +1 -0
  35. package/dist/{environment → private/node/environment}/spin-cache.d.ts +0 -0
  36. package/dist/{environment → private/node/environment}/spin-cache.js +0 -0
  37. package/dist/private/node/environment/spin-cache.js.map +1 -0
  38. package/dist/{environment → private/node/environment}/utilities.d.ts +0 -0
  39. package/dist/{environment → private/node/environment}/utilities.js +0 -0
  40. package/dist/private/node/environment/utilities.js.map +1 -0
  41. package/dist/{session → private/node/session}/authorize.d.ts +1 -5
  42. package/dist/{session → private/node/session}/authorize.js +9 -9
  43. package/dist/private/node/session/authorize.js.map +1 -0
  44. package/dist/{session → private/node/session}/device-authorization.d.ts +0 -0
  45. package/dist/{session → private/node/session}/device-authorization.js +7 -9
  46. package/dist/private/node/session/device-authorization.js.map +1 -0
  47. package/dist/{session → private/node/session}/exchange.d.ts +2 -2
  48. package/dist/{session → private/node/session}/exchange.js +5 -5
  49. package/dist/private/node/session/exchange.js.map +1 -0
  50. package/dist/{session → private/node/session}/identity-token-validation.d.ts +0 -0
  51. package/dist/{session → private/node/session}/identity-token-validation.js +4 -4
  52. package/dist/private/node/session/identity-token-validation.js.map +1 -0
  53. package/dist/{session → private/node/session}/identity.d.ts +1 -1
  54. package/dist/{session → private/node/session}/identity.js +2 -3
  55. package/dist/private/node/session/identity.js.map +1 -0
  56. package/dist/{session → private/node/session}/post-auth.d.ts +1 -1
  57. package/dist/{session → private/node/session}/post-auth.js +10 -10
  58. package/dist/private/node/session/post-auth.js.map +1 -0
  59. package/dist/{session → private/node/session}/redirect-listener.d.ts +0 -0
  60. package/dist/{session → private/node/session}/redirect-listener.js +2 -2
  61. package/dist/private/node/session/redirect-listener.js.map +1 -0
  62. package/dist/{session → private/node/session}/schema.d.ts +1 -1
  63. package/dist/{session → private/node/session}/schema.js +1 -1
  64. package/dist/private/node/session/schema.js.map +1 -0
  65. package/dist/{session → private/node/session}/scopes.d.ts +1 -1
  66. package/dist/{session → private/node/session}/scopes.js +2 -2
  67. package/dist/private/node/session/scopes.js.map +1 -0
  68. package/dist/{session → private/node/session}/store.d.ts +0 -0
  69. package/dist/{session → private/node/session}/store.js +10 -10
  70. package/dist/private/node/session/store.js.map +1 -0
  71. package/dist/{session → private/node/session}/validate.d.ts +0 -0
  72. package/dist/{session → private/node/session}/validate.js +4 -4
  73. package/dist/private/node/session/validate.js.map +1 -0
  74. package/dist/private/node/session.d.ts +56 -0
  75. package/dist/{session.js → private/node/session.js} +98 -134
  76. package/dist/private/node/session.js.map +1 -0
  77. package/dist/private/node/ui/components/SelectPrompt.d.ts +2 -1
  78. package/dist/private/node/ui/components/SelectPrompt.js +2 -1
  79. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  80. package/dist/private/node/ui/components/Table/Column.d.ts +5 -0
  81. package/dist/private/node/ui/components/Table/Column.js +2 -0
  82. package/dist/private/node/ui/components/Table/Column.js.map +1 -0
  83. package/dist/private/node/ui/components/Table/Row.d.ts +12 -0
  84. package/dist/private/node/ui/components/Table/Row.js +24 -0
  85. package/dist/private/node/ui/components/Table/Row.js.map +1 -0
  86. package/dist/private/node/ui/components/Table/ScalarDict.d.ts +5 -0
  87. package/dist/private/node/ui/components/Table/ScalarDict.js +2 -0
  88. package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -0
  89. package/dist/private/node/ui/components/Table/Table.d.ts +12 -0
  90. package/dist/private/node/ui/components/Table/Table.js +30 -0
  91. package/dist/private/node/ui/components/Table/Table.js.map +1 -0
  92. package/dist/private/node/ui/components/Table/Table.test.d.ts +1 -0
  93. package/dist/private/node/ui/components/Table/Table.test.js +41 -0
  94. package/dist/private/node/ui/components/Table/Table.test.js.map +1 -0
  95. package/dist/private/node/ui.js +1 -1
  96. package/dist/private/node/ui.js.map +1 -1
  97. package/dist/public/common/string.d.ts +11 -0
  98. package/dist/public/common/string.js +21 -0
  99. package/dist/public/common/string.js.map +1 -1
  100. package/dist/public/common/version.d.ts +1 -0
  101. package/dist/public/common/version.js +2 -0
  102. package/dist/public/common/version.js.map +1 -0
  103. package/dist/public/node/analytics.js +5 -5
  104. package/dist/public/node/analytics.js.map +1 -1
  105. package/dist/public/node/api/admin.d.ts +5 -2
  106. package/dist/public/node/api/admin.js +4 -3
  107. package/dist/public/node/api/admin.js.map +1 -1
  108. package/dist/public/node/api/partners.js +1 -1
  109. package/dist/public/node/api/partners.js.map +1 -1
  110. package/dist/public/node/base-command.js +2 -2
  111. package/dist/public/node/base-command.js.map +1 -1
  112. package/dist/public/node/cli.d.ts +8 -0
  113. package/dist/public/node/cli.js +25 -8
  114. package/dist/public/node/cli.js.map +1 -1
  115. package/dist/public/node/dot-env.js +2 -2
  116. package/dist/public/node/dot-env.js.map +1 -1
  117. package/dist/public/node/environment/fqdn.d.ts +26 -0
  118. package/dist/{environment → public/node/environment}/fqdn.js +15 -31
  119. package/dist/public/node/environment/fqdn.js.map +1 -0
  120. package/dist/{environment → public/node/environment}/local.d.ts +62 -15
  121. package/dist/{environment → public/node/environment}/local.js +81 -36
  122. package/dist/public/node/environment/local.js.map +1 -0
  123. package/dist/public/node/environment/spin.d.ts +43 -0
  124. package/dist/{environment → public/node/environment}/spin.js +31 -38
  125. package/dist/public/node/environment/spin.js.map +1 -0
  126. package/dist/public/node/error-handler.js +6 -5
  127. package/dist/public/node/error-handler.js.map +1 -1
  128. package/dist/public/node/fs.d.ts +222 -3
  129. package/dist/public/node/fs.js +338 -2
  130. package/dist/public/node/fs.js.map +1 -1
  131. package/dist/public/node/git.d.ts +90 -0
  132. package/dist/public/node/git.js +174 -0
  133. package/dist/public/node/git.js.map +1 -0
  134. package/dist/public/node/liquid.js +6 -6
  135. package/dist/public/node/liquid.js.map +1 -1
  136. package/dist/public/node/node-package-manager.d.ts +0 -10
  137. package/dist/public/node/node-package-manager.js +3 -20
  138. package/dist/public/node/node-package-manager.js.map +1 -1
  139. package/dist/public/node/presets.js +2 -2
  140. package/dist/public/node/presets.js.map +1 -1
  141. package/dist/public/node/ruby.d.ts +1 -1
  142. package/dist/public/node/ruby.js +19 -20
  143. package/dist/public/node/ruby.js.map +1 -1
  144. package/dist/public/node/session.d.ts +53 -0
  145. package/dist/public/node/session.js +95 -0
  146. package/dist/public/node/session.js.map +1 -0
  147. package/dist/public/node/system.d.ts +44 -0
  148. package/dist/{system.js → public/node/system.js} +34 -54
  149. package/dist/public/node/system.js.map +1 -0
  150. package/dist/public/node/tcp.js +1 -1
  151. package/dist/public/node/tcp.js.map +1 -1
  152. package/dist/public/node/ui.d.ts +13 -0
  153. package/dist/public/node/ui.js +14 -0
  154. package/dist/public/node/ui.js.map +1 -1
  155. package/dist/public/node/vscode.js +5 -5
  156. package/dist/public/node/vscode.js.map +1 -1
  157. package/dist/secure-store.js +4 -4
  158. package/dist/secure-store.js.map +1 -1
  159. package/dist/store.d.ts +10 -10
  160. package/dist/store.js +21 -22
  161. package/dist/store.js.map +1 -1
  162. package/dist/testing/store.js +3 -3
  163. package/dist/testing/store.js.map +1 -1
  164. package/dist/testing/ui.js +1 -1
  165. package/dist/testing/ui.js.map +1 -1
  166. package/dist/tsconfig.tsbuildinfo +1 -1
  167. package/dist/ui.js +4 -4
  168. package/dist/ui.js.map +1 -1
  169. package/package.json +10 -7
  170. package/dist/cli.d.ts +0 -8
  171. package/dist/cli.js +0 -18
  172. package/dist/cli.js.map +0 -1
  173. package/dist/constants.d.ts +0 -51
  174. package/dist/constants.js +0 -70
  175. package/dist/constants.js.map +0 -1
  176. package/dist/environment/fqdn.d.ts +0 -29
  177. package/dist/environment/fqdn.js.map +0 -1
  178. package/dist/environment/local.js.map +0 -1
  179. package/dist/environment/service.d.ts +0 -4
  180. package/dist/environment/service.js +0 -19
  181. package/dist/environment/service.js.map +0 -1
  182. package/dist/environment/spin-cache.js.map +0 -1
  183. package/dist/environment/spin.d.ts +0 -50
  184. package/dist/environment/spin.js.map +0 -1
  185. package/dist/environment/utilities.js.map +0 -1
  186. package/dist/environment.d.ts +0 -7
  187. package/dist/environment.js +0 -8
  188. package/dist/environment.js.map +0 -1
  189. package/dist/file.d.ts +0 -98
  190. package/dist/file.js +0 -216
  191. package/dist/file.js.map +0 -1
  192. package/dist/network/service.d.ts +0 -14
  193. package/dist/network/service.js +0 -11
  194. package/dist/network/service.js.map +0 -1
  195. package/dist/session/authorize.js.map +0 -1
  196. package/dist/session/device-authorization.js.map +0 -1
  197. package/dist/session/exchange.js.map +0 -1
  198. package/dist/session/identity-token-validation.js.map +0 -1
  199. package/dist/session/identity.js.map +0 -1
  200. package/dist/session/post-auth.js.map +0 -1
  201. package/dist/session/redirect-listener.js.map +0 -1
  202. package/dist/session/schema.js.map +0 -1
  203. package/dist/session/scopes.js.map +0 -1
  204. package/dist/session/store.js.map +0 -1
  205. package/dist/session/token.d.ts +0 -40
  206. package/dist/session/token.js +0 -22
  207. package/dist/session/token.js.map +0 -1
  208. package/dist/session/validate.js.map +0 -1
  209. package/dist/session.d.ts +0 -96
  210. package/dist/session.js.map +0 -1
  211. package/dist/system.d.ts +0 -51
  212. package/dist/system.js.map +0 -1
@@ -0,0 +1,95 @@
1
+ import { normalizeStoreFqdn } from './environment/fqdn.js';
2
+ import * as secureStore from '../../private/node/session/store.js';
3
+ import { exchangeCustomPartnerToken } from '../../private/node/session/exchange.js';
4
+ import { content, token, debug } from '../../output.js';
5
+ import { Bug } from '../../error.js';
6
+ import { ensureAuthenticated } from '../../private/node/session.js';
7
+ import { environmentVariables } from '../../private/node/constants.js';
8
+ /**
9
+ * Ensure that we have a valid session to access the Partners API.
10
+ * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token
11
+ * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.
12
+ *
13
+ * @param scopes - Optional array of extra scopes to authenticate with.
14
+ * @param env - Optional environment variables to use.
15
+ * @returns The access token for the Partners API.
16
+ */
17
+ export async function ensureAuthenticatedPartners(scopes = [], env = process.env) {
18
+ debug(content `Ensuring that the user is authenticated with the Partners API with the following scopes:
19
+ ${token.json(scopes)}
20
+ `);
21
+ const envToken = env[environmentVariables.partnersToken];
22
+ if (envToken) {
23
+ return (await exchangeCustomPartnerToken(envToken)).accessToken;
24
+ }
25
+ const tokens = await ensureAuthenticated({ partnersApi: { scopes } });
26
+ if (!tokens.partners) {
27
+ throw new Bug('No partners token found after ensuring authenticated');
28
+ }
29
+ return tokens.partners;
30
+ }
31
+ /**
32
+ * Ensure that we have a valid session to access the Storefront API.
33
+ *
34
+ * @param scopes - Optional array of extra scopes to authenticate with.
35
+ * @param password - Optional password to use.
36
+ * @returns The access token for the Storefront API.
37
+ */
38
+ export async function ensureAuthenticatedStorefront(scopes = [], password = undefined) {
39
+ if (password)
40
+ return password;
41
+ debug(content `Ensuring that the user is authenticated with the Storefront API with the following scopes:
42
+ ${token.json(scopes)}
43
+ `);
44
+ const tokens = await ensureAuthenticated({ storefrontRendererApi: { scopes } });
45
+ if (!tokens.storefront) {
46
+ throw new Bug('No storefront token found after ensuring authenticated');
47
+ }
48
+ return tokens.storefront;
49
+ }
50
+ /**
51
+ * Ensure that we have a valid Admin session for the given store.
52
+ *
53
+ * @param store - Store fqdn to request auth for.
54
+ * @param scopes - Optional array of extra scopes to authenticate with.
55
+ * @param forceRefresh - Optional flag to force a refresh of the token.
56
+ * @returns The access token for the Admin API.
57
+ */
58
+ export async function ensureAuthenticatedAdmin(store, scopes = [], forceRefresh = false) {
59
+ debug(content `Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${token.raw(store)}:
60
+ ${token.json(scopes)}
61
+ `);
62
+ const tokens = await ensureAuthenticated({ adminApi: { scopes, storeFqdn: store } }, process.env, forceRefresh);
63
+ if (!tokens.admin) {
64
+ throw new Bug('No admin token found after ensuring authenticated');
65
+ }
66
+ return tokens.admin;
67
+ }
68
+ /**
69
+ * Ensure that we have a valid session to access the Theme API.
70
+ * If a password is provided, that token will be used against Theme Access API.
71
+ * Otherwise, it will ensure that the user is authenticated with the Admin API.
72
+ *
73
+ * @param store - Store fqdn to request auth for.
74
+ * @param password - Password generated from Theme Access app.
75
+ * @param scopes - Optional array of extra scopes to authenticate with.
76
+ * @param forceRefresh - Optional flag to force a refresh of the token.
77
+ * @returns The access token and store.
78
+ */
79
+ export async function ensureAuthenticatedThemes(store, password, scopes = [], forceRefresh = false) {
80
+ debug(content `Ensuring that the user is authenticated with the Theme API with the following scopes:
81
+ ${token.json(scopes)}
82
+ `);
83
+ if (password)
84
+ return { token: password, storeFqdn: await normalizeStoreFqdn(store) };
85
+ return ensureAuthenticatedAdmin(store, scopes, forceRefresh);
86
+ }
87
+ /**
88
+ * Logout from Shopify.
89
+ *
90
+ * @returns A promise that resolves when the logout is complete.
91
+ */
92
+ export function logout() {
93
+ return secureStore.remove();
94
+ }
95
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/public/node/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,WAAW,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAA;AAClC,OAAO,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AAUpE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,SAAmB,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IACxF,KAAK,CAAC,OAAO,CAAA;EACb,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAA;IACA,MAAM,QAAQ,GAAG,GAAG,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAA;IACxD,IAAI,QAAQ,EAAE;QACZ,OAAO,CAAC,MAAM,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAA;KAChE;IACD,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAC,WAAW,EAAE,EAAC,MAAM,EAAC,EAAC,CAAC,CAAA;IACjE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpB,MAAM,IAAI,GAAG,CAAC,sDAAsD,CAAC,CAA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AAO,CAAA;EACb,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAA;IACA,IAAI,QAAQ;QAAE,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAAC,CAAA;IAClF,OAAO,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {normalizeStoreFqdn} from './environment/fqdn.js'\nimport * as secureStore from '../../private/node/session/store.js'\nimport {exchangeCustomPartnerToken} from '../../private/node/session/exchange.js'\nimport {content, token, debug} from '../../output.js'\nimport {Bug} from '../../error.js'\nimport {ensureAuthenticated} from '../../private/node/session.js'\nimport {environmentVariables} from '../../private/node/constants.js'\n\n/**\n * Session Object to access the Admin API, includes the token and the store FQDN.\n */\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param env - Optional environment variables to use.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(scopes: string[] = [], env = process.env): Promise<string> {\n debug(content`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${token.json(scopes)}\n`)\n const envToken = env[environmentVariables.partnersToken]\n if (envToken) {\n return (await exchangeCustomPartnerToken(envToken)).accessToken\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}})\n if (!tokens.partners) {\n throw new Bug('No partners token found after ensuring authenticated')\n }\n return tokens.partners\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param password - Optional password to use.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n): Promise<string> {\n if (password) return password\n\n debug(content`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${token.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}})\n if (!tokens.storefront) {\n throw new Bug('No storefront token found after ensuring authenticated')\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n *\n * @param store - Store fqdn to request auth for.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Admin API.\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n debug(content`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${token.raw(\n store,\n )}:\n${token.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, forceRefresh)\n if (!tokens.admin) {\n throw new Bug('No admin token found after ensuring authenticated')\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n *\n * @param store - Store fqdn to request auth for.\n * @param password - Password generated from Theme Access app.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token and store.\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n debug(content`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${token.json(scopes)}\n`)\n if (password) return {token: password, storeFqdn: await normalizeStoreFqdn(store)}\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * Logout from Shopify.\n *\n * @returns A promise that resolves when the logout is complete.\n */\nexport function logout(): Promise<void> {\n return secureStore.remove()\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ import { AbortSignal } from './abort.js';
3
+ import type { Writable, Readable } from 'stream';
4
+ export interface ExecOptions {
5
+ cwd?: string;
6
+ env?: {
7
+ [key: string]: string | undefined;
8
+ };
9
+ stdin?: Readable | 'inherit';
10
+ stdout?: Writable | 'inherit';
11
+ stderr?: Writable | 'inherit';
12
+ stdio?: 'inherit';
13
+ input?: string;
14
+ signal?: AbortSignal;
15
+ }
16
+ /**
17
+ * Opens a URL in the user's default browser.
18
+ *
19
+ * @param url - URL to open.
20
+ */
21
+ export declare function openURL(url: string): Promise<void>;
22
+ /**
23
+ * Runs a command asynchronously, aggregates the stdout data, and returns it.
24
+ *
25
+ * @param command - Command to be executed.
26
+ * @param args - Arguments to pass to the command.
27
+ * @param options - Optional settings for how to run the command.
28
+ * @returns A promise that resolves with the aggregatted stdout of the command.
29
+ */
30
+ export declare function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string>;
31
+ /**
32
+ * Runs a command asynchronously.
33
+ *
34
+ * @param command - Command to be executed.
35
+ * @param args - Arguments to pass to the command.
36
+ * @param options - Optional settings for how to run the command.
37
+ */
38
+ export declare function exec(command: string, args: string[], options?: ExecOptions): Promise<void>;
39
+ /**
40
+ * Waits for a given number of seconds.
41
+ *
42
+ * @param seconds - Number of seconds to wait.
43
+ */
44
+ export declare function sleep(seconds: number): Promise<void>;
@@ -1,24 +1,36 @@
1
- import { shouldDisplayColors, debug } from './output.js';
2
- import { platformAndArch } from './public/node/os.js';
3
- import { Abort, ExternalError } from './error.js';
4
- import { renderConcurrent } from './public/node/ui.js';
1
+ import { Abort, ExternalError } from '../../error.js';
2
+ import { shouldDisplayColors, debug } from '../../output.js';
5
3
  import { execa } from 'execa';
6
4
  import treeKill from 'tree-kill';
7
- export const open = async (url) => {
5
+ /**
6
+ * Opens a URL in the user's default browser.
7
+ *
8
+ * @param url - URL to open.
9
+ */
10
+ export async function openURL(url) {
8
11
  const externalOpen = await import('open');
9
12
  await externalOpen.default(url);
10
- };
13
+ }
11
14
  /**
12
15
  * Runs a command asynchronously, aggregates the stdout data, and returns it.
16
+ *
13
17
  * @param command - Command to be executed.
14
18
  * @param args - Arguments to pass to the command.
19
+ * @param options - Optional settings for how to run the command.
15
20
  * @returns A promise that resolves with the aggregatted stdout of the command.
16
21
  */
17
- export const captureOutput = async (command, args, options) => {
22
+ export async function captureOutput(command, args, options) {
18
23
  const result = await buildExec(command, args, options);
19
24
  return result.stdout;
20
- };
21
- export const exec = async (command, args, options) => {
25
+ }
26
+ /**
27
+ * Runs a command asynchronously.
28
+ *
29
+ * @param command - Command to be executed.
30
+ * @param args - Arguments to pass to the command.
31
+ * @param options - Optional settings for how to run the command.
32
+ */
33
+ export async function exec(command, args, options) {
22
34
  const commandProcess = buildExec(command, args, options);
23
35
  if (options?.stderr && options.stderr !== 'inherit') {
24
36
  commandProcess.stderr?.pipe(options.stderr);
@@ -50,8 +62,16 @@ export const exec = async (command, args, options) => {
50
62
  abortError.stack = processError.stack;
51
63
  throw abortError;
52
64
  }
53
- };
54
- const buildExec = (command, args, options) => {
65
+ }
66
+ /**
67
+ * Runs a command asynchronously.
68
+ *
69
+ * @param command - Command to be executed.
70
+ * @param args - Arguments to pass to the command.
71
+ * @param options - Optional settings for how to run the command.
72
+ * @returns A promise for a result with stdout and stderr properties.
73
+ */
74
+ function buildExec(command, args, options) {
55
75
  const env = options?.env ?? process.env;
56
76
  if (shouldDisplayColors()) {
57
77
  env.FORCE_COLOR = '1';
@@ -74,52 +94,12 @@ Running system process:
74
94
  · Working directory: ${options?.cwd ?? process.cwd()}
75
95
  `);
76
96
  return commandProcess;
77
- };
78
- /**
79
- * Runs commands concurrently and combines the standard output and error data
80
- * into a single stream. See {@link renderConcurrent} for more information about
81
- * the output format.
82
- *
83
- * If one of the processes fails, it aborts the running ones and exits with that error.
84
- * @param commands - Commands to execute.
85
- */
86
- export const concurrentExec = async (commands) => {
87
- await renderConcurrent({
88
- processes: commands.map((command) => {
89
- return {
90
- prefix: command.prefix,
91
- action: async (stdout, stderr, signal) => {
92
- await exec(command.executable, command.args, {
93
- stdout,
94
- stderr,
95
- cwd: command.cwd,
96
- signal,
97
- });
98
- },
99
- };
100
- }),
101
- });
102
- };
97
+ }
103
98
  /**
104
- * Displays a large file using the terminal pager set by the user, or a
105
- * reasonable default for the user's OS:
99
+ * Waits for a given number of seconds.
106
100
  *
107
- * @param filename - The path to the file to be displayed.
101
+ * @param seconds - Number of seconds to wait.
108
102
  */
109
- export async function page(filename) {
110
- let executable;
111
- if (process.env.PAGER) {
112
- executable = process.env.PAGER;
113
- }
114
- else if ((await platformAndArch()).platform === 'windows') {
115
- executable = 'more';
116
- }
117
- else {
118
- executable = 'less -NR';
119
- }
120
- const [command, ...args] = [...executable.split(' '), filename];
121
- await exec(command, args, { stdout: 'inherit', stdin: 'inherit' });
122
- }
123
103
  export async function sleep(seconds) {
124
104
  return new Promise((resolve) => {
125
105
  setTimeout(resolve, 1000 * seconds);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAC,mBAAmB,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAC,KAAK,EAAoB,MAAM,OAAO,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAchC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;IACzC,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;I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abort.js'\nimport {Abort, ExternalError} from '../../error.js'\nimport {shouldDisplayColors, debug} from '../../output.js'\nimport {execa, ExecaChildProcess} from 'execa'\nimport treeKill from 'tree-kill'\nimport type {Writable, Readable} from 'stream'\n\nexport interface ExecOptions {\n cwd?: string\n env?: {[key: string]: string | undefined}\n stdin?: Readable | 'inherit'\n stdout?: Writable | 'inherit'\n stderr?: Writable | 'inherit'\n stdio?: 'inherit'\n input?: string\n signal?: AbortSignal\n}\n\n/**\n * Opens a URL in the user's default browser.\n *\n * @param url - URL to open.\n */\nexport async function openURL(url: string): Promise<void> {\n const externalOpen = await import('open')\n await externalOpen.default(url)\n}\n\n/**\n * Runs a command asynchronously, aggregates the stdout data, and returns it.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise that resolves with the aggregatted stdout of the command.\n */\nexport async function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string> {\n const result = await buildExec(command, args, options)\n return result.stdout\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n */\nexport async function exec(command: string, args: string[], options?: ExecOptions): Promise<void> {\n const commandProcess = buildExec(command, args, options)\n if (options?.stderr && options.stderr !== 'inherit') {\n commandProcess.stderr?.pipe(options.stderr)\n }\n if (options?.stdout && options.stdout !== 'inherit') {\n commandProcess.stdout?.pipe(options.stdout)\n }\n let aborted = false\n options?.signal?.addEventListener('abort', () => {\n const pid = commandProcess.pid\n if (pid) {\n aborted = true\n treeKill(pid, (err) => {\n if (err) throw new Abort(`Failed to kill process ${pid}: ${err}`)\n })\n }\n })\n try {\n await commandProcess\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n // Windows will throw an error whenever the process is killed, no matter the reason.\n // The aborted flag tell use that we killed it, so we can ignore the error.\n if (aborted) return\n const abortError = new ExternalError(processError.message, command, args)\n abortError.stack = processError.stack\n throw abortError\n }\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise for a result with stdout and stderr properties.\n */\nfunction buildExec(command: string, args: string[], options?: ExecOptions): ExecaChildProcess<string> {\n const env = options?.env ?? process.env\n if (shouldDisplayColors()) {\n env.FORCE_COLOR = '1'\n }\n const commandProcess = execa(command, args, {\n env,\n cwd: options?.cwd,\n input: options?.input,\n stdio: options?.stdio,\n stdin: options?.stdin,\n stdout: options?.stdout === 'inherit' ? 'inherit' : undefined,\n stderr: options?.stderr === 'inherit' ? 'inherit' : undefined,\n // Setting this to false makes it possible to kill the main process\n // and all its sub-processes with Ctrl+C on Windows\n windowsHide: false,\n })\n debug(`\nRunning system process:\n · Command: ${command} ${args.join(' ')}\n · Working directory: ${options?.cwd ?? process.cwd()}\n`)\n return commandProcess\n}\n\n/**\n * Waits for a given number of seconds.\n *\n * @param seconds - Number of seconds to wait.\n */\nexport async function sleep(seconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, 1000 * seconds)\n })\n}\n"]}
@@ -1,6 +1,6 @@
1
+ import { sleep } from './system.js';
1
2
  import { debug, content, token } from '../../output.js';
2
3
  import { Abort } from '../../error.js';
3
- import { sleep } from '../../system.js';
4
4
  import * as port from 'get-port-please';
5
5
  /**
6
6
  * Returns an available port in the current environment.
@@ -1 +1 @@
1
- {"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,KAAK,CAAC,OAAO,CAAA,0BAA0B,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;IACjE,KAAK,CAAC,OAAO,CAAA,yBAAyB,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IACnE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAI,OAAgB,EAAE,QAAQ,GAAG,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAClF,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,OAAO,IAAI,EAAE;QACX,IAAI;YACF,4CAA4C;YAC5C,OAAO,MAAM,OAAO,EAAE,CAAA;YACtB,8DAA8D;SAC/D;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,UAAU,EAAE,GAAG,QAAQ,EAAE;gBAC3B,KAAK,CAAC,OAAO,CAAA,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;gBACvE,4CAA4C;gBAC5C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;aAC/B;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;KACF;AACH,CAAC","sourcesContent":["import {debug, content, token} from '../../output.js'\nimport {Abort} from '../../error.js'\nimport {sleep} from '../../system.js'\nimport * as port from 'get-port-please'\n\n/**\n * Returns an available port in the current environment.\n *\n * @returns A promise that resolves with an availabe port.\n * @example\n */\nexport async function getAvailableTCPPort(): Promise<number> {\n debug(content`Getting a random port...`)\n const randomPort = await retryOnError(() => port.getRandomPort())\n debug(content`Random port obtained: ${token.raw(`${randomPort}`)}`)\n return randomPort\n}\n\n/**\n * Given a function, it runs it and retries in case of failiure up to the provided number of times.\n *\n * @param execute - The function to execute.\n * @param maxTries - The maximum retries.\n * @param waitTimeInSeconds - The time to wait between retries.\n */\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n debug(content`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new Abort(error.message)\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,KAAK,CAAC,OAAO,CAAA,0BAA0B,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;IACjE,KAAK,CAAC,OAAO,CAAA,yBAAyB,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IACnE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAI,OAAgB,EAAE,QAAQ,GAAG,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAClF,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,OAAO,IAAI,EAAE;QACX,IAAI;YACF,4CAA4C;YAC5C,OAAO,MAAM,OAAO,EAAE,CAAA;YACtB,8DAA8D;SAC/D;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,UAAU,EAAE,GAAG,QAAQ,EAAE;gBAC3B,KAAK,CAAC,OAAO,CAAA,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;gBACvE,4CAA4C;gBAC5C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;aAC/B;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;KACF;AACH,CAAC","sourcesContent":["import {sleep} from './system.js'\nimport {debug, content, token} from '../../output.js'\nimport {Abort} from '../../error.js'\nimport * as port from 'get-port-please'\n\n/**\n * Returns an available port in the current environment.\n *\n * @returns A promise that resolves with an availabe port.\n * @example\n */\nexport async function getAvailableTCPPort(): Promise<number> {\n debug(content`Getting a random port...`)\n const randomPort = await retryOnError(() => port.getRandomPort())\n debug(content`Random port obtained: ${token.raw(`${randomPort}`)}`)\n return randomPort\n}\n\n/**\n * Given a function, it runs it and retries in case of failiure up to the provided number of times.\n *\n * @param execute - The function to execute.\n * @param maxTries - The maximum retries.\n * @param waitTimeInSeconds - The time to wait between retries.\n */\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n debug(content`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new Abort(error.message)\n }\n }\n }\n}\n"]}
@@ -1,6 +1,8 @@
1
1
  import { OutputProcess } from '../../output.js';
2
2
  import { Fatal } from '../../error.js';
3
3
  import { AlertProps } from '../../private/node/ui/components/Alert.js';
4
+ import ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js';
5
+ import { TableProps } from '../../private/node/ui/components/Table/Table.js';
4
6
  import { Props as SelectPromptProps } from '../../private/node/ui/components/SelectPrompt.js';
5
7
  import { Task } from '../../private/node/ui/components/Tasks.js';
6
8
  import { Props as TextPromptProps } from '../../private/node/ui/components/TextPrompt.js';
@@ -170,6 +172,17 @@ export declare function renderFatalError(error: Fatal): void;
170
172
  * navigate with arrows, enter to select
171
173
  */
172
174
  export declare function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T>;
175
+ /**
176
+ * Renders a table to the console.
177
+ *
178
+ * name role Identifier
179
+ * ──────────────────────── ───────────── ──────────
180
+ * Dawn [live] #1361
181
+ * Studio #1363
182
+ * Debut [unpublished] #1374
183
+ * Development (1a23b4-MBP) [development] #1368
184
+ */
185
+ export declare function renderTable<T extends ScalarDict>(props: TableProps<T>): void;
173
186
  /**
174
187
  * Runs async tasks and displays their progress to the console.
175
188
  */
@@ -3,6 +3,7 @@ import { consoleError } from '../../output.js';
3
3
  import { render, renderOnce } from '../../private/node/ui.js';
4
4
  import { alert } from '../../private/node/ui/alert.js';
5
5
  import { FatalError } from '../../private/node/ui/components/FatalError.js';
6
+ import Table from '../../private/node/ui/components/Table/Table.js';
6
7
  import { SelectPrompt } from '../../private/node/ui/components/SelectPrompt.js';
7
8
  import { Tasks } from '../../private/node/ui/components/Tasks.js';
8
9
  import { TextPrompt } from '../../private/node/ui/components/TextPrompt.js';
@@ -181,6 +182,19 @@ export function renderSelectPrompt(props) {
181
182
  }).catch(reject);
182
183
  });
183
184
  }
185
+ /**
186
+ * Renders a table to the console.
187
+ *
188
+ * name role Identifier
189
+ * ──────────────────────── ───────────── ──────────
190
+ * Dawn [live] #1361
191
+ * Studio #1363
192
+ * Debut [unpublished] #1374
193
+ * Development (1a23b4-MBP) [development] #1368
194
+ */
195
+ export function renderTable(props) {
196
+ return renderOnce(React.createElement(Table, { ...props }));
197
+ }
184
198
  /**
185
199
  * Runs async tasks and displays their progress to the console.
186
200
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"A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ConcurrentOutput.js'\nimport {consoleError, OutputProcess} from '../../output.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {Fatal} from '../../error.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport {SelectPrompt, Props as SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, Props as TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport React from 'react'\nimport {RenderOptions} from 'ink'\nimport {AbortController} from '@shopify/cli-kit/node/abort'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({\n processes,\n abortController,\n showTimestamps = true,\n renderOptions = {},\n}: RenderConcurrentOptions) {\n return render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n renderOptions,\n )\n}\n\ntype RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n return renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\n/**\n * Renders a select prompt to the console.\n *\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n\n * \\> (f) first\n * (s) second\n * (3) third\n * (4) fourth\n * (5) seventh\n * (6) tenth\n\n * Automations\n * (7) fifth\n * (8) sixth\n\n * Merchant Admin\n * (9) eighth\n * (10) ninth\n\n * navigate with arrows, enter to select\n */\nexport function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T> {\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n */\nexport function renderTasks(tasks: Task[]) {\n return render(<Tasks tasks={tasks} />)\n}\n\n/**\n * Renders a text prompt to the console.\n *\n * ? What is your name?\n * \\> John\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>) {\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AACnF,OAAO,EAAC,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,gDAAgD,CAAA;AAEzE,OAAO,KAAmB,MAAM,iDAAiD,CAAA;AACjF,OAAO,EAAC,YAAY,EAA6B,MAAM,kDAAkD,CAA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AC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAA6C;IACjF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,oBAAC,YAAY,OAAK,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC1E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAuB,KAAoB;IACpE,OAAO,UAAU,CAAC,oBAAC,KAAK,OAAK,KAAK,GAAI,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,MAAM,CAAC,oBAAC,KAAK,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwC;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,oBAAC,UAAU,OAAK,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC7E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {consoleError, OutputProcess} from '../../output.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {Fatal} from '../../error.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport Table, {TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {SelectPrompt, Props as SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, Props as TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport React from 'react'\nimport {RenderOptions} from 'ink'\nimport {AbortController} from '@shopify/cli-kit/node/abort'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({\n processes,\n abortController,\n showTimestamps = true,\n renderOptions = {},\n}: RenderConcurrentOptions) {\n return render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n renderOptions,\n )\n}\n\ntype RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n return renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\n/**\n * Renders a select prompt to the console.\n *\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n\n * \\> (f) first\n * (s) second\n * (3) third\n * (4) fourth\n * (5) seventh\n * (6) tenth\n\n * Automations\n * (7) fifth\n * (8) sixth\n\n * Merchant Admin\n * (9) eighth\n * (10) ninth\n\n * navigate with arrows, enter to select\n */\nexport function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T> {\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Renders a table to the console.\n *\n * name role Identifier\n * ──────────────────────── ───────────── ──────────\n * Dawn [live] #1361\n * Studio #1363\n * Debut [unpublished] #1374\n * Development (1a23b4-MBP) [development] #1368\n */\nexport function renderTable<T extends ScalarDict>(props: TableProps<T>) {\n return renderOnce(<Table {...props} />)\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n */\nexport function renderTasks(tasks: Task[]) {\n return render(<Tasks tasks={tasks} />)\n}\n\n/**\n * Renders a text prompt to the console.\n *\n * ? What is your name?\n * \\> John\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>) {\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { exists, write, read } from '../../file.js';
1
+ import { fileExists, writeFile, readFile } from './fs.js';
2
2
  import { findUp, join } from '../../path.js';
3
3
  import { content, token, debug } from '../../output.js';
4
4
  /**
@@ -13,7 +13,7 @@ export async function isVSCode(root = process.cwd()) {
13
13
  if (!config) {
14
14
  return false;
15
15
  }
16
- return exists(config);
16
+ return fileExists(config);
17
17
  }
18
18
  /**
19
19
  * Add VSCode extension recommendations.
@@ -28,15 +28,15 @@ ${token.json(recommendations)}
28
28
  const extensionsPath = join(directory, '.vscode/extensions.json');
29
29
  if (await isVSCode(directory)) {
30
30
  let originalExtensionsJson = { recommendations: [] };
31
- if (await exists(extensionsPath)) {
32
- const originalExtensionsFile = await read(extensionsPath);
31
+ if (await fileExists(extensionsPath)) {
32
+ const originalExtensionsFile = await readFile(extensionsPath);
33
33
  originalExtensionsJson = JSON.parse(originalExtensionsFile);
34
34
  }
35
35
  const newExtensionsJson = {
36
36
  ...originalExtensionsJson,
37
37
  recommendations: [...originalExtensionsJson.recommendations, ...recommendations],
38
38
  };
39
- await write(extensionsPath, JSON.stringify(newExtensionsJson, null, 2));
39
+ await writeFile(extensionsPath, JSON.stringify(newExtensionsJson, null, 2));
40
40
  }
41
41
  }
42
42
  //# sourceMappingURL=vscode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../../../src/public/node/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AACjD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAErD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;IACjD,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;AAED;;;;;GAKG;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 *\n * @param root - Root directory to start searching for .vscode directory.\n * @returns True if user editor is VS Code.\n */\nexport async function isVSCode(root = process.cwd()): Promise<boolean> {\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 *\n * @param directory - Directory that contains the .vscode folder.\n * @param recommendations - List of VSCode extensions to recommend.\n */\nexport async function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void> {\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"]}
1
+ {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../../../src/public/node/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAA;AACvD,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAErD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE;IACjD,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,UAAU,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC;AAED;;;;;GAKG;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,UAAU,CAAC,cAAc,CAAC,EAAE;YACpC,MAAM,sBAAsB,GAAG,MAAM,QAAQ,CAAC,cAAc,CAAC,CAAA;YAC7D,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,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;KAC5E;AACH,CAAC","sourcesContent":["import {fileExists, writeFile, readFile} from './fs.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 *\n * @param root - Root directory to start searching for .vscode directory.\n * @returns True if user editor is VS Code.\n */\nexport async function isVSCode(root = process.cwd()): Promise<boolean> {\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 fileExists(config)\n}\n\n/**\n * Add VSCode extension recommendations.\n *\n * @param directory - Directory that contains the .vscode folder.\n * @param recommendations - List of VSCode extensions to recommend.\n */\nexport async function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void> {\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 fileExists(extensionsPath)) {\n const originalExtensionsFile = await readFile(extensionsPath)\n originalExtensionsJson = JSON.parse(originalExtensionsFile)\n }\n const newExtensionsJson = {\n ...originalExtensionsJson,\n recommendations: [...originalExtensionsJson.recommendations, ...recommendations],\n }\n await writeFile(extensionsPath, JSON.stringify(newExtensionsJson, null, 2))\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
- import constants from './constants.js';
2
1
  import { content as outputContent, debug } from './output.js';
3
2
  import { Abort } from './error.js';
3
+ import { keychainConstants } from './private/node/constants.js';
4
4
  /**
5
5
  * Fetches secured content from the system's keychain.
6
6
  * @param identifier - Identifier to identify the content.
@@ -10,7 +10,7 @@ export async function fetch(identifier) {
10
10
  debug(outputContent `Reading ${identifier} from the secure store...`);
11
11
  try {
12
12
  const keytar = await import('keytar');
13
- const content = await keytar.getPassword(constants.keychain.service, identifier);
13
+ const content = await keytar.getPassword(keychainConstants.service, identifier);
14
14
  return content;
15
15
  }
16
16
  catch (error) {
@@ -27,7 +27,7 @@ export async function store(identifier, content) {
27
27
  debug(outputContent `Updating ${identifier} in the secure store with new content...`);
28
28
  try {
29
29
  const keytar = await import('keytar');
30
- await keytar.default.setPassword(constants.keychain.service, identifier, content);
30
+ await keytar.default.setPassword(keychainConstants.service, identifier, content);
31
31
  }
32
32
  catch (error) {
33
33
  throw createAbort(error, 'Unable to update the secure store');
@@ -42,7 +42,7 @@ export async function remove(identifier) {
42
42
  debug(outputContent `Removing ${identifier} from the secure store...`);
43
43
  try {
44
44
  const keytar = await import('keytar');
45
- const result = await keytar.default.deletePassword(constants.keychain.service, identifier);
45
+ const result = await keytar.default.deletePassword(keychainConstants.service, identifier);
46
46
  return result;
47
47
  }
48
48
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"secure-store.js","sourceRoot":"","sources":["../src/secure-store.ts"],"names":[],"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ACrC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC1F,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,wCAAwC,CAAC,CAAA;KACnE;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,OAAe;IAClD,IAAI,UAAU,GAAG,OAAO,CAAA;IACxB,IAAI,KAAK,GAAuB,EAAE,CAAA;IAClC,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACjD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;KACpB;IACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;IACnC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAA;IACnB,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import constants from './constants.js'\nimport {content as outputContent, debug} from './output.js'\nimport {Abort} from './error.js'\n\n/**\n * Fetches secured content from the system's keychain.\n * @param identifier - Identifier to identify the content.\n * @returns A promise that resolves with the content or null if it doesn't exist.\n */\nexport async function fetch(identifier: string): Promise<string | null> {\n debug(outputContent`Reading ${identifier} from the secure store...`)\n try {\n const keytar = await import('keytar')\n const content = await keytar.getPassword(constants.keychain.service, identifier)\n return content\n } catch (error) {\n throw createAbort(error, 'Unable to read from the secure store')\n }\n}\n\n/**\n * Securely stores the content under the given key.\n * @param identifier - Identifier to identify the content.\n * @param content - The content to be stored.\n * @returns A promise that resolves when the storing completes.\n */\nexport async function store(identifier: string, content: string): Promise<void> {\n debug(outputContent`Updating ${identifier} in the secure store with new content...`)\n try {\n const keytar = await import('keytar')\n await keytar.default.setPassword(constants.keychain.service, identifier, content)\n } catch (error) {\n throw createAbort(error, 'Unable to update the secure store')\n }\n}\n\n/**\n * Removes the content with the given identifier.\n * @param identifier - Identifier to identify the content.\n * @returns A promise that resolves with true if the content was deleted.\n */\nexport async function remove(identifier: string): Promise<boolean> {\n debug(outputContent`Removing ${identifier} from the secure store...`)\n try {\n const keytar = await import('keytar')\n const result = await keytar.default.deletePassword(constants.keychain.service, identifier)\n return result\n } catch (error) {\n throw createAbort(error, 'Unable to remove from the secure store')\n }\n}\n\nfunction createAbort(error: unknown, message: string) {\n let newMessage = message\n let stack: string | undefined = ''\n if (error instanceof Error) {\n newMessage = message.concat(`: ${error.message}`)\n stack = error.stack\n }\n const abort = new Abort(newMessage)\n abort.stack = stack\n return abort\n}\n"]}
1
+ {"version":3,"file":"secure-store.js","sourceRoot":"","sources":["../src/secure-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAA;AAE7D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,UAAkB;IAC5C,KAAK,CAAC,aAAa,CAAA,WAAW,UAAU,2BAA2B,CAAC,CAAA;IACpE,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC/E,OAAO,OAAO,CAAA;KACf;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,sCAAsC,CAAC,CAAA;KACjE;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,UAAkB,EAAE,OAAe;IAC7D,KAAK,CAAC,aAAa,CAAA,YAAY,UAAU,0CAA0C,CAAC,CAAA;IACpF,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;KACjF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,mCAAmC,CAAC,CAAA;KAC9D;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,UAAkB;IAC7C,KAAK,CAAC,aAAa,CAAA,YAAY,UAAU,2BAA2B,CAAC,CAAA;IACrE,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACrC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QACzF,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,CAAC,KAAK,EAAE,wCAAwC,CAAC,CAAA;KACnE;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,OAAe;IAClD,IAAI,UAAU,GAAG,OAAO,CAAA;IACxB,IAAI,KAAK,GAAuB,EAAE,CAAA;IAClC,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACjD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;KACpB;IACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,CAAA;IACnC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAA;IACnB,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {content as outputContent, debug} from './output.js'\nimport {Abort} from './error.js'\nimport {keychainConstants} from './private/node/constants.js'\n\n/**\n * Fetches secured content from the system's keychain.\n * @param identifier - Identifier to identify the content.\n * @returns A promise that resolves with the content or null if it doesn't exist.\n */\nexport async function fetch(identifier: string): Promise<string | null> {\n debug(outputContent`Reading ${identifier} from the secure store...`)\n try {\n const keytar = await import('keytar')\n const content = await keytar.getPassword(keychainConstants.service, identifier)\n return content\n } catch (error) {\n throw createAbort(error, 'Unable to read from the secure store')\n }\n}\n\n/**\n * Securely stores the content under the given key.\n * @param identifier - Identifier to identify the content.\n * @param content - The content to be stored.\n * @returns A promise that resolves when the storing completes.\n */\nexport async function store(identifier: string, content: string): Promise<void> {\n debug(outputContent`Updating ${identifier} in the secure store with new content...`)\n try {\n const keytar = await import('keytar')\n await keytar.default.setPassword(keychainConstants.service, identifier, content)\n } catch (error) {\n throw createAbort(error, 'Unable to update the secure store')\n }\n}\n\n/**\n * Removes the content with the given identifier.\n * @param identifier - Identifier to identify the content.\n * @returns A promise that resolves with true if the content was deleted.\n */\nexport async function remove(identifier: string): Promise<boolean> {\n debug(outputContent`Removing ${identifier} from the secure store...`)\n try {\n const keytar = await import('keytar')\n const result = await keytar.default.deletePassword(keychainConstants.service, identifier)\n return result\n } catch (error) {\n throw createAbort(error, 'Unable to remove from the secure store')\n }\n}\n\nfunction createAbort(error: unknown, message: string) {\n let newMessage = message\n let stack: string | undefined = ''\n if (error instanceof Error) {\n newMessage = message.concat(`: ${error.message}`)\n stack = error.stack\n }\n const abort = new Abort(newMessage)\n abort.stack = stack\n return abort\n}\n"]}
package/dist/store.d.ts CHANGED
@@ -13,8 +13,8 @@ interface ConfSchema {
13
13
  themeStore: string;
14
14
  session: string;
15
15
  }
16
- export declare function cliKitStore(): Promise<CLIKitStore>;
17
- export declare function getAppInfo(directory: string): Promise<CachedAppInfo | undefined>;
16
+ export declare function cliKitStore(): CLIKitStore;
17
+ export declare function getAppInfo(directory: string): CachedAppInfo | undefined;
18
18
  export declare function setAppInfo(options: {
19
19
  directory: string;
20
20
  appId?: string;
@@ -23,14 +23,14 @@ export declare function setAppInfo(options: {
23
23
  orgId?: string;
24
24
  updateURLs?: boolean;
25
25
  tunnelPlugin?: string;
26
- }): Promise<void>;
27
- export declare function clearAppInfo(directory: string): Promise<void>;
28
- export declare function getThemeStore(): Promise<string | undefined>;
29
- export declare function setThemeStore(themeStore: string): Promise<void>;
30
- export declare function getSession(): Promise<string | undefined>;
31
- export declare function setSession(session: string): Promise<void>;
32
- export declare function removeSession(): Promise<void>;
33
- export declare function clearAllAppInfo(): Promise<void>;
26
+ }): void;
27
+ export declare function clearAppInfo(directory: string): void;
28
+ export declare function getThemeStore(): string | undefined;
29
+ export declare function setThemeStore(themeStore: string): void;
30
+ export declare function getSession(): string | undefined;
31
+ export declare function setSession(session: string): void;
32
+ export declare function removeSession(): void;
33
+ export declare function clearAllAppInfo(): void;
34
34
  export declare class CLIKitStore extends Conf<ConfSchema> {
35
35
  getAppInfo(directory: string): CachedAppInfo | undefined;
36
36
  setAppInfo(options: {