@shopify/cli-hydrogen 7.1.2 → 8.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.
Files changed (145) hide show
  1. package/dist/commands/hydrogen/build-vite.js +19 -10
  2. package/dist/commands/hydrogen/build.js +10 -2
  3. package/dist/commands/hydrogen/check.js +1 -0
  4. package/dist/commands/hydrogen/codegen.js +1 -0
  5. package/dist/commands/hydrogen/customer-account/push.js +170 -0
  6. package/dist/commands/hydrogen/debug/cpu.js +10 -1
  7. package/dist/commands/hydrogen/deploy.js +110 -36
  8. package/dist/commands/hydrogen/dev-vite.js +128 -59
  9. package/dist/commands/hydrogen/dev.js +108 -51
  10. package/dist/commands/hydrogen/env/list.js +20 -28
  11. package/dist/commands/hydrogen/env/pull.js +29 -19
  12. package/dist/commands/hydrogen/env/{push__unstable.js → push.js} +34 -68
  13. package/dist/commands/hydrogen/generate/route.js +1 -0
  14. package/dist/commands/hydrogen/init.js +39 -21
  15. package/dist/commands/hydrogen/link.js +25 -6
  16. package/dist/commands/hydrogen/list.js +1 -0
  17. package/dist/commands/hydrogen/login.js +1 -0
  18. package/dist/commands/hydrogen/logout.js +1 -0
  19. package/dist/commands/hydrogen/preview.js +31 -16
  20. package/dist/commands/hydrogen/setup/css.js +8 -1
  21. package/dist/commands/hydrogen/setup/markets.js +1 -0
  22. package/dist/commands/hydrogen/setup/vite.js +244 -138
  23. package/dist/commands/hydrogen/setup.js +21 -23
  24. package/dist/commands/hydrogen/shortcut.js +10 -0
  25. package/dist/commands/hydrogen/unlink.js +1 -0
  26. package/dist/commands/hydrogen/upgrade.js +2 -1
  27. package/dist/generator-templates/assets/vite/package.json +3 -4
  28. package/dist/generator-templates/assets/vite/vite.config.js +15 -2
  29. package/dist/generator-templates/starter/CHANGELOG.md +129 -0
  30. package/dist/generator-templates/starter/README.md +3 -44
  31. package/dist/generator-templates/starter/app/components/Footer.tsx +1 -1
  32. package/dist/generator-templates/starter/app/components/Header.tsx +1 -1
  33. package/dist/generator-templates/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +1 -0
  34. package/dist/generator-templates/starter/app/lib/fragments.ts +2 -0
  35. package/dist/generator-templates/starter/app/lib/root-data.ts +11 -0
  36. package/dist/generator-templates/starter/app/root.tsx +4 -20
  37. package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +1 -1
  38. package/dist/generator-templates/starter/app/routes/account.tsx +1 -1
  39. package/dist/generator-templates/starter/app/routes/blogs.$blogHandle._index.tsx +3 -3
  40. package/dist/generator-templates/starter/app/routes/cart.tsx +1 -1
  41. package/dist/generator-templates/starter/app/routes/collections.all.tsx +160 -0
  42. package/dist/generator-templates/starter/app/routes/products.$handle.tsx +1 -2
  43. package/dist/generator-templates/starter/customer-accountapi.generated.d.ts +6 -3
  44. package/dist/generator-templates/starter/{remix.env.d.ts → env.d.ts} +8 -2
  45. package/dist/generator-templates/starter/package.json +14 -9
  46. package/dist/generator-templates/starter/server.ts +2 -1
  47. package/dist/generator-templates/starter/storefrontapi.generated.d.ts +59 -3
  48. package/dist/generator-templates/starter/vite.config.ts +26 -0
  49. package/dist/{commands/hydrogen/init.d.ts → init.d.ts} +11 -4
  50. package/dist/lib/check-lockfile.js +12 -18
  51. package/dist/lib/codegen.js +37 -13
  52. package/dist/lib/common.js +50 -0
  53. package/dist/lib/cpu-profiler.js +4 -1
  54. package/dist/lib/dev-shared.js +99 -0
  55. package/dist/lib/environment-variables.js +51 -30
  56. package/dist/lib/file.js +8 -1
  57. package/dist/lib/flags.js +37 -26
  58. package/dist/lib/get-oxygen-deployment-data.js +10 -17
  59. package/dist/lib/graphql/admin/customer-application-update.js +29 -0
  60. package/dist/lib/graphql/admin/get-oxygen-data.js +1 -0
  61. package/dist/lib/graphql/admin/list-environments.js +1 -0
  62. package/dist/lib/graphql/admin/pull-variables.js +4 -4
  63. package/dist/lib/graphql/admin/test-helper.js +37 -0
  64. package/dist/lib/log.js +86 -13
  65. package/dist/lib/mini-oxygen/common.js +19 -33
  66. package/dist/lib/mini-oxygen/index.js +6 -2
  67. package/dist/lib/mini-oxygen/node.js +43 -31
  68. package/dist/lib/mini-oxygen/workerd.js +72 -165
  69. package/dist/lib/missing-routes.js +1 -1
  70. package/dist/lib/onboarding/common.js +85 -70
  71. package/dist/lib/onboarding/local.js +19 -9
  72. package/dist/lib/onboarding/remote.js +35 -30
  73. package/dist/lib/package-managers.js +24 -0
  74. package/dist/lib/remix-config.js +17 -1
  75. package/dist/lib/render-errors.js +17 -10
  76. package/dist/lib/request-events.js +6 -1
  77. package/dist/lib/setups/i18n/replacers.js +9 -6
  78. package/dist/lib/setups/routes/generate.js +1 -0
  79. package/dist/lib/shell.js +2 -1
  80. package/dist/lib/shopify-config.js +19 -1
  81. package/dist/lib/template-diff.js +36 -15
  82. package/dist/lib/template-downloader.js +35 -5
  83. package/dist/lib/transpile/morph/functions.js +26 -8
  84. package/dist/lib/transpile/morph/typedefs.js +6 -4
  85. package/dist/lib/transpile/project.js +8 -4
  86. package/dist/lib/tunneling.js +44 -0
  87. package/dist/lib/verify-linked-storefront.js +24 -0
  88. package/dist/lib/virtual-routes.js +1 -1
  89. package/dist/lib/vite-config.js +39 -9
  90. package/oclif.manifest.json +704 -508
  91. package/package.json +32 -24
  92. package/dist/commands/hydrogen/deploy.test.js +0 -553
  93. package/dist/commands/hydrogen/env/list.test.js +0 -148
  94. package/dist/commands/hydrogen/env/pull.test.js +0 -207
  95. package/dist/commands/hydrogen/env/push__unstable.test.js +0 -383
  96. package/dist/commands/hydrogen/generate/route.test.js +0 -43
  97. package/dist/commands/hydrogen/init.test.js +0 -641
  98. package/dist/commands/hydrogen/link.test.js +0 -187
  99. package/dist/commands/hydrogen/list.test.js +0 -111
  100. package/dist/commands/hydrogen/setup.test.js +0 -61
  101. package/dist/commands/hydrogen/shortcut.test.js +0 -30
  102. package/dist/commands/hydrogen/unlink.test.js +0 -36
  103. package/dist/commands/hydrogen/upgrade.test.js +0 -786
  104. package/dist/generator-templates/starter/remix.config.js +0 -24
  105. package/dist/lib/auth.test.js +0 -157
  106. package/dist/lib/check-lockfile.test.js +0 -81
  107. package/dist/lib/check-version.test.js +0 -86
  108. package/dist/lib/environment-variables.test.js +0 -149
  109. package/dist/lib/file.test.js +0 -68
  110. package/dist/lib/flags.test.js +0 -43
  111. package/dist/lib/get-oxygen-deployment-data.test.js +0 -120
  112. package/dist/lib/gid.test.js +0 -15
  113. package/dist/lib/graphql/admin/client.test.js +0 -76
  114. package/dist/lib/graphql/admin/create-storefront.test.js +0 -64
  115. package/dist/lib/graphql/admin/link-storefront.test.js +0 -38
  116. package/dist/lib/graphql/admin/list-environments.test.js +0 -44
  117. package/dist/lib/graphql/admin/list-storefronts.test.js +0 -44
  118. package/dist/lib/graphql/admin/pull-variables.test.js +0 -43
  119. package/dist/lib/graphql/business-platform/user-account.test.js +0 -80
  120. package/dist/lib/log.test.js +0 -92
  121. package/dist/lib/mini-oxygen/assets.js +0 -134
  122. package/dist/lib/mini-oxygen/mini-oxygen.test.js +0 -214
  123. package/dist/lib/mini-oxygen/workerd-inspector-logs.js +0 -227
  124. package/dist/lib/mini-oxygen/workerd-inspector-proxy.js +0 -200
  125. package/dist/lib/mini-oxygen/workerd-inspector.js +0 -219
  126. package/dist/lib/missing-routes.test.js +0 -45
  127. package/dist/lib/remix-version-check.test.js +0 -39
  128. package/dist/lib/remix-version-interop.test.js +0 -13
  129. package/dist/lib/setups/i18n/domains.test.js +0 -39
  130. package/dist/lib/setups/i18n/replacers.test.js +0 -261
  131. package/dist/lib/setups/i18n/subdomains.test.js +0 -39
  132. package/dist/lib/setups/i18n/subfolders.test.js +0 -39
  133. package/dist/lib/setups/routes/generate.test.js +0 -296
  134. package/dist/lib/shell.test.js +0 -111
  135. package/dist/lib/shopify-config.test.js +0 -199
  136. package/dist/lib/string.test.js +0 -16
  137. package/dist/lib/virtual-routes.test.js +0 -49
  138. package/dist/lib/vite/hydrogen-middleware.js +0 -82
  139. package/dist/lib/vite/mini-oxygen.js +0 -152
  140. package/dist/lib/vite/plugins.d.ts +0 -27
  141. package/dist/lib/vite/plugins.js +0 -139
  142. package/dist/lib/vite/shared.js +0 -10
  143. package/dist/lib/vite/utils.js +0 -55
  144. package/dist/lib/vite/worker-entry.js +0 -1518
  145. /package/dist/generator-templates/starter/{.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -1,187 +0,0 @@
1
- import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest';
2
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
3
- import { renderSelectPrompt, renderTextPrompt, renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
4
- import { login } from '../../lib/auth.js';
5
- import { getStorefronts } from '../../lib/graphql/admin/link-storefront.js';
6
- import { runLink } from './link.js';
7
- import { createStorefront } from '../../lib/graphql/admin/create-storefront.js';
8
- import { waitForJob } from '../../lib/graphql/admin/fetch-job.js';
9
- import { setStorefront } from '../../lib/shopify-config.js';
10
-
11
- vi.mock("@shopify/cli-kit/node/ui", async () => {
12
- const original = await vi.importActual("@shopify/cli-kit/node/ui");
13
- return {
14
- ...original,
15
- renderConfirmationPrompt: vi.fn(),
16
- renderSelectPrompt: vi.fn(),
17
- renderTextPrompt: vi.fn()
18
- };
19
- });
20
- vi.mock("../../lib/auth.js");
21
- vi.mock("../../lib/shopify-config.js");
22
- vi.mock("../../lib/graphql/admin/link-storefront.js");
23
- vi.mock("../../lib/graphql/admin/create-storefront.js");
24
- vi.mock("../../lib/graphql/admin/fetch-job.js");
25
- vi.mock("../../lib/shell.js", () => ({ getCliCommand: () => "h2" }));
26
- describe("link", () => {
27
- const outputMock = mockAndCaptureOutput();
28
- const ADMIN_SESSION = {
29
- token: "abc123",
30
- storeFqdn: "my-shop.myshopify.com"
31
- };
32
- const FULL_SHOPIFY_CONFIG = {
33
- shop: "my-shop.myshopify.com",
34
- shopName: "My Shop",
35
- email: "email",
36
- storefront: {
37
- id: "gid://shopify/HydrogenStorefront/1",
38
- title: "Hydrogen"
39
- }
40
- };
41
- const UNLINKED_SHOPIFY_CONFIG = {
42
- ...FULL_SHOPIFY_CONFIG,
43
- storefront: void 0
44
- };
45
- const expectedStorefrontName = "New Storefront";
46
- const expectedJobId = "gid://shopify/Job/1";
47
- beforeEach(async () => {
48
- vi.mocked(login).mockResolvedValue({
49
- session: ADMIN_SESSION,
50
- config: UNLINKED_SHOPIFY_CONFIG
51
- });
52
- vi.mocked(getStorefronts).mockResolvedValue([
53
- {
54
- ...FULL_SHOPIFY_CONFIG.storefront,
55
- parsedId: "1",
56
- productionUrl: "https://example.com"
57
- }
58
- ]);
59
- vi.mocked(renderSelectPrompt).mockResolvedValue(FULL_SHOPIFY_CONFIG.shop);
60
- vi.mocked(createStorefront).mockResolvedValue({
61
- storefront: {
62
- id: "gid://shopify/HydrogenStorefront/1",
63
- title: expectedStorefrontName,
64
- productionUrl: "https://example.com"
65
- },
66
- jobId: expectedJobId
67
- });
68
- });
69
- afterEach(() => {
70
- vi.resetAllMocks();
71
- outputMock.clear();
72
- });
73
- it("fetches the storefronts", async () => {
74
- await runLink({});
75
- expect(getStorefronts).toHaveBeenCalledWith(ADMIN_SESSION);
76
- });
77
- it("renders a list of choices and forwards the selection to setStorefront", async () => {
78
- vi.mocked(renderSelectPrompt).mockResolvedValue(
79
- FULL_SHOPIFY_CONFIG.storefront.id
80
- );
81
- await runLink({ path: "my-path" });
82
- expect(setStorefront).toHaveBeenCalledWith(
83
- "my-path",
84
- expect.objectContaining(FULL_SHOPIFY_CONFIG.storefront)
85
- );
86
- });
87
- describe("when you want to link an existing Hydrogen storefront", () => {
88
- beforeEach(async () => {
89
- vi.mocked(renderSelectPrompt).mockResolvedValue(
90
- "gid://shopify/HydrogenStorefront/1"
91
- );
92
- });
93
- it("renders a list of choices and forwards the selection to setStorefront", async () => {
94
- vi.mocked(renderSelectPrompt).mockResolvedValue(
95
- FULL_SHOPIFY_CONFIG.storefront.id
96
- );
97
- await runLink({ path: "my-path" });
98
- expect(setStorefront).toHaveBeenCalledWith(
99
- "my-path",
100
- expect.objectContaining(FULL_SHOPIFY_CONFIG.storefront)
101
- );
102
- });
103
- it("renders a success message", async () => {
104
- vi.mocked(renderSelectPrompt).mockResolvedValue(
105
- FULL_SHOPIFY_CONFIG.storefront.id
106
- );
107
- await runLink({ path: "my-path" });
108
- expect(outputMock.info()).toMatch(/is now linked/i);
109
- expect(outputMock.info()).toMatch(/Run `h2 dev`/i);
110
- });
111
- });
112
- describe("when you want to link a new Hydrogen storefront", () => {
113
- beforeEach(async () => {
114
- vi.mocked(renderSelectPrompt).mockResolvedValue(null);
115
- });
116
- it("chooses to create a new storefront given the directory path", async () => {
117
- await runLink({ path: "my-path" });
118
- expect(renderTextPrompt).toHaveBeenCalledWith({
119
- message: expect.stringMatching(/name/i),
120
- defaultValue: "My Path"
121
- });
122
- });
123
- it("handles the successful creation of the storefront on Admin", async () => {
124
- await runLink({});
125
- expect(waitForJob).toHaveBeenCalledWith(ADMIN_SESSION, expectedJobId);
126
- expect(outputMock.info()).toContain(
127
- `${expectedStorefrontName} is now linked`
128
- );
129
- });
130
- it("handles the job errors when creating the storefront on Admin", async () => {
131
- vi.mocked(waitForJob).mockRejectedValue(void 0);
132
- await expect(runLink({})).rejects.toThrow(Error);
133
- });
134
- });
135
- describe("when a linked storefront already exists", () => {
136
- beforeEach(() => {
137
- vi.mocked(login).mockResolvedValue({
138
- session: ADMIN_SESSION,
139
- config: FULL_SHOPIFY_CONFIG
140
- });
141
- });
142
- it("prompts the user to confirm", async () => {
143
- vi.mocked(renderConfirmationPrompt).mockResolvedValue(true);
144
- await runLink({});
145
- expect(renderConfirmationPrompt).toHaveBeenCalledWith({
146
- message: expect.stringMatching(
147
- /link to a different Hydrogen storefront/i
148
- )
149
- });
150
- });
151
- describe("and the user cancels", () => {
152
- it("returns early", async () => {
153
- vi.mocked(renderConfirmationPrompt).mockResolvedValue(false);
154
- await runLink({});
155
- expect(getStorefronts).not.toHaveBeenCalled();
156
- expect(setStorefront).not.toHaveBeenCalled();
157
- });
158
- });
159
- describe("and the --force flag is provided", () => {
160
- it("does not prompt the user to confirm", async () => {
161
- await runLink({ force: true });
162
- expect(renderConfirmationPrompt).not.toHaveBeenCalled();
163
- });
164
- });
165
- });
166
- describe("when the --storefront flag is provided", () => {
167
- it("does not prompt the user to make a selection", async () => {
168
- await runLink({ path: "my-path", storefront: "Hydrogen" });
169
- expect(renderSelectPrompt).not.toHaveBeenCalled();
170
- expect(setStorefront).toHaveBeenCalledWith(
171
- "my-path",
172
- expect.objectContaining({
173
- id: "gid://shopify/HydrogenStorefront/1",
174
- title: "Hydrogen"
175
- })
176
- );
177
- });
178
- describe("and there is no matching storefront", () => {
179
- it("renders a warning message and returns early", async () => {
180
- const outputMock2 = mockAndCaptureOutput();
181
- await runLink({ storefront: "Does not exist" });
182
- expect(setStorefront).not.toHaveBeenCalled();
183
- expect(outputMock2.warn()).toMatch(/Couldn\'t find Does not exist/g);
184
- });
185
- });
186
- });
187
- });
@@ -1,111 +0,0 @@
1
- import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest';
2
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
3
- import { getStorefrontsWithDeployment } from '../../lib/graphql/admin/list-storefronts.js';
4
- import { runList, formatDeployment } from './list.js';
5
- import { login } from '../../lib/auth.js';
6
-
7
- vi.mock("../../lib/auth.js");
8
- vi.mock("../../lib/graphql/admin/list-storefronts.js");
9
- describe("list", () => {
10
- const ADMIN_SESSION = {
11
- token: "abc123",
12
- storeFqdn: "my-shop"
13
- };
14
- const SHOPIFY_CONFIG = {
15
- shop: "my-shop.myshopify.com",
16
- shopName: "My Shop",
17
- email: "email",
18
- storefront: {
19
- id: "gid://shopify/HydrogenStorefront/1",
20
- title: "Hydrogen"
21
- }
22
- };
23
- beforeEach(async () => {
24
- vi.mocked(login).mockResolvedValue({
25
- session: ADMIN_SESSION,
26
- config: SHOPIFY_CONFIG
27
- });
28
- vi.mocked(getStorefrontsWithDeployment).mockResolvedValue([]);
29
- });
30
- afterEach(() => {
31
- vi.resetAllMocks();
32
- mockAndCaptureOutput().clear();
33
- });
34
- it("fetches the storefronts", async () => {
35
- await runList({});
36
- expect(getStorefrontsWithDeployment).toHaveBeenCalledWith(ADMIN_SESSION);
37
- });
38
- describe("and there are storefronts", () => {
39
- beforeEach(() => {
40
- vi.mocked(getStorefrontsWithDeployment).mockResolvedValue([
41
- {
42
- id: "gid://shopify/HydrogenStorefront/1",
43
- parsedId: "1",
44
- title: "Hydrogen",
45
- productionUrl: "https://example.com",
46
- currentProductionDeployment: null
47
- },
48
- {
49
- id: "gid://shopify/HydrogenStorefront/2",
50
- parsedId: "2",
51
- title: "Demo Store",
52
- productionUrl: "https://demo.example.com",
53
- currentProductionDeployment: {
54
- id: "gid://shopify/HydrogenStorefrontDeployment/1",
55
- createdAt: "2023-03-22T22:28:38Z",
56
- commitMessage: "Update README.md"
57
- }
58
- }
59
- ]);
60
- });
61
- it("renders a list of storefronts", async () => {
62
- const outputMock = mockAndCaptureOutput();
63
- await runList({});
64
- expect(outputMock.info()).toMatch(
65
- /Showing 2 Hydrogen storefronts for the store my-shop/i
66
- );
67
- expect(outputMock.info()).toMatch(/Hydrogen \(id: 1\)/);
68
- expect(outputMock.info()).toMatch(/https:\/\/example.com/);
69
- expect(outputMock.info()).toMatch(/Demo Store \(id: 2\)/);
70
- expect(outputMock.info()).toMatch(/https:\/\/demo.example.com/);
71
- expect(outputMock.info()).toMatch(/3\/22\/2023, Update README.md/);
72
- });
73
- });
74
- describe("and there are no storefronts", () => {
75
- it("prompts the user to create a storefront", async () => {
76
- const outputMock = mockAndCaptureOutput();
77
- await runList({});
78
- expect(outputMock.info()).toMatch(
79
- /There are no Hydrogen storefronts on your Shop\./i
80
- );
81
- expect(outputMock.info()).toMatch(/Create a new Hydrogen storefront/i);
82
- expect(outputMock.info()).toMatch(
83
- /https:\/\/my\-shop\/admin\/custom_storefronts\/new/
84
- );
85
- });
86
- });
87
- });
88
- describe("formatDeployment", () => {
89
- const createdAt = "2023-03-22T22:28:38Z";
90
- it("returns a string combined with a date and commit message", () => {
91
- const deployment = {
92
- id: "gid://shopify/HydrogenStorefrontDeployment/1",
93
- createdAt,
94
- commitMessage: "Update README.md\n\nThis is a description of why the change was made."
95
- };
96
- expect(formatDeployment(deployment)).toStrictEqual(
97
- "3/22/2023, Update README.md"
98
- );
99
- });
100
- describe("when there is no commit message", () => {
101
- it("only returns the date", () => {
102
- const deployment = {
103
- id: "gid://shopify/HydrogenStorefrontDeployment/1",
104
- parsedId: "1",
105
- createdAt,
106
- commitMessage: null
107
- };
108
- expect(formatDeployment(deployment)).toStrictEqual("3/22/2023");
109
- });
110
- });
111
- });
@@ -1,61 +0,0 @@
1
- import { fileURLToPath } from 'node:url';
2
- import { vi, describe, beforeEach, it, expect } from 'vitest';
3
- import { inTemporaryDirectory, copyFile, fileExists, readFile } from '@shopify/cli-kit/node/fs';
4
- import { joinPath } from '@shopify/cli-kit/node/path';
5
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
6
- import { runSetup } from './setup.js';
7
- import { renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
8
-
9
- vi.mock("../../lib/shell.js");
10
- vi.mock("@shopify/cli-kit/node/ui", async () => {
11
- const original = await vi.importActual("@shopify/cli-kit/node/ui");
12
- return {
13
- ...original,
14
- renderConfirmationPrompt: vi.fn(),
15
- renderSelectPrompt: vi.fn(),
16
- renderTextPrompt: vi.fn(),
17
- renderInfo: vi.fn()
18
- };
19
- });
20
- describe("setup", () => {
21
- const outputMock = mockAndCaptureOutput();
22
- beforeEach(() => {
23
- vi.resetAllMocks();
24
- });
25
- beforeEach(() => {
26
- outputMock.clear();
27
- });
28
- it("sets up an i18n strategy and generates routes", async () => {
29
- await inTemporaryDirectory(async (tmpDir) => {
30
- await copyFile(
31
- fileURLToPath(
32
- new URL("../../../../../templates/hello-world", import.meta.url)
33
- ),
34
- tmpDir
35
- );
36
- await expect(
37
- fileExists(joinPath(tmpDir, "app/routes/_index.tsx"))
38
- ).resolves.toBeFalsy();
39
- vi.mocked(renderConfirmationPrompt).mockResolvedValueOnce(true);
40
- await expect(
41
- runSetup({
42
- directory: tmpDir,
43
- markets: "subfolders",
44
- installDeps: false
45
- })
46
- ).resolves.not.toThrow();
47
- await expect(
48
- fileExists(joinPath(tmpDir, "app/routes/($locale)._index.tsx"))
49
- ).resolves.toBeTruthy();
50
- const serverFile = await readFile(`${tmpDir}/server.ts`);
51
- expect(serverFile).toMatch(/i18n: getLocaleFromRequest\(request\),/);
52
- expect(serverFile).toMatch(/url.pathname/);
53
- const output = outputMock.info();
54
- expect(output).toMatch("success");
55
- expect(output).not.toMatch("warning");
56
- expect(output).toMatch(/Markets:\s*Subfolders/);
57
- expect(output).toMatch("Routes");
58
- expect(output).toMatch("Home (/ & /:catchAll)");
59
- });
60
- });
61
- });
@@ -1,30 +0,0 @@
1
- import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest';
2
- import { runCreateShortcut } from './shortcut.js';
3
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
4
- import { createPlatformShortcut } from '../../lib/shell.js';
5
-
6
- vi.mock("../../lib/shell.js");
7
- describe("shortcut", () => {
8
- const outputMock = mockAndCaptureOutput();
9
- beforeEach(() => {
10
- vi.resetAllMocks();
11
- });
12
- afterEach(() => {
13
- outputMock.clear();
14
- });
15
- it("shows created aliases", async () => {
16
- vi.mocked(createPlatformShortcut).mockResolvedValue([
17
- "zsh",
18
- "bash",
19
- "fish"
20
- ]);
21
- await runCreateShortcut();
22
- expect(outputMock.info()).toMatch(`zsh, bash, fish`);
23
- });
24
- it("warns when not finding shells", async () => {
25
- vi.mocked(createPlatformShortcut).mockResolvedValue([]);
26
- await runCreateShortcut();
27
- expect(outputMock.info()).toBeFalsy();
28
- expect(outputMock.error()).toBeTruthy();
29
- });
30
- });
@@ -1,36 +0,0 @@
1
- import { vi, describe, afterEach, it, expect } from 'vitest';
2
- import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
3
- import { getConfig, unsetStorefront } from '../../lib/shopify-config.js';
4
- import { unlinkStorefront } from './unlink.js';
5
-
6
- vi.mock("../../lib/shopify-config.js");
7
- describe("link", () => {
8
- const outputMock = mockAndCaptureOutput();
9
- afterEach(() => {
10
- vi.resetAllMocks();
11
- outputMock.clear();
12
- });
13
- it("removes the storefront information from the config file", async () => {
14
- vi.mocked(getConfig).mockResolvedValue({
15
- storefront: {
16
- id: "gid://shopify/HydrogenStorefront/2",
17
- title: "Existing Link"
18
- }
19
- });
20
- await unlinkStorefront({ path: "my-path" });
21
- expect(unsetStorefront).toHaveBeenCalledWith("my-path");
22
- expect(outputMock.output()).toMatch(
23
- /You are no longer linked to Existing Link/g
24
- );
25
- });
26
- describe("when there is no existing storefront link", () => {
27
- it("renders a warning message and returns early", async () => {
28
- vi.mocked(getConfig).mockResolvedValue({});
29
- await unlinkStorefront({});
30
- expect(outputMock.output()).toMatch(
31
- /This project isn\'t linked to a Hydrogen storefront\./g
32
- );
33
- expect(unsetStorefront).not.toHaveBeenCalled();
34
- });
35
- });
36
- });