@nuxt/cli-nightly 3.26.0-20250607-210256-59f83b1 → 3.26.0-20250607-215204-1943f84

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 (36) hide show
  1. package/bin/nuxi.mjs +1 -0
  2. package/dist/chunks/add.mjs +308 -290
  3. package/dist/chunks/add2.mjs +291 -307
  4. package/dist/chunks/analyze.mjs +8 -7
  5. package/dist/chunks/build.mjs +11 -11
  6. package/dist/chunks/cleanup.mjs +8 -7
  7. package/dist/chunks/dev-child.mjs +11 -71
  8. package/dist/chunks/dev.mjs +142 -117
  9. package/dist/chunks/devtools.mjs +3 -2
  10. package/dist/chunks/generate.mjs +8 -8
  11. package/dist/chunks/index.mjs +379 -12
  12. package/dist/chunks/index2.mjs +15 -0
  13. package/dist/chunks/info.mjs +8 -6
  14. package/dist/chunks/init.mjs +4 -3
  15. package/dist/chunks/prepare.mjs +7 -6
  16. package/dist/chunks/preview.mjs +6 -5
  17. package/dist/chunks/search.mjs +3 -2
  18. package/dist/chunks/test.mjs +3 -2
  19. package/dist/chunks/typecheck.mjs +6 -6
  20. package/dist/chunks/upgrade.mjs +9 -8
  21. package/dist/dev/index.d.mts +75 -0
  22. package/dist/dev/index.d.ts +75 -0
  23. package/dist/dev/index.mjs +21 -0
  24. package/dist/index.mjs +2 -1
  25. package/dist/shared/{cli-nightly.DTVmTXKJ.mjs → cli-nightly.B4U5vhqQ.mjs} +7 -6
  26. package/dist/shared/cli-nightly.B9AmABr3.mjs +5 -0
  27. package/dist/shared/{cli-nightly.CjK7ZDKA.mjs → cli-nightly.BgFMCBoq.mjs} +9 -10
  28. package/dist/shared/{cli-nightly.DlcAx0De.mjs → cli-nightly.BrKZotr9.mjs} +11 -9
  29. package/dist/shared/{cli-nightly.DDBHWicM.mjs → cli-nightly.Bu_9IHj2.mjs} +2 -2
  30. package/dist/shared/{cli-nightly.DPQxxyDx.mjs → cli-nightly.Cf9T6EbF.mjs} +1 -1
  31. package/dist/shared/{cli-nightly.BnfAj4iy.mjs → cli-nightly.DPmMxQ6h.mjs} +1 -1
  32. package/dist/shared/cli-nightly.Dc8ncNQ_.mjs +27 -0
  33. package/dist/shared/{cli-nightly.DdmGgrsK.mjs → cli-nightly.DkO5RR_e.mjs} +1 -1
  34. package/package.json +2 -1
  35. package/dist/chunks/dev2.mjs +0 -293
  36. package/dist/shared/cli-nightly.COGWopdX.mjs +0 -26
@@ -1,335 +1,319 @@
1
- import * as fs from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { join } from 'node:path';
1
+ import { existsSync, promises } from 'node:fs';
4
2
  import process from 'node:process';
5
- import { updateConfig } from 'c12/update';
6
3
  import { defineCommand } from 'citty';
7
- import { colors } from 'consola/utils';
8
- import { addDependency } from 'nypm';
9
- import { $fetch } from 'ofetch';
10
- import { resolve } from 'pathe';
11
- import { readPackageJSON } from 'pkg-types';
12
- import { satisfies } from 'semver';
13
- import { joinURL } from 'ufo';
14
- import { r as runCommand } from '../shared/cli-nightly.DTVmTXKJ.mjs';
15
- import { l as logLevelArgs, c as cwdArgs, a as logger } from '../shared/cli-nightly.CjK7ZDKA.mjs';
16
- import { f as fetchModules, g as getNuxtVersion, c as checkNuxtCompatibility } from '../shared/cli-nightly.C935N1ss.mjs';
4
+ import { resolve, extname, dirname } from 'pathe';
5
+ import { l as loadKit } from '../shared/cli-nightly.BrKZotr9.mjs';
6
+ import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
7
+ import { pascalCase, camelCase } from 'scule';
8
+ import { a as logLevelArgs, c as cwdArgs } from '../shared/cli-nightly.BgFMCBoq.mjs';
17
9
  import 'node:url';
18
- import 'node:crypto';
19
- import 'std-env';
20
- import '../shared/cli-nightly.DPQxxyDx.mjs';
10
+ import 'exsolve';
21
11
  import 'consola';
12
+ import 'node:path';
13
+ import 'std-env';
14
+
15
+ const httpMethods = [
16
+ "connect",
17
+ "delete",
18
+ "get",
19
+ "head",
20
+ "options",
21
+ "post",
22
+ "put",
23
+ "trace",
24
+ "patch"
25
+ ];
26
+ const api = ({ name, args, nuxtOptions }) => {
27
+ return {
28
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, `api/${name}${applySuffix(args, httpMethods, "method")}.ts`),
29
+ contents: `
30
+ export default defineEventHandler(event => {
31
+ return 'Hello ${name}'
32
+ })
33
+ `
34
+ };
35
+ };
36
+
37
+ const app = ({ args, nuxtOptions }) => ({
38
+ path: resolve(nuxtOptions.srcDir, "app.vue"),
39
+ contents: args.pages ? `
40
+ <script setup lang="ts"><\/script>
41
+
42
+ <template>
43
+ <div>
44
+ <NuxtLayout>
45
+ <NuxtPage/>
46
+ </NuxtLayout>
47
+ </div>
48
+ </template>
49
+
50
+ <style scoped></style>
51
+ ` : `
52
+ <script setup lang="ts"><\/script>
53
+
54
+ <template>
55
+ <div>
56
+ <h1>Hello World!</h1>
57
+ </div>
58
+ </template>
59
+
60
+ <style scoped></style>
61
+ `
62
+ });
63
+
64
+ const appConfig = ({ nuxtOptions }) => ({
65
+ path: resolve(nuxtOptions.srcDir, "app.config.ts"),
66
+ contents: `
67
+ export default defineAppConfig({})
68
+ `
69
+ });
70
+
71
+ const component = ({ name, args, nuxtOptions }) => ({
72
+ path: resolve(nuxtOptions.srcDir, `components/${name}${applySuffix(
73
+ args,
74
+ ["client", "server"],
75
+ "mode"
76
+ )}.vue`),
77
+ contents: `
78
+ <script setup lang="ts"><\/script>
79
+
80
+ <template>
81
+ <div>
82
+ Component: ${name}
83
+ </div>
84
+ </template>
85
+
86
+ <style scoped></style>
87
+ `
88
+ });
89
+
90
+ const composable = ({ name, nuxtOptions }) => {
91
+ const nameWithoutUsePrefix = name.replace(/^use-?/, "");
92
+ const nameWithUsePrefix = `use${pascalCase(nameWithoutUsePrefix)}`;
93
+ return {
94
+ path: resolve(nuxtOptions.srcDir, `composables/${name}.ts`),
95
+ contents: `
96
+ export const ${nameWithUsePrefix} = () => {
97
+ return ref()
98
+ }
99
+ `
100
+ };
101
+ };
102
+
103
+ const error = ({ nuxtOptions }) => ({
104
+ path: resolve(nuxtOptions.srcDir, "error.vue"),
105
+ contents: `
106
+ <script setup lang="ts">
107
+ import type { NuxtError } from '#app'
108
+
109
+ const props = defineProps({
110
+ error: Object as () => NuxtError
111
+ })
112
+ <\/script>
113
+
114
+ <template>
115
+ <div>
116
+ <h1>{{ error.statusCode }}</h1>
117
+ <NuxtLink to="/">Go back home</NuxtLink>
118
+ </div>
119
+ </template>
120
+
121
+ <style scoped></style>
122
+ `
123
+ });
124
+
125
+ const layer = ({ name, nuxtOptions }) => {
126
+ return {
127
+ path: resolve(nuxtOptions.srcDir, `layers/${name}/nuxt.config.ts`),
128
+ contents: `
129
+ export default defineNuxtConfig({})
130
+ `
131
+ };
132
+ };
133
+
134
+ const layout = ({ name, nuxtOptions }) => ({
135
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.dir.layouts, `${name}.vue`),
136
+ contents: `
137
+ <script setup lang="ts"><\/script>
138
+
139
+ <template>
140
+ <div>
141
+ Layout: ${name}
142
+ <slot />
143
+ </div>
144
+ </template>
145
+
146
+ <style scoped></style>
147
+ `
148
+ });
149
+
150
+ const middleware = ({ name, args, nuxtOptions }) => ({
151
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.dir.middleware, `${name}${applySuffix(args, ["global"])}.ts`),
152
+ contents: `
153
+ export default defineNuxtRouteMiddleware((to, from) => {})
154
+ `
155
+ });
156
+
157
+ const module = ({ name, nuxtOptions }) => ({
158
+ path: resolve(nuxtOptions.rootDir, "modules", `${name}.ts`),
159
+ contents: `
160
+ import { defineNuxtModule } from 'nuxt/kit'
161
+
162
+ export default defineNuxtModule({
163
+ meta: {
164
+ name: '${name}'
165
+ },
166
+ setup () {}
167
+ })
168
+ `
169
+ });
170
+
171
+ const page = ({ name, nuxtOptions }) => ({
172
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.dir.pages, `${name}.vue`),
173
+ contents: `
174
+ <script setup lang="ts"><\/script>
175
+
176
+ <template>
177
+ <div>
178
+ Page: ${name}
179
+ </div>
180
+ </template>
181
+
182
+ <style scoped></style>
183
+ `
184
+ });
185
+
186
+ const plugin = ({ name, args, nuxtOptions }) => ({
187
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.dir.plugins, `${name}${applySuffix(args, ["client", "server"], "mode")}.ts`),
188
+ contents: `
189
+ export default defineNuxtPlugin(nuxtApp => {})
190
+ `
191
+ });
192
+
193
+ const serverMiddleware = ({ name, nuxtOptions }) => ({
194
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, "middleware", `${name}.ts`),
195
+ contents: `
196
+ export default defineEventHandler(event => {})
197
+ `
198
+ });
199
+
200
+ const serverPlugin = ({ name, nuxtOptions }) => ({
201
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, "plugins", `${name}.ts`),
202
+ contents: `
203
+ export default defineNitroPlugin(nitroApp => {})
204
+ `
205
+ });
206
+
207
+ const serverRoute = ({ name, args, nuxtOptions }) => ({
208
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, args.api ? "api" : "routes", `${name}.ts`),
209
+ contents: `
210
+ export default defineEventHandler(event => {})
211
+ `
212
+ });
213
+
214
+ const serverUtil = ({ name, nuxtOptions }) => ({
215
+ path: resolve(nuxtOptions.srcDir, nuxtOptions.serverDir, "utils", `${name}.ts`),
216
+ contents: `
217
+ export function ${camelCase(name)}() {}
218
+ `
219
+ });
22
220
 
221
+ const templates = {
222
+ "api": api,
223
+ "app": app,
224
+ "app-config": appConfig,
225
+ "component": component,
226
+ "composable": composable,
227
+ "error": error,
228
+ "layer": layer,
229
+ "layout": layout,
230
+ "middleware": middleware,
231
+ "module": module,
232
+ "page": page,
233
+ "plugin": plugin,
234
+ "server-middleware": serverMiddleware,
235
+ "server-plugin": serverPlugin,
236
+ "server-route": serverRoute,
237
+ "server-util": serverUtil
238
+ };
239
+ function applySuffix(args, suffixes, unwrapFrom) {
240
+ let suffix = "";
241
+ for (const s of suffixes) {
242
+ if (args[s]) {
243
+ suffix += `.${s}`;
244
+ }
245
+ }
246
+ if (unwrapFrom && args[unwrapFrom] && suffixes.includes(args[unwrapFrom])) {
247
+ suffix += `.${args[unwrapFrom]}`;
248
+ }
249
+ return suffix;
250
+ }
251
+
252
+ const templateNames = Object.keys(templates);
23
253
  const add = defineCommand({
24
254
  meta: {
25
255
  name: "add",
26
- description: "Add Nuxt modules"
256
+ description: "Create a new template file."
27
257
  },
28
258
  args: {
29
259
  ...cwdArgs,
30
260
  ...logLevelArgs,
31
- moduleName: {
32
- type: "positional",
33
- description: "Specify one or more modules to install by name, separated by spaces"
34
- },
35
- skipInstall: {
261
+ force: {
36
262
  type: "boolean",
37
- description: "Skip npm install"
263
+ description: "Force override file if it already exists",
264
+ default: false
38
265
  },
39
- skipConfig: {
40
- type: "boolean",
41
- description: "Skip nuxt.config.ts update"
266
+ template: {
267
+ type: "positional",
268
+ required: true,
269
+ valueHint: templateNames.join("|"),
270
+ description: `Specify which template to generate`
42
271
  },
43
- dev: {
44
- type: "boolean",
45
- description: "Install modules as dev dependencies"
272
+ name: {
273
+ type: "positional",
274
+ required: true,
275
+ description: "Specify name of the generated file"
46
276
  }
47
277
  },
48
- async setup(ctx) {
278
+ async run(ctx) {
49
279
  const cwd = resolve(ctx.args.cwd);
50
- const modules = ctx.args._.map((e) => e.trim()).filter(Boolean);
51
- const projectPkg = await readPackageJSON(cwd).catch(() => ({}));
52
- if (!projectPkg.dependencies?.nuxt && !projectPkg.devDependencies?.nuxt) {
53
- logger.warn(`No \`nuxt\` dependency detected in \`${cwd}\`.`);
54
- const shouldContinue = await logger.prompt(
55
- `Do you want to continue anyway?`,
56
- {
57
- type: "confirm",
58
- initial: false,
59
- cancel: "default"
60
- }
280
+ const templateName = ctx.args.template;
281
+ if (!templateNames.includes(templateName)) {
282
+ logger.error(
283
+ `Template ${templateName} is not supported. Possible values: ${Object.keys(
284
+ templates
285
+ ).join(", ")}`
61
286
  );
62
- if (shouldContinue !== true) {
63
- process.exit(1);
64
- }
287
+ process.exit(1);
65
288
  }
66
- const maybeResolvedModules = await Promise.all(modules.map((moduleName) => resolveModule(moduleName, cwd)));
67
- const resolvedModules = maybeResolvedModules.filter((x) => x != null);
68
- logger.info(`Resolved \`${resolvedModules.map((x) => x.pkgName).join("`, `")}\`, adding module${resolvedModules.length > 1 ? "s" : ""}...`);
69
- await addModules(resolvedModules, { ...ctx.args, cwd }, projectPkg);
70
- if (!ctx.args.skipInstall) {
71
- const args = Object.entries(ctx.args).filter(([k]) => k in cwdArgs || k in logLevelArgs).map(([k, v]) => `--${k}=${v}`);
72
- await runCommand("prepare", args);
289
+ const ext = extname(ctx.args.name);
290
+ const name = ext === ".vue" || ext === ".ts" ? ctx.args.name.replace(ext, "") : ctx.args.name;
291
+ if (!name) {
292
+ logger.error("name argument is missing!");
293
+ process.exit(1);
73
294
  }
74
- }
75
- });
76
- async function addModules(modules, { skipInstall, skipConfig, cwd, dev }, projectPkg) {
77
- if (!skipInstall) {
78
- const installedModules = [];
79
- const notInstalledModules = [];
80
- const dependencies = /* @__PURE__ */ new Set([
81
- ...Object.keys(projectPkg.dependencies || {}),
82
- ...Object.keys(projectPkg.devDependencies || {})
83
- ]);
84
- for (const module of modules) {
85
- if (dependencies.has(module.pkgName)) {
86
- installedModules.push(module);
87
- } else {
88
- notInstalledModules.push(module);
89
- }
90
- }
91
- if (installedModules.length > 0) {
92
- const installedModulesList = installedModules.map((module) => module.pkgName).join("`, `");
93
- const are = installedModules.length > 1 ? "are" : "is";
94
- logger.info(`\`${installedModulesList}\` ${are} already installed`);
95
- }
96
- if (notInstalledModules.length > 0) {
97
- const isDev = Boolean(projectPkg.devDependencies?.nuxt) || dev;
98
- const notInstalledModulesList = notInstalledModules.map((module) => module.pkg).join("`, `");
99
- const dependency = notInstalledModules.length > 1 ? "dependencies" : "dependency";
100
- const a = notInstalledModules.length > 1 ? "" : " a";
101
- logger.info(`Installing \`${notInstalledModulesList}\` as${a}${isDev ? " development" : ""} ${dependency}`);
102
- const res = await addDependency(notInstalledModules.map((module) => module.pkg), {
103
- cwd,
104
- dev: isDev,
105
- installPeerDependencies: true
106
- }).then(() => true).catch(
107
- (error) => {
108
- logger.error(error);
109
- const failedModulesList = notInstalledModules.map((module) => colors.cyan(module.pkg)).join("`, `");
110
- const s = notInstalledModules.length > 1 ? "s" : "";
111
- return logger.prompt(`Install failed for \`${failedModulesList}\`. Do you want to continue adding the module${s} to ${colors.cyan("nuxt.config")}?`, {
112
- type: "confirm",
113
- initial: false,
114
- cancel: "default"
115
- });
116
- }
117
- );
118
- if (res !== true) {
119
- return;
120
- }
121
- }
122
- }
123
- if (!skipConfig) {
124
- await updateConfig({
125
- cwd,
126
- configFile: "nuxt.config",
127
- async onCreate() {
128
- logger.info(`Creating \`nuxt.config.ts\``);
129
- return getDefaultNuxtConfig();
130
- },
131
- async onUpdate(config) {
132
- if (!config.modules) {
133
- config.modules = [];
134
- }
135
- for (const resolved of modules) {
136
- if (config.modules.includes(resolved.pkgName)) {
137
- logger.info(`\`${resolved.pkgName}\` is already in the \`modules\``);
138
- continue;
139
- }
140
- logger.info(`Adding \`${resolved.pkgName}\` to the \`modules\``);
141
- config.modules.push(resolved.pkgName);
142
- }
143
- }
144
- }).catch((error) => {
145
- logger.error(`Failed to update \`nuxt.config\`: ${error.message}`);
146
- logger.error(`Please manually add \`${modules.map((module) => module.pkgName).join("`, `")}\` to the \`modules\` in \`nuxt.config.ts\``);
147
- return null;
148
- });
149
- }
150
- }
151
- function getDefaultNuxtConfig() {
152
- return `
153
- // https://nuxt.com/docs/api/configuration/nuxt-config
154
- export default defineNuxtConfig({
155
- modules: []
156
- })`;
157
- }
158
- const packageRegex = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?([a-z0-9-~][a-z0-9-._~]*)(@[^@]+)?$/;
159
- async function resolveModule(moduleName, cwd) {
160
- let pkgName = moduleName;
161
- let pkgVersion;
162
- const reMatch = moduleName.match(packageRegex);
163
- if (reMatch) {
164
- if (reMatch[3]) {
165
- pkgName = `${reMatch[1] || ""}${reMatch[2] || ""}`;
166
- pkgVersion = reMatch[3].slice(1);
167
- }
168
- } else {
169
- logger.error(`Invalid package name \`${pkgName}\`.`);
170
- return false;
171
- }
172
- const modulesDB = await fetchModules().catch((err) => {
173
- logger.warn(`Cannot search in the Nuxt Modules database: ${err}`);
174
- return [];
175
- });
176
- const matchedModule = modulesDB.find(
177
- (module) => module.name === moduleName || pkgVersion && module.name === pkgName || module.npm === pkgName || module.aliases?.includes(pkgName)
178
- );
179
- if (matchedModule?.npm) {
180
- pkgName = matchedModule.npm;
181
- }
182
- if (matchedModule && matchedModule.compatibility.nuxt) {
183
- const nuxtVersion = await getNuxtVersion(cwd);
184
- if (!checkNuxtCompatibility(matchedModule, nuxtVersion)) {
185
- logger.warn(
186
- `The module \`${pkgName}\` is not compatible with Nuxt \`${nuxtVersion}\` (requires \`${matchedModule.compatibility.nuxt}\`)`
187
- );
188
- const shouldContinue = await logger.prompt(
189
- "Do you want to continue installing incompatible version?",
190
- {
191
- type: "confirm",
192
- initial: false,
193
- cancel: "default"
194
- }
295
+ const kit = await loadKit(cwd);
296
+ const config = await kit.loadNuxtConfig({ cwd });
297
+ const template = templates[templateName];
298
+ const res = template({ name, args: ctx.args, nuxtOptions: config });
299
+ if (!ctx.args.force && existsSync(res.path)) {
300
+ logger.error(
301
+ `File exists: ${res.path} . Use --force to override or use a different name.`
195
302
  );
196
- if (!shouldContinue) {
197
- return false;
198
- }
303
+ process.exit(1);
199
304
  }
200
- const versionMap = matchedModule.compatibility.versionMap;
201
- if (versionMap) {
202
- for (const [_nuxtVersion, _moduleVersion] of Object.entries(versionMap)) {
203
- if (satisfies(nuxtVersion, _nuxtVersion)) {
204
- if (!pkgVersion) {
205
- pkgVersion = _moduleVersion;
206
- } else {
207
- logger.warn(
208
- `Recommended version of \`${pkgName}\` for Nuxt \`${nuxtVersion}\` is \`${_moduleVersion}\` but you have requested \`${pkgVersion}\``
209
- );
210
- pkgVersion = await logger.prompt("Choose a version:", {
211
- type: "select",
212
- options: [_moduleVersion, pkgVersion],
213
- cancel: "undefined"
214
- });
215
- if (!pkgVersion) {
216
- return false;
217
- }
218
- }
219
- break;
220
- }
221
- }
222
- }
223
- }
224
- let version = pkgVersion || "latest";
225
- const pkgScope = pkgName.startsWith("@") ? pkgName.split("/")[0] : null;
226
- const meta = await detectNpmRegistry(pkgScope);
227
- const headers = {};
228
- if (meta.authToken) {
229
- headers.Authorization = `Bearer ${meta.authToken}`;
230
- }
231
- const pkgDetails = await $fetch(joinURL(meta.registry, `${pkgName}`), { headers });
232
- if (pkgDetails["dist-tags"]?.[version]) {
233
- version = pkgDetails["dist-tags"][version];
234
- } else {
235
- version = Object.keys(pkgDetails.versions)?.findLast((v) => satisfies(v, version)) || version;
236
- }
237
- const pkg = pkgDetails.versions[version];
238
- const pkgDependencies = Object.assign(
239
- pkg.dependencies || {},
240
- pkg.devDependencies || {}
241
- );
242
- if (!pkgDependencies.nuxt && !pkgDependencies["nuxt-edge"] && !pkgDependencies["@nuxt/kit"]) {
243
- logger.warn(`It seems that \`${pkgName}\` is not a Nuxt module.`);
244
- const shouldContinue = await logger.prompt(
245
- `Do you want to continue installing ${colors.cyan(pkgName)} anyway?`,
246
- {
247
- type: "confirm",
248
- initial: false,
249
- cancel: "default"
305
+ const parentDir = dirname(res.path);
306
+ if (!existsSync(parentDir)) {
307
+ logger.info("Creating directory", parentDir);
308
+ if (templateName === "page") {
309
+ logger.info("This enables vue-router functionality!");
250
310
  }
251
- );
252
- if (!shouldContinue) {
253
- return false;
311
+ await promises.mkdir(parentDir, { recursive: true });
254
312
  }
313
+ await promises.writeFile(res.path, `${res.contents.trim()}
314
+ `);
315
+ logger.info(`\u{1FA84} Generated a new ${templateName} in ${res.path}`);
255
316
  }
256
- return {
257
- nuxtModule: matchedModule,
258
- pkg: `${pkgName}@${version}`,
259
- pkgName,
260
- pkgVersion: version
261
- };
262
- }
263
- function getNpmrcPaths() {
264
- const userNpmrcPath = join(homedir(), ".npmrc");
265
- const cwdNpmrcPath = join(process.cwd(), ".npmrc");
266
- return [cwdNpmrcPath, userNpmrcPath];
267
- }
268
- async function getAuthToken(registry) {
269
- const paths = getNpmrcPaths();
270
- const authTokenRegex = new RegExp(`^//${registry.replace(/^https?:\/\//, "").replace(/\/$/, "")}/:_authToken=(.+)$`, "m");
271
- for (const npmrcPath of paths) {
272
- let fd;
273
- try {
274
- fd = await fs.promises.open(npmrcPath, "r");
275
- if (await fd.stat().then((r) => r.isFile())) {
276
- const npmrcContent = await fd.readFile("utf-8");
277
- const authTokenMatch = npmrcContent.match(authTokenRegex)?.[1];
278
- if (authTokenMatch) {
279
- return authTokenMatch.trim();
280
- }
281
- }
282
- } catch {
283
- } finally {
284
- await fd?.close();
285
- }
286
- }
287
- return null;
288
- }
289
- async function detectNpmRegistry(scope) {
290
- const registry = await getRegistry(scope);
291
- const authToken = await getAuthToken(registry);
292
- return {
293
- registry,
294
- authToken
295
- };
296
- }
297
- async function getRegistry(scope) {
298
- if (process.env.COREPACK_NPM_REGISTRY) {
299
- return process.env.COREPACK_NPM_REGISTRY;
300
- }
301
- const registry = await getRegistryFromFile(getNpmrcPaths(), scope);
302
- if (registry) {
303
- process.env.COREPACK_NPM_REGISTRY = registry;
304
- }
305
- return registry || "https://registry.npmjs.org";
306
- }
307
- async function getRegistryFromFile(paths, scope) {
308
- for (const npmrcPath of paths) {
309
- let fd;
310
- try {
311
- fd = await fs.promises.open(npmrcPath, "r");
312
- if (await fd.stat().then((r) => r.isFile())) {
313
- const npmrcContent = await fd.readFile("utf-8");
314
- if (scope) {
315
- const scopedRegex = new RegExp(`^${scope}:registry=(.+)$`, "m");
316
- const scopedMatch = npmrcContent.match(scopedRegex)?.[1];
317
- if (scopedMatch) {
318
- return scopedMatch.trim();
319
- }
320
- }
321
- const defaultRegex = /^\s*registry=(.+)$/m;
322
- const defaultMatch = npmrcContent.match(defaultRegex)?.[1];
323
- if (defaultMatch) {
324
- return defaultMatch.trim();
325
- }
326
- }
327
- } catch {
328
- } finally {
329
- await fd?.close();
330
- }
331
- }
332
- return null;
333
- }
317
+ });
334
318
 
335
319
  export { add as default };
@@ -5,15 +5,16 @@ import { defu } from 'defu';
5
5
  import { createApp, lazyEventHandler, eventHandler, toNodeListener } from 'h3';
6
6
  import { listen } from 'listhen';
7
7
  import { resolve, join } from 'pathe';
8
- import { o as overrideEnv } from '../shared/cli-nightly.DdmGgrsK.mjs';
9
- import { c as clearDir } from '../shared/cli-nightly.BnfAj4iy.mjs';
10
- import { l as loadKit } from '../shared/cli-nightly.DlcAx0De.mjs';
11
- import { d as dotEnvArgs, b as legacyRootDirArgs, l as logLevelArgs, c as cwdArgs, a as logger } from '../shared/cli-nightly.CjK7ZDKA.mjs';
12
- import 'jiti';
8
+ import { o as overrideEnv } from '../shared/cli-nightly.DkO5RR_e.mjs';
9
+ import { c as clearDir } from '../shared/cli-nightly.DPmMxQ6h.mjs';
10
+ import { l as loadKit } from '../shared/cli-nightly.BrKZotr9.mjs';
11
+ import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
12
+ import { d as dotEnvArgs, l as legacyRootDirArgs, a as logLevelArgs, c as cwdArgs } from '../shared/cli-nightly.BgFMCBoq.mjs';
13
+ import 'node:url';
14
+ import 'exsolve';
15
+ import 'consola';
13
16
  import 'node:path';
14
17
  import 'std-env';
15
- import 'consola';
16
- import 'node:url';
17
18
 
18
19
  const analyze = defineCommand({
19
20
  meta: {
@@ -1,19 +1,19 @@
1
1
  import process from 'node:process';
2
2
  import { defineCommand } from 'citty';
3
3
  import { resolve, relative } from 'pathe';
4
- import { s as showVersions } from '../shared/cli-nightly.COGWopdX.mjs';
5
- import { o as overrideEnv } from '../shared/cli-nightly.DdmGgrsK.mjs';
6
- import { a as clearBuildDir } from '../shared/cli-nightly.BnfAj4iy.mjs';
7
- import { l as loadKit } from '../shared/cli-nightly.DlcAx0De.mjs';
8
- import { b as legacyRootDirArgs, e as envNameArgs, d as dotEnvArgs, l as logLevelArgs, c as cwdArgs, a as logger } from '../shared/cli-nightly.CjK7ZDKA.mjs';
9
- import 'consola/utils';
10
- import 'pkg-types';
4
+ import { s as showVersions } from '../shared/cli-nightly.Dc8ncNQ_.mjs';
5
+ import { o as overrideEnv } from '../shared/cli-nightly.DkO5RR_e.mjs';
6
+ import { a as clearBuildDir } from '../shared/cli-nightly.DPmMxQ6h.mjs';
7
+ import { l as loadKit } from '../shared/cli-nightly.BrKZotr9.mjs';
8
+ import { l as logger } from '../shared/cli-nightly.B9AmABr3.mjs';
9
+ import { l as legacyRootDirArgs, e as envNameArgs, d as dotEnvArgs, a as logLevelArgs, c as cwdArgs } from '../shared/cli-nightly.BgFMCBoq.mjs';
11
10
  import 'node:fs';
12
- import 'jiti';
11
+ import 'consola/utils';
12
+ import 'exsolve';
13
+ import 'node:url';
14
+ import 'consola';
13
15
  import 'node:path';
14
16
  import 'std-env';
15
- import 'consola';
16
- import 'node:url';
17
17
 
18
18
  const buildCommand = defineCommand({
19
19
  meta: {
@@ -38,7 +38,7 @@ const buildCommand = defineCommand({
38
38
  async run(ctx) {
39
39
  overrideEnv("production");
40
40
  const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
41
- await showVersions(cwd);
41
+ showVersions(cwd);
42
42
  const kit = await loadKit(cwd);
43
43
  const nuxt = await kit.loadNuxt({
44
44
  cwd,