Skip to content

Commit

Permalink
add back withZuplo wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-lee committed Jan 15, 2025
1 parent 2405001 commit 070458f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/zudoku/src/config/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { RollupOutput, RollupWatcher } from "rollup";
import { tsImport } from "tsx/esm/api";
import { withZuplo } from "../zuplo/with-zuplo.js";
import { ConfigWithMeta } from "./common.js";
import { CommonConfig, validateCommonConfig } from "./validators/common.js";
import { validateConfig } from "./validators/validate.js";
Expand Down Expand Up @@ -117,6 +118,9 @@ async function loadDevPortalConfig<TConfig extends CommonConfig>(
// 2. Replace $env() placeholders with actual environment
config = replaceEnvVariables(config, envVars);

// 3. Add Zuplo to the config
config = withZuplo(config);

return config;
}

Expand Down
1 change: 1 addition & 0 deletions packages/zudoku/src/config/validators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export const CommonConfigSchema = z.object({
apiKeys: ApiKeysSchema,
redirects: z.array(Redirect),
sitemap: SiteMapSchema,
isZuplo: z.boolean().optional(),
});

export const refine = (
Expand Down
9 changes: 5 additions & 4 deletions packages/zudoku/src/vite/plugin-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "node:fs/promises";
import path from "node:path";
import { tsImport } from "tsx/esm/api";
import hashit from "object-hash";
import { tsImport } from "tsx/esm/api";
import { type Plugin } from "vite";
import yaml from "yaml";
import { type ZudokuPluginOptions } from "../config/config.js";
Expand All @@ -10,21 +10,22 @@ import type {
ApiCatalogItem,
ApiCatalogPluginOptions,
} from "../lib/plugins/api-catalog/index.js";
import { ZuploEnv } from "../zuplo/env.js";

const viteApiPlugin = async (
getConfig: () => ZudokuPluginOptions,
): Promise<Plugin> => {
const virtualModuleId = "virtual:zudoku-api-plugins";
const resolvedVirtualModuleId = "\0" + virtualModuleId;

const initialConfig = getConfig();

// TODO: For now this is Zuplo specific, but we should make it more generic in the future.
// Following options might be possible:
// a) Have a processors only file
// b) Have a build related config (e.g. Vite, Rehype, Remark, etc.)
const zuploProcessors = ZuploEnv.isZuplo
const zuploProcessors = initialConfig.isZuplo
? await tsImport("../zuplo/with-zuplo-processors.ts", import.meta.url)
.then((m) => m.default(getConfig().rootDir))
.then((m) => m.default(initialConfig.rootDir))
.catch((e) => {
// eslint-disable-next-line no-console
console.warn("Failed to load Zuplo processors", e);
Expand Down

0 comments on commit 070458f

Please sign in to comment.