@shopify/cli-hydrogen 5.5.1 → 6.0.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 +2 -6
- package/dist/commands/hydrogen/{codegen-unstable.js → codegen.js} +2 -0
- package/dist/commands/hydrogen/deploy.js +1 -0
- package/dist/commands/hydrogen/deploy.test.js +1 -0
- package/dist/commands/hydrogen/dev.js +6 -8
- package/dist/commands/hydrogen/generate/route.js +5 -1
- package/dist/commands/hydrogen/generate/route.test.js +4 -2
- package/dist/commands/hydrogen/init.test.js +1 -4
- package/dist/commands/hydrogen/setup.js +1 -6
- package/dist/generator-templates/starter/CHANGELOG.md +143 -0
- package/dist/generator-templates/starter/app/components/Footer.tsx +19 -8
- package/dist/generator-templates/starter/app/components/Header.tsx +13 -5
- package/dist/generator-templates/starter/app/components/Layout.tsx +14 -4
- package/dist/generator-templates/starter/app/root.tsx +14 -27
- package/dist/generator-templates/starter/app/routes/$.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/[robots.txt].tsx +2 -2
- package/dist/generator-templates/starter/app/routes/[sitemap.xml].tsx +5 -2
- package/dist/generator-templates/starter/app/routes/_index.tsx +4 -9
- package/dist/generator-templates/starter/app/routes/account.$.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/account.addresses.tsx +6 -6
- package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/account.profile.tsx +6 -6
- package/dist/generator-templates/starter/app/routes/account.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +6 -6
- package/dist/generator-templates/starter/app/routes/account_.login.tsx +6 -11
- package/dist/generator-templates/starter/app/routes/account_.logout.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/account_.recover.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/account_.register.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/api.predictive-search.tsx +4 -4
- package/dist/generator-templates/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +5 -5
- package/dist/generator-templates/starter/app/routes/blogs.$blogHandle._index.tsx +5 -5
- package/dist/generator-templates/starter/app/routes/blogs._index.tsx +7 -4
- package/dist/generator-templates/starter/app/routes/cart.$lines.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/cart.tsx +11 -8
- package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +5 -5
- package/dist/generator-templates/starter/app/routes/collections._index.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/discount.$code.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/pages.$handle.tsx +5 -5
- package/dist/generator-templates/starter/app/routes/policies.$handle.tsx +5 -5
- package/dist/generator-templates/starter/app/routes/policies._index.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +7 -7
- package/dist/generator-templates/starter/app/routes/search.tsx +5 -4
- package/dist/generator-templates/starter/app/styles/app.css +16 -16
- package/dist/generator-templates/starter/package.json +10 -10
- package/dist/generator-templates/starter/remix.config.js +0 -8
- package/dist/generator-templates/starter/storefrontapi.generated.d.ts +79 -55
- package/dist/lib/codegen.js +31 -22
- package/dist/lib/flags.js +8 -1
- package/dist/lib/onboarding/common.js +2 -14
- package/dist/lib/remix-version-check.js +2 -1
- package/dist/lib/remix-version-interop.js +1 -39
- package/dist/lib/remix-version-interop.test.js +8 -98
- package/dist/lib/setups/css/postcss.js +1 -6
- package/dist/lib/setups/css/tailwind.js +6 -12
- package/dist/lib/setups/routes/generate.js +13 -23
- package/dist/lib/setups/routes/generate.test.js +6 -20
- package/dist/lib/transpile/morph/typedefs.js +1 -1
- package/oclif.manifest.json +29 -16
- package/package.json +13 -9
|
@@ -1,103 +1,13 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { convertRouteToV1
|
|
2
|
+
import { convertRouteToV1 } from './remix-version-interop.js';
|
|
3
3
|
|
|
4
4
|
describe("remix-version-interop", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe("v2_meta", () => {
|
|
16
|
-
const META_TEMPLATE = `
|
|
17
|
-
import {type MetaFunction} from '@shopify/remix-oxygen';
|
|
18
|
-
import {type V2_MetaFunction} from '@remix-run/react';
|
|
19
|
-
export const metaV1: MetaFunction = ({data}) => {
|
|
20
|
-
const title = 'title';
|
|
21
|
-
return {title};
|
|
22
|
-
};
|
|
23
|
-
export const meta: V2_MetaFunction = ({data}) => {
|
|
24
|
-
const title = 'title';
|
|
25
|
-
return [{title}];
|
|
26
|
-
};
|
|
27
|
-
`.replace(/^\s{4}/gm, "");
|
|
28
|
-
it("transforms meta exports to v2", async () => {
|
|
29
|
-
const result = convertTemplateToRemixVersion(META_TEMPLATE, {
|
|
30
|
-
isV2Meta: true
|
|
31
|
-
});
|
|
32
|
-
expect(result).toContain("type V2_MetaFunction");
|
|
33
|
-
expect(result).not.toContain("type MetaFunction");
|
|
34
|
-
expect(result).not.toContain("@shopify/remix-oxygen");
|
|
35
|
-
expect(result).toMatch(/return \[\{title\}\];/);
|
|
36
|
-
expect(result).not.toMatch(/return \{title\};/);
|
|
37
|
-
});
|
|
38
|
-
it("transforms meta exports to v1", async () => {
|
|
39
|
-
const result = convertTemplateToRemixVersion(META_TEMPLATE, {
|
|
40
|
-
isV2Meta: false
|
|
41
|
-
});
|
|
42
|
-
expect(result).toContain("type MetaFunction");
|
|
43
|
-
expect(result).not.toContain("type V2_MetaFunction");
|
|
44
|
-
expect(result).not.toContain("@remix-run/react");
|
|
45
|
-
expect(result).toMatch(/return \{title\};/);
|
|
46
|
-
expect(result).not.toMatch(/return \[\{title\}\];/);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe("v2_errorBoundary", () => {
|
|
50
|
-
const ERROR_BOUNDARY_TEMPLATE = `
|
|
51
|
-
import {useCatch, isRouteErrorResponse, useRouteError} from "@remix-run/react";
|
|
52
|
-
import {type ErrorBoundaryComponent} from '@shopify/remix-oxygen';
|
|
53
|
-
|
|
54
|
-
export function CatchBoundary() {
|
|
55
|
-
const caught = useCatch();
|
|
56
|
-
console.error(caught);
|
|
57
|
-
|
|
58
|
-
return <div>stuff</div>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const ErrorBoundaryV1 = ({error}: {error: Error}) => {
|
|
62
|
-
console.error(error);
|
|
63
|
-
|
|
64
|
-
return <div>There was an error.</div>;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export function ErrorBoundary() {
|
|
68
|
-
const error = useRouteError();
|
|
69
|
-
|
|
70
|
-
if (isRouteErrorResponse(error)) {
|
|
71
|
-
return <div>RouteError</div>;
|
|
72
|
-
} else {
|
|
73
|
-
return <h1>Unknown Error</h1>;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
`.replace(/^\s{4}/gm, "");
|
|
77
|
-
it("transforms ErrorBoundary exports to v2", async () => {
|
|
78
|
-
const result = convertTemplateToRemixVersion(ERROR_BOUNDARY_TEMPLATE, {
|
|
79
|
-
isV2ErrorBoundary: true
|
|
80
|
-
});
|
|
81
|
-
expect(result).toContain("export function ErrorBoundary");
|
|
82
|
-
expect(result).not.toContain("export const ErrorBoundary");
|
|
83
|
-
expect(result).not.toMatch("export function CatchBoundary");
|
|
84
|
-
expect(result).not.toContain("type ErrorBoundaryComponent");
|
|
85
|
-
expect(result).not.toContain("@shopify/remix-oxygen");
|
|
86
|
-
expect(result).toContain("useRouteError");
|
|
87
|
-
expect(result).toContain("isRouteErrorResponse");
|
|
88
|
-
expect(result).not.toContain("useCatch");
|
|
89
|
-
});
|
|
90
|
-
it("transforms ErrorBoundary exports to v1", async () => {
|
|
91
|
-
const result = convertTemplateToRemixVersion(ERROR_BOUNDARY_TEMPLATE, {
|
|
92
|
-
isV2ErrorBoundary: false
|
|
93
|
-
});
|
|
94
|
-
expect(result).toContain("export const ErrorBoundary");
|
|
95
|
-
expect(result).not.toContain("export function ErrorBoundary");
|
|
96
|
-
expect(result).toMatch("export function CatchBoundary");
|
|
97
|
-
expect(result).toContain("type ErrorBoundaryComponent");
|
|
98
|
-
expect(result).toContain("useCatch");
|
|
99
|
-
expect(result).not.toContain("useRouteError");
|
|
100
|
-
expect(result).not.toContain("isRouteErrorResponse");
|
|
101
|
-
});
|
|
5
|
+
it("converts routes to v1", () => {
|
|
6
|
+
expect(convertRouteToV1("_index")).toEqual("index");
|
|
7
|
+
expect(convertRouteToV1("path.to.file")).toEqual("path/to/file");
|
|
8
|
+
expect(convertRouteToV1("path.to._index")).toEqual("path/to/index");
|
|
9
|
+
expect(convertRouteToV1("patht.to.[sitemap.xml]")).toEqual(
|
|
10
|
+
"patht/to/[sitemap.xml]"
|
|
11
|
+
);
|
|
102
12
|
});
|
|
103
13
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { outputInfo } from '@shopify/cli-kit/node/output';
|
|
2
2
|
import { canWriteFiles, mergePackageJson, copyAssets } from './assets.js';
|
|
3
|
-
import { getCodeFormatOptions } from '../../format-code.js';
|
|
4
|
-
import { replaceRemixConfig } from './replacers.js';
|
|
5
3
|
|
|
6
4
|
async function setupPostCss({ rootDirectory, appDirectory, ...futureOptions }, force = false) {
|
|
7
5
|
const assetMap = {
|
|
@@ -19,10 +17,7 @@ async function setupPostCss({ rootDirectory, appDirectory, ...futureOptions }, f
|
|
|
19
17
|
}
|
|
20
18
|
const workPromise = Promise.all([
|
|
21
19
|
mergePackageJson("postcss", rootDirectory),
|
|
22
|
-
copyAssets("postcss", assetMap, rootDirectory)
|
|
23
|
-
getCodeFormatOptions(rootDirectory).then(
|
|
24
|
-
(formatConfig) => replaceRemixConfig(rootDirectory, formatConfig, { postcss: true })
|
|
25
|
-
)
|
|
20
|
+
copyAssets("postcss", assetMap, rootDirectory)
|
|
26
21
|
]);
|
|
27
22
|
return {
|
|
28
23
|
workPromise,
|
|
@@ -2,7 +2,7 @@ import { outputInfo } from '@shopify/cli-kit/node/output';
|
|
|
2
2
|
import { relativePath, joinPath } from '@shopify/cli-kit/node/path';
|
|
3
3
|
import { canWriteFiles, mergePackageJson, copyAssets } from './assets.js';
|
|
4
4
|
import { getCodeFormatOptions } from '../../format-code.js';
|
|
5
|
-
import {
|
|
5
|
+
import { replaceRootLinks } from './replacers.js';
|
|
6
6
|
|
|
7
7
|
const tailwindCssPath = "styles/tailwind.css";
|
|
8
8
|
async function setupTailwind({ rootDirectory, appDirectory, ...futureOptions }, force = false) {
|
|
@@ -31,17 +31,11 @@ async function setupTailwind({ rootDirectory, appDirectory, ...futureOptions },
|
|
|
31
31
|
(content, filepath) => filepath === "tailwind.config.js" ? content.replace("{src-dir}", relativeAppDirectory) : content
|
|
32
32
|
),
|
|
33
33
|
getCodeFormatOptions(rootDirectory).then(
|
|
34
|
-
(formatConfig) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
replaceRootLinks(appDirectory, formatConfig, {
|
|
40
|
-
name: "tailwindCss",
|
|
41
|
-
path: tailwindCssPath,
|
|
42
|
-
isDefault: true
|
|
43
|
-
})
|
|
44
|
-
])
|
|
34
|
+
(formatConfig) => replaceRootLinks(appDirectory, formatConfig, {
|
|
35
|
+
name: "tailwindCss",
|
|
36
|
+
path: tailwindCssPath,
|
|
37
|
+
isDefault: true
|
|
38
|
+
})
|
|
45
39
|
)
|
|
46
40
|
]);
|
|
47
41
|
return {
|
|
@@ -6,7 +6,7 @@ import { renderConfirmationPrompt } from '@shopify/cli-kit/node/ui';
|
|
|
6
6
|
import { transpileFile } from '../../transpile/index.js';
|
|
7
7
|
import { getCodeFormatOptions, formatCode } from '../../../lib/format-code.js';
|
|
8
8
|
import { getTemplateAppFile, GENERATOR_ROUTE_DIR, getStarterDir } from '../../../lib/build.js';
|
|
9
|
-
import {
|
|
9
|
+
import { convertRouteToV1 } from '../../../lib/remix-version-interop.js';
|
|
10
10
|
import { getRemixConfig } from '../../remix-config.js';
|
|
11
11
|
import { findFileWithExtension } from '../../file.js';
|
|
12
12
|
|
|
@@ -53,18 +53,13 @@ async function getResolvedRoutes(routeKeys = Object.keys(ROUTE_MAP)) {
|
|
|
53
53
|
const ALL_ROUTE_CHOICES = [...Object.keys(ROUTE_MAP), "all"];
|
|
54
54
|
async function generateRoutes(options, remixConfig) {
|
|
55
55
|
const { routeGroups, resolvedRouteFiles } = options.routeName === "all" ? await getResolvedRoutes() : await getResolvedRoutes([options.routeName]);
|
|
56
|
-
const { rootDirectory, appDirectory
|
|
56
|
+
const { rootDirectory, appDirectory } = remixConfig || await getRemixConfig(options.directory);
|
|
57
57
|
const routesArray = resolvedRouteFiles.flatMap(
|
|
58
58
|
(item) => GENERATOR_ROUTE_DIR + "/" + item
|
|
59
59
|
);
|
|
60
|
-
const v2Flags = await getV2Flags(rootDirectory, future);
|
|
61
60
|
const formatOptions = await getCodeFormatOptions(rootDirectory);
|
|
62
|
-
const localePrefix = await getLocalePrefix(
|
|
63
|
-
|
|
64
|
-
options,
|
|
65
|
-
v2Flags.isV2RouteConvention
|
|
66
|
-
);
|
|
67
|
-
const typescript = !!(options.typescript ?? tsconfigPath?.endsWith("tsconfig.json"));
|
|
61
|
+
const localePrefix = await getLocalePrefix(appDirectory, options);
|
|
62
|
+
const typescript = !!(options.typescript ?? await fileExists(joinPath(rootDirectory, "tsconfig.json")));
|
|
68
63
|
const routes = [];
|
|
69
64
|
for (const route of routesArray) {
|
|
70
65
|
routes.push(
|
|
@@ -74,8 +69,7 @@ async function generateRoutes(options, remixConfig) {
|
|
|
74
69
|
localePrefix,
|
|
75
70
|
rootDirectory,
|
|
76
71
|
appDirectory,
|
|
77
|
-
formatOptions
|
|
78
|
-
v2Flags
|
|
72
|
+
formatOptions
|
|
79
73
|
})
|
|
80
74
|
);
|
|
81
75
|
}
|
|
@@ -83,11 +77,10 @@ async function generateRoutes(options, remixConfig) {
|
|
|
83
77
|
routes,
|
|
84
78
|
routeGroups,
|
|
85
79
|
isTypescript: typescript,
|
|
86
|
-
v2Flags,
|
|
87
80
|
formatOptions
|
|
88
81
|
};
|
|
89
82
|
}
|
|
90
|
-
async function getLocalePrefix(appDirectory, { localePrefix, routeName
|
|
83
|
+
async function getLocalePrefix(appDirectory, { localePrefix, routeName, v1RouteConvention }) {
|
|
91
84
|
if (localePrefix)
|
|
92
85
|
return localePrefix;
|
|
93
86
|
if (localePrefix !== void 0 || routeName === "all")
|
|
@@ -95,7 +88,7 @@ async function getLocalePrefix(appDirectory, { localePrefix, routeName }, isV2Ro
|
|
|
95
88
|
const existingFiles = await readdir(joinPath(appDirectory, "routes")).catch(
|
|
96
89
|
() => []
|
|
97
90
|
);
|
|
98
|
-
const coreRouteWithLocaleRE =
|
|
91
|
+
const coreRouteWithLocaleRE = v1RouteConvention ? /^\(\$(\w+)\)$/ : /^\(\$(\w+)\)\.(_index|\$|cart).[jt]sx?$/;
|
|
99
92
|
const coreRouteWithLocale = existingFiles.find(
|
|
100
93
|
(file) => coreRouteWithLocaleRE.test(file)
|
|
101
94
|
);
|
|
@@ -112,7 +105,7 @@ async function generateProjectFile(routeFrom, {
|
|
|
112
105
|
templatesRoot = getStarterDir(),
|
|
113
106
|
formatOptions,
|
|
114
107
|
localePrefix,
|
|
115
|
-
|
|
108
|
+
v1RouteConvention = false,
|
|
116
109
|
signal
|
|
117
110
|
}) {
|
|
118
111
|
const extension = (routeFrom.match(/(\.[jt]sx?)$/) ?? [])[1] ?? ".tsx";
|
|
@@ -127,7 +120,7 @@ async function generateProjectFile(routeFrom, {
|
|
|
127
120
|
);
|
|
128
121
|
const routeDestinationPath = joinPath(
|
|
129
122
|
appDirectory,
|
|
130
|
-
getDestinationRoute(routeFrom, localePrefix,
|
|
123
|
+
getDestinationRoute(routeFrom, localePrefix, { v1RouteConvention }) + (typescript ? extension : extension.replace(".ts", ".js"))
|
|
131
124
|
);
|
|
132
125
|
const result = {
|
|
133
126
|
operation: "created",
|
|
@@ -160,10 +153,7 @@ async function generateProjectFile(routeFrom, {
|
|
|
160
153
|
await copyFile(templateAppFilePath, destinationPath);
|
|
161
154
|
continue;
|
|
162
155
|
}
|
|
163
|
-
let templateContent =
|
|
164
|
-
await readFile(templateAppFilePath),
|
|
165
|
-
v2Flags
|
|
166
|
-
);
|
|
156
|
+
let templateContent = await readFile(templateAppFilePath);
|
|
167
157
|
if (!typescript) {
|
|
168
158
|
templateContent = await transpileFile(
|
|
169
159
|
templateContent,
|
|
@@ -185,12 +175,12 @@ async function generateProjectFile(routeFrom, {
|
|
|
185
175
|
}
|
|
186
176
|
return result;
|
|
187
177
|
}
|
|
188
|
-
function getDestinationRoute(routeFrom, localePrefix,
|
|
178
|
+
function getDestinationRoute(routeFrom, localePrefix, options) {
|
|
189
179
|
const routePath = routeFrom.replace(GENERATOR_ROUTE_DIR + "/", "");
|
|
190
|
-
const filePrefix = localePrefix && !NO_LOCALE_PATTERNS.some((pattern) => pattern.test(routePath)) ? `($${localePrefix})` + (
|
|
180
|
+
const filePrefix = localePrefix && !NO_LOCALE_PATTERNS.some((pattern) => pattern.test(routePath)) ? `($${localePrefix})` + (options.v1RouteConvention ? "/" : ".") : "";
|
|
191
181
|
return GENERATOR_ROUTE_DIR + "/" + filePrefix + // The template file uses the v2 route convention, so we need to convert
|
|
192
182
|
// it to v1 if the user is not using v2.
|
|
193
|
-
(
|
|
183
|
+
(options.v1RouteConvention ? convertRouteToV1(routePath) : routePath);
|
|
194
184
|
}
|
|
195
185
|
async function findRouteDependencies(routeFilePath, appDirectory) {
|
|
196
186
|
const filesToCheck = /* @__PURE__ */ new Set([routeFilePath]);
|
|
@@ -60,10 +60,7 @@ describe("generate/route", () => {
|
|
|
60
60
|
});
|
|
61
61
|
vi.mocked(getRemixConfig).mockResolvedValue({
|
|
62
62
|
...directories,
|
|
63
|
-
tsconfigPath: "somewhere/tsconfig.json"
|
|
64
|
-
future: {
|
|
65
|
-
v2_routeConvention: true
|
|
66
|
-
}
|
|
63
|
+
tsconfigPath: "somewhere/tsconfig.json"
|
|
67
64
|
});
|
|
68
65
|
const result = await generateRoutes({
|
|
69
66
|
routeName: ["page"],
|
|
@@ -94,9 +91,7 @@ describe("generate/route", () => {
|
|
|
94
91
|
});
|
|
95
92
|
await generateProjectFile(route, {
|
|
96
93
|
...directories,
|
|
97
|
-
|
|
98
|
-
isV2RouteConvention: false
|
|
99
|
-
}
|
|
94
|
+
v1RouteConvention: true
|
|
100
95
|
});
|
|
101
96
|
expect(
|
|
102
97
|
await readProjectFile(directories, route.replace(".", "/"), "jsx")
|
|
@@ -110,10 +105,7 @@ describe("generate/route", () => {
|
|
|
110
105
|
files: [],
|
|
111
106
|
templates: [[route + ".tsx", `const str = "hello world"`]]
|
|
112
107
|
});
|
|
113
|
-
await generateProjectFile(route,
|
|
114
|
-
...directories,
|
|
115
|
-
v2Flags: { isV2RouteConvention: true }
|
|
116
|
-
});
|
|
108
|
+
await generateProjectFile(route, directories);
|
|
117
109
|
expect(await readProjectFile(directories, route, "jsx")).toContain(
|
|
118
110
|
`const str = 'hello world'`
|
|
119
111
|
);
|
|
@@ -134,25 +126,22 @@ describe("generate/route", () => {
|
|
|
134
126
|
const localePrefix = "locale";
|
|
135
127
|
await generateProjectFile("routes/_index", {
|
|
136
128
|
...directories,
|
|
137
|
-
v2Flags: { isV2RouteConvention: true },
|
|
138
129
|
localePrefix,
|
|
139
130
|
typescript: true
|
|
140
131
|
});
|
|
141
132
|
await generateProjectFile("routes/pages.$handle", {
|
|
142
133
|
...directories,
|
|
143
|
-
|
|
134
|
+
v1RouteConvention: true,
|
|
144
135
|
localePrefix,
|
|
145
136
|
typescript: true
|
|
146
137
|
});
|
|
147
138
|
await generateProjectFile("routes/[sitemap.xml]", {
|
|
148
139
|
...directories,
|
|
149
|
-
v2Flags: { isV2RouteConvention: true },
|
|
150
140
|
localePrefix,
|
|
151
141
|
typescript: true
|
|
152
142
|
});
|
|
153
143
|
await generateProjectFile("routes/[robots.txt]", {
|
|
154
144
|
...directories,
|
|
155
|
-
v2Flags: { isV2RouteConvention: true },
|
|
156
145
|
localePrefix,
|
|
157
146
|
typescript: true
|
|
158
147
|
});
|
|
@@ -179,8 +168,7 @@ describe("generate/route", () => {
|
|
|
179
168
|
});
|
|
180
169
|
await generateProjectFile(route, {
|
|
181
170
|
...directories,
|
|
182
|
-
typescript: true
|
|
183
|
-
v2Flags: { isV2RouteConvention: true }
|
|
171
|
+
typescript: true
|
|
184
172
|
});
|
|
185
173
|
expect(await readProjectFile(directories, route)).toContain(
|
|
186
174
|
`const str = 'hello typescript'`
|
|
@@ -198,8 +186,7 @@ describe("generate/route", () => {
|
|
|
198
186
|
templates: [[route + ".tsx", 'const str = "hello world"']]
|
|
199
187
|
});
|
|
200
188
|
await generateProjectFile(route, {
|
|
201
|
-
...directories
|
|
202
|
-
v2Flags: { isV2RouteConvention: true }
|
|
189
|
+
...directories
|
|
203
190
|
});
|
|
204
191
|
expect(renderConfirmationPrompt).toHaveBeenCalledWith(
|
|
205
192
|
expect.objectContaining({
|
|
@@ -266,7 +253,6 @@ export {Button, Text};
|
|
|
266
253
|
vi.mocked(getRemixConfig).mockResolvedValue(directories);
|
|
267
254
|
await generateProjectFile("routes/pages.$pageHandle", {
|
|
268
255
|
...directories,
|
|
269
|
-
v2Flags: { isV2RouteConvention: true },
|
|
270
256
|
force: true
|
|
271
257
|
});
|
|
272
258
|
await Promise.all(
|
|
@@ -30,7 +30,7 @@ function generateTypeDefs(sourceFile, code) {
|
|
|
30
30
|
for (const typeElement of typeElements) {
|
|
31
31
|
if (typeElement === "SerializeFrom")
|
|
32
32
|
continue;
|
|
33
|
-
const hasGeneric = typeElement === "
|
|
33
|
+
const hasGeneric = typeElement === "MetaFunction";
|
|
34
34
|
typedefs.push(
|
|
35
35
|
`/** ${hasGeneric ? "@template T " : ""}@typedef {import('${moduleSpecifier}').${typeElement}${hasGeneric ? "<T>" : ""}} ${typeElement} */`
|
|
36
36
|
);
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "6.0.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"hydrogen:build": {
|
|
5
5
|
"id": "hydrogen:build",
|
|
@@ -40,12 +40,15 @@
|
|
|
40
40
|
"description": "Disable warning about missing standard routes.",
|
|
41
41
|
"allowNo": false
|
|
42
42
|
},
|
|
43
|
-
"codegen
|
|
44
|
-
"name": "codegen
|
|
43
|
+
"codegen": {
|
|
44
|
+
"name": "codegen",
|
|
45
45
|
"type": "boolean",
|
|
46
46
|
"description": "Generate types for the Storefront API queries found in your project.",
|
|
47
47
|
"required": false,
|
|
48
|
-
"allowNo": false
|
|
48
|
+
"allowNo": false,
|
|
49
|
+
"aliases": [
|
|
50
|
+
"codegen-unstable"
|
|
51
|
+
]
|
|
49
52
|
},
|
|
50
53
|
"codegen-config-path": {
|
|
51
54
|
"name": "codegen-config-path",
|
|
@@ -54,7 +57,7 @@
|
|
|
54
57
|
"required": false,
|
|
55
58
|
"multiple": false,
|
|
56
59
|
"dependsOn": [
|
|
57
|
-
"codegen
|
|
60
|
+
"codegen"
|
|
58
61
|
]
|
|
59
62
|
},
|
|
60
63
|
"base": {
|
|
@@ -105,41 +108,48 @@
|
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
},
|
|
108
|
-
"hydrogen:codegen
|
|
109
|
-
"id": "hydrogen:codegen
|
|
111
|
+
"hydrogen:codegen": {
|
|
112
|
+
"id": "hydrogen:codegen",
|
|
110
113
|
"description": "Generate types for the Storefront API queries found in your project.",
|
|
111
114
|
"strict": true,
|
|
112
115
|
"pluginName": "@shopify/cli-hydrogen",
|
|
113
116
|
"pluginAlias": "@shopify/cli-hydrogen",
|
|
114
117
|
"pluginType": "core",
|
|
115
|
-
"aliases": [
|
|
118
|
+
"aliases": [
|
|
119
|
+
"codegen-unstable"
|
|
120
|
+
],
|
|
121
|
+
"deprecateAliases": true,
|
|
116
122
|
"flags": {
|
|
117
123
|
"path": {
|
|
118
124
|
"name": "path",
|
|
119
125
|
"type": "option",
|
|
120
126
|
"description": "The path to the directory of the Hydrogen storefront. The default is the current directory.",
|
|
121
|
-
"multiple": false
|
|
127
|
+
"multiple": false,
|
|
128
|
+
"deprecateAliases": true
|
|
122
129
|
},
|
|
123
130
|
"codegen-config-path": {
|
|
124
131
|
"name": "codegen-config-path",
|
|
125
132
|
"type": "option",
|
|
126
133
|
"description": "Specify a path to a codegen configuration file. Defaults to `<root>/codegen.ts` if it exists.",
|
|
127
134
|
"required": false,
|
|
128
|
-
"multiple": false
|
|
135
|
+
"multiple": false,
|
|
136
|
+
"deprecateAliases": true
|
|
129
137
|
},
|
|
130
138
|
"force-sfapi-version": {
|
|
131
139
|
"name": "force-sfapi-version",
|
|
132
140
|
"type": "option",
|
|
133
141
|
"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>`.",
|
|
134
142
|
"hidden": true,
|
|
135
|
-
"multiple": false
|
|
143
|
+
"multiple": false,
|
|
144
|
+
"deprecateAliases": true
|
|
136
145
|
},
|
|
137
146
|
"watch": {
|
|
138
147
|
"name": "watch",
|
|
139
148
|
"type": "boolean",
|
|
140
149
|
"description": "Watch the project for changes to update types on file save.",
|
|
141
150
|
"required": false,
|
|
142
|
-
"allowNo": false
|
|
151
|
+
"allowNo": false,
|
|
152
|
+
"deprecateAliases": true
|
|
143
153
|
}
|
|
144
154
|
},
|
|
145
155
|
"args": {}
|
|
@@ -241,12 +251,15 @@
|
|
|
241
251
|
"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.",
|
|
242
252
|
"allowNo": false
|
|
243
253
|
},
|
|
244
|
-
"codegen
|
|
245
|
-
"name": "codegen
|
|
254
|
+
"codegen": {
|
|
255
|
+
"name": "codegen",
|
|
246
256
|
"type": "boolean",
|
|
247
257
|
"description": "Generate types for the Storefront API queries found in your project. It updates the types on file save.",
|
|
248
258
|
"required": false,
|
|
249
|
-
"allowNo": false
|
|
259
|
+
"allowNo": false,
|
|
260
|
+
"aliases": [
|
|
261
|
+
"codegen-unstable"
|
|
262
|
+
]
|
|
250
263
|
},
|
|
251
264
|
"codegen-config-path": {
|
|
252
265
|
"name": "codegen-config-path",
|
|
@@ -255,7 +268,7 @@
|
|
|
255
268
|
"required": false,
|
|
256
269
|
"multiple": false,
|
|
257
270
|
"dependsOn": [
|
|
258
|
-
"codegen
|
|
271
|
+
"codegen"
|
|
259
272
|
]
|
|
260
273
|
},
|
|
261
274
|
"sourcemap": {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "6.0.0",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@ast-grep/napi": "0.11.0",
|
|
36
|
-
"@graphql-codegen/cli": "
|
|
36
|
+
"@graphql-codegen/cli": "5.0.0",
|
|
37
37
|
"@oclif/core": "2.11.7",
|
|
38
|
-
"@shopify/cli-kit": "3.
|
|
39
|
-
"@shopify/hydrogen-codegen": "^0.0
|
|
38
|
+
"@shopify/cli-kit": "3.50.0",
|
|
39
|
+
"@shopify/hydrogen-codegen": "^0.1.0",
|
|
40
40
|
"@shopify/mini-oxygen": "^2.2.3",
|
|
41
|
-
"@shopify/oxygen-cli": "^2.
|
|
41
|
+
"@shopify/oxygen-cli": "^2.3.2",
|
|
42
42
|
"ansi-escapes": "^6.2.0",
|
|
43
43
|
"diff": "^5.1.0",
|
|
44
44
|
"fs-extra": "^11.1.0",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"gunzip-maybe": "^1.4.2",
|
|
47
47
|
"miniflare": "3.20230918.0",
|
|
48
48
|
"prettier": "^2.8.4",
|
|
49
|
+
"semver": "^7.5.3",
|
|
49
50
|
"source-map": "^0.7.4",
|
|
50
51
|
"stack-trace": "^1.0.0-pre2",
|
|
51
52
|
"tar-fs": "^2.1.1",
|
|
@@ -53,11 +54,14 @@
|
|
|
53
54
|
"use-resize-observer": "^9.1.0",
|
|
54
55
|
"ws": "^8.13.0"
|
|
55
56
|
},
|
|
57
|
+
"optionalDependencies": {
|
|
58
|
+
"@parcel/watcher": "^2.3.0"
|
|
59
|
+
},
|
|
56
60
|
"peerDependencies": {
|
|
57
|
-
"@remix-run/dev": "1.
|
|
58
|
-
"@remix-run/react": "1.
|
|
59
|
-
"@shopify/hydrogen
|
|
60
|
-
"@shopify/remix-oxygen": "^
|
|
61
|
+
"@remix-run/dev": "^2.1.0",
|
|
62
|
+
"@remix-run/react": "^2.1.0",
|
|
63
|
+
"@shopify/hydrogen": "2023.10.0",
|
|
64
|
+
"@shopify/remix-oxygen": "^2.0.0"
|
|
61
65
|
},
|
|
62
66
|
"peerDependenciesMeta": {
|
|
63
67
|
"@remix-run/dev": {
|