@shopify/cli-hydrogen 7.0.0 → 7.0.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.
@@ -171,8 +171,8 @@ describe("init", () => {
171
171
  const examplePath = templatePath.replace("templates", "examples").replace("skeleton", exampleName);
172
172
  const ignore = ["**/node_modules/**", "**/dist/**"];
173
173
  const resultFiles = await glob("**/*", { ignore, cwd: tmpDir });
174
- const templateFiles = await glob("**/*", { ignore, cwd: templatePath });
175
174
  const exampleFiles = await glob("**/*", { ignore, cwd: examplePath });
175
+ const templateFiles = (await glob("**/*", { ignore, cwd: templatePath })).filter((item) => !item.endsWith("CHANGELOG.md"));
176
176
  expect(resultFiles).toEqual(
177
177
  expect.arrayContaining([
178
178
  .../* @__PURE__ */ new Set([...templateFiles, ...exampleFiles])
@@ -7,7 +7,7 @@ import { commonFlags, overrideFlag, flagsToCamelObject } from '../../lib/flags.j
7
7
  import { renderI18nPrompt, setupI18nStrategy } from '../../lib/setups/i18n/index.js';
8
8
  import { getRemixConfig } from '../../lib/remix-config.js';
9
9
  import { handleRouteGeneration, generateProjectEntries, handleCliShortcut, renderProjectReady } from '../../lib/onboarding/common.js';
10
- import { getCliCommand } from '../../lib/shell.js';
10
+ import { getCliCommand, ALIAS_NAME } from '../../lib/shell.js';
11
11
  import { getTemplateAppFile } from '../../lib/build.js';
12
12
 
13
13
  class Setup extends Command {
@@ -89,24 +89,22 @@ async function runSetup(options) {
89
89
  () => setupI18nStrategy(i18n, remixConfig)
90
90
  );
91
91
  }
92
- let hasCreatedShortcut = false;
93
- const cliCommand = await cliCommandPromise;
94
- const needsAlias = cliCommand !== "h2";
95
- if (needsAlias) {
96
- const { createShortcut, showShortcutBanner } = await handleCliShortcut(
97
- controller,
98
- await cliCommandPromise,
99
- options.shortcut
100
- );
101
- if (createShortcut) {
102
- backgroundWorkPromise = backgroundWorkPromise.then(async () => {
103
- hasCreatedShortcut = await createShortcut();
104
- });
105
- showShortcutBanner();
106
- }
107
- }
108
- if (!i18n && !needsRouteGeneration && !needsAlias)
92
+ let cliCommand = await Promise.resolve(cliCommandPromise);
93
+ const { createShortcut, showShortcutBanner } = await handleCliShortcut(
94
+ controller,
95
+ cliCommand,
96
+ options.shortcut
97
+ );
98
+ if (!i18n && !needsRouteGeneration && !createShortcut)
109
99
  return;
100
+ if (createShortcut) {
101
+ backgroundWorkPromise = backgroundWorkPromise.then(async () => {
102
+ if (await createShortcut()) {
103
+ cliCommand = ALIAS_NAME;
104
+ }
105
+ });
106
+ showShortcutBanner();
107
+ }
110
108
  await renderTasks(tasks);
111
109
  await renderProjectReady(
112
110
  {
@@ -115,7 +113,7 @@ async function runSetup(options) {
115
113
  directory: remixConfig.rootDirectory
116
114
  },
117
115
  {
118
- hasCreatedShortcut,
116
+ cliCommand,
119
117
  depsInstalled: true,
120
118
  packageManager: "npm",
121
119
  i18n,
@@ -1,5 +1,15 @@
1
1
  # skeleton
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ♻️ `CustomerClient` type is deprecated and replaced by `CustomerAccount` ([#1692](https://github.com/Shopify/hydrogen/pull/1692)) by [@michenly](https://github.com/michenly)
8
+
9
+ - Updated dependencies [[`02798786`](https://github.com/Shopify/hydrogen/commit/02798786bf8ae5c53f6430723a86d62b8e94d120), [`52b15df4`](https://github.com/Shopify/hydrogen/commit/52b15df457ce723bbc83ad594ded73a7b06447d6), [`a2664362`](https://github.com/Shopify/hydrogen/commit/a2664362a7d89b34835553a9b0eb7af55ca70ae4), [`eee5d927`](https://github.com/Shopify/hydrogen/commit/eee5d9274b72404dfb0ffef30d5503fd553be5fe), [`c7b2017f`](https://github.com/Shopify/hydrogen/commit/c7b2017f11a2cb4d280dfd8f170e65a908b9ea02), [`06320ee4`](https://github.com/Shopify/hydrogen/commit/06320ee48b94dbfece945461031a252f454fd0a3)]:
10
+ - @shopify/hydrogen@2024.1.1
11
+ - @shopify/cli-hydrogen@7.0.1
12
+
3
13
  ## 1.0.2
4
14
 
5
15
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
  "name": "skeleton",
3
3
  "private": true,
4
4
  "sideEffects": false,
5
- "version": "1.0.2",
5
+ "version": "1.0.3",
6
6
  "scripts": {
7
7
  "build": "shopify hydrogen build",
8
8
  "dev": "shopify hydrogen dev --codegen",
@@ -16,8 +16,8 @@
16
16
  "@remix-run/react": "^2.5.1",
17
17
  "@remix-run/server-runtime": "^2.5.1",
18
18
  "@shopify/cli": "3.52.0",
19
- "@shopify/cli-hydrogen": "^7.0.0",
20
- "@shopify/hydrogen": "~2024.1.0",
19
+ "@shopify/cli-hydrogen": "^7.0.1",
20
+ "@shopify/hydrogen": "~2024.1.1",
21
21
  "@shopify/remix-oxygen": "^2.0.3",
22
22
  "graphql": "^16.6.0",
23
23
  "graphql-tag": "^2.12.6",
@@ -5,7 +5,11 @@
5
5
  // Enhance TypeScript's built-in typings.
6
6
  import '@total-typescript/ts-reset';
7
7
 
8
- import type {Storefront, CustomerClient, HydrogenCart} from '@shopify/hydrogen';
8
+ import type {
9
+ Storefront,
10
+ CustomerAccount,
11
+ HydrogenCart,
12
+ } from '@shopify/hydrogen';
9
13
  import type {AppSession} from '~/lib/session';
10
14
 
11
15
  declare global {
@@ -36,7 +40,7 @@ declare module '@shopify/remix-oxygen' {
36
40
  env: Env;
37
41
  cart: HydrogenCart;
38
42
  storefront: Storefront;
39
- customerAccount: CustomerClient;
43
+ customerAccount: CustomerAccount;
40
44
  session: AppSession;
41
45
  waitUntil: ExecutionContext['waitUntil'];
42
46
  }
@@ -63,14 +63,7 @@ function spawnCodegenProcess({
63
63
  });
64
64
  return child;
65
65
  }
66
- async function codegen(options) {
67
- await import('@shopify/hydrogen-codegen/patch').catch((error) => {
68
- throw new AbortError(
69
- `Failed to patch dependencies for codegen.
70
- ${error.stack}`,
71
- "Please report this issue."
72
- );
73
- });
66
+ function codegen(options) {
74
67
  return generateTypes(options).catch((error) => {
75
68
  const { message, details } = normalizeCodegenError(
76
69
  error.message,
package/dist/lib/file.js CHANGED
@@ -84,7 +84,10 @@ async function mergePackageJson(sourceDir, targetDir, options) {
84
84
  }, {});
85
85
  }
86
86
  }
87
- await writePackageJSON(targetDir, targetPkgJson);
87
+ await writePackageJSON(
88
+ targetDir,
89
+ options?.onResult?.(targetPkgJson) ?? targetPkgJson
90
+ );
88
91
  }
89
92
 
90
93
  export { findFileWithExtension, mergePackageJson, replaceFileContent };
@@ -8,6 +8,9 @@ function getGraphiQLUrl({
8
8
  if (typeof variables !== "string")
9
9
  variables = JSON.stringify(variables);
10
10
  url += `?query=${encodeURIComponent(query)}${variables ? `&variables=${encodeURIComponent(variables)}` : ""}`;
11
+ if (graphql.schema) {
12
+ url += `&schema=${graphql.schema}`;
13
+ }
11
14
  }
12
15
  return url;
13
16
  }
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import { createRequire } from 'node:module';
3
4
  import { createServer } from 'node:http';
4
5
  import { lookupMimeType } from '@shopify/cli-kit/node/mimes';
5
6
 
@@ -10,13 +11,28 @@ function buildAssetsUrl(assetsPort) {
10
11
  }
11
12
  function createAssetsServer(buildPathClient) {
12
13
  return createServer(async (req, res) => {
14
+ if (req.method === "OPTIONS") {
15
+ res.setHeader("Access-Control-Allow-Origin", req.headers.origin || "*");
16
+ res.setHeader("Access-Control-Allow-Credentials", "true");
17
+ res.setHeader("Access-Control-Allow-Private-Network", "true");
18
+ res.setHeader("Access-Control-Max-Age", "86400");
19
+ res.writeHead(204);
20
+ res.end();
21
+ return;
22
+ }
13
23
  res.setHeader("Access-Control-Allow-Origin", "*");
14
24
  res.setHeader("X-Content-Type-Options", "nosniff");
15
25
  const pathname = req.url?.split("?")[0] || "";
16
26
  const isValidAssetPath = pathname.startsWith(`/${artificialAssetPrefix}/`) && !pathname.includes("..");
17
27
  const relativeAssetPath = isValidAssetPath ? pathname.replace(`/${artificialAssetPrefix}`, "") : pathname;
18
28
  if (isValidAssetPath) {
19
- const filePath = path.join(buildPathClient, relativeAssetPath);
29
+ let filePath = path.join(buildPathClient, relativeAssetPath);
30
+ if (relativeAssetPath === "/graphiql/customer-account.schema.json") {
31
+ const require2 = createRequire(import.meta.url);
32
+ filePath = require2.resolve(
33
+ "@shopify/hydrogen/customer-account.schema.json"
34
+ );
35
+ }
20
36
  const file = await fs.open(filePath).catch(() => {
21
37
  });
22
38
  const stat = await file?.stat().catch(() => {
@@ -11,7 +11,7 @@ import colors from '@shopify/cli-kit/node/colors';
11
11
  import { login, renderLoginSuccess } from '../auth.js';
12
12
  import { renderI18nPrompt, setupI18nStrategy, I18N_STRATEGY_NAME_MAP } from '../setups/i18n/index.js';
13
13
  import { titleize } from '../string.js';
14
- import { ALIAS_NAME, createPlatformShortcut, getCliCommand } from '../shell.js';
14
+ import { ALIAS_NAME, createPlatformShortcut } from '../shell.js';
15
15
  import { transpileProject } from '../transpile/index.js';
16
16
  import { renderCssPrompt, setupCssStrategy, CSS_STRATEGY_NAME_MAP } from '../setups/css/index.js';
17
17
  import { renderRoutePrompt, generateRoutes, generateProjectFile } from '../setups/routes/generate.js';
@@ -75,6 +75,8 @@ function generateProjectEntries(options) {
75
75
  );
76
76
  }
77
77
  async function handleCliShortcut(controller, cliCommand, flagShortcut) {
78
+ if (cliCommand === ALIAS_NAME)
79
+ return {};
78
80
  const shouldCreateShortcut = flagShortcut ?? await renderConfirmationPrompt({
79
81
  confirmationMessage: "Yes",
80
82
  cancellationMessage: "No",
@@ -329,7 +331,7 @@ async function renderProjectReady(project, {
329
331
  packageManager,
330
332
  depsInstalled,
331
333
  cssStrategy,
332
- hasCreatedShortcut,
334
+ cliCommand,
333
335
  routes,
334
336
  i18n,
335
337
  depsError,
@@ -369,7 +371,6 @@ async function renderProjectReady(project, {
369
371
  }
370
372
  }
371
373
  const padMin = 1 + bodyLines.reduce((max, [label]) => Math.max(max, label.length), 0);
372
- const cliCommand = hasCreatedShortcut ? ALIAS_NAME : await getCliCommand(project.directory, packageManager);
373
374
  const render = hasErrors ? renderWarning : renderSuccess;
374
375
  render({
375
376
  headline: `Storefront setup complete` + (hasErrors ? " with errors (see warnings below)." : "!"),
@@ -156,7 +156,7 @@ async function setupLocalStarterTemplate(options, controller) {
156
156
  packageManager,
157
157
  cssStrategy,
158
158
  depsInstalled: false,
159
- hasCreatedShortcut: false
159
+ cliCommand: await getCliCommand("", packageManager)
160
160
  };
161
161
  if (shouldInstallDeps) {
162
162
  const installingDepsPromise = backgroundWorkPromise.then(async () => {
@@ -174,19 +174,19 @@ async function setupLocalStarterTemplate(options, controller) {
174
174
  }
175
175
  });
176
176
  }
177
- const pkgManagerCommand = await getCliCommand("", packageManager);
178
177
  const { createShortcut, showShortcutBanner } = await handleCliShortcut(
179
178
  controller,
180
- pkgManagerCommand,
179
+ setupSummary.cliCommand,
181
180
  options.shortcut
182
181
  );
183
182
  if (createShortcut) {
184
183
  backgroundWorkPromise = backgroundWorkPromise.then(async () => {
185
- setupSummary.hasCreatedShortcut = await createShortcut();
184
+ if (await createShortcut()) {
185
+ setupSummary.cliCommand = ALIAS_NAME;
186
+ }
186
187
  });
187
188
  showShortcutBanner();
188
189
  }
189
- const cliCommand = createShortcut ? ALIAS_NAME : pkgManagerCommand;
190
190
  renderSuccess({
191
191
  headline: [
192
192
  { userInput: storefrontInfo?.title ?? project.name },
@@ -196,13 +196,13 @@ async function setupLocalStarterTemplate(options, controller) {
196
196
  const continueWithSetup = (options.i18n ?? options.routes) !== void 0 || await renderConfirmationPrompt({
197
197
  message: "Do you want to scaffold routes and core functionality?",
198
198
  confirmationMessage: "Yes, set up now",
199
- cancellationMessage: "No, set up later " + colors.dim(`(run \`${cliCommand} setup\`)`),
199
+ cancellationMessage: "No, set up later " + colors.dim(`(run \`${setupSummary.cliCommand} setup\`)`),
200
200
  abortSignal: controller.signal
201
201
  });
202
202
  if (continueWithSetup) {
203
203
  const { i18nStrategy, setupI18n } = await handleI18n(
204
204
  controller,
205
- cliCommand,
205
+ setupSummary.cliCommand,
206
206
  options.i18n
207
207
  );
208
208
  const { setupRoutes } = await handleRouteGeneration(
@@ -5,6 +5,7 @@ import { joinPath } from '@shopify/cli-kit/node/path';
5
5
  import { renderTasks, renderInfo } from '@shopify/cli-kit/node/ui';
6
6
  import { getLatestTemplates } from '../template-downloader.js';
7
7
  import { applyTemplateDiff } from '../template-diff.js';
8
+ import { getCliCommand } from '../shell.js';
8
9
  import { createAbortHandler, handleProjectLocation, handleLanguage, createInitialCommit, handleDependencies, commitAll, renderProjectReady } from './common.js';
9
10
 
10
11
  async function setupRemoteTemplate(options, controller) {
@@ -65,7 +66,7 @@ async function setupRemoteTemplate(options, controller) {
65
66
  language,
66
67
  packageManager,
67
68
  depsInstalled: false,
68
- hasCreatedShortcut: false
69
+ cliCommand: await getCliCommand("", packageManager)
69
70
  };
70
71
  const tasks = [
71
72
  {
@@ -50,7 +50,7 @@ describe("i18n replacers", () => {
50
50
 
51
51
  import type {
52
52
  Storefront,
53
- CustomerClient,
53
+ CustomerAccount,
54
54
  HydrogenCart,
55
55
  } from "@shopify/hydrogen";
56
56
  import type {
@@ -92,7 +92,7 @@ describe("i18n replacers", () => {
92
92
  env: Env;
93
93
  cart: HydrogenCart;
94
94
  storefront: Storefront<I18nLocale>;
95
- customerAccount: CustomerClient;
95
+ customerAccount: CustomerAccount;
96
96
  session: AppSession;
97
97
  waitUntil: ExecutionContext["waitUntil"];
98
98
  }
package/dist/lib/shell.js CHANGED
@@ -155,7 +155,7 @@ async function createShortcutsForWindows() {
155
155
  return shells;
156
156
  }
157
157
  async function getCliCommand(directory = process.cwd(), forcePkgManager) {
158
- if (!forcePkgManager && await hasCliAlias()) {
158
+ if (await hasCliAlias()) {
159
159
  return ALIAS_NAME;
160
160
  }
161
161
  let cli = "npx";
@@ -67,15 +67,25 @@ ${colors.dim(
67
67
  async function applyTemplateDiff(targetDirectory, diffDirectory, templateDir = getStarterDir()) {
68
68
  const createFilter = (re) => (filepath) => !re.test(relativePath(templateDir, filepath));
69
69
  await copy(templateDir, targetDirectory, {
70
- filter: createFilter(/[\/\\](dist|node_modules|\.cache)(\/|\\|$)/i)
70
+ filter: createFilter(
71
+ /(^|\/|\\)(dist|node_modules|\.cache|CHANGELOG\.md)(\/|\\|$)/i
72
+ )
71
73
  });
72
74
  await copy(diffDirectory, targetDirectory, {
73
75
  filter: createFilter(
74
- /[\/\\](dist|node_modules|\.cache|package\.json|tsconfig\.json)(\/|\\|$)/i
76
+ /(^|\/|\\)(dist|node_modules|\.cache|package\.json|tsconfig\.json)(\/|\\|$)/i
75
77
  )
76
78
  });
77
79
  await mergePackageJson(diffDirectory, targetDirectory, {
78
- ignoredKeys: ["scripts"]
80
+ onResult: (pkgJson) => {
81
+ for (const key of ["build", "dev"]) {
82
+ const scriptLine = pkgJson.scripts?.[key];
83
+ if (pkgJson.scripts?.[key] && typeof scriptLine === "string") {
84
+ pkgJson.scripts[key] = scriptLine.replace(/\s+--diff/, "");
85
+ }
86
+ }
87
+ return pkgJson;
88
+ }
79
89
  });
80
90
  }
81
91
  async function copyDiffBuild(targetDirectory, diffDirectory) {
@@ -64,13 +64,13 @@ function RequestDetails({
64
64
  /* @__PURE__ */ jsx("div", { id: "tab1-panel", className: `tabPanel${activeTabClass(1)}`, children: /* @__PURE__ */ jsxs("div", { className: "grid-layout", children: [
65
65
  /* @__PURE__ */ jsx(DetailsRow, { rowName: "Name", value: requestInfo.displayName }),
66
66
  /* @__PURE__ */ jsx(DetailsRow, { rowName: "Request URL", value: requestInfo.url }),
67
- /* @__PURE__ */ jsx(
67
+ requestInfo.responseInit ? /* @__PURE__ */ jsx(
68
68
  DetailsRow,
69
69
  {
70
70
  rowName: "Status",
71
71
  value: `${requestInfo.responseInit?.status} ${requestInfo.responseInit?.statusText}`
72
72
  }
73
- ),
73
+ ) : null,
74
74
  /* @__PURE__ */ jsx(
75
75
  DetailsRow,
76
76
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.0.0",
2
+ "version": "7.0.1",
3
3
  "commands": {
4
4
  "hydrogen:build": {
5
5
  "id": "hydrogen:build",
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
- "version": "7.0.0",
7
+ "version": "7.0.1",
8
8
  "license": "MIT",
9
9
  "type": "module",
10
10
  "scripts": {
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@ast-grep/napi": "0.11.0",
37
- "@graphql-codegen/cli": "5.0.0",
37
+ "@graphql-codegen/cli": "5.0.1",
38
38
  "@oclif/core": "2.11.7",
39
39
  "@shopify/cli-kit": "3.52.0",
40
- "@shopify/hydrogen-codegen": "^0.2.0",
40
+ "@shopify/hydrogen-codegen": "^0.2.1",
41
41
  "@shopify/mini-oxygen": "^2.2.5",
42
42
  "@shopify/oxygen-cli": "^4.0.0",
43
43
  "ansi-escapes": "^6.2.0",