Repository navigation
Expand file tree
/
Copy pathnuxt.ts
More file actions
87 lines (82 loc) · 2.36 KB
/
Copy pathnuxt.ts
File metadata and controls
87 lines (82 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { PACKAGE_MANAGER } from "../const.ts";
import deps from "../json/deps.json" with { type: "json" };
import { PACKAGE_VERSION, readTemplate } from "../lib.ts";
import type { PackageManager, WebFrameworkDescription } from "../types.ts";
import { defaultDenoDependencies, defaultDevDependencies } from "./const.ts";
import {
getInstruction,
getNodeBunDevToolTasks,
getTestDependencies,
getTestTask,
} from "./utils.ts";
const nuxtDescription: WebFrameworkDescription = {
label: "Nuxt",
packageManagers: PACKAGE_MANAGER,
defaultPort: 3000,
init: async ({ packageManager: pm, testMode }) => ({
command: Array.from(getInitCommand(pm)),
dependencies: getDeps(pm),
devDependencies: {
...defaultDevDependencies,
"typescript": deps["npm:typescript"],
"@types/node": deps["npm:@types/node@25"],
...getTestDependencies(pm),
},
federationFile: "server/federation.ts",
loggingFile: "server/logging.ts",
loggingTemplate: "nuxt/server/logging.ts",
testFile: "scripts/smoke.test.ts",
format: {
ignorePatterns: [".output/**"],
},
env: testMode ? { HOST: "127.0.0.1" } : {} as Record<string, string>,
files: {
"nuxt.config.ts": await readTemplate("nuxt/nuxt.config.ts"),
"server/plugins/logging.ts": await readTemplate(
"nuxt/server/plugins/logging.ts",
),
},
tasks: { ...getNodeBunDevToolTasks(pm), test: getTestTask(pm) },
instruction: getInstruction(pm, 3000),
}),
};
export default nuxtDescription;
function* getInitCommand(pm: PackageManager) {
yield* getNuxtInitCommand(pm);
yield* [
"init",
".",
"--template",
"minimal",
"--no-install",
"--force",
"--packageManager",
pm,
"--no-gitInit",
"--no-modules",
"&&",
"rm",
"nuxt.config.ts",
];
}
/**
* Returns the shell command array to scaffold a new Nuxt project
* in the current directory using the given package manager.
*/
const getNuxtInitCommand = (pm: PackageManager): string[] =>
pm === "bun"
? ["bunx", "nuxi"]
: pm === "deno"
? ["deno", "-A", "npm:nuxi@latest"]
: pm === "npm"
? ["npx", "nuxi"]
: [pm, "dlx", "nuxi"];
const getDeps = (pm: PackageManager): Record<string, string> =>
pm !== "deno"
? {
"@fedify/nuxt": PACKAGE_VERSION,
}
: {
...defaultDenoDependencies,
"@fedify/nuxt": PACKAGE_VERSION,
};