Skip to content

Commit

Permalink
chore: update to prettier v3
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 6, 2023
1 parent 38b7498 commit 25dd376
Show file tree
Hide file tree
Showing 33 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"pathe": "^1.1.1",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.0.3",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"scule": "^1.0.0",
"semver": "^7.5.3",
"unbuild": "^1.2.1"
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export default defineCommand({
if (!templates[template]) {
consola.error(
`Template ${template} is not supported. Possible values: ${Object.keys(
templates
).join(', ')}`
templates,
).join(', ')}`,
)
process.exit(1)
}
Expand All @@ -63,7 +63,7 @@ export default defineCommand({
// Ensure not overriding user code
if (!ctx.args.force && existsSync(path)) {
consola.error(
`File exists: ${path} . Use --force to override or use a different name.`
`File exists: ${path} . Use --force to override or use a different name.`,
)
process.exit(1)
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ export default defineCommand({
await fsp.writeFile(
join(analyzeDir, 'meta.json'),
JSON.stringify(meta, null, 2),
'utf-8'
'utf-8',
)

console.info('Analyze results are available at: `' + analyzeDir + '`')
console.warn(
'Do not deploy analyze results! Use `nuxi build` before deploying.'
'Do not deploy analyze results! Use `nuxi build` before deploying.',
)

if (ctx.args.serve !== false && !process.env.CI) {
Expand Down Expand Up @@ -125,8 +125,8 @@ export default defineCommand({
</li>
</ul>
</html>
`
)
`,
),
)

await listen(toNodeListener(app))
Expand Down
4 changes: 2 additions & 2 deletions src/commands/build-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default defineCommand({

const hasLocal = await tryResolveModule(
`${MODULE_BUILDER_PKG}/package.json`,
cwd
cwd,
)

const execArgs = Object.entries({
Expand All @@ -43,7 +43,7 @@ export default defineCommand({
let cmd = 'nuxt-module-build'
if (!hasLocal) {
consola.warn(
`Cannot find locally installed version of \`${MODULE_BUILDER_PKG}\` (>=0.2.0). Falling back to \`npx ${MODULE_BUILDER_PKG}\``
`Cannot find locally installed version of \`${MODULE_BUILDER_PKG}\` (>=0.2.0). Falling back to \`npx ${MODULE_BUILDER_PKG}\``,
)
cmd = 'npx'
execArgs.unshift(MODULE_BUILDER_PKG)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ export default defineCommand({
if (ctx.args.prerender) {
if (!nuxt.options.ssr) {
consola.warn(
'HTML content not prerendered because `ssr: false` was set. You can read more in `https://nuxt.com/docs/getting-started/deployment#static-hosting`.'
'HTML content not prerendered because `ssr: false` was set. You can read more in `https://nuxt.com/docs/getting-started/deployment#static-hosting`.',
)
}
// TODO: revisit later if/when nuxt build --prerender will output hybrid
const dir = nitro?.options.output.publicDir
const publicDir = dir ? relative(process.cwd(), dir) : '.output/public'
consola.success(
`You can now deploy \`${publicDir}\` to any static hosting!`
`You can now deploy \`${publicDir}\` to any static hosting!`,
)
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default defineCommand({
const loadingHandler: RequestListener = async (_req, res) => {
const { loading: loadingTemplate } = await importModule(
'@nuxt/ui-templates',
config.modulesDir
config.modulesDir,
)
res.setHeader('Content-Type', 'text/html; charset=UTF-8')
res.statusCode = 503 // Service Unavailable
Expand Down Expand Up @@ -199,7 +199,7 @@ export default defineCommand({
// Write manifest and also check if we need cache invalidation
if (!isRestart) {
const previousManifest = await loadNuxtManifest(
currentNuxt.options.buildDir
currentNuxt.options.buildDir,
)
const newManifest = await writeNuxtManifest(currentNuxt)
if (
Expand All @@ -215,7 +215,7 @@ export default defineCommand({

distWatcher = chokidar.watch(
resolve(currentNuxt.options.buildDir, 'dist'),
{ ignoreInitial: true, depth: 0 }
{ ignoreInitial: true, depth: 0 },
)
distWatcher.on('unlinkDir', () => {
dLoad(true, '.nuxt/dist directory has been removed')
Expand Down
2 changes: 1 addition & 1 deletion src/commands/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default defineCommand({
{
stdio: 'inherit',
cwd,
}
},
)
},
})
8 changes: 4 additions & 4 deletions src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default defineCommand({
console.log(
`Nuxt project info: ${
copied ? '(copied to clipboard)' : ''
}\n\n${splitter}\n${infoStr}${splitter}\n`
}\n\n${splitter}\n${infoStr}${splitter}\n`,
)

const isNuxt3OrBridge =
Expand All @@ -132,14 +132,14 @@ export default defineCommand({
`👉 Read documentation: ${
isNuxt3OrBridge ? 'https://nuxt.com' : 'https://v2.nuxt.com'
}`,
].join('\n\n') + '\n'
].join('\n\n') + '\n',
)
},
})

function normalizeConfigModule(
module: NuxtModule | string | null | undefined,
rootDir: string
rootDir: string,
): string | null {
if (!module) {
return null
Expand All @@ -165,7 +165,7 @@ function getNuxtConfig(rootDir: string) {
try {
;(globalThis as any).defineNuxtConfig = (c: any) => c
const result = jiti(rootDir, { interopDefault: true, esmResolve: true })(
'./nuxt.config'
'./nuxt.config',
)
delete (globalThis as any).defineNuxtConfig
return result
Expand Down
2 changes: 1 addition & 1 deletion src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default defineCommand({

// Display next steps
consola.log(
`\n✨ Nuxt project has been created with the \`${template.name}\` template. Next steps:`
`\n✨ Nuxt project has been created with the \`${template.name}\` template. Next steps:`,
)

const nextSteps = [
Expand Down
2 changes: 1 addition & 1 deletion src/commands/module/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface NuxtModule {

export async function fetchModules(): Promise<NuxtModule[]> {
const data = await $fetch<NuxtModule[]>(
'https://cdn.jsdelivr.net/npm/@nuxt/modules@latest/modules.json'
'https://cdn.jsdelivr.net/npm/@nuxt/modules@latest/modules.json',
)
return data
}
6 changes: 3 additions & 3 deletions src/commands/module/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineCommand({
await addDependency(npmPackage, { cwd, dev: true }).catch((err) => {
consola.error(err)
consola.error(
`Please manually install \`${npmPackage}\` as a dev dependency`
`Please manually install \`${npmPackage}\` as a dev dependency`,
)
})
}
Expand All @@ -60,7 +60,7 @@ export default defineCommand({
}).catch((err) => {
consola.error(err)
consola.error(
`Please manually add \`${npmPackage}\` to the \`modules\` in \`nuxt.config.ts\``
`Please manually add \`${npmPackage}\` to the \`modules\` in \`nuxt.config.ts\``,
)
})
}
Expand All @@ -71,7 +71,7 @@ export default defineCommand({

async function updateNuxtConfig(
rootDir: string,
update: (config: any) => void
update: (config: any) => void,
) {
let _module: ProxifiedModule
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.ts')
Expand Down
2 changes: 1 addition & 1 deletion src/commands/module/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function findModuleByKeywords(query: string) {
consola.success(
`Found ${results.length} nuxt ${
results.length > 1 ? 'modules' : 'module'
} matching ${cyan(query)}:\n`
} matching ${cyan(query)}:\n`,
)
for (const foundModule of results) {
let maxLength = 0
Expand Down
2 changes: 1 addition & 1 deletion src/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineCommand({
await writeTypes(nuxt)
consola.success(
'Types generated in',
relative(process.cwd(), nuxt.options.buildDir)
relative(process.cwd(), nuxt.options.buildDir),
)
},
})
6 changes: 3 additions & 3 deletions src/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineCommand({
config.srcDir || cwd,
config.nitro.srcDir || 'server',
config.nitro.output?.dir || '.output',
'nitro.json'
'nitro.json',
)
const defaultOutput = resolve(cwd, '.output', 'nitro.json') // for backwards compatibility

Expand All @@ -47,7 +47,7 @@ export default defineCommand({
if (!nitroJSONPath) {
consola.error(
'Cannot find `nitro.json`. Did you run `nuxi build` first? Search path:\n',
nitroJSONPaths
nitroJSONPaths,
)
process.exit(1)
}
Expand All @@ -68,7 +68,7 @@ export default defineCommand({
: existsSync(cwd)
if (envExists) {
consola.info(
'Loading `.env`. This will not be loaded when running the server in production.'
'Loading `.env`. This will not be loaded when running the server in production.',
)
await setupDotenv({ cwd, fileName: ctx.args.dotenv })
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ async function importTestUtils(): Promise<typeof import('@nuxt/test-utils')> {
}
console.error(err)
throw new Error(
'`@nuxt/test-utils-edge` seems missing. Run `npm i -D @nuxt/test-utils-edge` or `yarn add -D @nuxt/test-utils-edge` to install.'
'`@nuxt/test-utils-edge` seems missing. Run `npm i -D @nuxt/test-utils-edge` or `yarn add -D @nuxt/test-utils-edge` to install.',
)
}
2 changes: 1 addition & 1 deletion src/commands/typecheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default defineCommand({
await execa(
'npx',
'-p vue-tsc -p typescript vue-tsc --noEmit'.split(' '),
{ stdio: 'inherit', cwd }
{ stdio: 'inherit', cwd },
)
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/commands/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default defineCommand({
`${packageManager} ${
packageManager === 'yarn' ? 'add' : 'install'
} -D nuxt`,
{ stdio: 'inherit', cwd }
{ stdio: 'inherit', cwd },
)

// Cleanup after upgrade
Expand All @@ -87,14 +87,14 @@ export default defineCommand({
'Successfully upgraded nuxt from',
currentVersion,
'to',
upgradedVersion
upgradedVersion,
)
const commitA = nuxtVersionToGitIdentifier(currentVersion)
const commitB = nuxtVersionToGitIdentifier(upgradedVersion)
if (commitA && commitB) {
consola.info(
'Changelog:',
`https://github.com/nuxt/nuxt/compare/${commitA}...${commitB}`
`https://github.com/nuxt/nuxt/compare/${commitA}...${commitB}`,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runCommand as _runCommand } from 'citty'
export async function runCommand(
name: string,
argv: string[] = process.argv.slice(2),
data: { overrides?: Record<string, any> } = {}
data: { overrides?: Record<string, any> } = {},
) {
argv.push('--no-clear') // Dev

Expand Down
4 changes: 2 additions & 2 deletions src/utils/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function showVersions(cwd: string) {
console.log(
gray(
green(`Nuxt ${bold(nuxtVersion)}`) +
(nitroVersion ? ` with Nitro ${bold(nitroVersion)}` : '')
)
(nitroVersion ? ` with Nitro ${bold(nitroVersion)}` : ''),
),
)
}
2 changes: 1 addition & 1 deletion src/utils/cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function getModulePaths(paths?: string | string[]): string[] {
global.__NUXT_PREPATHS__,
paths,
process.cwd(),
global.__NUXT_PATHS__
global.__NUXT_PATHS__,
)
.filter(Boolean) as string[]
}
Expand Down
10 changes: 5 additions & 5 deletions src/utils/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const wrapReporter = (reporter: ConsolaReporter) =>
// Hide vue-router 404 warnings
if (
msg.startsWith(
'[Vue Router warn]: No match found for location with path'
'[Vue Router warn]: No match found for location with path',
)
) {
return
}
// Suppress warning about native Node.js fetch
if (
msg.includes(
'ExperimentalWarning: The Fetch API is an experimental feature'
'ExperimentalWarning: The Fetch API is an experimental feature',
)
) {
return
Expand All @@ -35,7 +35,7 @@ const wrapReporter = (reporter: ConsolaReporter) =>
}
return reporter.log(logObj, ctx)
},
} satisfies ConsolaReporter)
}) satisfies ConsolaReporter

export function setupGlobalConsole(opts: { dev?: boolean } = {}) {
consola.options.reporters = consola.options.reporters.map(wrapReporter)
Expand All @@ -48,10 +48,10 @@ export function setupGlobalConsole(opts: { dev?: boolean } = {}) {
}

process.on('unhandledRejection', (err) =>
consola.error('[unhandledRejection]', err)
consola.error('[unhandledRejection]', err),
)

process.on('uncaughtException', (err) =>
consola.error('[uncaughtException]', err)
consola.error('[uncaughtException]', err),
)
}
Loading

0 comments on commit 25dd376

Please sign in to comment.