Skip to content

Commit 11f42ae

Browse files
authored
Merge pull request #938 from Shopify/revert-931-dependabot/npm_and_yarn/vite-6.0.7
Revert "Bump vite from 5.4.11 to 6.0.7"
1 parent 7fe336d commit 11f42ae

18 files changed

+898
-1
lines changed

.graphqlrc.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import fs from "fs";
2+
import { LATEST_API_VERSION } from "@shopify/shopify-api";
3+
import { shopifyApiProject, ApiType } from "@shopify/api-codegen-preset";
4+
import type { IGraphQLConfig } from "graphql-config";
5+
6+
function getConfig() {
7+
const config: IGraphQLConfig = {
8+
projects: {
9+
default: shopifyApiProject({
10+
apiType: ApiType.Admin,
11+
apiVersion: LATEST_API_VERSION,
12+
documents: ["./app/**/*.{js,ts,jsx,tsx}", "./app/.server/**/*.{js,ts,jsx,tsx}"],
13+
outputDir: "./app/types",
14+
}),
15+
},
16+
};
17+
18+
let extensions: string[] = [];
19+
try {
20+
extensions = fs.readdirSync("./extensions");
21+
} catch {
22+
// ignore if no extensions
23+
}
24+
25+
for (const entry of extensions) {
26+
const extensionPath = `./extensions/${entry}`;
27+
const schema = `${extensionPath}/schema.graphql`;
28+
if (!fs.existsSync(schema)) {
29+
continue;
30+
}
31+
config.projects[entry] = {
32+
schema,
33+
documents: [`${extensionPath}/**/*.graphql`],
34+
};
35+
}
36+
37+
return config;
38+
}
39+
40+
const config = getConfig();
41+
42+
export default config;

app/db.server.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { PrismaClient } from "@prisma/client";
2+
3+
declare global {
4+
var prisma: PrismaClient;
5+
}
6+
7+
if (process.env.NODE_ENV !== "production") {
8+
if (!global.prisma) {
9+
global.prisma = new PrismaClient();
10+
}
11+
}
12+
13+
const prisma: PrismaClient = global.prisma || new PrismaClient();
14+
15+
export default prisma;

app/entry.server.tsx

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { PassThrough } from "stream";
2+
import { renderToPipeableStream } from "react-dom/server";
3+
import { RemixServer } from "@remix-run/react";
4+
import {
5+
createReadableStreamFromReadable,
6+
type EntryContext,
7+
} from "@remix-run/node";
8+
import { isbot } from "isbot";
9+
import { addDocumentResponseHeaders } from "./shopify.server";
10+
11+
export const streamTimeout = 5000;
12+
13+
export default async function handleRequest(
14+
request: Request,
15+
responseStatusCode: number,
16+
responseHeaders: Headers,
17+
remixContext: EntryContext
18+
) {
19+
addDocumentResponseHeaders(request, responseHeaders);
20+
const userAgent = request.headers.get("user-agent");
21+
const callbackName = isbot(userAgent ?? '')
22+
? "onAllReady"
23+
: "onShellReady";
24+
25+
return new Promise((resolve, reject) => {
26+
const { pipe, abort } = renderToPipeableStream(
27+
<RemixServer
28+
context={remixContext}
29+
url={request.url}
30+
/>,
31+
{
32+
[callbackName]: () => {
33+
const body = new PassThrough();
34+
const stream = createReadableStreamFromReadable(body);
35+
36+
responseHeaders.set("Content-Type", "text/html");
37+
resolve(
38+
new Response(stream, {
39+
headers: responseHeaders,
40+
status: responseStatusCode,
41+
})
42+
);
43+
pipe(body);
44+
},
45+
onShellError(error) {
46+
reject(error);
47+
},
48+
onError(error) {
49+
responseStatusCode = 500;
50+
console.error(error);
51+
},
52+
}
53+
);
54+
55+
// Automatically timeout the React renderer after 6 seconds, which ensures
56+
// React has enough time to flush down the rejected boundary contents
57+
setTimeout(abort, streamTimeout + 1000);
58+
});
59+
}

app/globals.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "*.css";

app/root.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {
2+
Links,
3+
Meta,
4+
Outlet,
5+
Scripts,
6+
ScrollRestoration,
7+
} from "@remix-run/react";
8+
9+
export default function App() {
10+
return (
11+
<html>
12+
<head>
13+
<meta charSet="utf-8" />
14+
<meta name="viewport" content="width=device-width,initial-scale=1" />
15+
<link rel="preconnect" href="https://cdn.shopify.com/" />
16+
<link
17+
rel="stylesheet"
18+
href="https://cdn.shopify.com/static/fonts/inter/v4/styles.css"
19+
/>
20+
<Meta />
21+
<Links />
22+
</head>
23+
<body>
24+
<Outlet />
25+
<ScrollRestoration />
26+
<Scripts />
27+
</body>
28+
</html>
29+
);
30+
}

app/routes.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { flatRoutes } from "@remix-run/fs-routes";
2+
3+
export default flatRoutes();

app/routes/_index/route.tsx

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { LoaderFunctionArgs } from "@remix-run/node";
2+
import { redirect } from "@remix-run/node";
3+
import { Form, useLoaderData } from "@remix-run/react";
4+
5+
import { login } from "../../shopify.server";
6+
7+
import styles from "./styles.module.css";
8+
9+
export const loader = async ({ request }: LoaderFunctionArgs) => {
10+
const url = new URL(request.url);
11+
12+
if (url.searchParams.get("shop")) {
13+
throw redirect(`/app?${url.searchParams.toString()}`);
14+
}
15+
16+
return { showForm: Boolean(login) };
17+
};
18+
19+
export default function App() {
20+
const { showForm } = useLoaderData<typeof loader>();
21+
22+
return (
23+
<div className={styles.index}>
24+
<div className={styles.content}>
25+
<h1 className={styles.heading}>A short heading about [your app]</h1>
26+
<p className={styles.text}>
27+
A tagline about [your app] that describes your value proposition.
28+
</p>
29+
{showForm && (
30+
<Form className={styles.form} method="post" action="/auth/login">
31+
<label className={styles.label}>
32+
<span>Shop domain</span>
33+
<input className={styles.input} type="text" name="shop" />
34+
<span>e.g: my-shop-domain.myshopify.com</span>
35+
</label>
36+
<button className={styles.button} type="submit">
37+
Log in
38+
</button>
39+
</Form>
40+
)}
41+
<ul className={styles.list}>
42+
<li>
43+
<strong>Product feature</strong>. Some detail about your feature and
44+
its benefit to your customer.
45+
</li>
46+
<li>
47+
<strong>Product feature</strong>. Some detail about your feature and
48+
its benefit to your customer.
49+
</li>
50+
<li>
51+
<strong>Product feature</strong>. Some detail about your feature and
52+
its benefit to your customer.
53+
</li>
54+
</ul>
55+
</div>
56+
</div>
57+
);
58+
}

0 commit comments

Comments
 (0)