Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: include framework name in more build packages #1973

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
Expand All @@ -424,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("Nitro server 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, {
Expand Down Expand Up @@ -484,14 +487,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` : ""
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const NitroDefaults: NitroConfig = {
// Logging
logging: {
compressedSizes: true,
devBuildSuccess: true,
buildSuccess: true,
},

// Routing
Expand Down
2 changes: 1 addition & 1 deletion src/types/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export interface NitroOptions extends PresetOptions {
// Logging
logging: {
compressedSizes: boolean;
devBuildSuccess: boolean;
buildSuccess: boolean;
};

// Routing
Expand Down
7 changes: 7 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -231,3 +232,9 @@ export function provideFallbackValues(obj: Record<string, any>) {
}
}
}

export function nitroServerName(nitro: Nitro) {
return nitro.options.framework.name === "nitro"
? "Nitro Server"
: `${upperFirst(nitro.options.framework.name)} Nitro server`;
}