@shopify/cli-hydrogen 12.0.0 → 12.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.
- package/README.md +1 -1
- package/dist/assets/hydrogen/routes/locale-check.ts +3 -3
- package/dist/assets/hydrogen/starter/.graphqlrc.ts +4 -2
- package/dist/assets/hydrogen/starter/CHANGELOG.md +271 -0
- package/dist/assets/hydrogen/starter/app/components/Aside.tsx +4 -2
- package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +67 -38
- package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +49 -8
- package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +133 -57
- package/dist/assets/hydrogen/starter/app/components/Header.tsx +3 -3
- package/dist/assets/hydrogen/starter/app/components/MockShopNotice.tsx +20 -0
- package/dist/assets/hydrogen/starter/app/components/PaginatedResourceSection.tsx +24 -4
- package/dist/assets/hydrogen/starter/app/components/ProductPrice.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/entry.client.tsx +2 -3
- package/dist/assets/hydrogen/starter/app/lib/context.ts +5 -0
- package/dist/assets/hydrogen/starter/app/lib/fragments.ts +8 -0
- package/dist/assets/hydrogen/starter/app/routes/[robots.txt].tsx +14 -53
- package/dist/assets/hydrogen/starter/app/routes/_index.tsx +15 -9
- package/dist/assets/hydrogen/starter/app/routes/account.$.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/account.addresses.tsx +14 -14
- package/dist/assets/hydrogen/starter/app/routes/account.profile.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/account.tsx +4 -7
- package/dist/assets/hydrogen/starter/app/routes/account_.login.tsx +10 -0
- package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle._index.tsx +2 -9
- package/dist/assets/hydrogen/starter/app/routes/blogs._index.tsx +1 -4
- package/dist/assets/hydrogen/starter/app/routes/cart.tsx +3 -11
- package/dist/assets/hydrogen/starter/app/routes/collections.all.tsx +1 -3
- package/dist/assets/hydrogen/starter/app/routes/pages.$handle.tsx +2 -8
- package/dist/assets/hydrogen/starter/app/routes/policies.$handle.tsx +1 -4
- package/dist/assets/hydrogen/starter/app/routes/policies._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +2 -9
- package/dist/assets/hydrogen/starter/app/routes/search.tsx +18 -12
- package/dist/assets/hydrogen/starter/app/styles/app.css +72 -1
- package/dist/assets/hydrogen/starter/eslint.config.js +1 -0
- package/dist/assets/hydrogen/starter/guides/predictiveSearch/predictiveSearch.md +3 -3
- package/dist/assets/hydrogen/starter/guides/search/search.md +1 -1
- package/dist/assets/hydrogen/starter/package.json +16 -16
- package/dist/assets/hydrogen/starter/server.ts +5 -7
- package/dist/assets/hydrogen/starter/storefrontapi.generated.d.ts +89 -11
- package/dist/assets/hydrogen/starter/vite.config.ts +10 -4
- package/dist/assets/hydrogen/vite/package.json +1 -2
- package/dist/assets/hydrogen/vite/vite.config.js +4 -3
- package/dist/commands/hydrogen/deploy.js +19 -13
- package/dist/commands/hydrogen/dev.js +6 -6
- package/dist/commands/hydrogen/generate/route.js +1 -1
- package/dist/commands/hydrogen/init.d.ts +2 -4
- package/dist/commands/hydrogen/init.js +2 -8
- package/dist/commands/hydrogen/preview.js +1 -1
- package/dist/commands/hydrogen/setup/css.js +1 -1
- package/dist/commands/hydrogen/setup/markets.js +1 -1
- package/dist/commands/hydrogen/setup/vite.js +1 -1
- package/dist/commands/hydrogen/setup.js +31 -33
- package/dist/commands/hydrogen/upgrade.js +173 -39
- package/dist/lib/build.js +4 -5
- package/dist/lib/bundle/vite-plugin.js +7 -21
- package/dist/lib/check-lockfile.js +16 -7
- package/dist/lib/codegen.js +2 -2
- package/dist/lib/format-code.js +3 -3
- package/dist/lib/graphql/admin/client.js +48 -23
- package/dist/lib/mini-oxygen/workerd.js +3 -5
- package/dist/lib/onboarding/common.js +21 -26
- package/dist/lib/onboarding/local.js +46 -59
- package/dist/lib/package-managers.js +2 -0
- package/dist/lib/patch-cli.js +198 -0
- package/dist/lib/setups/routes/generate.js +5 -3
- package/dist/lib/template-pack.js +93 -0
- package/dist/lib/transpile/morph/functions.js +1 -1
- package/dist/lib/transpile/morph/typedefs.js +2 -3
- package/dist/lib/upgrade-e2e-utils.js +50 -0
- package/oclif.manifest.json +7 -15
- package/package.json +22 -19
- package/dist/assets/hydrogen/starter/app/routes/api.$version.[graphql.json].tsx +0 -14
- package/dist/lib/react-router-version-check.js +0 -82
|
@@ -36,6 +36,9 @@ export type CartLineFragment = Pick<
|
|
|
36
36
|
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
|
|
37
37
|
>;
|
|
38
38
|
};
|
|
39
|
+
parentRelationship?: StorefrontAPI.Maybe<{
|
|
40
|
+
parent: Pick<StorefrontAPI.CartLine, 'id'>;
|
|
41
|
+
}>;
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
export type CartLineComponentFragment = Pick<
|
|
@@ -66,6 +69,46 @@ export type CartLineComponentFragment = Pick<
|
|
|
66
69
|
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
|
|
67
70
|
>;
|
|
68
71
|
};
|
|
72
|
+
lineComponents: Array<
|
|
73
|
+
Pick<StorefrontAPI.CartLine, 'id' | 'quantity'> & {
|
|
74
|
+
attributes: Array<Pick<StorefrontAPI.Attribute, 'key' | 'value'>>;
|
|
75
|
+
cost: {
|
|
76
|
+
totalAmount: Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>;
|
|
77
|
+
amountPerQuantity: Pick<
|
|
78
|
+
StorefrontAPI.MoneyV2,
|
|
79
|
+
'currencyCode' | 'amount'
|
|
80
|
+
>;
|
|
81
|
+
compareAtAmountPerQuantity?: StorefrontAPI.Maybe<
|
|
82
|
+
Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>
|
|
83
|
+
>;
|
|
84
|
+
};
|
|
85
|
+
merchandise: Pick<
|
|
86
|
+
StorefrontAPI.ProductVariant,
|
|
87
|
+
'id' | 'availableForSale' | 'requiresShipping' | 'title'
|
|
88
|
+
> & {
|
|
89
|
+
compareAtPrice?: StorefrontAPI.Maybe<
|
|
90
|
+
Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>
|
|
91
|
+
>;
|
|
92
|
+
price: Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>;
|
|
93
|
+
image?: StorefrontAPI.Maybe<
|
|
94
|
+
Pick<
|
|
95
|
+
StorefrontAPI.Image,
|
|
96
|
+
'id' | 'url' | 'altText' | 'width' | 'height'
|
|
97
|
+
>
|
|
98
|
+
>;
|
|
99
|
+
product: Pick<
|
|
100
|
+
StorefrontAPI.Product,
|
|
101
|
+
'handle' | 'title' | 'id' | 'vendor'
|
|
102
|
+
>;
|
|
103
|
+
selectedOptions: Array<
|
|
104
|
+
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
|
|
105
|
+
>;
|
|
106
|
+
};
|
|
107
|
+
parentRelationship?: StorefrontAPI.Maybe<{
|
|
108
|
+
parent: Pick<StorefrontAPI.CartLine, 'id'>;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
>;
|
|
69
112
|
};
|
|
70
113
|
|
|
71
114
|
export type CartApiQueryFragment = Pick<
|
|
@@ -124,6 +167,9 @@ export type CartApiQueryFragment = Pick<
|
|
|
124
167
|
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
|
|
125
168
|
>;
|
|
126
169
|
};
|
|
170
|
+
parentRelationship?: StorefrontAPI.Maybe<{
|
|
171
|
+
parent: Pick<StorefrontAPI.CartLine, 'id'>;
|
|
172
|
+
}>;
|
|
127
173
|
})
|
|
128
174
|
| (Pick<StorefrontAPI.ComponentizableCartLine, 'id' | 'quantity'> & {
|
|
129
175
|
attributes: Array<Pick<StorefrontAPI.Attribute, 'key' | 'value'>>;
|
|
@@ -159,6 +205,49 @@ export type CartApiQueryFragment = Pick<
|
|
|
159
205
|
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
|
|
160
206
|
>;
|
|
161
207
|
};
|
|
208
|
+
lineComponents: Array<
|
|
209
|
+
Pick<StorefrontAPI.CartLine, 'id' | 'quantity'> & {
|
|
210
|
+
attributes: Array<Pick<StorefrontAPI.Attribute, 'key' | 'value'>>;
|
|
211
|
+
cost: {
|
|
212
|
+
totalAmount: Pick<
|
|
213
|
+
StorefrontAPI.MoneyV2,
|
|
214
|
+
'currencyCode' | 'amount'
|
|
215
|
+
>;
|
|
216
|
+
amountPerQuantity: Pick<
|
|
217
|
+
StorefrontAPI.MoneyV2,
|
|
218
|
+
'currencyCode' | 'amount'
|
|
219
|
+
>;
|
|
220
|
+
compareAtAmountPerQuantity?: StorefrontAPI.Maybe<
|
|
221
|
+
Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>
|
|
222
|
+
>;
|
|
223
|
+
};
|
|
224
|
+
merchandise: Pick<
|
|
225
|
+
StorefrontAPI.ProductVariant,
|
|
226
|
+
'id' | 'availableForSale' | 'requiresShipping' | 'title'
|
|
227
|
+
> & {
|
|
228
|
+
compareAtPrice?: StorefrontAPI.Maybe<
|
|
229
|
+
Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>
|
|
230
|
+
>;
|
|
231
|
+
price: Pick<StorefrontAPI.MoneyV2, 'currencyCode' | 'amount'>;
|
|
232
|
+
image?: StorefrontAPI.Maybe<
|
|
233
|
+
Pick<
|
|
234
|
+
StorefrontAPI.Image,
|
|
235
|
+
'id' | 'url' | 'altText' | 'width' | 'height'
|
|
236
|
+
>
|
|
237
|
+
>;
|
|
238
|
+
product: Pick<
|
|
239
|
+
StorefrontAPI.Product,
|
|
240
|
+
'handle' | 'title' | 'id' | 'vendor'
|
|
241
|
+
>;
|
|
242
|
+
selectedOptions: Array<
|
|
243
|
+
Pick<StorefrontAPI.SelectedOption, 'name' | 'value'>
|
|
244
|
+
>;
|
|
245
|
+
};
|
|
246
|
+
parentRelationship?: StorefrontAPI.Maybe<{
|
|
247
|
+
parent: Pick<StorefrontAPI.CartLine, 'id'>;
|
|
248
|
+
}>;
|
|
249
|
+
}
|
|
250
|
+
>;
|
|
162
251
|
})
|
|
163
252
|
>;
|
|
164
253
|
};
|
|
@@ -288,13 +377,6 @@ export type FooterQuery = {
|
|
|
288
377
|
>;
|
|
289
378
|
};
|
|
290
379
|
|
|
291
|
-
export type StoreRobotsQueryVariables = StorefrontAPI.Exact<{
|
|
292
|
-
country?: StorefrontAPI.InputMaybe<StorefrontAPI.CountryCode>;
|
|
293
|
-
language?: StorefrontAPI.InputMaybe<StorefrontAPI.LanguageCode>;
|
|
294
|
-
}>;
|
|
295
|
-
|
|
296
|
-
export type StoreRobotsQuery = {shop: Pick<StorefrontAPI.Shop, 'id'>};
|
|
297
|
-
|
|
298
380
|
export type FeaturedCollectionFragment = Pick<
|
|
299
381
|
StorefrontAPI.Collection,
|
|
300
382
|
'id' | 'title' | 'handle'
|
|
@@ -1194,10 +1276,6 @@ interface GeneratedQueryTypes {
|
|
|
1194
1276
|
return: FooterQuery;
|
|
1195
1277
|
variables: FooterQueryVariables;
|
|
1196
1278
|
};
|
|
1197
|
-
'#graphql\n query StoreRobots($country: CountryCode, $language: LanguageCode)\n @inContext(country: $country, language: $language) {\n shop {\n id\n }\n }\n': {
|
|
1198
|
-
return: StoreRobotsQuery;
|
|
1199
|
-
variables: StoreRobotsQueryVariables;
|
|
1200
|
-
};
|
|
1201
1279
|
'#graphql\n fragment FeaturedCollection on Collection {\n id\n title\n image {\n id\n url\n altText\n width\n height\n }\n handle\n }\n query FeaturedCollection($country: CountryCode, $language: LanguageCode)\n @inContext(country: $country, language: $language) {\n collections(first: 1, sortKey: UPDATED_AT, reverse: true) {\n nodes {\n ...FeaturedCollection\n }\n }\n }\n': {
|
|
1202
1280
|
return: FeaturedCollectionQuery;
|
|
1203
1281
|
variables: FeaturedCollectionQueryVariables;
|
|
@@ -2,13 +2,15 @@ import {defineConfig} from 'vite';
|
|
|
2
2
|
import {hydrogen} from '@shopify/hydrogen/vite';
|
|
3
3
|
import {oxygen} from '@shopify/mini-oxygen/vite';
|
|
4
4
|
import {reactRouter} from '@react-router/dev/vite';
|
|
5
|
-
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
6
5
|
|
|
7
6
|
export default defineConfig({
|
|
8
|
-
plugins: [hydrogen(), oxygen(), reactRouter()
|
|
7
|
+
plugins: [hydrogen(), oxygen(), reactRouter()],
|
|
8
|
+
resolve: {
|
|
9
|
+
tsconfigPaths: true,
|
|
10
|
+
},
|
|
9
11
|
build: {
|
|
10
12
|
// Allow a strict Content-Security-Policy
|
|
11
|
-
//
|
|
13
|
+
// without inlining assets as base64:
|
|
12
14
|
assetsInlineLimit: 0,
|
|
13
15
|
},
|
|
14
16
|
ssr: {
|
|
@@ -23,7 +25,11 @@ export default defineConfig({
|
|
|
23
25
|
* Include 'example-dep' in the array below.
|
|
24
26
|
* @see https://vitejs.dev/config/dep-optimization-options
|
|
25
27
|
*/
|
|
26
|
-
include: [
|
|
28
|
+
include: [
|
|
29
|
+
'react-router > set-cookie-parser',
|
|
30
|
+
'react-router > cookie',
|
|
31
|
+
'react-router',
|
|
32
|
+
],
|
|
27
33
|
},
|
|
28
34
|
},
|
|
29
35
|
server: {
|
|
@@ -2,9 +2,11 @@ import {defineConfig} from 'vite';
|
|
|
2
2
|
import {hydrogen} from '@shopify/hydrogen/vite';
|
|
3
3
|
import {oxygen} from '@shopify/mini-oxygen/vite';
|
|
4
4
|
import {vitePlugin as remix} from '@remix-run/dev';
|
|
5
|
-
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
6
5
|
|
|
7
6
|
export default defineConfig({
|
|
7
|
+
resolve: {
|
|
8
|
+
tsconfigPaths: true,
|
|
9
|
+
},
|
|
8
10
|
plugins: [
|
|
9
11
|
hydrogen(),
|
|
10
12
|
oxygen(),
|
|
@@ -17,11 +19,10 @@ export default defineConfig({
|
|
|
17
19
|
v3_routeConfig: false,
|
|
18
20
|
},
|
|
19
21
|
}),
|
|
20
|
-
tsconfigPaths(),
|
|
21
22
|
],
|
|
22
23
|
build: {
|
|
23
24
|
// Allow a strict Content-Security-Policy
|
|
24
|
-
//
|
|
25
|
+
// without inlining assets as base64:
|
|
25
26
|
assetsInlineLimit: 0,
|
|
26
27
|
},
|
|
27
28
|
ssr: {
|
|
@@ -46,7 +46,7 @@ class Deploy extends Command {
|
|
|
46
46
|
}),
|
|
47
47
|
force: Flags.boolean({
|
|
48
48
|
char: "f",
|
|
49
|
-
description: "Forces a deployment to proceed if there are
|
|
49
|
+
description: "Forces a deployment to proceed if there are uncommitted changes in its Git repository.",
|
|
50
50
|
default: false,
|
|
51
51
|
env: "SHOPIFY_HYDROGEN_FLAG_FORCE",
|
|
52
52
|
required: false
|
|
@@ -88,7 +88,7 @@ class Deploy extends Command {
|
|
|
88
88
|
required: false
|
|
89
89
|
}),
|
|
90
90
|
"metadata-description": Flags.string({
|
|
91
|
-
description: "Description of the changes in the deployment. Defaults to the commit message of the latest commit if there are no
|
|
91
|
+
description: "Description of the changes in the deployment. Defaults to the commit message of the latest commit if there are no uncommitted changes.",
|
|
92
92
|
required: false,
|
|
93
93
|
env: "SHOPIFY_HYDROGEN_FLAG_METADATA_DESCRIPTION"
|
|
94
94
|
}),
|
|
@@ -155,7 +155,7 @@ async function runDeploy(options) {
|
|
|
155
155
|
env: envHandle,
|
|
156
156
|
envBranch,
|
|
157
157
|
environmentFile,
|
|
158
|
-
force:
|
|
158
|
+
force: forceOnUncommittedChanges,
|
|
159
159
|
forceClientSourcemap = false,
|
|
160
160
|
noVerify,
|
|
161
161
|
lockfileCheck,
|
|
@@ -175,7 +175,7 @@ async function runDeploy(options) {
|
|
|
175
175
|
if (error instanceof GitDirectoryNotCleanError) {
|
|
176
176
|
isCleanGit = false;
|
|
177
177
|
}
|
|
178
|
-
if (!
|
|
178
|
+
if (!forceOnUncommittedChanges && !isCleanGit) {
|
|
179
179
|
let errorMessage = "Uncommitted changes detected";
|
|
180
180
|
let changedFiles = void 0;
|
|
181
181
|
const nextSteps = [
|
|
@@ -193,15 +193,21 @@ async function runDeploy(options) {
|
|
|
193
193
|
errorMessage += `:
|
|
194
194
|
|
|
195
195
|
${changedFiles.trimEnd()}`;
|
|
196
|
-
packageManagers.forEach(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
packageManagers.forEach(
|
|
197
|
+
({ name, lockfile, alternativeLockfiles, installCommand }) => {
|
|
198
|
+
const allLockfiles = [lockfile, ...alternativeLockfiles || []];
|
|
199
|
+
const changedLockfile = allLockfiles.find(
|
|
200
|
+
(lf) => changedFiles.includes(lf)
|
|
201
|
+
);
|
|
202
|
+
if (changedLockfile) {
|
|
203
|
+
nextSteps.push([
|
|
204
|
+
`If you are using ${name}, try running`,
|
|
205
|
+
{ command: installCommand },
|
|
206
|
+
`to avoid changes to ${changedLockfile}.`
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
203
209
|
}
|
|
204
|
-
|
|
210
|
+
);
|
|
205
211
|
}
|
|
206
212
|
throw new AbortError(errorMessage, null, nextSteps);
|
|
207
213
|
}
|
|
@@ -225,7 +231,7 @@ ${changedFiles.trimEnd()}`;
|
|
|
225
231
|
renderWarning({
|
|
226
232
|
headline: "No deployment description provided",
|
|
227
233
|
body: [
|
|
228
|
-
"Deploying
|
|
234
|
+
"Deploying uncommitted changes, but no description has been provided. Use the ",
|
|
229
235
|
{ command: "--metadata-description" },
|
|
230
236
|
"flag to provide a description. If no description is provided, the description defaults to ",
|
|
231
237
|
{ userInput: "<sha> with additional changes" },
|
|
@@ -7,11 +7,10 @@ import { renderSuccess, renderInfo } from '@shopify/cli-kit/node/ui';
|
|
|
7
7
|
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
8
8
|
import { removeFile } from '@shopify/cli-kit/node/fs';
|
|
9
9
|
import { setH2OVerbose, isH2Verbose, muteDevLogs, enhanceH2Logs } from '../../lib/log.js';
|
|
10
|
-
import { commonFlags, overrideFlag, flagsToCamelObject,
|
|
10
|
+
import { commonFlags, overrideFlag, flagsToCamelObject, DEFAULT_APP_PORT, DEFAULT_INSPECTOR_PORT } from '../../lib/flags.js';
|
|
11
11
|
import { spawnCodegenProcess } from '../../lib/codegen.js';
|
|
12
12
|
import { getAllEnvironmentVariables } from '../../lib/environment-variables.js';
|
|
13
13
|
import { displayDevUpgradeNotice } from './upgrade.js';
|
|
14
|
-
import { checkReactRouterVersions } from '../../lib/react-router-version-check.js';
|
|
15
14
|
import { getDevConfigInBackground, TUNNEL_DOMAIN, startTunnelAndPushConfig, isMockShop, notifyIssueWithTunnelAndMockShop, getUtilityBannerlines, getDebugBannerLine } from '../../lib/dev-shared.js';
|
|
16
15
|
import { getCliCommand } from '../../lib/shell.js';
|
|
17
16
|
import { findPort } from '../../lib/find-port.js';
|
|
@@ -104,6 +103,9 @@ async function runDev({
|
|
|
104
103
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "development";
|
|
105
104
|
if (verbose) setH2OVerbose();
|
|
106
105
|
if (!isH2Verbose()) muteDevLogs();
|
|
106
|
+
if (appPort === 0) {
|
|
107
|
+
appPort = await findPort(DEFAULT_APP_PORT);
|
|
108
|
+
}
|
|
107
109
|
const root = appPath ?? process.cwd();
|
|
108
110
|
const cliCommandPromise = getCliCommand(root);
|
|
109
111
|
const backgroundPromise = getDevConfigInBackground(
|
|
@@ -134,6 +136,8 @@ async function runDev({
|
|
|
134
136
|
const viteServer = await vite.createServer({
|
|
135
137
|
root,
|
|
136
138
|
clearScreen: false,
|
|
139
|
+
// In unit tests, node_modules is a symlink. Avoid writing .vite cache inside it.
|
|
140
|
+
cacheDir: process.env.SHOPIFY_UNIT_TEST ? joinPath(root, ".vite") : void 0,
|
|
137
141
|
customLogger: process.env.SHOPIFY_UNIT_TEST ? Object.assign(vite.createLogger(), {
|
|
138
142
|
info: (msg) => collectLog("info", msg),
|
|
139
143
|
warn: (msg) => collectLog("warn", msg),
|
|
@@ -197,7 +201,6 @@ async function runDev({
|
|
|
197
201
|
"Add `hydrogen()` plugin to your Vite config."
|
|
198
202
|
);
|
|
199
203
|
}
|
|
200
|
-
h2Plugin.api?.getPluginOptions?.();
|
|
201
204
|
const remixConfig = (await getViteConfig(root)).remixConfig;
|
|
202
205
|
let codegenProcess;
|
|
203
206
|
const setupCodegen = useCodegen ? () => {
|
|
@@ -236,9 +239,6 @@ async function runDev({
|
|
|
236
239
|
viteServer.bindCLIShortcuts({ print: true });
|
|
237
240
|
console.log("\n");
|
|
238
241
|
const storefrontTitle = (await backgroundPromise).storefrontTitle;
|
|
239
|
-
if (!disableVersionCheck) {
|
|
240
|
-
await checkReactRouterVersions(root);
|
|
241
|
-
}
|
|
242
242
|
showSuccessBanner({
|
|
243
243
|
disableVirtualRoutes,
|
|
244
244
|
debug,
|
|
@@ -12,7 +12,7 @@ class GenerateRoute extends Command {
|
|
|
12
12
|
static description = "Generates a standard Shopify route.";
|
|
13
13
|
static flags = {
|
|
14
14
|
adapter: Flags.string({
|
|
15
|
-
description: "
|
|
15
|
+
description: "React Router adapter used in the route. The default is `react-router`.",
|
|
16
16
|
env: "SHOPIFY_HYDROGEN_FLAG_ADAPTER"
|
|
17
17
|
}),
|
|
18
18
|
typescript: Flags.boolean({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { PackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
1
2
|
import * as _oclif_core_lib_interfaces_parser_js from '@oclif/core/lib/interfaces/parser.js';
|
|
2
3
|
import Command from '@shopify/cli-kit/node/base-command';
|
|
3
|
-
import { PackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
4
4
|
|
|
5
5
|
declare const SETUP_I18N_STRATEGIES: readonly ["subfolders", "domains", "subdomains"];
|
|
6
6
|
type I18nStrategy = (typeof SETUP_I18N_STRATEGIES)[number];
|
|
@@ -24,7 +24,6 @@ type InitOptions = {
|
|
|
24
24
|
i18n?: I18nChoice;
|
|
25
25
|
token?: string;
|
|
26
26
|
force?: boolean;
|
|
27
|
-
routes?: boolean;
|
|
28
27
|
shortcut?: boolean;
|
|
29
28
|
installDeps?: boolean;
|
|
30
29
|
git?: boolean;
|
|
@@ -41,7 +40,6 @@ declare class Init extends Command {
|
|
|
41
40
|
static descriptionWithMarkdown: string;
|
|
42
41
|
static description: string;
|
|
43
42
|
static flags: {
|
|
44
|
-
routes: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
45
43
|
git: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
46
44
|
quickstart: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
47
45
|
'package-manager': _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
@@ -60,7 +58,7 @@ declare class Init extends Command {
|
|
|
60
58
|
declare function runInit({ markets, ...options }?: InitOptions & {
|
|
61
59
|
markets?: InitOptions['i18n'];
|
|
62
60
|
}): Promise<{
|
|
63
|
-
language?:
|
|
61
|
+
language?: Language;
|
|
64
62
|
packageManager: "npm" | "pnpm" | "yarn" | "bun" | "unknown";
|
|
65
63
|
cssStrategy?: CssStrategy;
|
|
66
64
|
cliCommand: CliCommand;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Command from '@shopify/cli-kit/node/base-command';
|
|
2
2
|
import { Flags } from '@oclif/core';
|
|
3
3
|
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
4
|
-
import { commonFlags,
|
|
4
|
+
import { commonFlags, flagsToCamelObject, parseProcessFlags } from '../../lib/flags.js';
|
|
5
5
|
import { checkCurrentCLIVersion } from '../../lib/check-cli-version.js';
|
|
6
6
|
import { STYLING_CHOICES } from '../../lib/setups/css/index.js';
|
|
7
7
|
import { I18N_CHOICES } from '../../lib/setups/i18n/index.js';
|
|
@@ -36,11 +36,6 @@ class Init extends Command {
|
|
|
36
36
|
...commonFlags.styling,
|
|
37
37
|
...commonFlags.markets,
|
|
38
38
|
...commonFlags.shortcut,
|
|
39
|
-
routes: Flags.boolean({
|
|
40
|
-
description: "Generate routes for all pages.",
|
|
41
|
-
env: "SHOPIFY_HYDROGEN_FLAG_ROUTES",
|
|
42
|
-
allowNo: true
|
|
43
|
-
}),
|
|
44
39
|
git: Flags.boolean({
|
|
45
40
|
description: "Init Git and create initial commits.",
|
|
46
41
|
env: "SHOPIFY_HYDROGEN_FLAG_GIT",
|
|
@@ -48,7 +43,7 @@ class Init extends Command {
|
|
|
48
43
|
allowNo: true
|
|
49
44
|
}),
|
|
50
45
|
quickstart: Flags.boolean({
|
|
51
|
-
description: "Scaffolds a new Hydrogen project with a set of sensible defaults. Equivalent to `shopify hydrogen init --path hydrogen-quickstart --mock-shop --language js --shortcut --
|
|
46
|
+
description: "Scaffolds a new Hydrogen project with a set of sensible defaults. Equivalent to `shopify hydrogen init --path hydrogen-quickstart --mock-shop --language js --shortcut --markets none`",
|
|
52
47
|
env: "SHOPIFY_HYDROGEN_FLAG_QUICKSTART",
|
|
53
48
|
default: false
|
|
54
49
|
}),
|
|
@@ -91,7 +86,6 @@ async function runInit({
|
|
|
91
86
|
options.language ??= "js";
|
|
92
87
|
options.mockShop ??= true;
|
|
93
88
|
options.path ??= "./hydrogen-quickstart";
|
|
94
|
-
options.routes ??= true;
|
|
95
89
|
options.shortcut ??= true;
|
|
96
90
|
options.styling ??= "none";
|
|
97
91
|
}
|
|
@@ -5,7 +5,7 @@ import { outputInfo } from '@shopify/cli-kit/node/output';
|
|
|
5
5
|
import { resolvePath, joinPath } from '@shopify/cli-kit/node/path';
|
|
6
6
|
import { setH2OVerbose, isH2Verbose, muteDevLogs } from '../../lib/log.js';
|
|
7
7
|
import { getProjectPaths, isClassicProject } from '../../lib/remix-config.js';
|
|
8
|
-
import {
|
|
8
|
+
import { commonFlags, overrideFlag, flagsToCamelObject, DEFAULT_APP_PORT } from '../../lib/flags.js';
|
|
9
9
|
import { startMiniOxygen } from '../../lib/mini-oxygen/index.js';
|
|
10
10
|
import { getAllEnvironmentVariables } from '../../lib/environment-variables.js';
|
|
11
11
|
import { getConfig } from '../../lib/shopify-config.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolvePath } from '@shopify/cli-kit/node/path';
|
|
2
|
-
import {
|
|
2
|
+
import { commonFlags, overrideFlag, flagsToCamelObject } from '../../../lib/flags.js';
|
|
3
3
|
import Command from '@shopify/cli-kit/node/base-command';
|
|
4
4
|
import { renderSuccess, renderTasks, renderWarning } from '@shopify/cli-kit/node/ui';
|
|
5
5
|
import { getPackageManager, installNodeModules } from '@shopify/cli-kit/node/node-package-manager';
|
|
@@ -45,7 +45,7 @@ async function runSetupMarkets({
|
|
|
45
45
|
}
|
|
46
46
|
]);
|
|
47
47
|
renderSuccess({
|
|
48
|
-
headline: `
|
|
48
|
+
headline: `Markets support setup complete with strategy ${I18N_STRATEGY_NAME_MAP[strategy].toLowerCase()}.`,
|
|
49
49
|
body: `You can now modify the supported locales in ${remixConfig.serverEntryPoint ?? "your server entry file."}
|
|
50
50
|
`
|
|
51
51
|
});
|
|
@@ -5,7 +5,7 @@ import { removeFile, moveFile, readFile, writeFile, fileExists } from '@shopify/
|
|
|
5
5
|
import { readAndParsePackageJson, installNodeModules, getPackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
6
6
|
import { commonFlags, flagsToCamelObject } from '../../../lib/flags.js';
|
|
7
7
|
import { getRawRemixConfig } from '../../../lib/remix-config.js';
|
|
8
|
-
import {
|
|
8
|
+
import { replaceFileContent, mergePackageJson } from '../../../lib/file.js';
|
|
9
9
|
import { importLangAstGrep } from '../../../lib/ast.js';
|
|
10
10
|
import { getAssetsDir } from '../../../lib/build.js';
|
|
11
11
|
import { getCodeFormatOptions, formatCode } from '../../../lib/format-code.js';
|
|
@@ -3,7 +3,7 @@ import { AbortController } from '@shopify/cli-kit/node/abort';
|
|
|
3
3
|
import { renderTasks } from '@shopify/cli-kit/node/ui';
|
|
4
4
|
import { resolvePath, basename, joinPath } from '@shopify/cli-kit/node/path';
|
|
5
5
|
import { fileExists, glob, copyFile } from '@shopify/cli-kit/node/fs';
|
|
6
|
-
import {
|
|
6
|
+
import { commonFlags, overrideFlag, flagsToCamelObject } from '../../lib/flags.js';
|
|
7
7
|
import { renderI18nPrompt, setupI18nStrategy } from '../../lib/setups/i18n/index.js';
|
|
8
8
|
import { getRemixConfig } from '../../lib/remix-config.js';
|
|
9
9
|
import { handleRouteGeneration, generateProjectEntries, handleCliShortcut, renderProjectReady } from '../../lib/onboarding/common.js';
|
|
@@ -49,39 +49,37 @@ async function runSetup(options) {
|
|
|
49
49
|
extraChoices: { none: "Set up later" }
|
|
50
50
|
});
|
|
51
51
|
const i18n = i18nStrategy === "none" ? void 0 : i18nStrategy;
|
|
52
|
-
const {
|
|
52
|
+
const { setupRoutes } = handleRouteGeneration(controller);
|
|
53
53
|
let routes;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(filename)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
overwriteFileDeps: true
|
|
82
|
-
});
|
|
54
|
+
const templateRoot = await getTemplateAppFile("..");
|
|
55
|
+
const [typescript, dtsFiles] = await Promise.all([
|
|
56
|
+
fileExists(joinPath(rootDirectory, "tsconfig.json")),
|
|
57
|
+
glob("*.d.ts", { cwd: templateRoot })
|
|
58
|
+
]);
|
|
59
|
+
backgroundWorkPromise = backgroundWorkPromise.then(
|
|
60
|
+
() => Promise.all([
|
|
61
|
+
...dtsFiles.map(
|
|
62
|
+
(filename) => copyFile(
|
|
63
|
+
joinPath(templateRoot, filename),
|
|
64
|
+
resolvePath(rootDirectory, filename)
|
|
65
|
+
)
|
|
66
|
+
),
|
|
67
|
+
// Copy app entries
|
|
68
|
+
generateProjectEntries({
|
|
69
|
+
rootDirectory,
|
|
70
|
+
appDirectory,
|
|
71
|
+
typescript
|
|
72
|
+
})
|
|
73
|
+
])
|
|
74
|
+
).then(async () => {
|
|
75
|
+
routes = await setupRoutes(rootDirectory, typescript ? "ts" : "js", {
|
|
76
|
+
i18nStrategy: i18n,
|
|
77
|
+
// User might have added files before running this command.
|
|
78
|
+
// We should overwrite them to ensure the routes are set up correctly.
|
|
79
|
+
// Relies on Git to restore the files if needed.
|
|
80
|
+
overwriteFileDeps: true
|
|
83
81
|
});
|
|
84
|
-
}
|
|
82
|
+
});
|
|
85
83
|
if (i18n) {
|
|
86
84
|
backgroundWorkPromise = backgroundWorkPromise.then(
|
|
87
85
|
() => setupI18nStrategy(i18n, { rootDirectory })
|
|
@@ -93,7 +91,7 @@ async function runSetup(options) {
|
|
|
93
91
|
cliCommand,
|
|
94
92
|
options.shortcut
|
|
95
93
|
);
|
|
96
|
-
if (!i18n && !
|
|
94
|
+
if (!i18n && !createShortcut) return;
|
|
97
95
|
if (createShortcut) {
|
|
98
96
|
backgroundWorkPromise = backgroundWorkPromise.then(async () => {
|
|
99
97
|
if (await createShortcut()) {
|