@farm.js/cli 0.1.0-beta.25 → 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/bin/farm.js +4 -1
- 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.mjs
CHANGED
|
@@ -1028,6 +1028,7 @@ async function generateFarmArtifacts(options = {}) {
|
|
|
1028
1028
|
layers: resolvedConfig.layers,
|
|
1029
1029
|
extraRoutes,
|
|
1030
1030
|
suppressLintOnLink: resolvedConfig.suppressLintOnLink,
|
|
1031
|
+
componentExtensions: resolvedConfig.renderer.componentExtensions,
|
|
1031
1032
|
i18nConfig: resolvedConfig.i18n,
|
|
1032
1033
|
check: options.check
|
|
1033
1034
|
});
|
|
@@ -1612,6 +1613,7 @@ const ROUTE_EXTENSIONS$1 = [
|
|
|
1612
1613
|
"tsx",
|
|
1613
1614
|
"js",
|
|
1614
1615
|
"jsx",
|
|
1616
|
+
"vue",
|
|
1615
1617
|
"md",
|
|
1616
1618
|
"mdx"
|
|
1617
1619
|
];
|
|
@@ -1827,10 +1829,11 @@ async function createProjectReport(root, options) {
|
|
|
1827
1829
|
function applySafeProjectFixes(root, config, checks) {
|
|
1828
1830
|
const fixes = [];
|
|
1829
1831
|
if (checks.some((check) => check.code === "ROOT_LAYOUT_MISSING")) {
|
|
1830
|
-
const
|
|
1832
|
+
const rendererExtension = config.renderer.componentExtensions?.[0] || ".tsx";
|
|
1833
|
+
const layoutPath = path.join(config.root, config.srcDir, "app", `layout${rendererExtension}`);
|
|
1831
1834
|
if (!existsSync(layoutPath)) {
|
|
1832
1835
|
mkdirSync(path.dirname(layoutPath), { recursive: true });
|
|
1833
|
-
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`, {
|
|
1836
|
+
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`, {
|
|
1834
1837
|
encoding: "utf8",
|
|
1835
1838
|
flag: "wx"
|
|
1836
1839
|
});
|
|
@@ -1902,7 +1905,7 @@ function collectPackageCheck(root, checks) {
|
|
|
1902
1905
|
function collectRouterChecks(config, checks) {
|
|
1903
1906
|
const sources = getFarmSourceRoots(config);
|
|
1904
1907
|
const appDirectories = sources.map((source) => path.join(source.root, source.srcDir, "app"));
|
|
1905
|
-
const hasPages = appDirectories.some((directory) => containsFile(directory, /^page\.(?:ts|tsx|js|jsx|md|mdx)$/));
|
|
1908
|
+
const hasPages = appDirectories.some((directory) => containsFile(directory, /^page\.(?:ts|tsx|js|jsx|vue|md|mdx)$/));
|
|
1906
1909
|
const hasProgrammaticRoutes = sources.some((source) => ROUTE_EXTENSIONS$1.some((extension) => existsSync(path.join(source.root, source.srcDir, `farm.routes.${extension}`))));
|
|
1907
1910
|
checks.push(hasPages || hasProgrammaticRoutes ? {
|
|
1908
1911
|
status: "pass",
|
|
@@ -1917,6 +1920,7 @@ function collectRouterChecks(config, checks) {
|
|
|
1917
1920
|
action: `Add ${config.srcDir}/app/page.tsx or ${config.srcDir}/farm.routes.tsx.`
|
|
1918
1921
|
});
|
|
1919
1922
|
const hasRootLayout = appDirectories.some((directory) => ROUTE_EXTENSIONS$1.some((extension) => existsSync(path.join(directory, `layout.${extension}`))));
|
|
1923
|
+
const suggestedLayoutExtension = config.renderer.componentExtensions?.[0] || ".tsx";
|
|
1920
1924
|
checks.push(hasRootLayout ? {
|
|
1921
1925
|
status: "pass",
|
|
1922
1926
|
code: "ROOT_LAYOUT_READY",
|
|
@@ -1927,7 +1931,7 @@ function collectRouterChecks(config, checks) {
|
|
|
1927
1931
|
code: "ROOT_LAYOUT_MISSING",
|
|
1928
1932
|
title: "Root layout is missing",
|
|
1929
1933
|
message: "The application has no shared root layout.",
|
|
1930
|
-
action: `Add ${config.srcDir}/app/layout
|
|
1934
|
+
action: `Add ${config.srcDir}/app/layout${suggestedLayoutExtension}.`
|
|
1931
1935
|
});
|
|
1932
1936
|
}
|
|
1933
1937
|
function collectDeploymentChecks(config, userConfig, checks) {
|
|
@@ -2060,6 +2064,7 @@ const ROUTE_EXTENSIONS = [
|
|
|
2060
2064
|
"ts",
|
|
2061
2065
|
"jsx",
|
|
2062
2066
|
"js",
|
|
2067
|
+
"vue",
|
|
2063
2068
|
"mdx",
|
|
2064
2069
|
"md"
|
|
2065
2070
|
];
|
|
@@ -2169,7 +2174,7 @@ function discoverMatchingPages(config, pathname) {
|
|
|
2169
2174
|
for (const [priority, source] of getFarmSourceRoots(config).entries()) {
|
|
2170
2175
|
const appDirectory = path.join(source.root, source.srcDir, "app");
|
|
2171
2176
|
if (existsSync(appDirectory)) for (const filePath of walkFiles(appDirectory)) {
|
|
2172
|
-
if (!/^page\.(?:tsx?|jsx?|mdx?)$/.test(path.basename(filePath))) continue;
|
|
2177
|
+
if (!/^page\.(?:tsx?|jsx?|vue|mdx?)$/.test(path.basename(filePath))) continue;
|
|
2173
2178
|
const relativeDirectory = path.relative(appDirectory, path.dirname(filePath));
|
|
2174
2179
|
if (relativeDirectory.split(path.sep).includes("api") || isRouteSlotDirectory(relativeDirectory)) continue;
|
|
2175
2180
|
const pattern = directoryToRoutePattern(relativeDirectory);
|