From 52455b83a535a7d1afc8e40c301494d4f885c4d7 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 25 Nov 2023 22:57:34 +0100 Subject: [PATCH 1/9] feat: show framework info on dev server build success --- src/build.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/build.ts b/src/build.ts index fb8f1dc9cf..bcf0b207b1 100644 --- a/src/build.ts +++ b/src/build.ts @@ -482,8 +482,9 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { // Finished building all bundles case "END": { nitro.hooks.callHook("compiled", nitro); + const { framework } = nitro.options; nitro.logger.success( - "Nitro built", + `${framework.name} v${framework.version} built`, start ? `in ${Date.now() - start} ms` : "" ); nitro.hooks.callHook("dev:reload"); From 9fc6f624027350fe986f83a7769c350c4466e2cb Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 27 Nov 2023 15:36:11 +0100 Subject: [PATCH 2/9] feat: show Nitro & Framework info on build success --- src/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.ts b/src/build.ts index bcf0b207b1..8ec532ae4c 100644 --- a/src/build.ts +++ b/src/build.ts @@ -484,7 +484,7 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { nitro.hooks.callHook("compiled", nitro); const { framework } = nitro.options; nitro.logger.success( - `${framework.name} v${framework.version} built`, + `Nitro Server v${nitroVersion} built for ${framework.name} v${framework.version}`, start ? `in ${Date.now() - start} ms` : "" ); nitro.hooks.callHook("dev:reload"); From 93cd75969a893adb0b73060f8f53a2d592c1925d Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 27 Nov 2023 15:42:31 +0100 Subject: [PATCH 3/9] refactor: check if current framework is "nitro" --- playground/nitro.config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/playground/nitro.config.ts b/playground/nitro.config.ts index 2a9dd131e6..4007767e3a 100644 --- a/playground/nitro.config.ts +++ b/playground/nitro.config.ts @@ -1 +1,10 @@ -export default defineNitroConfig({}); +export default defineNitroConfig({ + // framework: { + // name: 'McFly', + // version: '0.0.1' + // }, + publicAssets: [{ + dir: 'something' + }] +}); + From 4ff88f656deddb1be55cff1c7a2804bf77506d7c Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 27 Nov 2023 16:12:33 +0100 Subject: [PATCH 4/9] refactor: push correct change --- playground/nitro.config.ts | 11 +---------- src/build.ts | 8 +++++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/playground/nitro.config.ts b/playground/nitro.config.ts index 4007767e3a..2a9dd131e6 100644 --- a/playground/nitro.config.ts +++ b/playground/nitro.config.ts @@ -1,10 +1 @@ -export default defineNitroConfig({ - // framework: { - // name: 'McFly', - // version: '0.0.1' - // }, - publicAssets: [{ - dir: 'something' - }] -}); - +export default defineNitroConfig({}); diff --git a/src/build.ts b/src/build.ts index 8ec532ae4c..f37d8b40ea 100644 --- a/src/build.ts +++ b/src/build.ts @@ -483,8 +483,14 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { case "END": { nitro.hooks.callHook("compiled", nitro); const { framework } = nitro.options; + let successReport = `Nitro Server v${nitroVersion} built`; + + if (framework.name !== 'nitro') { + successReport += ` for ${framework.name} v${framework.version}`; + } + nitro.logger.success( - `Nitro Server v${nitroVersion} built for ${framework.name} v${framework.version}`, + successReport, start ? `in ${Date.now() - start} ms` : "" ); nitro.hooks.callHook("dev:reload"); From b6e3e73ee6d95081d32dbde5e0eaffc980caba3b Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 27 Nov 2023 18:17:56 +0100 Subject: [PATCH 5/9] feat: implement showBuildSuccess option --- playground/nitro.config.ts | 12 +++++++++++- playground/routes/index.ts | 2 +- src/build.ts | 18 ++++++++++++++---- src/types/nitro.ts | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/playground/nitro.config.ts b/playground/nitro.config.ts index 2a9dd131e6..7331c8af0e 100644 --- a/playground/nitro.config.ts +++ b/playground/nitro.config.ts @@ -1 +1,11 @@ -export default defineNitroConfig({}); +export default defineNitroConfig({ + framework: { + name: 'McFly', + version: '0.13.3', + showBuildSuccess: 'verbose' + }, + publicAssets: [{ + dir: 'something' + }] +}); + diff --git a/playground/routes/index.ts b/playground/routes/index.ts index 8fffd8bfbd..d9fce4a557 100644 --- a/playground/routes/index.ts +++ b/playground/routes/index.ts @@ -1,4 +1,4 @@ // eslint-disable-next-line require-await export default eventHandler(async (event) => { - return {}; + return { hello: "world" }; }); diff --git a/src/build.ts b/src/build.ts index f37d8b40ea..9e0ad68ca8 100644 --- a/src/build.ts +++ b/src/build.ts @@ -483,14 +483,24 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { case "END": { nitro.hooks.callHook("compiled", nitro); const { framework } = nitro.options; - let successReport = `Nitro Server v${nitroVersion} built`; + let successReport = `Nitro Server`; - if (framework.name !== 'nitro') { - successReport += ` for ${framework.name} v${framework.version}`; + if (framework.showBuildSuccess) { + if (framework.showBuildSuccess === 'verbose') { + successReport += ` v${nitroVersion}`; + } + + if (framework.name !== 'nitro') { + successReport += ` for ${framework.name}`; + } + + if (framework.version !== nitroVersion && framework.showBuildSuccess === 'verbose') { + successReport += ` for v${framework.version}`; + } } nitro.logger.success( - successReport, + `${successReport} built`, start ? `in ${Date.now() - start} ms` : "" ); nitro.hooks.callHook("dev:reload"); diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 5f15ea261a..63eec7658f 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -201,6 +201,7 @@ export interface NitroFrameworkInfo { // eslint-disable-next-line @typescript-eslint/ban-types name?: "nitro" | (string & {}); version?: string; + showBuildSuccess?: boolean | 'verbose'; } /** Build info written to `.output/nitro.json` or `.nitro/dev/nitro.json` */ From 103328b84457d944a31dff7df091b0b826df7644 Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 27 Nov 2023 18:19:13 +0100 Subject: [PATCH 6/9] fix: undo test config --- playground/nitro.config.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/playground/nitro.config.ts b/playground/nitro.config.ts index 7331c8af0e..2a9dd131e6 100644 --- a/playground/nitro.config.ts +++ b/playground/nitro.config.ts @@ -1,11 +1 @@ -export default defineNitroConfig({ - framework: { - name: 'McFly', - version: '0.13.3', - showBuildSuccess: 'verbose' - }, - publicAssets: [{ - dir: 'something' - }] -}); - +export default defineNitroConfig({}); From 773b7a907f7c71036e150e068b485aab2c969650 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 30 Nov 2023 11:43:27 +0100 Subject: [PATCH 7/9] update --- src/build.ts | 27 ++++++++++----------------- src/options.ts | 1 + src/types/nitro.ts | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/build.ts b/src/build.ts index 9e0ad68ca8..a61dd387ac 100644 --- a/src/build.ts +++ b/src/build.ts @@ -17,6 +17,7 @@ import { parseNodeModulePath, resolvePath, } from "mlly"; +import { upperFirst } from "scule"; import { version as nitroVersion } from "../package.json"; import { generateFSTree } from "./utils/tree"; import { getRollupConfig, RollupConfig } from "./rollup/config"; @@ -482,27 +483,19 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { // Finished building all bundles case "END": { nitro.hooks.callHook("compiled", nitro); - const { framework } = nitro.options; - let successReport = `Nitro Server`; - if (framework.showBuildSuccess) { - if (framework.showBuildSuccess === 'verbose') { - successReport += ` v${nitroVersion}`; - } - - if (framework.name !== 'nitro') { - successReport += ` for ${framework.name}`; - } - - if (framework.version !== nitroVersion && framework.showBuildSuccess === 'verbose') { - successReport += ` for v${framework.version}`; + if (nitro.options.logging.showBuildSuccess) { + let successReport = `Nitro Server`; + if (nitro.options.framework.name !== "nitro") { + const _name = upperFirst(nitro.options.framework.name); + successReport = `${_name} ${successReport}`; } + nitro.logger.success( + `${successReport} built`, + start ? `in ${Date.now() - start} ms` : "" + ); } - nitro.logger.success( - `${successReport} built`, - start ? `in ${Date.now() - start} ms` : "" - ); nitro.hooks.callHook("dev:reload"); return; } diff --git a/src/options.ts b/src/options.ts index de1f4a4e48..c42f91d6c8 100644 --- a/src/options.ts +++ b/src/options.ts @@ -73,6 +73,7 @@ const NitroDefaults: NitroConfig = { // Logging logging: { compressedSizes: true, + showBuildSuccess: true, }, // Routing diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 63eec7658f..77cb102bbf 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -201,7 +201,6 @@ export interface NitroFrameworkInfo { // eslint-disable-next-line @typescript-eslint/ban-types name?: "nitro" | (string & {}); version?: string; - showBuildSuccess?: boolean | 'verbose'; } /** Build info written to `.output/nitro.json` or `.nitro/dev/nitro.json` */ @@ -310,6 +309,7 @@ export interface NitroOptions extends PresetOptions { // Logging logging: { compressedSizes: boolean; + showBuildSuccess: boolean; }; // Routing From 42082a57f2dd7ecbb4d5595ebe0264ea866ac3c2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 30 Nov 2023 11:43:49 +0100 Subject: [PATCH 8/9] revert playground change --- playground/routes/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/routes/index.ts b/playground/routes/index.ts index d9fce4a557..8fffd8bfbd 100644 --- a/playground/routes/index.ts +++ b/playground/routes/index.ts @@ -1,4 +1,4 @@ // eslint-disable-next-line require-await export default eventHandler(async (event) => { - return { hello: "world" }; + return {}; }); From a17c5911d770f95b1c088998ae9a15769025dec6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 30 Nov 2023 15:46:07 +0100 Subject: [PATCH 9/9] rename to `devBuildSuccess` --- src/build.ts | 8 ++++---- src/options.ts | 2 +- src/types/nitro.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/build.ts b/src/build.ts index a61dd387ac..a0134474c9 100644 --- a/src/build.ts +++ b/src/build.ts @@ -484,14 +484,14 @@ function startRollupWatcher(nitro: Nitro, rollupConfig: RollupConfig) { case "END": { nitro.hooks.callHook("compiled", nitro); - if (nitro.options.logging.showBuildSuccess) { - let successReport = `Nitro Server`; + if (nitro.options.logging.devBuildSuccess) { + let message = `Nitro Server`; if (nitro.options.framework.name !== "nitro") { const _name = upperFirst(nitro.options.framework.name); - successReport = `${_name} ${successReport}`; + message = `${_name} ${message}`; } nitro.logger.success( - `${successReport} built`, + `${message} built`, start ? `in ${Date.now() - start} ms` : "" ); } diff --git a/src/options.ts b/src/options.ts index c42f91d6c8..cfda908289 100644 --- a/src/options.ts +++ b/src/options.ts @@ -73,7 +73,7 @@ const NitroDefaults: NitroConfig = { // Logging logging: { compressedSizes: true, - showBuildSuccess: true, + devBuildSuccess: true, }, // Routing diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 77cb102bbf..344ab31ce9 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -309,7 +309,7 @@ export interface NitroOptions extends PresetOptions { // Logging logging: { compressedSizes: boolean; - showBuildSuccess: boolean; + devBuildSuccess: boolean; }; // Routing