@nuxt/cli-nightly 3.29.4-20251009-171833-0915ec9 → 3.29.4-20251021-190716-bbf70fc

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.
Files changed (69) hide show
  1. package/dist/_shared-C3vB2YLc.mjs +42 -0
  2. package/dist/_utils-DTrPahho.mjs +29 -0
  3. package/dist/add-BGMHIn5L.mjs +333 -0
  4. package/dist/add-CRBwIlDF.mjs +298 -0
  5. package/dist/add-hFFIzkcy.mjs +10 -0
  6. package/dist/analyze-CUKAi_IN.mjs +115 -0
  7. package/dist/banner-CqfM_0Qo.mjs +55 -0
  8. package/dist/build-BSxJLNs_.mjs +78 -0
  9. package/dist/build-KNIBU0AI.mjs +9 -0
  10. package/dist/cleanup-8GRakeLu.mjs +31 -0
  11. package/dist/dev/index.d.mts +87 -83
  12. package/dist/dev/index.mjs +7 -23
  13. package/dist/dev-Bs_0dzlh.mjs +591 -0
  14. package/dist/dev-CnQwDUaD.mjs +7 -0
  15. package/dist/dev-L7lhoThJ.mjs +438 -0
  16. package/dist/dev-child-CSiX6Uyv.mjs +37 -0
  17. package/dist/devtools-BLGzUSNU.mjs +44 -0
  18. package/dist/env-Dz4K_NkM.mjs +12 -0
  19. package/dist/fs-ewAp6tjM.mjs +40 -0
  20. package/dist/generate-CGy3-x2K.mjs +35 -0
  21. package/dist/index.d.mts +9 -18
  22. package/dist/index.mjs +129 -8
  23. package/dist/info-BDdsghj1.mjs +120 -0
  24. package/dist/init-_n9DXzzY.mjs +336 -0
  25. package/dist/kit-xFxVGu6d.mjs +37 -0
  26. package/dist/logger-Dk0gkCkX.mjs +7 -0
  27. package/dist/module-CqBrGD-s.mjs +17 -0
  28. package/dist/nuxt-Cc9ZTk7m.mjs +44 -0
  29. package/dist/packageManagers-DbVB5cXf.mjs +9 -0
  30. package/dist/prepare-B0KOhO-L.mjs +7 -0
  31. package/dist/prepare-xI978yFg.mjs +49 -0
  32. package/dist/preview-C5fNqrC6.mjs +109 -0
  33. package/dist/search-DCyXfxzn.mjs +113 -0
  34. package/dist/test-CBt1emEB.mjs +55 -0
  35. package/dist/typecheck-DCWe7Iej.mjs +102 -0
  36. package/dist/upgrade-BMSFcUWJ.mjs +184 -0
  37. package/dist/versions-CSy_3o_-.mjs +18 -0
  38. package/package.json +13 -13
  39. package/dist/chunks/add.mjs +0 -381
  40. package/dist/chunks/add2.mjs +0 -319
  41. package/dist/chunks/analyze.mjs +0 -139
  42. package/dist/chunks/build.mjs +0 -94
  43. package/dist/chunks/cleanup.mjs +0 -34
  44. package/dist/chunks/dev-child.mjs +0 -38
  45. package/dist/chunks/dev.mjs +0 -709
  46. package/dist/chunks/devtools.mjs +0 -46
  47. package/dist/chunks/generate.mjs +0 -45
  48. package/dist/chunks/index.mjs +0 -507
  49. package/dist/chunks/index2.mjs +0 -15
  50. package/dist/chunks/info.mjs +0 -150
  51. package/dist/chunks/init.mjs +0 -413
  52. package/dist/chunks/prepare.mjs +0 -57
  53. package/dist/chunks/preview.mjs +0 -131
  54. package/dist/chunks/search.mjs +0 -114
  55. package/dist/chunks/test.mjs +0 -62
  56. package/dist/chunks/typecheck.mjs +0 -85
  57. package/dist/chunks/upgrade.mjs +0 -214
  58. package/dist/dev/index.d.ts +0 -94
  59. package/dist/index.d.ts +0 -23
  60. package/dist/shared/cli-nightly.B9AmABr3.mjs +0 -5
  61. package/dist/shared/cli-nightly.BRlCc6aT.mjs +0 -204
  62. package/dist/shared/cli-nightly.BSm0_9Hr.mjs +0 -7
  63. package/dist/shared/cli-nightly.Bu_9IHj2.mjs +0 -51
  64. package/dist/shared/cli-nightly.Cr-OCgdO.mjs +0 -37
  65. package/dist/shared/cli-nightly.DHenkA1C.mjs +0 -14
  66. package/dist/shared/cli-nightly.DPmMxQ6h.mjs +0 -33
  67. package/dist/shared/cli-nightly.DS8guhZv.mjs +0 -52
  68. package/dist/shared/cli-nightly.DkO5RR_e.mjs +0 -14
  69. package/dist/shared/cli-nightly.qKvs7FJ2.mjs +0 -36
@@ -1,150 +0,0 @@
1
- import os from 'node:os';
2
- import process from 'node:process';
3
- import { defineCommand } from 'citty';
4
- import clipboardy from 'clipboardy';
5
- import { detectPackageManager } from 'nypm';
6
- import { resolve } from 'pathe';
7
- import { readPackageJSON } from 'pkg-types';
8
- import { splitByCase } from 'scule';
9
- import { isMinimal } from 'std-env';
10
- import { t as tryResolveNuxt } from '../shared/cli-nightly.qKvs7FJ2.mjs';
11
- import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
12
- import { g as getPackageManagerVersion } from '../shared/cli-nightly.BSm0_9Hr.mjs';
13
- import { l as legacyRootDirArgs, c as cwdArgs } from '../shared/cli-nightly.BRlCc6aT.mjs';
14
- import 'node:url';
15
- import 'exsolve';
16
- import 'consola';
17
- import 'node:child_process';
18
- import 'node:path';
19
-
20
- const version = "3.29.4-20251009-171814-0915ec9";
21
-
22
- const info = defineCommand({
23
- meta: {
24
- name: "info",
25
- description: "Get information about Nuxt project"
26
- },
27
- args: {
28
- ...cwdArgs,
29
- ...legacyRootDirArgs
30
- },
31
- async run(ctx) {
32
- const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
33
- const nuxtConfig = await getNuxtConfig(cwd);
34
- const { dependencies = {}, devDependencies = {} } = await readPackageJSON(cwd).catch(() => ({}));
35
- const nuxtPath = tryResolveNuxt(cwd);
36
- async function getDepVersion(name) {
37
- for (const url of [cwd, nuxtPath]) {
38
- if (!url) {
39
- continue;
40
- }
41
- const pkg = await readPackageJSON(name, { url }).catch(() => null);
42
- if (pkg) {
43
- return pkg.version;
44
- }
45
- }
46
- return dependencies[name] || devDependencies[name];
47
- }
48
- async function listModules(arr = []) {
49
- const info = [];
50
- for (let m of arr) {
51
- if (Array.isArray(m)) {
52
- m = m[0];
53
- }
54
- const name = normalizeConfigModule(m, cwd);
55
- if (name) {
56
- const npmName = name.split("/").splice(0, 2).join("/");
57
- const v = await getDepVersion(npmName);
58
- info.push(`\`${v ? `${name}@${v}` : name}\``);
59
- }
60
- }
61
- return info.join(", ");
62
- }
63
- const nuxtVersion = await getDepVersion("nuxt") || await getDepVersion("nuxt-nightly") || await getDepVersion("nuxt-edge") || await getDepVersion("nuxt3") || "-";
64
- const isLegacy = nuxtVersion.startsWith("2");
65
- const builder = !isLegacy ? nuxtConfig.builder || "-" : nuxtConfig.bridge?.vite ? "vite" : nuxtConfig.buildModules?.includes("nuxt-vite") ? "vite" : "webpack";
66
- let packageManager = (await detectPackageManager(cwd))?.name;
67
- if (packageManager) {
68
- packageManager += `@${getPackageManagerVersion(packageManager)}`;
69
- }
70
- const infoObj = {
71
- OperatingSystem: os.type(),
72
- NodeVersion: process.version,
73
- NuxtVersion: nuxtVersion,
74
- CLIVersion: version,
75
- NitroVersion: await getDepVersion("nitropack"),
76
- PackageManager: packageManager ?? "unknown",
77
- Builder: typeof builder === "string" ? builder : "custom",
78
- UserConfig: Object.keys(nuxtConfig).map((key) => `\`${key}\``).join(", "),
79
- RuntimeModules: await listModules(nuxtConfig.modules),
80
- BuildModules: await listModules(nuxtConfig.buildModules || [])
81
- };
82
- logger.log("Working directory:", cwd);
83
- let maxLength = 0;
84
- const entries = Object.entries(infoObj).map(([key, val]) => {
85
- const label = splitByCase(key).join(" ");
86
- if (label.length > maxLength) {
87
- maxLength = label.length;
88
- }
89
- return [label, val || "-"];
90
- });
91
- let infoStr = "";
92
- for (const [label, value] of entries) {
93
- infoStr += `- ${`${label}: `.padEnd(maxLength + 2)}${value.includes("`") ? value : `\`${value}\``}
94
- `;
95
- }
96
- const copied = !isMinimal && await clipboardy.write(infoStr).then(() => true).catch(() => false);
97
- const isNuxt3 = !isLegacy;
98
- const isBridge = !isNuxt3 && infoObj.BuildModules.includes("bridge");
99
- const repo = isBridge ? "nuxt/bridge" : "nuxt/nuxt";
100
- const log = [
101
- (isNuxt3 || isBridge) && `\u{1F449} Report an issue: https://github.com/${repo}/issues/new?template=bug-report.yml`,
102
- (isNuxt3 || isBridge) && `\u{1F449} Suggest an improvement: https://github.com/${repo}/discussions/new`,
103
- `\u{1F449} Read documentation: ${isNuxt3 || isBridge ? "https://nuxt.com" : "https://v2.nuxt.com"}`
104
- ].filter(Boolean).join("\n");
105
- const splitter = "------------------------------";
106
- logger.log(`Nuxt project info: ${copied ? "(copied to clipboard)" : ""}
107
-
108
- ${splitter}
109
- ${infoStr}${splitter}
110
-
111
- ${log}
112
- `);
113
- }
114
- });
115
- function normalizeConfigModule(module, rootDir) {
116
- if (!module) {
117
- return null;
118
- }
119
- if (typeof module === "string") {
120
- return module.split(rootDir).pop().split("node_modules").pop().replace(/^\//, "");
121
- }
122
- if (typeof module === "function") {
123
- return `${module.name}()`;
124
- }
125
- if (Array.isArray(module)) {
126
- return normalizeConfigModule(module[0], rootDir);
127
- }
128
- return null;
129
- }
130
- async function getNuxtConfig(rootDir) {
131
- try {
132
- const { createJiti } = await import('jiti');
133
- const jiti = createJiti(rootDir, {
134
- interopDefault: true,
135
- // allow using `~` and `@` in `nuxt.config`
136
- alias: {
137
- "~": rootDir,
138
- "@": rootDir
139
- }
140
- });
141
- globalThis.defineNuxtConfig = (c) => c;
142
- const result = await jiti.import("./nuxt.config", { default: true });
143
- delete globalThis.defineNuxtConfig;
144
- return result;
145
- } catch {
146
- return {};
147
- }
148
- }
149
-
150
- export { info as default };
@@ -1,413 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import process from 'node:process';
3
- import { defineCommand } from 'citty';
4
- import { colors } from 'consola/utils';
5
- import { downloadTemplate, startShell } from 'giget';
6
- import { installDependencies } from 'nypm';
7
- import { $fetch } from 'ofetch';
8
- import { resolve, relative, join, basename } from 'pathe';
9
- import { findFile, readPackageJSON, writePackageJSON } from 'pkg-types';
10
- import { hasTTY } from 'std-env';
11
- import { x } from 'tinyexec';
12
- import { r as runCommand, a as addModuleCommand } from './add.mjs';
13
- import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
14
- import { a as logLevelArgs, c as cwdArgs } from '../shared/cli-nightly.BRlCc6aT.mjs';
15
- import 'node:os';
16
- import 'node:path';
17
- import 'c12/update';
18
- import 'semver';
19
- import 'ufo';
20
- import 'node:url';
21
- import '../shared/cli-nightly.DHenkA1C.mjs';
22
- import './prepare.mjs';
23
- import '../shared/cli-nightly.DPmMxQ6h.mjs';
24
- import '../shared/cli-nightly.qKvs7FJ2.mjs';
25
- import 'exsolve';
26
- import 'consola';
27
- import '../shared/cli-nightly.Cr-OCgdO.mjs';
28
- import 'confbox';
29
-
30
- const themeColor = "\x1B[38;2;0;220;130m";
31
- const icon = [
32
- ` .d$b.`,
33
- ` i$$A$$L .d$b`,
34
- ` .$$F\` \`$$L.$$A$$.`,
35
- ` j$$' \`4$$:\` \`$$.`,
36
- ` j$$' .4$: \`$$.`,
37
- ` j$$\` .$$: \`4$L`,
38
- ` :$$:____.d$$: _____.:$$:`,
39
- ` \`4$$$$$$$$P\` .i$$$$$$$$P\``
40
- ];
41
- const nuxtIcon = icon.map((line) => line.split("").join(themeColor)).join("\n");
42
-
43
- const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/nuxt/starter/templates/templates";
44
- const DEFAULT_TEMPLATE_NAME = "v4";
45
- const pms = {
46
- npm: void 0,
47
- pnpm: void 0,
48
- yarn: void 0,
49
- bun: void 0,
50
- deno: void 0
51
- };
52
- const packageManagerOptions = Object.keys(pms);
53
- async function getModuleDependencies(moduleName) {
54
- try {
55
- const response = await $fetch(`https://registry.npmjs.org/${moduleName}/latest`);
56
- const dependencies = response.dependencies || {};
57
- return Object.keys(dependencies);
58
- } catch (err) {
59
- logger.warn(`Could not get dependencies for ${moduleName}: ${err}`);
60
- return [];
61
- }
62
- }
63
- function filterModules(modules, allDependencies) {
64
- const result = {
65
- toInstall: [],
66
- skipped: []
67
- };
68
- for (const module of modules) {
69
- const isDependency = modules.some((otherModule) => {
70
- if (otherModule === module)
71
- return false;
72
- const deps = allDependencies[otherModule] || [];
73
- return deps.includes(module);
74
- });
75
- if (isDependency) {
76
- result.skipped.push(module);
77
- } else {
78
- result.toInstall.push(module);
79
- }
80
- }
81
- return result;
82
- }
83
- async function getTemplateDependencies(templateDir) {
84
- try {
85
- const packageJsonPath = join(templateDir, "package.json");
86
- if (!existsSync(packageJsonPath)) {
87
- return [];
88
- }
89
- const packageJson = await readPackageJSON(packageJsonPath);
90
- const directDeps = {
91
- ...packageJson.dependencies,
92
- ...packageJson.devDependencies
93
- };
94
- const directDepNames = Object.keys(directDeps);
95
- const allDeps = new Set(directDepNames);
96
- const transitiveDepsResults = await Promise.all(
97
- directDepNames.map((dep) => getModuleDependencies(dep))
98
- );
99
- transitiveDepsResults.forEach((deps) => {
100
- deps.forEach((dep) => allDeps.add(dep));
101
- });
102
- return Array.from(allDeps);
103
- } catch (err) {
104
- logger.warn(`Could not read template dependencies: ${err}`);
105
- return [];
106
- }
107
- }
108
- const init = defineCommand({
109
- meta: {
110
- name: "init",
111
- description: "Initialize a fresh project"
112
- },
113
- args: {
114
- ...cwdArgs,
115
- ...logLevelArgs,
116
- dir: {
117
- type: "positional",
118
- description: "Project directory",
119
- default: ""
120
- },
121
- template: {
122
- type: "string",
123
- alias: "t",
124
- description: "Template name"
125
- },
126
- force: {
127
- type: "boolean",
128
- alias: "f",
129
- description: "Override existing directory"
130
- },
131
- offline: {
132
- type: "boolean",
133
- description: "Force offline mode"
134
- },
135
- preferOffline: {
136
- type: "boolean",
137
- description: "Prefer offline mode"
138
- },
139
- install: {
140
- type: "boolean",
141
- default: true,
142
- description: "Skip installing dependencies"
143
- },
144
- gitInit: {
145
- type: "boolean",
146
- description: "Initialize git repository"
147
- },
148
- shell: {
149
- type: "boolean",
150
- description: "Start shell after installation in project directory"
151
- },
152
- packageManager: {
153
- type: "string",
154
- description: "Package manager choice (npm, pnpm, yarn, bun)"
155
- },
156
- modules: {
157
- type: "string",
158
- required: false,
159
- description: "Nuxt modules to install (comma separated without spaces)",
160
- negativeDescription: "Skip module installation prompt",
161
- alias: "M"
162
- },
163
- nightly: {
164
- type: "string",
165
- description: "Use Nuxt nightly release channel (3x or latest)"
166
- }
167
- },
168
- async run(ctx) {
169
- if (hasTTY) {
170
- process.stdout.write(`
171
- ${nuxtIcon}
172
-
173
- `);
174
- }
175
- logger.info(colors.bold(`Welcome to Nuxt!`.split("").map((m) => `${themeColor}${m}`).join("")));
176
- if (ctx.args.dir === "") {
177
- ctx.args.dir = await logger.prompt("Where would you like to create your project?", {
178
- placeholder: "./nuxt-app",
179
- type: "text",
180
- default: "nuxt-app",
181
- cancel: "reject"
182
- }).catch(() => process.exit(1));
183
- }
184
- const cwd = resolve(ctx.args.cwd);
185
- let templateDownloadPath = resolve(cwd, ctx.args.dir);
186
- logger.info(`Creating a new project in ${colors.cyan(relative(cwd, templateDownloadPath) || templateDownloadPath)}.`);
187
- const templateName = ctx.args.template || DEFAULT_TEMPLATE_NAME;
188
- if (typeof templateName !== "string") {
189
- logger.error("Please specify a template!");
190
- process.exit(1);
191
- }
192
- let shouldForce = Boolean(ctx.args.force);
193
- const shouldVerify = !shouldForce && existsSync(templateDownloadPath);
194
- if (shouldVerify) {
195
- const selectedAction = await logger.prompt(
196
- `The directory ${colors.cyan(templateDownloadPath)} already exists. What would you like to do?`,
197
- {
198
- type: "select",
199
- options: ["Override its contents", "Select different directory", "Abort"]
200
- }
201
- );
202
- switch (selectedAction) {
203
- case "Override its contents":
204
- shouldForce = true;
205
- break;
206
- case "Select different directory": {
207
- templateDownloadPath = resolve(cwd, await logger.prompt("Please specify a different directory:", {
208
- type: "text",
209
- cancel: "reject"
210
- }).catch(() => process.exit(1)));
211
- break;
212
- }
213
- // 'Abort' or Ctrl+C
214
- default:
215
- process.exit(1);
216
- }
217
- }
218
- let template;
219
- try {
220
- template = await downloadTemplate(templateName, {
221
- dir: templateDownloadPath,
222
- force: shouldForce,
223
- offline: Boolean(ctx.args.offline),
224
- preferOffline: Boolean(ctx.args.preferOffline),
225
- registry: process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY
226
- });
227
- if (ctx.args.dir.length > 0) {
228
- const path = await findFile("package.json", {
229
- startingFrom: join(templateDownloadPath, "package.json"),
230
- reverse: true
231
- });
232
- if (path) {
233
- const pkg = await readPackageJSON(path, { try: true });
234
- if (pkg && pkg.name) {
235
- const slug = basename(templateDownloadPath).replace(/[^\w-]/g, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
236
- if (slug) {
237
- pkg.name = slug;
238
- await writePackageJSON(path, pkg);
239
- }
240
- }
241
- }
242
- }
243
- } catch (err) {
244
- if (process.env.DEBUG) {
245
- throw err;
246
- }
247
- logger.error(err.toString());
248
- process.exit(1);
249
- }
250
- if (ctx.args.nightly !== void 0 && !ctx.args.offline && !ctx.args.preferOffline) {
251
- const response = await $fetch("https://registry.npmjs.org/nuxt-nightly");
252
- const nightlyChannelTag = ctx.args.nightly || "latest";
253
- const nightlyChannelVersion = response["dist-tags"][nightlyChannelTag];
254
- if (!nightlyChannelVersion) {
255
- logger.error(`Nightly channel version for tag '${nightlyChannelTag}' not found.`);
256
- process.exit(1);
257
- }
258
- const nightlyNuxtPackageJsonVersion = `npm:nuxt-nightly@${nightlyChannelVersion}`;
259
- const packageJsonPath = resolve(cwd, ctx.args.dir);
260
- const packageJson = await readPackageJSON(packageJsonPath);
261
- if (packageJson.dependencies && "nuxt" in packageJson.dependencies) {
262
- packageJson.dependencies.nuxt = nightlyNuxtPackageJsonVersion;
263
- } else if (packageJson.devDependencies && "nuxt" in packageJson.devDependencies) {
264
- packageJson.devDependencies.nuxt = nightlyNuxtPackageJsonVersion;
265
- }
266
- await writePackageJSON(join(packageJsonPath, "package.json"), packageJson);
267
- }
268
- function detectCurrentPackageManager() {
269
- const userAgent = process.env.npm_config_user_agent;
270
- if (!userAgent) {
271
- return;
272
- }
273
- const [name] = userAgent.split("/");
274
- if (packageManagerOptions.includes(name)) {
275
- return name;
276
- }
277
- }
278
- const currentPackageManager = detectCurrentPackageManager();
279
- const packageManagerArg = ctx.args.packageManager;
280
- const packageManagerSelectOptions = packageManagerOptions.map((pm) => ({
281
- label: pm,
282
- value: pm,
283
- hint: currentPackageManager === pm ? "current" : void 0
284
- }));
285
- const selectedPackageManager = packageManagerOptions.includes(packageManagerArg) ? packageManagerArg : await logger.prompt("Which package manager would you like to use?", {
286
- type: "select",
287
- options: packageManagerSelectOptions,
288
- initial: currentPackageManager,
289
- cancel: "reject"
290
- }).catch(() => process.exit(1));
291
- if (ctx.args.install === false) {
292
- logger.info("Skipping install dependencies step.");
293
- } else {
294
- logger.start("Installing dependencies...");
295
- try {
296
- await installDependencies({
297
- cwd: template.dir,
298
- packageManager: {
299
- name: selectedPackageManager,
300
- command: selectedPackageManager
301
- }
302
- });
303
- } catch (err) {
304
- if (process.env.DEBUG) {
305
- throw err;
306
- }
307
- logger.error(err.toString());
308
- process.exit(1);
309
- }
310
- logger.success("Installation completed.");
311
- }
312
- if (ctx.args.gitInit === void 0) {
313
- ctx.args.gitInit = await logger.prompt("Initialize git repository?", {
314
- type: "confirm",
315
- cancel: "reject"
316
- }).catch(() => process.exit(1));
317
- }
318
- if (ctx.args.gitInit) {
319
- logger.info("Initializing git repository...\n");
320
- try {
321
- await x("git", ["init", template.dir], {
322
- throwOnError: true,
323
- nodeOptions: {
324
- stdio: "inherit"
325
- }
326
- });
327
- } catch (err) {
328
- logger.warn(`Failed to initialize git repository: ${err}`);
329
- }
330
- }
331
- const modulesToAdd = [];
332
- if (ctx.args.modules !== void 0) {
333
- modulesToAdd.push(
334
- ...(ctx.args.modules || "").split(",").map((module) => module.trim()).filter(Boolean)
335
- );
336
- } else if (!ctx.args.offline && !ctx.args.preferOffline) {
337
- const modulesPromise = $fetch("https://api.nuxt.com/modules");
338
- const wantsUserModules = await logger.prompt(
339
- `Would you like to install any of the official modules?`,
340
- {
341
- initial: false,
342
- type: "confirm",
343
- cancel: "reject"
344
- }
345
- ).catch(() => process.exit(1));
346
- if (wantsUserModules) {
347
- const [response, templateDeps] = await Promise.all([
348
- modulesPromise,
349
- getTemplateDependencies(template.dir)
350
- ]);
351
- const officialModules = response.modules.filter((module) => module.type === "official" && module.npm !== "@nuxt/devtools").filter((module) => !templateDeps.includes(module.npm));
352
- if (officialModules.length === 0) {
353
- logger.info("All official modules are already included in this template.");
354
- } else {
355
- const selectedOfficialModules = await logger.prompt(
356
- "Pick the modules to install:",
357
- {
358
- type: "multiselect",
359
- options: officialModules.map((module) => ({
360
- label: `${colors.bold(colors.greenBright(module.npm))} \u2013 ${module.description.replace(/\.$/, "")}`,
361
- value: module.npm
362
- })),
363
- required: false
364
- }
365
- );
366
- if (selectedOfficialModules === void 0) {
367
- process.exit(1);
368
- }
369
- if (selectedOfficialModules.length > 0) {
370
- const modules = selectedOfficialModules;
371
- const allDependencies = Object.fromEntries(
372
- await Promise.all(modules.map(
373
- async (module) => [module, await getModuleDependencies(module)]
374
- ))
375
- );
376
- const { toInstall, skipped } = filterModules(modules, allDependencies);
377
- if (skipped.length) {
378
- logger.info(`The following modules are already included as dependencies of another module and will not be installed: ${skipped.map((m) => colors.cyan(m)).join(", ")}`);
379
- }
380
- modulesToAdd.push(...toInstall);
381
- }
382
- }
383
- }
384
- }
385
- if (modulesToAdd.length > 0) {
386
- const args = [
387
- ...modulesToAdd,
388
- `--cwd=${templateDownloadPath}`,
389
- ctx.args.install ? "" : "--skipInstall",
390
- ctx.args.logLevel ? `--logLevel=${ctx.args.logLevel}` : ""
391
- ].filter(Boolean);
392
- await runCommand(addModuleCommand, args);
393
- }
394
- logger.log(
395
- `
396
- \u2728 Nuxt project has been created with the \`${template.name}\` template. Next steps:`
397
- );
398
- const relativeTemplateDir = relative(process.cwd(), template.dir) || ".";
399
- const runCmd = selectedPackageManager === "deno" ? "task" : "run";
400
- const nextSteps = [
401
- !ctx.args.shell && relativeTemplateDir.length > 1 && `\`cd ${relativeTemplateDir}\``,
402
- `Start development server with \`${selectedPackageManager} ${runCmd} dev\``
403
- ].filter(Boolean);
404
- for (const step of nextSteps) {
405
- logger.log(` \u203A ${step}`);
406
- }
407
- if (ctx.args.shell) {
408
- startShell(template.dir);
409
- }
410
- }
411
- });
412
-
413
- export { init as default };
@@ -1,57 +0,0 @@
1
- import process from 'node:process';
2
- import { defineCommand } from 'citty';
3
- import { resolve, relative } from 'pathe';
4
- import { a as clearBuildDir } from '../shared/cli-nightly.DPmMxQ6h.mjs';
5
- import { l as loadKit } from '../shared/cli-nightly.qKvs7FJ2.mjs';
6
- import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
7
- import { l as legacyRootDirArgs, e as extendsArgs, b as envNameArgs, a as logLevelArgs, c as cwdArgs, d as dotEnvArgs } from '../shared/cli-nightly.BRlCc6aT.mjs';
8
- import 'node:fs';
9
- import 'node:url';
10
- import 'exsolve';
11
- import 'consola';
12
- import 'node:path';
13
- import 'std-env';
14
-
15
- const prepareCommand = defineCommand({
16
- meta: {
17
- name: "prepare",
18
- description: "Prepare Nuxt for development/build"
19
- },
20
- args: {
21
- ...dotEnvArgs,
22
- ...cwdArgs,
23
- ...logLevelArgs,
24
- ...envNameArgs,
25
- ...extendsArgs,
26
- ...legacyRootDirArgs
27
- },
28
- async run(ctx) {
29
- process.env.NODE_ENV = process.env.NODE_ENV || "production";
30
- const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
31
- const { loadNuxt, buildNuxt, writeTypes } = await loadKit(cwd);
32
- const nuxt = await loadNuxt({
33
- cwd,
34
- dotenv: {
35
- cwd,
36
- fileName: ctx.args.dotenv
37
- },
38
- envName: ctx.args.envName,
39
- // c12 will fall back to NODE_ENV
40
- overrides: {
41
- _prepare: true,
42
- logLevel: ctx.args.logLevel,
43
- ...ctx.args.extends && { extends: ctx.args.extends },
44
- ...ctx.data?.overrides
45
- }
46
- });
47
- await clearBuildDir(nuxt.options.buildDir);
48
- await buildNuxt(nuxt);
49
- await writeTypes(nuxt);
50
- logger.success(
51
- "Types generated in",
52
- relative(process.cwd(), nuxt.options.buildDir)
53
- );
54
- }
55
- });
56
-
57
- export { prepareCommand as default };