@shopify/cli 3.63.2 → 3.64.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/assets/cli-ruby/lib/shopify_cli/reporting_configuration_controller.rb +2 -37
  2. package/dist/assets/cli-ruby/lib/shopify_cli/theme/file.rb +5 -1
  3. package/dist/assets/dev-console/extensions/dev-console/assets/index-Cgb-oKsM.css +1 -0
  4. package/dist/assets/dev-console/extensions/dev-console/assets/{index-Dui3DO9f.js → index-D7F9wNys.js} +12 -12
  5. package/dist/assets/dev-console/index.html +2 -2
  6. package/dist/assets/hydrogen/starter/.graphqlrc.ts +27 -0
  7. package/dist/assets/hydrogen/starter/CHANGELOG.md +108 -6
  8. package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +37 -0
  9. package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +150 -0
  10. package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +68 -0
  11. package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +101 -0
  12. package/dist/assets/hydrogen/starter/app/components/Header.tsx +3 -3
  13. package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +2 -2
  14. package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +80 -0
  15. package/dist/assets/hydrogen/starter/app/components/ProductImage.tsx +23 -0
  16. package/dist/assets/hydrogen/starter/app/components/ProductPrice.tsx +27 -0
  17. package/dist/assets/hydrogen/starter/app/root.tsx +11 -17
  18. package/dist/assets/hydrogen/starter/app/routes/cart.tsx +1 -1
  19. package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +51 -232
  20. package/dist/assets/hydrogen/starter/package.json +11 -11
  21. package/dist/assets/hydrogen/tailwind/package.json +1 -6
  22. package/dist/assets/hydrogen/tailwind/tailwind.css +6 -3
  23. package/dist/assets/hydrogen/vanilla-extract/package.json +2 -3
  24. package/dist/assets/hydrogen/virtual-routes/components/{Layout.jsx → PageLayout.jsx} +2 -2
  25. package/dist/assets/hydrogen/virtual-routes/virtual-root.jsx +8 -30
  26. package/dist/{chunk-YAYFJITA.js → chunk-2DXCIFDK.js} +3 -3
  27. package/dist/{chunk-EQR6CWKL.js → chunk-63D4EGTO.js} +3 -3
  28. package/dist/{chunk-EZYMDZPN.js → chunk-6PJAGL2L.js} +5 -5
  29. package/dist/{chunk-S4VBXFXP.js → chunk-7PVTYKQI.js} +220 -16
  30. package/dist/{chunk-IRWSC76I.js → chunk-7TIDA343.js} +3 -3
  31. package/dist/{chunk-NPLAQVTF.js → chunk-7W6SRTYP.js} +3 -3
  32. package/dist/{chunk-UJYIV6JP.js → chunk-ARCFCLME.js} +5 -5
  33. package/dist/{chunk-DIZHFZTJ.js → chunk-ATGUMSCJ.js} +4 -4
  34. package/dist/chunk-B3D5VLUA.js +12 -0
  35. package/dist/{chunk-UNPXLODI.js → chunk-B7RN7IRD.js} +3 -4
  36. package/dist/{chunk-5BLMIE7F.js → chunk-DX43V2L4.js} +4 -4
  37. package/dist/{chunk-6UDFXWNE.js → chunk-EJITPGUJ.js} +21 -4
  38. package/dist/chunk-FDLU3RD4.js +29 -0
  39. package/dist/{chunk-7OCUVNSF.js → chunk-H6AQTECB.js} +1485 -2977
  40. package/dist/{chunk-T54B5GJP.js → chunk-JNUJZFQL.js} +2 -2
  41. package/dist/{chunk-XER2L725.js → chunk-KUVX423E.js} +2 -2
  42. package/dist/{chunk-R5KML52V.js → chunk-KZTALMEV.js} +4 -4
  43. package/dist/{chunk-CM4H6QMH.js → chunk-M6KGRVDD.js} +3 -3
  44. package/dist/{chunk-3MDI6LZT.js → chunk-NLE3ZLU6.js} +905 -896
  45. package/dist/{chunk-WADS2TV5.js → chunk-NO7MYZEO.js} +5 -4
  46. package/dist/{chunk-LH533WG4.js → chunk-NPH2SXRO.js} +2 -2
  47. package/dist/{chunk-VZUWS5IH.js → chunk-OVWFZSJT.js} +3 -3
  48. package/dist/{chunk-UQUO22Q5.js → chunk-OXMHVKM3.js} +5 -5
  49. package/dist/{chunk-PNFEODLY.js → chunk-QNI6VLVR.js} +3 -3
  50. package/dist/{chunk-MCT2524Y.js → chunk-QYT42J3T.js} +4 -4
  51. package/dist/{chunk-VQTHQBEC.js → chunk-S3HWVIGJ.js} +9 -14
  52. package/dist/{chunk-23OKKZ5V.js → chunk-S7A7BHNA.js} +4 -4
  53. package/dist/{chunk-3TGMDPDI.js → chunk-SSAUIEBT.js} +2 -2
  54. package/dist/{chunk-YMPGWFWU.js → chunk-UQQI7TQG.js} +3 -3
  55. package/dist/{chunk-UZUD5DRI.js → chunk-UXA5YROL.js} +2 -2
  56. package/dist/{chunk-K3CVGV3F.js → chunk-V7NH4SZB.js} +3 -3
  57. package/dist/{chunk-7AVKIH7O.js → chunk-WVY52EEZ.js} +5 -5
  58. package/dist/{chunk-QEOBHRRQ.js → chunk-X3OUSYUQ.js} +17912 -17444
  59. package/dist/{chunk-EARPFFS7.js → chunk-XNCQBHNR.js} +241 -4
  60. package/dist/{chunk-EQPYUHNM.js → chunk-ZIGJPI5N.js} +1497 -112
  61. package/dist/{chunk-A2UVOX6O.js → chunk-ZKWHKX2C.js} +7066 -6051
  62. package/dist/{chunk-GPMHDCWK.js → chunk-ZRGD2HUL.js} +3 -3
  63. package/dist/{chunk-PQKGBYDC.js → chunk-ZVT2WZZF.js} +3 -3
  64. package/dist/cli/commands/auth/logout.js +14 -19
  65. package/dist/cli/commands/auth/logout.test.js +17 -21
  66. package/dist/cli/commands/debug/command-flags.js +11 -15
  67. package/dist/cli/commands/demo/catalog.js +13 -18
  68. package/dist/cli/commands/demo/generate-file.js +13 -18
  69. package/dist/cli/commands/demo/index.js +13 -18
  70. package/dist/cli/commands/demo/print-ai-prompt.js +13 -18
  71. package/dist/cli/commands/docs/generate.js +11 -15
  72. package/dist/cli/commands/docs/generate.test.js +11 -15
  73. package/dist/cli/commands/help.js +11 -15
  74. package/dist/cli/commands/kitchen-sink/async.js +12 -16
  75. package/dist/cli/commands/kitchen-sink/async.test.js +12 -16
  76. package/dist/cli/commands/kitchen-sink/index.js +14 -18
  77. package/dist/cli/commands/kitchen-sink/index.test.js +14 -18
  78. package/dist/cli/commands/kitchen-sink/prompts.js +12 -16
  79. package/dist/cli/commands/kitchen-sink/prompts.test.js +12 -16
  80. package/dist/cli/commands/kitchen-sink/static.js +12 -16
  81. package/dist/cli/commands/kitchen-sink/static.test.js +12 -16
  82. package/dist/cli/commands/search.js +12 -16
  83. package/dist/cli/commands/upgrade.js +11 -15
  84. package/dist/cli/commands/version.js +12 -16
  85. package/dist/cli/commands/version.test.js +12 -16
  86. package/dist/cli/services/commands/search.js +4 -4
  87. package/dist/cli/services/commands/search.test.js +4 -4
  88. package/dist/cli/services/commands/version.js +6 -7
  89. package/dist/cli/services/commands/version.test.js +7 -8
  90. package/dist/cli/services/demo.js +5 -6
  91. package/dist/cli/services/demo.test.js +5 -6
  92. package/dist/cli/services/kitchen-sink/async.js +4 -4
  93. package/dist/cli/services/kitchen-sink/prompts.js +4 -4
  94. package/dist/cli/services/kitchen-sink/static.js +4 -4
  95. package/dist/cli/services/upgrade.js +5 -6
  96. package/dist/cli/services/upgrade.test.js +7 -8
  97. package/dist/{constants-3CLHB4LQ.js → constants-EVER32LA.js} +3 -3
  98. package/dist/{custom-oclif-loader-D4H5EJW6.js → custom-oclif-loader-BQAFOUNG.js} +13 -6
  99. package/dist/{error-handler-HUI4HW3X.js → error-handler-S56KHSGD.js} +10 -8
  100. package/dist/hooks/postrun.js +12 -14
  101. package/dist/hooks/prerun.js +8 -11
  102. package/dist/index.js +7811 -7490
  103. package/dist/{local-7IRDZWLW.js → local-UQAQKOVL.js} +4 -4
  104. package/dist/{morph-6NYGHGNT.js → morph-DN4AZJZW.js} +9 -9
  105. package/dist/{node-UIH7JP3D.js → node-GZYZUMBW.js} +21 -19
  106. package/dist/{node-package-manager-2LWT2MNN.js → node-package-manager-AOVZD6TP.js} +5 -6
  107. package/dist/{path-JVVXOELJ.js → path-KUSF6CYC.js} +2 -2
  108. package/dist/{system-4HHX42JS.js → system-G7DVECOP.js} +4 -4
  109. package/dist/templates/ui-extensions/projects/web_pixel_extension/package.json.liquid +1 -1
  110. package/dist/tsconfig.tsbuildinfo +1 -1
  111. package/dist/{ui-NFBKMC4P.js → ui-2AOZFYFM.js} +4 -4
  112. package/dist/{workerd-4HFD3PS4.js → workerd-2MO23YDQ.js} +22 -19
  113. package/oclif.manifest.json +265 -4
  114. package/package.json +7 -10
  115. package/dist/assets/dev-console/extensions/dev-console/assets/index-Bi7y6lI5.css +0 -1
  116. package/dist/assets/hydrogen/css-modules/package.json +0 -6
  117. package/dist/assets/hydrogen/postcss/package.json +0 -10
  118. package/dist/assets/hydrogen/postcss/postcss.config.js +0 -8
  119. package/dist/assets/hydrogen/starter/.graphqlrc.yml +0 -12
  120. package/dist/assets/hydrogen/starter/app/components/Cart.tsx +0 -364
  121. package/dist/assets/hydrogen/tailwind/postcss.config.js +0 -10
  122. package/dist/assets/hydrogen/tailwind/tailwind.config.js +0 -8
  123. package/dist/chunk-4WBV3WP3.js +0 -221
  124. package/dist/chunk-OWICSMFV.js +0 -12
  125. package/dist/chunk-QCDYZY46.js +0 -1070
  126. package/dist/chunk-QEKTVN5A.js +0 -4385
  127. package/dist/chunk-QOUOFEGO.js +0 -35
  128. package/dist/chunk-WP234IUO.js +0 -265
  129. package/dist/chunk-XLPMGRR3.js +0 -496
  130. package/dist/chunk-XSKJYEAZ.js +0 -1453
  131. package/dist/error-handler-QDDLQDOJ.js +0 -43
@@ -1,364 +0,0 @@
1
- import {
2
- CartForm,
3
- Image,
4
- Money,
5
- useOptimisticCart,
6
- type OptimisticCart,
7
- } from '@shopify/hydrogen';
8
- import type {CartLineUpdateInput} from '@shopify/hydrogen/storefront-api-types';
9
- import {Link} from '@remix-run/react';
10
- import type {CartApiQueryFragment} from 'storefrontapi.generated';
11
- import {useVariantUrl} from '~/lib/variants';
12
-
13
- type CartLine = OptimisticCart<CartApiQueryFragment>['lines']['nodes'][0];
14
-
15
- type CartMainProps = {
16
- cart: CartApiQueryFragment | null;
17
- layout: 'page' | 'aside';
18
- };
19
-
20
- export function CartMain({layout, cart: originalCart}: CartMainProps) {
21
- const cart = useOptimisticCart(originalCart);
22
-
23
- const linesCount = Boolean(cart?.lines?.nodes?.length || 0);
24
- const withDiscount =
25
- cart &&
26
- Boolean(cart?.discountCodes?.filter((code) => code.applicable)?.length);
27
- const className = `cart-main ${withDiscount ? 'with-discount' : ''}`;
28
-
29
- return (
30
- <div className={className}>
31
- <CartEmpty hidden={linesCount} layout={layout} />
32
- <CartDetails cart={cart} layout={layout} />
33
- </div>
34
- );
35
- }
36
-
37
- function CartDetails({
38
- layout,
39
- cart,
40
- }: {
41
- cart: OptimisticCart<CartApiQueryFragment>;
42
- layout: 'page' | 'aside';
43
- }) {
44
- const cartHasItems = !!cart && cart.totalQuantity > 0;
45
-
46
- return (
47
- <div className="cart-details">
48
- <CartLines lines={cart?.lines?.nodes} layout={layout} />
49
- {cartHasItems && (
50
- <CartSummary cost={cart.cost} layout={layout}>
51
- <CartDiscounts discountCodes={cart.discountCodes} />
52
- <CartCheckoutActions checkoutUrl={cart.checkoutUrl} />
53
- </CartSummary>
54
- )}
55
- </div>
56
- );
57
- }
58
-
59
- function CartLines({
60
- lines,
61
- layout,
62
- }: {
63
- layout: CartMainProps['layout'];
64
- lines: CartLine[];
65
- }) {
66
- if (!lines) return null;
67
-
68
- return (
69
- <div aria-labelledby="cart-lines">
70
- <ul>
71
- {lines.map((line) => (
72
- <CartLineItem key={line.id} line={line} layout={layout} />
73
- ))}
74
- </ul>
75
- </div>
76
- );
77
- }
78
-
79
- function CartLineItem({
80
- layout,
81
- line,
82
- }: {
83
- layout: CartMainProps['layout'];
84
- line: CartLine;
85
- }) {
86
- const {id, merchandise} = line;
87
- const {product, title, image, selectedOptions} = merchandise;
88
- const lineItemUrl = useVariantUrl(product.handle, selectedOptions);
89
-
90
- return (
91
- <li key={id} className="cart-line">
92
- {image && (
93
- <Image
94
- alt={title}
95
- aspectRatio="1/1"
96
- data={image}
97
- height={100}
98
- loading="lazy"
99
- width={100}
100
- />
101
- )}
102
-
103
- <div>
104
- <Link
105
- prefetch="intent"
106
- to={lineItemUrl}
107
- onClick={() => {
108
- if (layout === 'aside') {
109
- // close the drawer
110
- window.location.href = lineItemUrl;
111
- }
112
- }}
113
- >
114
- <p>
115
- <strong>{product.title}</strong>
116
- </p>
117
- </Link>
118
- <CartLinePrice line={line} as="span" />
119
- <ul>
120
- {selectedOptions.map((option) => (
121
- <li key={option.name}>
122
- <small>
123
- {option.name}: {option.value}
124
- </small>
125
- </li>
126
- ))}
127
- </ul>
128
- <CartLineQuantity line={line} />
129
- </div>
130
- </li>
131
- );
132
- }
133
-
134
- function CartCheckoutActions({checkoutUrl}: {checkoutUrl: string}) {
135
- if (!checkoutUrl) return null;
136
-
137
- return (
138
- <div>
139
- <a href={checkoutUrl} target="_self">
140
- <p>Continue to Checkout &rarr;</p>
141
- </a>
142
- <br />
143
- </div>
144
- );
145
- }
146
-
147
- export function CartSummary({
148
- cost,
149
- layout,
150
- children = null,
151
- }: {
152
- children?: React.ReactNode;
153
- cost: CartApiQueryFragment['cost'];
154
- layout: CartMainProps['layout'];
155
- }) {
156
- const className =
157
- layout === 'page' ? 'cart-summary-page' : 'cart-summary-aside';
158
-
159
- return (
160
- <div aria-labelledby="cart-summary" className={className}>
161
- <h4>Totals</h4>
162
- <dl className="cart-subtotal">
163
- <dt>Subtotal</dt>
164
- <dd>
165
- {cost?.subtotalAmount?.amount ? (
166
- <Money data={cost?.subtotalAmount} />
167
- ) : (
168
- '-'
169
- )}
170
- </dd>
171
- </dl>
172
- {children}
173
- </div>
174
- );
175
- }
176
-
177
- function CartLineRemoveButton({
178
- lineIds,
179
- disabled,
180
- }: {
181
- lineIds: string[];
182
- disabled: boolean;
183
- }) {
184
- return (
185
- <CartForm
186
- route="/cart"
187
- action={CartForm.ACTIONS.LinesRemove}
188
- inputs={{lineIds}}
189
- >
190
- <button disabled={disabled} type="submit">
191
- Remove
192
- </button>
193
- </CartForm>
194
- );
195
- }
196
-
197
- function CartLineQuantity({line}: {line: CartLine}) {
198
- if (!line || typeof line?.quantity === 'undefined') return null;
199
- const {id: lineId, quantity, isOptimistic} = line;
200
- const prevQuantity = Number(Math.max(0, quantity - 1).toFixed(0));
201
- const nextQuantity = Number((quantity + 1).toFixed(0));
202
-
203
- return (
204
- <div className="cart-line-quantity">
205
- <small>Quantity: {quantity} &nbsp;&nbsp;</small>
206
- <CartLineUpdateButton lines={[{id: lineId, quantity: prevQuantity}]}>
207
- <button
208
- aria-label="Decrease quantity"
209
- disabled={quantity <= 1 || !!isOptimistic}
210
- name="decrease-quantity"
211
- value={prevQuantity}
212
- >
213
- <span>&#8722; </span>
214
- </button>
215
- </CartLineUpdateButton>
216
- &nbsp;
217
- <CartLineUpdateButton lines={[{id: lineId, quantity: nextQuantity}]}>
218
- <button
219
- aria-label="Increase quantity"
220
- name="increase-quantity"
221
- value={nextQuantity}
222
- disabled={!!isOptimistic}
223
- >
224
- <span>&#43;</span>
225
- </button>
226
- </CartLineUpdateButton>
227
- &nbsp;
228
- <CartLineRemoveButton lineIds={[lineId]} disabled={!!isOptimistic} />
229
- </div>
230
- );
231
- }
232
-
233
- function CartLinePrice({
234
- line,
235
- priceType = 'regular',
236
- ...passthroughProps
237
- }: {
238
- line: CartLine;
239
- priceType?: 'regular' | 'compareAt';
240
- [key: string]: any;
241
- }) {
242
- if (!line?.cost?.amountPerQuantity || !line?.cost?.totalAmount)
243
- return <div style={{visibility: 'hidden'}}>&nbsp;</div>;
244
-
245
- const moneyV2 =
246
- priceType === 'regular'
247
- ? line.cost.totalAmount
248
- : line.cost.compareAtAmountPerQuantity;
249
-
250
- if (moneyV2 == null) {
251
- return <div style={{visibility: 'hidden'}}>&nbsp;</div>;
252
- }
253
-
254
- return (
255
- <div>
256
- <Money withoutTrailingZeros {...passthroughProps} data={moneyV2} />
257
- </div>
258
- );
259
- }
260
-
261
- export function CartEmpty({
262
- hidden = false,
263
- layout = 'aside',
264
- }: {
265
- hidden: boolean;
266
- layout?: CartMainProps['layout'];
267
- }) {
268
- return (
269
- <div hidden={hidden}>
270
- <br />
271
- <p>
272
- Looks like you haven&rsquo;t added anything yet, let&rsquo;s get you
273
- started!
274
- </p>
275
- <br />
276
- <Link
277
- to="/collections"
278
- onClick={() => {
279
- if (layout === 'aside') {
280
- window.location.href = '/collections';
281
- }
282
- }}
283
- >
284
- Continue shopping →
285
- </Link>
286
- </div>
287
- );
288
- }
289
-
290
- function CartDiscounts({
291
- discountCodes,
292
- }: {
293
- discountCodes: CartApiQueryFragment['discountCodes'];
294
- }) {
295
- const codes: string[] =
296
- discountCodes
297
- ?.filter((discount) => discount.applicable)
298
- ?.map(({code}) => code) || [];
299
-
300
- return (
301
- <div>
302
- {/* Have existing discount, display it with a remove option */}
303
- <dl hidden={!codes.length}>
304
- <div>
305
- <dt>Discount(s)</dt>
306
- <UpdateDiscountForm>
307
- <div className="cart-discount">
308
- <code>{codes?.join(', ')}</code>
309
- &nbsp;
310
- <button>Remove</button>
311
- </div>
312
- </UpdateDiscountForm>
313
- </div>
314
- </dl>
315
-
316
- {/* Show an input to apply a discount */}
317
- <UpdateDiscountForm discountCodes={codes}>
318
- <div>
319
- <input type="text" name="discountCode" placeholder="Discount code" />
320
- &nbsp;
321
- <button type="submit">Apply</button>
322
- </div>
323
- </UpdateDiscountForm>
324
- </div>
325
- );
326
- }
327
-
328
- function UpdateDiscountForm({
329
- discountCodes,
330
- children,
331
- }: {
332
- discountCodes?: string[];
333
- children: React.ReactNode;
334
- }) {
335
- return (
336
- <CartForm
337
- route="/cart"
338
- action={CartForm.ACTIONS.DiscountCodesUpdate}
339
- inputs={{
340
- discountCodes: discountCodes || [],
341
- }}
342
- >
343
- {children}
344
- </CartForm>
345
- );
346
- }
347
-
348
- function CartLineUpdateButton({
349
- children,
350
- lines,
351
- }: {
352
- children: React.ReactNode;
353
- lines: CartLineUpdateInput[];
354
- }) {
355
- return (
356
- <CartForm
357
- route="/cart"
358
- action={CartForm.ACTIONS.LinesUpdate}
359
- inputs={{lines}}
360
- >
361
- {children}
362
- </CartForm>
363
- );
364
- }
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- plugins: {
3
- 'postcss-import': {},
4
- 'tailwindcss/nesting': {},
5
- tailwindcss: {},
6
- 'postcss-preset-env': {
7
- features: {'nesting-rules': false},
8
- },
9
- },
10
- };
@@ -1,8 +0,0 @@
1
- import formsPlugin from '@tailwindcss/forms';
2
- import typographyPlugin from '@tailwindcss/typography';
3
-
4
- /** @type {import('tailwindcss').Config} */
5
- export default {
6
- content: ['./{src-dir}/**/*.{js,ts,jsx,tsx}'],
7
- plugins: [formsPlugin, typographyPlugin],
8
- };
@@ -1,221 +0,0 @@
1
- import {
2
- require_notifier
3
- } from "./chunk-S4VBXFXP.js";
4
- import {
5
- fanoutHooks,
6
- reportAnalyticsEvent
7
- } from "./chunk-QCDYZY46.js";
8
- import {
9
- getEnvironmentData
10
- } from "./chunk-VQTHQBEC.js";
11
- import {
12
- CLI_KIT_VERSION
13
- } from "./chunk-OWICSMFV.js";
14
- import {
15
- AbortSilentError,
16
- CancelExecution,
17
- cleanSingleStackTracePath,
18
- errorMapper,
19
- getAllPublicMetadata,
20
- getAllSensitiveMetadata,
21
- handler,
22
- outputDebug,
23
- outputInfo,
24
- printEventsJson,
25
- require_stacktracey,
26
- shouldReportError
27
- } from "./chunk-3MDI6LZT.js";
28
- import {
29
- bugsnagApiKey
30
- } from "./chunk-WADS2TV5.js";
31
- import {
32
- require_lib
33
- } from "./chunk-GEN4RXTD.js";
34
- import {
35
- cwd,
36
- isAbsolutePath,
37
- joinPath,
38
- normalizePath,
39
- relativePath
40
- } from "./chunk-UNPXLODI.js";
41
- import {
42
- __toESM,
43
- init_cjs_shims
44
- } from "./chunk-ZPL24Y2D.js";
45
-
46
- // ../cli-kit/src/public/node/error-handler.ts
47
- init_cjs_shims();
48
- var import_core = __toESM(require_lib(), 1);
49
- var import_stacktracey = __toESM(require_stacktracey(), 1);
50
- var import_js = __toESM(require_notifier(), 1);
51
- import { realpath } from "fs/promises";
52
- async function errorHandler(error, config) {
53
- if (error instanceof CancelExecution) {
54
- if (error.message && error.message !== "") {
55
- outputInfo(`\u2728 ${error.message}`);
56
- }
57
- } else if (error instanceof AbortSilentError) {
58
- printEventsJson();
59
- } else {
60
- return errorMapper(error).then((error2) => {
61
- return handler(error2);
62
- }).then((mappedError) => {
63
- printEventsJson();
64
- return reportError(mappedError, config);
65
- });
66
- }
67
- }
68
- var reportError = async (error, config) => {
69
- let exitMode = "expected_error";
70
- if (shouldReportError(error))
71
- exitMode = "unexpected_error";
72
- if (config !== void 0) {
73
- await reportAnalyticsEvent({ config, errorMessage: error instanceof Error ? error.message : void 0, exitMode });
74
- }
75
- await sendErrorToBugsnag(error, exitMode);
76
- };
77
- async function sendErrorToBugsnag(error, exitMode) {
78
- if (import_core.settings.debug) {
79
- outputDebug(`Skipping Bugsnag report`);
80
- return { reported: false, error, unhandled: void 0 };
81
- }
82
- const unhandled = exitMode === "unexpected_error";
83
- let reportableError;
84
- let stacktrace;
85
- let report = false;
86
- if (error instanceof Error) {
87
- report = true;
88
- reportableError = new Error(error.message);
89
- stacktrace = error.stack;
90
- } else if (typeof error === "string" && error.trim().length !== 0) {
91
- report = true;
92
- reportableError = new Error(error);
93
- stacktrace = reportableError.stack;
94
- } else {
95
- report = false;
96
- reportableError = new Error("Unknown error");
97
- }
98
- const formattedStacktrace = new import_stacktracey.default(stacktrace ?? "").clean().items.map((item) => {
99
- const filePath = cleanSingleStackTracePath(item.file);
100
- return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
101
- }).join("\n");
102
- reportableError.stack = `Error: ${reportableError.message}
103
- ${formattedStacktrace}`;
104
- if (report) {
105
- initializeBugsnag();
106
- await new Promise((resolve, reject) => {
107
- outputDebug(`Reporting ${unhandled ? "unhandled" : "handled"} error to Bugsnag: ${reportableError.message}`);
108
- const eventHandler = (event) => {
109
- event.severity = "error";
110
- event.unhandled = unhandled;
111
- };
112
- const errorHandler2 = (error2) => {
113
- if (error2) {
114
- reject(error2);
115
- } else {
116
- resolve(reportableError);
117
- }
118
- };
119
- import_js.default.notify(reportableError, eventHandler, errorHandler2);
120
- });
121
- }
122
- return { error: reportableError, reported: report, unhandled };
123
- }
124
- function cleanStackFrameFilePath({
125
- currentFilePath,
126
- projectRoot,
127
- pluginLocations
128
- }) {
129
- const fullLocation = isAbsolutePath(currentFilePath) ? currentFilePath : joinPath(projectRoot, currentFilePath);
130
- const matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.indexOf(pluginPath) === 0)[0];
131
- if (matchingPluginPath !== void 0) {
132
- return joinPath(matchingPluginPath.name, relativePath(matchingPluginPath.pluginPath, fullLocation));
133
- }
134
- return currentFilePath.replace(/.*node_modules\//, "");
135
- }
136
- async function registerCleanBugsnagErrorsFromWithinPlugins(config) {
137
- const bugsnagConfigProjectRoot = import_js.default?._client?._config?.projectRoot ?? cwd();
138
- const projectRoot = normalizePath(bugsnagConfigProjectRoot);
139
- const pluginLocations = await Promise.all(
140
- [...config.plugins].map(async ([_, plugin]) => {
141
- const followSymlinks = await realpath(plugin.root);
142
- return { name: plugin.name, pluginPath: normalizePath(followSymlinks) };
143
- })
144
- );
145
- initializeBugsnag();
146
- import_js.default.addOnError(async (event) => {
147
- event.errors.forEach((error) => {
148
- error.stacktrace.forEach((stackFrame) => {
149
- stackFrame.file = cleanStackFrameFilePath({ currentFilePath: stackFrame.file, projectRoot, pluginLocations });
150
- });
151
- });
152
- try {
153
- await addBugsnagMetadata(event, config);
154
- } catch (metadataError) {
155
- outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`);
156
- }
157
- });
158
- }
159
- async function addBugsnagMetadata(event, config) {
160
- const publicData = getAllPublicMetadata();
161
- const { commandStartOptions } = getAllSensitiveMetadata();
162
- const { startCommand } = commandStartOptions ?? {};
163
- const { "@shopify/app": appPublic, ...otherPluginsPublic } = await fanoutHooks(config, "public_command_metadata", {});
164
- const environment = await getEnvironmentData(config);
165
- const allMetadata = {
166
- command: startCommand,
167
- ...appPublic,
168
- ...publicData,
169
- ...environment,
170
- pluginData: otherPluginsPublic
171
- };
172
- const appData = {};
173
- const commandData = {};
174
- const environmentData = {};
175
- const miscData = {};
176
- const appKeys = ["api_key", "partner_id", "project_type"];
177
- const commandKeys = ["command"];
178
- const environmentKeys = ["cli_version", "node_version", "ruby_version", "uname"];
179
- Object.entries(allMetadata).forEach(([key, value]) => {
180
- if (key.startsWith("app_") || appKeys.includes(key)) {
181
- appData[key] = value;
182
- } else if (key.startsWith("cmd_") || commandKeys.includes(key)) {
183
- commandData[key] = value;
184
- } else if (key.startsWith("env_") || environmentKeys) {
185
- environmentData[key] = value;
186
- } else {
187
- miscData[key] = value;
188
- }
189
- });
190
- const bugsnagMetadata = {
191
- "Shopify App": appData,
192
- Command: commandData,
193
- Environment: environmentData,
194
- Misc: miscData
195
- };
196
- Object.entries(bugsnagMetadata).forEach(([section, values]) => {
197
- event.addMetadata(section, values);
198
- });
199
- }
200
- function initializeBugsnag() {
201
- if (import_js.default.isStarted()) {
202
- return;
203
- }
204
- import_js.default.start({
205
- appType: "node",
206
- apiKey: bugsnagApiKey,
207
- logger: null,
208
- appVersion: CLI_KIT_VERSION,
209
- autoTrackSessions: false,
210
- autoDetectErrors: false
211
- });
212
- }
213
-
214
- export {
215
- errorHandler,
216
- sendErrorToBugsnag,
217
- cleanStackFrameFilePath,
218
- registerCleanBugsnagErrorsFromWithinPlugins,
219
- addBugsnagMetadata
220
- };
221
- //# sourceMappingURL=chunk-4WBV3WP3.js.map
@@ -1,12 +0,0 @@
1
- import {
2
- init_cjs_shims
3
- } from "./chunk-ZPL24Y2D.js";
4
-
5
- // ../cli-kit/src/public/common/version.ts
6
- init_cjs_shims();
7
- var CLI_KIT_VERSION = "3.63.2";
8
-
9
- export {
10
- CLI_KIT_VERSION
11
- };
12
- //# sourceMappingURL=chunk-OWICSMFV.js.map