@shopify/cli-hydrogen 6.0.2 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/hydrogen/build.js +40 -78
- package/dist/commands/hydrogen/codegen.js +8 -3
- package/dist/commands/hydrogen/deploy.js +173 -37
- package/dist/commands/hydrogen/deploy.test.js +192 -20
- package/dist/commands/hydrogen/dev.js +56 -31
- package/dist/commands/hydrogen/init.js +1 -1
- package/dist/commands/hydrogen/init.test.js +155 -53
- package/dist/commands/hydrogen/link.js +5 -21
- package/dist/commands/hydrogen/link.test.js +10 -10
- package/dist/commands/hydrogen/preview.js +22 -11
- package/dist/commands/hydrogen/setup.js +0 -4
- package/dist/commands/hydrogen/setup.test.js +0 -1
- package/dist/commands/hydrogen/shortcut.js +1 -0
- package/dist/commands/hydrogen/upgrade.js +720 -0
- package/dist/commands/hydrogen/upgrade.test.js +786 -0
- package/dist/generator-templates/starter/.graphqlrc.yml +12 -1
- package/dist/generator-templates/starter/CHANGELOG.md +126 -0
- package/dist/generator-templates/starter/README.md +23 -0
- package/dist/generator-templates/starter/app/components/Cart.tsx +1 -1
- package/dist/generator-templates/starter/app/components/Footer.tsx +3 -1
- package/dist/generator-templates/starter/app/components/Header.tsx +5 -1
- package/dist/generator-templates/starter/app/components/Layout.tsx +14 -11
- package/dist/generator-templates/starter/app/components/Search.tsx +1 -1
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerAddressMutations.ts +61 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +39 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrderQuery.ts +87 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrdersQuery.ts +58 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerUpdateMutation.ts +24 -0
- package/dist/generator-templates/starter/app/lib/fragments.ts +102 -0
- package/dist/generator-templates/starter/app/lib/session.ts +67 -0
- package/dist/generator-templates/starter/app/root.tsx +11 -45
- package/dist/generator-templates/starter/app/routes/[robots.txt].tsx +0 -27
- package/dist/generator-templates/starter/app/routes/account.$.tsx +8 -4
- package/dist/generator-templates/starter/app/routes/account._index.tsx +5 -0
- package/dist/generator-templates/starter/app/routes/account.addresses.tsx +215 -206
- package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +56 -163
- package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +32 -109
- package/dist/generator-templates/starter/app/routes/account.profile.tsx +40 -180
- package/dist/generator-templates/starter/app/routes/account.tsx +20 -135
- package/dist/generator-templates/starter/app/routes/account_.authorize.tsx +5 -0
- package/dist/generator-templates/starter/app/routes/account_.login.tsx +3 -140
- package/dist/generator-templates/starter/app/routes/account_.logout.tsx +5 -24
- package/dist/generator-templates/starter/app/routes/cart.tsx +7 -5
- package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +1 -1
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/search.tsx +1 -1
- package/dist/generator-templates/starter/customer-accountapi.generated.d.ts +506 -0
- package/dist/generator-templates/starter/package.json +11 -10
- package/dist/generator-templates/starter/remix.config.js +4 -0
- package/dist/generator-templates/starter/remix.env.d.ts +6 -11
- package/dist/generator-templates/starter/server.ts +24 -167
- package/dist/generator-templates/starter/storefrontapi.generated.d.ts +104 -881
- package/dist/hooks/init.js +4 -4
- package/dist/lib/auth.js +5 -10
- package/dist/lib/build.js +6 -1
- package/dist/lib/bundle/analyzer.js +36 -26
- package/dist/lib/check-lockfile.js +1 -0
- package/dist/lib/codegen.js +59 -18
- package/dist/lib/defer.js +12 -0
- package/dist/lib/file.js +52 -3
- package/dist/lib/flags.js +27 -9
- package/dist/lib/get-oxygen-deployment-data.test.js +4 -2
- package/dist/lib/graphql/admin/client.test.js +2 -2
- package/dist/lib/graphql/admin/get-oxygen-data.js +1 -0
- package/dist/lib/log.js +32 -14
- package/dist/lib/mini-oxygen/assets.js +118 -0
- package/dist/lib/mini-oxygen/common.js +2 -1
- package/dist/lib/mini-oxygen/index.js +7 -5
- package/dist/lib/mini-oxygen/mini-oxygen.test.js +214 -0
- package/dist/lib/mini-oxygen/node.js +19 -5
- package/dist/lib/mini-oxygen/workerd-inspector-logs.js +227 -0
- package/dist/lib/mini-oxygen/workerd-inspector-proxy.js +200 -0
- package/dist/lib/mini-oxygen/workerd-inspector.js +62 -235
- package/dist/lib/mini-oxygen/workerd.js +74 -50
- package/dist/lib/missing-routes.js +6 -3
- package/dist/lib/onboarding/common.js +40 -9
- package/dist/lib/onboarding/local.js +19 -11
- package/dist/lib/onboarding/remote.js +48 -28
- package/dist/lib/render-errors.js +2 -0
- package/dist/lib/request-events.js +65 -31
- package/dist/lib/setups/css/assets.js +1 -46
- package/dist/lib/setups/css/css-modules.js +3 -2
- package/dist/lib/setups/css/postcss.js +4 -2
- package/dist/lib/setups/css/tailwind.js +4 -2
- package/dist/lib/setups/css/vanilla-extract.js +3 -2
- package/dist/lib/setups/i18n/replacers.test.js +56 -38
- package/dist/lib/shell.js +1 -1
- package/dist/lib/template-diff.js +89 -0
- package/dist/lib/template-downloader.js +3 -2
- package/dist/lib/transpile/project.js +1 -1
- package/dist/virtual-routes/assets/debug-network.css +592 -0
- package/dist/virtual-routes/assets/favicon-dark.svg +20 -0
- package/dist/virtual-routes/components/FlameChartWrapper.jsx +8 -10
- package/dist/virtual-routes/components/IconClose.jsx +38 -0
- package/dist/virtual-routes/components/IconDiscard.jsx +44 -0
- package/dist/virtual-routes/components/RequestDetails.jsx +179 -0
- package/dist/virtual-routes/components/RequestTable.jsx +92 -0
- package/dist/virtual-routes/components/RequestWaterfall.jsx +151 -0
- package/dist/virtual-routes/lib/useDebugNetworkServer.jsx +176 -0
- package/dist/virtual-routes/routes/subrequest-profiler.jsx +243 -0
- package/oclif.manifest.json +134 -59
- package/package.json +18 -26
- package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +0 -161
- package/dist/generator-templates/starter/app/routes/account_.recover.tsx +0 -129
- package/dist/generator-templates/starter/app/routes/account_.register.tsx +0 -207
- package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +0 -136
- package/dist/virtual-routes/routes/debug-network.jsx +0 -289
- /package/dist/generator-templates/starter/app/{utils.ts → lib/variants.ts} +0 -0
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
projects:
|
|
2
|
+
default:
|
|
3
|
+
schema: 'node_modules/@shopify/hydrogen/storefront.schema.json'
|
|
4
|
+
documents:
|
|
5
|
+
- '!*.d.ts'
|
|
6
|
+
- '*.{ts,tsx,js,jsx}'
|
|
7
|
+
- 'app/**/*.{ts,tsx,js,jsx}'
|
|
8
|
+
- '!app/graphql/**/*.{ts,tsx,js,jsx}'
|
|
9
|
+
customer-account:
|
|
10
|
+
schema: 'node_modules/@shopify/hydrogen/customer-account.schema.json'
|
|
11
|
+
documents:
|
|
12
|
+
- 'app/graphql/customer-account/**/*.{ts,tsx,js,jsx}'
|
|
@@ -1,5 +1,131 @@
|
|
|
1
1
|
# skeleton
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Use new parameters introduced in Storefront API v2024-01 to fix redirection to the product's default variant when there are unknown query params in the URL. ([#1642](https://github.com/Shopify/hydrogen/pull/1642)) by [@wizardlyhel](https://github.com/wizardlyhel)
|
|
8
|
+
|
|
9
|
+
```diff
|
|
10
|
+
- selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions) {
|
|
11
|
+
+ selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions, ignoreUnknownOptions: true, caseInsensitiveMatch: true) {
|
|
12
|
+
...ProductVariant
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Update the GraphQL config in `.graphqlrc.yml` to use the more modern `projects` structure: ([#1577](https://github.com/Shopify/hydrogen/pull/1577)) by [@frandiox](https://github.com/frandiox)
|
|
17
|
+
|
|
18
|
+
```diff
|
|
19
|
+
-schema: node_modules/@shopify/hydrogen/storefront.schema.json
|
|
20
|
+
+projects:
|
|
21
|
+
+ default:
|
|
22
|
+
+ schema: 'node_modules/@shopify/hydrogen/storefront.schema.json'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This allows you to add additional projects to the GraphQL config, such as third party CMS schemas.
|
|
26
|
+
|
|
27
|
+
Also, you can modify the document paths used for the Storefront API queries. This is useful if you have a large codebase and want to exclude certain files from being used for codegen or other GraphQL utilities:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
projects:
|
|
31
|
+
default:
|
|
32
|
+
schema: 'node_modules/@shopify/hydrogen/storefront.schema.json'
|
|
33
|
+
documents:
|
|
34
|
+
- '!*.d.ts'
|
|
35
|
+
- '*.{ts,tsx,js,jsx}'
|
|
36
|
+
- 'app/**/*.{ts,tsx,js,jsx}'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- Improve resiliency of `HydrogenSession` ([#1583](https://github.com/Shopify/hydrogen/pull/1583)) by [@blittle](https://github.com/blittle)
|
|
40
|
+
|
|
41
|
+
- Update `@shopify/cli` dependency in `package.json`: ([#1579](https://github.com/Shopify/hydrogen/pull/1579)) by [@frandiox](https://github.com/frandiox)
|
|
42
|
+
|
|
43
|
+
```diff
|
|
44
|
+
- "@shopify/cli": "3.51.0",
|
|
45
|
+
+ "@shopify/cli": "3.52.0",
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- - Update example and template Remix versions to `^2.5.1` ([#1639](https://github.com/Shopify/hydrogen/pull/1639)) by [@wizardlyhel](https://github.com/wizardlyhel)
|
|
49
|
+
|
|
50
|
+
- Enable Remix future flags:
|
|
51
|
+
- [`v3_fetcherPersist`](https://remix.run/docs/en/main/hooks/use-fetchers#additional-resources)
|
|
52
|
+
- [`v3_relativeSplatpath`](https://remix.run/docs/en/main/hooks/use-resolved-path#splat-paths)
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [[`810f48cf`](https://github.com/Shopify/hydrogen/commit/810f48cf5d55f0cfcac6e01fe481db8c76e77cd2), [`8c477cb5`](https://github.com/Shopify/hydrogen/commit/8c477cb565c3e018bf4e13bad01804c21611fb8a), [`42ac4138`](https://github.com/Shopify/hydrogen/commit/42ac4138553c7e1a438b075c4f9cb781edffebc4), [`0241b7d2`](https://github.com/Shopify/hydrogen/commit/0241b7d2dcb887d259ce9033aca356d391bc07df), [`6a897586`](https://github.com/Shopify/hydrogen/commit/6a897586bd0908db90736921d11e4b6bdf29c912), [`0ff63bed`](https://github.com/Shopify/hydrogen/commit/0ff63bed840f5b8a5eb9968b67bd9a5a57099253), [`6bc1d61c`](https://github.com/Shopify/hydrogen/commit/6bc1d61c17a9c9be13f52338d2ab940e64e73495), [`eb0f4bcc`](https://github.com/Shopify/hydrogen/commit/eb0f4bccb57966a00ecb2b88d17dd694599da340), [`400bfee6`](https://github.com/Shopify/hydrogen/commit/400bfee6836a51c6ab5e4804e8b1e9ad48856dcb), [`a69c21ca`](https://github.com/Shopify/hydrogen/commit/a69c21caa15dfedb88afd50f262f17bf86f74836), [`970073e7`](https://github.com/Shopify/hydrogen/commit/970073e78258880505e0de563136b5379d5d24af), [`772118ca`](https://github.com/Shopify/hydrogen/commit/772118ca6aefbd47841fffc6ce42856c2dc779bd), [`335375a6`](https://github.com/Shopify/hydrogen/commit/335375a6b1a512f70e169a82bc87a8392dc8c92c), [`335371ce`](https://github.com/Shopify/hydrogen/commit/335371ceb6e1bd5aebb6104f131d3f22798a245f), [`94509b75`](https://github.com/Shopify/hydrogen/commit/94509b750afefd686971198ed86277e2c70f3176), [`36d6fa2c`](https://github.com/Shopify/hydrogen/commit/36d6fa2c4fa54ff79f06ef17aa41f60478977bc0), [`3e7b6e8a`](https://github.com/Shopify/hydrogen/commit/3e7b6e8a3bf66bad7fc0f9c224f1c163dbe3e288), [`cce65795`](https://github.com/Shopify/hydrogen/commit/cce6579580f849bec9a28cf575f7130ba3627f6b), [`9e3d88d4`](https://github.com/Shopify/hydrogen/commit/9e3d88d498efaa20fe23de9837e0f444180bc787), [`ca1161b2`](https://github.com/Shopify/hydrogen/commit/ca1161b29ad7b4d0838953782fb114d5fe82193a), [`92840e51`](https://github.com/Shopify/hydrogen/commit/92840e51820e5c7822f731affd3f591c0099be10), [`952fedf2`](https://github.com/Shopify/hydrogen/commit/952fedf27b869164550954d1c15f53b32ec02675), [`1bc053c9`](https://github.com/Shopify/hydrogen/commit/1bc053c94ba1be14ddc28be9eb70be7219b295d1)]:
|
|
55
|
+
- @shopify/hydrogen@2024.1.0
|
|
56
|
+
- @shopify/cli-hydrogen@7.0.0
|
|
57
|
+
- @shopify/remix-oxygen@2.0.3
|
|
58
|
+
|
|
59
|
+
## 1.0.1
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Sync up environment variable names across all example & type files. ([#1542](https://github.com/Shopify/hydrogen/pull/1542)) by [@michenly](https://github.com/michenly)
|
|
64
|
+
|
|
65
|
+
- Remove error boundary from robots.txt file in the Skeleton template ([#1492](https://github.com/Shopify/hydrogen/pull/1492)) by [@andrewcohen](https://github.com/andrewcohen)
|
|
66
|
+
|
|
67
|
+
- Use the worker runtime by default when running the `dev` or `preview` commands. ([#1525](https://github.com/Shopify/hydrogen/pull/1525)) by [@frandiox](https://github.com/frandiox)
|
|
68
|
+
|
|
69
|
+
Enable it in your project by adding the `--worker` flag to your package.json scripts:
|
|
70
|
+
|
|
71
|
+
```diff
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "shopify hydrogen build",
|
|
74
|
+
- "dev": "shopify hydrogen dev --codegen",
|
|
75
|
+
+ "dev": "shopify hydrogen dev --worker --codegen",
|
|
76
|
+
- "preview": "npm run build && shopify hydrogen preview",
|
|
77
|
+
+ "preview": "npm run build && shopify hydrogen preview --worker",
|
|
78
|
+
...
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Update to the latest version of `@shopify/oxygen-workers-types`. ([#1494](https://github.com/Shopify/hydrogen/pull/1494)) by [@frandiox](https://github.com/frandiox)
|
|
83
|
+
|
|
84
|
+
In TypeScript projects, when updating to the latest `@shopify/remix-oxygen` adapter release, you should also update to the latest version of `@shopify/oxygen-workers-types`:
|
|
85
|
+
|
|
86
|
+
```diff
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@remix-run/dev": "2.1.0",
|
|
89
|
+
"@remix-run/eslint-config": "2.1.0",
|
|
90
|
+
- "@shopify/oxygen-workers-types": "^3.17.3",
|
|
91
|
+
+ "@shopify/oxygen-workers-types": "^4.0.0",
|
|
92
|
+
"@shopify/prettier-config": "^1.1.2",
|
|
93
|
+
...
|
|
94
|
+
},
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- Update internal dependencies for bug resolution. ([#1496](https://github.com/Shopify/hydrogen/pull/1496)) by [@vincentezw](https://github.com/vincentezw)
|
|
98
|
+
|
|
99
|
+
Update your `@shopify/cli` dependency to avoid duplicated sub-dependencies:
|
|
100
|
+
|
|
101
|
+
```diff
|
|
102
|
+
"dependencies": {
|
|
103
|
+
- "@shopify/cli": "3.50.2",
|
|
104
|
+
+ "@shopify/cli": "3.51.0",
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Update all Node.js dependencies to version 18. (Not a breaking change, since Node.js 18 is already required by Remix v2.) ([#1543](https://github.com/Shopify/hydrogen/pull/1543)) by [@michenly](https://github.com/michenly)
|
|
109
|
+
|
|
110
|
+
- 🐛 fix undefined menu error ([#1533](https://github.com/Shopify/hydrogen/pull/1533)) by [@michenly](https://github.com/michenly)
|
|
111
|
+
|
|
112
|
+
- Add `@remix-run/server-runtime` dependency. ([#1489](https://github.com/Shopify/hydrogen/pull/1489)) by [@frandiox](https://github.com/frandiox)
|
|
113
|
+
|
|
114
|
+
Since Remix is now a peer dependency of `@shopify/remix-oxygen`, you need to add `@remix-run/server-runtime` to your dependencies, with the same version as the rest of your Remix dependencies.
|
|
115
|
+
|
|
116
|
+
```diff
|
|
117
|
+
"dependencies": {
|
|
118
|
+
"@remix-run/react": "2.1.0"
|
|
119
|
+
+ "@remix-run/server-runtime": "2.1.0"
|
|
120
|
+
...
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- Updated dependencies [[`b2a350a7`](https://github.com/Shopify/hydrogen/commit/b2a350a754ea2d29bc267c260dc298a02f8f4470), [`9b4f4534`](https://github.com/Shopify/hydrogen/commit/9b4f453407338874bd8f1a1f619b607670e021d0), [`74ea1dba`](https://github.com/Shopify/hydrogen/commit/74ea1dba9af37a146882df7ed9674be5659862b5), [`2be9ce82`](https://github.com/Shopify/hydrogen/commit/2be9ce82fd4a5121f1772bbb7349e96ed530e84e), [`a9b8bcde`](https://github.com/Shopify/hydrogen/commit/a9b8bcde96c22cedef7d87631d429199810b4a7a), [`bca112ed`](https://github.com/Shopify/hydrogen/commit/bca112ed7db49e533fe49898b663fa0dd318e6ba), [`848c6260`](https://github.com/Shopify/hydrogen/commit/848c6260a2db3a9cb0c86351f0f7128f61e028f0), [`d53b4ed7`](https://github.com/Shopify/hydrogen/commit/d53b4ed752eb0530622a666ea7dcf4b40239cafa), [`961fd8c6`](https://github.com/Shopify/hydrogen/commit/961fd8c630727784f77b9f693d2e8ff8601969fc), [`2bff9fc7`](https://github.com/Shopify/hydrogen/commit/2bff9fc75916fa95f9a9279d069408fb7a33755c), [`c8e8f6fd`](https://github.com/Shopify/hydrogen/commit/c8e8f6fd233e52cf5570b1904af710d6b907aae5), [`8fce70de`](https://github.com/Shopify/hydrogen/commit/8fce70de32bd61ee86a6d895ac43cc1f78f1bf49), [`f90e4d47`](https://github.com/Shopify/hydrogen/commit/f90e4d4713c6c1fc1e921a7ecd08e95fe5da1744), [`e8cc49fe`](https://github.com/Shopify/hydrogen/commit/e8cc49feff18f5ee72d5f6965ff2094addc23466)]:
|
|
125
|
+
- @shopify/cli-hydrogen@6.1.0
|
|
126
|
+
- @shopify/remix-oxygen@2.0.2
|
|
127
|
+
- @shopify/hydrogen@2023.10.3
|
|
128
|
+
|
|
3
129
|
## 1.0.0
|
|
4
130
|
|
|
5
131
|
### Major Changes
|
|
@@ -38,3 +38,26 @@ npm run build
|
|
|
38
38
|
```bash
|
|
39
39
|
npm run dev
|
|
40
40
|
```
|
|
41
|
+
|
|
42
|
+
## Setup for using Customer Account API (`/account` section)
|
|
43
|
+
|
|
44
|
+
### Setup public domain using ngrok
|
|
45
|
+
|
|
46
|
+
1. Setup a [ngrok](https://ngrok.com/) account and add a permanent domain (ie. `https://<your-ngrok-domain>.app`).
|
|
47
|
+
1. Install the [ngrok CLI](https://ngrok.com/download) to use in terminal
|
|
48
|
+
1. Start ngrok using `ngrok http --domain=<your-ngrok-domain>.app 3000`
|
|
49
|
+
|
|
50
|
+
### Include public domain in Customer Account API settings
|
|
51
|
+
|
|
52
|
+
1. Go to your Shopify admin => `Hydrogen` or `Headless` app/channel => Customer Account API => Application setup
|
|
53
|
+
1. Edit `Callback URI(s)` to include `https://<your-ngrok-domain>.app/account/authorize`
|
|
54
|
+
1. Edit `Javascript origin(s)` to include your public domain `https://<your-ngrok-domain>.app` or keep it blank
|
|
55
|
+
1. Edit `Logout URI` to include your public domain `https://<your-ngrok-domain>.app` or keep it blank
|
|
56
|
+
|
|
57
|
+
### Prepare Environment variables
|
|
58
|
+
|
|
59
|
+
Run [`npx shopify hydrogen link`](https://shopify.dev/docs/custom-storefronts/hydrogen/cli#link) or [`npx shopify hydrogen env pull`](https://shopify.dev/docs/custom-storefronts/hydrogen/cli#env-pull) to link this app to your own test shop.
|
|
60
|
+
|
|
61
|
+
Alternatly, the values of the required environment varaibles "PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID" and "PUBLIC_CUSTOMER_ACCOUNT_API_URL" can be found in customer account api settings in the Hydrogen admin channel.
|
|
62
|
+
|
|
63
|
+
🗒️ Note that mock.shop doesn't supply these variables automatically.
|
|
@@ -2,7 +2,7 @@ import {CartForm, Image, Money} from '@shopify/hydrogen';
|
|
|
2
2
|
import type {CartLineUpdateInput} from '@shopify/hydrogen/storefront-api-types';
|
|
3
3
|
import {Link} from '@remix-run/react';
|
|
4
4
|
import type {CartApiQueryFragment} from 'storefrontapi.generated';
|
|
5
|
-
import {useVariantUrl} from '~/
|
|
5
|
+
import {useVariantUrl} from '~/lib/variants';
|
|
6
6
|
|
|
7
7
|
type CartLine = CartApiQueryFragment['lines']['nodes'][0];
|
|
8
8
|
|
|
@@ -8,7 +8,9 @@ export function Footer({
|
|
|
8
8
|
}: FooterQuery & {shop: HeaderQuery['shop']}) {
|
|
9
9
|
return (
|
|
10
10
|
<footer className="footer">
|
|
11
|
-
|
|
11
|
+
{menu && shop?.primaryDomain?.url && (
|
|
12
|
+
<FooterMenu menu={menu} primaryDomainUrl={shop.primaryDomain.url} />
|
|
13
|
+
)}
|
|
12
14
|
</footer>
|
|
13
15
|
);
|
|
14
16
|
}
|
|
@@ -93,7 +93,11 @@ function HeaderCtas({
|
|
|
93
93
|
<nav className="header-ctas" role="navigation">
|
|
94
94
|
<HeaderMenuMobileToggle />
|
|
95
95
|
<NavLink prefetch="intent" to="/account" style={activeLinkStyle}>
|
|
96
|
-
|
|
96
|
+
<Suspense fallback="Sign in">
|
|
97
|
+
<Await resolve={isLoggedIn} errorElement="Sign in">
|
|
98
|
+
{(isLoggedIn) => (isLoggedIn ? 'Account' : 'Sign in')}
|
|
99
|
+
</Await>
|
|
100
|
+
</Suspense>
|
|
97
101
|
</NavLink>
|
|
98
102
|
<SearchToggle />
|
|
99
103
|
<CartToggle cart={cart} />
|
|
@@ -19,7 +19,7 @@ export type LayoutProps = {
|
|
|
19
19
|
children?: React.ReactNode;
|
|
20
20
|
footer: Promise<FooterQuery>;
|
|
21
21
|
header: HeaderQuery;
|
|
22
|
-
isLoggedIn: boolean
|
|
22
|
+
isLoggedIn: Promise<boolean>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export function Layout({
|
|
@@ -33,12 +33,12 @@ export function Layout({
|
|
|
33
33
|
<>
|
|
34
34
|
<CartAside cart={cart} />
|
|
35
35
|
<SearchAside />
|
|
36
|
-
<MobileMenuAside menu={header
|
|
37
|
-
<Header header={header} cart={cart} isLoggedIn={isLoggedIn} />
|
|
36
|
+
<MobileMenuAside menu={header?.menu} shop={header?.shop} />
|
|
37
|
+
{header && <Header header={header} cart={cart} isLoggedIn={isLoggedIn} />}
|
|
38
38
|
<main>{children}</main>
|
|
39
39
|
<Suspense>
|
|
40
40
|
<Await resolve={footer}>
|
|
41
|
-
{(footer) => <Footer menu={footer
|
|
41
|
+
{(footer) => <Footer menu={footer?.menu} shop={header?.shop} />}
|
|
42
42
|
</Await>
|
|
43
43
|
</Suspense>
|
|
44
44
|
</>
|
|
@@ -94,12 +94,15 @@ function MobileMenuAside({
|
|
|
94
94
|
shop: HeaderQuery['shop'];
|
|
95
95
|
}) {
|
|
96
96
|
return (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
menu &&
|
|
98
|
+
shop?.primaryDomain?.url && (
|
|
99
|
+
<Aside id="mobile-menu-aside" heading="MENU">
|
|
100
|
+
<HeaderMenu
|
|
101
|
+
menu={menu}
|
|
102
|
+
viewport="mobile"
|
|
103
|
+
primaryDomainUrl={shop.primaryDomain.url}
|
|
104
|
+
/>
|
|
105
|
+
</Aside>
|
|
106
|
+
)
|
|
104
107
|
);
|
|
105
108
|
}
|
|
@@ -211,7 +211,7 @@ function SearchResultArticleGrid({articles}: Pick<SearchQuery, 'articles'>) {
|
|
|
211
211
|
<div>
|
|
212
212
|
{articles?.nodes?.map((article) => (
|
|
213
213
|
<div className="search-results-item" key={article.id}>
|
|
214
|
-
<Link prefetch="intent" to={`/
|
|
214
|
+
<Link prefetch="intent" to={`/blogs/${article.handle}`}>
|
|
215
215
|
{article.title}
|
|
216
216
|
</Link>
|
|
217
217
|
</div>
|
package/dist/generator-templates/starter/app/graphql/customer-account/CustomerAddressMutations.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/mutations/customerAddressUpdate
|
|
2
|
+
export const UPDATE_ADDRESS_MUTATION = `#graphql
|
|
3
|
+
mutation customerAddressUpdate(
|
|
4
|
+
$address: CustomerAddressInput!
|
|
5
|
+
$addressId: ID!
|
|
6
|
+
$defaultAddress: Boolean
|
|
7
|
+
) {
|
|
8
|
+
customerAddressUpdate(
|
|
9
|
+
address: $address
|
|
10
|
+
addressId: $addressId
|
|
11
|
+
defaultAddress: $defaultAddress
|
|
12
|
+
) {
|
|
13
|
+
customerAddress {
|
|
14
|
+
id
|
|
15
|
+
}
|
|
16
|
+
userErrors {
|
|
17
|
+
code
|
|
18
|
+
field
|
|
19
|
+
message
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
` as const;
|
|
24
|
+
|
|
25
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/mutations/customerAddressDelete
|
|
26
|
+
export const DELETE_ADDRESS_MUTATION = `#graphql
|
|
27
|
+
mutation customerAddressDelete(
|
|
28
|
+
$addressId: ID!,
|
|
29
|
+
) {
|
|
30
|
+
customerAddressDelete(addressId: $addressId) {
|
|
31
|
+
deletedAddressId
|
|
32
|
+
userErrors {
|
|
33
|
+
code
|
|
34
|
+
field
|
|
35
|
+
message
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
` as const;
|
|
40
|
+
|
|
41
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/mutations/customerAddressCreate
|
|
42
|
+
export const CREATE_ADDRESS_MUTATION = `#graphql
|
|
43
|
+
mutation customerAddressCreate(
|
|
44
|
+
$address: CustomerAddressInput!
|
|
45
|
+
$defaultAddress: Boolean
|
|
46
|
+
) {
|
|
47
|
+
customerAddressCreate(
|
|
48
|
+
address: $address
|
|
49
|
+
defaultAddress: $defaultAddress
|
|
50
|
+
) {
|
|
51
|
+
customerAddress {
|
|
52
|
+
id
|
|
53
|
+
}
|
|
54
|
+
userErrors {
|
|
55
|
+
code
|
|
56
|
+
field
|
|
57
|
+
message
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
` as const;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/objects/Customer
|
|
2
|
+
export const CUSTOMER_FRAGMENT = `#graphql
|
|
3
|
+
fragment Customer on Customer {
|
|
4
|
+
firstName
|
|
5
|
+
lastName
|
|
6
|
+
defaultAddress {
|
|
7
|
+
...Address
|
|
8
|
+
}
|
|
9
|
+
addresses(first: 6) {
|
|
10
|
+
nodes {
|
|
11
|
+
...Address
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
fragment Address on CustomerAddress {
|
|
16
|
+
id
|
|
17
|
+
formatted
|
|
18
|
+
firstName
|
|
19
|
+
lastName
|
|
20
|
+
company
|
|
21
|
+
address1
|
|
22
|
+
address2
|
|
23
|
+
territoryCode
|
|
24
|
+
zoneCode
|
|
25
|
+
city
|
|
26
|
+
zip
|
|
27
|
+
phoneNumber
|
|
28
|
+
}
|
|
29
|
+
` as const;
|
|
30
|
+
|
|
31
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/queries/customer
|
|
32
|
+
export const CUSTOMER_DETAILS_QUERY = `#graphql
|
|
33
|
+
query CustomerDetails {
|
|
34
|
+
customer {
|
|
35
|
+
...Customer
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
${CUSTOMER_FRAGMENT}
|
|
39
|
+
` as const;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/queries/order
|
|
2
|
+
export const CUSTOMER_ORDER_QUERY = `#graphql
|
|
3
|
+
fragment OrderMoney on MoneyV2 {
|
|
4
|
+
amount
|
|
5
|
+
currencyCode
|
|
6
|
+
}
|
|
7
|
+
fragment DiscountApplication on DiscountApplication {
|
|
8
|
+
value {
|
|
9
|
+
__typename
|
|
10
|
+
... on MoneyV2 {
|
|
11
|
+
...OrderMoney
|
|
12
|
+
}
|
|
13
|
+
... on PricingPercentageValue {
|
|
14
|
+
percentage
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
fragment OrderLineItemFull on LineItem {
|
|
19
|
+
id
|
|
20
|
+
title
|
|
21
|
+
quantity
|
|
22
|
+
price {
|
|
23
|
+
...OrderMoney
|
|
24
|
+
}
|
|
25
|
+
discountAllocations {
|
|
26
|
+
allocatedAmount {
|
|
27
|
+
...OrderMoney
|
|
28
|
+
}
|
|
29
|
+
discountApplication {
|
|
30
|
+
...DiscountApplication
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
totalDiscount {
|
|
34
|
+
...OrderMoney
|
|
35
|
+
}
|
|
36
|
+
image {
|
|
37
|
+
altText
|
|
38
|
+
height
|
|
39
|
+
url
|
|
40
|
+
id
|
|
41
|
+
width
|
|
42
|
+
}
|
|
43
|
+
variantTitle
|
|
44
|
+
}
|
|
45
|
+
fragment Order on Order {
|
|
46
|
+
id
|
|
47
|
+
name
|
|
48
|
+
statusPageUrl
|
|
49
|
+
processedAt
|
|
50
|
+
fulfillments(first: 1) {
|
|
51
|
+
nodes {
|
|
52
|
+
status
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
totalTax {
|
|
56
|
+
...OrderMoney
|
|
57
|
+
}
|
|
58
|
+
totalPrice {
|
|
59
|
+
...OrderMoney
|
|
60
|
+
}
|
|
61
|
+
subtotal {
|
|
62
|
+
...OrderMoney
|
|
63
|
+
}
|
|
64
|
+
shippingAddress {
|
|
65
|
+
name
|
|
66
|
+
formatted(withName: true)
|
|
67
|
+
formattedArea
|
|
68
|
+
}
|
|
69
|
+
discountApplications(first: 100) {
|
|
70
|
+
nodes {
|
|
71
|
+
...DiscountApplication
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
lineItems(first: 100) {
|
|
75
|
+
nodes {
|
|
76
|
+
...OrderLineItemFull
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
query Order($orderId: ID!) {
|
|
81
|
+
order(id: $orderId) {
|
|
82
|
+
... on Order {
|
|
83
|
+
...Order
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
` as const;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/customer/latest/objects/Order
|
|
2
|
+
export const ORDER_ITEM_FRAGMENT = `#graphql
|
|
3
|
+
fragment OrderItem on Order {
|
|
4
|
+
totalPrice {
|
|
5
|
+
amount
|
|
6
|
+
currencyCode
|
|
7
|
+
}
|
|
8
|
+
financialStatus
|
|
9
|
+
fulfillments(first: 1) {
|
|
10
|
+
nodes {
|
|
11
|
+
status
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
id
|
|
15
|
+
number
|
|
16
|
+
processedAt
|
|
17
|
+
}
|
|
18
|
+
` as const;
|
|
19
|
+
|
|
20
|
+
// https://shopify.dev/docs/api/customer/latest/objects/Customer
|
|
21
|
+
export const CUSTOMER_ORDERS_FRAGMENT = `#graphql
|
|
22
|
+
fragment CustomerOrders on Customer {
|
|
23
|
+
orders(
|
|
24
|
+
sortKey: PROCESSED_AT,
|
|
25
|
+
reverse: true,
|
|
26
|
+
first: $first,
|
|
27
|
+
last: $last,
|
|
28
|
+
before: $startCursor,
|
|
29
|
+
after: $endCursor
|
|
30
|
+
) {
|
|
31
|
+
nodes {
|
|
32
|
+
...OrderItem
|
|
33
|
+
}
|
|
34
|
+
pageInfo {
|
|
35
|
+
hasPreviousPage
|
|
36
|
+
hasNextPage
|
|
37
|
+
endCursor
|
|
38
|
+
startCursor
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
${ORDER_ITEM_FRAGMENT}
|
|
43
|
+
` as const;
|
|
44
|
+
|
|
45
|
+
// https://shopify.dev/docs/api/customer/latest/queries/customer
|
|
46
|
+
export const CUSTOMER_ORDERS_QUERY = `#graphql
|
|
47
|
+
${CUSTOMER_ORDERS_FRAGMENT}
|
|
48
|
+
query CustomerOrders(
|
|
49
|
+
$endCursor: String
|
|
50
|
+
$first: Int
|
|
51
|
+
$last: Int
|
|
52
|
+
$startCursor: String
|
|
53
|
+
) {
|
|
54
|
+
customer {
|
|
55
|
+
...CustomerOrders
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
` as const;
|
package/dist/generator-templates/starter/app/graphql/customer-account/CustomerUpdateMutation.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const CUSTOMER_UPDATE_MUTATION = `#graphql
|
|
2
|
+
# https://shopify.dev/docs/api/customer/latest/mutations/customerUpdate
|
|
3
|
+
mutation customerUpdate(
|
|
4
|
+
$customer: CustomerUpdateInput!
|
|
5
|
+
){
|
|
6
|
+
customerUpdate(input: $customer) {
|
|
7
|
+
customer {
|
|
8
|
+
firstName
|
|
9
|
+
lastName
|
|
10
|
+
emailAddress {
|
|
11
|
+
emailAddress
|
|
12
|
+
}
|
|
13
|
+
phoneNumber {
|
|
14
|
+
phoneNumber
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
userErrors {
|
|
18
|
+
code
|
|
19
|
+
field
|
|
20
|
+
message
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
` as const;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/storefront/latest/queries/cart
|
|
2
|
+
export const CART_QUERY_FRAGMENT = `#graphql
|
|
3
|
+
fragment Money on MoneyV2 {
|
|
4
|
+
currencyCode
|
|
5
|
+
amount
|
|
6
|
+
}
|
|
7
|
+
fragment CartLine on CartLine {
|
|
8
|
+
id
|
|
9
|
+
quantity
|
|
10
|
+
attributes {
|
|
11
|
+
key
|
|
12
|
+
value
|
|
13
|
+
}
|
|
14
|
+
cost {
|
|
15
|
+
totalAmount {
|
|
16
|
+
...Money
|
|
17
|
+
}
|
|
18
|
+
amountPerQuantity {
|
|
19
|
+
...Money
|
|
20
|
+
}
|
|
21
|
+
compareAtAmountPerQuantity {
|
|
22
|
+
...Money
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
merchandise {
|
|
26
|
+
... on ProductVariant {
|
|
27
|
+
id
|
|
28
|
+
availableForSale
|
|
29
|
+
compareAtPrice {
|
|
30
|
+
...Money
|
|
31
|
+
}
|
|
32
|
+
price {
|
|
33
|
+
...Money
|
|
34
|
+
}
|
|
35
|
+
requiresShipping
|
|
36
|
+
title
|
|
37
|
+
image {
|
|
38
|
+
id
|
|
39
|
+
url
|
|
40
|
+
altText
|
|
41
|
+
width
|
|
42
|
+
height
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
product {
|
|
46
|
+
handle
|
|
47
|
+
title
|
|
48
|
+
id
|
|
49
|
+
}
|
|
50
|
+
selectedOptions {
|
|
51
|
+
name
|
|
52
|
+
value
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
fragment CartApiQuery on Cart {
|
|
58
|
+
id
|
|
59
|
+
checkoutUrl
|
|
60
|
+
totalQuantity
|
|
61
|
+
buyerIdentity {
|
|
62
|
+
countryCode
|
|
63
|
+
customer {
|
|
64
|
+
id
|
|
65
|
+
email
|
|
66
|
+
firstName
|
|
67
|
+
lastName
|
|
68
|
+
displayName
|
|
69
|
+
}
|
|
70
|
+
email
|
|
71
|
+
phone
|
|
72
|
+
}
|
|
73
|
+
lines(first: $numCartLines) {
|
|
74
|
+
nodes {
|
|
75
|
+
...CartLine
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
cost {
|
|
79
|
+
subtotalAmount {
|
|
80
|
+
...Money
|
|
81
|
+
}
|
|
82
|
+
totalAmount {
|
|
83
|
+
...Money
|
|
84
|
+
}
|
|
85
|
+
totalDutyAmount {
|
|
86
|
+
...Money
|
|
87
|
+
}
|
|
88
|
+
totalTaxAmount {
|
|
89
|
+
...Money
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
note
|
|
93
|
+
attributes {
|
|
94
|
+
key
|
|
95
|
+
value
|
|
96
|
+
}
|
|
97
|
+
discountCodes {
|
|
98
|
+
code
|
|
99
|
+
applicable
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
` as const;
|