@shopify/cli-hydrogen 5.0.2 → 5.1.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 +16 -2
- package/dist/commands/hydrogen/codegen-unstable.js +13 -24
- package/dist/commands/hydrogen/dev.js +45 -39
- package/dist/commands/hydrogen/env/list.js +25 -24
- package/dist/commands/hydrogen/env/list.test.js +46 -43
- package/dist/commands/hydrogen/env/pull.js +53 -25
- package/dist/commands/hydrogen/env/pull.test.js +123 -42
- package/dist/commands/hydrogen/generate/route.js +31 -132
- package/dist/commands/hydrogen/generate/route.test.js +34 -126
- package/dist/commands/hydrogen/init.js +46 -127
- package/dist/commands/hydrogen/init.test.js +352 -100
- package/dist/commands/hydrogen/link.js +70 -69
- package/dist/commands/hydrogen/link.test.js +72 -107
- package/dist/commands/hydrogen/list.js +22 -12
- package/dist/commands/hydrogen/list.test.js +51 -48
- package/dist/commands/hydrogen/login.js +31 -0
- package/dist/commands/hydrogen/logout.js +21 -0
- package/dist/commands/hydrogen/setup/css.js +79 -0
- package/dist/commands/hydrogen/setup/markets.js +53 -0
- package/dist/commands/hydrogen/setup.js +133 -0
- package/dist/commands/hydrogen/shortcut.js +2 -45
- package/dist/commands/hydrogen/shortcut.test.js +10 -37
- package/dist/generator-templates/assets/css-modules/package.json +6 -0
- package/dist/generator-templates/assets/postcss/package.json +10 -0
- package/dist/generator-templates/assets/postcss/postcss.config.js +8 -0
- package/dist/generator-templates/assets/tailwind/package.json +13 -0
- package/dist/generator-templates/assets/tailwind/postcss.config.js +10 -0
- package/dist/generator-templates/assets/tailwind/tailwind.config.js +8 -0
- package/dist/generator-templates/assets/tailwind/tailwind.css +3 -0
- package/dist/generator-templates/assets/vanilla-extract/package.json +9 -0
- package/dist/generator-templates/starter/.eslintignore +5 -0
- package/dist/generator-templates/starter/.eslintrc.js +18 -0
- package/dist/generator-templates/starter/.graphqlrc.yml +1 -0
- package/dist/generator-templates/starter/README.md +40 -0
- package/dist/generator-templates/starter/app/components/Aside.tsx +47 -0
- package/dist/generator-templates/starter/app/components/Cart.tsx +340 -0
- package/dist/generator-templates/starter/app/components/Footer.tsx +99 -0
- package/dist/generator-templates/starter/app/components/Header.tsx +178 -0
- package/dist/generator-templates/starter/app/components/Layout.tsx +95 -0
- package/dist/generator-templates/starter/app/components/Search.tsx +480 -0
- package/dist/generator-templates/starter/app/entry.client.tsx +12 -0
- package/dist/generator-templates/starter/app/entry.server.tsx +33 -0
- package/dist/generator-templates/starter/app/root.tsx +270 -0
- package/dist/generator-templates/starter/app/routes/$.tsx +7 -0
- package/dist/generator-templates/{routes → starter/app/routes}/[robots.txt].tsx +47 -69
- package/dist/generator-templates/starter/app/routes/[sitemap.xml].tsx +174 -0
- package/dist/generator-templates/starter/app/routes/_index.tsx +145 -0
- package/dist/generator-templates/starter/app/routes/account.$.tsx +9 -0
- package/dist/generator-templates/starter/app/routes/account.addresses.tsx +563 -0
- package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +309 -0
- package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +196 -0
- package/dist/generator-templates/starter/app/routes/account.profile.tsx +289 -0
- package/dist/generator-templates/starter/app/routes/account.tsx +203 -0
- package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +157 -0
- package/dist/generator-templates/starter/app/routes/account_.login.tsx +143 -0
- package/dist/generator-templates/starter/app/routes/account_.logout.tsx +33 -0
- package/dist/generator-templates/starter/app/routes/account_.recover.tsx +124 -0
- package/dist/generator-templates/starter/app/routes/account_.register.tsx +207 -0
- package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +136 -0
- package/dist/generator-templates/starter/app/routes/api.predictive-search.tsx +342 -0
- package/dist/generator-templates/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +88 -0
- package/dist/generator-templates/starter/app/routes/blogs.$blogHandle._index.tsx +162 -0
- package/dist/generator-templates/starter/app/routes/blogs._index.tsx +94 -0
- package/dist/generator-templates/starter/app/routes/cart.tsx +104 -0
- package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +184 -0
- package/dist/generator-templates/starter/app/routes/collections._index.tsx +120 -0
- package/dist/generator-templates/starter/app/routes/pages.$handle.tsx +57 -0
- package/dist/generator-templates/starter/app/routes/policies.$handle.tsx +94 -0
- package/dist/generator-templates/starter/app/routes/policies._index.tsx +63 -0
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +418 -0
- package/dist/generator-templates/starter/app/routes/search.tsx +168 -0
- package/dist/generator-templates/starter/app/styles/app.css +473 -0
- package/dist/generator-templates/starter/app/styles/reset.css +129 -0
- package/dist/generator-templates/starter/app/utils.ts +46 -0
- package/dist/generator-templates/starter/package.json +43 -0
- package/dist/generator-templates/starter/public/favicon.svg +28 -0
- package/dist/generator-templates/starter/remix.config.js +26 -0
- package/dist/generator-templates/starter/remix.env.d.ts +39 -0
- package/dist/generator-templates/starter/server.ts +253 -0
- package/dist/generator-templates/starter/storefrontapi.generated.d.ts +1906 -0
- package/dist/generator-templates/starter/tsconfig.json +22 -0
- package/dist/lib/auth.js +123 -0
- package/dist/lib/auth.test.js +157 -0
- package/dist/lib/build.js +51 -0
- package/dist/lib/check-version.js +3 -3
- package/dist/lib/check-version.test.js +24 -0
- package/dist/lib/codegen.js +26 -17
- package/dist/lib/environment-variables.js +68 -0
- package/dist/lib/environment-variables.test.js +147 -0
- package/dist/lib/file.js +41 -0
- package/dist/lib/file.test.js +69 -0
- package/dist/lib/flags.js +39 -2
- package/dist/lib/format-code.js +26 -0
- package/dist/lib/gid.js +12 -0
- package/dist/lib/{graphql.test.js → gid.test.js} +1 -1
- package/dist/lib/graphql/admin/client.js +27 -0
- package/dist/lib/graphql/admin/client.test.js +51 -0
- package/dist/lib/graphql/admin/create-storefront.js +13 -15
- package/dist/lib/graphql/admin/create-storefront.test.js +64 -0
- package/dist/lib/graphql/admin/fetch-job.js +6 -15
- package/dist/lib/graphql/admin/link-storefront.js +7 -11
- package/dist/lib/graphql/admin/link-storefront.test.js +38 -0
- package/dist/lib/graphql/admin/list-environments.js +2 -2
- package/dist/lib/graphql/admin/list-environments.test.js +44 -0
- package/dist/lib/graphql/admin/list-storefronts.js +7 -11
- package/dist/lib/graphql/admin/list-storefronts.test.js +44 -0
- package/dist/lib/graphql/admin/pull-variables.js +3 -3
- package/dist/lib/graphql/admin/pull-variables.test.js +37 -0
- package/dist/lib/graphql/business-platform/user-account.js +83 -0
- package/dist/lib/graphql/business-platform/user-account.test.js +80 -0
- package/dist/lib/log.js +185 -9
- package/dist/lib/log.test.js +92 -0
- package/dist/lib/mini-oxygen.js +19 -9
- package/dist/lib/missing-routes.js +0 -2
- package/dist/lib/onboarding/common.js +456 -0
- package/dist/lib/onboarding/index.js +2 -0
- package/dist/lib/onboarding/local.js +229 -0
- package/dist/lib/onboarding/remote.js +89 -0
- package/dist/lib/remix-version-interop.js +5 -5
- package/dist/lib/remix-version-interop.test.js +11 -1
- package/dist/lib/render-errors.js +13 -11
- package/dist/lib/setups/css/assets.js +89 -0
- package/dist/lib/setups/css/css-modules.js +22 -0
- package/dist/lib/setups/css/index.js +44 -0
- package/dist/lib/setups/css/postcss.js +34 -0
- package/dist/lib/setups/css/replacers.js +137 -0
- package/dist/lib/setups/css/tailwind.js +54 -0
- package/dist/lib/setups/css/vanilla-extract.js +22 -0
- package/dist/lib/setups/i18n/domains.test.js +25 -0
- package/dist/lib/setups/i18n/index.js +46 -0
- package/dist/lib/setups/i18n/replacers.js +227 -0
- package/dist/lib/setups/i18n/subdomains.test.js +25 -0
- package/dist/lib/setups/i18n/subfolders.test.js +25 -0
- package/dist/lib/setups/i18n/templates/domains.js +14 -0
- package/dist/lib/setups/i18n/templates/domains.ts +25 -0
- package/dist/lib/setups/i18n/templates/subdomains.js +14 -0
- package/dist/lib/setups/i18n/templates/subdomains.ts +24 -0
- package/dist/lib/setups/i18n/templates/subfolders.js +14 -0
- package/dist/lib/setups/i18n/templates/subfolders.ts +28 -0
- package/dist/lib/setups/routes/generate.js +244 -0
- package/dist/lib/setups/routes/generate.test.js +313 -0
- package/dist/lib/shell.js +52 -5
- package/dist/lib/shell.test.js +42 -16
- package/dist/lib/shopify-config.js +23 -18
- package/dist/lib/shopify-config.test.js +63 -73
- package/dist/lib/template-downloader.js +9 -7
- package/dist/lib/transpile-ts.js +9 -29
- package/dist/virtual-routes/routes/index.jsx +40 -19
- package/oclif.manifest.json +710 -1
- package/package.json +16 -16
- package/dist/commands/hydrogen/build.d.ts +0 -23
- package/dist/commands/hydrogen/check.d.ts +0 -15
- package/dist/commands/hydrogen/codegen-unstable.d.ts +0 -15
- package/dist/commands/hydrogen/dev.d.ts +0 -21
- package/dist/commands/hydrogen/env/list.d.ts +0 -18
- package/dist/commands/hydrogen/env/pull.d.ts +0 -22
- package/dist/commands/hydrogen/g.d.ts +0 -10
- package/dist/commands/hydrogen/generate/route.d.ts +0 -32
- package/dist/commands/hydrogen/generate/route.test.d.ts +0 -1
- package/dist/commands/hydrogen/generate/routes.d.ts +0 -16
- package/dist/commands/hydrogen/init.d.ts +0 -24
- package/dist/commands/hydrogen/init.test.d.ts +0 -1
- package/dist/commands/hydrogen/link.d.ts +0 -23
- package/dist/commands/hydrogen/link.test.d.ts +0 -1
- package/dist/commands/hydrogen/list.d.ts +0 -21
- package/dist/commands/hydrogen/list.test.d.ts +0 -1
- package/dist/commands/hydrogen/preview.d.ts +0 -17
- package/dist/commands/hydrogen/shortcut.d.ts +0 -9
- package/dist/commands/hydrogen/shortcut.test.d.ts +0 -1
- package/dist/commands/hydrogen/unlink.d.ts +0 -16
- package/dist/commands/hydrogen/unlink.test.d.ts +0 -1
- package/dist/create-app.d.ts +0 -1
- package/dist/generator-templates/routes/[sitemap.xml].tsx +0 -235
- package/dist/generator-templates/routes/account/login.tsx +0 -103
- package/dist/generator-templates/routes/account/register.tsx +0 -103
- package/dist/generator-templates/routes/cart.tsx +0 -81
- package/dist/generator-templates/routes/collections/$collectionHandle.tsx +0 -104
- package/dist/generator-templates/routes/collections/index.tsx +0 -102
- package/dist/generator-templates/routes/graphiql.tsx +0 -10
- package/dist/generator-templates/routes/index.tsx +0 -40
- package/dist/generator-templates/routes/pages/$pageHandle.tsx +0 -112
- package/dist/generator-templates/routes/policies/$policyHandle.tsx +0 -140
- package/dist/generator-templates/routes/policies/index.tsx +0 -117
- package/dist/generator-templates/routes/products/$productHandle.tsx +0 -92
- package/dist/hooks/init.d.ts +0 -5
- package/dist/lib/admin-session.d.ts +0 -6
- package/dist/lib/admin-session.js +0 -16
- package/dist/lib/admin-session.test.d.ts +0 -1
- package/dist/lib/admin-session.test.js +0 -27
- package/dist/lib/admin-urls.d.ts +0 -8
- package/dist/lib/check-lockfile.d.ts +0 -3
- package/dist/lib/check-lockfile.test.d.ts +0 -1
- package/dist/lib/check-version.d.ts +0 -16
- package/dist/lib/check-version.test.d.ts +0 -1
- package/dist/lib/codegen.d.ts +0 -26
- package/dist/lib/combined-environment-variables.d.ts +0 -8
- package/dist/lib/combined-environment-variables.js +0 -57
- package/dist/lib/combined-environment-variables.test.d.ts +0 -1
- package/dist/lib/combined-environment-variables.test.js +0 -111
- package/dist/lib/config.d.ts +0 -20
- package/dist/lib/flags.d.ts +0 -27
- package/dist/lib/flags.test.d.ts +0 -1
- package/dist/lib/graphql/admin/create-storefront.d.ts +0 -17
- package/dist/lib/graphql/admin/fetch-job.d.ts +0 -23
- package/dist/lib/graphql/admin/link-storefront.d.ts +0 -14
- package/dist/lib/graphql/admin/list-environments.d.ts +0 -21
- package/dist/lib/graphql/admin/list-storefronts.d.ts +0 -25
- package/dist/lib/graphql/admin/pull-variables.d.ts +0 -21
- package/dist/lib/graphql.d.ts +0 -21
- package/dist/lib/graphql.js +0 -18
- package/dist/lib/graphql.test.d.ts +0 -1
- package/dist/lib/log.d.ts +0 -6
- package/dist/lib/mini-oxygen.d.ts +0 -22
- package/dist/lib/missing-routes.d.ts +0 -8
- package/dist/lib/missing-routes.test.d.ts +0 -1
- package/dist/lib/missing-storefronts.d.ts +0 -5
- package/dist/lib/missing-storefronts.js +0 -18
- package/dist/lib/process.d.ts +0 -6
- package/dist/lib/pull-environment-variables.d.ts +0 -20
- package/dist/lib/pull-environment-variables.js +0 -57
- package/dist/lib/pull-environment-variables.test.d.ts +0 -1
- package/dist/lib/pull-environment-variables.test.js +0 -174
- package/dist/lib/remix-version-interop.d.ts +0 -11
- package/dist/lib/remix-version-interop.test.d.ts +0 -1
- package/dist/lib/render-errors.d.ts +0 -16
- package/dist/lib/shell.d.ts +0 -11
- package/dist/lib/shell.test.d.ts +0 -1
- package/dist/lib/shop.d.ts +0 -7
- package/dist/lib/shop.js +0 -32
- package/dist/lib/shop.test.d.ts +0 -1
- package/dist/lib/shop.test.js +0 -78
- package/dist/lib/shopify-config.d.ts +0 -35
- package/dist/lib/shopify-config.test.d.ts +0 -1
- package/dist/lib/string.d.ts +0 -3
- package/dist/lib/string.test.d.ts +0 -1
- package/dist/lib/template-downloader.d.ts +0 -6
- package/dist/lib/transpile-ts.d.ts +0 -16
- package/dist/lib/user-errors.d.ts +0 -9
- package/dist/lib/user-errors.js +0 -11
- package/dist/lib/virtual-routes.d.ts +0 -7
- package/dist/lib/virtual-routes.test.d.ts +0 -1
- /package/dist/{commands/hydrogen/env/list.test.d.ts → lib/setups/css/common.js} +0 -0
- /package/dist/{commands/hydrogen/env/pull.test.d.ts → lib/setups/i18n/mock-i18n-types.js} +0 -0
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ActionFunction,
|
|
3
|
-
type LoaderArgs,
|
|
4
|
-
type ErrorBoundaryComponent,
|
|
5
|
-
redirect,
|
|
6
|
-
} from '@shopify/remix-oxygen';
|
|
7
|
-
import {
|
|
8
|
-
Form,
|
|
9
|
-
useCatch,
|
|
10
|
-
useRouteError,
|
|
11
|
-
isRouteErrorResponse,
|
|
12
|
-
} from '@remix-run/react';
|
|
13
|
-
|
|
14
|
-
export async function loader({context, params}: LoaderArgs) {
|
|
15
|
-
const customerAccessToken = await context.session.get('customerAccessToken');
|
|
16
|
-
|
|
17
|
-
if (customerAccessToken) {
|
|
18
|
-
return redirect(params.lang ? `${params.lang}/account` : '/account');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return new Response(null);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const action: ActionFunction = async ({request}) => {
|
|
25
|
-
const formData = await request.formData();
|
|
26
|
-
|
|
27
|
-
const email = formData.get('email');
|
|
28
|
-
const password = formData.get('password');
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
!email ||
|
|
32
|
-
!password ||
|
|
33
|
-
typeof email !== 'string' ||
|
|
34
|
-
typeof password !== 'string'
|
|
35
|
-
) {
|
|
36
|
-
throw new Response('Please provide both an email and a password.', {
|
|
37
|
-
status: 400,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// TODO Add login logic
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default function Login() {
|
|
45
|
-
return (
|
|
46
|
-
<Form method="post">
|
|
47
|
-
<input
|
|
48
|
-
id="email"
|
|
49
|
-
name="email"
|
|
50
|
-
type="email"
|
|
51
|
-
autoComplete="email"
|
|
52
|
-
required
|
|
53
|
-
placeholder="Email address"
|
|
54
|
-
aria-label="Email address"
|
|
55
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
56
|
-
autoFocus
|
|
57
|
-
/>
|
|
58
|
-
<input
|
|
59
|
-
id="password"
|
|
60
|
-
name="password"
|
|
61
|
-
type="password"
|
|
62
|
-
autoComplete="current-password"
|
|
63
|
-
placeholder="Password"
|
|
64
|
-
aria-label="Password"
|
|
65
|
-
minLength={8}
|
|
66
|
-
required
|
|
67
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
68
|
-
autoFocus
|
|
69
|
-
/>
|
|
70
|
-
<button type="submit">Sign in</button>
|
|
71
|
-
</Form>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
76
|
-
console.error(error);
|
|
77
|
-
|
|
78
|
-
return <div>There was an error.</div>;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export function CatchBoundary() {
|
|
82
|
-
const caught = useCatch();
|
|
83
|
-
console.error(caught);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div>
|
|
87
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
88
|
-
{caught.data?.message}
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function ErrorBoundary() {
|
|
94
|
-
const error = useRouteError();
|
|
95
|
-
|
|
96
|
-
if (isRouteErrorResponse(error)) {
|
|
97
|
-
console.error(error.status, error.statusText, error.data);
|
|
98
|
-
return <div>Route Error</div>;
|
|
99
|
-
} else {
|
|
100
|
-
console.error((error as Error).message);
|
|
101
|
-
return <div>Thrown Error</div>;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ActionFunction,
|
|
3
|
-
type LoaderArgs,
|
|
4
|
-
type ErrorBoundaryComponent,
|
|
5
|
-
redirect,
|
|
6
|
-
} from '@shopify/remix-oxygen';
|
|
7
|
-
import {
|
|
8
|
-
Form,
|
|
9
|
-
useCatch,
|
|
10
|
-
useRouteError,
|
|
11
|
-
isRouteErrorResponse,
|
|
12
|
-
} from '@remix-run/react';
|
|
13
|
-
|
|
14
|
-
export async function loader({context, params}: LoaderArgs) {
|
|
15
|
-
const customerAccessToken = await context.session.get('customerAccessToken');
|
|
16
|
-
|
|
17
|
-
if (customerAccessToken) {
|
|
18
|
-
return redirect(params.lang ? `${params.lang}/account` : '/account');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return new Response(null);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const action: ActionFunction = async ({request}) => {
|
|
25
|
-
const formData = await request.formData();
|
|
26
|
-
|
|
27
|
-
const email = formData.get('email');
|
|
28
|
-
const password = formData.get('password');
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
!email ||
|
|
32
|
-
!password ||
|
|
33
|
-
typeof email !== 'string' ||
|
|
34
|
-
typeof password !== 'string'
|
|
35
|
-
) {
|
|
36
|
-
throw new Response('Please provide both an email and a password.', {
|
|
37
|
-
status: 404,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// TODO Add register logic
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default function Register() {
|
|
45
|
-
return (
|
|
46
|
-
<Form method="post">
|
|
47
|
-
<input
|
|
48
|
-
id="email"
|
|
49
|
-
name="email"
|
|
50
|
-
type="email"
|
|
51
|
-
autoComplete="email"
|
|
52
|
-
required
|
|
53
|
-
placeholder="Email address"
|
|
54
|
-
aria-label="Email address"
|
|
55
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
56
|
-
autoFocus
|
|
57
|
-
/>
|
|
58
|
-
<input
|
|
59
|
-
id="password"
|
|
60
|
-
name="password"
|
|
61
|
-
type="password"
|
|
62
|
-
autoComplete="current-password"
|
|
63
|
-
placeholder="Password"
|
|
64
|
-
aria-label="Password"
|
|
65
|
-
minLength={8}
|
|
66
|
-
required
|
|
67
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
68
|
-
autoFocus
|
|
69
|
-
/>
|
|
70
|
-
<button type="submit">Sign up</button>
|
|
71
|
-
</Form>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
76
|
-
console.error(error);
|
|
77
|
-
|
|
78
|
-
return <div>There was an error.</div>;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export function CatchBoundary() {
|
|
82
|
-
const caught = useCatch();
|
|
83
|
-
console.error(caught);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div>
|
|
87
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
88
|
-
{caught.data?.message}
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function ErrorBoundary() {
|
|
94
|
-
const error = useRouteError();
|
|
95
|
-
|
|
96
|
-
if (isRouteErrorResponse(error)) {
|
|
97
|
-
console.error(error.status, error.statusText, error.data);
|
|
98
|
-
return <div>Route Error</div>;
|
|
99
|
-
} else {
|
|
100
|
-
console.error((error as Error).message);
|
|
101
|
-
return <div>Thrown Error</div>;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Await,
|
|
3
|
-
useMatches,
|
|
4
|
-
useCatch,
|
|
5
|
-
useRouteError,
|
|
6
|
-
isRouteErrorResponse,
|
|
7
|
-
} from '@remix-run/react';
|
|
8
|
-
import {Suspense} from 'react';
|
|
9
|
-
import {flattenConnection} from '@shopify/hydrogen';
|
|
10
|
-
import type {Cart as CartType} from '@shopify/hydrogen/storefront-api-types';
|
|
11
|
-
import {type ErrorBoundaryComponent} from '@shopify/remix-oxygen';
|
|
12
|
-
|
|
13
|
-
export async function action() {
|
|
14
|
-
// @TODO implement cart action
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default function CartRoute() {
|
|
18
|
-
const [root] = useMatches();
|
|
19
|
-
return (
|
|
20
|
-
<Suspense fallback="loading">
|
|
21
|
-
<Await
|
|
22
|
-
resolve={root.data?.cart as CartType}
|
|
23
|
-
errorElement={<div>An error occurred</div>}
|
|
24
|
-
>
|
|
25
|
-
{(cart) => {
|
|
26
|
-
const linesCount = Boolean(cart?.lines?.edges?.length || 0);
|
|
27
|
-
if (!linesCount) {
|
|
28
|
-
return (
|
|
29
|
-
<p>Looks like you haven’t added anything to your cart.</p>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const cartLines = cart?.lines ? flattenConnection(cart?.lines) : [];
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<>
|
|
37
|
-
<h1>Cart</h1>
|
|
38
|
-
<ul>
|
|
39
|
-
{cartLines.map((line) => (
|
|
40
|
-
<div key={line.id}>
|
|
41
|
-
<h2>{line?.merchandise?.title}</h2>
|
|
42
|
-
</div>
|
|
43
|
-
))}
|
|
44
|
-
</ul>
|
|
45
|
-
</>
|
|
46
|
-
);
|
|
47
|
-
}}
|
|
48
|
-
</Await>
|
|
49
|
-
</Suspense>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
54
|
-
console.error(error);
|
|
55
|
-
|
|
56
|
-
return <div>There was an error.</div>;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export function CatchBoundary() {
|
|
60
|
-
const caught = useCatch();
|
|
61
|
-
console.error(caught);
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div>
|
|
65
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
66
|
-
{caught.data?.message}
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function ErrorBoundary() {
|
|
72
|
-
const error = useRouteError();
|
|
73
|
-
|
|
74
|
-
if (isRouteErrorResponse(error)) {
|
|
75
|
-
console.error(error.status, error.statusText, error.data);
|
|
76
|
-
return <div>Route Error</div>;
|
|
77
|
-
} else {
|
|
78
|
-
console.error((error as Error).message);
|
|
79
|
-
return <div>Thrown Error</div>;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
json,
|
|
3
|
-
type LoaderArgs,
|
|
4
|
-
type ErrorBoundaryComponent,
|
|
5
|
-
} from '@shopify/remix-oxygen';
|
|
6
|
-
import {
|
|
7
|
-
useLoaderData,
|
|
8
|
-
Link,
|
|
9
|
-
useCatch,
|
|
10
|
-
useRouteError,
|
|
11
|
-
isRouteErrorResponse,
|
|
12
|
-
} from '@remix-run/react';
|
|
13
|
-
import type {Collection as CollectionType} from '@shopify/hydrogen/storefront-api-types';
|
|
14
|
-
|
|
15
|
-
export async function loader({params, context}: LoaderArgs) {
|
|
16
|
-
const {collectionHandle} = params;
|
|
17
|
-
|
|
18
|
-
const {collection} = await context.storefront.query<{
|
|
19
|
-
collection: CollectionType;
|
|
20
|
-
}>(COLLECTION_QUERY, {
|
|
21
|
-
variables: {
|
|
22
|
-
handle: collectionHandle,
|
|
23
|
-
country: context.storefront.i18n?.country,
|
|
24
|
-
language: context.storefront.i18n?.language,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (!collection) {
|
|
29
|
-
throw new Response(null, {status: 404});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return json({collection});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default function Collection() {
|
|
36
|
-
const {collection} = useLoaderData<typeof loader>();
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<>
|
|
40
|
-
<h1>{collection.title}</h1>
|
|
41
|
-
{collection.products.nodes.map((product) => (
|
|
42
|
-
<div key={product.id}>
|
|
43
|
-
<Link to={`/products/${product.handle}`}>{product.title}</Link>
|
|
44
|
-
</div>
|
|
45
|
-
))}
|
|
46
|
-
</>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
51
|
-
console.error(error);
|
|
52
|
-
|
|
53
|
-
return <div>There was an error.</div>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export function CatchBoundary() {
|
|
57
|
-
const caught = useCatch();
|
|
58
|
-
console.error(caught);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div>
|
|
62
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
63
|
-
{caught.data?.message}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function ErrorBoundary() {
|
|
69
|
-
const error = useRouteError();
|
|
70
|
-
|
|
71
|
-
if (isRouteErrorResponse(error)) {
|
|
72
|
-
console.error(error.status, error.statusText, error.data);
|
|
73
|
-
return <div>Route Error</div>;
|
|
74
|
-
} else {
|
|
75
|
-
console.error((error as Error).message);
|
|
76
|
-
return <div>Thrown Error</div>;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const COLLECTION_QUERY = `#graphql
|
|
81
|
-
query collection_details(
|
|
82
|
-
$handle: String!
|
|
83
|
-
$country: CountryCode
|
|
84
|
-
$language: LanguageCode
|
|
85
|
-
|
|
86
|
-
) @inContext(country: $country, language: $language) {
|
|
87
|
-
collection(handle: $handle) {
|
|
88
|
-
id
|
|
89
|
-
handle
|
|
90
|
-
title
|
|
91
|
-
description
|
|
92
|
-
products(
|
|
93
|
-
first: 100,
|
|
94
|
-
) {
|
|
95
|
-
nodes {
|
|
96
|
-
title
|
|
97
|
-
id
|
|
98
|
-
handle
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useLoaderData,
|
|
3
|
-
Link,
|
|
4
|
-
useRouteError,
|
|
5
|
-
isRouteErrorResponse,
|
|
6
|
-
useCatch,
|
|
7
|
-
} from '@remix-run/react';
|
|
8
|
-
import {
|
|
9
|
-
json,
|
|
10
|
-
type LoaderArgs,
|
|
11
|
-
type ErrorBoundaryComponent,
|
|
12
|
-
} from '@shopify/remix-oxygen';
|
|
13
|
-
import type {CollectionConnection} from '@shopify/hydrogen/storefront-api-types';
|
|
14
|
-
import {Image} from '@shopify/hydrogen';
|
|
15
|
-
|
|
16
|
-
export async function loader({context}: LoaderArgs) {
|
|
17
|
-
const {collectionConnection} = await context.storefront.query<{
|
|
18
|
-
collectionConnection: CollectionConnection;
|
|
19
|
-
}>(COLLECTIONS_QUERY, {
|
|
20
|
-
variables: {
|
|
21
|
-
country: context.storefront.i18n?.country,
|
|
22
|
-
language: context.storefront.i18n?.language,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return json({collectionConnection});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default function Collections() {
|
|
30
|
-
const {collectionConnection} = useLoaderData<typeof loader>();
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<>
|
|
34
|
-
{collectionConnection.nodes.map((collection, collectionIndex) => {
|
|
35
|
-
return (
|
|
36
|
-
<Link key={collection.id} to={`/collections/${collection.handle}`}>
|
|
37
|
-
<h3>{collection.title}</h3>
|
|
38
|
-
{collection.image && (
|
|
39
|
-
<Image
|
|
40
|
-
data={collection.image}
|
|
41
|
-
loading={collectionIndex === 0 ? 'eager' : undefined}
|
|
42
|
-
/>
|
|
43
|
-
)}
|
|
44
|
-
</Link>
|
|
45
|
-
);
|
|
46
|
-
})}
|
|
47
|
-
</>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
52
|
-
console.error(error);
|
|
53
|
-
|
|
54
|
-
return <div>There was an error.</div>;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export function CatchBoundary() {
|
|
58
|
-
const caught = useCatch();
|
|
59
|
-
console.error(caught);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div>
|
|
63
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
64
|
-
{caught.data?.message}
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function ErrorBoundary() {
|
|
70
|
-
const error = useRouteError();
|
|
71
|
-
|
|
72
|
-
if (isRouteErrorResponse(error)) {
|
|
73
|
-
console.error(error.status, error.statusText, error.data);
|
|
74
|
-
return <div>Route Error</div>;
|
|
75
|
-
} else {
|
|
76
|
-
console.error((error as Error).message);
|
|
77
|
-
return <div>Thrown Error</div>;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const COLLECTIONS_QUERY = `#graphql
|
|
82
|
-
query collection_index(
|
|
83
|
-
$country: CountryCode
|
|
84
|
-
$language: LanguageCode
|
|
85
|
-
) @inContext(country: $country, language: $language)
|
|
86
|
-
{
|
|
87
|
-
collectionConnection: collections(first: 250) {
|
|
88
|
-
nodes {
|
|
89
|
-
id
|
|
90
|
-
title
|
|
91
|
-
handle
|
|
92
|
-
image {
|
|
93
|
-
id
|
|
94
|
-
url
|
|
95
|
-
altText
|
|
96
|
-
width
|
|
97
|
-
height
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
`;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {graphiqlLoader} from '@shopify/hydrogen';
|
|
2
|
-
import {redirect, type LoaderArgs} from '@shopify/remix-oxygen';
|
|
3
|
-
|
|
4
|
-
export async function loader(args: LoaderArgs) {
|
|
5
|
-
if (process.env.NODE_ENV === 'development') {
|
|
6
|
-
return graphiqlLoader(args);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return redirect('/');
|
|
10
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {type ErrorBoundaryComponent} from '@shopify/remix-oxygen';
|
|
2
|
-
import {useCatch, useRouteError, isRouteErrorResponse} from '@remix-run/react';
|
|
3
|
-
|
|
4
|
-
export default function Index() {
|
|
5
|
-
return (
|
|
6
|
-
<p>
|
|
7
|
-
Edit this route in <em>app/routes/index.tsx</em>.
|
|
8
|
-
</p>
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
13
|
-
console.error(error);
|
|
14
|
-
|
|
15
|
-
return <div>There was an error.</div>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function CatchBoundary() {
|
|
19
|
-
const caught = useCatch();
|
|
20
|
-
console.error(caught);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div>
|
|
24
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
25
|
-
{caught.data?.message}
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function ErrorBoundary() {
|
|
31
|
-
const error = useRouteError();
|
|
32
|
-
|
|
33
|
-
if (isRouteErrorResponse(error)) {
|
|
34
|
-
console.error(error.status, error.statusText, error.data);
|
|
35
|
-
return <div>Route Error</div>;
|
|
36
|
-
} else {
|
|
37
|
-
console.error((error as Error).message);
|
|
38
|
-
return <div>Thrown Error</div>;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
json,
|
|
3
|
-
type MetaFunction,
|
|
4
|
-
type LoaderArgs,
|
|
5
|
-
type ErrorBoundaryComponent,
|
|
6
|
-
} from '@shopify/remix-oxygen';
|
|
7
|
-
import {
|
|
8
|
-
useLoaderData,
|
|
9
|
-
type V2_MetaFunction,
|
|
10
|
-
useCatch,
|
|
11
|
-
useRouteError,
|
|
12
|
-
isRouteErrorResponse,
|
|
13
|
-
} from '@remix-run/react';
|
|
14
|
-
import type {Page as PageType} from '@shopify/hydrogen/storefront-api-types';
|
|
15
|
-
import type {SeoHandleFunction} from '@shopify/hydrogen';
|
|
16
|
-
|
|
17
|
-
export async function loader({params, context}: LoaderArgs) {
|
|
18
|
-
if (!params.pageHandle) {
|
|
19
|
-
throw new Error('Missing page handle');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const {page} = await context.storefront.query<{page: PageType}>(PAGE_QUERY, {
|
|
23
|
-
variables: {
|
|
24
|
-
handle: params.pageHandle,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (!page) {
|
|
29
|
-
throw new Response('Not Found', {
|
|
30
|
-
status: 404,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return json({page});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const seo: SeoHandleFunction<typeof loader> = ({data}) => ({
|
|
38
|
-
title: data?.page?.seo?.title,
|
|
39
|
-
description: data?.page?.seo?.description,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export const handle = {
|
|
43
|
-
seo,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const metaV1: MetaFunction = ({data}) => {
|
|
47
|
-
const {title, description} = data?.page.seo ?? {};
|
|
48
|
-
return {title, description};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const meta: V2_MetaFunction = ({data}) => {
|
|
52
|
-
const {title, description} = data?.page.seo ?? {};
|
|
53
|
-
return [{title}, {name: 'description', content: description}];
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default function Page() {
|
|
57
|
-
const {page} = useLoaderData<typeof loader>();
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<>
|
|
61
|
-
<header>
|
|
62
|
-
<h1>{page.title}</h1>
|
|
63
|
-
</header>
|
|
64
|
-
<main dangerouslySetInnerHTML={{__html: page.body}} />
|
|
65
|
-
</>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const ErrorBoundaryV1: ErrorBoundaryComponent = ({error}) => {
|
|
70
|
-
console.error(error);
|
|
71
|
-
|
|
72
|
-
return <div>There was an error.</div>;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export function CatchBoundary() {
|
|
76
|
-
const caught = useCatch();
|
|
77
|
-
console.error(caught);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<div>
|
|
81
|
-
There was an error. Status: {caught.status}. Message:{' '}
|
|
82
|
-
{caught.data?.message}
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function ErrorBoundary() {
|
|
88
|
-
const error = useRouteError();
|
|
89
|
-
|
|
90
|
-
if (isRouteErrorResponse(error)) {
|
|
91
|
-
console.error(error.status, error.statusText, error.data);
|
|
92
|
-
return <div>Route Error</div>;
|
|
93
|
-
} else {
|
|
94
|
-
console.error((error as Error).message);
|
|
95
|
-
return <div>Thrown Error</div>;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const PAGE_QUERY = `#graphql
|
|
100
|
-
query page_details($language: LanguageCode, $handle: String!)
|
|
101
|
-
@inContext(language: $language) {
|
|
102
|
-
page(handle: $handle) {
|
|
103
|
-
id
|
|
104
|
-
title
|
|
105
|
-
body
|
|
106
|
-
seo {
|
|
107
|
-
description
|
|
108
|
-
title
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
`;
|