From a78901a97bdecf080f7935ffcad61fb7286b2322 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 30 Nov 2023 15:57:53 +0100 Subject: [PATCH 1/2] refactor: include framework name in more build packages --- src/build.ts | 14 +++++--------- src/options.ts | 2 +- src/types/nitro.ts | 2 +- src/utils/index.ts | 7 +++++++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/build.ts b/src/build.ts index a0134474c9..fa2b9c218c 100644 --- a/src/build.ts +++ b/src/build.ts @@ -26,6 +26,7 @@ import { writeFile, isDirectory, resolvePath as resolveNitroPath, + nitroServerName, } from "./utils"; import { GLOB_SCAN_PATTERN, scanHandlers } from "./scan"; import type { Nitro, NitroBuildInfo } from "./types"; @@ -397,7 +398,7 @@ async function _build(nitro: Nitro, rollupConfig: RollupConfig) { if (!nitro.options.static) { nitro.logger.info( - `Building Nitro Server (preset: \`${nitro.options.preset}\`)` + `Building ${nitroServerName(nitro)} (preset: \`${nitro.options.preset}\`)` ); const build = await rollup.rollup(rollupConfig).catch((error) => { nitro.logger.error(formatRollupError(error)); @@ -424,7 +425,7 @@ async function _build(nitro: Nitro, rollupConfig: RollupConfig) { await writeFile(buildInfoPath, JSON.stringify(buildInfo, null, 2)); if (!nitro.options.static) { - nitro.logger.success("Nitro server built"); + nitro.logger.success(`${nitroServerName(nitro)} built`); if (nitro.options.logLevel > 1) { process.stdout.write( await generateFSTree(nitro.options.output.serverDir, { @@ -484,14 +485,9 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { case "END": { nitro.hooks.callHook("compiled", nitro); - if (nitro.options.logging.devBuildSuccess) { - let message = `Nitro Server`; - if (nitro.options.framework.name !== "nitro") { - const _name = upperFirst(nitro.options.framework.name); - message = `${_name} ${message}`; - } + if (nitro.options.logging.buildSuccess) { nitro.logger.success( - `${message} built`, + `${nitroServerName(nitro)} built`, start ? `in ${Date.now() - start} ms` : "" ); } diff --git a/src/options.ts b/src/options.ts index cfda908289..0c63f93b25 100644 --- a/src/options.ts +++ b/src/options.ts @@ -73,7 +73,7 @@ const NitroDefaults: NitroConfig = { // Logging logging: { compressedSizes: true, - devBuildSuccess: true, + buildSuccess: true, }, // Routing diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 5b8f418890..41f51f4e7d 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -309,7 +309,7 @@ export interface NitroOptions extends PresetOptions { // Logging logging: { compressedSizes: boolean; - devBuildSuccess: boolean; + buildSuccess: boolean; }; // Routing diff --git a/src/utils/index.ts b/src/utils/index.ts index 1396e01439..07105cd54b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -8,6 +8,7 @@ import chalk from "chalk"; import { getProperty } from "dot-prop"; import { provider } from "std-env"; import type { ProviderName } from "std-env"; +import { upperFirst } from "scule"; import { KebabCase, Nitro } from "../types"; import type * as _PRESETS from "../presets"; @@ -231,3 +232,9 @@ export function provideFallbackValues(obj: Record) { } } } + +export function nitroServerName(nitro: Nitro) { + return nitro.options.framework.name === "nitro" + ? "Nitro Server" + : `${upperFirst(nitro.options.framework.name)} Nitro server`; +} From 290f761300cefc4ddbd86b5511f6c6ba6d6224fc Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 30 Nov 2023 16:00:06 +0100 Subject: [PATCH 2/2] respect config --- src/build.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/build.ts b/src/build.ts index fa2b9c218c..ada0467848 100644 --- a/src/build.ts +++ b/src/build.ts @@ -425,7 +425,9 @@ async function _build(nitro: Nitro, rollupConfig: RollupConfig) { await writeFile(buildInfoPath, JSON.stringify(buildInfo, null, 2)); if (!nitro.options.static) { - nitro.logger.success(`${nitroServerName(nitro)} built`); + if (nitro.options.logging.buildSuccess) { + nitro.logger.success(`${nitroServerName(nitro)} built`); + } if (nitro.options.logLevel > 1) { process.stdout.write( await generateFSTree(nitro.options.output.serverDir, {