@farm.js/cli 0.1.0-beta.26 → 0.1.0-beta.28
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/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1029,6 +1029,7 @@ async function generateFarmArtifacts(options = {}) {
|
|
|
1029
1029
|
layers: resolvedConfig.layers,
|
|
1030
1030
|
extraRoutes,
|
|
1031
1031
|
suppressLintOnLink: resolvedConfig.suppressLintOnLink,
|
|
1032
|
+
componentExtensions: resolvedConfig.renderer.componentExtensions,
|
|
1032
1033
|
i18nConfig: resolvedConfig.i18n,
|
|
1033
1034
|
check: options.check
|
|
1034
1035
|
});
|
|
@@ -1613,6 +1614,7 @@ const ROUTE_EXTENSIONS$1 = [
|
|
|
1613
1614
|
"tsx",
|
|
1614
1615
|
"js",
|
|
1615
1616
|
"jsx",
|
|
1617
|
+
"vue",
|
|
1616
1618
|
"md",
|
|
1617
1619
|
"mdx"
|
|
1618
1620
|
];
|
|
@@ -1828,10 +1830,11 @@ async function createProjectReport(root, options) {
|
|
|
1828
1830
|
function applySafeProjectFixes(root, config, checks) {
|
|
1829
1831
|
const fixes = [];
|
|
1830
1832
|
if (checks.some((check) => check.code === "ROOT_LAYOUT_MISSING")) {
|
|
1831
|
-
const
|
|
1833
|
+
const rendererExtension = config.renderer.componentExtensions?.[0] || ".tsx";
|
|
1834
|
+
const layoutPath = node_path.default.join(config.root, config.srcDir, "app", `layout${rendererExtension}`);
|
|
1832
1835
|
if (!(0, node_fs.existsSync)(layoutPath)) {
|
|
1833
1836
|
(0, node_fs.mkdirSync)(node_path.default.dirname(layoutPath), { recursive: true });
|
|
1834
|
-
(0, node_fs.writeFileSync)(layoutPath, `import type { ReactNode } from "react";\n\nexport default function RootLayout({ children }: { children: ReactNode }) {\n return (\n <html lang="en">\n <body>{children}</body>\n </html>\n );\n}\n`, {
|
|
1837
|
+
(0, node_fs.writeFileSync)(layoutPath, config.renderer.name === "vue" ? `<script setup lang="ts">\ndefineOptions({ inheritAttrs: false });\n<\/script>\n\n<template>\n <slot />\n</template>\n` : config.renderer.name === "solid" ? `import type { ParentProps } from "solid-js";\n\nexport default function RootLayout(props: ParentProps) {\n return <>{props.children}</>;\n}\n` : `import type { ReactNode } from "react";\n\nexport default function RootLayout({ children }: { children: ReactNode }) {\n return (\n <html lang="en">\n <body>{children}</body>\n </html>\n );\n}\n`, {
|
|
1835
1838
|
encoding: "utf8",
|
|
1836
1839
|
flag: "wx"
|
|
1837
1840
|
});
|
|
@@ -1903,7 +1906,7 @@ function collectPackageCheck(root, checks) {
|
|
|
1903
1906
|
function collectRouterChecks(config, checks) {
|
|
1904
1907
|
const sources = (0, _farm_js_core.getFarmSourceRoots)(config);
|
|
1905
1908
|
const appDirectories = sources.map((source) => node_path.default.join(source.root, source.srcDir, "app"));
|
|
1906
|
-
const hasPages = appDirectories.some((directory) => containsFile(directory, /^page\.(?:ts|tsx|js|jsx|md|mdx)$/));
|
|
1909
|
+
const hasPages = appDirectories.some((directory) => containsFile(directory, /^page\.(?:ts|tsx|js|jsx|vue|md|mdx)$/));
|
|
1907
1910
|
const hasProgrammaticRoutes = sources.some((source) => ROUTE_EXTENSIONS$1.some((extension) => (0, node_fs.existsSync)(node_path.default.join(source.root, source.srcDir, `farm.routes.${extension}`))));
|
|
1908
1911
|
checks.push(hasPages || hasProgrammaticRoutes ? {
|
|
1909
1912
|
status: "pass",
|
|
@@ -1918,6 +1921,7 @@ function collectRouterChecks(config, checks) {
|
|
|
1918
1921
|
action: `Add ${config.srcDir}/app/page.tsx or ${config.srcDir}/farm.routes.tsx.`
|
|
1919
1922
|
});
|
|
1920
1923
|
const hasRootLayout = appDirectories.some((directory) => ROUTE_EXTENSIONS$1.some((extension) => (0, node_fs.existsSync)(node_path.default.join(directory, `layout.${extension}`))));
|
|
1924
|
+
const suggestedLayoutExtension = config.renderer.componentExtensions?.[0] || ".tsx";
|
|
1921
1925
|
checks.push(hasRootLayout ? {
|
|
1922
1926
|
status: "pass",
|
|
1923
1927
|
code: "ROOT_LAYOUT_READY",
|
|
@@ -1928,7 +1932,7 @@ function collectRouterChecks(config, checks) {
|
|
|
1928
1932
|
code: "ROOT_LAYOUT_MISSING",
|
|
1929
1933
|
title: "Root layout is missing",
|
|
1930
1934
|
message: "The application has no shared root layout.",
|
|
1931
|
-
action: `Add ${config.srcDir}/app/layout
|
|
1935
|
+
action: `Add ${config.srcDir}/app/layout${suggestedLayoutExtension}.`
|
|
1932
1936
|
});
|
|
1933
1937
|
}
|
|
1934
1938
|
function collectDeploymentChecks(config, userConfig, checks) {
|
|
@@ -2061,6 +2065,7 @@ const ROUTE_EXTENSIONS = [
|
|
|
2061
2065
|
"ts",
|
|
2062
2066
|
"jsx",
|
|
2063
2067
|
"js",
|
|
2068
|
+
"vue",
|
|
2064
2069
|
"mdx",
|
|
2065
2070
|
"md"
|
|
2066
2071
|
];
|
|
@@ -2170,7 +2175,7 @@ function discoverMatchingPages(config, pathname) {
|
|
|
2170
2175
|
for (const [priority, source] of (0, _farm_js_core.getFarmSourceRoots)(config).entries()) {
|
|
2171
2176
|
const appDirectory = node_path.default.join(source.root, source.srcDir, "app");
|
|
2172
2177
|
if ((0, node_fs.existsSync)(appDirectory)) for (const filePath of walkFiles(appDirectory)) {
|
|
2173
|
-
if (!/^page\.(?:tsx?|jsx?|mdx?)$/.test(node_path.default.basename(filePath))) continue;
|
|
2178
|
+
if (!/^page\.(?:tsx?|jsx?|vue|mdx?)$/.test(node_path.default.basename(filePath))) continue;
|
|
2174
2179
|
const relativeDirectory = node_path.default.relative(appDirectory, node_path.default.dirname(filePath));
|
|
2175
2180
|
if (relativeDirectory.split(node_path.default.sep).includes("api") || isRouteSlotDirectory(relativeDirectory)) continue;
|
|
2176
2181
|
const pattern = directoryToRoutePattern(relativeDirectory);
|