Skip to content

Commit 99c0bb8

Browse files
committed
chore: remove narration comments
1 parent b814f4f commit 99c0bb8

11 files changed

Lines changed: 2 additions & 58 deletions

File tree

packages/create-nuxt/src/init.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ export default defineCommand({
226226
if (!ctx.args.template || !ctx.args.dir) {
227227
const defaultTemplates = await import('../../nuxt-cli/src/data/templates').then(r => r.templates)
228228
if (ctx.args.offline || ctx.args.preferOffline) {
229-
// In offline mode, use static templates directly
230229
availableTemplates = defaultTemplates
231230
}
232231
else {
@@ -297,7 +296,6 @@ export default defineCommand({
297296
prompted = true
298297
}
299298

300-
// Fallback to default if still not set
301299
templateName ||= DEFAULT_TEMPLATE_NAME
302300

303301
if (typeof templateName !== 'string') {
@@ -329,8 +327,6 @@ export default defineCommand({
329327

330328
let shouldForce = Boolean(ctx.args.force)
331329

332-
// Prompt the user if the template download directory already exists
333-
// when no `--force` flag is provided
334330
const shouldVerify = !shouldForce && existsSync(templateDownloadPath)
335331
if (shouldVerify) {
336332
if (isNonInteractive) {
@@ -371,14 +367,12 @@ export default defineCommand({
371367
break
372368
}
373369

374-
// 'Abort'
375370
case 'abort':
376371
default:
377372
process.exit(1)
378373
}
379374
}
380375

381-
// Download template
382376
let template: DownloadTemplateResult
383377

384378
const registry = process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY
@@ -482,7 +476,6 @@ export default defineCommand({
482476
const recoveryCommands: string[] = []
483477

484478
const currentPackageManager = detectCurrentPackageManager()
485-
// Resolve package manager
486479
const packageManagerArg = ctx.args.packageManager as PackageManagerName
487480
const packageManagerSelectOptions = packageManagerOptions.map(pm => ({
488481
label: pm,
@@ -545,7 +538,6 @@ export default defineCommand({
545538
logger.info(`Created ${styleText('cyan', '.yarnrc.yml')} with ${styleText('cyan', 'nodeLinker: node-modules')}, as Nuxt cannot resolve its modules under Yarn's Plug'n'Play linker.`)
546539
}
547540

548-
// Determine if we should init git
549541
let gitInit: boolean | undefined = ctx.args.gitInit === 'false' as unknown ? false : ctx.args.gitInit
550542
if (gitInit === undefined) {
551543
const result = await confirm({
@@ -561,8 +553,6 @@ export default defineCommand({
561553
prompted = true
562554
}
563555

564-
// Install project dependencies and initialize git
565-
// or skip installation based on the '--no-install' flag
566556
if (!installRequested || skipInstallOnConflict) {
567557
if (!skipInstallOnConflict) {
568558
logger.info('Skipping install dependencies step.')
@@ -652,13 +642,9 @@ export default defineCommand({
652642
logger.warn(`Skipping module installation. Add ${requestedModules.map(mod => styleText('cyan', mod)).join(', ')} with ${styleText('cyan', 'nuxt module add')} once dependencies are installed.`)
653643
}
654644
}
655-
656-
// Get modules from arg (if provided)
657645
else if (ctx.args.modules !== undefined) {
658646
modulesToAdd.push(...requestedModules)
659647
}
660-
661-
// ...or offer to browse and install modules (if not offline nor non-interactive)
662648
else if (!ctx.args.offline && !ctx.args.preferOffline && !isNonInteractive) {
663649
// Requested before the prompt so the list is ready if the user says yes,
664650
// but a failure is only reported to users who asked for it (and never
@@ -731,7 +717,6 @@ export default defineCommand({
731717
}
732718
}
733719

734-
// Add modules
735720
if (modulesToAdd.length > 0) {
736721
const args: string[] = [
737722
...modulesToAdd,

packages/nuxi/src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ const _main = defineCommand({
5555
setupGlobalConsole({ dev: command === 'dev' })
5656
debug(`Running \`nuxt ${command}\` command`)
5757

58-
// Check Node.js version in background
5958
let backgroundTasks: Promise<any> | undefined
6059
if (provider !== 'stackblitz') {
6160
backgroundTasks = Promise.all([
6261
checkEngines(),
6362
]).catch(err => logger.error(String(err)))
6463
}
6564

66-
// Avoid background check to fix prompt issues
65+
// Awaited so the engine warning cannot land in the middle of a prompt.
6766
if (command === 'init') {
6867
await backgroundTasks
6968
}

packages/nuxt-cli/src/commands/dev.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ const command = defineCommand({
154154
},
155155
},
156156
async run(ctx) {
157-
// Prepare
158157
const requestedCwd = resolveRootDir(ctx.args)
159158
const cwd = await preflight({ cwd: requestedCwd })
160159
if (cwd !== requestedCwd) {
@@ -190,7 +189,6 @@ const command = defineCommand({
190189
await openInspector(inspect)
191190
}
192191

193-
// Start the initial dev server in-process with listener
194192
const { listener, close, reload, onRestart, onReady, onFileChange } = await initialize({ cwd, args: ctx.args, handoverFrom: takeover.action === 'taken' ? takeover.pid : undefined }, {
195193
data: ctx.data,
196194
listenOverrides,
@@ -226,7 +224,6 @@ const command = defineCommand({
226224
pool.startWarming()
227225
})
228226

229-
// On hard restart, use a fork from the pool
230227
// Whatever is serving the app right now: this process, then each fork in turn.
231228
let closeCurrent = close
232229
let currentPid = process.pid
@@ -261,7 +258,6 @@ const command = defineCommand({
261258
// serialised whenever the inspector is open.
262259
const handover = reusePort && !inspect
263260

264-
// Get a fork from the pool (warm if available, cold otherwise)
265261
const context: NuxtDevContext = {
266262
cwd,
267263
args: ctx.args,
@@ -283,7 +279,6 @@ const command = defineCommand({
283279
? { port: listener.address.port, handover: true }
284280
: undefined,
285281
onMessage: (message) => {
286-
// Handle IPC messages from the fork
287282
if (message.type === 'nuxt:internal:dev:ready' || message.type === 'nuxt:internal:dev:loading:error') {
288283
serving = true
289284
if (message.type === 'nuxt:internal:dev:ready' && startTime) {
@@ -295,7 +290,6 @@ const command = defineCommand({
295290
// leaves the outgoing server in place.
296291
}
297292
else if (message.type === 'nuxt:internal:dev:restart') {
298-
// Fork is requesting another restart
299293
void restartWithFork(message.reason)
300294
}
301295
else if (message.type === 'nuxt:internal:dev:rejection') {

packages/nuxt-cli/src/commands/module/add.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ async function resolveModule(moduleName: string, cwd: string, modulesDB: NuxtMod
376376
if (matchedModule && matchedModule.compatibility.nuxt) {
377377
const nuxtVersion = await getProjectNuxtVersion()
378378

379-
// Check for Module Compatibility
380379
if (!checkNuxtCompatibility(matchedModule, nuxtVersion)) {
381380
logger.warn(
382381
`The module ${styleText('cyan', pkgName)} is not compatible with Nuxt ${styleText('cyan', nuxtVersion)} (requires ${styleText('cyan', matchedModule.compatibility.nuxt)})`,
@@ -390,7 +389,6 @@ async function resolveModule(moduleName: string, cwd: string, modulesDB: NuxtMod
390389
}
391390
}
392391

393-
// Match corresponding version of module for local Nuxt version
394392
const versionMap = matchedModule.compatibility.versionMap
395393
if (versionMap) {
396394
for (const [_nuxtVersion, _moduleVersion] of Object.entries(versionMap)) {
@@ -420,7 +418,6 @@ async function resolveModule(moduleName: string, cwd: string, modulesDB: NuxtMod
420418
}
421419
}
422420

423-
// Fetch package on npm
424421
let version = pkgVersion || 'latest'
425422
const pkgScope = pkgName.startsWith('@') ? pkgName.split('/')[0]! : null
426423
const meta: RegistryMeta = await detectNpmRegistry(pkgScope, cwd)
@@ -440,7 +437,6 @@ async function resolveModule(moduleName: string, cwd: string, modulesDB: NuxtMod
440437
return false
441438
}
442439

443-
// fully resolve the version
444440
if (pkgDetails['dist-tags']?.[version]) {
445441
version = pkgDetails['dist-tags'][version]
446442
}

packages/nuxt-cli/src/dev/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function formatErrorMessage(error: unknown): string {
2020

2121
/**
2222
* Hand an unhandled rejection to the parent process and stop this one, unless
23-
* it is only a client that went away — that is traffic, not a crash, and the
23+
* it is only a client that went away. That is traffic, not a crash, and the
2424
* session has to survive it.
2525
*/
2626
export function createRejectionHandler(report: (message: string) => void, stop: () => void): (reason: unknown) => void {
@@ -42,7 +42,6 @@ interface InitializeOptions {
4242
showBanner?: boolean
4343
}
4444

45-
// IPC Hooks
4645
class IPC {
4746
enabled = !!process.send && !process.title?.includes('vitest') && process.env.__NUXT__FORK
4847
#shutdown?: () => Promise<void>
@@ -186,7 +185,6 @@ export async function initialize(devContext: NuxtDevContext, ctx: InitializeOpti
186185
})
187186
}
188187

189-
// Init server
190188
await devServer.init()
191189

192190
if (process.env.DEBUG) {

packages/nuxt-cli/src/dev/pool.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export class ForkPool {
7070
}
7171
this.warming = true
7272

73-
// Start warming forks up to pool size
7473
for (let i = 0; i < this.poolSize; i++) {
7574
this.warmFork()
7675
}
@@ -165,7 +164,6 @@ export class ForkPool {
165164
fork.state = 'ready'
166165
}
167166
}).catch(() => {
168-
// Fork failed to warm, remove from pool
169167
this.removeFork(fork)
170168
})
171169
this.pool.push(fork)
@@ -201,20 +199,17 @@ export class ForkPool {
201199
serving: false,
202200
}
203201

204-
// Listen for fork-ready message
205202
childProc.on('message', (message: NuxtDevIPCMessage) => {
206203
if (message.type === 'nuxt:internal:dev:fork-ready') {
207204
readyResolve()
208205
}
209206
})
210207

211-
// Handle errors
212208
childProc.on('error', (err) => {
213209
readyReject(err)
214210
this.removeFork(pooledFork)
215211
})
216212

217-
// Handle unexpected exit
218213
childProc.on('close', (errorCode) => {
219214
// A fork can exit without ever emitting `error` (a throw while loading the
220215
// entry, or a kill), which would leave `ready` pending forever.
@@ -223,7 +218,6 @@ export class ForkPool {
223218
// Ending the session on the crash of the process that holds the listener is
224219
// silent otherwise, leaving no clue as to what stopped the dev server.
225220
logger.error(`The dev server process (PID ${childProc.pid}) exited with code ${errorCode}.`)
226-
// Active fork crashed
227221
process.exit(errorCode)
228222
}
229223
this.removeFork(pooledFork)

packages/nuxt-cli/src/dev/utils.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
399399
try {
400400
this.closeWatchers()
401401

402-
// For reloads, we already have a listener, so use the existing flow
403402
await this.#load(reload, reason)
404403

405404
this.#loadingError = undefined
@@ -538,11 +537,9 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
538537
throw new Error('Nuxt must be loaded before creating listener')
539538
}
540539

541-
// Merge config values with CLI overrides
542540
const listenOptions = this.#resolveListenOptions()
543541
this.listener = await listen(this.handler, listenOptions)
544542

545-
// Apply devServer overrides based on whether listener is public
546543
if (listenOptions.public) {
547544
this.#currentNuxt.options.devServer.cors = { origin: '*' }
548545
if (this.#currentNuxt.options.vite?.server) {
@@ -551,7 +548,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
551548
return
552549
}
553550

554-
// Get listener URLs for configuring allowed hosts
555551
const urls = this.listener.getURLs().map(({ url }) => url)
556552
if (urls.length > 0) {
557553
this.#currentNuxt.options.vite = defu(this.#currentNuxt.options.vite, {
@@ -574,7 +570,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
574570

575571
const hostname = overrides.hostname ?? nuxtConfig.devServer?.host
576572

577-
// Resolve public flag
578573
const isPublic = provider === 'codesandbox' || (overrides.public ?? (isPublicHostname(hostname) ? true : undefined))
579574

580575
// `--https` (or its absence) wins over the config; `https.*` arguments and
@@ -583,7 +578,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
583578
const https = (httpsEnabled ?? !!nuxtConfig.devServer?.https)
584579
&& defu(typeof overrides.https === 'object' ? overrides.https : {}, httpsFromConfig)
585580

586-
// Resolve baseURL
587581
const baseURL = nuxtConfig.app?.baseURL?.startsWith?.('./')
588582
? nuxtConfig.app.baseURL.slice(1)
589583
: nuxtConfig.app?.baseURL
@@ -607,7 +601,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
607601
this.emit('change')
608602
})
609603

610-
// Connect Vite HMR
611604
if (!process.env.NUXI_DISABLE_VITE_HMR) {
612605
this.#currentNuxt.hooks.hook('vite:extend', ({ config }) => {
613606
if (config.server) {
@@ -616,13 +609,11 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
616609
})
617610
}
618611

619-
// Remove websocket handlers on close
620612
this.#currentNuxt.hooks.hookOnce('close', () => {
621613
this.#closeWebSocketConnections()
622614
this.listener.server.removeAllListeners('upgrade')
623615
})
624616

625-
// Write manifest and also check if we need cache invalidation
626617
if (!reload) {
627618
const previousManifest = await loadNuxtManifest(this.#currentNuxt.options.buildDir)
628619
const newManifest = resolveNuxtManifest(this.#currentNuxt)
@@ -666,7 +657,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
666657
}
667658
nuxt.server.upgrade(req, socket as any, head)
668659

669-
// Track WebSocket connections
670660
this.#websocketConnections.add(socket)
671661
socket.on('close', () => {
672662
this.#websocketConnections.delete(socket)
@@ -700,7 +690,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
700690
throw new Error('Nitro server has not been initialized.')
701691
}
702692

703-
// Watch dist directory
704693
const distDir = join(this.#currentNuxt.options.buildDir, 'dist')
705694
await mkdir(distDir, { recursive: true })
706695
this.#fileChangeTracker.prime(distDir)
@@ -727,7 +716,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
727716
this.#handler = toNodeListener(this.#currentNuxt.server.app)
728717
}
729718

730-
// Emit ready with the server URL
731719
const serverUrl = getAddressURL(addr, !!this.listener.https).replace(TRAILING_SLASH_RE, '')
732720

733721
// Re-acquire if buildDir changed (nuxt.config edits can move it on reload);
@@ -835,7 +823,6 @@ export class NuxtDevServer extends EventEmitter<DevServerEventMap> {
835823
}
836824
}
837825

838-
// Configure the Nuxt instance (shared logic with initial load)
839826
await this.#initializeNuxt(!!reload)
840827
}
841828

packages/nuxt-cli/src/utils/console.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { isRemotePeerError } from './errors'
88
import { debug } from './logger'
99
import { trackOutputSpacing } from './stdout'
1010

11-
// Filter out unwanted logs
1211
// TODO: Use better API from consola for intercepting logs
1312
function wrapReporter(reporter: ConsolaReporter) {
1413
return ({
@@ -33,7 +32,6 @@ export function setupGlobalConsole(opts: { dev?: boolean } = {}) {
3332
consola.options.formatOptions.date = false
3433
consola.options.reporters = consola.options.reporters.map(wrapReporter)
3534

36-
// Wrap all console logs with consola for better DX
3735
if (opts.dev) {
3836
trackOutputSpacing()
3937
consola.wrapAll()

packages/nuxt-cli/src/utils/formatting.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export function formatInfoBox(infoObj: Record<string, string | undefined>): stri
5151
return [label, val || '-'] as const
5252
})
5353

54-
// get maximum width of terminal
5554
const terminalWidth = Math.max(process.stdout.columns || 80, firstColumnLength) - 8 /* box padding + extra margin */
5655

5756
let boxStr = ''
@@ -64,7 +63,6 @@ export function formatInfoBox(infoObj: Record<string, string | undefined>): stri
6463

6564
let boxRowLength = firstColumnLength
6665

67-
// Split by spaces and wrap as needed
6866
const words = formattedValue.split(' ')
6967
let currentLine = ''
7068

@@ -73,7 +71,6 @@ export function formatInfoBox(infoObj: Record<string, string | undefined>): stri
7371
const spaceLength = currentLine ? 1 : 0
7472

7573
if (boxRowLength + wordLength + spaceLength > terminalWidth) {
76-
// Wrap to next line
7774
if (currentLine) {
7875
boxStr += styleText('cyan', currentLine)
7976
}

0 commit comments

Comments
 (0)