@shopify/cli-hydrogen 5.2.2 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/hydrogen/build.js +49 -25
- package/dist/commands/hydrogen/deploy.js +171 -0
- package/dist/commands/hydrogen/deploy.test.js +185 -0
- package/dist/commands/hydrogen/dev.js +27 -14
- package/dist/commands/hydrogen/init.js +10 -6
- package/dist/commands/hydrogen/init.test.js +16 -1
- package/dist/commands/hydrogen/preview.js +27 -11
- package/dist/generator-templates/starter/app/root.tsx +6 -4
- package/dist/generator-templates/starter/app/routes/account.tsx +1 -1
- package/dist/generator-templates/starter/app/routes/cart.$lines.tsx +70 -0
- package/dist/generator-templates/starter/app/routes/cart.tsx +1 -1
- package/dist/generator-templates/starter/app/routes/discount.$code.tsx +43 -0
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +3 -1
- package/dist/generator-templates/starter/package.json +4 -4
- package/dist/generator-templates/starter/remix.env.d.ts +12 -3
- package/dist/generator-templates/starter/server.ts +22 -19
- package/dist/generator-templates/starter/tsconfig.json +1 -1
- package/dist/lib/bundle/analyzer.js +56 -0
- package/dist/lib/bundle/bundle-analyzer.html +2045 -0
- package/dist/lib/flags.js +4 -0
- package/dist/lib/get-oxygen-token.js +47 -0
- package/dist/lib/get-oxygen-token.test.js +104 -0
- package/dist/lib/graphql/admin/oxygen-token.js +21 -0
- package/dist/lib/live-reload.js +2 -1
- package/dist/lib/log.js +56 -13
- package/dist/lib/mini-oxygen/common.js +58 -0
- package/dist/lib/mini-oxygen/index.js +12 -0
- package/dist/lib/mini-oxygen/node.js +110 -0
- package/dist/lib/mini-oxygen/types.js +1 -0
- package/dist/lib/mini-oxygen/workerd-inspector.js +392 -0
- package/dist/lib/mini-oxygen/workerd.js +182 -0
- package/dist/lib/onboarding/common.js +24 -13
- package/dist/lib/onboarding/local.js +1 -1
- package/dist/lib/remix-config.js +12 -2
- package/dist/lib/remix-version-check.js +7 -4
- package/dist/lib/remix-version-check.test.js +1 -1
- package/dist/lib/render-errors.js +1 -1
- package/dist/lib/request-events.js +84 -0
- package/dist/lib/setups/routes/generate.js +3 -3
- package/dist/lib/transpile-ts.js +21 -23
- package/dist/lib/virtual-routes.js +11 -9
- package/dist/virtual-routes/components/FlameChartWrapper.jsx +125 -0
- package/dist/virtual-routes/routes/debug-network.jsx +289 -0
- package/dist/virtual-routes/routes/index.jsx +4 -4
- package/dist/virtual-routes/virtual-root.jsx +7 -4
- package/oclif.manifest.json +81 -3
- package/package.json +35 -12
- package/dist/lib/mini-oxygen.js +0 -108
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { FlameChartWrapper } from "../components/FlameChartWrapper.jsx";
|
|
4
|
+
import { Link } from "@remix-run/react";
|
|
5
|
+
import { Script } from "@shopify/hydrogen";
|
|
6
|
+
function DebugNetwork() {
|
|
7
|
+
const serverEvents = useRef({
|
|
8
|
+
smallestStartTime: 0,
|
|
9
|
+
mainRequests: [],
|
|
10
|
+
subRequests: {},
|
|
11
|
+
showPutRequests: false
|
|
12
|
+
});
|
|
13
|
+
const [timestamp, setTimestamp] = useState();
|
|
14
|
+
function serverEventHandler(onEvent) {
|
|
15
|
+
return (event) => {
|
|
16
|
+
const data = JSON.parse(event.data);
|
|
17
|
+
if (serverEvents.current.smallestStartTime === 0) {
|
|
18
|
+
serverEvents.current.smallestStartTime = data.startTime;
|
|
19
|
+
} else {
|
|
20
|
+
serverEvents.current.smallestStartTime = Math.min(
|
|
21
|
+
data.startTime,
|
|
22
|
+
serverEvents.current.smallestStartTime
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
onEvent(data);
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
setTimestamp((/* @__PURE__ */ new Date()).getTime());
|
|
28
|
+
}, 0);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const evtSource = new EventSource("/debug-network-server", {
|
|
33
|
+
withCredentials: true
|
|
34
|
+
});
|
|
35
|
+
const mainRequestHandler = serverEventHandler((data) => {
|
|
36
|
+
serverEvents.current.mainRequests = [
|
|
37
|
+
...serverEvents.current.mainRequests,
|
|
38
|
+
{
|
|
39
|
+
...data,
|
|
40
|
+
url: data.url.replace(location.origin, "")
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
});
|
|
44
|
+
evtSource.addEventListener("Request", mainRequestHandler);
|
|
45
|
+
const subRequestHandler = serverEventHandler((data) => {
|
|
46
|
+
let groupEvents = serverEvents.current.subRequests[data.id] || [];
|
|
47
|
+
groupEvents = [...groupEvents, data];
|
|
48
|
+
serverEvents.current.subRequests = {
|
|
49
|
+
...serverEvents.current.subRequests,
|
|
50
|
+
[data.id]: groupEvents
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
evtSource.addEventListener("Sub request", subRequestHandler);
|
|
54
|
+
return () => {
|
|
55
|
+
evtSource.removeEventListener("Request", mainRequestHandler);
|
|
56
|
+
evtSource.removeEventListener("Sub request", subRequestHandler);
|
|
57
|
+
evtSource.close();
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
Script,
|
|
63
|
+
{
|
|
64
|
+
src: "https://unpkg.com/flame-chart-js@2.3.1/dist/index.min.js",
|
|
65
|
+
suppressHydrationWarning: true
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ jsxs(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
style: {
|
|
72
|
+
width: "100vw",
|
|
73
|
+
backgroundColor: "#F5F5F5",
|
|
74
|
+
fontSize: "0.8rem"
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsxs(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
style: {
|
|
81
|
+
display: "flex",
|
|
82
|
+
justifyContent: "space-between"
|
|
83
|
+
},
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsxs(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
style: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
alignItems: "center"
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx(
|
|
94
|
+
"button",
|
|
95
|
+
{
|
|
96
|
+
onClick: () => {
|
|
97
|
+
fetch("/debug-network-server", { method: "DELETE" }).catch(
|
|
98
|
+
(error) => console.error("Could not clear history:", error)
|
|
99
|
+
);
|
|
100
|
+
serverEvents.current = {
|
|
101
|
+
smallestStartTime: 0,
|
|
102
|
+
mainRequests: [],
|
|
103
|
+
subRequests: {},
|
|
104
|
+
showPutRequests: serverEvents.current.showPutRequests
|
|
105
|
+
};
|
|
106
|
+
setTimestamp((/* @__PURE__ */ new Date()).getTime());
|
|
107
|
+
},
|
|
108
|
+
children: "Clear"
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
112
|
+
"input",
|
|
113
|
+
{
|
|
114
|
+
id: "showPutRequests",
|
|
115
|
+
type: "checkbox",
|
|
116
|
+
checked: serverEvents.current.showPutRequests,
|
|
117
|
+
onChange: (event) => {
|
|
118
|
+
serverEvents.current.showPutRequests = event.target.checked;
|
|
119
|
+
setTimestamp((/* @__PURE__ */ new Date()).getTime());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "showPutRequests", children: "Show cache update requests (PUT)" })
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
"p",
|
|
129
|
+
{
|
|
130
|
+
style: {
|
|
131
|
+
paddingRight: "5px"
|
|
132
|
+
},
|
|
133
|
+
children: "Unstable"
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsx(FlameChart, { serverEvents: serverEvents.current }, timestamp),
|
|
140
|
+
/* @__PURE__ */ jsxs("p", { style: { color: "#777", fontSize: "0.7rem", paddingLeft: "5px" }, children: [
|
|
141
|
+
"Note: You may need to turn on '",
|
|
142
|
+
/* @__PURE__ */ jsx("b", { children: "Disable Cache" }),
|
|
143
|
+
"' for your navigating window. If you are not seeing any requests, try re-running '",
|
|
144
|
+
/* @__PURE__ */ jsx("b", { children: "npm run dev" }),
|
|
145
|
+
"' in your terminal while leaving this window open."
|
|
146
|
+
] })
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
const PANEL_HEIGHT = 300;
|
|
153
|
+
function FlameChart({ serverEvents }) {
|
|
154
|
+
if (serverEvents.mainRequests.length === 0)
|
|
155
|
+
return /* @__PURE__ */ jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
style: {
|
|
159
|
+
height: `${PANEL_HEIGHT}px`,
|
|
160
|
+
display: "flex",
|
|
161
|
+
justifyContent: "center",
|
|
162
|
+
alignItems: "center",
|
|
163
|
+
backgroundColor: "#FAFAFA"
|
|
164
|
+
},
|
|
165
|
+
children: /* @__PURE__ */ jsxs("p", { style: { fontWeight: "bold", color: "#777" }, children: [
|
|
166
|
+
"Navigate your",
|
|
167
|
+
" ",
|
|
168
|
+
/* @__PURE__ */ jsx(Link, { to: "/", target: "_blank", children: "app" })
|
|
169
|
+
] })
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
let totalRequests = 0;
|
|
173
|
+
let totalSubRequests = 0;
|
|
174
|
+
const calcDuration = (time) => time - serverEvents.smallestStartTime;
|
|
175
|
+
let items = [];
|
|
176
|
+
serverEvents.mainRequests.forEach((mainRequest) => {
|
|
177
|
+
const mainResponseStart = calcDuration(mainRequest.endTime);
|
|
178
|
+
let mainResponseEnd = mainResponseStart;
|
|
179
|
+
const subRequestItems = [];
|
|
180
|
+
const subRequests = serverEvents.subRequests[mainRequest.id] || [];
|
|
181
|
+
subRequests.forEach((subRequest) => {
|
|
182
|
+
const subRequestEnd = calcDuration(subRequest.endTime);
|
|
183
|
+
if (subRequest.cacheStatus !== "PUT") {
|
|
184
|
+
mainResponseEnd = Math.max(mainResponseEnd, subRequestEnd);
|
|
185
|
+
}
|
|
186
|
+
const subRequestItem = {
|
|
187
|
+
name: `${subRequest.cacheStatus} ${subRequest.url}`.trim(),
|
|
188
|
+
intervals: "request",
|
|
189
|
+
timing: {
|
|
190
|
+
requestStart: calcDuration(subRequest.startTime),
|
|
191
|
+
requestEnd: subRequestEnd
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
if (serverEvents.showPutRequests) {
|
|
195
|
+
subRequestItems.push(subRequestItem);
|
|
196
|
+
} else {
|
|
197
|
+
subRequest.cacheStatus !== "PUT" && subRequestItems.push(subRequestItem);
|
|
198
|
+
}
|
|
199
|
+
totalSubRequests++;
|
|
200
|
+
});
|
|
201
|
+
totalRequests++;
|
|
202
|
+
items.push({
|
|
203
|
+
name: mainRequest.url,
|
|
204
|
+
intervals: "mainRequest",
|
|
205
|
+
timing: {
|
|
206
|
+
requestStart: calcDuration(mainRequest.startTime),
|
|
207
|
+
responseStart: mainResponseStart,
|
|
208
|
+
responseEnd: mainResponseEnd
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
items = items.concat(subRequestItems);
|
|
212
|
+
});
|
|
213
|
+
const data = {
|
|
214
|
+
items,
|
|
215
|
+
intervals: {
|
|
216
|
+
mainRequest: [
|
|
217
|
+
{
|
|
218
|
+
name: "server",
|
|
219
|
+
color: "#99CC00",
|
|
220
|
+
type: "block",
|
|
221
|
+
start: "requestStart",
|
|
222
|
+
end: "responseStart"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "streaming",
|
|
226
|
+
color: "#33CCFF",
|
|
227
|
+
type: "block",
|
|
228
|
+
start: "responseStart",
|
|
229
|
+
end: "responseEnd"
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
request: [
|
|
233
|
+
{
|
|
234
|
+
name: "request",
|
|
235
|
+
color: "#FFCC00",
|
|
236
|
+
type: "block",
|
|
237
|
+
start: "requestStart",
|
|
238
|
+
end: "requestEnd"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
244
|
+
/* @__PURE__ */ jsx(
|
|
245
|
+
FlameChartWrapper,
|
|
246
|
+
{
|
|
247
|
+
height: PANEL_HEIGHT,
|
|
248
|
+
waterfall: data,
|
|
249
|
+
settings: {
|
|
250
|
+
styles: {
|
|
251
|
+
waterfallPlugin: {
|
|
252
|
+
defaultHeight: PANEL_HEIGHT
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
/* @__PURE__ */ jsxs(
|
|
259
|
+
"div",
|
|
260
|
+
{
|
|
261
|
+
style: {
|
|
262
|
+
display: "flex",
|
|
263
|
+
padding: "5px",
|
|
264
|
+
borderTop: "1px solid #CCC",
|
|
265
|
+
borderBottom: "1px solid #CCC"
|
|
266
|
+
},
|
|
267
|
+
children: [
|
|
268
|
+
totalRequests,
|
|
269
|
+
" requests",
|
|
270
|
+
/* @__PURE__ */ jsx(
|
|
271
|
+
"span",
|
|
272
|
+
{
|
|
273
|
+
style: {
|
|
274
|
+
paddingLeft: "2px",
|
|
275
|
+
paddingRight: "2px"
|
|
276
|
+
},
|
|
277
|
+
children: "|"
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
totalSubRequests,
|
|
281
|
+
" sub requests"
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] });
|
|
286
|
+
}
|
|
287
|
+
export {
|
|
288
|
+
DebugNetwork as default
|
|
289
|
+
};
|
|
@@ -66,8 +66,8 @@ function Index() {
|
|
|
66
66
|
"You\u2019re seeing this because you don\u2019t have a home route in your project yet. ",
|
|
67
67
|
/* @__PURE__ */ jsx("br", {}),
|
|
68
68
|
"Run ",
|
|
69
|
-
/* @__PURE__ */ jsx("code", { children: "h2
|
|
70
|
-
" to
|
|
69
|
+
/* @__PURE__ */ jsx("code", { children: "h2 setup" }),
|
|
70
|
+
" to scaffold standard Shopify routes. Learn more about",
|
|
71
71
|
` `,
|
|
72
72
|
/* @__PURE__ */ jsx(CreateRoutesLink, {})
|
|
73
73
|
] }) : /* @__PURE__ */ jsxs("p", { children: [
|
|
@@ -80,8 +80,8 @@ function Index() {
|
|
|
80
80
|
/* @__PURE__ */ jsx("code", { children: "h2 link && h2 env pull" }),
|
|
81
81
|
". Then, run",
|
|
82
82
|
" ",
|
|
83
|
-
/* @__PURE__ */ jsx("code", { children: "h2
|
|
84
|
-
" to
|
|
83
|
+
/* @__PURE__ */ jsx("code", { children: "h2 setup" }),
|
|
84
|
+
" to scaffold standard Shopify routes.",
|
|
85
85
|
/* @__PURE__ */ jsx("br", {}),
|
|
86
86
|
"Learn more about",
|
|
87
87
|
` `,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import styles from "./assets/styles.css";
|
|
12
12
|
import favicon from "./assets/favicon.svg";
|
|
13
13
|
import { Layout } from "./components/Layout.jsx";
|
|
14
|
+
import { useNonce } from "@shopify/hydrogen";
|
|
14
15
|
const links = () => {
|
|
15
16
|
return [
|
|
16
17
|
{ rel: "stylesheet", href: styles },
|
|
@@ -18,6 +19,7 @@ const links = () => {
|
|
|
18
19
|
];
|
|
19
20
|
};
|
|
20
21
|
function App() {
|
|
22
|
+
const nonce = useNonce();
|
|
21
23
|
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
22
24
|
/* @__PURE__ */ jsxs("head", { children: [
|
|
23
25
|
/* @__PURE__ */ jsx("meta", { charSet: "utf-8" }),
|
|
@@ -35,12 +37,13 @@ function App() {
|
|
|
35
37
|
] }),
|
|
36
38
|
/* @__PURE__ */ jsxs("body", { children: [
|
|
37
39
|
/* @__PURE__ */ jsx(Layout, { children: /* @__PURE__ */ jsx(Outlet, {}) }),
|
|
38
|
-
/* @__PURE__ */ jsx(ScrollRestoration, {}),
|
|
39
|
-
/* @__PURE__ */ jsx(Scripts, {})
|
|
40
|
+
/* @__PURE__ */ jsx(ScrollRestoration, { nonce }),
|
|
41
|
+
/* @__PURE__ */ jsx(Scripts, { nonce })
|
|
40
42
|
] })
|
|
41
43
|
] });
|
|
42
44
|
}
|
|
43
45
|
function ErrorBoundary() {
|
|
46
|
+
const nonce = useNonce();
|
|
44
47
|
const error = useRouteError();
|
|
45
48
|
let errorMessage = "Unknown error";
|
|
46
49
|
let errorStatus = 500;
|
|
@@ -71,8 +74,8 @@ function ErrorBoundary() {
|
|
|
71
74
|
/* @__PURE__ */ jsx("h2", { children: errorStatus }),
|
|
72
75
|
errorMessage && /* @__PURE__ */ jsx("fieldset", { children: /* @__PURE__ */ jsx("pre", { children: errorMessage }) })
|
|
73
76
|
] }) }),
|
|
74
|
-
/* @__PURE__ */ jsx(ScrollRestoration, {}),
|
|
75
|
-
/* @__PURE__ */ jsx(Scripts, {})
|
|
77
|
+
/* @__PURE__ */ jsx(ScrollRestoration, { nonce }),
|
|
78
|
+
/* @__PURE__ */ jsx(Scripts, { nonce })
|
|
76
79
|
] })
|
|
77
80
|
] });
|
|
78
81
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.3.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"hydrogen:build": {
|
|
5
5
|
"id": "hydrogen:build",
|
|
@@ -20,7 +20,13 @@
|
|
|
20
20
|
"name": "sourcemap",
|
|
21
21
|
"type": "boolean",
|
|
22
22
|
"description": "Generate sourcemaps for the build.",
|
|
23
|
-
"allowNo":
|
|
23
|
+
"allowNo": true
|
|
24
|
+
},
|
|
25
|
+
"bundle-stats": {
|
|
26
|
+
"name": "bundle-stats",
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Show a bundle size summary after building.",
|
|
29
|
+
"allowNo": true
|
|
24
30
|
},
|
|
25
31
|
"disable-route-warning": {
|
|
26
32
|
"name": "disable-route-warning",
|
|
@@ -132,6 +138,59 @@
|
|
|
132
138
|
},
|
|
133
139
|
"args": {}
|
|
134
140
|
},
|
|
141
|
+
"hydrogen:deploy": {
|
|
142
|
+
"id": "hydrogen:deploy",
|
|
143
|
+
"strict": true,
|
|
144
|
+
"pluginName": "@shopify/cli-hydrogen",
|
|
145
|
+
"pluginAlias": "@shopify/cli-hydrogen",
|
|
146
|
+
"pluginType": "core",
|
|
147
|
+
"hidden": true,
|
|
148
|
+
"aliases": [],
|
|
149
|
+
"flags": {
|
|
150
|
+
"path": {
|
|
151
|
+
"name": "path",
|
|
152
|
+
"type": "option",
|
|
153
|
+
"description": "The path to the directory of the Hydrogen storefront. The default is the current directory.",
|
|
154
|
+
"multiple": false
|
|
155
|
+
},
|
|
156
|
+
"shop": {
|
|
157
|
+
"name": "shop",
|
|
158
|
+
"type": "option",
|
|
159
|
+
"char": "s",
|
|
160
|
+
"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).",
|
|
161
|
+
"multiple": false
|
|
162
|
+
},
|
|
163
|
+
"publicDeployment": {
|
|
164
|
+
"name": "publicDeployment",
|
|
165
|
+
"type": "boolean",
|
|
166
|
+
"description": "Marks a preview deployment as publicly accessible.",
|
|
167
|
+
"required": false,
|
|
168
|
+
"allowNo": false
|
|
169
|
+
},
|
|
170
|
+
"metadataUrl": {
|
|
171
|
+
"name": "metadataUrl",
|
|
172
|
+
"type": "option",
|
|
173
|
+
"description": "URL that links to the deployment. Will be saved and displayed in the Shopify admin",
|
|
174
|
+
"required": false,
|
|
175
|
+
"multiple": false
|
|
176
|
+
},
|
|
177
|
+
"metadataUser": {
|
|
178
|
+
"name": "metadataUser",
|
|
179
|
+
"type": "option",
|
|
180
|
+
"description": "User that initiated the deployment. Will be saved and displayed in the Shopify admin",
|
|
181
|
+
"required": false,
|
|
182
|
+
"multiple": false
|
|
183
|
+
},
|
|
184
|
+
"metadataVersion": {
|
|
185
|
+
"name": "metadataVersion",
|
|
186
|
+
"type": "option",
|
|
187
|
+
"description": "A version identifier for the deployment. Will be saved and displayed in the Shopify admin",
|
|
188
|
+
"required": false,
|
|
189
|
+
"multiple": false
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"args": {}
|
|
193
|
+
},
|
|
135
194
|
"hydrogen:dev": {
|
|
136
195
|
"id": "hydrogen:dev",
|
|
137
196
|
"description": "Runs Hydrogen storefront in an Oxygen worker for development.",
|
|
@@ -154,6 +213,12 @@
|
|
|
154
213
|
"multiple": false,
|
|
155
214
|
"default": 3000
|
|
156
215
|
},
|
|
216
|
+
"worker-unstable": {
|
|
217
|
+
"name": "worker-unstable",
|
|
218
|
+
"type": "boolean",
|
|
219
|
+
"description": "Run the app in a worker environment closer to Oxygen production instead of a Node.js sandbox. This flag is unstable and may change without notice.",
|
|
220
|
+
"allowNo": false
|
|
221
|
+
},
|
|
157
222
|
"codegen-unstable": {
|
|
158
223
|
"name": "codegen-unstable",
|
|
159
224
|
"type": "boolean",
|
|
@@ -286,7 +351,7 @@
|
|
|
286
351
|
"type": "boolean",
|
|
287
352
|
"description": "Generate routes for all pages.",
|
|
288
353
|
"hidden": true,
|
|
289
|
-
"allowNo":
|
|
354
|
+
"allowNo": true
|
|
290
355
|
},
|
|
291
356
|
"git": {
|
|
292
357
|
"name": "git",
|
|
@@ -410,6 +475,19 @@
|
|
|
410
475
|
"description": "Port to run the server on.",
|
|
411
476
|
"multiple": false,
|
|
412
477
|
"default": 3000
|
|
478
|
+
},
|
|
479
|
+
"worker-unstable": {
|
|
480
|
+
"name": "worker-unstable",
|
|
481
|
+
"type": "boolean",
|
|
482
|
+
"description": "Run the app in a worker environment closer to Oxygen production instead of a Node.js sandbox. This flag is unstable and may change without notice.",
|
|
483
|
+
"allowNo": false
|
|
484
|
+
},
|
|
485
|
+
"env-branch": {
|
|
486
|
+
"name": "env-branch",
|
|
487
|
+
"type": "option",
|
|
488
|
+
"char": "e",
|
|
489
|
+
"description": "Specify an environment's branch name when using remote environment variables.",
|
|
490
|
+
"multiple": false
|
|
413
491
|
}
|
|
414
492
|
},
|
|
415
493
|
"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.
|
|
7
|
+
"version": "5.3.0",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
@@ -21,34 +21,57 @@
|
|
|
21
21
|
"@types/gunzip-maybe": "^1.4.0",
|
|
22
22
|
"@types/prettier": "^2.7.2",
|
|
23
23
|
"@types/recursive-readdir": "^2.2.1",
|
|
24
|
+
"@types/stack-trace": "^0.0.30",
|
|
24
25
|
"@types/tar-fs": "^2.0.1",
|
|
26
|
+
"devtools-protocol": "^0.0.1177611",
|
|
27
|
+
"get-port": "^7.0.0",
|
|
25
28
|
"@vitest/coverage-v8": "^0.33.0",
|
|
29
|
+
"fast-glob": "^3.2.12",
|
|
30
|
+
"flame-chart-js": "2.3.1",
|
|
26
31
|
"type-fest": "^3.6.0",
|
|
27
32
|
"vitest": "^0.33.0"
|
|
28
33
|
},
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"@remix-run/react": "1.19.1",
|
|
31
|
-
"@shopify/hydrogen-react": "^2023.7.4",
|
|
32
|
-
"@shopify/remix-oxygen": "^1.1.3"
|
|
33
|
-
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@ast-grep/napi": "0.11.0",
|
|
36
36
|
"@graphql-codegen/cli": "3.3.1",
|
|
37
|
-
"@oclif/core": "2.
|
|
38
|
-
"@
|
|
39
|
-
"@shopify/cli-kit": "3.48.0",
|
|
37
|
+
"@oclif/core": "2.11.7",
|
|
38
|
+
"@shopify/cli-kit": "3.49.2",
|
|
40
39
|
"@shopify/hydrogen-codegen": "^0.0.2",
|
|
41
40
|
"@shopify/mini-oxygen": "^2.2.1",
|
|
41
|
+
"@shopify/oxygen-cli": "^1.12.0",
|
|
42
42
|
"ansi-escapes": "^6.2.0",
|
|
43
43
|
"diff": "^5.1.0",
|
|
44
|
-
"fast-glob": "^3.2.12",
|
|
45
44
|
"fs-extra": "^11.1.0",
|
|
46
45
|
"get-port": "^7.0.0",
|
|
47
46
|
"gunzip-maybe": "^1.4.2",
|
|
47
|
+
"miniflare": "3.20230918.0",
|
|
48
48
|
"prettier": "^2.8.4",
|
|
49
|
-
"
|
|
49
|
+
"source-map": "^0.7.4",
|
|
50
|
+
"stack-trace": "^1.0.0-pre2",
|
|
50
51
|
"tar-fs": "^2.1.1",
|
|
51
|
-
"typescript": "^5.2.2"
|
|
52
|
+
"typescript": "^5.2.2",
|
|
53
|
+
"use-resize-observer": "^9.1.0",
|
|
54
|
+
"ws": "^8.13.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@remix-run/dev": "1.19.1",
|
|
58
|
+
"@remix-run/react": "1.19.1",
|
|
59
|
+
"@shopify/hydrogen-react": "^2023.7.4",
|
|
60
|
+
"@shopify/remix-oxygen": "^1.1.4"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@remix-run/dev": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"@remix-run/react": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"@shopify/hydrogen-react": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"@shopify/remix-oxygen": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
52
75
|
},
|
|
53
76
|
"bin": "dist/create-app.js",
|
|
54
77
|
"exports": {
|
package/dist/lib/mini-oxygen.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { outputToken, outputInfo, outputContent } from '@shopify/cli-kit/node/output';
|
|
2
|
-
import { resolvePath } from '@shopify/cli-kit/node/path';
|
|
3
|
-
import { readFile, fileExists } from '@shopify/cli-kit/node/fs';
|
|
4
|
-
import colors from '@shopify/cli-kit/node/colors';
|
|
5
|
-
import { renderSuccess } from '@shopify/cli-kit/node/ui';
|
|
6
|
-
import { startServer } from '@shopify/mini-oxygen';
|
|
7
|
-
import { DEFAULT_PORT } from './flags.js';
|
|
8
|
-
|
|
9
|
-
async function startMiniOxygen({
|
|
10
|
-
root,
|
|
11
|
-
port = DEFAULT_PORT,
|
|
12
|
-
watch = false,
|
|
13
|
-
autoReload = watch,
|
|
14
|
-
buildPathWorkerFile,
|
|
15
|
-
buildPathClient,
|
|
16
|
-
env
|
|
17
|
-
}) {
|
|
18
|
-
const dotenvPath = resolvePath(root, ".env");
|
|
19
|
-
const miniOxygen = await startServer({
|
|
20
|
-
script: await readFile(buildPathWorkerFile),
|
|
21
|
-
workerFile: buildPathWorkerFile,
|
|
22
|
-
assetsDir: buildPathClient,
|
|
23
|
-
publicPath: "",
|
|
24
|
-
port,
|
|
25
|
-
watch,
|
|
26
|
-
autoReload,
|
|
27
|
-
modules: true,
|
|
28
|
-
env: {
|
|
29
|
-
...env,
|
|
30
|
-
...process.env
|
|
31
|
-
},
|
|
32
|
-
envPath: !env && await fileExists(dotenvPath) ? dotenvPath : void 0,
|
|
33
|
-
log: () => {
|
|
34
|
-
},
|
|
35
|
-
onResponse: (request, response) => (
|
|
36
|
-
// 'Request' and 'Response' types in MiniOxygen comes from
|
|
37
|
-
// Miniflare and are slightly different from standard types.
|
|
38
|
-
logResponse(
|
|
39
|
-
request,
|
|
40
|
-
response
|
|
41
|
-
)
|
|
42
|
-
)
|
|
43
|
-
});
|
|
44
|
-
const listeningAt = `http://localhost:${miniOxygen.port}`;
|
|
45
|
-
return {
|
|
46
|
-
listeningAt,
|
|
47
|
-
port: miniOxygen.port,
|
|
48
|
-
async reload(options = {}) {
|
|
49
|
-
const nextOptions = {};
|
|
50
|
-
if (options.env) {
|
|
51
|
-
nextOptions.env = {
|
|
52
|
-
...options.env,
|
|
53
|
-
...process.env
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (options.worker) {
|
|
57
|
-
nextOptions.script = await readFile(buildPathWorkerFile);
|
|
58
|
-
}
|
|
59
|
-
return miniOxygen.reload(nextOptions);
|
|
60
|
-
},
|
|
61
|
-
showBanner(options) {
|
|
62
|
-
console.log("");
|
|
63
|
-
renderSuccess({
|
|
64
|
-
headline: `${options?.headlinePrefix ?? ""}MiniOxygen ${options?.mode ?? "development"} server running.`,
|
|
65
|
-
body: [
|
|
66
|
-
`View ${options?.appName ?? "Hydrogen"} app: ${listeningAt}`,
|
|
67
|
-
...options?.extraLines ?? []
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
console.log("");
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function logResponse(request, response) {
|
|
75
|
-
try {
|
|
76
|
-
const url = new URL(request.url);
|
|
77
|
-
if (["/graphiql"].includes(url.pathname)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const isProxy = !!response.url && response.url !== request.url;
|
|
81
|
-
const isDataRequest = !isProxy && url.searchParams.has("_data");
|
|
82
|
-
let route = request.url.replace(url.origin, "");
|
|
83
|
-
let info = "";
|
|
84
|
-
let type = "render";
|
|
85
|
-
if (isProxy) {
|
|
86
|
-
type = "proxy";
|
|
87
|
-
info = `[${response.url}]`;
|
|
88
|
-
}
|
|
89
|
-
if (isDataRequest) {
|
|
90
|
-
type = request.method === "GET" ? "loader" : "action";
|
|
91
|
-
const dataParam = url.searchParams.get("_data")?.replace("routes/", "");
|
|
92
|
-
route = url.pathname;
|
|
93
|
-
info = `[${dataParam}]`;
|
|
94
|
-
}
|
|
95
|
-
const colorizeStatus = response.status < 300 ? outputToken.green : response.status < 400 ? outputToken.cyan : outputToken.errorText;
|
|
96
|
-
outputInfo(
|
|
97
|
-
outputContent`${request.method.padStart(6)} ${colorizeStatus(
|
|
98
|
-
String(response.status)
|
|
99
|
-
)} ${outputToken.italic(type.padEnd(7, " "))} ${route}${info ? " " + colors.dim(info) : ""} ${request.headers.get("purpose") === "prefetch" ? outputToken.italic("(prefetch)") : ""}`
|
|
100
|
-
);
|
|
101
|
-
} catch {
|
|
102
|
-
if (request && response) {
|
|
103
|
-
outputInfo(`${request.method} ${response.status} ${request.url}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { logResponse, startMiniOxygen };
|