@shopify/cli-hydrogen 11.1.3 → 11.1.5
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/assets/hydrogen/bundle/analyzer.html +155 -148
- package/dist/assets/hydrogen/starter/CHANGELOG.md +125 -49
- package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +62 -29
- package/dist/assets/hydrogen/starter/app/components/Header.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +2 -2
- package/dist/assets/hydrogen/starter/app/components/SearchForm.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/SearchFormPredictive.tsx +8 -3
- package/dist/assets/hydrogen/starter/app/components/SearchResults.tsx +3 -11
- package/dist/assets/hydrogen/starter/app/components/SearchResultsPredictive.tsx +2 -6
- package/dist/assets/hydrogen/starter/app/entry.client.tsx +10 -2
- package/dist/assets/hydrogen/starter/app/entry.server.tsx +5 -3
- package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerAddressMutations.ts +7 -4
- package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +1 -1
- package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerOrderQuery.ts +4 -1
- package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerOrdersQuery.ts +10 -5
- package/dist/assets/hydrogen/starter/app/graphql/customer-account/CustomerUpdateMutation.ts +3 -2
- package/dist/assets/hydrogen/starter/app/lib/context.ts +34 -17
- package/dist/assets/hydrogen/starter/app/lib/fragments.ts +1 -0
- package/dist/assets/hydrogen/starter/app/lib/orderFilters.ts +90 -0
- package/dist/assets/hydrogen/starter/app/lib/redirect.ts +1 -1
- package/dist/assets/hydrogen/starter/app/lib/session.ts +1 -1
- package/dist/assets/hydrogen/starter/app/lib/variants.ts +1 -1
- package/dist/assets/hydrogen/starter/app/root.tsx +23 -18
- package/dist/assets/hydrogen/starter/app/routes/$.tsx +2 -2
- package/dist/assets/hydrogen/starter/app/routes/[robots.txt].tsx +2 -2
- package/dist/assets/hydrogen/starter/app/routes/[sitemap.xml].tsx +2 -3
- package/dist/assets/hydrogen/starter/app/routes/_index.tsx +12 -8
- package/dist/assets/hydrogen/starter/app/routes/account.$.tsx +4 -3
- package/dist/assets/hydrogen/starter/app/routes/account._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/account.addresses.tsx +15 -11
- package/dist/assets/hydrogen/starter/app/routes/account.orders.$id.tsx +47 -22
- package/dist/assets/hydrogen/starter/app/routes/account.orders._index.tsx +152 -23
- package/dist/assets/hydrogen/starter/app/routes/account.profile.tsx +11 -8
- package/dist/assets/hydrogen/starter/app/routes/account.tsx +16 -4
- package/dist/assets/hydrogen/starter/app/routes/account_.authorize.tsx +2 -2
- package/dist/assets/hydrogen/starter/app/routes/account_.login.tsx +5 -3
- package/dist/assets/hydrogen/starter/app/routes/account_.logout.tsx +3 -2
- package/dist/assets/hydrogen/starter/app/routes/api.$version.[graphql.json].tsx +2 -2
- package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +6 -10
- package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle._index.tsx +10 -7
- package/dist/assets/hydrogen/starter/app/routes/blogs._index.tsx +13 -7
- package/dist/assets/hydrogen/starter/app/routes/cart.$lines.tsx +3 -2
- package/dist/assets/hydrogen/starter/app/routes/cart.tsx +13 -9
- package/dist/assets/hydrogen/starter/app/routes/collections.$handle.tsx +8 -11
- package/dist/assets/hydrogen/starter/app/routes/collections._index.tsx +6 -6
- package/dist/assets/hydrogen/starter/app/routes/collections.all.tsx +10 -7
- package/dist/assets/hydrogen/starter/app/routes/discount.$code.tsx +3 -2
- package/dist/assets/hydrogen/starter/app/routes/pages.$handle.tsx +8 -6
- package/dist/assets/hydrogen/starter/app/routes/policies.$handle.tsx +7 -4
- package/dist/assets/hydrogen/starter/app/routes/policies._index.tsx +19 -13
- package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +9 -6
- package/dist/assets/hydrogen/starter/app/routes/search.tsx +14 -14
- package/dist/assets/hydrogen/starter/app/routes/sitemap.$type.$page[.xml].tsx +2 -3
- package/dist/assets/hydrogen/starter/app/routes.ts +1 -1
- package/dist/assets/hydrogen/starter/app/styles/app.css +53 -1
- package/dist/assets/hydrogen/starter/customer-accountapi.generated.d.ts +47 -13
- package/dist/assets/hydrogen/starter/env.d.ts +1 -39
- package/dist/assets/hydrogen/starter/eslint.config.js +35 -52
- package/dist/assets/hydrogen/starter/package.json +14 -15
- package/dist/assets/hydrogen/starter/react-router.config.ts +9 -3
- package/dist/assets/hydrogen/starter/server.ts +7 -7
- package/dist/assets/hydrogen/starter/storefrontapi.generated.d.ts +1 -1
- package/dist/assets/hydrogen/starter/tsconfig.json +17 -13
- package/dist/assets/hydrogen/starter/vite.config.ts +3 -0
- package/dist/assets/hydrogen/virtual-routes/components/RequestDetails.jsx +13 -20
- package/dist/assets/hydrogen/virtual-routes/routes/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.jsx +37 -0
- package/dist/commands/hydrogen/build.js +2 -16
- package/dist/commands/hydrogen/codegen.js +2 -10
- package/dist/commands/hydrogen/debug/cpu.js +3 -7
- package/dist/commands/hydrogen/deploy.js +14 -9
- package/dist/commands/hydrogen/dev.js +6 -10
- package/dist/commands/hydrogen/env/pull.js +9 -1
- package/dist/commands/hydrogen/init.d.ts +1 -1
- package/dist/commands/hydrogen/preview.js +1 -16
- package/dist/commands/hydrogen/upgrade.js +145 -20
- package/dist/index.d.ts +1 -6
- package/dist/lib/build.js +17 -4
- package/dist/lib/flags.js +2 -10
- package/dist/lib/import-utils.js +4 -1
- package/dist/lib/live-reload.js +4 -4
- package/dist/lib/log.js +1 -1
- package/dist/lib/mini-oxygen/common.js +4 -1
- package/dist/lib/onboarding/local.js +25 -1
- package/dist/lib/onboarding/remote.js +4 -13
- package/dist/lib/onboarding/setup-template.mocks.js +4 -6
- package/dist/lib/react-router-version-check.js +82 -0
- package/dist/lib/setups/routes/generate.js +3 -0
- package/dist/lib/transpile/project.js +15 -7
- package/oclif.manifest.json +8 -53
- package/package.json +5 -5
- package/dist/lib/template-diff.js +0 -202
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { symlink, cp } from 'node:fs/promises';
|
|
2
|
-
import { temporaryDirectory } from 'tempy';
|
|
3
|
-
import { copyFile, fileExists, removeFile } from '@shopify/cli-kit/node/fs';
|
|
4
|
-
import { joinPath, relativePath } from '@shopify/cli-kit/node/path';
|
|
5
|
-
import { readAndParsePackageJson } from '@shopify/cli-kit/node/node-package-manager';
|
|
6
|
-
import { outputInfo } from '@shopify/cli-kit/node/output';
|
|
7
|
-
import colors from '@shopify/cli-kit/node/colors';
|
|
8
|
-
import { getStarterDir, isHydrogenMonorepo, getRepoNodeModules } from './build.js';
|
|
9
|
-
import { mergePackageJson, mergeTsConfig } from './file.js';
|
|
10
|
-
|
|
11
|
-
async function prepareDiffDirectory(diffDirectory, watch) {
|
|
12
|
-
const targetDirectory = temporaryDirectory({ prefix: "tmp-hydrogen-diff-" });
|
|
13
|
-
outputInfo(
|
|
14
|
-
`
|
|
15
|
-
-- Applying diff to starter template in
|
|
16
|
-
${colors.dim(
|
|
17
|
-
targetDirectory
|
|
18
|
-
)}
|
|
19
|
-
`
|
|
20
|
-
);
|
|
21
|
-
const templateDirectory = await getStarterDir(isHydrogenMonorepo);
|
|
22
|
-
await applyTemplateDiff(targetDirectory, diffDirectory, templateDirectory);
|
|
23
|
-
await symlink(
|
|
24
|
-
await getRepoNodeModules(),
|
|
25
|
-
joinPath(targetDirectory, "node_modules")
|
|
26
|
-
);
|
|
27
|
-
const { default: chokidar } = await import('chokidar');
|
|
28
|
-
const subscriptions = watch ? [
|
|
29
|
-
// Copy back the changes in generated d.ts from the
|
|
30
|
-
// temporary directory to the original diff directory.
|
|
31
|
-
chokidar.watch(joinPath(targetDirectory, "*.generated.d.ts"), {
|
|
32
|
-
ignoreInitial: true
|
|
33
|
-
}).on("all", async (eventName, eventFilePath) => {
|
|
34
|
-
const targetFile = joinPath(
|
|
35
|
-
diffDirectory,
|
|
36
|
-
relativePath(targetDirectory, eventFilePath)
|
|
37
|
-
);
|
|
38
|
-
await copyFile(eventFilePath, targetFile);
|
|
39
|
-
}),
|
|
40
|
-
// Copy new changes in the original diff directory to
|
|
41
|
-
// the temporary directory.
|
|
42
|
-
chokidar.watch(diffDirectory, {
|
|
43
|
-
ignoreInitial: true,
|
|
44
|
-
ignored: [
|
|
45
|
-
"**/*.generated.d.ts",
|
|
46
|
-
"**/package.json",
|
|
47
|
-
"**/tsconfig.json",
|
|
48
|
-
"**/.shopify"
|
|
49
|
-
]
|
|
50
|
-
}).on("all", async (eventName, eventFilePath) => {
|
|
51
|
-
const targetFile = joinPath(
|
|
52
|
-
targetDirectory,
|
|
53
|
-
relativePath(diffDirectory, eventFilePath)
|
|
54
|
-
);
|
|
55
|
-
const fileInTemplate = eventFilePath.replace(
|
|
56
|
-
diffDirectory,
|
|
57
|
-
templateDirectory
|
|
58
|
-
);
|
|
59
|
-
if (eventName === "unlink") {
|
|
60
|
-
return fileExists(fileInTemplate).then(
|
|
61
|
-
(exists) => exists ? (
|
|
62
|
-
// Replace it with original file from the starter template.
|
|
63
|
-
copyFile(fileInTemplate, targetFile)
|
|
64
|
-
) : (
|
|
65
|
-
// Remove the file otherwise.
|
|
66
|
-
removeFile(targetFile)
|
|
67
|
-
)
|
|
68
|
-
).catch(() => {
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return copyFile(eventFilePath, targetFile);
|
|
72
|
-
}),
|
|
73
|
-
// Copy new changes in the starter template to the temporary
|
|
74
|
-
// directory only if they don't overwrite the files in the
|
|
75
|
-
// original diff directory, which have higher priority.
|
|
76
|
-
chokidar.watch(templateDirectory, {
|
|
77
|
-
ignoreInitial: true,
|
|
78
|
-
ignored: [
|
|
79
|
-
"**/*.generated.d.ts",
|
|
80
|
-
"**/package.json",
|
|
81
|
-
"**/tsconfig.json",
|
|
82
|
-
"**/.shopify"
|
|
83
|
-
]
|
|
84
|
-
}).on("all", async (eventName, eventFilePath) => {
|
|
85
|
-
const fileInDiff = eventFilePath.replace(
|
|
86
|
-
templateDirectory,
|
|
87
|
-
diffDirectory
|
|
88
|
-
);
|
|
89
|
-
if (await fileExists(fileInDiff)) return;
|
|
90
|
-
const targetFile = joinPath(
|
|
91
|
-
targetDirectory,
|
|
92
|
-
relativePath(templateDirectory, eventFilePath)
|
|
93
|
-
);
|
|
94
|
-
return eventName === "unlink" ? removeFile(targetFile).catch(() => {
|
|
95
|
-
}) : copyFile(eventFilePath, targetFile);
|
|
96
|
-
})
|
|
97
|
-
] : [];
|
|
98
|
-
return {
|
|
99
|
-
/**
|
|
100
|
-
* The temporary directory with the starter template and diff applied.
|
|
101
|
-
*/
|
|
102
|
-
targetDirectory,
|
|
103
|
-
/**
|
|
104
|
-
* Removes the temporary directory and stops the file watchers.
|
|
105
|
-
*/
|
|
106
|
-
cleanup: async () => {
|
|
107
|
-
await Promise.all(subscriptions.map((sub) => sub.close()));
|
|
108
|
-
await removeFile(targetDirectory);
|
|
109
|
-
},
|
|
110
|
-
/**
|
|
111
|
-
* Brings the `.shopify` directory back to the original project.
|
|
112
|
-
* This is important to keep a reference of the tunnel configuration
|
|
113
|
-
* so that it can be removed in the next run.
|
|
114
|
-
*/
|
|
115
|
-
async copyShopifyConfig() {
|
|
116
|
-
const source = joinPath(targetDirectory, ".shopify");
|
|
117
|
-
if (!await fileExists(source)) return;
|
|
118
|
-
const target = joinPath(diffDirectory, ".shopify");
|
|
119
|
-
await removeFile(target);
|
|
120
|
-
await cp(source, target, { recursive: true, force: true });
|
|
121
|
-
},
|
|
122
|
-
/**
|
|
123
|
-
* Brings the `dist` directory back to the original project.
|
|
124
|
-
* This is used to run `h2 preview` with the resulting build.
|
|
125
|
-
*/
|
|
126
|
-
async copyDiffBuild() {
|
|
127
|
-
const target = joinPath(diffDirectory, "dist");
|
|
128
|
-
await removeFile(target);
|
|
129
|
-
await cp(joinPath(targetDirectory, "dist"), target, {
|
|
130
|
-
force: true,
|
|
131
|
-
recursive: true
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
/**
|
|
135
|
-
* Brings the generated d.ts files back to the original project.
|
|
136
|
-
*/
|
|
137
|
-
copyDiffCodegen() {
|
|
138
|
-
return Promise.all([
|
|
139
|
-
copyFile(
|
|
140
|
-
joinPath(targetDirectory, "storefrontapi.generated.d.ts"),
|
|
141
|
-
joinPath(diffDirectory, "storefrontapi.generated.d.ts")
|
|
142
|
-
),
|
|
143
|
-
copyFile(
|
|
144
|
-
joinPath(targetDirectory, "customer-accountapi.generated.d.ts"),
|
|
145
|
-
joinPath(diffDirectory, "customer-accountapi.generated.d.ts")
|
|
146
|
-
)
|
|
147
|
-
]);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
async function applyTemplateDiff(targetDirectory, diffDirectory, templateDir) {
|
|
152
|
-
templateDir ??= await getStarterDir();
|
|
153
|
-
const diffPkgJson = await readAndParsePackageJson(
|
|
154
|
-
joinPath(diffDirectory, "package.json")
|
|
155
|
-
);
|
|
156
|
-
const diffOptions = diffPkgJson["h2:diff"] ?? {};
|
|
157
|
-
const createFilter = (re, skipFiles) => (filepath) => {
|
|
158
|
-
const filename = relativePath(templateDir, filepath);
|
|
159
|
-
return !re.test(filename) && !skipFiles?.includes(filename);
|
|
160
|
-
};
|
|
161
|
-
await cp(templateDir, targetDirectory, {
|
|
162
|
-
force: true,
|
|
163
|
-
recursive: true,
|
|
164
|
-
filter: createFilter(
|
|
165
|
-
// Do not copy .shopify from skeleton to avoid linking in examples inadvertedly
|
|
166
|
-
/(^|\/|\\)(dist|node_modules|\.cache|\.turbo|\.shopify|CHANGELOG\.md)(\/|\\|$)/i,
|
|
167
|
-
diffOptions.skipFiles || []
|
|
168
|
-
)
|
|
169
|
-
});
|
|
170
|
-
await cp(diffDirectory, targetDirectory, {
|
|
171
|
-
force: true,
|
|
172
|
-
recursive: true,
|
|
173
|
-
filter: createFilter(
|
|
174
|
-
/(^|\/|\\)(dist|node_modules|\.cache|.turbo|package\.json|tsconfig\.json)(\/|\\|$)/i
|
|
175
|
-
)
|
|
176
|
-
});
|
|
177
|
-
await mergePackageJson(diffDirectory, targetDirectory, {
|
|
178
|
-
ignoredKeys: ["h2:diff"],
|
|
179
|
-
onResult: (pkgJson) => {
|
|
180
|
-
for (const key of ["build", "dev", "preview"]) {
|
|
181
|
-
const scriptLine = pkgJson.scripts?.[key];
|
|
182
|
-
if (pkgJson.scripts?.[key] && typeof scriptLine === "string") {
|
|
183
|
-
pkgJson.scripts[key] = scriptLine.replace(/\s+--diff/, "");
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (diffOptions.skipDependencies && pkgJson.dependencies) {
|
|
187
|
-
for (const dep of diffOptions.skipDependencies) {
|
|
188
|
-
delete pkgJson.dependencies[dep];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (diffOptions.skipDevDependencies && pkgJson.devDependencies) {
|
|
192
|
-
for (const devDep of diffOptions.skipDevDependencies) {
|
|
193
|
-
delete pkgJson.devDependencies[devDep];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return pkgJson;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
await mergeTsConfig(diffDirectory, targetDirectory);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export { applyTemplateDiff, prepareDiffDirectory };
|