Skip to content

Commit

Permalink
Merge pull request #1 from contentstack/shopify-add-oxygen-workflow-ww7p
Browse files Browse the repository at this point in the history
Add Oxygen deployment workflow file
  • Loading branch information
sankartn authored Dec 18, 2023
2 parents 96eecb7 + bf16f97 commit 2d8ec1d
Show file tree
Hide file tree
Showing 56 changed files with 25,233 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
node_modules
bin
*.d.ts
dist
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @type {import("@types/eslint").Linter.BaseConfig}
*/
module.exports = {
extends: [
'@remix-run/eslint-config',
'plugin:hydrogen/recommended',
'plugin:hydrogen/typescript',
],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/naming-convention': 'off',
'hydrogen/prefer-image-component': 'off',
'no-useless-escape': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'no-case-declarations': 'off',
},
};
57 changes: 57 additions & 0 deletions .github/workflows/oxygen-deployment-1000010341.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Don't change the line below!
#! oxygen_storefront_id: 1000010341

name: Storefront 1000010341
on: [push]

permissions:
contents: read
deployments: write

jobs:
deploy:
name: Deploy to Oxygen
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
check-latest: true

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci

- name: Build and Publish to Oxygen
id: deploy
uses: shopify/oxygenctl-action@v4
with:
oxygen_deployment_token: ${{ secrets.OXYGEN_DEPLOYMENT_TOKEN_1000010341 }}
build_command: "npm run build"

# Create GitHub Deployment
- name: Create GitHub Deployment
uses: shopify/github-deployment-action@v1
if: always()
with:
token: ${{ github.token }}
environment: 'preview'
preview_url: ${{ steps.deploy.outputs.url }}
description: ${{ github.event.head_commit.message }}

9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.cache
/build
/dist
/public/build
/.mf
.env
.shopify
/node_modules
/README 2.md
1 change: 1 addition & 0 deletions .graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
schema: node_modules/@shopify/hydrogen-react/storefront.schema.json
143 changes: 143 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# skeleton

## 1.0.0

### Major Changes

- The Storefront API 2023-10 now returns menu item URLs that include the `primaryDomainUrl`, instead of defaulting to the Shopify store ID URL (example.myshopify.com). The skeleton template requires changes to check for the `primaryDomainUrl`: by [@blittle](https://github.com/blittle)

1. Update the `HeaderMenu` component to accept a `primaryDomainUrl` and include
it in the internal url check

```diff
// app/components/Header.tsx

+ import type {HeaderQuery} from 'storefrontapi.generated';

export function HeaderMenu({
menu,
+ primaryDomainUrl,
viewport,
}: {
menu: HeaderProps['header']['menu'];
+ primaryDomainUrl: HeaderQuery['shop']['primaryDomain']['url'];
viewport: Viewport;
}) {

// ...code

// if the url is internal, we strip the domain
const url =
item.url.includes('myshopify.com') ||
item.url.includes(publicStoreDomain) ||
+ item.url.includes(primaryDomainUrl)
? new URL(item.url).pathname
: item.url;

// ...code

}
```

2. Update the `FooterMenu` component to accept a `primaryDomainUrl` prop and include
it in the internal url check

```diff
// app/components/Footer.tsx

- import type {FooterQuery} from 'storefrontapi.generated';
+ import type {FooterQuery, HeaderQuery} from 'storefrontapi.generated';

function FooterMenu({
menu,
+ primaryDomainUrl,
}: {
menu: FooterQuery['menu'];
+ primaryDomainUrl: HeaderQuery['shop']['primaryDomain']['url'];
}) {
// code...

// if the url is internal, we strip the domain
const url =
item.url.includes('myshopify.com') ||
item.url.includes(publicStoreDomain) ||
+ item.url.includes(primaryDomainUrl)
? new URL(item.url).pathname
: item.url;

// ...code

);
}
```

3. Update the `Footer` component to accept a `shop` prop

```diff
export function Footer({
menu,
+ shop,
}: FooterQuery & {shop: HeaderQuery['shop']}) {
return (
<footer className="footer">
- <FooterMenu menu={menu} />
+ <FooterMenu menu={menu} primaryDomainUrl={shop.primaryDomain.url} />
</footer>
);
}
```

4. Update `Layout.tsx` to pass the `shop` prop

```diff
export function Layout({
cart,
children = null,
footer,
header,
isLoggedIn,
}: LayoutProps) {
return (
<>
<CartAside cart={cart} />
<SearchAside />
<MobileMenuAside menu={header.menu} shop={header.shop} />
<Header header={header} cart={cart} isLoggedIn={isLoggedIn} />
<main>{children}</main>
<Suspense>
<Await resolve={footer}>
- {(footer) => <Footer menu={footer.menu} />}
+ {(footer) => <Footer menu={footer.menu} shop={header.shop} />}
</Await>
</Suspense>
</>
);
}
```

### Patch Changes

- If you are calling `useMatches()` in different places of your app to access the data returned by the root loader, you may want to update it to the following pattern to enhance types: ([#1289](https://github.com/Shopify/hydrogen/pull/1289)) by [@frandiox](https://github.com/frandiox)

```ts
// root.tsx

import {useMatches} from '@remix-run/react';
import {type SerializeFrom} from '@shopify/remix-oxygen';

export const useRootLoaderData = () => {
const [root] = useMatches();
return root?.data as SerializeFrom<typeof loader>;
};

export function loader(context) {
// ...
}
```

This way, you can import `useRootLoaderData()` anywhere in your app and get the correct type for the data returned by the root loader.

- Updated dependencies [[`81400439`](https://github.com/Shopify/hydrogen/commit/814004397c1d17ef0a53a425ed28a42cf67765cf), [`a6f397b6`](https://github.com/Shopify/hydrogen/commit/a6f397b64dc6a0d856cb7961731ee1f86bf80292), [`3464ec04`](https://github.com/Shopify/hydrogen/commit/3464ec04a084e1ceb30ee19874dc1b9171ce2b34), [`7fc088e2`](https://github.com/Shopify/hydrogen/commit/7fc088e21bea47840788cb7c60f873ce1f253128), [`867e0b03`](https://github.com/Shopify/hydrogen/commit/867e0b033fc9eb04b7250baea97d8fd49d26ccca), [`ad45656c`](https://github.com/Shopify/hydrogen/commit/ad45656c5f663cc1a60eab5daab4da1dfd0e6cc3), [`f24e3424`](https://github.com/Shopify/hydrogen/commit/f24e3424c8e2b363b181b71fcbd3e45f696fdd3f), [`66a48573`](https://github.com/Shopify/hydrogen/commit/66a4857387148b6a104df5783314c74aca8aada0), [`0ae7cbe2`](https://github.com/Shopify/hydrogen/commit/0ae7cbe280d8351126e11dc13f35d7277d9b2d86), [`8198c1be`](https://github.com/Shopify/hydrogen/commit/8198c1befdfafb39fbcc88d71f91d21eae252973), [`ad45656c`](https://github.com/Shopify/hydrogen/commit/ad45656c5f663cc1a60eab5daab4da1dfd0e6cc3)]:
- @shopify/[email protected]
- @shopify/[email protected]
- @shopify/[email protected]
47 changes: 47 additions & 0 deletions app/components/Aside.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* A side bar component with Overlay that works without JavaScript.
* @example
* ```jsx
* <Aside id="search-aside" heading="SEARCH">
* <input type="search" />
* ...
* </Aside>
* ```
*/
export function Aside({
children,
heading,
id = 'aside',
}: {
children?: React.ReactNode;
heading: React.ReactNode;
id?: string;
}) {
return (
<div aria-modal className="overlay" id={id} role="dialog">
<button
className="close-outside"
onClick={() => {
history.go(-1);
window.location.hash = '';
}}
/>
<aside>
<header>
<h3>{heading}</h3>
<CloseAside />
</header>
<main>{children}</main>
</aside>
</div>
);
}

function CloseAside() {
return (
/* eslint-disable-next-line jsx-a11y/anchor-is-valid */
<a className="close" href="#" onChange={() => history.go(-1)}>
&times;
</a>
);
}
Loading

0 comments on commit 2d8ec1d

Please sign in to comment.