@shopify/cli-hydrogen 5.0.1 → 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.
Files changed (240) hide show
  1. package/dist/commands/hydrogen/build.js +38 -8
  2. package/dist/commands/hydrogen/codegen-unstable.js +13 -24
  3. package/dist/commands/hydrogen/dev.js +61 -41
  4. package/dist/commands/hydrogen/env/list.js +25 -24
  5. package/dist/commands/hydrogen/env/list.test.js +46 -43
  6. package/dist/commands/hydrogen/env/pull.js +53 -25
  7. package/dist/commands/hydrogen/env/pull.test.js +123 -42
  8. package/dist/commands/hydrogen/generate/route.js +31 -132
  9. package/dist/commands/hydrogen/generate/route.test.js +34 -126
  10. package/dist/commands/hydrogen/init.js +46 -127
  11. package/dist/commands/hydrogen/init.test.js +352 -100
  12. package/dist/commands/hydrogen/link.js +101 -43
  13. package/dist/commands/hydrogen/link.test.js +108 -74
  14. package/dist/commands/hydrogen/list.js +22 -12
  15. package/dist/commands/hydrogen/list.test.js +51 -48
  16. package/dist/commands/hydrogen/login.js +31 -0
  17. package/dist/commands/hydrogen/logout.js +21 -0
  18. package/dist/commands/hydrogen/preview.js +2 -1
  19. package/dist/commands/hydrogen/setup/css.js +79 -0
  20. package/dist/commands/hydrogen/setup/markets.js +53 -0
  21. package/dist/commands/hydrogen/setup.js +133 -0
  22. package/dist/commands/hydrogen/shortcut.js +2 -45
  23. package/dist/commands/hydrogen/shortcut.test.js +10 -37
  24. package/dist/generator-templates/assets/css-modules/package.json +6 -0
  25. package/dist/generator-templates/assets/postcss/package.json +10 -0
  26. package/dist/generator-templates/assets/postcss/postcss.config.js +8 -0
  27. package/dist/generator-templates/assets/tailwind/package.json +13 -0
  28. package/dist/generator-templates/assets/tailwind/postcss.config.js +10 -0
  29. package/dist/generator-templates/assets/tailwind/tailwind.config.js +8 -0
  30. package/dist/generator-templates/assets/tailwind/tailwind.css +3 -0
  31. package/dist/generator-templates/assets/vanilla-extract/package.json +9 -0
  32. package/dist/generator-templates/starter/.eslintignore +5 -0
  33. package/dist/generator-templates/starter/.eslintrc.js +18 -0
  34. package/dist/generator-templates/starter/.graphqlrc.yml +1 -0
  35. package/dist/generator-templates/starter/README.md +40 -0
  36. package/dist/generator-templates/starter/app/components/Aside.tsx +47 -0
  37. package/dist/generator-templates/starter/app/components/Cart.tsx +340 -0
  38. package/dist/generator-templates/starter/app/components/Footer.tsx +99 -0
  39. package/dist/generator-templates/starter/app/components/Header.tsx +178 -0
  40. package/dist/generator-templates/starter/app/components/Layout.tsx +95 -0
  41. package/dist/generator-templates/starter/app/components/Search.tsx +480 -0
  42. package/dist/generator-templates/starter/app/entry.client.tsx +12 -0
  43. package/dist/generator-templates/starter/app/entry.server.tsx +33 -0
  44. package/dist/generator-templates/starter/app/root.tsx +270 -0
  45. package/dist/generator-templates/starter/app/routes/$.tsx +7 -0
  46. package/dist/generator-templates/{routes → starter/app/routes}/[robots.txt].tsx +47 -69
  47. package/dist/generator-templates/starter/app/routes/[sitemap.xml].tsx +174 -0
  48. package/dist/generator-templates/starter/app/routes/_index.tsx +145 -0
  49. package/dist/generator-templates/starter/app/routes/account.$.tsx +9 -0
  50. package/dist/generator-templates/starter/app/routes/account.addresses.tsx +563 -0
  51. package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +309 -0
  52. package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +196 -0
  53. package/dist/generator-templates/starter/app/routes/account.profile.tsx +289 -0
  54. package/dist/generator-templates/starter/app/routes/account.tsx +203 -0
  55. package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +157 -0
  56. package/dist/generator-templates/starter/app/routes/account_.login.tsx +143 -0
  57. package/dist/generator-templates/starter/app/routes/account_.logout.tsx +33 -0
  58. package/dist/generator-templates/starter/app/routes/account_.recover.tsx +124 -0
  59. package/dist/generator-templates/starter/app/routes/account_.register.tsx +207 -0
  60. package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +136 -0
  61. package/dist/generator-templates/starter/app/routes/api.predictive-search.tsx +342 -0
  62. package/dist/generator-templates/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +88 -0
  63. package/dist/generator-templates/starter/app/routes/blogs.$blogHandle._index.tsx +162 -0
  64. package/dist/generator-templates/starter/app/routes/blogs._index.tsx +94 -0
  65. package/dist/generator-templates/starter/app/routes/cart.tsx +104 -0
  66. package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +184 -0
  67. package/dist/generator-templates/starter/app/routes/collections._index.tsx +120 -0
  68. package/dist/generator-templates/starter/app/routes/pages.$handle.tsx +57 -0
  69. package/dist/generator-templates/starter/app/routes/policies.$handle.tsx +94 -0
  70. package/dist/generator-templates/starter/app/routes/policies._index.tsx +63 -0
  71. package/dist/generator-templates/starter/app/routes/products.$handle.tsx +418 -0
  72. package/dist/generator-templates/starter/app/routes/search.tsx +168 -0
  73. package/dist/generator-templates/starter/app/styles/app.css +473 -0
  74. package/dist/generator-templates/starter/app/styles/reset.css +129 -0
  75. package/dist/generator-templates/starter/app/utils.ts +46 -0
  76. package/dist/generator-templates/starter/package.json +43 -0
  77. package/dist/generator-templates/starter/public/favicon.svg +28 -0
  78. package/dist/generator-templates/starter/remix.config.js +26 -0
  79. package/dist/generator-templates/starter/remix.env.d.ts +39 -0
  80. package/dist/generator-templates/starter/server.ts +253 -0
  81. package/dist/generator-templates/starter/storefrontapi.generated.d.ts +1906 -0
  82. package/dist/generator-templates/starter/tsconfig.json +22 -0
  83. package/dist/lib/auth.js +123 -0
  84. package/dist/lib/auth.test.js +157 -0
  85. package/dist/lib/build.js +51 -0
  86. package/dist/lib/check-version.js +3 -3
  87. package/dist/lib/check-version.test.js +24 -0
  88. package/dist/lib/codegen.js +26 -17
  89. package/dist/lib/environment-variables.js +68 -0
  90. package/dist/lib/environment-variables.test.js +147 -0
  91. package/dist/lib/file.js +41 -0
  92. package/dist/lib/file.test.js +69 -0
  93. package/dist/lib/flags.js +39 -2
  94. package/dist/lib/format-code.js +26 -0
  95. package/dist/lib/gid.js +12 -0
  96. package/dist/lib/{graphql.test.js → gid.test.js} +1 -1
  97. package/dist/lib/graphql/admin/client.js +27 -0
  98. package/dist/lib/graphql/admin/client.test.js +51 -0
  99. package/dist/lib/graphql/admin/create-storefront.js +36 -0
  100. package/dist/lib/graphql/admin/create-storefront.test.js +64 -0
  101. package/dist/lib/graphql/admin/fetch-job.js +39 -0
  102. package/dist/lib/graphql/admin/link-storefront.js +7 -11
  103. package/dist/lib/graphql/admin/link-storefront.test.js +38 -0
  104. package/dist/lib/graphql/admin/list-environments.js +2 -2
  105. package/dist/lib/graphql/admin/list-environments.test.js +44 -0
  106. package/dist/lib/graphql/admin/list-storefronts.js +7 -11
  107. package/dist/lib/graphql/admin/list-storefronts.test.js +44 -0
  108. package/dist/lib/graphql/admin/pull-variables.js +3 -3
  109. package/dist/lib/graphql/admin/pull-variables.test.js +37 -0
  110. package/dist/lib/graphql/business-platform/user-account.js +83 -0
  111. package/dist/lib/graphql/business-platform/user-account.test.js +80 -0
  112. package/dist/lib/log.js +185 -9
  113. package/dist/lib/log.test.js +92 -0
  114. package/dist/lib/mini-oxygen.js +32 -14
  115. package/dist/lib/missing-routes.js +0 -2
  116. package/dist/lib/onboarding/common.js +456 -0
  117. package/dist/lib/onboarding/index.js +2 -0
  118. package/dist/lib/onboarding/local.js +229 -0
  119. package/dist/lib/onboarding/remote.js +89 -0
  120. package/dist/lib/remix-version-interop.js +5 -5
  121. package/dist/lib/remix-version-interop.test.js +11 -1
  122. package/dist/lib/render-errors.js +13 -11
  123. package/dist/lib/setups/css/assets.js +89 -0
  124. package/dist/lib/setups/css/css-modules.js +22 -0
  125. package/dist/lib/setups/css/index.js +44 -0
  126. package/dist/lib/setups/css/postcss.js +34 -0
  127. package/dist/lib/setups/css/replacers.js +137 -0
  128. package/dist/lib/setups/css/tailwind.js +54 -0
  129. package/dist/lib/setups/css/vanilla-extract.js +22 -0
  130. package/dist/lib/setups/i18n/domains.test.js +25 -0
  131. package/dist/lib/setups/i18n/index.js +46 -0
  132. package/dist/lib/setups/i18n/replacers.js +227 -0
  133. package/dist/lib/setups/i18n/subdomains.test.js +25 -0
  134. package/dist/lib/setups/i18n/subfolders.test.js +25 -0
  135. package/dist/lib/setups/i18n/templates/domains.js +14 -0
  136. package/dist/lib/setups/i18n/templates/domains.ts +25 -0
  137. package/dist/lib/setups/i18n/templates/subdomains.js +14 -0
  138. package/dist/lib/setups/i18n/templates/subdomains.ts +24 -0
  139. package/dist/lib/setups/i18n/templates/subfolders.js +14 -0
  140. package/dist/lib/setups/i18n/templates/subfolders.ts +28 -0
  141. package/dist/lib/setups/routes/generate.js +244 -0
  142. package/dist/lib/setups/routes/generate.test.js +313 -0
  143. package/dist/lib/shell.js +52 -5
  144. package/dist/lib/shell.test.js +42 -16
  145. package/dist/lib/shopify-config.js +23 -18
  146. package/dist/lib/shopify-config.test.js +63 -73
  147. package/dist/lib/string.js +7 -0
  148. package/dist/lib/string.test.js +16 -0
  149. package/dist/lib/template-downloader.js +9 -7
  150. package/dist/lib/transpile-ts.js +9 -29
  151. package/dist/virtual-routes/routes/index.jsx +40 -19
  152. package/oclif.manifest.json +710 -1
  153. package/package.json +16 -16
  154. package/dist/commands/hydrogen/build.d.ts +0 -23
  155. package/dist/commands/hydrogen/check.d.ts +0 -15
  156. package/dist/commands/hydrogen/codegen-unstable.d.ts +0 -15
  157. package/dist/commands/hydrogen/dev.d.ts +0 -21
  158. package/dist/commands/hydrogen/env/list.d.ts +0 -18
  159. package/dist/commands/hydrogen/env/pull.d.ts +0 -22
  160. package/dist/commands/hydrogen/g.d.ts +0 -10
  161. package/dist/commands/hydrogen/generate/route.d.ts +0 -32
  162. package/dist/commands/hydrogen/generate/route.test.d.ts +0 -1
  163. package/dist/commands/hydrogen/generate/routes.d.ts +0 -16
  164. package/dist/commands/hydrogen/init.d.ts +0 -24
  165. package/dist/commands/hydrogen/init.test.d.ts +0 -1
  166. package/dist/commands/hydrogen/link.d.ts +0 -23
  167. package/dist/commands/hydrogen/link.test.d.ts +0 -1
  168. package/dist/commands/hydrogen/list.d.ts +0 -21
  169. package/dist/commands/hydrogen/list.test.d.ts +0 -1
  170. package/dist/commands/hydrogen/preview.d.ts +0 -17
  171. package/dist/commands/hydrogen/shortcut.d.ts +0 -9
  172. package/dist/commands/hydrogen/shortcut.test.d.ts +0 -1
  173. package/dist/commands/hydrogen/unlink.d.ts +0 -16
  174. package/dist/commands/hydrogen/unlink.test.d.ts +0 -1
  175. package/dist/create-app.d.ts +0 -1
  176. package/dist/generator-templates/routes/[sitemap.xml].tsx +0 -235
  177. package/dist/generator-templates/routes/account/login.tsx +0 -103
  178. package/dist/generator-templates/routes/account/register.tsx +0 -103
  179. package/dist/generator-templates/routes/cart.tsx +0 -81
  180. package/dist/generator-templates/routes/collections/$collectionHandle.tsx +0 -104
  181. package/dist/generator-templates/routes/collections/index.tsx +0 -102
  182. package/dist/generator-templates/routes/graphiql.tsx +0 -10
  183. package/dist/generator-templates/routes/index.tsx +0 -40
  184. package/dist/generator-templates/routes/pages/$pageHandle.tsx +0 -112
  185. package/dist/generator-templates/routes/policies/$policyHandle.tsx +0 -140
  186. package/dist/generator-templates/routes/policies/index.tsx +0 -117
  187. package/dist/generator-templates/routes/products/$productHandle.tsx +0 -92
  188. package/dist/hooks/init.d.ts +0 -5
  189. package/dist/lib/admin-session.d.ts +0 -6
  190. package/dist/lib/admin-session.js +0 -16
  191. package/dist/lib/admin-session.test.d.ts +0 -1
  192. package/dist/lib/admin-session.test.js +0 -27
  193. package/dist/lib/admin-urls.d.ts +0 -8
  194. package/dist/lib/check-lockfile.d.ts +0 -3
  195. package/dist/lib/check-lockfile.test.d.ts +0 -1
  196. package/dist/lib/check-version.d.ts +0 -16
  197. package/dist/lib/check-version.test.d.ts +0 -1
  198. package/dist/lib/codegen.d.ts +0 -26
  199. package/dist/lib/combined-environment-variables.d.ts +0 -8
  200. package/dist/lib/combined-environment-variables.js +0 -57
  201. package/dist/lib/combined-environment-variables.test.d.ts +0 -1
  202. package/dist/lib/combined-environment-variables.test.js +0 -111
  203. package/dist/lib/config.d.ts +0 -20
  204. package/dist/lib/flags.d.ts +0 -27
  205. package/dist/lib/flags.test.d.ts +0 -1
  206. package/dist/lib/graphql/admin/link-storefront.d.ts +0 -14
  207. package/dist/lib/graphql/admin/list-environments.d.ts +0 -21
  208. package/dist/lib/graphql/admin/list-storefronts.d.ts +0 -25
  209. package/dist/lib/graphql/admin/pull-variables.d.ts +0 -21
  210. package/dist/lib/graphql.d.ts +0 -21
  211. package/dist/lib/graphql.js +0 -18
  212. package/dist/lib/graphql.test.d.ts +0 -1
  213. package/dist/lib/log.d.ts +0 -6
  214. package/dist/lib/mini-oxygen.d.ts +0 -14
  215. package/dist/lib/missing-routes.d.ts +0 -8
  216. package/dist/lib/missing-routes.test.d.ts +0 -1
  217. package/dist/lib/missing-storefronts.d.ts +0 -5
  218. package/dist/lib/missing-storefronts.js +0 -18
  219. package/dist/lib/process.d.ts +0 -6
  220. package/dist/lib/pull-environment-variables.d.ts +0 -20
  221. package/dist/lib/pull-environment-variables.js +0 -57
  222. package/dist/lib/pull-environment-variables.test.d.ts +0 -1
  223. package/dist/lib/pull-environment-variables.test.js +0 -174
  224. package/dist/lib/remix-version-interop.d.ts +0 -11
  225. package/dist/lib/remix-version-interop.test.d.ts +0 -1
  226. package/dist/lib/render-errors.d.ts +0 -16
  227. package/dist/lib/shell.d.ts +0 -11
  228. package/dist/lib/shell.test.d.ts +0 -1
  229. package/dist/lib/shop.d.ts +0 -7
  230. package/dist/lib/shop.js +0 -32
  231. package/dist/lib/shop.test.d.ts +0 -1
  232. package/dist/lib/shop.test.js +0 -78
  233. package/dist/lib/shopify-config.d.ts +0 -35
  234. package/dist/lib/shopify-config.test.d.ts +0 -1
  235. package/dist/lib/template-downloader.d.ts +0 -6
  236. package/dist/lib/transpile-ts.d.ts +0 -16
  237. package/dist/lib/virtual-routes.d.ts +0 -7
  238. package/dist/lib/virtual-routes.test.d.ts +0 -1
  239. /package/dist/{commands/hydrogen/env/list.test.d.ts → lib/setups/css/common.js} +0 -0
  240. /package/dist/{commands/hydrogen/env/pull.test.d.ts → lib/setups/i18n/mock-i18n-types.js} +0 -0
@@ -1,27 +0,0 @@
1
- import * as _oclif_core_lib_interfaces_parser_js from '@oclif/core/lib/interfaces/parser.js';
2
-
3
- declare const commonFlags: {
4
- path: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
5
- port: _oclif_core_lib_interfaces_parser_js.OptionFlag<number, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
6
- force: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
7
- shop: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
8
- "env-branch": _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
9
- sourcemap: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
10
- };
11
- declare function flagsToCamelObject(obj: Record<string, any>): any;
12
- /**
13
- * Parse process arguments into an object for use in the cli as flags.
14
- * This is used when starting the init command from create-hydrogen without Oclif.
15
- * @example
16
- * input: `node ./bin --force --no-install-deps --language js`
17
- * output: { force: true, installDeps: false, language: 'js' }
18
- */
19
- declare function parseProcessFlags(processArgv: string[], flagMap?: Record<string, string>): any;
20
- /**
21
- * Create a deprecated flag to prevent the CLI from crashing when a deprecated flag is used.
22
- * Displays an info message when the flag is used.
23
- * @param name The name of the flag.
24
- */
25
- declare function deprecated(name: string): _oclif_core_lib_interfaces_parser_js.FlagDefinition<unknown, Record<string, unknown>>;
26
-
27
- export { commonFlags, deprecated, flagsToCamelObject, parseProcessFlags };
@@ -1 +0,0 @@
1
-
@@ -1,14 +0,0 @@
1
- import { AdminSession } from '@shopify/cli-kit/node/session';
2
-
3
- declare const LinkStorefrontQuery = "#graphql\n query LinkStorefront {\n hydrogenStorefronts {\n id\n title\n productionUrl\n }\n }\n";
4
- declare function getStorefronts(shop: string): Promise<{
5
- adminSession: AdminSession;
6
- storefronts: {
7
- parsedId: string;
8
- id: string;
9
- title: string;
10
- productionUrl: string;
11
- }[];
12
- }>;
13
-
14
- export { LinkStorefrontQuery, getStorefronts };
@@ -1,21 +0,0 @@
1
- import { AdminSession } from '@shopify/cli-kit/node/session';
2
-
3
- type EnvironmentType = 'PREVIEW' | 'PRODUCTION' | 'CUSTOM';
4
- interface Environment {
5
- branch: string | null;
6
- createdAt: string;
7
- id: string;
8
- name: string;
9
- type: EnvironmentType;
10
- url: string | null;
11
- }
12
- interface HydrogenStorefront {
13
- id: string;
14
- environments: Environment[];
15
- productionUrl: string;
16
- }
17
- declare function getStorefrontEnvironments(adminSession: AdminSession, storefrontId: string): Promise<{
18
- storefront: HydrogenStorefront | null;
19
- }>;
20
-
21
- export { Environment, getStorefrontEnvironments };
@@ -1,25 +0,0 @@
1
- import { AdminSession } from '@shopify/cli-kit/node/session';
2
-
3
- interface Deployment {
4
- id: string;
5
- createdAt: string;
6
- commitMessage: string | null;
7
- }
8
- interface HydrogenStorefront {
9
- id: string;
10
- title: string;
11
- productionUrl?: string;
12
- currentProductionDeployment: Deployment | null;
13
- }
14
- declare function getStorefrontsWithDeployment(shop: string): Promise<{
15
- adminSession: AdminSession;
16
- storefronts: {
17
- parsedId: string;
18
- id: string;
19
- title: string;
20
- productionUrl?: string | undefined;
21
- currentProductionDeployment: Deployment | null;
22
- }[];
23
- }>;
24
-
25
- export { Deployment, HydrogenStorefront, getStorefrontsWithDeployment };
@@ -1,21 +0,0 @@
1
- import { AdminSession } from '@shopify/cli-kit/node/session';
2
-
3
- declare const PullVariablesQuery = "#graphql\n query PullVariables($id: ID!, $branch: String) {\n hydrogenStorefront(id: $id) {\n id\n environmentVariables(branchName: $branch) {\n id\n isSecret\n key\n value\n }\n }\n }\n";
4
- interface EnvironmentVariable {
5
- id: string;
6
- isSecret: boolean;
7
- key: string;
8
- value: string;
9
- }
10
- interface HydrogenStorefront {
11
- id: string;
12
- environmentVariables: EnvironmentVariable[];
13
- }
14
- interface PullVariablesSchema {
15
- hydrogenStorefront: HydrogenStorefront | null;
16
- }
17
- declare function getStorefrontEnvVariables(adminSession: AdminSession, storefrontId: string, envBranch?: string): Promise<{
18
- storefront: HydrogenStorefront | null;
19
- }>;
20
-
21
- export { EnvironmentVariable, PullVariablesQuery, PullVariablesSchema, getStorefrontEnvVariables };
@@ -1,21 +0,0 @@
1
- import { GraphQLVariables } from '@shopify/cli-kit/node/api/graphql';
2
- import { AdminSession } from '@shopify/cli-kit/node/session';
3
-
4
- /**
5
- * This is a temporary workaround until cli-kit includes a way to specify
6
- * API versions for the Admin API because we need to target the unstable
7
- * branch for this early access phase.
8
- *
9
- * @param query - GraphQL query to execute.
10
- * @param session - Shopify admin session including token and Store FQDN.
11
- * @param variables - GraphQL variables to pass to the query.
12
- * @returns The response of the query of generic type <T>.
13
- */
14
- declare function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables): Promise<T>;
15
- /**
16
- * @param gid a Global ID to parse (e.g. 'gid://shopify/HydrogenStorefront/1')
17
- * @returns the ID of the record (e.g. '1')
18
- */
19
- declare function parseGid(gid: string): string;
20
-
21
- export { adminRequest, parseGid };
@@ -1,18 +0,0 @@
1
- import { graphqlRequest } from '@shopify/cli-kit/node/api/graphql';
2
- import { AbortError } from '@shopify/cli-kit/node/error';
3
-
4
- async function adminRequest(query, session, variables) {
5
- const api = "Admin";
6
- const url = `https://${session.storeFqdn}/admin/api/unstable/graphql.json`;
7
- return graphqlRequest({ query, api, url, token: session.token, variables });
8
- }
9
- const GID_REGEXP = /gid:\/\/shopify\/\w*\/(\d+)/;
10
- function parseGid(gid) {
11
- const matches = GID_REGEXP.exec(gid);
12
- if (matches && matches[1] !== void 0) {
13
- return matches[1];
14
- }
15
- throw new AbortError(`Invalid Global ID: ${gid}`);
16
- }
17
-
18
- export { adminRequest, parseGid };
@@ -1 +0,0 @@
1
-
package/dist/lib/log.d.ts DELETED
@@ -1,6 +0,0 @@
1
- declare function muteDevLogs({ workerReload }?: {
2
- workerReload?: boolean;
3
- }): void;
4
- declare const warnOnce: (string: string) => void;
5
-
6
- export { muteDevLogs, warnOnce };
@@ -1,14 +0,0 @@
1
- type MiniOxygenOptions = {
2
- root: string;
3
- port?: number;
4
- watch?: boolean;
5
- buildPathClient: string;
6
- buildPathWorkerFile: string;
7
- environmentVariables?: {
8
- [key: string]: string;
9
- };
10
- };
11
- declare function startMiniOxygen({ root, port, watch, buildPathWorkerFile, buildPathClient, environmentVariables, }: MiniOxygenOptions): Promise<void>;
12
- declare function logResponse(request: Request, response: Response): void;
13
-
14
- export { logResponse, startMiniOxygen };
@@ -1,8 +0,0 @@
1
- import { RemixConfig } from '@remix-run/dev/dist/config.js';
2
-
3
- declare function findMissingRoutes(config: {
4
- routes: RemixConfig['routes'];
5
- }, requiredRoutes?: string[]): string[];
6
- declare function logMissingRoutes(routes: string[]): void;
7
-
8
- export { findMissingRoutes, logMissingRoutes };
@@ -1 +0,0 @@
1
-
@@ -1,5 +0,0 @@
1
- import { AdminSession } from '@shopify/cli-kit/node/session';
2
-
3
- declare function logMissingStorefronts(adminSession: AdminSession): void;
4
-
5
- export { logMissingStorefronts };
@@ -1,18 +0,0 @@
1
- import { renderInfo } from '@shopify/cli-kit/node/ui';
2
- import { newHydrogenStorefrontUrl } from './admin-urls.js';
3
-
4
- function logMissingStorefronts(adminSession) {
5
- renderInfo({
6
- headline: "Hydrogen storefronts",
7
- body: "There are no Hydrogen storefronts on your Shop.",
8
- nextSteps: [
9
- `Ensure you have specified the correct shop (you specified: ${adminSession.storeFqdn})`,
10
- `Ensure you have the Hydrogen sales channel installed https://apps.shopify.com/hydrogen`,
11
- `Create a new Hydrogen storefront: ${newHydrogenStorefrontUrl(
12
- adminSession
13
- )}`
14
- ]
15
- });
16
- }
17
-
18
- export { logMissingStorefronts };
@@ -1,6 +0,0 @@
1
- import { exec } from 'node:child_process';
2
-
3
- declare const execAsync: typeof exec.__promisify__;
4
- declare function supressNodeExperimentalWarnings(): void;
5
-
6
- export { execAsync, supressNodeExperimentalWarnings };
@@ -1,20 +0,0 @@
1
- import { EnvironmentVariable } from './graphql/admin/pull-variables.js';
2
- import '@shopify/cli-kit/node/session';
3
-
4
- interface Arguments {
5
- envBranch?: string;
6
- root: string;
7
- /**
8
- * Optional shop override that developers would have passed using the --shop
9
- * flag.
10
- */
11
- flagShop?: string;
12
- /**
13
- * Does not prompt the user to fix any errors that are encountered (e.g. no
14
- * linked storefront)
15
- */
16
- silent?: boolean;
17
- }
18
- declare function pullRemoteEnvironmentVariables({ envBranch, root, flagShop, silent, }: Arguments): Promise<EnvironmentVariable[]>;
19
-
20
- export { pullRemoteEnvironmentVariables };
@@ -1,57 +0,0 @@
1
- import { renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
2
- import { outputContent, outputToken, outputInfo } from '@shopify/cli-kit/node/output';
3
- import { linkStorefront } from '../commands/hydrogen/link.js';
4
- import { getHydrogenShop } from './shop.js';
5
- import { getAdminSession } from './admin-session.js';
6
- import { getConfig } from './shopify-config.js';
7
- import { renderMissingLink, renderMissingStorefront } from './render-errors.js';
8
- import { getStorefrontEnvVariables } from './graphql/admin/pull-variables.js';
9
-
10
- async function pullRemoteEnvironmentVariables({
11
- envBranch,
12
- root,
13
- flagShop,
14
- silent
15
- }) {
16
- const shop = await getHydrogenShop({ path: root, shop: flagShop });
17
- const adminSession = await getAdminSession(shop);
18
- let configStorefront = (await getConfig(root)).storefront;
19
- if (!configStorefront?.id) {
20
- if (!silent) {
21
- renderMissingLink({ adminSession });
22
- const runLink = await renderConfirmationPrompt({
23
- message: outputContent`Run ${outputToken.genericShellCommand(
24
- `npx shopify hydrogen link`
25
- )}?`.value
26
- });
27
- if (!runLink) {
28
- return [];
29
- }
30
- await linkStorefront({ path: root, shop: flagShop, silent });
31
- }
32
- }
33
- configStorefront = (await getConfig(root)).storefront;
34
- if (!configStorefront) {
35
- return [];
36
- }
37
- const { storefront } = await getStorefrontEnvVariables(
38
- adminSession,
39
- configStorefront.id,
40
- envBranch
41
- );
42
- if (!storefront) {
43
- if (!silent) {
44
- renderMissingStorefront({ adminSession, storefront: configStorefront });
45
- }
46
- return [];
47
- }
48
- if (!storefront.environmentVariables.length) {
49
- if (!silent) {
50
- outputInfo(`No environment variables found.`);
51
- }
52
- return [];
53
- }
54
- return storefront.environmentVariables;
55
- }
56
-
57
- export { pullRemoteEnvironmentVariables };
@@ -1,174 +0,0 @@
1
- import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest';
2
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
3
- import { inTemporaryDirectory } from '@shopify/cli-kit/node/fs';
4
- import { renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
5
- import { PullVariablesQuery } from './graphql/admin/pull-variables.js';
6
- import { getAdminSession } from './admin-session.js';
7
- import { adminRequest } from './graphql.js';
8
- import { getConfig } from './shopify-config.js';
9
- import { renderMissingLink, renderMissingStorefront } from './render-errors.js';
10
- import { linkStorefront } from '../commands/hydrogen/link.js';
11
- import { pullRemoteEnvironmentVariables } from './pull-environment-variables.js';
12
-
13
- vi.mock("@shopify/cli-kit/node/ui", async () => {
14
- const original = await vi.importActual("@shopify/cli-kit/node/ui");
15
- return {
16
- ...original,
17
- renderConfirmationPrompt: vi.fn()
18
- };
19
- });
20
- vi.mock("../commands/hydrogen/link.js");
21
- vi.mock("./admin-session.js");
22
- vi.mock("./shopify-config.js");
23
- vi.mock("./render-errors.js");
24
- vi.mock("./graphql.js", async () => {
25
- const original = await vi.importActual(
26
- "./graphql.js"
27
- );
28
- return {
29
- ...original,
30
- adminRequest: vi.fn()
31
- };
32
- });
33
- vi.mock("./shop.js", () => ({
34
- getHydrogenShop: () => "my-shop"
35
- }));
36
- describe("pullRemoteEnvironmentVariables", () => {
37
- const ENVIRONMENT_VARIABLES_RESPONSE = [
38
- {
39
- id: "gid://shopify/HydrogenStorefrontEnvironmentVariable/1",
40
- key: "PUBLIC_API_TOKEN",
41
- value: "abc123",
42
- isSecret: false
43
- }
44
- ];
45
- const ADMIN_SESSION = {
46
- token: "abc123",
47
- storeFqdn: "my-shop"
48
- };
49
- beforeEach(async () => {
50
- vi.mocked(getAdminSession).mockResolvedValue(ADMIN_SESSION);
51
- vi.mocked(getConfig).mockResolvedValue({
52
- storefront: {
53
- id: "gid://shopify/HydrogenStorefront/2",
54
- title: "Existing Link"
55
- }
56
- });
57
- vi.mocked(adminRequest).mockResolvedValue({
58
- hydrogenStorefront: {
59
- id: "gid://shopify/HydrogenStorefront/1",
60
- environmentVariables: ENVIRONMENT_VARIABLES_RESPONSE
61
- }
62
- });
63
- });
64
- afterEach(() => {
65
- vi.resetAllMocks();
66
- mockAndCaptureOutput().clear();
67
- });
68
- it("makes a GraphQL call to fetch environment variables", async () => {
69
- await inTemporaryDirectory(async (tmpDir) => {
70
- await pullRemoteEnvironmentVariables({
71
- root: tmpDir,
72
- envBranch: "staging"
73
- });
74
- expect(adminRequest).toHaveBeenCalledWith(
75
- PullVariablesQuery,
76
- ADMIN_SESSION,
77
- {
78
- id: "gid://shopify/HydrogenStorefront/2",
79
- branch: "staging"
80
- }
81
- );
82
- });
83
- });
84
- it("returns environment variables", async () => {
85
- await inTemporaryDirectory(async (tmpDir) => {
86
- const environmentVariables = await pullRemoteEnvironmentVariables({
87
- root: tmpDir
88
- });
89
- expect(environmentVariables).toBe(ENVIRONMENT_VARIABLES_RESPONSE);
90
- });
91
- });
92
- describe("when environment variables are empty", () => {
93
- beforeEach(() => {
94
- vi.mocked(adminRequest).mockResolvedValue({
95
- hydrogenStorefront: {
96
- id: "gid://shopify/HydrogenStorefront/1",
97
- environmentVariables: []
98
- }
99
- });
100
- });
101
- it("renders a message", async () => {
102
- await inTemporaryDirectory(async (tmpDir) => {
103
- const outputMock = mockAndCaptureOutput();
104
- await pullRemoteEnvironmentVariables({ root: tmpDir });
105
- expect(outputMock.info()).toMatch(/No environment variables found\./);
106
- });
107
- });
108
- it("returns an empty array", async () => {
109
- await inTemporaryDirectory(async (tmpDir) => {
110
- const environmentVariables = await pullRemoteEnvironmentVariables({
111
- root: tmpDir
112
- });
113
- expect(environmentVariables).toStrictEqual([]);
114
- });
115
- });
116
- });
117
- describe("when there is no linked storefront", () => {
118
- beforeEach(() => {
119
- vi.mocked(getConfig).mockResolvedValue({
120
- storefront: void 0
121
- });
122
- });
123
- it("calls renderMissingLink", async () => {
124
- await inTemporaryDirectory(async (tmpDir) => {
125
- await pullRemoteEnvironmentVariables({ root: tmpDir });
126
- expect(renderMissingLink).toHaveBeenCalledOnce();
127
- });
128
- });
129
- it("prompts the user to create a link", async () => {
130
- vi.mocked(renderConfirmationPrompt).mockResolvedValue(true);
131
- await inTemporaryDirectory(async (tmpDir) => {
132
- await pullRemoteEnvironmentVariables({ root: tmpDir });
133
- expect(renderConfirmationPrompt).toHaveBeenCalledWith({
134
- message: expect.stringMatching(/Run .*npx shopify hydrogen link.*\?/)
135
- });
136
- expect(linkStorefront).toHaveBeenCalledWith({
137
- path: tmpDir
138
- });
139
- });
140
- });
141
- describe("and the user does not create a new link", () => {
142
- it("returns an empty array", async () => {
143
- vi.mocked(renderConfirmationPrompt).mockResolvedValue(false);
144
- await inTemporaryDirectory(async (tmpDir) => {
145
- const environmentVariables = await pullRemoteEnvironmentVariables({
146
- root: tmpDir
147
- });
148
- expect(environmentVariables).toStrictEqual([]);
149
- });
150
- });
151
- });
152
- });
153
- describe("when there is no matching storefront in the shop", () => {
154
- beforeEach(() => {
155
- vi.mocked(adminRequest).mockResolvedValue({
156
- hydrogenStorefront: null
157
- });
158
- });
159
- it("calls renderMissingStorefront", async () => {
160
- await inTemporaryDirectory(async (tmpDir) => {
161
- await pullRemoteEnvironmentVariables({ root: tmpDir });
162
- expect(renderMissingStorefront).toHaveBeenCalledOnce();
163
- });
164
- });
165
- it("returns an empty array", async () => {
166
- await inTemporaryDirectory(async (tmpDir) => {
167
- const environmentVariables = await pullRemoteEnvironmentVariables({
168
- root: tmpDir
169
- });
170
- expect(environmentVariables).toStrictEqual([]);
171
- });
172
- });
173
- });
174
- });
@@ -1,11 +0,0 @@
1
- declare function isRemixV2(): boolean;
2
- declare function getV2Flags(root: string): Promise<{
3
- isV2Meta: boolean;
4
- isV2ErrorBoundary: boolean;
5
- isV2RouteConvention: boolean;
6
- }>;
7
- type RemixV2Flags = Partial<Awaited<ReturnType<typeof getV2Flags>>>;
8
- declare function convertRouteToV2(route: string): string;
9
- declare function convertTemplateToRemixVersion(template: string, { isV2Meta, isV2ErrorBoundary }: RemixV2Flags): string;
10
-
11
- export { RemixV2Flags, convertRouteToV2, convertTemplateToRemixVersion, getV2Flags, isRemixV2 };
@@ -1,16 +0,0 @@
1
- import { AdminSession } from '@shopify/cli-kit/node/session';
2
-
3
- interface MissingStorefront {
4
- adminSession: AdminSession;
5
- storefront: {
6
- id: string;
7
- title: string;
8
- };
9
- }
10
- declare function renderMissingStorefront({ adminSession, storefront, }: MissingStorefront): void;
11
- interface MissingLink {
12
- adminSession: AdminSession;
13
- }
14
- declare function renderMissingLink({ adminSession }: MissingLink): void;
15
-
16
- export { renderMissingLink, renderMissingStorefront };
@@ -1,11 +0,0 @@
1
- type UnixShell = 'zsh' | 'bash' | 'fish';
2
- type WindowsShell = 'PowerShell' | 'PowerShell 7+' | 'CMD';
3
- type Shell = UnixShell | WindowsShell;
4
- declare const ALIAS_NAME = "h2";
5
- declare const isWindows: () => boolean;
6
- declare const isGitBash: () => boolean;
7
- declare function shellWriteAlias(shell: UnixShell, aliasName: string, content: string): Promise<boolean>;
8
- declare function shellRunScript(script: string, shellBin: string): Promise<boolean>;
9
- declare function getCliCommand(): Promise<"h2" | "yarn shopify hydrogen" | "pnpm shopify hydrogen" | "npx shopify hydrogen">;
10
-
11
- export { ALIAS_NAME, Shell, UnixShell, WindowsShell, getCliCommand, isGitBash, isWindows, shellRunScript, shellWriteAlias };
@@ -1 +0,0 @@
1
-
@@ -1,7 +0,0 @@
1
- interface Flags {
2
- shop?: string;
3
- path?: string;
4
- }
5
- declare function getHydrogenShop(flags: Flags): Promise<string>;
6
-
7
- export { getHydrogenShop };
package/dist/lib/shop.js DELETED
@@ -1,32 +0,0 @@
1
- import { renderTextPrompt } from '@shopify/cli-kit/node/ui';
2
- import { AbortError } from '@shopify/cli-kit/node/error';
3
- import { outputContent, outputToken } from '@shopify/cli-kit/node/output';
4
- import { getConfig, setShop } from './shopify-config.js';
5
-
6
- async function getHydrogenShop(flags) {
7
- const { shop: flagShop, path: flagPath } = flags;
8
- const targetPath = flagPath ?? process.cwd();
9
- const { shop: configShop } = await getConfig(targetPath);
10
- let promptShop;
11
- if (!flagShop && !configShop) {
12
- promptShop = await renderTextPrompt({
13
- message: "Specify which Shop you would like to use (e.g. janes-goods.myshopify.com)",
14
- allowEmpty: false
15
- });
16
- }
17
- const shop = flagShop || configShop || promptShop;
18
- if (!shop) {
19
- throw new AbortError(
20
- "A shop is required",
21
- `Specify the shop passing ${outputContent`${outputToken.genericShellCommand(
22
- `--shop={your_shop_url}}`
23
- )}`.value} or set the ${outputContent`${outputToken.genericShellCommand("SHOPIFY_SHOP")}`.value} environment variable.`
24
- );
25
- }
26
- if (!configShop || flagShop && flagShop != configShop) {
27
- await setShop(targetPath, shop);
28
- }
29
- return shop;
30
- }
31
-
32
- export { getHydrogenShop };
@@ -1 +0,0 @@
1
-
@@ -1,78 +0,0 @@
1
- import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest';
2
- import { inTemporaryDirectory } from '@shopify/cli-kit/node/fs';
3
- import { AbortError } from '@shopify/cli-kit/node/error';
4
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
5
- import { renderTextPrompt } from '@shopify/cli-kit/node/ui';
6
- import { getHydrogenShop } from './shop.js';
7
- import { getConfig, setShop } from './shopify-config.js';
8
-
9
- vi.mock("@shopify/cli-kit/node/ui");
10
- vi.mock("./shopify-config.js");
11
- describe("getHydrogenShop()", () => {
12
- beforeEach(() => {
13
- vi.mocked(getConfig).mockResolvedValue({});
14
- });
15
- afterEach(() => {
16
- mockAndCaptureOutput().clear();
17
- vi.clearAllMocks();
18
- });
19
- describe("when a shop is passed via flag", () => {
20
- it("returns the shop", async () => {
21
- await inTemporaryDirectory(async (tmpDir) => {
22
- const shop = await getHydrogenShop({ shop: "my-shop", path: tmpDir });
23
- expect(shop).toBe("my-shop");
24
- });
25
- });
26
- });
27
- describe("when a shop is not provided via flag", () => {
28
- describe("and there is no existing SHOP_NAME file", () => {
29
- it("prompts the user to enter a new name", async () => {
30
- await inTemporaryDirectory(async (tmpDir) => {
31
- vi.mocked(renderTextPrompt).mockResolvedValue("my-prompted-shop");
32
- const shop = await getHydrogenShop({ path: tmpDir });
33
- expect(renderTextPrompt).toHaveBeenCalledWith({
34
- message: "Specify which Shop you would like to use (e.g. janes-goods.myshopify.com)",
35
- allowEmpty: false
36
- });
37
- expect(shop).toBe("my-prompted-shop");
38
- });
39
- });
40
- describe("and the user does not enter a value", () => {
41
- it("throws an error", async () => {
42
- await inTemporaryDirectory(async (tmpDir) => {
43
- vi.mocked(renderTextPrompt).mockResolvedValue("");
44
- await expect(getHydrogenShop({ path: tmpDir })).rejects.toThrow(
45
- AbortError
46
- );
47
- });
48
- });
49
- });
50
- });
51
- describe("and there is an existing shop from the config file", () => {
52
- it("returns the shop", async () => {
53
- vi.mocked(getConfig).mockResolvedValue({ shop: "previous-shop" });
54
- await inTemporaryDirectory(async (tmpDir) => {
55
- const shop = await getHydrogenShop({ path: tmpDir });
56
- expect(shop).toBe("previous-shop");
57
- });
58
- });
59
- });
60
- });
61
- describe("when the SHOP_NAME file does not exist", () => {
62
- it("gets created", async () => {
63
- await inTemporaryDirectory(async (tmpDir) => {
64
- await getHydrogenShop({ shop: "new-shop", path: tmpDir });
65
- expect(setShop).toHaveBeenCalledWith(tmpDir, "new-shop");
66
- });
67
- });
68
- });
69
- describe("when the shop is different from the value in SHOP_NAME", () => {
70
- it("overwrites SHOP_NAME with the new value", async () => {
71
- vi.mocked(getConfig).mockResolvedValue({ shop: "previous-shop" });
72
- await inTemporaryDirectory(async (tmpDir) => {
73
- await getHydrogenShop({ shop: "new-shop", path: tmpDir });
74
- expect(setShop).toHaveBeenCalledWith(tmpDir, "new-shop");
75
- });
76
- });
77
- });
78
- });