@nuxt/cli-nightly 0.0.0 → 3.20.0-20250109-193455-6ea36ef

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.
@@ -0,0 +1,250 @@
1
+ import EventEmitter from 'node:events';
2
+ import process from 'node:process';
3
+ import chokidar from 'chokidar';
4
+ import { toNodeListener } from 'h3';
5
+ import { createJiti } from 'jiti';
6
+ import { listen } from 'listhen';
7
+ import { resolve, join, relative } from 'pathe';
8
+ import { debounce } from 'perfect-debounce';
9
+ import { joinURL } from 'ufo';
10
+ import { a as clearBuildDir } from '../shared/cli-nightly.7lipAIIb.mjs';
11
+ import { l as loadKit } from '../shared/cli-nightly.DlcAx0De.mjs';
12
+ import { a as logger } from '../shared/cli-nightly.CnY_9Zvw.mjs';
13
+ import { l as loadNuxtManifest, w as writeNuxtManifest } from '../shared/cli-nightly.CPUttwQp.mjs';
14
+ import 'node:fs';
15
+ import 'node:path';
16
+ import 'citty';
17
+ import 'std-env';
18
+ import 'consola';
19
+ import 'node:url';
20
+ import 'ohash';
21
+
22
+ async function createNuxtDevServer(options, listenOptions) {
23
+ const devServer = new NuxtDevServer(options);
24
+ devServer.listener = await listen(
25
+ devServer.handler,
26
+ listenOptions || {
27
+ port: options.port ?? 0,
28
+ hostname: "127.0.0.1",
29
+ showURL: false
30
+ }
31
+ );
32
+ devServer.listener._url = devServer.listener.url;
33
+ if (options.devContext.proxy?.url) {
34
+ devServer.listener.url = options.devContext.proxy.url;
35
+ }
36
+ if (options.devContext.proxy?.urls) {
37
+ const _getURLs = devServer.listener.getURLs.bind(devServer.listener);
38
+ devServer.listener.getURLs = async () => Array.from(
39
+ /* @__PURE__ */ new Set([...options.devContext.proxy.urls, ...await _getURLs()])
40
+ );
41
+ }
42
+ return devServer;
43
+ }
44
+ const RESTART_RE = /^(?:nuxt\.config\.[a-z0-9]+|\.nuxtignore|\.nuxtrc|\.config\/nuxt(?:\.config)?\.[a-z0-9]+)$/;
45
+ class NuxtDevServer extends EventEmitter {
46
+ constructor(options) {
47
+ super();
48
+ this.options = options;
49
+ this.loadDebounced = debounce(this.load);
50
+ let _initResolve;
51
+ const _initPromise = new Promise((resolve2) => {
52
+ _initResolve = resolve2;
53
+ });
54
+ this.once("ready", () => {
55
+ _initResolve();
56
+ });
57
+ this._jiti = createJiti(options.cwd);
58
+ this.handler = async (req, res) => {
59
+ await _initPromise;
60
+ if (this._handler) {
61
+ this._handler(req, res);
62
+ } else {
63
+ this._renderError(res);
64
+ }
65
+ };
66
+ this.listener = undefined;
67
+ }
68
+ _handler;
69
+ _distWatcher;
70
+ _currentNuxt;
71
+ _loadingMessage;
72
+ _jiti;
73
+ loadDebounced;
74
+ handler;
75
+ listener;
76
+ async _renderError(res, _error) {
77
+ res.statusCode = 503;
78
+ res.setHeader("Content-Type", "text/html");
79
+ const loadingTemplate = this.options.loadingTemplate || this._currentNuxt?.options.devServer.loadingTemplate || await this._jiti.import("@nuxt/ui-templates").then((r) => r.loading).catch(() => {
80
+ }) || ((params) => `<h2>${params.loading}</h2>`);
81
+ res.end(
82
+ loadingTemplate({
83
+ loading: _error?.toString() || this._loadingMessage || "Loading..."
84
+ })
85
+ );
86
+ }
87
+ async init() {
88
+ await this.load();
89
+ await this._watchConfig();
90
+ }
91
+ async load(reload, reason) {
92
+ try {
93
+ await this._load(reload, reason);
94
+ } catch (error) {
95
+ logger.error(`Cannot ${reload ? "restart" : "start"} nuxt: `, error);
96
+ this._handler = undefined;
97
+ this._loadingMessage = "Error while loading Nuxt. Please check console and fix errors.";
98
+ this.emit("loading", this._loadingMessage);
99
+ }
100
+ }
101
+ async _load(reload, reason) {
102
+ const action = reload ? "Restarting" : "Starting";
103
+ this._loadingMessage = `${reason ? `${reason}. ` : ""}${action} Nuxt...`;
104
+ this._handler = undefined;
105
+ this.emit("loading", this._loadingMessage);
106
+ if (reload) {
107
+ logger.info(this._loadingMessage);
108
+ }
109
+ if (this._currentNuxt) {
110
+ await this._currentNuxt.close();
111
+ }
112
+ if (this._distWatcher) {
113
+ await this._distWatcher.close();
114
+ }
115
+ const kit = await loadKit(this.options.cwd);
116
+ this._currentNuxt = await kit.loadNuxt({
117
+ cwd: this.options.cwd,
118
+ dev: true,
119
+ ready: false,
120
+ envName: this.options.envName,
121
+ overrides: {
122
+ logLevel: this.options.logLevel,
123
+ vite: {
124
+ clearScreen: this.options.clear
125
+ },
126
+ nitro: {
127
+ devErrorHandler: (error, event) => {
128
+ this._renderError(event.node.res, error);
129
+ }
130
+ },
131
+ ...this.options.overrides
132
+ }
133
+ });
134
+ if (!process.env.NUXI_DISABLE_VITE_HMR) {
135
+ this._currentNuxt.hooks.hook("vite:extend", ({ config }) => {
136
+ if (config.server) {
137
+ config.server.hmr = {
138
+ protocol: undefined,
139
+ ...config.server.hmr,
140
+ port: undefined,
141
+ host: undefined,
142
+ server: this.listener.server
143
+ };
144
+ }
145
+ });
146
+ }
147
+ this._currentNuxt.hooks.hookOnce("close", () => {
148
+ this.listener.server.removeAllListeners("upgrade");
149
+ });
150
+ if (!reload) {
151
+ const previousManifest = await loadNuxtManifest(
152
+ this._currentNuxt.options.buildDir
153
+ );
154
+ const newManifest = await writeNuxtManifest(this._currentNuxt);
155
+ if (previousManifest && newManifest && previousManifest._hash !== newManifest._hash) {
156
+ await clearBuildDir(this._currentNuxt.options.buildDir);
157
+ }
158
+ }
159
+ await this._currentNuxt.ready();
160
+ const unsub = this._currentNuxt.hooks.hook("restart", async (options) => {
161
+ unsub();
162
+ if (options?.hard) {
163
+ this.emit("restart");
164
+ return;
165
+ }
166
+ await this.load(true);
167
+ });
168
+ if (this._currentNuxt.server && "upgrade" in this._currentNuxt.server) {
169
+ this.listener.server.on(
170
+ "upgrade",
171
+ async (req, socket, head) => {
172
+ const nuxt = this._currentNuxt;
173
+ if (!nuxt)
174
+ return;
175
+ const viteHmrPath = joinURL(
176
+ nuxt.options.app.baseURL.startsWith("./") ? nuxt.options.app.baseURL.slice(1) : nuxt.options.app.baseURL,
177
+ nuxt.options.app.buildAssetsDir
178
+ );
179
+ if (req.url.startsWith(viteHmrPath)) {
180
+ return;
181
+ }
182
+ await nuxt.server.upgrade(req, socket, head);
183
+ }
184
+ );
185
+ }
186
+ await this._currentNuxt.hooks.callHook(
187
+ "listen",
188
+ this.listener.server,
189
+ this.listener
190
+ );
191
+ const addr = this.listener.address;
192
+ this._currentNuxt.options.devServer.host = addr.address;
193
+ this._currentNuxt.options.devServer.port = addr.port;
194
+ this._currentNuxt.options.devServer.url = _getAddressURL(
195
+ addr,
196
+ !!this.listener.https
197
+ );
198
+ this._currentNuxt.options.devServer.https = this.options.devContext.proxy?.https;
199
+ if (this.listener.https && !process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
200
+ logger.warn(
201
+ "You might need `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variable to make https work."
202
+ );
203
+ }
204
+ await Promise.all([
205
+ kit.writeTypes(this._currentNuxt).catch(console.error),
206
+ kit.buildNuxt(this._currentNuxt)
207
+ ]);
208
+ this._distWatcher = chokidar.watch(
209
+ resolve(this._currentNuxt.options.buildDir, "dist"),
210
+ { ignoreInitial: true, depth: 0 }
211
+ );
212
+ this._distWatcher.on("unlinkDir", () => {
213
+ this.loadDebounced(true, ".nuxt/dist directory has been removed");
214
+ });
215
+ this._handler = toNodeListener(this._currentNuxt.server.app);
216
+ this.emit("ready", addr);
217
+ }
218
+ async _watchConfig() {
219
+ const configWatcher = chokidar.watch(
220
+ [this.options.cwd, join(this.options.cwd, ".config")],
221
+ {
222
+ ignoreInitial: true,
223
+ depth: 0
224
+ }
225
+ );
226
+ configWatcher.on("all", (event, _file) => {
227
+ if (event === "all" || event === "ready" || event === "error" || event === "raw") {
228
+ return;
229
+ }
230
+ const file = relative(this.options.cwd, _file);
231
+ if (file === (this.options.dotenv || ".env")) {
232
+ this.emit("restart");
233
+ }
234
+ if (RESTART_RE.test(file)) {
235
+ this.loadDebounced(true, `${file} updated`);
236
+ }
237
+ });
238
+ }
239
+ }
240
+ function _getAddressURL(addr, https) {
241
+ const proto = https ? "https" : "http";
242
+ let host = addr.address.includes(":") ? `[${addr.address}]` : addr.address;
243
+ if (host === "[::]") {
244
+ host = "localhost";
245
+ }
246
+ const port = addr.port || 3e3;
247
+ return `${proto}://${host}:${port}/`;
248
+ }
249
+
250
+ export { createNuxtDevServer };
@@ -0,0 +1,44 @@
1
+ import process from 'node:process';
2
+ import { defineCommand } from 'citty';
3
+ import { resolve } from 'pathe';
4
+ import { x } from 'tinyexec';
5
+ import { c as cwdArgs, b as legacyRootDirArgs, a as logger } from '../shared/cli-nightly.CnY_9Zvw.mjs';
6
+ import 'node:path';
7
+ import 'std-env';
8
+ import 'consola';
9
+ import 'node:url';
10
+
11
+ const devtools = defineCommand({
12
+ meta: {
13
+ name: "devtools",
14
+ description: "Enable or disable devtools in a Nuxt project"
15
+ },
16
+ args: {
17
+ ...cwdArgs,
18
+ command: {
19
+ type: "positional",
20
+ description: "Command to run",
21
+ valueHint: "enable|disable"
22
+ },
23
+ ...legacyRootDirArgs
24
+ },
25
+ async run(ctx) {
26
+ const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
27
+ if (!["enable", "disable"].includes(ctx.args.command)) {
28
+ logger.error(`Unknown command \`${ctx.args.command}\`.`);
29
+ process.exit(1);
30
+ }
31
+ await x(
32
+ "npx",
33
+ ["@nuxt/devtools-wizard@latest", ctx.args.command, cwd],
34
+ {
35
+ nodeOptions: {
36
+ stdio: "inherit",
37
+ cwd
38
+ }
39
+ }
40
+ );
41
+ }
42
+ });
43
+
44
+ export { devtools as default };
@@ -0,0 +1,40 @@
1
+ import { defineCommand } from 'citty';
2
+ import { c as cwdArgs, l as logLevelArgs, e as envNameArgs, b as legacyRootDirArgs, d as dotEnvArgs } from '../shared/cli-nightly.CnY_9Zvw.mjs';
3
+ import buildCommand from './build.mjs';
4
+ import 'node:path';
5
+ import 'node:process';
6
+ import 'std-env';
7
+ import 'consola';
8
+ import 'node:url';
9
+ import 'pathe';
10
+ import '../shared/cli-nightly.CGRrR0sp.mjs';
11
+ import 'consola/utils';
12
+ import 'pkg-types';
13
+ import '../shared/cli-nightly.DlcAx0De.mjs';
14
+ import 'jiti';
15
+ import '../shared/cli-nightly.cDY7IcTr.mjs';
16
+ import '../shared/cli-nightly.7lipAIIb.mjs';
17
+ import 'node:fs';
18
+
19
+ const generate = defineCommand({
20
+ meta: {
21
+ name: "generate",
22
+ description: "Build Nuxt and prerender all routes"
23
+ },
24
+ args: {
25
+ ...cwdArgs,
26
+ ...logLevelArgs,
27
+ ...envNameArgs,
28
+ ...legacyRootDirArgs,
29
+ ...dotEnvArgs
30
+ },
31
+ async run(ctx) {
32
+ ctx.args.prerender = true;
33
+ await buildCommand.run(
34
+ // @ts-expect-error types do not match
35
+ ctx
36
+ );
37
+ }
38
+ });
39
+
40
+ export { generate as default };
@@ -0,0 +1,15 @@
1
+ import { defineCommand } from 'citty';
2
+
3
+ const index = defineCommand({
4
+ meta: {
5
+ name: "module",
6
+ description: "Manage Nuxt modules"
7
+ },
8
+ args: {},
9
+ subCommands: {
10
+ add: () => import('./add2.mjs').then((r) => r.default || r),
11
+ search: () => import('./search.mjs').then((r) => r.default || r)
12
+ }
13
+ });
14
+
15
+ export { index as default };
@@ -0,0 +1,146 @@
1
+ import os from 'node:os';
2
+ import process from 'node:process';
3
+ import { defineCommand } from 'citty';
4
+ import clipboardy from 'clipboardy';
5
+ import { createJiti } from 'jiti';
6
+ import { detectPackageManager } from 'nypm';
7
+ import { resolve } from 'pathe';
8
+ import { readPackageJSON } from 'pkg-types';
9
+ import { splitByCase } from 'scule';
10
+ import { c as cwdArgs, b as legacyRootDirArgs, n as nuxiPkg, a as logger } from '../shared/cli-nightly.CnY_9Zvw.mjs';
11
+ import { t as tryResolveNuxt } from '../shared/cli-nightly.DlcAx0De.mjs';
12
+ import { g as getPackageManagerVersion } from '../shared/cli-nightly.BSm0_9Hr.mjs';
13
+ import 'node:path';
14
+ import 'std-env';
15
+ import 'consola';
16
+ import 'node:url';
17
+ import 'node:child_process';
18
+
19
+ const info = defineCommand({
20
+ meta: {
21
+ name: "info",
22
+ description: "Get information about Nuxt project"
23
+ },
24
+ args: {
25
+ ...cwdArgs,
26
+ ...legacyRootDirArgs
27
+ },
28
+ async run(ctx) {
29
+ const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
30
+ const nuxtConfig = await getNuxtConfig(cwd);
31
+ const { dependencies = {}, devDependencies = {} } = await readPackageJSON(cwd).catch(() => ({}));
32
+ const nuxtPath = await tryResolveNuxt(cwd);
33
+ async function getDepVersion(name) {
34
+ for (const url of [cwd, nuxtPath]) {
35
+ if (!url) {
36
+ continue;
37
+ }
38
+ const pkg = await readPackageJSON(name, { url }).catch(() => null);
39
+ if (pkg) {
40
+ return pkg.version;
41
+ }
42
+ }
43
+ return dependencies[name] || devDependencies[name];
44
+ }
45
+ async function listModules(arr = []) {
46
+ const info = [];
47
+ for (let m of arr) {
48
+ if (Array.isArray(m)) {
49
+ m = m[0];
50
+ }
51
+ const name = normalizeConfigModule(m, cwd);
52
+ if (name) {
53
+ const npmName = name.split("/").splice(0, 2).join("/");
54
+ const v = await getDepVersion(npmName);
55
+ info.push(`\`${v ? `${name}@${v}` : name}\``);
56
+ }
57
+ }
58
+ return info.join(", ");
59
+ }
60
+ const nuxtVersion = await getDepVersion("nuxt") || await getDepVersion("nuxt-nightly") || await getDepVersion("nuxt-edge") || await getDepVersion("nuxt3") || "-";
61
+ const isLegacy = nuxtVersion.startsWith("2");
62
+ const builder = !isLegacy ? nuxtConfig.builder || "-" : nuxtConfig.bridge?.vite ? "vite" : nuxtConfig.buildModules?.includes("nuxt-vite") ? "vite" : "webpack";
63
+ let packageManager = (await detectPackageManager(cwd))?.name;
64
+ if (packageManager) {
65
+ packageManager += `@${getPackageManagerVersion(packageManager)}`;
66
+ }
67
+ const infoObj = {
68
+ OperatingSystem: os.type(),
69
+ NodeVersion: process.version,
70
+ NuxtVersion: nuxtVersion,
71
+ CLIVersion: nuxiPkg.version,
72
+ NitroVersion: await getDepVersion("nitropack"),
73
+ PackageManager: packageManager ?? "unknown",
74
+ Builder: typeof builder === "string" ? builder : "custom",
75
+ UserConfig: Object.keys(nuxtConfig).map((key) => `\`${key}\``).join(", "),
76
+ RuntimeModules: await listModules(nuxtConfig.modules),
77
+ BuildModules: await listModules(nuxtConfig.buildModules || [])
78
+ };
79
+ logger.log("Working directory:", cwd);
80
+ let maxLength = 0;
81
+ const entries = Object.entries(infoObj).map(([key, val]) => {
82
+ const label = splitByCase(key).join(" ");
83
+ if (label.length > maxLength) {
84
+ maxLength = label.length;
85
+ }
86
+ return [label, val || "-"];
87
+ });
88
+ let infoStr = "";
89
+ for (const [label, value] of entries) {
90
+ infoStr += `- ${`${label}: `.padEnd(maxLength + 2)}${value.includes("`") ? value : `\`${value}\``}
91
+ `;
92
+ }
93
+ const copied = await clipboardy.write(infoStr).then(() => true).catch(() => false);
94
+ const isNuxt3 = !isLegacy;
95
+ const isBridge = !isNuxt3 && infoObj.BuildModules.includes("bridge");
96
+ const repo = isBridge ? "nuxt/bridge" : "nuxt/nuxt";
97
+ const log = [
98
+ (isNuxt3 || isBridge) && `\u{1F449} Report an issue: https://github.com/${repo}/issues/new?template=bug-report.yml`,
99
+ (isNuxt3 || isBridge) && `\u{1F449} Suggest an improvement: https://github.com/${repo}/discussions/new`,
100
+ `\u{1F449} Read documentation: ${isNuxt3 || isBridge ? "https://nuxt.com" : "https://v2.nuxt.com"}`
101
+ ].filter(Boolean).join("\n");
102
+ const splitter = "------------------------------";
103
+ logger.log(`Nuxt project info: ${copied ? "(copied to clipboard)" : ""}
104
+
105
+ ${splitter}
106
+ ${infoStr}${splitter}
107
+
108
+ ${log}
109
+ `);
110
+ }
111
+ });
112
+ function normalizeConfigModule(module, rootDir) {
113
+ if (!module) {
114
+ return null;
115
+ }
116
+ if (typeof module === "string") {
117
+ return module.split(rootDir).pop().split("node_modules").pop().replace(/^\//, "");
118
+ }
119
+ if (typeof module === "function") {
120
+ return `${module.name}()`;
121
+ }
122
+ if (Array.isArray(module)) {
123
+ return normalizeConfigModule(module[0], rootDir);
124
+ }
125
+ return null;
126
+ }
127
+ async function getNuxtConfig(rootDir) {
128
+ try {
129
+ const jiti = createJiti(rootDir, {
130
+ interopDefault: true,
131
+ // allow using `~` and `@` in `nuxt.config`
132
+ alias: {
133
+ "~": rootDir,
134
+ "@": rootDir
135
+ }
136
+ });
137
+ globalThis.defineNuxtConfig = (c) => c;
138
+ const result = await jiti.import("./nuxt.config", { default: true });
139
+ delete globalThis.defineNuxtConfig;
140
+ return result;
141
+ } catch {
142
+ return {};
143
+ }
144
+ }
145
+
146
+ export { info as default };
@@ -0,0 +1,189 @@
1
+ import { existsSync } from 'node:fs';
2
+ import process from 'node:process';
3
+ import { defineCommand } from 'citty';
4
+ import { downloadTemplate, startShell } from 'giget';
5
+ import { installDependencies } from 'nypm';
6
+ import { resolve, relative } from 'pathe';
7
+ import { x } from 'tinyexec';
8
+ import { c as cwdArgs, a as logger } from '../shared/cli-nightly.CnY_9Zvw.mjs';
9
+ import 'node:path';
10
+ import 'std-env';
11
+ import 'consola';
12
+ import 'node:url';
13
+
14
+ const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/nuxt/starter/templates/templates";
15
+ const DEFAULT_TEMPLATE_NAME = "v3";
16
+ const init = defineCommand({
17
+ meta: {
18
+ name: "init",
19
+ description: "Initialize a fresh project"
20
+ },
21
+ args: {
22
+ ...cwdArgs,
23
+ dir: {
24
+ type: "positional",
25
+ description: "Project directory",
26
+ default: ""
27
+ },
28
+ template: {
29
+ type: "string",
30
+ alias: "t",
31
+ description: "Template name"
32
+ },
33
+ force: {
34
+ type: "boolean",
35
+ alias: "f",
36
+ description: "Override existing directory"
37
+ },
38
+ offline: {
39
+ type: "boolean",
40
+ description: "Force offline mode"
41
+ },
42
+ preferOffline: {
43
+ type: "boolean",
44
+ description: "Prefer offline mode"
45
+ },
46
+ install: {
47
+ type: "boolean",
48
+ default: true,
49
+ description: "Skip installing dependencies"
50
+ },
51
+ gitInit: {
52
+ type: "boolean",
53
+ description: "Initialize git repository"
54
+ },
55
+ shell: {
56
+ type: "boolean",
57
+ description: "Start shell after installation in project directory"
58
+ },
59
+ packageManager: {
60
+ type: "string",
61
+ description: "Package manager choice (npm, pnpm, yarn, bun)"
62
+ }
63
+ },
64
+ async run(ctx) {
65
+ const cwd = resolve(ctx.args.cwd);
66
+ const templateName = ctx.args.template || DEFAULT_TEMPLATE_NAME;
67
+ if (typeof templateName !== "string") {
68
+ logger.error("Please specify a template!");
69
+ process.exit(1);
70
+ }
71
+ let templateDownloadPath = resolve(cwd, ctx.args.dir);
72
+ let shouldForce = Boolean(ctx.args.force);
73
+ const shouldVerify = !shouldForce && existsSync(templateDownloadPath);
74
+ if (shouldVerify) {
75
+ const selectedAction = await logger.prompt(
76
+ `The directory \`${templateDownloadPath}\` already exists. What would you like to do?`,
77
+ {
78
+ type: "select",
79
+ options: ["Override its contents", "Select different directory", "Abort"]
80
+ }
81
+ );
82
+ switch (selectedAction) {
83
+ case "Override its contents":
84
+ shouldForce = true;
85
+ break;
86
+ case "Select different directory": {
87
+ const dir = await logger.prompt("Please specify a different directory:", {
88
+ type: "text"
89
+ });
90
+ if (dir && typeof dir === "string") {
91
+ templateDownloadPath = resolve(cwd, dir);
92
+ }
93
+ break;
94
+ }
95
+ // 'Abort' or Ctrl+C
96
+ default:
97
+ logger.info("Initialization aborted.");
98
+ process.exit(1);
99
+ }
100
+ }
101
+ let template;
102
+ try {
103
+ template = await downloadTemplate(templateName, {
104
+ dir: templateDownloadPath,
105
+ force: shouldForce,
106
+ offline: Boolean(ctx.args.offline),
107
+ preferOffline: Boolean(ctx.args.preferOffline),
108
+ registry: process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY
109
+ });
110
+ } catch (err) {
111
+ if (process.env.DEBUG) {
112
+ throw err;
113
+ }
114
+ logger.error(err.toString());
115
+ process.exit(1);
116
+ }
117
+ const packageManagerOptions = [
118
+ "npm",
119
+ "pnpm",
120
+ "yarn",
121
+ "bun",
122
+ "deno"
123
+ ];
124
+ const packageManagerArg = ctx.args.packageManager;
125
+ const selectedPackageManager = packageManagerOptions.includes(
126
+ packageManagerArg
127
+ ) ? packageManagerArg : await logger.prompt("Which package manager would you like to use?", {
128
+ type: "select",
129
+ options: packageManagerOptions
130
+ });
131
+ if (ctx.args.install === false) {
132
+ logger.info("Skipping install dependencies step.");
133
+ } else {
134
+ logger.start("Installing dependencies...");
135
+ try {
136
+ await installDependencies({
137
+ cwd: template.dir,
138
+ packageManager: {
139
+ name: selectedPackageManager,
140
+ command: selectedPackageManager
141
+ }
142
+ });
143
+ } catch (err) {
144
+ if (process.env.DEBUG) {
145
+ throw err;
146
+ }
147
+ logger.error(err.toString());
148
+ process.exit(1);
149
+ }
150
+ logger.success("Installation completed.");
151
+ }
152
+ if (ctx.args.gitInit === undefined) {
153
+ ctx.args.gitInit = await logger.prompt("Initialize git repository?", {
154
+ type: "confirm"
155
+ });
156
+ }
157
+ if (ctx.args.gitInit) {
158
+ logger.info("Initializing git repository...\n");
159
+ try {
160
+ await x("git", ["init", template.dir], {
161
+ throwOnError: true,
162
+ nodeOptions: {
163
+ stdio: "inherit"
164
+ }
165
+ });
166
+ } catch (err) {
167
+ logger.warn(`Failed to initialize git repository: ${err}`);
168
+ }
169
+ }
170
+ logger.log(
171
+ `
172
+ \u2728 Nuxt project has been created with the \`${template.name}\` template. Next steps:`
173
+ );
174
+ const relativeTemplateDir = relative(process.cwd(), template.dir) || ".";
175
+ const runCmd = selectedPackageManager === "deno" ? "task" : "run";
176
+ const nextSteps = [
177
+ !ctx.args.shell && relativeTemplateDir.length > 1 && `\`cd ${relativeTemplateDir}\``,
178
+ `Start development server with \`${selectedPackageManager} ${runCmd} dev\``
179
+ ].filter(Boolean);
180
+ for (const step of nextSteps) {
181
+ logger.log(` \u203A ${step}`);
182
+ }
183
+ if (ctx.args.shell) {
184
+ startShell(template.dir);
185
+ }
186
+ }
187
+ });
188
+
189
+ export { init as default };