@shopify/cli-hydrogen 5.0.1 → 5.0.2
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.
- package/dist/commands/hydrogen/build.js +22 -6
- package/dist/commands/hydrogen/dev.js +27 -13
- package/dist/commands/hydrogen/link.js +61 -4
- package/dist/commands/hydrogen/link.test.js +92 -23
- package/dist/commands/hydrogen/preview.js +2 -1
- package/dist/lib/graphql/admin/create-storefront.d.ts +17 -0
- package/dist/lib/graphql/admin/create-storefront.js +38 -0
- package/dist/lib/graphql/admin/fetch-job.d.ts +23 -0
- package/dist/lib/graphql/admin/fetch-job.js +48 -0
- package/dist/lib/mini-oxygen.d.ts +9 -1
- package/dist/lib/mini-oxygen.js +15 -7
- package/dist/lib/string.d.ts +3 -0
- package/dist/lib/string.js +7 -0
- package/dist/lib/string.test.d.ts +1 -0
- package/dist/lib/string.test.js +16 -0
- package/dist/lib/user-errors.d.ts +9 -0
- package/dist/lib/user-errors.js +11 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { Flags } from '@oclif/core';
|
|
3
2
|
import Command from '@shopify/cli-kit/node/base-command';
|
|
4
3
|
import { outputInfo, outputContent, outputToken, outputWarn } from '@shopify/cli-kit/node/output';
|
|
5
|
-
import { rmdir, fileSize, copyFile } from '@shopify/cli-kit/node/fs';
|
|
4
|
+
import { rmdir, fileSize, glob, removeFile, copyFile } from '@shopify/cli-kit/node/fs';
|
|
5
|
+
import { resolvePath, relativePath, joinPath } from '@shopify/cli-kit/node/path';
|
|
6
6
|
import { getPackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
7
7
|
import colors from '@shopify/cli-kit/node/colors';
|
|
8
8
|
import { getProjectPaths, getRemixConfig } from '../../lib/config.js';
|
|
@@ -16,7 +16,11 @@ class Build extends Command {
|
|
|
16
16
|
static description = "Builds a Hydrogen storefront for production.";
|
|
17
17
|
static flags = {
|
|
18
18
|
path: commonFlags.path,
|
|
19
|
-
sourcemap:
|
|
19
|
+
sourcemap: Flags.boolean({
|
|
20
|
+
description: "Generate sourcemaps for the build.",
|
|
21
|
+
env: "SHOPIFY_HYDROGEN_FLAG_SOURCEMAP",
|
|
22
|
+
default: false
|
|
23
|
+
}),
|
|
20
24
|
"disable-route-warning": Flags.boolean({
|
|
21
25
|
description: "Disable warning about missing standard routes.",
|
|
22
26
|
env: "SHOPIFY_HYDROGEN_FLAG_DISABLE_ROUTE_WARNING"
|
|
@@ -27,13 +31,13 @@ class Build extends Command {
|
|
|
27
31
|
};
|
|
28
32
|
async run() {
|
|
29
33
|
const { flags } = await this.parse(Build);
|
|
30
|
-
const directory = flags.path ?
|
|
34
|
+
const directory = flags.path ? resolvePath(flags.path) : process.cwd();
|
|
31
35
|
await runBuild({ ...flagsToCamelObject(flags), path: directory });
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
async function runBuild({
|
|
35
39
|
path: appPath,
|
|
36
|
-
sourcemap =
|
|
40
|
+
sourcemap = false,
|
|
37
41
|
disableRouteWarning = false
|
|
38
42
|
}) {
|
|
39
43
|
if (!process.env.NODE_ENV) {
|
|
@@ -71,7 +75,7 @@ async function runBuild({
|
|
|
71
75
|
const sizeMB = await fileSize(buildPathWorkerFile) / (1024 * 1024);
|
|
72
76
|
outputInfo(
|
|
73
77
|
outputContent` ${colors.dim(
|
|
74
|
-
|
|
78
|
+
relativePath(root, buildPathWorkerFile)
|
|
75
79
|
)} ${outputToken.yellow(sizeMB.toFixed(2))} MB\n`
|
|
76
80
|
);
|
|
77
81
|
if (sizeMB >= 1) {
|
|
@@ -80,6 +84,18 @@ async function runBuild({
|
|
|
80
84
|
`
|
|
81
85
|
);
|
|
82
86
|
}
|
|
87
|
+
if (sourcemap) {
|
|
88
|
+
if (process.env.HYDROGEN_ASSET_BASE_URL) {
|
|
89
|
+
const filepaths = await glob(joinPath(buildPathClient, "**/*.js.map"));
|
|
90
|
+
for (const filepath of filepaths) {
|
|
91
|
+
await removeFile(filepath);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
outputWarn(
|
|
95
|
+
"\u{1F6A8} Sourcemaps are enabled in production! Use this only for testing.\n"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
83
99
|
}
|
|
84
100
|
if (!disableRouteWarning) {
|
|
85
101
|
const missingRoutes = findMissingRoutes(remixConfig);
|
|
@@ -3,6 +3,7 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import { outputInfo } from '@shopify/cli-kit/node/output';
|
|
4
4
|
import { fileExists } from '@shopify/cli-kit/node/fs';
|
|
5
5
|
import { renderFatalError } from '@shopify/cli-kit/node/ui';
|
|
6
|
+
import colors from '@shopify/cli-kit/node/colors';
|
|
6
7
|
import { copyPublicFiles } from './build.js';
|
|
7
8
|
import { getProjectPaths, getRemixConfig } from '../../lib/config.js';
|
|
8
9
|
import { muteDevLogs, warnOnce } from '../../lib/log.js';
|
|
@@ -12,10 +13,10 @@ import { Flags } from '@oclif/core';
|
|
|
12
13
|
import { startMiniOxygen } from '../../lib/mini-oxygen.js';
|
|
13
14
|
import { checkHydrogenVersion } from '../../lib/check-version.js';
|
|
14
15
|
import { addVirtualRoutes } from '../../lib/virtual-routes.js';
|
|
16
|
+
import { spawnCodegenProcess } from '../../lib/codegen.js';
|
|
15
17
|
import { combinedEnvironmentVariables } from '../../lib/combined-environment-variables.js';
|
|
16
18
|
import { getConfig } from '../../lib/shopify-config.js';
|
|
17
19
|
|
|
18
|
-
const LOG_INITIAL_BUILD = "\n\u{1F3C1} Initial build";
|
|
19
20
|
const LOG_REBUILDING = "\u{1F9F1} Rebuilding...";
|
|
20
21
|
const LOG_REBUILT = "\u{1F680} Rebuilt";
|
|
21
22
|
class Dev extends Command {
|
|
@@ -74,7 +75,6 @@ async function runDev({
|
|
|
74
75
|
muteDevLogs();
|
|
75
76
|
if (debug)
|
|
76
77
|
(await import('node:inspector')).open();
|
|
77
|
-
console.time(LOG_INITIAL_BUILD);
|
|
78
78
|
const { root, publicPath, buildPathClient, buildPathWorkerFile } = getProjectPaths(appPath);
|
|
79
79
|
const checkingHydrogenVersion = checkHydrogenVersion(root);
|
|
80
80
|
const copyingFiles = copyPublicFiles(publicPath, buildPathClient);
|
|
@@ -93,11 +93,18 @@ async function runDev({
|
|
|
93
93
|
shop,
|
|
94
94
|
envBranch
|
|
95
95
|
}) : void 0;
|
|
96
|
+
const [{ watch }, { createFileWatchCache }] = await Promise.all([
|
|
97
|
+
import('@remix-run/dev/dist/compiler/watch.js'),
|
|
98
|
+
import('@remix-run/dev/dist/compiler/fileWatchCache.js')
|
|
99
|
+
]);
|
|
100
|
+
let isInitialBuild = true;
|
|
101
|
+
let initialBuildDurationMs = 0;
|
|
102
|
+
let initialBuildStartTimeMs = Date.now();
|
|
96
103
|
let isMiniOxygenStarted = false;
|
|
97
104
|
async function safeStartMiniOxygen() {
|
|
98
105
|
if (isMiniOxygenStarted)
|
|
99
106
|
return;
|
|
100
|
-
await startMiniOxygen({
|
|
107
|
+
const miniOxygen = await startMiniOxygen({
|
|
101
108
|
root,
|
|
102
109
|
port,
|
|
103
110
|
watch: true,
|
|
@@ -106,19 +113,28 @@ async function runDev({
|
|
|
106
113
|
environmentVariables
|
|
107
114
|
});
|
|
108
115
|
isMiniOxygenStarted = true;
|
|
116
|
+
miniOxygen.showBanner({
|
|
117
|
+
headlinePrefix: initialBuildDurationMs > 0 ? `Initial build: ${initialBuildDurationMs}ms
|
|
118
|
+
` : "",
|
|
119
|
+
extraLines: [
|
|
120
|
+
colors.dim(
|
|
121
|
+
`
|
|
122
|
+
View GraphiQL API browser: ${miniOxygen.listeningAt}/graphiql`
|
|
123
|
+
)
|
|
124
|
+
]
|
|
125
|
+
});
|
|
109
126
|
const showUpgrade = await checkingHydrogenVersion;
|
|
110
127
|
if (showUpgrade)
|
|
111
128
|
showUpgrade();
|
|
112
129
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
]);
|
|
130
|
+
const remixConfig = await reloadConfig();
|
|
131
|
+
if (codegen) {
|
|
132
|
+
spawnCodegenProcess({ ...remixConfig, configFilePath: codegenConfigPath });
|
|
133
|
+
}
|
|
118
134
|
const fileWatchCache = createFileWatchCache();
|
|
119
135
|
await watch(
|
|
120
136
|
{
|
|
121
|
-
config:
|
|
137
|
+
config: remixConfig,
|
|
122
138
|
options: {
|
|
123
139
|
mode: process.env.NODE_ENV,
|
|
124
140
|
onWarning: warnOnce,
|
|
@@ -129,9 +145,7 @@ async function runDev({
|
|
|
129
145
|
{
|
|
130
146
|
reloadConfig,
|
|
131
147
|
onBuildStart() {
|
|
132
|
-
if (isInitialBuild) {
|
|
133
|
-
console.time(LOG_INITIAL_BUILD);
|
|
134
|
-
} else {
|
|
148
|
+
if (!isInitialBuild) {
|
|
135
149
|
console.time(LOG_REBUILT);
|
|
136
150
|
outputInfo(LOG_REBUILDING);
|
|
137
151
|
}
|
|
@@ -139,7 +153,7 @@ async function runDev({
|
|
|
139
153
|
async onBuildFinish() {
|
|
140
154
|
if (isInitialBuild) {
|
|
141
155
|
await copyingFiles;
|
|
142
|
-
|
|
156
|
+
initialBuildDurationMs = Date.now() - initialBuildStartTimeMs;
|
|
143
157
|
isInitialBuild = false;
|
|
144
158
|
} else {
|
|
145
159
|
console.timeEnd(LOG_REBUILT);
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import Command from '@shopify/cli-kit/node/base-command';
|
|
3
|
-
import {
|
|
3
|
+
import { basename } from '@shopify/cli-kit/node/path';
|
|
4
|
+
import { renderConfirmationPrompt, renderWarning, renderSelectPrompt, renderTextPrompt, renderTasks, renderSuccess } from '@shopify/cli-kit/node/ui';
|
|
4
5
|
import { commonFlags } from '../../lib/flags.js';
|
|
5
6
|
import { getHydrogenShop } from '../../lib/shop.js';
|
|
6
7
|
import { getStorefronts } from '../../lib/graphql/admin/link-storefront.js';
|
|
8
|
+
import { createStorefront } from '../../lib/graphql/admin/create-storefront.js';
|
|
9
|
+
import { waitForJob } from '../../lib/graphql/admin/fetch-job.js';
|
|
7
10
|
import { getConfig, setStorefront } from '../../lib/shopify-config.js';
|
|
8
11
|
import { logMissingStorefronts } from '../../lib/missing-storefronts.js';
|
|
12
|
+
import { titleize } from '../../lib/string.js';
|
|
9
13
|
import { getCliCommand } from '../../lib/shell.js';
|
|
14
|
+
import { renderUserErrors, renderError } from '../../lib/user-errors.js';
|
|
10
15
|
|
|
11
16
|
class Link extends Command {
|
|
12
17
|
static description = "Link a local project to one of your shop's Hydrogen storefronts.";
|
|
@@ -24,6 +29,7 @@ class Link extends Command {
|
|
|
24
29
|
await linkStorefront(flags);
|
|
25
30
|
}
|
|
26
31
|
}
|
|
32
|
+
const CREATE_NEW_STOREFRONT_ID = "NEW_STOREFRONT";
|
|
27
33
|
async function linkStorefront({
|
|
28
34
|
force,
|
|
29
35
|
path,
|
|
@@ -47,6 +53,7 @@ async function linkStorefront({
|
|
|
47
53
|
return;
|
|
48
54
|
}
|
|
49
55
|
let selectedStorefront;
|
|
56
|
+
let selectCreateNewStorefront = false;
|
|
50
57
|
const cliCommand = await getCliCommand();
|
|
51
58
|
if (flagStorefront) {
|
|
52
59
|
selectedStorefront = storefronts.find(
|
|
@@ -77,11 +84,61 @@ async function linkStorefront({
|
|
|
77
84
|
message: "Choose a Hydrogen storefront to link",
|
|
78
85
|
choices
|
|
79
86
|
});
|
|
80
|
-
|
|
87
|
+
if (storefrontId === CREATE_NEW_STOREFRONT_ID) {
|
|
88
|
+
selectCreateNewStorefront = true;
|
|
89
|
+
} else {
|
|
90
|
+
selectedStorefront = storefronts.find(({ id }) => id === storefrontId);
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
93
|
+
if (selectCreateNewStorefront) {
|
|
94
|
+
const storefront = await createNewStorefront(path, shop);
|
|
95
|
+
if (!storefront) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
selectedStorefront = storefront;
|
|
84
99
|
}
|
|
100
|
+
if (selectedStorefront) {
|
|
101
|
+
await linkExistingStorefront(path, selectedStorefront, silent, cliCommand);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function createNewStorefront(path, shop) {
|
|
105
|
+
const projectDirectory = path && basename(path);
|
|
106
|
+
const projectName = await renderTextPrompt({
|
|
107
|
+
message: "What do you want to name the Hydrogen storefront on Shopify?",
|
|
108
|
+
defaultValue: titleize(projectDirectory) || "Hydrogen Storefront"
|
|
109
|
+
});
|
|
110
|
+
let storefront;
|
|
111
|
+
let jobId;
|
|
112
|
+
await renderTasks([
|
|
113
|
+
{
|
|
114
|
+
title: "Creating storefront",
|
|
115
|
+
task: async () => {
|
|
116
|
+
const result = await createStorefront(shop, projectName);
|
|
117
|
+
storefront = result.storefront;
|
|
118
|
+
jobId = result.jobId;
|
|
119
|
+
if (result.userErrors.length > 0) {
|
|
120
|
+
renderUserErrors(result.userErrors);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
title: "Creating API tokens",
|
|
126
|
+
task: async () => {
|
|
127
|
+
try {
|
|
128
|
+
await waitForJob(shop, jobId);
|
|
129
|
+
} catch (_err) {
|
|
130
|
+
storefront = void 0;
|
|
131
|
+
renderError(
|
|
132
|
+
"Please try again or contact support if the error persists."
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
skip: () => !jobId
|
|
137
|
+
}
|
|
138
|
+
]);
|
|
139
|
+
return storefront;
|
|
140
|
+
}
|
|
141
|
+
async function linkExistingStorefront(path, selectedStorefront, silent, cliCommand) {
|
|
85
142
|
await setStorefront(path ?? process.cwd(), selectedStorefront);
|
|
86
143
|
if (!silent) {
|
|
87
144
|
renderSuccess({
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { vi, describe, beforeEach, afterEach, it, expect } from 'vitest';
|
|
2
2
|
import { mockAndCaptureOutput } from '@shopify/cli-kit/node/testing/output';
|
|
3
|
-
import { renderSelectPrompt, renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
|
|
3
|
+
import { renderSelectPrompt, renderTextPrompt, renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
|
|
4
4
|
import { adminRequest } from '../../lib/graphql.js';
|
|
5
5
|
import { getStorefronts } from '../../lib/graphql/admin/link-storefront.js';
|
|
6
|
+
import { createStorefront } from '../../lib/graphql/admin/create-storefront.js';
|
|
7
|
+
import { waitForJob } from '../../lib/graphql/admin/fetch-job.js';
|
|
6
8
|
import { getConfig, setStorefront } from '../../lib/shopify-config.js';
|
|
9
|
+
import { renderUserErrors, renderError } from '../../lib/user-errors.js';
|
|
7
10
|
import { linkStorefront } from './link.js';
|
|
8
11
|
|
|
9
12
|
const SHOP = "my-shop";
|
|
@@ -16,12 +19,16 @@ vi.mock("@shopify/cli-kit/node/ui", async () => {
|
|
|
16
19
|
return {
|
|
17
20
|
...original,
|
|
18
21
|
renderConfirmationPrompt: vi.fn(),
|
|
19
|
-
renderSelectPrompt: vi.fn()
|
|
22
|
+
renderSelectPrompt: vi.fn(),
|
|
23
|
+
renderTextPrompt: vi.fn()
|
|
20
24
|
};
|
|
21
25
|
});
|
|
22
26
|
vi.mock("../../lib/graphql.js");
|
|
23
27
|
vi.mock("../../lib/shopify-config.js");
|
|
24
28
|
vi.mock("../../lib/graphql/admin/link-storefront.js");
|
|
29
|
+
vi.mock("../../lib/graphql/admin/create-storefront.js");
|
|
30
|
+
vi.mock("../../lib/graphql/admin/fetch-job.js");
|
|
31
|
+
vi.mock("../../lib/user-errors.js");
|
|
25
32
|
vi.mock("../../lib/shop.js", () => ({
|
|
26
33
|
getHydrogenShop: () => SHOP
|
|
27
34
|
}));
|
|
@@ -52,28 +59,90 @@ describe("link", () => {
|
|
|
52
59
|
await linkStorefront({});
|
|
53
60
|
expect(getStorefronts).toHaveBeenCalledWith(SHOP);
|
|
54
61
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
describe("when you want to link an existing Hydrogen storefront", () => {
|
|
63
|
+
beforeEach(async () => {
|
|
64
|
+
vi.mocked(renderSelectPrompt).mockResolvedValue(
|
|
65
|
+
"gid://shopify/HydrogenStorefront/1"
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
it("renders a list of choices and forwards the selection to setStorefront", async () => {
|
|
69
|
+
await linkStorefront({ path: "my-path" });
|
|
70
|
+
expect(setStorefront).toHaveBeenCalledWith(
|
|
71
|
+
"my-path",
|
|
72
|
+
expect.objectContaining({
|
|
73
|
+
id: "gid://shopify/HydrogenStorefront/1",
|
|
74
|
+
title: "Hydrogen"
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
it("renders a success message", async () => {
|
|
79
|
+
await linkStorefront({ path: "my-path" });
|
|
80
|
+
expect(outputMock.info()).toMatch(/Hydrogen is now linked/g);
|
|
81
|
+
expect(outputMock.info()).toMatch(
|
|
82
|
+
/Run `h2 dev` to start your local development server and start building/g
|
|
83
|
+
);
|
|
84
|
+
});
|
|
67
85
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
describe("when you want to link a new Hydrogen storefront", () => {
|
|
87
|
+
const expectedStorefrontName = "New Storefront";
|
|
88
|
+
const expectedJobId = "gid://shopify/Job/1";
|
|
89
|
+
beforeEach(async () => {
|
|
90
|
+
vi.mocked(renderSelectPrompt).mockResolvedValue("NEW_STOREFRONT");
|
|
91
|
+
vi.mocked(createStorefront).mockResolvedValue({
|
|
92
|
+
adminSession: ADMIN_SESSION,
|
|
93
|
+
storefront: {
|
|
94
|
+
id: "gid://shopify/HydrogenStorefront/1",
|
|
95
|
+
title: expectedStorefrontName,
|
|
96
|
+
productionUrl: "https://example.com"
|
|
97
|
+
},
|
|
98
|
+
userErrors: [],
|
|
99
|
+
jobId: expectedJobId
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it("chooses to create a new storefront given the directory path", async () => {
|
|
103
|
+
await linkStorefront({ path: "my-path" });
|
|
104
|
+
expect(renderTextPrompt).toHaveBeenCalledWith({
|
|
105
|
+
message: expect.stringMatching(/name/i),
|
|
106
|
+
defaultValue: "My Path"
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
it("chooses to create a new storefront without directory path", async () => {
|
|
110
|
+
await linkStorefront({});
|
|
111
|
+
expect(renderTextPrompt).toHaveBeenCalledWith({
|
|
112
|
+
message: expect.stringMatching(/name/i),
|
|
113
|
+
defaultValue: "Hydrogen Storefront"
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
it("handles the successful creation of the storefront on Admin", async () => {
|
|
117
|
+
await linkStorefront({});
|
|
118
|
+
expect(waitForJob).toHaveBeenCalledWith(SHOP, expectedJobId);
|
|
119
|
+
expect(outputMock.info()).toContain(
|
|
120
|
+
`${expectedStorefrontName} is now linked`
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
it("handles the user-errors when creating the storefront on Admin", async () => {
|
|
124
|
+
const expectedUserErrors = [
|
|
125
|
+
{
|
|
126
|
+
code: "INVALID",
|
|
127
|
+
field: [],
|
|
128
|
+
message: "Bad thing happend."
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
vi.mocked(createStorefront).mockResolvedValue({
|
|
132
|
+
adminSession: ADMIN_SESSION,
|
|
133
|
+
storefront: void 0,
|
|
134
|
+
userErrors: expectedUserErrors,
|
|
135
|
+
jobId: void 0
|
|
136
|
+
});
|
|
137
|
+
await linkStorefront({});
|
|
138
|
+
expect(waitForJob).not.toHaveBeenCalled();
|
|
139
|
+
expect(renderUserErrors).toHaveBeenCalledWith(expectedUserErrors);
|
|
140
|
+
});
|
|
141
|
+
it("handles the job errors when creating the storefront on Admin", async () => {
|
|
142
|
+
vi.mocked(waitForJob).mockRejectedValue(void 0);
|
|
143
|
+
await linkStorefront({});
|
|
144
|
+
expect(renderError).toHaveBeenCalled();
|
|
145
|
+
});
|
|
77
146
|
});
|
|
78
147
|
describe("when there are no Hydrogen storefronts", () => {
|
|
79
148
|
it("renders a message and returns early", async () => {
|
|
@@ -23,12 +23,13 @@ async function runPreview({
|
|
|
23
23
|
process.env.NODE_ENV = "production";
|
|
24
24
|
muteDevLogs({ workerReload: false });
|
|
25
25
|
const { root, buildPathWorkerFile, buildPathClient } = getProjectPaths(appPath);
|
|
26
|
-
await startMiniOxygen({
|
|
26
|
+
const miniOxygen = await startMiniOxygen({
|
|
27
27
|
root,
|
|
28
28
|
port,
|
|
29
29
|
buildPathClient,
|
|
30
30
|
buildPathWorkerFile
|
|
31
31
|
});
|
|
32
|
+
miniOxygen.showBanner({ mode: "preview" });
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export { Preview as default, runPreview };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AdminSession } from '@shopify/cli-kit/node/session';
|
|
2
|
+
import { UserError } from '../../user-errors.js';
|
|
3
|
+
|
|
4
|
+
declare const CreateStorefrontMutation = "#graphql\n mutation CreateStorefront($title: String!) {\n hydrogenStorefrontCreate(title: $title) {\n hydrogenStorefront {\n id\n title\n productionUrl\n }\n userErrors {\n code\n field\n message\n }\n jobId\n }\n }\n";
|
|
5
|
+
interface HydrogenStorefront {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
productionUrl: string;
|
|
9
|
+
}
|
|
10
|
+
declare function createStorefront(shop: string, title: string): Promise<{
|
|
11
|
+
adminSession: AdminSession;
|
|
12
|
+
storefront: HydrogenStorefront | undefined;
|
|
13
|
+
userErrors: UserError[];
|
|
14
|
+
jobId: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export { CreateStorefrontMutation, createStorefront };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { adminRequest } from '../../graphql.js';
|
|
2
|
+
import { getAdminSession } from '../../admin-session.js';
|
|
3
|
+
|
|
4
|
+
const CreateStorefrontMutation = `#graphql
|
|
5
|
+
mutation CreateStorefront($title: String!) {
|
|
6
|
+
hydrogenStorefrontCreate(title: $title) {
|
|
7
|
+
hydrogenStorefront {
|
|
8
|
+
id
|
|
9
|
+
title
|
|
10
|
+
productionUrl
|
|
11
|
+
}
|
|
12
|
+
userErrors {
|
|
13
|
+
code
|
|
14
|
+
field
|
|
15
|
+
message
|
|
16
|
+
}
|
|
17
|
+
jobId
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
async function createStorefront(shop, title) {
|
|
22
|
+
const adminSession = await getAdminSession(shop);
|
|
23
|
+
const { hydrogenStorefrontCreate } = await adminRequest(
|
|
24
|
+
CreateStorefrontMutation,
|
|
25
|
+
adminSession,
|
|
26
|
+
{
|
|
27
|
+
title
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
return {
|
|
31
|
+
adminSession,
|
|
32
|
+
storefront: hydrogenStorefrontCreate.hydrogenStorefront,
|
|
33
|
+
userErrors: hydrogenStorefrontCreate.userErrors,
|
|
34
|
+
jobId: hydrogenStorefrontCreate.jobId
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { CreateStorefrontMutation, createStorefront };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AdminSession } from '@shopify/cli-kit/node/session';
|
|
2
|
+
|
|
3
|
+
declare const FetchJobQuery = "#graphql\n query FetchJob($id: ID!) {\n hydrogenStorefrontJob(id: $id) {\n id\n done\n errors {\n code\n message\n }\n }\n }\n";
|
|
4
|
+
interface JobError {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface JobSchema {
|
|
9
|
+
hydrogenStorefrontJob: {
|
|
10
|
+
id: string;
|
|
11
|
+
done: boolean;
|
|
12
|
+
errors: JobError[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare function fetchJob(shop: string, jobId: string): Promise<{
|
|
16
|
+
adminSession: AdminSession;
|
|
17
|
+
id: string;
|
|
18
|
+
done: boolean;
|
|
19
|
+
errors: JobError[];
|
|
20
|
+
}>;
|
|
21
|
+
declare function waitForJob(shop: string, jobId: string): Promise<void>;
|
|
22
|
+
|
|
23
|
+
export { FetchJobQuery, JobSchema, fetchJob, waitForJob };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { adminRequest } from '../../graphql.js';
|
|
2
|
+
import { getAdminSession } from '../../admin-session.js';
|
|
3
|
+
|
|
4
|
+
const FetchJobQuery = `#graphql
|
|
5
|
+
query FetchJob($id: ID!) {
|
|
6
|
+
hydrogenStorefrontJob(id: $id) {
|
|
7
|
+
id
|
|
8
|
+
done
|
|
9
|
+
errors {
|
|
10
|
+
code
|
|
11
|
+
message
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
async function fetchJob(shop, jobId) {
|
|
17
|
+
const adminSession = await getAdminSession(shop);
|
|
18
|
+
const { hydrogenStorefrontJob } = await adminRequest(
|
|
19
|
+
FetchJobQuery,
|
|
20
|
+
adminSession,
|
|
21
|
+
{
|
|
22
|
+
id: jobId
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
return {
|
|
26
|
+
adminSession,
|
|
27
|
+
id: hydrogenStorefrontJob.id,
|
|
28
|
+
done: hydrogenStorefrontJob.done,
|
|
29
|
+
errors: hydrogenStorefrontJob.errors
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function waitForJob(shop, jobId) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const interval = setInterval(async () => {
|
|
35
|
+
const job = await fetchJob(shop, jobId);
|
|
36
|
+
if (job.errors.length > 0) {
|
|
37
|
+
clearInterval(interval);
|
|
38
|
+
return reject();
|
|
39
|
+
}
|
|
40
|
+
if (job.done) {
|
|
41
|
+
clearInterval(interval);
|
|
42
|
+
return resolve();
|
|
43
|
+
}
|
|
44
|
+
}, 500);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { FetchJobQuery, fetchJob, waitForJob };
|
|
@@ -8,7 +8,15 @@ type MiniOxygenOptions = {
|
|
|
8
8
|
[key: string]: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
declare function startMiniOxygen({ root, port, watch, buildPathWorkerFile, buildPathClient, environmentVariables, }: MiniOxygenOptions): Promise<
|
|
11
|
+
declare function startMiniOxygen({ root, port, watch, buildPathWorkerFile, buildPathClient, environmentVariables, }: MiniOxygenOptions): Promise<{
|
|
12
|
+
listeningAt: string;
|
|
13
|
+
port: number;
|
|
14
|
+
showBanner(options?: {
|
|
15
|
+
mode?: string;
|
|
16
|
+
headlinePrefix?: string;
|
|
17
|
+
extraLines?: string[];
|
|
18
|
+
}): void;
|
|
19
|
+
}>;
|
|
12
20
|
declare function logResponse(request: Request, response: Response): void;
|
|
13
21
|
|
|
14
22
|
export { logResponse, startMiniOxygen };
|
package/dist/lib/mini-oxygen.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { outputInfo, outputContent
|
|
1
|
+
import { outputToken, outputInfo, outputContent } from '@shopify/cli-kit/node/output';
|
|
2
2
|
import { resolvePath } from '@shopify/cli-kit/node/path';
|
|
3
3
|
import { fileExists } from '@shopify/cli-kit/node/fs';
|
|
4
4
|
import colors from '@shopify/cli-kit/node/colors';
|
|
5
|
+
import { renderSuccess } from '@shopify/cli-kit/node/ui';
|
|
5
6
|
|
|
6
7
|
async function startMiniOxygen({
|
|
7
8
|
root,
|
|
@@ -36,12 +37,19 @@ async function startMiniOxygen({
|
|
|
36
37
|
)
|
|
37
38
|
});
|
|
38
39
|
const listeningAt = `http://localhost:${actualPort}`;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
return {
|
|
41
|
+
listeningAt,
|
|
42
|
+
port: actualPort,
|
|
43
|
+
showBanner(options) {
|
|
44
|
+
renderSuccess({
|
|
45
|
+
headline: `${options?.headlinePrefix ?? ""}MiniOxygen ${options?.mode ?? "development"} server running.`,
|
|
46
|
+
body: [
|
|
47
|
+
`View Hydrogen app: ${listeningAt}`,
|
|
48
|
+
...options?.extraLines ?? []
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
45
53
|
}
|
|
46
54
|
function logResponse(request, response) {
|
|
47
55
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { titleize } from './string.js';
|
|
3
|
+
|
|
4
|
+
describe("titleize", () => {
|
|
5
|
+
const TEST_DIRECTORY_NAMES = {
|
|
6
|
+
"demo-storefront": "Demo Storefront",
|
|
7
|
+
"nifty \u{1F602} project ": "Nifty Project",
|
|
8
|
+
"Hello \u{1F602}": "Hello",
|
|
9
|
+
_____: ""
|
|
10
|
+
};
|
|
11
|
+
it("replaces non-alpha-numeric characters with spaces and capitalizes the first letter of every word", () => {
|
|
12
|
+
for (const [input, expected] of Object.entries(TEST_DIRECTORY_NAMES)) {
|
|
13
|
+
expect(titleize(input)).toBe(expected);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface UserError {
|
|
2
|
+
code: string | undefined;
|
|
3
|
+
field: string[];
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
declare function renderUserErrors(userErrors: UserError[]): void;
|
|
7
|
+
declare function renderError(message: string): void;
|
|
8
|
+
|
|
9
|
+
export { UserError, renderError, renderUserErrors };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
2
|
+
|
|
3
|
+
function renderUserErrors(userErrors) {
|
|
4
|
+
const errorMessages = userErrors.map(({ message }) => message).join(", ");
|
|
5
|
+
renderError(errorMessages);
|
|
6
|
+
}
|
|
7
|
+
function renderError(message) {
|
|
8
|
+
throw new AbortError(message);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { renderError, renderUserErrors };
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.0.1","commands":{"hydrogen:build":{"id":"hydrogen:build","description":"Builds a Hydrogen storefront for production.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"sourcemap":{"name":"sourcemap","type":"boolean","description":"Generate sourcemaps for the build.","allowNo":true},"disable-route-warning":{"name":"disable-route-warning","type":"boolean","description":"Disable warning about missing standard routes.","allowNo":false},"base":{"name":"base","type":"option","hidden":true,"multiple":false},"entry":{"name":"entry","type":"option","hidden":true,"multiple":false},"target":{"name":"target","type":"option","hidden":true,"multiple":false}},"args":[]},"hydrogen:check":{"id":"hydrogen:check","description":"Returns diagnostic information about a Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[{"name":"resource","description":"The resource to check. Currently only 'routes' is supported.","required":true,"options":["routes"]}]},"hydrogen:codegen-unstable":{"id":"hydrogen:codegen-unstable","description":"Generate types for the Storefront API queries found in your project.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"codegen-config-path":{"name":"codegen-config-path","type":"option","description":"Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.","required":false,"multiple":false},"force-sfapi-version":{"name":"force-sfapi-version","type":"option","description":"Force generating Storefront API types for a specific version instead of using the one provided in Hydrogen. A token can also be provided with this format: `<version>:<token>`.","hidden":true,"multiple":false},"watch":{"name":"watch","type":"boolean","description":"Watch the project for changes to update types on file save.","required":false,"allowNo":false}},"args":[]},"hydrogen:dev":{"id":"hydrogen:dev","description":"Runs Hydrogen storefront in an Oxygen worker for development.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"port":{"name":"port","type":"option","description":"Port to run the server on.","multiple":false,"default":3000},"codegen-unstable":{"name":"codegen-unstable","type":"boolean","description":"Generate types for the Storefront API queries found in your project. It updates the types on file save.","required":false,"allowNo":false},"codegen-config-path":{"name":"codegen-config-path","type":"option","description":"Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.","required":false,"multiple":false,"dependsOn":["codegen-unstable"]},"sourcemap":{"name":"sourcemap","type":"boolean","description":"Generate sourcemaps for the build.","allowNo":true},"disable-virtual-routes":{"name":"disable-virtual-routes","type":"boolean","description":"Disable rendering fallback routes when a route file doesn't exist.","allowNo":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false},"debug":{"name":"debug","type":"boolean","description":"Attaches a Node inspector","allowNo":false},"host":{"name":"host","type":"option","hidden":true,"multiple":false},"env-branch":{"name":"env-branch","type":"option","char":"e","description":"Specify an environment's branch name when using remote environment variables.","multiple":false}},"args":[]},"hydrogen:g":{"id":"hydrogen:g","description":"Shortcut for `hydrogen generate`. See `hydrogen generate --help` for more information.","strict":false,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"hydrogen:init":{"id":"hydrogen:init","description":"Creates a new Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the new Hydrogen storefront.","multiple":false},"language":{"name":"language","type":"option","description":"Sets the template language to use. One of `js` or `ts`.","multiple":false},"template":{"name":"template","type":"option","description":"Sets the template to use. One of `demo-store` or `hello-world`.","multiple":false},"install-deps":{"name":"install-deps","type":"boolean","description":"Auto install dependencies using the active package manager","allowNo":true}},"args":[]},"hydrogen:link":{"id":"hydrogen:link","description":"Link a local project to one of your shop's Hydrogen storefronts.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false},"storefront":{"name":"storefront","type":"option","description":"The name of a Hydrogen Storefront (e.g. \"Jane's Apparel\")","multiple":false}},"args":[]},"hydrogen:list":{"id":"hydrogen:list","description":"Returns a list of Hydrogen storefronts available on a given shop.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false}},"args":[]},"hydrogen:preview":{"id":"hydrogen:preview","description":"Runs a Hydrogen storefront in an Oxygen worker for production.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"port":{"name":"port","type":"option","description":"Port to run the server on.","multiple":false,"default":3000}},"args":[]},"hydrogen:shortcut":{"id":"hydrogen:shortcut","description":"Creates a global `h2` shortcut for the Hydrogen CLI","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{},"args":[]},"hydrogen:unlink":{"id":"hydrogen:unlink","description":"Unlink a local project from a Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[]},"hydrogen:env:list":{"id":"hydrogen:env:list","description":"List the environments on your linked Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false}},"args":[]},"hydrogen:env:pull":{"id":"hydrogen:env:pull","description":"Populate your .env with variables from your Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"env-branch":{"name":"env-branch","type":"option","char":"e","description":"Specify an environment's branch name when using remote environment variables.","multiple":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false},"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false}},"args":[]},"hydrogen:generate:route":{"id":"hydrogen:generate:route","description":"Generates a standard Shopify route.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"adapter":{"name":"adapter","type":"option","description":"Remix adapter used in the route. The default is `@shopify/remix-oxygen`.","multiple":false},"typescript":{"name":"typescript","type":"boolean","description":"Generate TypeScript files","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[{"name":"route","description":"The route to generate. One of home,page,cart,products,collections,policies,robots,sitemap,account,all.","required":true,"options":["home","page","cart","products","collections","policies","robots","sitemap","account","all"]}]},"hydrogen:generate:routes":{"id":"hydrogen:generate:routes","description":"Generates all supported standard shopify routes.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"adapter":{"name":"adapter","type":"option","description":"Remix adapter used in the route. The default is `@shopify/remix-oxygen`.","multiple":false},"typescript":{"name":"typescript","type":"boolean","description":"Generate TypeScript files","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[]}}}
|
|
1
|
+
{"version":"5.0.2","commands":{"hydrogen:build":{"id":"hydrogen:build","description":"Builds a Hydrogen storefront for production.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"sourcemap":{"name":"sourcemap","type":"boolean","description":"Generate sourcemaps for the build.","allowNo":false},"disable-route-warning":{"name":"disable-route-warning","type":"boolean","description":"Disable warning about missing standard routes.","allowNo":false},"base":{"name":"base","type":"option","hidden":true,"multiple":false},"entry":{"name":"entry","type":"option","hidden":true,"multiple":false},"target":{"name":"target","type":"option","hidden":true,"multiple":false}},"args":[]},"hydrogen:check":{"id":"hydrogen:check","description":"Returns diagnostic information about a Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[{"name":"resource","description":"The resource to check. Currently only 'routes' is supported.","required":true,"options":["routes"]}]},"hydrogen:codegen-unstable":{"id":"hydrogen:codegen-unstable","description":"Generate types for the Storefront API queries found in your project.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"codegen-config-path":{"name":"codegen-config-path","type":"option","description":"Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.","required":false,"multiple":false},"force-sfapi-version":{"name":"force-sfapi-version","type":"option","description":"Force generating Storefront API types for a specific version instead of using the one provided in Hydrogen. A token can also be provided with this format: `<version>:<token>`.","hidden":true,"multiple":false},"watch":{"name":"watch","type":"boolean","description":"Watch the project for changes to update types on file save.","required":false,"allowNo":false}},"args":[]},"hydrogen:dev":{"id":"hydrogen:dev","description":"Runs Hydrogen storefront in an Oxygen worker for development.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"port":{"name":"port","type":"option","description":"Port to run the server on.","multiple":false,"default":3000},"codegen-unstable":{"name":"codegen-unstable","type":"boolean","description":"Generate types for the Storefront API queries found in your project. It updates the types on file save.","required":false,"allowNo":false},"codegen-config-path":{"name":"codegen-config-path","type":"option","description":"Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.","required":false,"multiple":false,"dependsOn":["codegen-unstable"]},"sourcemap":{"name":"sourcemap","type":"boolean","description":"Generate sourcemaps for the build.","allowNo":true},"disable-virtual-routes":{"name":"disable-virtual-routes","type":"boolean","description":"Disable rendering fallback routes when a route file doesn't exist.","allowNo":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false},"debug":{"name":"debug","type":"boolean","description":"Attaches a Node inspector","allowNo":false},"host":{"name":"host","type":"option","hidden":true,"multiple":false},"env-branch":{"name":"env-branch","type":"option","char":"e","description":"Specify an environment's branch name when using remote environment variables.","multiple":false}},"args":[]},"hydrogen:g":{"id":"hydrogen:g","description":"Shortcut for `hydrogen generate`. See `hydrogen generate --help` for more information.","strict":false,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"hydrogen:init":{"id":"hydrogen:init","description":"Creates a new Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the new Hydrogen storefront.","multiple":false},"language":{"name":"language","type":"option","description":"Sets the template language to use. One of `js` or `ts`.","multiple":false},"template":{"name":"template","type":"option","description":"Sets the template to use. One of `demo-store` or `hello-world`.","multiple":false},"install-deps":{"name":"install-deps","type":"boolean","description":"Auto install dependencies using the active package manager","allowNo":true}},"args":[]},"hydrogen:link":{"id":"hydrogen:link","description":"Link a local project to one of your shop's Hydrogen storefronts.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false},"storefront":{"name":"storefront","type":"option","description":"The name of a Hydrogen Storefront (e.g. \"Jane's Apparel\")","multiple":false}},"args":[]},"hydrogen:list":{"id":"hydrogen:list","description":"Returns a list of Hydrogen storefronts available on a given shop.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false}},"args":[]},"hydrogen:preview":{"id":"hydrogen:preview","description":"Runs a Hydrogen storefront in an Oxygen worker for production.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"port":{"name":"port","type":"option","description":"Port to run the server on.","multiple":false,"default":3000}},"args":[]},"hydrogen:shortcut":{"id":"hydrogen:shortcut","description":"Creates a global `h2` shortcut for the Hydrogen CLI","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{},"args":[]},"hydrogen:unlink":{"id":"hydrogen:unlink","description":"Unlink a local project from a Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[]},"hydrogen:env:list":{"id":"hydrogen:env:list","description":"List the environments on your linked Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false}},"args":[]},"hydrogen:env:pull":{"id":"hydrogen:env:pull","description":"Populate your .env with variables from your Hydrogen storefront.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"env-branch":{"name":"env-branch","type":"option","char":"e","description":"Specify an environment's branch name when using remote environment variables.","multiple":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false},"shop":{"name":"shop","type":"option","char":"s","description":"Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).","multiple":false},"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false}},"args":[]},"hydrogen:generate:route":{"id":"hydrogen:generate:route","description":"Generates a standard Shopify route.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"adapter":{"name":"adapter","type":"option","description":"Remix adapter used in the route. The default is `@shopify/remix-oxygen`.","multiple":false},"typescript":{"name":"typescript","type":"boolean","description":"Generate TypeScript files","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[{"name":"route","description":"The route to generate. One of home,page,cart,products,collections,policies,robots,sitemap,account,all.","required":true,"options":["home","page","cart","products","collections","policies","robots","sitemap","account","all"]}]},"hydrogen:generate:routes":{"id":"hydrogen:generate:routes","description":"Generates all supported standard shopify routes.","strict":true,"pluginName":"@shopify/cli-hydrogen","pluginAlias":"@shopify/cli-hydrogen","pluginType":"core","aliases":[],"flags":{"adapter":{"name":"adapter","type":"option","description":"Remix adapter used in the route. The default is `@shopify/remix-oxygen`.","multiple":false},"typescript":{"name":"typescript","type":"boolean","description":"Generate TypeScript files","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the destination directory and files if they already exist.","allowNo":false},"path":{"name":"path","type":"option","description":"The path to the directory of the Hydrogen storefront. The default is the current directory.","multiple":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
|
-
"version": "5.0.
|
|
7
|
+
"version": "5.0.2",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@remix-run/react": "^1.17.1",
|
|
31
|
-
"@shopify/hydrogen-react": "^2023.4.
|
|
31
|
+
"@shopify/hydrogen-react": "^2023.4.5",
|
|
32
32
|
"@shopify/remix-oxygen": "^1.1.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|