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

feat: include preset config in .output/nitro.json #2807

Merged
merged 2 commits into from
Oct 21, 2024
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
2 changes: 2 additions & 0 deletions scripts/gen-presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ ${presetsWithType
.join("\n")}
}

export const presetsWithConfig = ${JSON.stringify(presetsWithType.map((p) => camelCase(p)))} as const;

export type PresetName = ${names.map((name) => `"${name}"`).join(" | ")};

export type PresetNameInput = ${names
Expand Down
6 changes: 6 additions & 0 deletions src/core/build/prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { version as nitroVersion } from "nitropack/meta";
import type { Nitro, NitroBuildInfo, RollupConfig } from "nitropack/types";
import { dirname, join, relative, resolve } from "pathe";
import * as rollup from "rollup";
import { presetsWithConfig } from "../../presets/_types.gen";
import { scanHandlers } from "../scan";
import { generateFSTree } from "../utils/fs-tree";
import { nitroServerName } from "../utils/nitro";
Expand Down Expand Up @@ -45,6 +46,11 @@ export async function buildProduction(
preview: nitro.options.commands.preview,
deploy: nitro.options.commands.deploy,
},
config: {
...Object.fromEntries(
presetsWithConfig.map((key) => [key, nitro.options[key]])
),
},
};
await writeFile(buildInfoPath, JSON.stringify(buildInfo, null, 2));

Expand Down
2 changes: 2 additions & 0 deletions src/presets/_types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface PresetOptions {
vercel: VercelOptions;
}

export const presetsWithConfig = ["awsAmplify","awsLambda","azure","cloudflare","firebase","netlify","vercel"] as const;

export type PresetName = "alwaysdata" | "aws-amplify" | "aws-lambda" | "azure" | "azure-functions" | "azure-swa" | "base-worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-durable" | "cloudflare-module" | "cloudflare-module-legacy" | "cloudflare-pages" | "cloudflare-pages-static" | "cloudflare-worker" | "deno" | "deno-deploy" | "deno-server" | "digital-ocean" | "edgio" | "firebase" | "flight-control" | "genezio" | "github-pages" | "gitlab-pages" | "heroku" | "iis" | "iis-handler" | "iis-node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlify-edge" | "netlify-legacy" | "netlify-static" | "nitro-dev" | "nitro-prerender" | "node" | "node-cluster" | "node-listener" | "node-server" | "platform-sh" | "render-com" | "service-worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercel-static" | "winterjs" | "zeabur" | "zeabur-static" | "zerops" | "zerops-static";

export type PresetNameInput = "alwaysdata" | "aws-amplify" | "awsAmplify" | "aws_amplify" | "aws-lambda" | "awsLambda" | "aws_lambda" | "azure" | "azure-functions" | "azureFunctions" | "azure_functions" | "azure-swa" | "azureSwa" | "azure_swa" | "base-worker" | "baseWorker" | "base_worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-durable" | "cloudflareDurable" | "cloudflare_durable" | "cloudflare-module" | "cloudflareModule" | "cloudflare_module" | "cloudflare-module-legacy" | "cloudflareModuleLegacy" | "cloudflare_module_legacy" | "cloudflare-pages" | "cloudflarePages" | "cloudflare_pages" | "cloudflare-pages-static" | "cloudflarePagesStatic" | "cloudflare_pages_static" | "cloudflare-worker" | "cloudflareWorker" | "cloudflare_worker" | "deno" | "deno-deploy" | "denoDeploy" | "deno_deploy" | "deno-server" | "denoServer" | "deno_server" | "digital-ocean" | "digitalOcean" | "digital_ocean" | "edgio" | "firebase" | "flight-control" | "flightControl" | "flight_control" | "genezio" | "github-pages" | "githubPages" | "github_pages" | "gitlab-pages" | "gitlabPages" | "gitlab_pages" | "heroku" | "iis" | "iis-handler" | "iisHandler" | "iis_handler" | "iis-node" | "iisNode" | "iis_node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlifyBuilder" | "netlify_builder" | "netlify-edge" | "netlifyEdge" | "netlify_edge" | "netlify-legacy" | "netlifyLegacy" | "netlify_legacy" | "netlify-static" | "netlifyStatic" | "netlify_static" | "nitro-dev" | "nitroDev" | "nitro_dev" | "nitro-prerender" | "nitroPrerender" | "nitro_prerender" | "node" | "node-cluster" | "nodeCluster" | "node_cluster" | "node-listener" | "nodeListener" | "node_listener" | "node-server" | "nodeServer" | "node_server" | "platform-sh" | "platformSh" | "platform_sh" | "render-com" | "renderCom" | "render_com" | "service-worker" | "serviceWorker" | "service_worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercelEdge" | "vercel_edge" | "vercel-static" | "vercelStatic" | "vercel_static" | "winterjs" | "zeabur" | "zeabur-static" | "zeaburStatic" | "zeabur_static" | "zerops" | "zerops-static" | "zeropsStatic" | "zerops_static" | (string & {});
3 changes: 2 additions & 1 deletion src/types/nitro.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ConsolaInstance } from "consola";
import type { RouterMethod } from "h3";
import type { Hookable } from "hookable";
import type { PresetName } from "nitropack/presets";
import type { PresetName, PresetOptions } from "nitropack/presets";
import type { Unimport } from "unimport";
import type { Storage } from "unstorage";
import type { NitroConfig, NitroOptions } from "./config";
Expand Down Expand Up @@ -56,4 +56,5 @@ export interface NitroBuildInfo {
pid: number;
workerAddress: { host: string; port: number; socketPath?: string };
};
config?: Partial<PresetOptions>;
}