Skip to content

Commit

Permalink
Merge branch 'v1.x-2022-07' into dependabot/npm_and_yarn/semver-5.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
blittle committed Mar 28, 2024
2 parents b74b618 + 4ec32f5 commit 27bac77
Show file tree
Hide file tree
Showing 47 changed files with 576 additions and 293 deletions.
5 changes: 0 additions & 5 deletions .changeset/chilly-dogs-sneeze.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/short-frogs-obey.md

This file was deleted.

62 changes: 31 additions & 31 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,34 +101,34 @@ jobs:
git commit -m "Update templates for dist"
git push origin HEAD:dist --force
discord_announcement:
needs: changelog
# Only announce if a release was published, and we're on the "latest" release branch
if: needs.changelog.outputs.published == 'true' && needs.changelog.outputs.latest == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2

- name: Read Hydrogen version from package.json
id: read_package_json
working-directory: ./packages/hydrogen
run: |
content=`cat ./package.json`
# the following lines are required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of handling multi line json
echo "::set-output name=packageJson::$content"
- run: |
echo "HYDROGEN_VERSION=${{fromJSON(steps.read_package_json.outputs.packageJson).version}}" >> $GITHUB_ENV
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: Shopify Devs
DISCORD_AVATAR: https://cdn.discordapp.com/avatars/905537246990590012/0f6a687b93ef3f81a036c817fb02ccbf.webp
uses: Ilshidur/action-discord@08d9328877d6954120eef2b07abbc79249bb6210
with:
args: "Hydrogen ${{ env.HYDROGEN_VERSION }} has been released.\nhttps://github.com/Shopify/hydrogen-v1/releases/tag/@shopify/hydrogen@${{ env.HYDROGEN_VERSION }}"
# discord_announcement:
# needs: changelog
# # Only announce if a release was published, and we're on the "latest" release branch
# if: needs.changelog.outputs.published == 'true' && needs.changelog.outputs.latest == 'true'
# runs-on: ubuntu-latest
# steps:
# - name: Check out the code
# uses: actions/checkout@v2

# - name: Read Hydrogen version from package.json
# id: read_package_json
# working-directory: ./packages/hydrogen
# run: |
# content=`cat ./package.json`
# # the following lines are required for multi line json
# content="${content//'%'/'%25'}"
# content="${content//$'\n'/'%0A'}"
# content="${content//$'\r'/'%0D'}"
# # end of handling multi line json
# echo "::set-output name=packageJson::$content"
# - run: |
# echo "HYDROGEN_VERSION=${{fromJSON(steps.read_package_json.outputs.packageJson).version}}" >> $GITHUB_ENV

# - name: Discord notification
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# DISCORD_USERNAME: Shopify Devs
# DISCORD_AVATAR: https://cdn.discordapp.com/avatars/905537246990590012/0f6a687b93ef3f81a036c817fb02ccbf.webp
# uses: Ilshidur/action-discord@08d9328877d6954120eef2b07abbc79249bb6210
# with:
# args: "Hydrogen ${{ env.HYDROGEN_VERSION }} has been released.\nhttps://github.com/Shopify/hydrogen-v1/releases/tag/@shopify/hydrogen@${{ env.HYDROGEN_VERSION }}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"turbo": "^1.7.4",
"type-fest": "^2.12.0",
"typescript": "^4.8.2",
"vite": "^2.9.13",
"vite": "^2.9.17",
"yorkie": "^2.0.0"
},
"gitHooks": {
Expand Down
40 changes: 40 additions & 0 deletions packages/hydrogen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Changelog

## 1.7.3

### Patch Changes

- Allow concatenating requests with a header. For example, if you want the route `/shop` to proxy render everything on `/products`, setup an API route at `/routes/shop.server.jsx` with the following: ([#2536](https://github.com/Shopify/hydrogen-v1/pull/2536)) by [@blittle](https://github.com/blittle)

```jsx
export async function api(request) {
return new Request(new URL(request.url).origin + '/products', {
headers: {
'Hydrogen-Concatenate': 'true',
},
});
}
```

## 1.7.2

### Patch Changes

- Log extra params in default error logger ([#2533](https://github.com/Shopify/hydrogen-v1/pull/2533)) by [@juanpprieto](https://github.com/juanpprieto)

## 1.7.1

### Patch Changes

- Add support for `languageCode` to the `CartProvider` component ([#2531](https://github.com/Shopify/hydrogen-v1/pull/2531)) by [@blittle](https://github.com/blittle)

## 1.7.0

### Minor Changes

- Updates default `powered-by` header output to `Shopify, Hydrogen`, and updates associateed documentation. ([#2518](https://github.com/Shopify/hydrogen-v1/pull/2518)) by [@benjaminsehl](https://github.com/benjaminsehl)

### Patch Changes

- Fix the `<CartProvider>` to by default pull localization from `<ShopifyProvider>`. You can still override the countryCode by passing a prop directly to `<CartProvider>`. Resolves https://github.com/Shopify/hydrogen/issues/622 ([#2521](https://github.com/Shopify/hydrogen-v1/pull/2521)) by [@blittle](https://github.com/blittle)

- Fix an issue where cache doesn't properly match requests ([#2530](https://github.com/Shopify/hydrogen-v1/pull/2530)) by [@blittle](https://github.com/blittle)

## 1.6.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/hydrogen/graphql.schema.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/hydrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"engines": {
"node": ">=14"
},
"version": "1.6.8",
"version": "1.7.3",
"description": "Modern custom Shopify storefronts",
"license": "MIT",
"main": "dist/esnext/index.js",
Expand Down Expand Up @@ -142,7 +142,7 @@
"connect": "^3.7.0",
"es-module-lexer": "^0.10.0",
"fast-glob": "^3.2.11",
"graphql": "^16.3.0",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"history": "^5.3.0",
"kolorist": "^1.5.1",
Expand All @@ -153,7 +153,7 @@
"react-helmet-async": "^1.3.0",
"serve-static": "^1.15.0",
"set-cookie-parser": "^2.5.0",
"undici": "^5.8.2",
"undici": "^5.28.3",
"uuid": "^8.3.2",
"vite-plugin-inspect": "^0.3.6",
"web-streams-polyfill": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CartLineInput,
CartLineUpdateInput,
CountryCode,
LanguageCode,
} from '../../storefront-api-types.js';
import {
CartAttributesUpdate,
Expand Down Expand Up @@ -62,13 +63,16 @@ export function useCartActions({
numCartLines,
cartFragment,
countryCode = CountryCode.Us,
languageCode = LanguageCode.En,
}: {
/** Maximum number of cart lines to fetch. Defaults to 250 cart lines. */
numCartLines?: number;
/** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
cartFragment: string;
/** The ISO country code for i18n. */
countryCode?: CountryCode;
/** The ISO country code for i18n. */
languageCode?: LanguageCode;
}) {
const fetchCart = useCartFetch();

Expand All @@ -80,10 +84,11 @@ export function useCartActions({
id: cartId,
numCartLines,
country: countryCode,
language: languageCode,
},
});
},
[fetchCart, cartFragment, numCartLines, countryCode]
[fetchCart, cartFragment, numCartLines, countryCode, languageCode]
);

const cartCreate = useCallback(
Expand All @@ -94,10 +99,11 @@ export function useCartActions({
input: cart,
numCartLines,
country: countryCode,
language: languageCode,
},
});
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

const cartLineAdd = useCallback(
Expand All @@ -109,10 +115,11 @@ export function useCartActions({
lines,
numCartLines,
country: countryCode,
language: languageCode,
},
});
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

const cartLineUpdate = useCallback(
Expand All @@ -125,11 +132,12 @@ export function useCartActions({
lines,
numCartLines,
country: countryCode,
language: languageCode,
},
}
);
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

const cartLineRemove = useCallback(
Expand All @@ -142,11 +150,12 @@ export function useCartActions({
lines,
numCartLines,
country: countryCode,
language: languageCode,
},
}
);
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

const noteUpdate = useCallback(
Expand All @@ -159,11 +168,12 @@ export function useCartActions({
note,
numCartLines,
country: countryCode,
language: languageCode,
},
}
);
},
[fetchCart, cartFragment, numCartLines, countryCode]
[fetchCart, cartFragment, numCartLines, countryCode, languageCode]
);

const buyerIdentityUpdate = useCallback(
Expand All @@ -178,10 +188,11 @@ export function useCartActions({
buyerIdentity,
numCartLines,
country: countryCode,
language: languageCode,
},
});
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

const cartAttributesUpdate = useCallback(
Expand All @@ -196,10 +207,11 @@ export function useCartActions({
attributes,
numCartLines,
country: countryCode,
language: languageCode,
},
});
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

const discountCodesUpdate = useCallback(
Expand All @@ -217,10 +229,11 @@ export function useCartActions({
discountCodes,
numCartLines,
country: countryCode,
language: languageCode,
},
});
},
[cartFragment, countryCode, fetchCart, numCartLines]
[cartFragment, countryCode, fetchCart, numCartLines, languageCode]
);

return useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
CartLineInput,
CartLineUpdateInput,
CountryCode,
LanguageCode,
} from '../../storefront-api-types.js';
import {defaultCartFragment} from './cart-queries.js';
import {CartContext} from './context.js';
Expand Down Expand Up @@ -59,6 +60,7 @@ export function CartProvider({
cartFragment = defaultCartFragment,
customerAccessToken,
countryCode,
languageCode,
}: {
/** Any `ReactNode` elements. */
children: React.ReactNode;
Expand Down Expand Up @@ -104,14 +106,21 @@ export function CartProvider({
customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];
/** The ISO country code for i18n. */
countryCode?: CountryCode;
/** The ISO language code for i18n. */
languageCode?: LanguageCode;
}) {
const {country} = useLocalization();
const {country, language} = useLocalization();

countryCode = (
(countryCode as string) ?? country.isoCode
).toUpperCase() as CountryCode;

languageCode = (
(languageCode as string) ?? language.isoCode
).toUpperCase() as LanguageCode;

if (countryCode) countryCode = countryCode.toUpperCase() as CountryCode;

const [prevCountryCode, setPrevCountryCode] = useState(countryCode);
const [prevCustomerAccessToken, setPrevCustomerAccessToken] =
useState(customerAccessToken);
Expand Down Expand Up @@ -261,6 +270,7 @@ export function CartProvider({
data: cart,
cartFragment,
countryCode,
languageCode,
onCartActionEntry,
onCartActionOptimisticUI,
onCartActionComplete,
Expand Down
Loading

0 comments on commit 27bac77

Please sign in to comment.