create-fumadocs-app 16.2.6 → 16.2.7
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.
|
@@ -12,7 +12,7 @@ function nextUseSrc() {
|
|
|
12
12
|
...info,
|
|
13
13
|
appDir: "src",
|
|
14
14
|
rename: (file) => {
|
|
15
|
-
if (isRelative(path.join(this.dest, "app"), file) || isRelative(path.join(this.dest, "lib"), file) || isRelative(path.join(this.dest, "components"), file)) return path.join(this.dest, "src", path.relative(this.dest, file));
|
|
15
|
+
if (isRelative(path.join(this.dest, "app"), file) || isRelative(path.join(this.dest, "lib"), file) || isRelative(path.join(this.dest, "components"), file) || isRootConventionFile(this.dest, file)) return path.join(this.dest, "src", path.relative(this.dest, file));
|
|
16
16
|
return file;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -27,6 +27,20 @@ function nextUseSrc() {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Next.js only reads these files from the same level as `app`, so they must move into `src` too.
|
|
32
|
+
*/
|
|
33
|
+
const rootConventionFiles = [
|
|
34
|
+
"proxy",
|
|
35
|
+
"middleware",
|
|
36
|
+
"instrumentation",
|
|
37
|
+
"instrumentation-client"
|
|
38
|
+
];
|
|
39
|
+
function isRootConventionFile(dest, file) {
|
|
40
|
+
const relative = path.relative(dest, file);
|
|
41
|
+
if (relative.includes(path.sep)) return false;
|
|
42
|
+
return rootConventionFiles.includes(relative.replace(/\.(ts|js|mts|mjs)$/, ""));
|
|
43
|
+
}
|
|
30
44
|
function isRelative(dir, file) {
|
|
31
45
|
return !path.relative(dir, file).startsWith(`..${path.sep}`);
|
|
32
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-use-src.js","names":[],"sources":["../../src/plugins/next-use-src.ts"],"sourcesContent":["import { TemplatePlugin } from '@/index';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\n\n/**\n * Use `src` for app directory\n */\nexport function nextUseSrc(): TemplatePlugin {\n return {\n template(info) {\n if (!info.value.startsWith('+next')) return;\n\n return {\n ...info,\n appDir: 'src',\n rename: (file) => {\n if (\n isRelative(path.join(this.dest, 'app'), file) ||\n isRelative(path.join(this.dest, 'lib'), file) ||\n isRelative(path.join(this.dest, 'components'), file)\n ) {\n return path.join(this.dest, 'src', path.relative(this.dest, file));\n }\n\n return file;\n },\n };\n },\n // update tsconfig.json for src dir\n async afterWrite() {\n if (!this.template.value.startsWith('+next')) return;\n\n const tsconfigPath = path.join(this.dest, 'tsconfig.json');\n const content = await fs.readFile(tsconfigPath, 'utf-8');\n const config = JSON.parse(content);\n\n if (config.compilerOptions?.paths) {\n Object.assign(config.compilerOptions.paths, {\n '@/*': ['./src/*'],\n });\n }\n\n await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));\n },\n };\n}\n\nfunction isRelative(dir: string, file: string) {\n return !path.relative(dir, file).startsWith(`..${path.sep}`);\n}\n"],"mappings":";;;;;;AAOA,SAAgB,aAA6B;CAC3C,OAAO;EACL,SAAS,MAAM;GACb,IAAI,CAAC,KAAK,MAAM,WAAW,OAAO,GAAG;GAErC,OAAO;IACL,GAAG;IACH,QAAQ;IACR,SAAS,SAAS;KAChB,IACE,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK,GAAG,IAAI,KAC5C,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK,GAAG,IAAI,KAC5C,WAAW,KAAK,KAAK,KAAK,MAAM,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"next-use-src.js","names":[],"sources":["../../src/plugins/next-use-src.ts"],"sourcesContent":["import { TemplatePlugin } from '@/index';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\n\n/**\n * Use `src` for app directory\n */\nexport function nextUseSrc(): TemplatePlugin {\n return {\n template(info) {\n if (!info.value.startsWith('+next')) return;\n\n return {\n ...info,\n appDir: 'src',\n rename: (file) => {\n if (\n isRelative(path.join(this.dest, 'app'), file) ||\n isRelative(path.join(this.dest, 'lib'), file) ||\n isRelative(path.join(this.dest, 'components'), file) ||\n isRootConventionFile(this.dest, file)\n ) {\n return path.join(this.dest, 'src', path.relative(this.dest, file));\n }\n\n return file;\n },\n };\n },\n // update tsconfig.json for src dir\n async afterWrite() {\n if (!this.template.value.startsWith('+next')) return;\n\n const tsconfigPath = path.join(this.dest, 'tsconfig.json');\n const content = await fs.readFile(tsconfigPath, 'utf-8');\n const config = JSON.parse(content);\n\n if (config.compilerOptions?.paths) {\n Object.assign(config.compilerOptions.paths, {\n '@/*': ['./src/*'],\n });\n }\n\n await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));\n },\n };\n}\n\n/**\n * Next.js only reads these files from the same level as `app`, so they must move into `src` too.\n */\nconst rootConventionFiles = ['proxy', 'middleware', 'instrumentation', 'instrumentation-client'];\n\nfunction isRootConventionFile(dest: string, file: string) {\n const relative = path.relative(dest, file);\n if (relative.includes(path.sep)) return false;\n\n return rootConventionFiles.includes(relative.replace(/\\.(ts|js|mts|mjs)$/, ''));\n}\n\nfunction isRelative(dir: string, file: string) {\n return !path.relative(dir, file).startsWith(`..${path.sep}`);\n}\n"],"mappings":";;;;;;AAOA,SAAgB,aAA6B;CAC3C,OAAO;EACL,SAAS,MAAM;GACb,IAAI,CAAC,KAAK,MAAM,WAAW,OAAO,GAAG;GAErC,OAAO;IACL,GAAG;IACH,QAAQ;IACR,SAAS,SAAS;KAChB,IACE,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK,GAAG,IAAI,KAC5C,WAAW,KAAK,KAAK,KAAK,MAAM,KAAK,GAAG,IAAI,KAC5C,WAAW,KAAK,KAAK,KAAK,MAAM,YAAY,GAAG,IAAI,KACnD,qBAAqB,KAAK,MAAM,IAAI,GAEpC,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,KAAK,SAAS,KAAK,MAAM,IAAI,CAAC;KAGnE,OAAO;IACT;GACF;EACF;EAEA,MAAM,aAAa;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