@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.
- package/dist/_shared-C3vB2YLc.mjs +42 -0
- package/dist/_utils-DTrPahho.mjs +29 -0
- package/dist/add-BGMHIn5L.mjs +333 -0
- package/dist/add-CRBwIlDF.mjs +298 -0
- package/dist/add-hFFIzkcy.mjs +10 -0
- package/dist/analyze-CUKAi_IN.mjs +115 -0
- package/dist/banner-CqfM_0Qo.mjs +55 -0
- package/dist/build-BSxJLNs_.mjs +78 -0
- package/dist/build-KNIBU0AI.mjs +9 -0
- package/dist/cleanup-8GRakeLu.mjs +31 -0
- package/dist/dev/index.d.mts +87 -83
- package/dist/dev/index.mjs +7 -23
- package/dist/dev-Bs_0dzlh.mjs +591 -0
- package/dist/dev-CnQwDUaD.mjs +7 -0
- package/dist/dev-L7lhoThJ.mjs +438 -0
- package/dist/dev-child-CSiX6Uyv.mjs +37 -0
- package/dist/devtools-BLGzUSNU.mjs +44 -0
- package/dist/env-Dz4K_NkM.mjs +12 -0
- package/dist/fs-ewAp6tjM.mjs +40 -0
- package/dist/generate-CGy3-x2K.mjs +35 -0
- package/dist/index.d.mts +9 -18
- package/dist/index.mjs +129 -8
- package/dist/info-BDdsghj1.mjs +120 -0
- package/dist/init-_n9DXzzY.mjs +336 -0
- package/dist/kit-xFxVGu6d.mjs +37 -0
- package/dist/logger-Dk0gkCkX.mjs +7 -0
- package/dist/module-CqBrGD-s.mjs +17 -0
- package/dist/nuxt-Cc9ZTk7m.mjs +44 -0
- package/dist/packageManagers-DbVB5cXf.mjs +9 -0
- package/dist/prepare-B0KOhO-L.mjs +7 -0
- package/dist/prepare-xI978yFg.mjs +49 -0
- package/dist/preview-C5fNqrC6.mjs +109 -0
- package/dist/search-DCyXfxzn.mjs +113 -0
- package/dist/test-CBt1emEB.mjs +55 -0
- package/dist/typecheck-DCWe7Iej.mjs +102 -0
- package/dist/upgrade-BMSFcUWJ.mjs +184 -0
- package/dist/versions-CSy_3o_-.mjs +18 -0
- package/package.json +13 -13
- package/dist/chunks/add.mjs +0 -381
- package/dist/chunks/add2.mjs +0 -319
- package/dist/chunks/analyze.mjs +0 -139
- package/dist/chunks/build.mjs +0 -94
- package/dist/chunks/cleanup.mjs +0 -34
- package/dist/chunks/dev-child.mjs +0 -38
- package/dist/chunks/dev.mjs +0 -709
- package/dist/chunks/devtools.mjs +0 -46
- package/dist/chunks/generate.mjs +0 -45
- package/dist/chunks/index.mjs +0 -507
- package/dist/chunks/index2.mjs +0 -15
- package/dist/chunks/info.mjs +0 -150
- package/dist/chunks/init.mjs +0 -413
- package/dist/chunks/prepare.mjs +0 -57
- package/dist/chunks/preview.mjs +0 -131
- package/dist/chunks/search.mjs +0 -114
- package/dist/chunks/test.mjs +0 -62
- package/dist/chunks/typecheck.mjs +0 -85
- package/dist/chunks/upgrade.mjs +0 -214
- package/dist/dev/index.d.ts +0 -94
- package/dist/index.d.ts +0 -23
- package/dist/shared/cli-nightly.B9AmABr3.mjs +0 -5
- package/dist/shared/cli-nightly.BRlCc6aT.mjs +0 -204
- package/dist/shared/cli-nightly.BSm0_9Hr.mjs +0 -7
- package/dist/shared/cli-nightly.Bu_9IHj2.mjs +0 -51
- package/dist/shared/cli-nightly.Cr-OCgdO.mjs +0 -37
- package/dist/shared/cli-nightly.DHenkA1C.mjs +0 -14
- package/dist/shared/cli-nightly.DPmMxQ6h.mjs +0 -33
- package/dist/shared/cli-nightly.DS8guhZv.mjs +0 -52
- package/dist/shared/cli-nightly.DkO5RR_e.mjs +0 -14
- package/dist/shared/cli-nightly.qKvs7FJ2.mjs +0 -36
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { defineCommand, runCommand as runCommand$1, runMain as runMain$1 } from "citty";
|
|
6
|
+
import { provider } from "std-env";
|
|
7
|
+
import { consola } from "consola";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
//#region ../nuxi/src/commands/index.ts
|
|
11
|
+
const _rDefault = (r) => r.default || r;
|
|
12
|
+
const commands = {
|
|
13
|
+
add: () => import("./add-BGMHIn5L.mjs").then(_rDefault),
|
|
14
|
+
analyze: () => import("./analyze-CUKAi_IN.mjs").then(_rDefault),
|
|
15
|
+
build: () => import("./build-KNIBU0AI.mjs").then(_rDefault),
|
|
16
|
+
cleanup: () => import("./cleanup-8GRakeLu.mjs").then(_rDefault),
|
|
17
|
+
_dev: () => import("./dev-child-CSiX6Uyv.mjs").then(_rDefault),
|
|
18
|
+
dev: () => import("./dev-Bs_0dzlh.mjs").then(_rDefault),
|
|
19
|
+
devtools: () => import("./devtools-BLGzUSNU.mjs").then(_rDefault),
|
|
20
|
+
generate: () => import("./generate-CGy3-x2K.mjs").then(_rDefault),
|
|
21
|
+
info: () => import("./info-BDdsghj1.mjs").then(_rDefault),
|
|
22
|
+
init: () => import("./init-_n9DXzzY.mjs").then(_rDefault),
|
|
23
|
+
module: () => import("./module-CqBrGD-s.mjs").then(_rDefault),
|
|
24
|
+
prepare: () => import("./prepare-B0KOhO-L.mjs").then(_rDefault),
|
|
25
|
+
preview: () => import("./preview-C5fNqrC6.mjs").then(_rDefault),
|
|
26
|
+
start: () => import("./preview-C5fNqrC6.mjs").then(_rDefault),
|
|
27
|
+
test: () => import("./test-CBt1emEB.mjs").then(_rDefault),
|
|
28
|
+
typecheck: () => import("./typecheck-DCWe7Iej.mjs").then(_rDefault),
|
|
29
|
+
upgrade: () => import("./upgrade-BMSFcUWJ.mjs").then(_rDefault)
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region ../nuxi/src/utils/console.ts
|
|
34
|
+
function wrapReporter(reporter) {
|
|
35
|
+
return { log(logObj, ctx) {
|
|
36
|
+
if (!logObj.args || !logObj.args.length) return;
|
|
37
|
+
const msg = logObj.args[0];
|
|
38
|
+
if (typeof msg === "string" && !process.env.DEBUG) {
|
|
39
|
+
if (msg.startsWith("[Vue Router warn]: No match found for location with path")) return;
|
|
40
|
+
if (msg.includes("ExperimentalWarning: The Fetch API is an experimental feature")) return;
|
|
41
|
+
if (msg.startsWith("Sourcemap") && msg.includes("node_modules")) return;
|
|
42
|
+
}
|
|
43
|
+
return reporter.log(logObj, ctx);
|
|
44
|
+
} };
|
|
45
|
+
}
|
|
46
|
+
function setupGlobalConsole(opts = {}) {
|
|
47
|
+
consola.options.reporters = consola.options.reporters.map(wrapReporter);
|
|
48
|
+
if (opts.dev) consola.wrapAll();
|
|
49
|
+
else consola.wrapConsole();
|
|
50
|
+
process.on("unhandledRejection", (err) => consola.error("[unhandledRejection]", err));
|
|
51
|
+
process.on("uncaughtException", (err) => consola.error("[uncaughtException]", err));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ../nuxi/src/utils/engines.ts
|
|
56
|
+
async function checkEngines() {
|
|
57
|
+
const satisfies = await import("semver/functions/satisfies.js").then((r) => r.default || r);
|
|
58
|
+
const currentNode = process.versions.node;
|
|
59
|
+
const nodeRange = ">= 18.0.0";
|
|
60
|
+
if (!satisfies(currentNode, nodeRange)) logger.warn(`Current version of Node.js (\`${currentNode}\`) is unsupported and might cause issues.\n Please upgrade to a compatible version \`${nodeRange}\`.`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region package.json
|
|
65
|
+
var name = "@nuxt/cli-nightly";
|
|
66
|
+
var version = "3.29.4-20251021-190716-bbf70fc";
|
|
67
|
+
var description = "Nuxt CLI";
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/main.ts
|
|
71
|
+
const _main = defineCommand({
|
|
72
|
+
meta: {
|
|
73
|
+
name: name.endsWith("nightly") ? name : "nuxi",
|
|
74
|
+
version,
|
|
75
|
+
description
|
|
76
|
+
},
|
|
77
|
+
args: {
|
|
78
|
+
...cwdArgs,
|
|
79
|
+
command: {
|
|
80
|
+
type: "positional",
|
|
81
|
+
required: false
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
subCommands: commands,
|
|
85
|
+
async setup(ctx) {
|
|
86
|
+
const command = ctx.args._[0];
|
|
87
|
+
setupGlobalConsole({ dev: command === "dev" });
|
|
88
|
+
let backgroundTasks;
|
|
89
|
+
if (command !== "_dev" && provider !== "stackblitz") backgroundTasks = Promise.all([checkEngines()]).catch((err) => logger.error(err));
|
|
90
|
+
if (command === "init") await backgroundTasks;
|
|
91
|
+
if (ctx.args.command && !(ctx.args.command in commands)) {
|
|
92
|
+
const cwd = resolve(ctx.args.cwd);
|
|
93
|
+
try {
|
|
94
|
+
const { x } = await import("tinyexec");
|
|
95
|
+
await x(`nuxt-${ctx.args.command}`, ctx.rawArgs.slice(1), {
|
|
96
|
+
nodeOptions: {
|
|
97
|
+
stdio: "inherit",
|
|
98
|
+
cwd
|
|
99
|
+
},
|
|
100
|
+
throwOnError: true
|
|
101
|
+
});
|
|
102
|
+
} catch (err) {
|
|
103
|
+
if (err instanceof Error && "code" in err && err.code === "ENOENT") return;
|
|
104
|
+
}
|
|
105
|
+
process.exit();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const main = _main;
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/run.ts
|
|
113
|
+
globalThis.__nuxt_cli__ = globalThis.__nuxt_cli__ || {
|
|
114
|
+
startTime: Date.now(),
|
|
115
|
+
entry: fileURLToPath(new URL("../../bin/nuxi.mjs", import.meta.url)),
|
|
116
|
+
devEntry: fileURLToPath(new URL("../dev/index.mjs", import.meta.url))
|
|
117
|
+
};
|
|
118
|
+
const runMain = () => runMain$1(main);
|
|
119
|
+
async function runCommand(name$1, argv = process.argv.slice(2), data = {}) {
|
|
120
|
+
argv.push("--no-clear");
|
|
121
|
+
if (!(name$1 in commands)) throw new Error(`Invalid command ${name$1}`);
|
|
122
|
+
return await runCommand$1(await commands[name$1](), {
|
|
123
|
+
rawArgs: argv,
|
|
124
|
+
data: { overrides: data.overrides || {} }
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
export { main, runCommand, runMain };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { a as legacyRootDirArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
3
|
+
import { n as tryResolveNuxt } from "./kit-xFxVGu6d.mjs";
|
|
4
|
+
import { t as getPackageManagerVersion } from "./packageManagers-DbVB5cXf.mjs";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import { isMinimal } from "std-env";
|
|
8
|
+
import { resolve } from "pathe";
|
|
9
|
+
import { splitByCase } from "scule";
|
|
10
|
+
import os from "node:os";
|
|
11
|
+
import { copy } from "copy-paste";
|
|
12
|
+
import { detectPackageManager } from "nypm";
|
|
13
|
+
import { readPackageJSON } from "pkg-types";
|
|
14
|
+
|
|
15
|
+
//#region ../nuxi/package.json
|
|
16
|
+
var version = "3.29.4-20251021-190708-bbf70fc";
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../nuxi/src/commands/info.ts
|
|
20
|
+
var info_default = defineCommand({
|
|
21
|
+
meta: {
|
|
22
|
+
name: "info",
|
|
23
|
+
description: "Get information about Nuxt project"
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
...cwdArgs,
|
|
27
|
+
...legacyRootDirArgs
|
|
28
|
+
},
|
|
29
|
+
async run(ctx) {
|
|
30
|
+
const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
|
|
31
|
+
const nuxtConfig = await getNuxtConfig(cwd);
|
|
32
|
+
const { dependencies = {}, devDependencies = {} } = await readPackageJSON(cwd).catch(() => ({}));
|
|
33
|
+
const nuxtPath = tryResolveNuxt(cwd);
|
|
34
|
+
async function getDepVersion(name) {
|
|
35
|
+
for (const url of [cwd, nuxtPath]) {
|
|
36
|
+
if (!url) continue;
|
|
37
|
+
const pkg = await readPackageJSON(name, { url }).catch(() => null);
|
|
38
|
+
if (pkg) return pkg.version;
|
|
39
|
+
}
|
|
40
|
+
return dependencies[name] || devDependencies[name];
|
|
41
|
+
}
|
|
42
|
+
async function listModules(arr = []) {
|
|
43
|
+
const info = [];
|
|
44
|
+
for (let m of arr) {
|
|
45
|
+
if (Array.isArray(m)) m = m[0];
|
|
46
|
+
const name = normalizeConfigModule(m, cwd);
|
|
47
|
+
if (name) {
|
|
48
|
+
const v = await getDepVersion(name.split("/").splice(0, 2).join("/"));
|
|
49
|
+
info.push(`\`${v ? `${name}@${v}` : name}\``);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return info.join(", ");
|
|
53
|
+
}
|
|
54
|
+
const nuxtVersion = await getDepVersion("nuxt") || await getDepVersion("nuxt-nightly") || await getDepVersion("nuxt-edge") || await getDepVersion("nuxt3") || "-";
|
|
55
|
+
const isLegacy = nuxtVersion.startsWith("2");
|
|
56
|
+
const builder = !isLegacy ? nuxtConfig.builder || "-" : nuxtConfig.bridge?.vite ? "vite" : nuxtConfig.buildModules?.includes("nuxt-vite") ? "vite" : "webpack";
|
|
57
|
+
let packageManager = (await detectPackageManager(cwd))?.name;
|
|
58
|
+
if (packageManager) packageManager += `@${getPackageManagerVersion(packageManager)}`;
|
|
59
|
+
const infoObj = {
|
|
60
|
+
OperatingSystem: os.type(),
|
|
61
|
+
NodeVersion: process.version,
|
|
62
|
+
NuxtVersion: nuxtVersion,
|
|
63
|
+
CLIVersion: version,
|
|
64
|
+
NitroVersion: await getDepVersion("nitropack"),
|
|
65
|
+
PackageManager: packageManager ?? "unknown",
|
|
66
|
+
Builder: typeof builder === "string" ? builder : "custom",
|
|
67
|
+
UserConfig: Object.keys(nuxtConfig).map((key) => `\`${key}\``).join(", "),
|
|
68
|
+
RuntimeModules: await listModules(nuxtConfig.modules),
|
|
69
|
+
BuildModules: await listModules(nuxtConfig.buildModules || [])
|
|
70
|
+
};
|
|
71
|
+
logger.log("Working directory:", cwd);
|
|
72
|
+
let maxLength = 0;
|
|
73
|
+
const entries = Object.entries(infoObj).map(([key, val]) => {
|
|
74
|
+
const label = splitByCase(key).join(" ");
|
|
75
|
+
if (label.length > maxLength) maxLength = label.length;
|
|
76
|
+
return [label, val || "-"];
|
|
77
|
+
});
|
|
78
|
+
let infoStr = "";
|
|
79
|
+
for (const [label, value] of entries) infoStr += `- ${`${label}: `.padEnd(maxLength + 2)}${value.includes("`") ? value : `\`${value}\``}\n`;
|
|
80
|
+
const copied = !isMinimal && await new Promise((resolve$1) => copy(infoStr, (err) => resolve$1(!err)));
|
|
81
|
+
const isNuxt3 = !isLegacy;
|
|
82
|
+
const isBridge = !isNuxt3 && infoObj.BuildModules.includes("bridge");
|
|
83
|
+
const repo = isBridge ? "nuxt/bridge" : "nuxt/nuxt";
|
|
84
|
+
const log = [
|
|
85
|
+
(isNuxt3 || isBridge) && `👉 Report an issue: https://github.com/${repo}/issues/new?template=bug-report.yml`,
|
|
86
|
+
(isNuxt3 || isBridge) && `👉 Suggest an improvement: https://github.com/${repo}/discussions/new`,
|
|
87
|
+
`👉 Read documentation: ${isNuxt3 || isBridge ? "https://nuxt.com" : "https://v2.nuxt.com"}`
|
|
88
|
+
].filter(Boolean).join("\n");
|
|
89
|
+
const splitter = "------------------------------";
|
|
90
|
+
logger.log(`Nuxt project info: ${copied ? "(copied to clipboard)" : ""}\n\n${splitter}\n${infoStr}${splitter}\n\n${log}\n`);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
function normalizeConfigModule(module, rootDir) {
|
|
94
|
+
if (!module) return null;
|
|
95
|
+
if (typeof module === "string") return module.split(rootDir).pop().split("node_modules").pop().replace(/^\//, "");
|
|
96
|
+
if (typeof module === "function") return `${module.name}()`;
|
|
97
|
+
if (Array.isArray(module)) return normalizeConfigModule(module[0], rootDir);
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
async function getNuxtConfig(rootDir) {
|
|
101
|
+
try {
|
|
102
|
+
const { createJiti } = await import("jiti");
|
|
103
|
+
const jiti = createJiti(rootDir, {
|
|
104
|
+
interopDefault: true,
|
|
105
|
+
alias: {
|
|
106
|
+
"~": rootDir,
|
|
107
|
+
"@": rootDir
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
globalThis.defineNuxtConfig = (c) => c;
|
|
111
|
+
const result = await jiti.import("./nuxt.config", { default: true });
|
|
112
|
+
delete globalThis.defineNuxtConfig;
|
|
113
|
+
return result;
|
|
114
|
+
} catch {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
export { info_default as default };
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { o as logLevelArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
3
|
+
import "./fs-ewAp6tjM.mjs";
|
|
4
|
+
import "./kit-xFxVGu6d.mjs";
|
|
5
|
+
import { n as runCommand$1, t as add_default } from "./add-CRBwIlDF.mjs";
|
|
6
|
+
import "./versions-CSy_3o_-.mjs";
|
|
7
|
+
import "./prepare-xI978yFg.mjs";
|
|
8
|
+
import "./_utils-DTrPahho.mjs";
|
|
9
|
+
import process from "node:process";
|
|
10
|
+
import { defineCommand } from "citty";
|
|
11
|
+
import { hasTTY } from "std-env";
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
13
|
+
import { basename, join, relative, resolve } from "pathe";
|
|
14
|
+
import { colors } from "consola/utils";
|
|
15
|
+
import { x } from "tinyexec";
|
|
16
|
+
import { installDependencies } from "nypm";
|
|
17
|
+
import { findFile, readPackageJSON, writePackageJSON } from "pkg-types";
|
|
18
|
+
import { downloadTemplate, startShell } from "giget";
|
|
19
|
+
import { $fetch } from "ofetch";
|
|
20
|
+
|
|
21
|
+
//#region ../nuxi/src/utils/ascii.ts
|
|
22
|
+
/**
|
|
23
|
+
* Thank you to IndyJoenz for this ASCII art
|
|
24
|
+
* https://bsky.app/profile/durdraw.org/post/3liadod3gv22a
|
|
25
|
+
*/
|
|
26
|
+
const themeColor = "\x1B[38;2;0;220;130m";
|
|
27
|
+
const icon = [
|
|
28
|
+
` .d$b.`,
|
|
29
|
+
` i$$A$$L .d$b`,
|
|
30
|
+
` .$$F\` \`$$L.$$A$$.`,
|
|
31
|
+
` j$$' \`4$$:\` \`$$.`,
|
|
32
|
+
` j$$' .4$: \`$$.`,
|
|
33
|
+
` j$$\` .$$: \`4$L`,
|
|
34
|
+
` :$$:____.d$$: _____.:$$:`,
|
|
35
|
+
` \`4$$$$$$$$P\` .i$$$$$$$$P\``
|
|
36
|
+
];
|
|
37
|
+
const nuxtIcon = icon.map((line) => line.split("").join(themeColor)).join("\n");
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region ../nuxi/src/commands/init.ts
|
|
41
|
+
const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/nuxt/starter/templates/templates";
|
|
42
|
+
const DEFAULT_TEMPLATE_NAME = "v4";
|
|
43
|
+
const packageManagerOptions = Object.keys({
|
|
44
|
+
npm: void 0,
|
|
45
|
+
pnpm: void 0,
|
|
46
|
+
yarn: void 0,
|
|
47
|
+
bun: void 0,
|
|
48
|
+
deno: void 0
|
|
49
|
+
});
|
|
50
|
+
async function getModuleDependencies(moduleName) {
|
|
51
|
+
try {
|
|
52
|
+
const dependencies = (await $fetch(`https://registry.npmjs.org/${moduleName}/latest`)).dependencies || {};
|
|
53
|
+
return Object.keys(dependencies);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
logger.warn(`Could not get dependencies for ${moduleName}: ${err}`);
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function filterModules(modules, allDependencies) {
|
|
60
|
+
const result = {
|
|
61
|
+
toInstall: [],
|
|
62
|
+
skipped: []
|
|
63
|
+
};
|
|
64
|
+
for (const module of modules) if (modules.some((otherModule) => {
|
|
65
|
+
if (otherModule === module) return false;
|
|
66
|
+
return (allDependencies[otherModule] || []).includes(module);
|
|
67
|
+
})) result.skipped.push(module);
|
|
68
|
+
else result.toInstall.push(module);
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
async function getTemplateDependencies(templateDir) {
|
|
72
|
+
try {
|
|
73
|
+
const packageJsonPath = join(templateDir, "package.json");
|
|
74
|
+
if (!existsSync(packageJsonPath)) return [];
|
|
75
|
+
const packageJson = await readPackageJSON(packageJsonPath);
|
|
76
|
+
const directDeps = {
|
|
77
|
+
...packageJson.dependencies,
|
|
78
|
+
...packageJson.devDependencies
|
|
79
|
+
};
|
|
80
|
+
const directDepNames = Object.keys(directDeps);
|
|
81
|
+
const allDeps = new Set(directDepNames);
|
|
82
|
+
(await Promise.all(directDepNames.map((dep) => getModuleDependencies(dep)))).forEach((deps) => {
|
|
83
|
+
deps.forEach((dep) => allDeps.add(dep));
|
|
84
|
+
});
|
|
85
|
+
return Array.from(allDeps);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
logger.warn(`Could not read template dependencies: ${err}`);
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
var init_default = defineCommand({
|
|
92
|
+
meta: {
|
|
93
|
+
name: "init",
|
|
94
|
+
description: "Initialize a fresh project"
|
|
95
|
+
},
|
|
96
|
+
args: {
|
|
97
|
+
...cwdArgs,
|
|
98
|
+
...logLevelArgs,
|
|
99
|
+
dir: {
|
|
100
|
+
type: "positional",
|
|
101
|
+
description: "Project directory",
|
|
102
|
+
default: ""
|
|
103
|
+
},
|
|
104
|
+
template: {
|
|
105
|
+
type: "string",
|
|
106
|
+
alias: "t",
|
|
107
|
+
description: "Template name"
|
|
108
|
+
},
|
|
109
|
+
force: {
|
|
110
|
+
type: "boolean",
|
|
111
|
+
alias: "f",
|
|
112
|
+
description: "Override existing directory"
|
|
113
|
+
},
|
|
114
|
+
offline: {
|
|
115
|
+
type: "boolean",
|
|
116
|
+
description: "Force offline mode"
|
|
117
|
+
},
|
|
118
|
+
preferOffline: {
|
|
119
|
+
type: "boolean",
|
|
120
|
+
description: "Prefer offline mode"
|
|
121
|
+
},
|
|
122
|
+
install: {
|
|
123
|
+
type: "boolean",
|
|
124
|
+
default: true,
|
|
125
|
+
description: "Skip installing dependencies"
|
|
126
|
+
},
|
|
127
|
+
gitInit: {
|
|
128
|
+
type: "boolean",
|
|
129
|
+
description: "Initialize git repository"
|
|
130
|
+
},
|
|
131
|
+
shell: {
|
|
132
|
+
type: "boolean",
|
|
133
|
+
description: "Start shell after installation in project directory"
|
|
134
|
+
},
|
|
135
|
+
packageManager: {
|
|
136
|
+
type: "string",
|
|
137
|
+
description: "Package manager choice (npm, pnpm, yarn, bun)"
|
|
138
|
+
},
|
|
139
|
+
modules: {
|
|
140
|
+
type: "string",
|
|
141
|
+
required: false,
|
|
142
|
+
description: "Nuxt modules to install (comma separated without spaces)",
|
|
143
|
+
negativeDescription: "Skip module installation prompt",
|
|
144
|
+
alias: "M"
|
|
145
|
+
},
|
|
146
|
+
nightly: {
|
|
147
|
+
type: "string",
|
|
148
|
+
description: "Use Nuxt nightly release channel (3x or latest)"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
async run(ctx) {
|
|
152
|
+
if (hasTTY) process.stdout.write(`\n${nuxtIcon}\n\n`);
|
|
153
|
+
logger.info(colors.bold(`Welcome to Nuxt!`.split("").map((m) => `${themeColor}${m}`).join("")));
|
|
154
|
+
if (ctx.args.dir === "") ctx.args.dir = await logger.prompt("Where would you like to create your project?", {
|
|
155
|
+
placeholder: "./nuxt-app",
|
|
156
|
+
type: "text",
|
|
157
|
+
default: "nuxt-app",
|
|
158
|
+
cancel: "reject"
|
|
159
|
+
}).catch(() => process.exit(1));
|
|
160
|
+
const cwd = resolve(ctx.args.cwd);
|
|
161
|
+
let templateDownloadPath = resolve(cwd, ctx.args.dir);
|
|
162
|
+
logger.info(`Creating a new project in ${colors.cyan(relative(cwd, templateDownloadPath) || templateDownloadPath)}.`);
|
|
163
|
+
const templateName = ctx.args.template || DEFAULT_TEMPLATE_NAME;
|
|
164
|
+
if (typeof templateName !== "string") {
|
|
165
|
+
logger.error("Please specify a template!");
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
let shouldForce = Boolean(ctx.args.force);
|
|
169
|
+
if (!shouldForce && existsSync(templateDownloadPath)) switch (await logger.prompt(`The directory ${colors.cyan(templateDownloadPath)} already exists. What would you like to do?`, {
|
|
170
|
+
type: "select",
|
|
171
|
+
options: [
|
|
172
|
+
"Override its contents",
|
|
173
|
+
"Select different directory",
|
|
174
|
+
"Abort"
|
|
175
|
+
]
|
|
176
|
+
})) {
|
|
177
|
+
case "Override its contents":
|
|
178
|
+
shouldForce = true;
|
|
179
|
+
break;
|
|
180
|
+
case "Select different directory":
|
|
181
|
+
templateDownloadPath = resolve(cwd, await logger.prompt("Please specify a different directory:", {
|
|
182
|
+
type: "text",
|
|
183
|
+
cancel: "reject"
|
|
184
|
+
}).catch(() => process.exit(1)));
|
|
185
|
+
break;
|
|
186
|
+
default: process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
let template;
|
|
189
|
+
try {
|
|
190
|
+
template = await downloadTemplate(templateName, {
|
|
191
|
+
dir: templateDownloadPath,
|
|
192
|
+
force: shouldForce,
|
|
193
|
+
offline: Boolean(ctx.args.offline),
|
|
194
|
+
preferOffline: Boolean(ctx.args.preferOffline),
|
|
195
|
+
registry: process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY
|
|
196
|
+
});
|
|
197
|
+
if (ctx.args.dir.length > 0) {
|
|
198
|
+
const path = await findFile("package.json", {
|
|
199
|
+
startingFrom: join(templateDownloadPath, "package.json"),
|
|
200
|
+
reverse: true
|
|
201
|
+
});
|
|
202
|
+
if (path) {
|
|
203
|
+
const pkg = await readPackageJSON(path, { try: true });
|
|
204
|
+
if (pkg && pkg.name) {
|
|
205
|
+
const slug = basename(templateDownloadPath).replace(/[^\w-]/g, "-").replace(/-{2,}/g, "-").replace(/^-|-$/g, "");
|
|
206
|
+
if (slug) {
|
|
207
|
+
pkg.name = slug;
|
|
208
|
+
await writePackageJSON(path, pkg);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (err) {
|
|
214
|
+
if (process.env.DEBUG) throw err;
|
|
215
|
+
logger.error(err.toString());
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
if (ctx.args.nightly !== void 0 && !ctx.args.offline && !ctx.args.preferOffline) {
|
|
219
|
+
const response = await $fetch("https://registry.npmjs.org/nuxt-nightly");
|
|
220
|
+
const nightlyChannelTag = ctx.args.nightly || "latest";
|
|
221
|
+
if (!nightlyChannelTag) {
|
|
222
|
+
logger.error(`Error getting nightly channel tag.`);
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
225
|
+
const nightlyChannelVersion = response["dist-tags"][nightlyChannelTag];
|
|
226
|
+
if (!nightlyChannelVersion) {
|
|
227
|
+
logger.error(`Nightly channel version for tag '${nightlyChannelTag}' not found.`);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
const nightlyNuxtPackageJsonVersion = `npm:nuxt-nightly@${nightlyChannelVersion}`;
|
|
231
|
+
const packageJsonPath = resolve(cwd, ctx.args.dir);
|
|
232
|
+
const packageJson = await readPackageJSON(packageJsonPath);
|
|
233
|
+
if (packageJson.dependencies && "nuxt" in packageJson.dependencies) packageJson.dependencies.nuxt = nightlyNuxtPackageJsonVersion;
|
|
234
|
+
else if (packageJson.devDependencies && "nuxt" in packageJson.devDependencies) packageJson.devDependencies.nuxt = nightlyNuxtPackageJsonVersion;
|
|
235
|
+
await writePackageJSON(join(packageJsonPath, "package.json"), packageJson);
|
|
236
|
+
}
|
|
237
|
+
function detectCurrentPackageManager() {
|
|
238
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
239
|
+
if (!userAgent) return;
|
|
240
|
+
const [name] = userAgent.split("/");
|
|
241
|
+
if (packageManagerOptions.includes(name)) return name;
|
|
242
|
+
}
|
|
243
|
+
const currentPackageManager = detectCurrentPackageManager();
|
|
244
|
+
const packageManagerArg = ctx.args.packageManager;
|
|
245
|
+
const packageManagerSelectOptions = packageManagerOptions.map((pm) => ({
|
|
246
|
+
label: pm,
|
|
247
|
+
value: pm,
|
|
248
|
+
hint: currentPackageManager === pm ? "current" : void 0
|
|
249
|
+
}));
|
|
250
|
+
const selectedPackageManager = packageManagerOptions.includes(packageManagerArg) ? packageManagerArg : await logger.prompt("Which package manager would you like to use?", {
|
|
251
|
+
type: "select",
|
|
252
|
+
options: packageManagerSelectOptions,
|
|
253
|
+
initial: currentPackageManager,
|
|
254
|
+
cancel: "reject"
|
|
255
|
+
}).catch(() => process.exit(1));
|
|
256
|
+
if (ctx.args.install === false) logger.info("Skipping install dependencies step.");
|
|
257
|
+
else {
|
|
258
|
+
logger.start("Installing dependencies...");
|
|
259
|
+
try {
|
|
260
|
+
await installDependencies({
|
|
261
|
+
cwd: template.dir,
|
|
262
|
+
packageManager: {
|
|
263
|
+
name: selectedPackageManager,
|
|
264
|
+
command: selectedPackageManager
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
} catch (err) {
|
|
268
|
+
if (process.env.DEBUG) throw err;
|
|
269
|
+
logger.error(err.toString());
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
logger.success("Installation completed.");
|
|
273
|
+
}
|
|
274
|
+
if (ctx.args.gitInit === void 0) ctx.args.gitInit = await logger.prompt("Initialize git repository?", {
|
|
275
|
+
type: "confirm",
|
|
276
|
+
cancel: "reject"
|
|
277
|
+
}).catch(() => process.exit(1));
|
|
278
|
+
if (ctx.args.gitInit) {
|
|
279
|
+
logger.info("Initializing git repository...\n");
|
|
280
|
+
try {
|
|
281
|
+
await x("git", ["init", template.dir], {
|
|
282
|
+
throwOnError: true,
|
|
283
|
+
nodeOptions: { stdio: "inherit" }
|
|
284
|
+
});
|
|
285
|
+
} catch (err) {
|
|
286
|
+
logger.warn(`Failed to initialize git repository: ${err}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const modulesToAdd = [];
|
|
290
|
+
if (ctx.args.modules !== void 0) modulesToAdd.push(...(ctx.args.modules || "").split(",").map((module) => module.trim()).filter(Boolean));
|
|
291
|
+
else if (!ctx.args.offline && !ctx.args.preferOffline) {
|
|
292
|
+
const modulesPromise = $fetch("https://api.nuxt.com/modules");
|
|
293
|
+
if (await logger.prompt(`Would you like to install any of the official modules?`, {
|
|
294
|
+
initial: false,
|
|
295
|
+
type: "confirm",
|
|
296
|
+
cancel: "reject"
|
|
297
|
+
}).catch(() => process.exit(1))) {
|
|
298
|
+
const [response, templateDeps] = await Promise.all([modulesPromise, getTemplateDependencies(template.dir)]);
|
|
299
|
+
const officialModules = response.modules.filter((module) => module.type === "official" && module.npm !== "@nuxt/devtools").filter((module) => !templateDeps.includes(module.npm));
|
|
300
|
+
if (officialModules.length === 0) logger.info("All official modules are already included in this template.");
|
|
301
|
+
else {
|
|
302
|
+
const selectedOfficialModules = await logger.prompt("Pick the modules to install:", {
|
|
303
|
+
type: "multiselect",
|
|
304
|
+
options: officialModules.map((module) => ({
|
|
305
|
+
label: `${colors.bold(colors.greenBright(module.npm))} – ${module.description.replace(/\.$/, "")}`,
|
|
306
|
+
value: module.npm
|
|
307
|
+
})),
|
|
308
|
+
required: false
|
|
309
|
+
});
|
|
310
|
+
if (selectedOfficialModules === void 0) process.exit(1);
|
|
311
|
+
if (selectedOfficialModules.length > 0) {
|
|
312
|
+
const modules = selectedOfficialModules;
|
|
313
|
+
const { toInstall, skipped } = filterModules(modules, Object.fromEntries(await Promise.all(modules.map(async (module) => [module, await getModuleDependencies(module)]))));
|
|
314
|
+
if (skipped.length) 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(", ")}`);
|
|
315
|
+
modulesToAdd.push(...toInstall);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (modulesToAdd.length > 0) await runCommand$1(add_default, [
|
|
321
|
+
...modulesToAdd,
|
|
322
|
+
`--cwd=${templateDownloadPath}`,
|
|
323
|
+
ctx.args.install ? "" : "--skipInstall",
|
|
324
|
+
ctx.args.logLevel ? `--logLevel=${ctx.args.logLevel}` : ""
|
|
325
|
+
].filter(Boolean));
|
|
326
|
+
logger.log(`\n✨ Nuxt project has been created with the \`${template.name}\` template. Next steps:`);
|
|
327
|
+
const relativeTemplateDir = relative(process.cwd(), template.dir) || ".";
|
|
328
|
+
const runCmd = selectedPackageManager === "deno" ? "task" : "run";
|
|
329
|
+
const nextSteps = [!ctx.args.shell && relativeTemplateDir.length > 1 && `\`cd ${relativeTemplateDir}\``, `Start development server with \`${selectedPackageManager} ${runCmd} dev\``].filter(Boolean);
|
|
330
|
+
for (const step of nextSteps) logger.log(` › ${step}`);
|
|
331
|
+
if (ctx.args.shell) startShell(template.dir);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
export { init_default as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { resolveModulePath } from "exsolve";
|
|
3
|
+
|
|
4
|
+
//#region ../nuxi/src/utils/kit.ts
|
|
5
|
+
async function loadKit(rootDir) {
|
|
6
|
+
try {
|
|
7
|
+
let kit = await import(pathToFileURL(resolveModulePath("@nuxt/kit", { from: tryResolveNuxt(rootDir) || rootDir })).href);
|
|
8
|
+
if (!kit.writeTypes) kit = {
|
|
9
|
+
...kit,
|
|
10
|
+
writeTypes: () => {
|
|
11
|
+
throw new Error("`writeTypes` is not available in this version of `@nuxt/kit`. Please upgrade to v3.7 or newer.");
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return kit;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (e.toString().includes("Cannot find module '@nuxt/kit'")) throw new Error("nuxi requires `@nuxt/kit` to be installed in your project. Try installing `nuxt` v3+ or `@nuxt/bridge` first.");
|
|
17
|
+
throw e;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function tryResolveNuxt(rootDir) {
|
|
21
|
+
for (const pkg of [
|
|
22
|
+
"nuxt-nightly",
|
|
23
|
+
"nuxt",
|
|
24
|
+
"nuxt3",
|
|
25
|
+
"nuxt-edge"
|
|
26
|
+
]) {
|
|
27
|
+
const path = resolveModulePath(pkg, {
|
|
28
|
+
from: rootDir,
|
|
29
|
+
try: true
|
|
30
|
+
});
|
|
31
|
+
if (path) return path;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { tryResolveNuxt as n, loadKit as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
|
|
3
|
+
//#region ../nuxi/src/commands/module/index.ts
|
|
4
|
+
var module_default = defineCommand({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "module",
|
|
7
|
+
description: "Manage Nuxt modules"
|
|
8
|
+
},
|
|
9
|
+
args: {},
|
|
10
|
+
subCommands: {
|
|
11
|
+
add: () => import("./add-hFFIzkcy.mjs").then((r) => r.default || r),
|
|
12
|
+
search: () => import("./search-DCyXfxzn.mjs").then((r) => r.default || r)
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { module_default as default };
|