@shopify/cli-hydrogen 3.26.0 → 4.0.0-alpha.1

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.
Files changed (249) hide show
  1. package/dist/commands/hydrogen/build.js +89 -0
  2. package/dist/commands/hydrogen/dev.js +116 -0
  3. package/dist/commands/hydrogen/init.js +42 -0
  4. package/dist/commands/hydrogen/preview.js +34 -0
  5. package/dist/hooks/init.js +21 -0
  6. package/dist/templates/demo-store/.editorconfig +8 -0
  7. package/dist/templates/demo-store/.eslintignore +4 -0
  8. package/dist/templates/demo-store/.eslintrc.js +16 -0
  9. package/dist/templates/demo-store/.graphqlrc.yml +1 -0
  10. package/dist/templates/demo-store/.prettierignore +2 -0
  11. package/dist/templates/demo-store/.turbo/turbo-build.log +13 -0
  12. package/dist/templates/demo-store/app/components/AccountAddressBook.tsx +97 -0
  13. package/dist/templates/demo-store/app/components/AccountDetails.tsx +41 -0
  14. package/dist/templates/demo-store/app/components/AddToCartButton.tsx +42 -0
  15. package/dist/templates/demo-store/app/components/Breadcrumbs.tsx +36 -0
  16. package/dist/templates/demo-store/app/components/Button.tsx +56 -0
  17. package/dist/templates/demo-store/app/components/Cart.tsx +431 -0
  18. package/dist/templates/demo-store/app/components/CartLoading.tsx +50 -0
  19. package/dist/templates/demo-store/app/components/CountrySelector.tsx +180 -0
  20. package/dist/templates/demo-store/app/components/Drawer.tsx +115 -0
  21. package/dist/templates/demo-store/app/components/FeaturedCollections.tsx +54 -0
  22. package/dist/templates/demo-store/app/components/FeaturedProducts.tsx +116 -0
  23. package/dist/templates/demo-store/app/components/FeaturedSection.tsx +39 -0
  24. package/dist/templates/demo-store/app/components/GenericError.tsx +58 -0
  25. package/dist/templates/demo-store/app/components/Grid.tsx +44 -0
  26. package/dist/templates/demo-store/app/components/Hero.tsx +136 -0
  27. package/dist/templates/demo-store/app/components/Icon.tsx +253 -0
  28. package/dist/templates/demo-store/app/components/Input.tsx +24 -0
  29. package/dist/templates/demo-store/app/components/Layout.tsx +492 -0
  30. package/dist/templates/demo-store/app/components/Link.tsx +46 -0
  31. package/dist/templates/demo-store/app/components/Modal.tsx +46 -0
  32. package/dist/templates/demo-store/app/components/NotFound.tsx +22 -0
  33. package/dist/templates/demo-store/app/components/OrderCard.tsx +85 -0
  34. package/dist/templates/demo-store/app/components/Pagination.tsx +277 -0
  35. package/dist/templates/demo-store/app/components/ProductCard.tsx +146 -0
  36. package/dist/templates/demo-store/app/components/ProductGallery.tsx +114 -0
  37. package/dist/templates/demo-store/app/components/ProductGrid.tsx +93 -0
  38. package/dist/templates/demo-store/app/components/ProductSwimlane.tsx +30 -0
  39. package/dist/templates/demo-store/app/components/Skeleton.tsx +24 -0
  40. package/dist/templates/demo-store/app/components/SortFilter.tsx +411 -0
  41. package/dist/templates/demo-store/app/components/Text.tsx +192 -0
  42. package/dist/templates/demo-store/app/components/index.ts +28 -0
  43. package/dist/templates/demo-store/app/data/countries.ts +194 -0
  44. package/dist/templates/demo-store/app/data/index.ts +1037 -0
  45. package/dist/templates/demo-store/app/entry.client.tsx +4 -0
  46. package/dist/templates/demo-store/app/entry.server.tsx +26 -0
  47. package/dist/templates/demo-store/app/hooks/useCartFetchers.tsx +14 -0
  48. package/dist/templates/demo-store/app/hooks/useIsHydrated.tsx +12 -0
  49. package/dist/templates/demo-store/app/lib/const.ts +10 -0
  50. package/dist/templates/demo-store/app/lib/placeholders.ts +242 -0
  51. package/dist/templates/demo-store/app/lib/seo/common.tsx +324 -0
  52. package/dist/templates/demo-store/app/lib/seo/debugger.tsx +175 -0
  53. package/dist/templates/demo-store/app/lib/seo/image.tsx +32 -0
  54. package/dist/templates/demo-store/app/lib/seo/index.ts +4 -0
  55. package/dist/templates/demo-store/app/lib/seo/seo.tsx +24 -0
  56. package/dist/templates/demo-store/app/lib/seo/types.ts +70 -0
  57. package/dist/templates/demo-store/app/lib/session.server.ts +57 -0
  58. package/dist/templates/demo-store/app/lib/type.ts +21 -0
  59. package/dist/templates/demo-store/app/lib/utils.ts +310 -0
  60. package/dist/templates/demo-store/app/root.tsx +282 -0
  61. package/dist/templates/demo-store/app/routes/$.tsx +7 -0
  62. package/dist/templates/demo-store/app/routes/$lang/$.tsx +1 -0
  63. package/dist/templates/demo-store/app/routes/$lang/[robots.txt].tsx +1 -0
  64. package/dist/templates/demo-store/app/routes/$lang/[sitemap.xml].tsx +1 -0
  65. package/dist/templates/demo-store/app/routes/$lang/account/__private/address/$id.tsx +1 -0
  66. package/dist/templates/demo-store/app/routes/$lang/account/__private/edit.tsx +1 -0
  67. package/dist/templates/demo-store/app/routes/$lang/account/__private/logout.ts +1 -0
  68. package/dist/templates/demo-store/app/routes/$lang/account/__private/orders.$id.tsx +1 -0
  69. package/dist/templates/demo-store/app/routes/$lang/account/__public/activate.$id.$activationToken.tsx +6 -0
  70. package/dist/templates/demo-store/app/routes/$lang/account/__public/login.tsx +7 -0
  71. package/dist/templates/demo-store/app/routes/$lang/account/__public/recover.tsx +1 -0
  72. package/dist/templates/demo-store/app/routes/$lang/account/__public/register.tsx +6 -0
  73. package/dist/templates/demo-store/app/routes/$lang/account/__public/reset.$id.$resetToken.tsx +5 -0
  74. package/dist/templates/demo-store/app/routes/$lang/account.tsx +1 -0
  75. package/dist/templates/demo-store/app/routes/$lang/api/countries.tsx +1 -0
  76. package/dist/templates/demo-store/app/routes/$lang/api/products.tsx +1 -0
  77. package/dist/templates/demo-store/app/routes/$lang/cart.tsx +1 -0
  78. package/dist/templates/demo-store/app/routes/$lang/collections/$collectionHandle.tsx +6 -0
  79. package/dist/templates/demo-store/app/routes/$lang/collections/all.tsx +1 -0
  80. package/dist/templates/demo-store/app/routes/$lang/collections/index.tsx +1 -0
  81. package/dist/templates/demo-store/app/routes/$lang/featured-products.tsx +1 -0
  82. package/dist/templates/demo-store/app/routes/$lang/index.tsx +7 -0
  83. package/dist/templates/demo-store/app/routes/$lang/journal/$journalHandle.tsx +7 -0
  84. package/dist/templates/demo-store/app/routes/$lang/journal/index.tsx +1 -0
  85. package/dist/templates/demo-store/app/routes/$lang/og-image.tsx +1 -0
  86. package/dist/templates/demo-store/app/routes/$lang/pages/$pageHandle.tsx +1 -0
  87. package/dist/templates/demo-store/app/routes/$lang/policies/$policyHandle.tsx +1 -0
  88. package/dist/templates/demo-store/app/routes/$lang/policies/index.tsx +1 -0
  89. package/dist/templates/demo-store/app/routes/$lang/products/$productHandle.tsx +6 -0
  90. package/dist/templates/demo-store/app/routes/$lang/products/index.tsx +1 -0
  91. package/dist/templates/demo-store/app/routes/$lang/search.tsx +6 -0
  92. package/dist/templates/demo-store/app/routes/[robots.txt].tsx +40 -0
  93. package/dist/templates/demo-store/app/routes/[sitemap.xml].tsx +198 -0
  94. package/dist/templates/demo-store/app/routes/account/__private/address/$id.tsx +320 -0
  95. package/dist/templates/demo-store/app/routes/account/__private/edit.tsx +273 -0
  96. package/dist/templates/demo-store/app/routes/account/__private/logout.ts +29 -0
  97. package/dist/templates/demo-store/app/routes/account/__private/orders.$id.tsx +324 -0
  98. package/dist/templates/demo-store/app/routes/account/__public/activate.$id.$activationToken.tsx +218 -0
  99. package/dist/templates/demo-store/app/routes/account/__public/login.tsx +197 -0
  100. package/dist/templates/demo-store/app/routes/account/__public/recover.tsx +144 -0
  101. package/dist/templates/demo-store/app/routes/account/__public/register.tsx +184 -0
  102. package/dist/templates/demo-store/app/routes/account/__public/reset.$id.$resetToken.tsx +214 -0
  103. package/dist/templates/demo-store/app/routes/account.tsx +191 -0
  104. package/dist/templates/demo-store/app/routes/api/countries.tsx +22 -0
  105. package/dist/templates/demo-store/app/routes/api/products.tsx +116 -0
  106. package/dist/templates/demo-store/app/routes/cart.tsx +498 -0
  107. package/dist/templates/demo-store/app/routes/collections/$collectionHandle.tsx +308 -0
  108. package/dist/templates/demo-store/app/routes/collections/all.tsx +5 -0
  109. package/dist/templates/demo-store/app/routes/collections/index.tsx +195 -0
  110. package/dist/templates/demo-store/app/routes/discounts.$code.tsx +60 -0
  111. package/dist/templates/demo-store/app/routes/featured-products.tsx +58 -0
  112. package/dist/templates/demo-store/app/routes/index.tsx +254 -0
  113. package/dist/templates/demo-store/app/routes/journal/$journalHandle.tsx +147 -0
  114. package/dist/templates/demo-store/app/routes/journal/index.tsx +150 -0
  115. package/dist/templates/demo-store/app/routes/og-image.tsx +19 -0
  116. package/dist/templates/demo-store/app/routes/pages/$pageHandle.tsx +82 -0
  117. package/dist/templates/demo-store/app/routes/policies/$policyHandle.tsx +117 -0
  118. package/dist/templates/demo-store/app/routes/policies/index.tsx +104 -0
  119. package/dist/templates/demo-store/app/routes/products/$productHandle.tsx +561 -0
  120. package/dist/templates/demo-store/app/routes/products/index.tsx +155 -0
  121. package/dist/templates/demo-store/app/routes/search.tsx +205 -0
  122. package/dist/templates/demo-store/app/styles/custom-font.css +13 -0
  123. package/dist/templates/demo-store/package-lock.json +25515 -0
  124. package/dist/templates/demo-store/package.json +67 -0
  125. package/dist/templates/demo-store/playwright.config.ts +109 -0
  126. package/dist/templates/demo-store/postcss.config.js +10 -0
  127. package/dist/templates/demo-store/public/favicon.svg +28 -0
  128. package/dist/templates/demo-store/public/fonts/IBMPlexSerif-Text.woff2 +0 -0
  129. package/dist/templates/demo-store/public/fonts/IBMPlexSerif-TextItalic.woff2 +0 -0
  130. package/dist/templates/demo-store/remix.config.js +12 -0
  131. package/dist/templates/demo-store/remix.env.d.ts +34 -0
  132. package/dist/templates/demo-store/remix.init/index.ts +15 -0
  133. package/dist/templates/demo-store/remix.init/package.json +7 -0
  134. package/dist/templates/demo-store/server.ts +87 -0
  135. package/dist/templates/demo-store/styles/app.css +182 -0
  136. package/dist/templates/demo-store/tailwind.config.js +70 -0
  137. package/dist/templates/demo-store/tests/cart.test.ts +70 -0
  138. package/dist/templates/demo-store/tests/seo.test.ts +36 -0
  139. package/dist/templates/demo-store/tests/utils.ts +100 -0
  140. package/dist/templates/demo-store/tsconfig.json +26 -0
  141. package/dist/templates/hello-world/.eslintignore +4 -0
  142. package/dist/templates/hello-world/.eslintrc.js +6 -0
  143. package/dist/templates/hello-world/.graphqlrc.yml +1 -0
  144. package/dist/templates/hello-world/.turbo/turbo-build.log +9 -0
  145. package/dist/templates/hello-world/README.md +20 -0
  146. package/dist/templates/hello-world/app/components/Layout.tsx +15 -0
  147. package/dist/templates/hello-world/app/components/index.ts +1 -0
  148. package/dist/templates/hello-world/app/entry.client.tsx +4 -0
  149. package/dist/templates/hello-world/app/entry.server.tsx +21 -0
  150. package/dist/templates/hello-world/app/root.tsx +212 -0
  151. package/dist/templates/hello-world/app/routes/index.tsx +7 -0
  152. package/dist/templates/hello-world/app/styles/app.css +38 -0
  153. package/dist/templates/hello-world/package-lock.json +27641 -0
  154. package/dist/templates/hello-world/package.json +41 -0
  155. package/dist/templates/hello-world/public/favicon.svg +28 -0
  156. package/dist/templates/hello-world/remix.env.d.ts +29 -0
  157. package/dist/templates/hello-world/server.ts +127 -0
  158. package/dist/templates/hello-world/tsconfig.json +25 -0
  159. package/dist/utils/config.js +81 -0
  160. package/dist/utils/flags.js +15 -0
  161. package/dist/utils/log.js +20 -0
  162. package/dist/utils/mini-oxygen.js +70 -0
  163. package/package.json +27 -64
  164. package/tmp-create-app.mjs +29 -0
  165. package/LICENSE +0 -8
  166. package/README.md +0 -61
  167. package/dist/cli/commands/hydrogen/add/eslint.d.ts +0 -11
  168. package/dist/cli/commands/hydrogen/add/eslint.js +0 -26
  169. package/dist/cli/commands/hydrogen/add/eslint.js.map +0 -1
  170. package/dist/cli/commands/hydrogen/add/tailwind.d.ts +0 -11
  171. package/dist/cli/commands/hydrogen/add/tailwind.js +0 -26
  172. package/dist/cli/commands/hydrogen/add/tailwind.js.map +0 -1
  173. package/dist/cli/commands/hydrogen/build.d.ts +0 -14
  174. package/dist/cli/commands/hydrogen/build.js +0 -49
  175. package/dist/cli/commands/hydrogen/build.js.map +0 -1
  176. package/dist/cli/commands/hydrogen/deploy.d.ts +0 -19
  177. package/dist/cli/commands/hydrogen/deploy.js +0 -58
  178. package/dist/cli/commands/hydrogen/deploy.js.map +0 -1
  179. package/dist/cli/commands/hydrogen/dev.d.ts +0 -13
  180. package/dist/cli/commands/hydrogen/dev.js +0 -31
  181. package/dist/cli/commands/hydrogen/dev.js.map +0 -1
  182. package/dist/cli/commands/hydrogen/info.d.ts +0 -12
  183. package/dist/cli/commands/hydrogen/info.js +0 -28
  184. package/dist/cli/commands/hydrogen/info.js.map +0 -1
  185. package/dist/cli/commands/hydrogen/preview.d.ts +0 -13
  186. package/dist/cli/commands/hydrogen/preview.js +0 -46
  187. package/dist/cli/commands/hydrogen/preview.js.map +0 -1
  188. package/dist/cli/constants.d.ts +0 -15
  189. package/dist/cli/constants.js +0 -16
  190. package/dist/cli/constants.js.map +0 -1
  191. package/dist/cli/flags.d.ts +0 -4
  192. package/dist/cli/flags.js +0 -16
  193. package/dist/cli/flags.js.map +0 -1
  194. package/dist/cli/models/hydrogen.d.ts +0 -22
  195. package/dist/cli/models/hydrogen.js +0 -82
  196. package/dist/cli/models/hydrogen.js.map +0 -1
  197. package/dist/cli/prompts/git-init.d.ts +0 -1
  198. package/dist/cli/prompts/git-init.js +0 -16
  199. package/dist/cli/prompts/git-init.js.map +0 -1
  200. package/dist/cli/services/build/check-lockfile.d.ts +0 -3
  201. package/dist/cli/services/build/check-lockfile.js +0 -80
  202. package/dist/cli/services/build/check-lockfile.js.map +0 -1
  203. package/dist/cli/services/build.d.ts +0 -14
  204. package/dist/cli/services/build.js +0 -44
  205. package/dist/cli/services/build.js.map +0 -1
  206. package/dist/cli/services/deploy/config.d.ts +0 -4
  207. package/dist/cli/services/deploy/config.js +0 -49
  208. package/dist/cli/services/deploy/config.js.map +0 -1
  209. package/dist/cli/services/deploy/error.d.ts +0 -4
  210. package/dist/cli/services/deploy/error.js +0 -11
  211. package/dist/cli/services/deploy/error.js.map +0 -1
  212. package/dist/cli/services/deploy/graphql/create_deployment.d.ts +0 -10
  213. package/dist/cli/services/deploy/graphql/create_deployment.js +0 -15
  214. package/dist/cli/services/deploy/graphql/create_deployment.js.map +0 -1
  215. package/dist/cli/services/deploy/graphql/upload_deployment.d.ts +0 -1
  216. package/dist/cli/services/deploy/graphql/upload_deployment.js +0 -16
  217. package/dist/cli/services/deploy/graphql/upload_deployment.js.map +0 -1
  218. package/dist/cli/services/deploy/types.d.ts +0 -37
  219. package/dist/cli/services/deploy/types.js +0 -2
  220. package/dist/cli/services/deploy/types.js.map +0 -1
  221. package/dist/cli/services/deploy/upload.d.ts +0 -5
  222. package/dist/cli/services/deploy/upload.js +0 -81
  223. package/dist/cli/services/deploy/upload.js.map +0 -1
  224. package/dist/cli/services/deploy.d.ts +0 -2
  225. package/dist/cli/services/deploy.js +0 -103
  226. package/dist/cli/services/deploy.js.map +0 -1
  227. package/dist/cli/services/dev/check-version.d.ts +0 -1
  228. package/dist/cli/services/dev/check-version.js +0 -30
  229. package/dist/cli/services/dev/check-version.js.map +0 -1
  230. package/dist/cli/services/dev.d.ts +0 -10
  231. package/dist/cli/services/dev.js +0 -36
  232. package/dist/cli/services/dev.js.map +0 -1
  233. package/dist/cli/services/eslint.d.ts +0 -8
  234. package/dist/cli/services/eslint.js +0 -74
  235. package/dist/cli/services/eslint.js.map +0 -1
  236. package/dist/cli/services/info.d.ts +0 -7
  237. package/dist/cli/services/info.js +0 -131
  238. package/dist/cli/services/info.js.map +0 -1
  239. package/dist/cli/services/preview.d.ts +0 -12
  240. package/dist/cli/services/preview.js +0 -63
  241. package/dist/cli/services/preview.js.map +0 -1
  242. package/dist/cli/services/tailwind.d.ts +0 -9
  243. package/dist/cli/services/tailwind.js +0 -103
  244. package/dist/cli/services/tailwind.js.map +0 -1
  245. package/dist/cli/utilities/load-config.d.ts +0 -5
  246. package/dist/cli/utilities/load-config.js +0 -6
  247. package/dist/cli/utilities/load-config.js.map +0 -1
  248. package/dist/tsconfig.tsbuildinfo +0 -1
  249. package/oclif.manifest.json +0 -1
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "hello-world",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "sideEffects": false,
6
+ "scripts": {
7
+ "build": "shopify hydrogen build --entry ./server",
8
+ "dev": "shopify hydrogen dev --entry ./server",
9
+ "lint": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx .",
10
+ "preview": "npm run build && shopify hydrogen preview",
11
+ "typecheck": "tsc --noEmit"
12
+ },
13
+ "prettier": "@shopify/prettier-config",
14
+ "dependencies": {
15
+ "@remix-run/react": "0.0.0-experimental-e18af792a",
16
+ "@shopify/cli": "^3.23.0",
17
+ "@shopify/cli-hydrogen": "^4.0.0-alpha.1",
18
+ "@shopify/hydrogen": "^2.0.0-alpha.1",
19
+ "@shopify/hydrogen-react": "^2022.10.3",
20
+ "@shopify/remix-oxygen": "^1.0.0-alpha.1",
21
+ "graphql": "^16.6.0",
22
+ "graphql-tag": "^2.12.6",
23
+ "react": "^18.2.0",
24
+ "react-dom": "^18.2.0"
25
+ },
26
+ "devDependencies": {
27
+ "@remix-run/dev": "0.0.0-experimental-e18af792a",
28
+ "@shopify/oxygen-workers-types": "^3.17.2",
29
+ "@shopify/prettier-config": "^1.1.2",
30
+ "@types/eslint": "^8.4.10",
31
+ "@types/react": "^18.0.20",
32
+ "@types/react-dom": "^18.0.6",
33
+ "eslint": "^8.20.0",
34
+ "eslint-plugin-hydrogen": "0.12.2",
35
+ "prettier": "^2.7.1",
36
+ "typescript": "^4.8.3"
37
+ },
38
+ "engines": {
39
+ "node": ">=16.13"
40
+ }
41
+ }
@@ -0,0 +1,28 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="none">
2
+ <style>
3
+ .stroke {
4
+ stroke: #000;
5
+ }
6
+ .fill {
7
+ fill: #000;
8
+ }
9
+ @media (prefers-color-scheme: dark) {
10
+ .stroke {
11
+ stroke: #fff;
12
+ }
13
+ .fill {
14
+ fill: #fff;
15
+ }
16
+ }
17
+ </style>
18
+ <path
19
+ class="stroke"
20
+ fill-rule="evenodd"
21
+ d="M16.1 16.04 1 8.02 6.16 5.3l5.82 3.09 4.88-2.57-5.82-3.1L16.21 0l15.1 8.02-5.17 2.72-5.5-2.91-4.88 2.57 5.5 2.92-5.16 2.72Z"
22
+ />
23
+ <path
24
+ class="fill"
25
+ fill-rule="evenodd"
26
+ d="M16.1 32 1 23.98l5.16-2.72 5.82 3.08 4.88-2.57-5.82-3.08 5.17-2.73 15.1 8.02-5.17 2.72-5.5-2.92-4.88 2.58 5.5 2.92L16.1 32Z"
27
+ />
28
+ </svg>
@@ -0,0 +1,29 @@
1
+ /// <reference types="@remix-run/dev" />
2
+ /// <reference types="@shopify/remix-oxygen" />
3
+ /// <reference types="@shopify/oxygen-workers-types" />
4
+
5
+ import type {StorefrontClient} from '@shopify/hydrogen';
6
+ import type {HydrogenSession} from '../server';
7
+
8
+ /**
9
+ * Declare expected Env parameter in fetch handler.
10
+ */
11
+ declare global {
12
+ interface Env {
13
+ SESSION_SECRET: string;
14
+ SHOPIFY_STOREFRONT_API_PUBLIC_TOKEN: string;
15
+ SHOPIFY_STOREFRONT_API_VERSION: string;
16
+ SHOPIFY_STORE_DOMAIN: string;
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Declare local additions to `AppLoadContext` to include the session utilities we injected in `server.ts`.
22
+ */
23
+ declare module '@shopify/remix-oxygen' {
24
+ export interface AppLoadContext {
25
+ session: HydrogenSession;
26
+ storefront: StorefrontClient['storefront'];
27
+ env: Env;
28
+ }
29
+ }
@@ -0,0 +1,127 @@
1
+ // Virtual entry point for the app
2
+ import * as remixBuild from '@remix-run/dev/server-build';
3
+ import {createStorefrontClient} from '@shopify/hydrogen';
4
+ import {
5
+ createRequestHandler,
6
+ getBuyerIp,
7
+ createCookieSessionStorage,
8
+ type SessionStorage,
9
+ type Session,
10
+ } from '@shopify/remix-oxygen';
11
+
12
+ /**
13
+ * A global `process` object is only available during build to access NODE_ENV.
14
+ */
15
+ declare const process: {env: {NODE_ENV: string}};
16
+
17
+ /**
18
+ * Export a fetch handler in module format.
19
+ */
20
+ export default {
21
+ async fetch(
22
+ request: Request,
23
+ env: Env,
24
+ executionContext: ExecutionContext,
25
+ ): Promise<Response> {
26
+ try {
27
+ /**
28
+ * Open a cache instance in the worker and a custom session instance.
29
+ */
30
+ if (!env?.SESSION_SECRET) {
31
+ throw new Error('SESSION_SECRET environment variable is not set');
32
+ }
33
+
34
+ const [cache, session] = await Promise.all([
35
+ caches.open('hydrogen'),
36
+ HydrogenSession.init(request, [env.SESSION_SECRET]),
37
+ ]);
38
+
39
+ /**
40
+ * Create a Remix request handler and pass
41
+ * Hydrogen's Storefront client to the loader context.
42
+ */
43
+ const handleRequest = createRequestHandler({
44
+ build: remixBuild,
45
+ mode: process.env.NODE_ENV,
46
+ getLoadContext() {
47
+ const waitUntil = executionContext.waitUntil.bind(executionContext);
48
+
49
+ const {storefront} = createStorefrontClient({
50
+ cache,
51
+ waitUntil,
52
+ buyerIp: getBuyerIp(request),
53
+ i18n: {language: 'EN', country: 'US'},
54
+ publicStorefrontToken: env.SHOPIFY_STOREFRONT_API_PUBLIC_TOKEN,
55
+ storeDomain: env.SHOPIFY_STORE_DOMAIN,
56
+ storefrontApiVersion:
57
+ env.SHOPIFY_STOREFRONT_API_VERSION || '2022-10',
58
+ });
59
+
60
+ return {
61
+ session,
62
+ storefront,
63
+ env,
64
+ };
65
+ },
66
+ });
67
+
68
+ return await handleRequest(request);
69
+ } catch (error) {
70
+ // eslint-disable-next-line no-console
71
+ console.error(error);
72
+ return new Response('An unexpected error occurred', {status: 500});
73
+ }
74
+ },
75
+ };
76
+
77
+ /**
78
+ * This is a custom session implementation for your Hydrogen shop.
79
+ * Feel free to customize it to your needs, add helper methods, or
80
+ * swap out the cookie-based implementation with something else!
81
+ */
82
+ class HydrogenSession {
83
+ constructor(
84
+ private sessionStorage: SessionStorage,
85
+ private session: Session,
86
+ ) {}
87
+
88
+ static async init(request: Request, secrets: string[]) {
89
+ const storage = createCookieSessionStorage({
90
+ cookie: {
91
+ name: 'session',
92
+ httpOnly: true,
93
+ path: '/',
94
+ sameSite: 'lax',
95
+ secrets,
96
+ },
97
+ });
98
+
99
+ const session = await storage.getSession(request.headers.get('Cookie'));
100
+
101
+ return new this(storage, session);
102
+ }
103
+
104
+ get(key: string) {
105
+ return this.session.get(key);
106
+ }
107
+
108
+ destroy() {
109
+ return this.sessionStorage.destroySession(this.session);
110
+ }
111
+
112
+ flash(key: string, value: any) {
113
+ this.session.flash(key, value);
114
+ }
115
+
116
+ unset(key: string) {
117
+ this.session.unset(key);
118
+ }
119
+
120
+ set(key: string, value: any) {
121
+ this.session.set(key, value);
122
+ }
123
+
124
+ commit() {
125
+ return this.sessionStorage.commitSession(this.session);
126
+ }
127
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "include": ["./**/*.d.ts", "./**/*.ts", "./**/*.tsx"],
3
+ "compilerOptions": {
4
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
5
+ "isolatedModules": true,
6
+ "esModuleInterop": true,
7
+ "jsx": "react-jsx",
8
+ "moduleResolution": "node",
9
+ "resolveJsonModule": true,
10
+ "target": "ES2022",
11
+ "strict": true,
12
+ "allowJs": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "skipLibCheck": true,
15
+ "baseUrl": ".",
16
+ "types": ["@shopify/oxygen-workers-types"],
17
+ "paths": {
18
+ "~/*": ["app/*"]
19
+ },
20
+
21
+ // Remix takes care of building everything in `./app` with `remix build`.
22
+ // Wrangler takes care of building everything in `./worker` with `wrangler start` / `wrangler publish`.
23
+ "noEmit": true
24
+ }
25
+ }
@@ -0,0 +1,81 @@
1
+ import { readConfig } from '@remix-run/dev/dist/config.js';
2
+ import { createRequire } from 'module';
3
+ import path from 'path';
4
+ import fs from 'fs-extra';
5
+
6
+ const BUILD_DIR = "dist";
7
+ const CLIENT_SUBDIR = "client";
8
+ const WORKER_SUBDIR = "worker";
9
+ function getProjectPaths(appPath, entry) {
10
+ const root = appPath ?? process.cwd();
11
+ const publicPath = path.join(root, "public");
12
+ const buildPath = path.join(root, BUILD_DIR);
13
+ const buildPathClient = path.join(buildPath, CLIENT_SUBDIR);
14
+ const buildPathWorkerFile = path.join(buildPath, WORKER_SUBDIR, "index.js");
15
+ const entryFile = entry ? path.join(root, entry) : "";
16
+ return {
17
+ root,
18
+ entryFile,
19
+ buildPath,
20
+ buildPathClient,
21
+ buildPathWorkerFile,
22
+ publicPath
23
+ };
24
+ }
25
+ let cachedConfig;
26
+ async function getRemixConfig(root, entryFile, publicPath, bustCacheFile, mode = process.env.NODE_ENV) {
27
+ if (!cachedConfig || bustCacheFile) {
28
+ let env = process.env.NODE_ENV;
29
+ if (bustCacheFile) {
30
+ const require2 = createRequire(import.meta.url);
31
+ delete require2.cache[bustCacheFile];
32
+ process.env.NODE_ENV = "test";
33
+ }
34
+ const config = await readConfig(root, mode);
35
+ process.env.NODE_ENV = env;
36
+ const hydrogenAssetBase = process.env.HYDROGEN_ASSET_BASE_URL;
37
+ if (hydrogenAssetBase) {
38
+ const suffix = config.publicPath?.replace(/\\/g, "/").replace(/^\//, "");
39
+ config.publicPath = hydrogenAssetBase + suffix;
40
+ }
41
+ config.serverEntryPoint ??= entryFile;
42
+ config.serverBuildTarget = "cloudflare-workers";
43
+ config.serverModuleFormat = "esm";
44
+ config.serverPlatform = "neutral";
45
+ config.serverBuildPath = path.resolve(
46
+ root,
47
+ path.join(BUILD_DIR, WORKER_SUBDIR, "index.js")
48
+ );
49
+ config.relativeAssetsBuildDirectory = path.join(
50
+ BUILD_DIR,
51
+ CLIENT_SUBDIR,
52
+ "build"
53
+ );
54
+ config.assetsBuildDirectory = path.resolve(
55
+ root,
56
+ config.relativeAssetsBuildDirectory
57
+ );
58
+ config.watchPaths = [publicPath, path.resolve(root, "remix.config.*")];
59
+ if (process.env.LOCAL_DEV) {
60
+ const packagesPath = new URL("../../..", import.meta.url).pathname;
61
+ config.watchPaths.push(
62
+ ...(await fs.readdir(packagesPath)).flatMap((pkg) => {
63
+ const files = [
64
+ path.resolve(packagesPath, pkg, "dist", "development", "index.js")
65
+ ];
66
+ if (pkg === "hydrogen") {
67
+ files.push(
68
+ path.resolve(packagesPath, pkg, "dist", "build", "index.js"),
69
+ path.resolve(packagesPath, pkg, "src", "templates", "**", "*")
70
+ );
71
+ }
72
+ return files;
73
+ })
74
+ );
75
+ }
76
+ cachedConfig = config;
77
+ }
78
+ return cachedConfig;
79
+ }
80
+
81
+ export { getProjectPaths, getRemixConfig };
@@ -0,0 +1,15 @@
1
+ import { Flags } from '@oclif/core';
2
+
3
+ const flags = {
4
+ path: Flags.string({
5
+ description: "the path to your hydrogen storefront",
6
+ env: "SHOPIFY_HYDROGEN_FLAG_PATH"
7
+ }),
8
+ port: Flags.integer({
9
+ description: "Port to run the preview server on",
10
+ env: "SHOPIFY_HYDROGEN_FLAG_PORT",
11
+ default: 3e3
12
+ })
13
+ };
14
+
15
+ export { flags };
@@ -0,0 +1,20 @@
1
+ let isFirstWorkerReload = true;
2
+ function muteDevLogs({ workerReload } = {}) {
3
+ const log = console.log.bind(console);
4
+ console.log = (first, ...rest) => {
5
+ if (typeof first === "string" && first.includes("[mf:")) {
6
+ if (workerReload !== false && first.includes("Worker reloaded")) {
7
+ if (isFirstWorkerReload)
8
+ isFirstWorkerReload = false;
9
+ else
10
+ return log(first.replace("[mf:inf] ", "\u{1F504} ") + "\n", ...rest);
11
+ }
12
+ if (!first.includes("[mf:err]")) {
13
+ return;
14
+ }
15
+ }
16
+ return log(first, ...rest);
17
+ };
18
+ }
19
+
20
+ export { muteDevLogs };
@@ -0,0 +1,70 @@
1
+ import path from 'path';
2
+ import miniOxygen from '@shopify/mini-oxygen';
3
+ import { output } from '@shopify/cli-kit';
4
+ import colors from '@shopify/cli-kit/node/colors';
5
+
6
+ const miniOxygenPreview = miniOxygen.default ?? miniOxygen;
7
+ async function startMiniOxygen({
8
+ root,
9
+ port = 3e3,
10
+ watch = false,
11
+ buildPathWorkerFile,
12
+ buildPathClient
13
+ }) {
14
+ const { port: actualPort } = await miniOxygenPreview({
15
+ workerFile: buildPathWorkerFile,
16
+ assetsDir: buildPathClient,
17
+ publicPath: "",
18
+ port,
19
+ watch,
20
+ autoReload: watch,
21
+ modules: true,
22
+ env: process.env,
23
+ envPath: path.resolve(root, ".env"),
24
+ log: () => {
25
+ },
26
+ buildWatchPaths: watch ? [path.resolve(root, buildPathWorkerFile)] : void 0,
27
+ onResponse: (request, response) => logResponse(request, response)
28
+ });
29
+ const listeningAt = `http://localhost:${actualPort}`;
30
+ output.info(
31
+ output.content`🚥 MiniOxygen server started at ${output.token.link(
32
+ listeningAt,
33
+ listeningAt
34
+ )}\n`
35
+ );
36
+ }
37
+ function logResponse(request, response) {
38
+ try {
39
+ const url = new URL(request.url);
40
+ if (["/graphiql"].includes(url.pathname))
41
+ return;
42
+ const isProxy = !!response.url && response.url !== request.url;
43
+ const isDataRequest = !isProxy && url.searchParams.has("_data");
44
+ let route = request.url.replace(url.origin, "");
45
+ let info = "";
46
+ let type = "render";
47
+ if (isProxy) {
48
+ type = "proxy";
49
+ info = `[${response.url}]`;
50
+ }
51
+ if (isDataRequest) {
52
+ type = request.method === "GET" ? "loader" : "action";
53
+ const dataParam = url.searchParams.get("_data")?.replace("routes/", "");
54
+ route = url.pathname;
55
+ info = `[${dataParam?.includes("/.hydrogen/") ? dataParam.replace(/^.*(\.hydrogen\/)/, "$1") : dataParam}]`;
56
+ }
57
+ const colorizeStatus = response.status < 300 ? output.token.green : response.status < 400 ? output.token.cyan : output.token.errorText;
58
+ output.info(
59
+ output.content`${request.method.padStart(6)} ${colorizeStatus(
60
+ String(response.status)
61
+ )} ${output.token.italic(type.padEnd(7, " "))} ${route}${info ? " " + colors.dim(info) : ""} ${request.headers.get("purpose") === "prefetch" ? output.token.italic("(prefetch)") : ""}`
62
+ );
63
+ } catch {
64
+ if (request && response) {
65
+ output.info(`${request.method} ${response.status} ${request.url}`);
66
+ }
67
+ }
68
+ }
69
+
70
+ export { logResponse, startMiniOxygen };
package/package.json CHANGED
@@ -1,77 +1,40 @@
1
1
  {
2
2
  "name": "@shopify/cli-hydrogen",
3
- "version": "3.26.0",
4
- "private": false,
5
- "description": "Commands for building Hydrogen storefronts",
6
- "license": "MIT",
7
- "bugs": {
8
- "url": "https://github.com/Shopify/cli/issues"
9
- },
10
- "homepage": "https://github.com/shopify/cli#readme",
11
- "type": "module",
12
- "files": [
13
- "/dist",
14
- "/oclif.manifest.json"
15
- ],
16
3
  "publishConfig": {
17
4
  "access": "public",
18
5
  "@shopify:registry": "https://registry.npmjs.org"
19
6
  },
20
- "exports": {
21
- "./commands/hydrogen/init": {
22
- "import": "./dist/commands/hydrogen/init.js",
23
- "types": "./dist/commands/hydrogen/init.d.ts"
24
- }
25
- },
26
- "eslintConfig": {
27
- "extends": [
28
- "../../.eslintrc.cjs"
29
- ]
30
- },
31
- "dependencies": {
32
- "@oclif/core": "1.9.2",
33
- "@shopify/hydrogen": "0.26.0",
34
- "@shopify/mini-oxygen": "0.2.0",
35
- "@types/prettier": "2.6.3",
36
- "prettier": "2.6.1",
37
- "vite": "2.9.13",
38
- "@shopify/cli-kit": "3.26.0",
39
- "fast-glob": "3.2.11",
40
- "fs-extra": "10.0.0",
41
- "typescript": "4.6.4",
42
- "@shopify/prettier-config": "1.1.2",
43
- "graphql-request": "4.3.0"
7
+ "version": "4.0.0-alpha.1",
8
+ "type": "module",
9
+ "scripts": {
10
+ "build": "tsup --clean --config ./tsup.config.ts",
11
+ "dev": "tsup --watch --config ./tsup.config.ts",
12
+ "typecheck": "tsc --noEmit"
44
13
  },
45
14
  "devDependencies": {
46
- "@types/fs-extra": "9.0.13",
47
- "vitest": "^0.23.4",
48
- "graphql": "^16.0.0",
49
- "react": "^18.2.0",
50
- "react-dom": "^18.2.0"
15
+ "@types/fs-extra": "^9.0.13"
51
16
  },
52
- "engine-strict": true,
53
- "engines": {
54
- "node": ">=14.17.0"
17
+ "dependencies": {
18
+ "@oclif/core": "^1.20.4",
19
+ "@remix-run/dev": "0.0.0-experimental-e18af792a",
20
+ "@shopify/cli-kit": "^3.23.0",
21
+ "@shopify/mini-oxygen": "^1.3.1",
22
+ "fs-extra": "^10.1.0"
55
23
  },
56
- "os": [
57
- "darwin",
58
- "linux",
59
- "win32"
24
+ "bin": "tmp-create-app.mjs",
25
+ "files": [
26
+ "dist",
27
+ "tmp-create-app.mjs"
60
28
  ],
61
29
  "oclif": {
62
- "commands": "dist/cli/commands"
63
- },
64
- "repository": {
65
- "type": "git",
66
- "url": "https://github.com/Shopify/cli/edit/main/packages/cli-hydrogen"
67
- },
68
- "scripts": {
69
- "build": "nx build",
70
- "clean": "nx clean",
71
- "lint": "nx lint",
72
- "lint:fix": "nx lint:fix",
73
- "test": "nx run cli-hydrogen:test",
74
- "test:watch": "nx test:watch",
75
- "type-check": "nx type-check"
30
+ "commands": "dist/commands",
31
+ "hooks": {
32
+ "init": "./dist/hooks/init.js"
33
+ },
34
+ "topics": {
35
+ "hydrogen": {
36
+ "description": "Hydrogen commands"
37
+ }
38
+ }
76
39
  }
77
- }
40
+ }
@@ -0,0 +1,29 @@
1
+ import {runInit} from './dist/commands/hydrogen/init.js';
2
+ import fs from 'fs/promises';
3
+
4
+ /**
5
+ * This is a temporary executable script which is used to create new H2 apps.
6
+ * Eventually, this will be replaced by the proper `init` command in this CLI tool,
7
+ * which is actually an oclif plugin to the standard Shopify CLI.
8
+ */
9
+
10
+ const [template] = process.argv.slice(2);
11
+
12
+ // List all available templates in the dir:
13
+ const templates = await fs.readdir(
14
+ new URL('./dist/templates', import.meta.url).pathname,
15
+ );
16
+ console.log(`\nAvailable templates: \n- ${templates.join('\n -')}\n`);
17
+
18
+ const defaultTemplate = new URL('./dist/templates/demo-store', import.meta.url)
19
+ .pathname;
20
+
21
+ const resolvedTemplate = template ? template : defaultTemplate;
22
+
23
+ console.log(
24
+ `\n✨ Using template: ${resolvedTemplate} ${template ? '' : ' (default)'}`,
25
+ );
26
+
27
+ runInit({
28
+ template: resolvedTemplate,
29
+ });
package/LICENSE DELETED
@@ -1,8 +0,0 @@
1
- Copyright 2019-present, Shopify Inc.
2
-
3
- ​​
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
-
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md DELETED
@@ -1,61 +0,0 @@
1
- <img src="https://github.com/Shopify/cli/blob/main/assets/logo.png?raw=true" width="150"/>
2
-
3
- # Shopify CLI
4
- <a href="http://twitter.com/ShopifyDevs"><img src="https://img.shields.io/twitter/follow/ShopifyDevs?style=flat-square" alt="Twitter Followers"></a>
5
- <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License">
6
- <a href="https://github.com/Shopify/cli/actions/workflows/shopify-cli.yml">![badge](https://github.com/Shopify/cli/actions/workflows/shopify-cli.yml/badge.svg)</a>
7
-
8
- With the Shopify command line interface (Shopify CLI 3.0), you can:
9
- - build custom storefronts and manage their hosting
10
- - initialize, build, dev, and deploy Shopify apps — and generate app extensions
11
-
12
- <p>&nbsp;</p>
13
-
14
- ### Before you begin ###
15
-
16
- Install the latest version of [Node.js](https://nodejs.org/en/download/) and [npm](https://docs.npmjs.com/getting-started) (or another package manager of your choice).
17
-
18
- <p>&nbsp;</p>
19
-
20
- ## Developing apps with Shopify CLI
21
-
22
- When you’re building a Shopify app, you can initialize your project using your preferred package manager. A single command will install all the dependencies you need — including Shopify CLI itself.
23
-
24
- Initialize your project using one of the following commands:
25
- - `npm init @shopify/app@latest` (installed by default with Node)
26
- - `pnpm create @shopify/create-app@latest`
27
- - `yarn create @shopify/app`
28
-
29
- Learn more in the docs: [Create an app](https://shopify.dev/apps/getting-started/create)
30
-
31
- <p>&nbsp;</p>
32
-
33
- ## Developing Hydrogen custom storefronts with Shopify CLI ##
34
-
35
- When you’re building a custom storefront, use Hydrogen, Shopify’s React-based framework optimized for headless commerce. Initialize a new Hydrogen app with a fully-featured Demo Store template, or start from scratch with the minimal Hello World template. Shopify Plus stores can deploy their Hydrogen apps to Oxygen, Shopify’s global hosting solution, at no extra cost.
36
-
37
- Get started using one of the following commands:
38
- - `npm init @shopify/hydrogen@latest`
39
- - `npx @shopify/create-hydrogen@latest`
40
- - `pnpm create @shopify/create-hydrogen@latest`
41
- - `yarn create @shopify/hydrogen`
42
-
43
- <p>&nbsp;</p>
44
-
45
- ## Help 🖐
46
-
47
- If you encounter issues using the CLI or have feedback you'd like to share with us, below are some options:
48
-
49
- - [Open a GitHub issue](https://github.com/Shopify/cli/issues) - To report bugs or request new features, open an issue in the Shopify CLI repository.
50
- - [Shopify Community Forums](https://community.shopify.com/) - Visit our forums to connect with the community and learn more about Shopify CLI development.
51
- - [CLI Documentation](https://shopify.dev/apps/tools/cli) - To view our complete API documentation
52
-
53
- ## Contribute 👩🏽‍💻
54
-
55
- If you'd like to contribute to the project, check out the [contributors docs](/docs) and the [steps to get started](/docs/get-started.md).
56
-
57
- <p>&nbsp;</p>
58
-
59
- ## References
60
-
61
- - [oclif](https://oclif.io/)
@@ -1,11 +0,0 @@
1
- import Command from '@shopify/cli-kit/node/base-command';
2
- export default class AddESLint extends Command {
3
- static flags: {
4
- force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
5
- path: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
6
- install: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
- preset: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
- verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
- };
10
- run(): Promise<void>;
11
- }