@shopify/cli-kit 3.36.1 → 3.36.2

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 (146) hide show
  1. package/dist/git.d.ts +5 -5
  2. package/dist/git.js +11 -14
  3. package/dist/git.js.map +1 -1
  4. package/dist/index.d.ts +0 -6
  5. package/dist/index.js +0 -6
  6. package/dist/index.js.map +1 -1
  7. package/dist/private/node/analytics.js +5 -4
  8. package/dist/private/node/analytics.js.map +1 -1
  9. package/dist/private/node/api/graphql.js +2 -2
  10. package/dist/private/node/api/graphql.js.map +1 -1
  11. package/dist/private/node/api/headers.d.ts +1 -1
  12. package/dist/private/node/api/headers.js +1 -1
  13. package/dist/private/node/api/headers.js.map +1 -1
  14. package/dist/{secure-store.d.ts → private/node/secure-store.d.ts} +3 -3
  15. package/dist/{secure-store.js → private/node/secure-store.js} +7 -7
  16. package/dist/private/node/secure-store.js.map +1 -0
  17. package/dist/private/node/session/authorize.d.ts +0 -2
  18. package/dist/private/node/session/authorize.js +2 -3
  19. package/dist/private/node/session/authorize.js.map +1 -1
  20. package/dist/private/node/session/device-authorization.js +2 -2
  21. package/dist/private/node/session/device-authorization.js.map +1 -1
  22. package/dist/private/node/session/exchange.d.ts +1 -1
  23. package/dist/private/node/session/exchange.js +1 -2
  24. package/dist/private/node/session/exchange.js.map +1 -1
  25. package/dist/private/node/session/identity.js +2 -2
  26. package/dist/private/node/session/identity.js.map +1 -1
  27. package/dist/private/node/session/post-auth.d.ts +2 -2
  28. package/dist/private/node/session/post-auth.js +2 -2
  29. package/dist/private/node/session/post-auth.js.map +1 -1
  30. package/dist/private/node/session/redirect-listener.js +5 -5
  31. package/dist/private/node/session/redirect-listener.js.map +1 -1
  32. package/dist/private/node/session/schema.d.ts +46 -46
  33. package/dist/private/node/session/schema.js +12 -12
  34. package/dist/private/node/session/schema.js.map +1 -1
  35. package/dist/private/node/session/scopes.js +2 -2
  36. package/dist/private/node/session/scopes.js.map +1 -1
  37. package/dist/private/node/session/store.js +4 -4
  38. package/dist/private/node/session/store.js.map +1 -1
  39. package/dist/private/node/session.js +3 -4
  40. package/dist/private/node/session.js.map +1 -1
  41. package/dist/{testing → private/node/testing}/store.d.ts +1 -1
  42. package/dist/{testing → private/node/testing}/store.js +2 -2
  43. package/dist/private/node/testing/store.js.map +1 -0
  44. package/dist/{testing → private/node/testing}/ui.d.ts +0 -0
  45. package/dist/{testing → private/node/testing}/ui.js +1 -1
  46. package/dist/private/node/testing/ui.js.map +1 -0
  47. package/dist/private/node/ui/components/AutocompletePrompt.test.js +1 -1
  48. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  49. package/dist/private/node/ui/components/ConcurrentOutput.test.js +1 -1
  50. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  51. package/dist/private/node/ui/components/FatalError.d.ts +1 -1
  52. package/dist/private/node/ui/components/FatalError.js +2 -2
  53. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  54. package/dist/private/node/ui/components/FatalError.test.js +4 -4
  55. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  56. package/dist/private/node/ui/components/SelectInput.test.js +1 -1
  57. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  58. package/dist/private/node/ui/components/SelectPrompt.test.js +1 -1
  59. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  60. package/dist/private/node/ui/components/Tasks.test.js +1 -1
  61. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  62. package/dist/private/node/ui/components/TextInput.test.js +1 -1
  63. package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
  64. package/dist/private/node/ui/components/TextPrompt.test.js +1 -1
  65. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  66. package/dist/public/common/version.d.ts +1 -1
  67. package/dist/public/common/version.js +1 -1
  68. package/dist/public/common/version.js.map +1 -1
  69. package/dist/public/node/analytics.js +6 -6
  70. package/dist/public/node/analytics.js.map +1 -1
  71. package/dist/public/node/api/admin.js +3 -3
  72. package/dist/public/node/api/admin.js.map +1 -1
  73. package/dist/public/node/base-command.js +6 -5
  74. package/dist/public/node/base-command.js.map +1 -1
  75. package/dist/public/node/environment/fqdn.d.ts +5 -5
  76. package/dist/public/node/environment/fqdn.js +5 -5
  77. package/dist/public/node/environment/fqdn.js.map +1 -1
  78. package/dist/public/node/environment/spin.js +2 -2
  79. package/dist/public/node/environment/spin.js.map +1 -1
  80. package/dist/public/node/error-handler.d.ts +2 -2
  81. package/dist/public/node/error-handler.js +7 -7
  82. package/dist/public/node/error-handler.js.map +1 -1
  83. package/dist/public/node/error.d.ts +84 -4
  84. package/dist/public/node/error.js +165 -4
  85. package/dist/public/node/error.js.map +1 -1
  86. package/dist/public/node/fs.js +4 -0
  87. package/dist/public/node/fs.js.map +1 -1
  88. package/dist/public/node/git.d.ts +2 -2
  89. package/dist/public/node/git.js +11 -10
  90. package/dist/public/node/git.js.map +1 -1
  91. package/dist/{metadata.d.ts → public/node/metadata.d.ts} +13 -13
  92. package/dist/{metadata.js → public/node/metadata.js} +13 -8
  93. package/dist/public/node/metadata.js.map +1 -0
  94. package/dist/{monorail.d.ts → public/node/monorail.d.ts} +11 -3
  95. package/dist/{monorail.js → public/node/monorail.js} +11 -3
  96. package/dist/public/node/monorail.js.map +1 -0
  97. package/dist/public/node/node-package-manager.d.ts +2 -2
  98. package/dist/public/node/node-package-manager.js +7 -2
  99. package/dist/public/node/node-package-manager.js.map +1 -1
  100. package/dist/public/node/path.d.ts +12 -2
  101. package/dist/public/node/path.js +17 -4
  102. package/dist/public/node/path.js.map +1 -1
  103. package/dist/public/node/plugins/tunnel.d.ts +2 -2
  104. package/dist/public/node/plugins/tunnel.js +1 -1
  105. package/dist/public/node/plugins/tunnel.js.map +1 -1
  106. package/dist/{plugins.d.ts → public/node/plugins.d.ts} +17 -11
  107. package/dist/{plugins.js → public/node/plugins.js} +15 -9
  108. package/dist/public/node/plugins.js.map +1 -0
  109. package/dist/public/node/result.js +3 -4
  110. package/dist/public/node/result.js.map +1 -1
  111. package/dist/public/node/ruby.js +8 -8
  112. package/dist/public/node/ruby.js.map +1 -1
  113. package/dist/public/node/schema.d.ts +1 -0
  114. package/dist/public/node/schema.js +2 -0
  115. package/dist/public/node/schema.js.map +1 -0
  116. package/dist/public/node/session.js +4 -4
  117. package/dist/public/node/session.js.map +1 -1
  118. package/dist/public/node/system.js +4 -3
  119. package/dist/public/node/system.js.map +1 -1
  120. package/dist/public/node/tcp.js +2 -2
  121. package/dist/public/node/tcp.js.map +1 -1
  122. package/dist/public/node/testing/output.d.ts +16 -0
  123. package/dist/{testing → public/node/testing}/output.js +6 -2
  124. package/dist/public/node/testing/output.js.map +1 -0
  125. package/dist/public/node/ui.d.ts +1 -1
  126. package/dist/public/node/ui.js.map +1 -1
  127. package/dist/public/node/vscode.js +2 -2
  128. package/dist/public/node/vscode.js.map +1 -1
  129. package/dist/tsconfig.tsbuildinfo +1 -1
  130. package/dist/ui.js +5 -5
  131. package/dist/ui.js.map +1 -1
  132. package/package.json +1 -1
  133. package/dist/error.d.ts +0 -68
  134. package/dist/error.js +0 -143
  135. package/dist/error.js.map +0 -1
  136. package/dist/metadata.js.map +0 -1
  137. package/dist/monorail.js.map +0 -1
  138. package/dist/plugins.js.map +0 -1
  139. package/dist/schema.d.ts +0 -1
  140. package/dist/schema.js +0 -2
  141. package/dist/schema.js.map +0 -1
  142. package/dist/secure-store.js.map +0 -1
  143. package/dist/testing/output.d.ts +0 -10
  144. package/dist/testing/output.js.map +0 -1
  145. package/dist/testing/store.js.map +0 -1
  146. package/dist/testing/ui.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/public/node/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,IAAI,MAAM,EAAC,MAAM,KAAK,CAAA","sourcesContent":["export {z as schema} from 'zod'\n"]}
@@ -1,8 +1,8 @@
1
1
  import { normalizeStoreFqdn } from './environment/fqdn.js';
2
+ import { BugError } from './error.js';
2
3
  import * as secureStore from '../../private/node/session/store.js';
3
4
  import { exchangeCustomPartnerToken } from '../../private/node/session/exchange.js';
4
5
  import { content, token, debug } from '../../output.js';
5
- import { Bug } from '../../error.js';
6
6
  import { ensureAuthenticated } from '../../private/node/session.js';
7
7
  import { environmentVariables } from '../../private/node/constants.js';
8
8
  /**
@@ -24,7 +24,7 @@ ${token.json(scopes)}
24
24
  }
25
25
  const tokens = await ensureAuthenticated({ partnersApi: { scopes } });
26
26
  if (!tokens.partners) {
27
- throw new Bug('No partners token found after ensuring authenticated');
27
+ throw new BugError('No partners token found after ensuring authenticated');
28
28
  }
29
29
  return tokens.partners;
30
30
  }
@@ -43,7 +43,7 @@ ${token.json(scopes)}
43
43
  `);
44
44
  const tokens = await ensureAuthenticated({ storefrontRendererApi: { scopes } });
45
45
  if (!tokens.storefront) {
46
- throw new Bug('No storefront token found after ensuring authenticated');
46
+ throw new BugError('No storefront token found after ensuring authenticated');
47
47
  }
48
48
  return tokens.storefront;
49
49
  }
@@ -61,7 +61,7 @@ ${token.json(scopes)}
61
61
  `);
62
62
  const tokens = await ensureAuthenticated({ adminApi: { scopes, storeFqdn: store } }, process.env, forceRefresh);
63
63
  if (!tokens.admin) {
64
- throw new Bug('No admin token found after ensuring authenticated');
64
+ throw new BugError('No admin token found after ensuring authenticated');
65
65
  }
66
66
  return tokens.admin;
67
67
  }
@@ -1 +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,gBA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G;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAa,EACb,SAAmB,EAAE,EACrB,YAAY,GAAG,KAAK;IAEpB,KAAK,CAAC,OAAO,CAAA,sGAAsG,KAAK,CAAC,GAAG,CAC1H,KAAK,CACN;EACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAA;IACA,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,EAAC,EAAE,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAC3G,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,MAAM,IAAI,GAAG,CAAC,mDAAmD,CAAC,CAAA;KACnE;IACD,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,KAAa,EACb,QAA4B,EAC5B,SAAmB,EAAE,EACrB,YAAY,GAAG,KAAK;IAEpB,KAAK,CAAC,OAAO,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"]}
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,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,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,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AAUpE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,C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ACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAA;IACA,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,EAAC,EAAE,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAC3G,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,MAAM,IAAI,QAAQ,CAAC,mDAAmD,CAAC,CAAA;KACxE;IACD,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,KAAa,EACb,QAA4B,EAC5B,SAAmB,EAAE,EACrB,YAAY,GAAG,KAAK;IAEpB,KAAK,CAAC,OAAO,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 {BugError} from './error.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 {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 BugError('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 BugError('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 BugError('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"]}
@@ -1,4 +1,5 @@
1
- import { Abort, ExternalError } from '../../error.js';
1
+ import { AbortError, ExternalError } from './error.js';
2
+ import { cwd } from './path.js';
2
3
  import { shouldDisplayColors, debug } from '../../output.js';
3
4
  import { execa } from 'execa';
4
5
  import treeKill from 'tree-kill';
@@ -45,7 +46,7 @@ export async function exec(command, args, options) {
45
46
  aborted = true;
46
47
  treeKill(pid, (err) => {
47
48
  if (err)
48
- throw new Abort(`Failed to kill process ${pid}: ${err}`);
49
+ throw new AbortError(`Failed to kill process ${pid}: ${err}`);
49
50
  });
50
51
  }
51
52
  });
@@ -91,7 +92,7 @@ function buildExec(command, args, options) {
91
92
  debug(`
92
93
  Running system process:
93
94
  · Command: ${command} ${args.join(' ')}
94
- · Working directory: ${options?.cwd ?? process.cwd()}
95
+ · Working directory: ${options?.cwd ?? cwd()}
95
96
  `);
96
97
  return commandProcess;
97
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,aAAa,EAAC,MAAM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AAW,EAAE,KAAK;KACnB,CAAC,CAAA;IACF,KAAK,CAAC;;eAEO,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;yBACf,OAAO,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;CACrD,CAAC,CAAA;IACA,OAAO,cAAc,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {AbortSignal} from './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
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EA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CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC7D,mEAAmE;QACnE,mDAAmD;QACnD,WAAW,EAAE,KAAK;KACnB,CAAC,CAAA;IACF,KAAK,CAAC;;eAEO,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;yBACf,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE;CAC7C,CAAC,CAAA;IACA,OAAO,cAAc,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {AbortError, ExternalError} from './error.js'\nimport {cwd} from './path.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 AbortError(`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 ?? 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
1
  import { sleep } from './system.js';
2
+ import { AbortError } from './error.js';
2
3
  import { debug, content, token } from '../../output.js';
3
- import { Abort } from '../../error.js';
4
4
  import * as port from 'get-port-please';
5
5
  /**
6
6
  * Returns an available port in the current environment.
@@ -36,7 +36,7 @@ async function retryOnError(execute, maxTries = 5, waitTimeInSeconds = 1) {
36
36
  await sleep(waitTimeInSeconds);
37
37
  }
38
38
  else {
39
- throw new Abort(error.message);
39
+ throw new AbortError(error.message);
40
40
  }
41
41
  }
42
42
  }
@@ -1 +1 @@
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
+ {"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,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,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,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aACpC;SACF;KACF;AACH,CAAC","sourcesContent":["import {sleep} from './system.js'\nimport {AbortError} from './error.js'\nimport {debug, content, token} from '../../output.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 AbortError(error.message)\n }\n }\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ interface OutputMock {
2
+ output: () => string;
3
+ info: () => string;
4
+ debug: () => string;
5
+ success: () => string;
6
+ completed: () => string;
7
+ warn: () => string;
8
+ error: () => string;
9
+ clear: () => void;
10
+ }
11
+ /**
12
+ * Returns a set of functions to get the outputs ocurred during a test run.
13
+ *
14
+ * @returns An mock object with all the output functions.
15
+ */ export declare function mockAndCaptureOutput(): OutputMock;
16
+ export {};
@@ -1,5 +1,9 @@
1
- import * as output from '../output.js';
2
- export function mockAndCaptureOutput() {
1
+ import * as output from '../../../output.js';
2
+ /**
3
+ * Returns a set of functions to get the outputs ocurred during a test run.
4
+ *
5
+ * @returns An mock object with all the output functions.
6
+ */ export function mockAndCaptureOutput() {
3
7
  return {
4
8
  output: () => (output.collectedLogs.output ?? []).join('\n'),
5
9
  info: () => (output.collectedLogs.info ?? []).join('\n'),
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../../src/public/node/testing/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAA;AAa5C;;;;GAIG,CAAC,MAAM,UAAU,oBAAoB;IACtC,OAAO;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5D,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACxD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1D,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9D,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAClE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACxD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1D,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,CAAC,kBAAkB,EAAE,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import * as output from '../../../output.js'\n\ninterface OutputMock {\n output: () => string\n info: () => string\n debug: () => string\n success: () => string\n completed: () => string\n warn: () => string\n error: () => string\n clear: () => void\n}\n\n/**\n * Returns a set of functions to get the outputs ocurred during a test run.\n *\n * @returns An mock object with all the output functions.\n */ export function mockAndCaptureOutput(): OutputMock {\n return {\n output: () => (output.collectedLogs.output ?? []).join('\\n'),\n info: () => (output.collectedLogs.info ?? []).join('\\n'),\n debug: () => (output.collectedLogs.debug ?? []).join('\\n'),\n success: () => (output.collectedLogs.success ?? []).join('\\n'),\n completed: () => (output.collectedLogs.completed ?? []).join('\\n'),\n warn: () => (output.collectedLogs.warn ?? []).join('\\n'),\n error: () => (output.collectedLogs.error ?? []).join('\\n'),\n clear: () => {\n output.clearCollectedLogs()\n },\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
+ import { FatalError as Fatal } from './error.js';
1
2
  import { OutputProcess } from '../../output.js';
2
- import { Fatal } from '../../error.js';
3
3
  import { AlertProps } from '../../private/node/ui/components/Alert.js';
4
4
  import ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js';
5
5
  import { TableProps } from '../../private/node/ui/components/Table/Table.js';
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,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,CAAA;AACzG,OAAO,EAAC,KAAK,EAAO,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAC,UAAU,EAA2B,MAAM,gDAAgD,CAAA;AAGnG,OAAO,EAAC,kBAAkB,EAAC,MAAM,wDAAwD,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAS3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,SAAS,EACT,eAAe,EACf,cAAc,GAAG,IAAI,EAC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AAoB;IACpE,OAAO,UAAU,CAAC,oBAAC,KAAK,OAAK,KAAK,GAAI,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAW,KAAuB;IACjE,OAAO,MAAM,CAAC,oBAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAI,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;GAMG;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 {isUnitTest} from './environment/local.js'\nimport 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 {Item as SelectItem, Props as SelectProps} from '../../private/node/ui/components/SelectInput.js'\nimport {Props as InfoTableProps} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.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\nexport type 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 * ```\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 * Press ↑↓ arrows to select, enter to confirm\n * ```\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\ninterface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable'> {\n confirmationMessage?: string\n cancellationMessage?: string\n}\n\n/**\n * Renders a confirmation prompt to the console.\n *\n * ? Do you want to continue?\n *\n * \\> (y) Yes, confirm\n * (n) No, canccel\n *\n * Press ↑↓ arrows to select, enter to confirm\n */\nexport function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n })\n}\n\ninterface RenderAutocompletePromptProps<T> {\n message: string\n choices: SelectProps<T>['items']\n infoTable?: InfoTableProps['table']\n search?: (term: string) => Promise<SelectItem<T>[]>\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * ```\n * ? Select a template Type to search...\n\n * \\> first\n * second\n * third\n\n * Press ↑↓ arrows to select, enter to confirm\n * ```\n */\nexport function renderAutocompletePrompt<T>(props: RenderAutocompletePromptProps<T>): Promise<T> {\n const newProps = {\n search(term: string) {\n return Promise.resolve(props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())))\n },\n ...props,\n }\n\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Renders a table to the console.\n *\n * ```\n * name role Identifier\n * ──────────────────────── ───────────── ──────────\n * Dawn [live] #1361\n * Studio #1363\n * Debut [unpublished] #1374\n * Development (1a23b4-MBP) [development] #1368\n * ```\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 async function renderTasks<TContext>(tasks: Task<TContext>[]) {\n return render(<Tasks tasks={tasks} silent={isUnitTest()} />)\n}\n\n/**\n * Renders a text prompt to the console.\n * ```\n * ? What is your name?\n * \\> John\n * ```\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>): Promise<string> {\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,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AAEjD,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AACnF,OAAO,EAAC,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAC3D,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,CAAA;AACzG,OAAO,EAAC,KAAK,EAAO,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAC,UAAU,EAA2B,MAAM,gDAAgD,CAAA;AAGnG,OAAO,EAAC,kBAAkB,EAAC,MAAM,wDAAwD,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAS3D;;GAEG;A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IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAuB,KAAoB;IACpE,OAAO,UAAU,CAAC,oBAAC,KAAK,OAAK,KAAK,GAAI,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAW,KAAuB;IACjE,OAAO,MAAM,CAAC,oBAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAI,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;GAMG;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 {isUnitTest} from './environment/local.js'\nimport {FatalError as Fatal} from './error.js'\nimport ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {consoleError, OutputProcess} from '../../output.js'\nimport {render, renderOnce} from '../../private/node/ui.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 {Item as SelectItem, Props as SelectProps} from '../../private/node/ui/components/SelectInput.js'\nimport {Props as InfoTableProps} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.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\nexport type 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 * ```\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 * Press ↑↓ arrows to select, enter to confirm\n * ```\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\ninterface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable'> {\n confirmationMessage?: string\n cancellationMessage?: string\n}\n\n/**\n * Renders a confirmation prompt to the console.\n *\n * ? Do you want to continue?\n *\n * \\> (y) Yes, confirm\n * (n) No, canccel\n *\n * Press ↑↓ arrows to select, enter to confirm\n */\nexport function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n })\n}\n\ninterface RenderAutocompletePromptProps<T> {\n message: string\n choices: SelectProps<T>['items']\n infoTable?: InfoTableProps['table']\n search?: (term: string) => Promise<SelectItem<T>[]>\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * ```\n * ? Select a template Type to search...\n\n * \\> first\n * second\n * third\n\n * Press ↑↓ arrows to select, enter to confirm\n * ```\n */\nexport function renderAutocompletePrompt<T>(props: RenderAutocompletePromptProps<T>): Promise<T> {\n const newProps = {\n search(term: string) {\n return Promise.resolve(props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())))\n },\n ...props,\n }\n\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Renders a table to the console.\n *\n * ```\n * name role Identifier\n * ──────────────────────── ───────────── ──────────\n * Dawn [live] #1361\n * Studio #1363\n * Debut [unpublished] #1374\n * Development (1a23b4-MBP) [development] #1368\n * ```\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 async function renderTasks<TContext>(tasks: Task<TContext>[]) {\n return render(<Tasks tasks={tasks} silent={isUnitTest()} />)\n}\n\n/**\n * Renders a text prompt to the console.\n * ```\n * ? What is your name?\n * \\> John\n * ```\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>): Promise<string> {\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,5 +1,5 @@
1
1
  import { fileExists, writeFile, readFile, findPathUp } from './fs.js';
2
- import { joinPath } from './path.js';
2
+ import { joinPath, cwd } from './path.js';
3
3
  import { content, token, debug } from '../../output.js';
4
4
  /**
5
5
  * Check if user editor is VS Code.
@@ -7,7 +7,7 @@ import { content, token, debug } from '../../output.js';
7
7
  * @param root - Root directory to start searching for .vscode directory.
8
8
  * @returns True if user editor is VS Code.
9
9
  */
10
- export async function isVSCode(root = process.cwd()) {
10
+ export async function isVSCode(root = cwd()) {
11
11
  debug(content `Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `);
12
12
  const config = await findPathUp(joinPath(root, '.vscode'), { type: 'directory' });
13
13
  if (!config) {
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../../../src/public/node/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,SAAS,CAAA;AACnE,OAAO,EAAC,QAAQ,E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;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, findPathUp} from './fs.js'\nimport {joinPath} 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 findPathUp(joinPath(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 = joinPath(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
+ {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../../../src/public/node/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,SAAS,CAAA;AACnE,OAAO,EAAC,QAAQ,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,EAAC,OAAO,EAAE,KAAK,E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iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;KAC5E;AACH,CAAC","sourcesContent":["import {fileExists, writeFile, readFile, findPathUp} from './fs.js'\nimport {joinPath, cwd} 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 = 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 findPathUp(joinPath(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 = joinPath(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"]}